query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
when :no_raise => true and the validation fails, an array is returned listing the 'deviations'
def test_no_raise r = Ruote.filter( [ { 'field' => 'x', 't' => 'hash', 'has' => 'a' } ], { 'x' => %w[ a b c ] }, :no_raise => true) assert_equal( [ [ { "has" => "a", "field" => "x", "t" => "hash"}, "x", [ "a", "b", "c" ] ] ], r) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_invalids\n\t\treturn @invalids\n\tend", "def validations\n []\n end", "def get_validate data\n data.values.flatten\n end", "def validate(_options = 0)\n []\n end", "def invalidations\n if @solver and invalidations = @solver.invalidations\n invalidations\n else\n []\n end\n end", "def validations_for_diff\n []\n end", "def validate()\n validation_errors = []\n @expected_results.each_pair do |key,expected_result|\n result_key = expected_result[\"population_ids\"].dup\n\n reported_result, errors = extract_results_by_ids(expected_result['measure_id'], result_key)\n @reported_results[key] = reported_result\n validation_errors.concat match_calculation_results(expected_result,reported_result)\n end\n\n validation_errors\n end", "def _validation_errors()\n errors = []\n @flows.each_value { |f| errors += f._validation_errors() }\n errors\n end", "def errors\n validate_or_get_results :errors\n end", "def validate\n [perform_validation].flatten.compact\n end", "def useful_validations_for_measure_type\n measure_types = selected_measure_types\n if measure_types[:discrete] == false\n Validation.all - Validation.all.measure_type('discrete')\n elsif measure_types[:continuous] == false\n Validation.all - Validation.all.measure_type('continuous')\n else\n Validation.all.to_a\n end\n end", "def errors\n run_validation\n @errors\n end", "def errors\n @validator ? @validator.errors : []\n end", "def warnings\n @validator ? @validator.warnings : []\n end", "def validate(result)\n if result.ntuples == 0\n raise NotFound\n elsif result.ntuples > 1\n raise TooManyChoices\n end\n end", "def errors\n result = []\n result.push(:title) unless valid_string? @title\n result.push(:author) unless valid_string? @author\n result.push(:release_date) unless valid_date? @release_date\n result.push(:publisher) unless valid_string? @publisher\n result.push(:isbn) unless valid_integer? @isbn\n result\n end", "def contents_with_errors\n contents.select(&:essence_validation_failed?)\n end", "def validations\n {}\n end", "def errors\n execute_lifecycle(:before, :validation) if self.respond_to? :execute_lifecycle\n errs = []\n self.class.validations.each do |validation|\n errs << (validation.is_a?(Proc) ? self.instance_exec(&validation) : self.send(validation))\n end\n # remove nils\n errs = errs.flatten.select { |x| !x.nil? }\n errs\n end", "def validate\n # add errors if not validate\n end", "def validate\n [] # schema.validate(@doc)\n end", "def determine_useful_validations\n useful_checks = [\n useful_validations_for_qrda_type,\n useful_validations_for_measure_type\n # TODO: Add useful_validations_for_performance_rate\n ]\n useful_checks.inject(:&)\n end", "def invalid_items\n items.select { |item| item.errors.present? }\n end", "def validation_errors\n errors = []\n ErrorCompiler.with_errors(errors) do |e|\n check_schools_consistency_in_each_round(e)\n check_legitimate_progress_through_rounds(e)\n check_wildcards(e)\n end\n errors\n end", "def incorrect_options\n Survey::Question.where(section_id: sections.collect(&:id)).map(&:incorrect_options).flatten\n end", "def findErrors(params)\n errors = []\n if !isNumericVal(params[:cost])\n errors << \"GP must be numeric value\"\n else\n if params[:cost].to_f < 0\n errors << \"GP must be a postivie value Nice try though ;)\"\n end\n end\n return errors\n end", "def validated; end", "def check\n errors = []\n \n @dsls_for_checking.each do |dsl|\n dsl_errors = dsl.check\n errors.push [dsl.id, dsl_errors] unless dsl_errors.blank?\n end\n \n errors\n end", "def validation_error_check_discrepancies(ar, fields)\n\t\tmsgs = []\n\t\t# get the list of fields that have errors (err_fields)\n\t\terr_fields = []\n\t\tar.errors.each {|k,v| err_fields << k}\n\t\t# identify fields missing from the record’s errors \n\t\tmissing_errors = []\n\t\tfields.each do |field_name|\n\t\t\tmissing_errors << field_name unless err_fields.include?(field_name) #if ar.errors[field_name].blank?\n\t\tend\n\t\tif missing_errors.length > 0\n\t\t\tmsgs << \"missing validation error for fields #{missing_errors.join(', ')}\"\n\t\tend\n\t\t# identify unexpected fields in the record’s errors\n\t\tunexpected_errors = []\n\t\terr_fields.each do |field_name|\n\t\t\tunexpected_errors << field_name unless fields.include?(field_name)\n\t\tend\n\t\tif unexpected_errors.length > 0\n\t\t\tmsgs << \"unexpected errors for fields #{unexpected_errors.join(', ')}\"\n\t\tend\n\t\tif msgs.length > 0\n\t\t\tassert false, msgs.join(\".\\r\")\n\t\tend\n\tend", "def field_validation_errors\n errors = field_validation_error_elements.map { |e| e.text.downcase }.reject { |e| e.empty? }\n exclude = \"Please fill the required fields.\"\n\n if errors.include?(exclude)\n errors.delete(exclude)\n end\n\n errors\n end", "def errors\n @fields.flat_map(&:errors)\n end", "def error_list(strict = false)\n c = @data_object\n res = []\n\n res << \"Missing name\" if c.con_first_name.empty? || c.con_last_name.empty?\n\n if strict\n if c.con_day_tel.empty? && c.con_eve_tel.empty? && c.con_fax_tel.empty? \n res << \"Must supply at least one contact telephone number\" \n end\n end\n\n check_length(res, c.con_first_name, 50, \"first name\")\n check_length(res, c.con_last_name, 50, \"first name\")\n check_length(res, c.con_day_tel, 20, \"daytime telephone number\")\n check_length(res, c.con_eve_tel, 20, \"evening telephone number\")\n check_length(res, c.con_fax_tel, 20, \"fax telephone number\")\n check_length(res, c.con_email, 60, \"e-mail address\")\n\n unless c.con_email.empty?\n msg = Mailer.invalid_email_address?(c.con_email)\n res << msg if msg \n end\n\n res.concat mail.error_list(strict, \"mailing\")\n res.concat ship.error_list(strict, \"shipping\")\n\n if strict && @mail.empty?\n res << \"Please specify a mailing address\"\n end\n\n if strict && !c.con_ship_to_mail && ship.empty?\n res << \"Please specify a shipping address (or click box to indicate\" +\n \" that your mailing address is your shipping address\"\n end\n\n res\n end", "def decks_contains_valid_decks\n @decks.each do |deck|\n next if deck.is_a?(ZombieBattleground::Api::Models::Deck) &&\n deck.valid? &&\n deck.errors.size.zero?\n\n errors.add(:decks, 'decks must be an array of Deck')\n end\n end", "def validated?; end", "def check_errors\n unless self.valid?\n bigmessage = self.errors.full_messages.join \"\\n\" \n raise bigmessage unless bigmessage.empty?\n end\n \n documents.each {|obj| obj.check_errors } \n \n invalids = (texts).reject {|obj| obj.valid? } \n bigmessage = invalids.map { |obj| obj.errors.full_messages.join \"\\n\" }.join \"\\n\"\n raise bigmessage unless bigmessage.empty?\n\n invalids = (audios ).reject {|obj| obj.valid? } \n bigmessage = invalids.map { |obj| obj.errors.full_messages.join \"\\n\" }.join \"\\n\"\n raise bigmessage unless bigmessage.empty?\n\n invalids = (images ).reject {|obj| obj.valid? } \n bigmessage = invalids.map { |obj| obj.errors.full_messages.join \"\\n\" }.join \"\\n\"\n raise bigmessage unless bigmessage.empty? \n \n object_formats.each {|obj| obj.check_errors } \n end", "def errors_for row\n ie = insert_error_for row\n return ie.errors if ie\n []\n end", "def failing_products\n return self.products.select do |product|\n product.failing?\n end\n end", "def store_validations #:nodoc:\n return if @validations.size == 0\n\n @validations.each do |param|\n store_dv(\n param[:cells],\n param[:validate],\n param[:criteria],\n param[:value],\n param[:maximum],\n param[:input_title],\n param[:input_message],\n param[:error_title],\n param[:error_message],\n param[:error_type],\n param[:ignore_blank],\n param[:dropdown],\n param[:show_input],\n param[:show_error]\n )\n end\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @is_included.nil?\n invalid_properties.push('invalid value for \"is_included\", is_included cannot be nil.')\n end\n\n if !@material_efficiency.nil? && @material_efficiency > 25\n invalid_properties.push('invalid value for \"material_efficiency\", must be smaller than or equal to 25.')\n end\n\n if !@material_efficiency.nil? && @material_efficiency < 0\n invalid_properties.push('invalid value for \"material_efficiency\", must be greater than or equal to 0.')\n end\n\n if @quantity.nil?\n invalid_properties.push('invalid value for \"quantity\", quantity cannot be nil.')\n end\n\n if @record_id.nil?\n invalid_properties.push('invalid value for \"record_id\", record_id cannot be nil.')\n end\n\n if [email protected]? && @runs < -1\n invalid_properties.push('invalid value for \"runs\", must be greater than or equal to -1.')\n end\n\n if !@time_efficiency.nil? && @time_efficiency > 20\n invalid_properties.push('invalid value for \"time_efficiency\", must be smaller than or equal to 20.')\n end\n\n if !@time_efficiency.nil? && @time_efficiency < 0\n invalid_properties.push('invalid value for \"time_efficiency\", must be greater than or equal to 0.')\n end\n\n if @type_id.nil?\n invalid_properties.push('invalid value for \"type_id\", type_id cannot be nil.')\n end\n\n invalid_properties\n end", "def validators\n []\n end", "def errors\n @errors ||= failed.select { |rule| rule.severity == \"Severe\" }\n end", "def loose_errors\n err = []\n err << title\n err << authors\n err << s3_error_uploads\n err << url_error_validating\n\n err.flatten\n end", "def validate_consumption_and_production_prices\n %i[marginal_costs max_consumption_price].each do |price_attribute|\n value = public_send(price_attribute)\n\n next if value.nil?\n\n if merit_order&.type != :flex\n errors.add(price_attribute, 'is only allowed when the merit_order type is \"flex\"')\n next\n end\n\n errors.add(price_attribute, 'must not be less than zero') if value.negative?\n end\n end", "def _validation_errors()\n errors = []\n @tasks.each_value { |t| errors += t._validation_errors() }\n errors\n end", "def stddev\n return 0.0 if errors.size < 2\n errors.stdev.to_f.round(1)\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @date.nil?\n invalid_properties.push('invalid value for \"date\", date cannot be nil.')\n end\n\n if @campaign_revenue.nil?\n invalid_properties.push('invalid value for \"campaign_revenue\", campaign_revenue cannot be nil.')\n end\n\n if @total_campaign_revenue.nil?\n invalid_properties.push('invalid value for \"total_campaign_revenue\", total_campaign_revenue cannot be nil.')\n end\n\n if @campaign_refund.nil?\n invalid_properties.push('invalid value for \"campaign_refund\", campaign_refund cannot be nil.')\n end\n\n if @total_campaign_refund.nil?\n invalid_properties.push('invalid value for \"total_campaign_refund\", total_campaign_refund cannot be nil.')\n end\n\n if @campaign_discount_costs.nil?\n invalid_properties.push('invalid value for \"campaign_discount_costs\", campaign_discount_costs cannot be nil.')\n end\n\n if @total_campaign_discount_costs.nil?\n invalid_properties.push('invalid value for \"total_campaign_discount_costs\", total_campaign_discount_costs cannot be nil.')\n end\n\n if @campaign_refunded_discounts.nil?\n invalid_properties.push('invalid value for \"campaign_refunded_discounts\", campaign_refunded_discounts cannot be nil.')\n end\n\n if @total_campaign_refunded_discounts.nil?\n invalid_properties.push('invalid value for \"total_campaign_refunded_discounts\", total_campaign_refunded_discounts cannot be nil.')\n end\n\n if @campaign_free_items.nil?\n invalid_properties.push('invalid value for \"campaign_free_items\", campaign_free_items cannot be nil.')\n end\n\n if @total_campaign_free_items.nil?\n invalid_properties.push('invalid value for \"total_campaign_free_items\", total_campaign_free_items cannot be nil.')\n end\n\n if @coupon_redemptions.nil?\n invalid_properties.push('invalid value for \"coupon_redemptions\", coupon_redemptions cannot be nil.')\n end\n\n if @total_coupon_redemptions.nil?\n invalid_properties.push('invalid value for \"total_coupon_redemptions\", total_coupon_redemptions cannot be nil.')\n end\n\n if @coupon_rolledback_redemptions.nil?\n invalid_properties.push('invalid value for \"coupon_rolledback_redemptions\", coupon_rolledback_redemptions cannot be nil.')\n end\n\n if @total_coupon_rolledback_redemptions.nil?\n invalid_properties.push('invalid value for \"total_coupon_rolledback_redemptions\", total_coupon_rolledback_redemptions cannot be nil.')\n end\n\n if @referral_redemptions.nil?\n invalid_properties.push('invalid value for \"referral_redemptions\", referral_redemptions cannot be nil.')\n end\n\n if @total_referral_redemptions.nil?\n invalid_properties.push('invalid value for \"total_referral_redemptions\", total_referral_redemptions cannot be nil.')\n end\n\n if @coupons_created.nil?\n invalid_properties.push('invalid value for \"coupons_created\", coupons_created cannot be nil.')\n end\n\n if @total_coupons_created.nil?\n invalid_properties.push('invalid value for \"total_coupons_created\", total_coupons_created cannot be nil.')\n end\n\n if @referrals_created.nil?\n invalid_properties.push('invalid value for \"referrals_created\", referrals_created cannot be nil.')\n end\n\n if @total_referrals_created.nil?\n invalid_properties.push('invalid value for \"total_referrals_created\", total_referrals_created cannot be nil.')\n end\n\n if @added_loyalty_points.nil?\n invalid_properties.push('invalid value for \"added_loyalty_points\", added_loyalty_points cannot be nil.')\n end\n\n if @total_added_loyalty_points.nil?\n invalid_properties.push('invalid value for \"total_added_loyalty_points\", total_added_loyalty_points cannot be nil.')\n end\n\n if @deducted_loyalty_points.nil?\n invalid_properties.push('invalid value for \"deducted_loyalty_points\", deducted_loyalty_points cannot be nil.')\n end\n\n if @total_deducted_loyalty_points.nil?\n invalid_properties.push('invalid value for \"total_deducted_loyalty_points\", total_deducted_loyalty_points cannot be nil.')\n end\n\n invalid_properties\n end", "def details\n hash = group_by_attribute.transform_values do |errors|\n errors.map(&:details)\n end\n hash.default = EMPTY_ARRAY\n hash.freeze\n hash\n end", "def proofread\n \n @errors = []\n \n # absolute dies\n @proof.absolute_dies.each do |key, die|\n applicable_eloras = REXML::XPath.match(@xml_document, die.xpath).select do |elora|\n die.namespace == elora.inherited_namespace\n end\n validate_eloras(applicable_eloras, die)\n end \n \n # arbitrary dies\n @proof.arbitrary_dies.each do |key, die|\n applicable_eloras = REXML::XPath.match(@xml_document, die.xpath)\n validate_eloras(applicable_eloras, die)\n end\n \n option?\n collection?\n \n return @errors.empty? # valid?\n \n end", "def attribute_errors\n {}\n end", "def test()\n # All errors\n errors = []\n # Return all the errors\n return errors\n end", "def extra_validations\n success\n end", "def errors\n @errors || []\n end", "def getErrors() \n\t\t\t$errors = @errors\n\t\t\t#@errors = []\n\t\t\treturn $errors;\n\t\tend", "def format_dv_errors(model)\n errors = []\n model.errors.each_pair do |key, value|\n errors.push({ key => value })\n end\n return errors\n end", "def _exceptions\n return @validated if @validated\n\n exceptions = {}\n if not @always_valid\n exceptions = self.validate(@data, false)\n end\n\n if @errors\n exceptions[:errors] = (exceptions[:errors] or {}).merge(@errors)\n end\n\n exceptions\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @product_rate_plan.nil?\n invalid_properties.push(\"invalid value for 'product_rate_plan', product_rate_plan cannot be nil.\")\n end\n\n if @invoicing_type.nil?\n invalid_properties.push(\"invalid value for 'invoicing_type', invoicing_type cannot be nil.\")\n end\n\n if @pricing_behaviour.nil?\n invalid_properties.push(\"invalid value for 'pricing_behaviour', pricing_behaviour cannot be nil.\")\n end\n\n return invalid_properties\n end", "def errors\n @errors.values.flatten\n end", "def error_list\n return @error_list if @error_list\n\n @error_list = @model.errors.delete(@method)\n @error_list ||= {} # Ensure some value\n return nil if @error_list.blank?\n\n save_summary_error_list(@error_list)\n @error_list\n end", "def errors\n e = []\n e << 'EndSeqNo must either be 0 (inifinity) or be >= BeginSeqNo' unless end_seq_no_valid?\n [super, e].flatten\n end", "def check_errors\n unless self.valid?\n bigmessage = self.errors.full_messages.join \"\\n\" \n raise bigmessage unless bigmessage.empty?\n end\n \n documents.each {|obj| obj.check_errors } \n \n invalids = (texts).reject {|obj| obj.valid? } \n bigmessage = invalids.map { |obj| obj.errors.full_messages.join \"\\n\" }.join \"\\n\"\n raise bigmessage unless bigmessage.empty?\n\n invalids = (audios ).reject {|obj| obj.valid? } \n bigmessage = invalids.map { |obj| obj.errors.full_messages.join \"\\n\" }.join \"\\n\"\n raise bigmessage unless bigmessage.empty?\n\n invalids = (images ).reject {|obj| obj.valid? } \n bigmessage = invalids.map { |obj| obj.errors.full_messages.join \"\\n\" }.join \"\\n\"\n raise bigmessage unless bigmessage.empty? \n \n object_formats.each {|obj| obj.check_errors } \n end", "def validate\n ensure_exclude_option_array_exists\n ensure_linter_section_exists\n ensure_linter_include_exclude_arrays_exist\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @currency_code.nil?\n invalid_properties.push(\"invalid value for 'currency_code', currency_code cannot be nil.\")\n end\n\n if @description.nil?\n invalid_properties.push(\"invalid value for 'description', description cannot be nil.\")\n end\n\n if @original_price.nil?\n invalid_properties.push(\"invalid value for 'original_price', original_price cannot be nil.\")\n end\n\n if @sku.nil?\n invalid_properties.push(\"invalid value for 'sku', sku cannot be nil.\")\n end\n\n return invalid_properties\n end", "def errors\n @errors ||= []\n end", "def errors\n @errors ||= []\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if [email protected]? && @sku.to_s.length > 50\n invalid_properties.push('invalid value for \"sku\", the character length must be smaller than or equal to 50.')\n end\n\n if !@stock_picking_location.nil? && @stock_picking_location.to_s.length > 20\n invalid_properties.push('invalid value for \"stock_picking_location\", the character length must be smaller than or equal to 20.')\n end\n\n invalid_properties\n end", "def errors\n @diagnostics.select {|d| d.severity == :error }\n end", "def validation; end", "def validation; end", "def errors\n @errors.values\n end", "def valid_entries\n entries.select(&:valid?)\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @dpv_confirmation.nil?\n invalid_properties.push('invalid value for \"dpv_confirmation\", dpv_confirmation cannot be nil.')\n end\n\n if @dpv_cmra.nil?\n invalid_properties.push('invalid value for \"dpv_cmra\", dpv_cmra cannot be nil.')\n end\n\n if @dpv_vacant.nil?\n invalid_properties.push('invalid value for \"dpv_vacant\", dpv_vacant cannot be nil.')\n end\n\n if @dpv_active.nil?\n invalid_properties.push('invalid value for \"dpv_active\", dpv_active cannot be nil.')\n end\n\n if @dpv_footnotes.nil?\n invalid_properties.push('invalid value for \"dpv_footnotes\", dpv_footnotes cannot be nil.')\n end\n\n if @ews_match.nil?\n invalid_properties.push('invalid value for \"ews_match\", ews_match cannot be nil.')\n end\n\n if @lacs_indicator.nil?\n invalid_properties.push('invalid value for \"lacs_indicator\", lacs_indicator cannot be nil.')\n end\n\n if @lacs_return_code.nil?\n invalid_properties.push('invalid value for \"lacs_return_code\", lacs_return_code cannot be nil.')\n end\n\n if @suite_return_code.nil?\n invalid_properties.push('invalid value for \"suite_return_code\", suite_return_code cannot be nil.')\n end\n\n invalid_properties\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @pricing_component_type.nil?\n invalid_properties.push(\"invalid value for 'pricing_component_type', pricing_component_type cannot be nil.\")\n end\n\n if @charge_type.nil?\n invalid_properties.push(\"invalid value for 'charge_type', charge_type cannot be nil.\")\n end\n\n if @period_start.nil?\n invalid_properties.push(\"invalid value for 'period_start', period_start cannot be nil.\")\n end\n\n if @period_end.nil?\n invalid_properties.push(\"invalid value for 'period_end', period_end cannot be nil.\")\n end\n\n if @invoice_id.nil?\n invalid_properties.push(\"invalid value for 'invoice_id', invoice_id cannot be nil.\")\n end\n\n if @organization_id.nil?\n invalid_properties.push(\"invalid value for 'organization_id', organization_id cannot be nil.\")\n end\n\n if @name.nil?\n invalid_properties.push(\"invalid value for 'name', name cannot be nil.\")\n end\n\n if @description.nil?\n invalid_properties.push(\"invalid value for 'description', description cannot be nil.\")\n end\n\n if @calculation.nil?\n invalid_properties.push(\"invalid value for 'calculation', calculation cannot be nil.\")\n end\n\n if @cost.nil?\n invalid_properties.push(\"invalid value for 'cost', cost cannot be nil.\")\n end\n\n if @tax.nil?\n invalid_properties.push(\"invalid value for 'tax', tax cannot be nil.\")\n end\n\n if @component_value.nil?\n invalid_properties.push(\"invalid value for 'component_value', component_value cannot be nil.\")\n end\n\n if @pricing_component_id.nil?\n invalid_properties.push(\"invalid value for 'pricing_component_id', pricing_component_id cannot be nil.\")\n end\n\n if @public_pricing_component_name.nil?\n invalid_properties.push(\"invalid value for 'public_pricing_component_name', public_pricing_component_name cannot be nil.\")\n end\n\n if @pricing_component_name.nil?\n invalid_properties.push(\"invalid value for 'pricing_component_name', pricing_component_name cannot be nil.\")\n end\n\n if @subscription_charge_id.nil?\n invalid_properties.push(\"invalid value for 'subscription_charge_id', subscription_charge_id cannot be nil.\")\n end\n\n if @child_invoice_id.nil?\n invalid_properties.push(\"invalid value for 'child_invoice_id', child_invoice_id cannot be nil.\")\n end\n\n if @type.nil?\n invalid_properties.push(\"invalid value for 'type', type cannot be nil.\")\n end\n\n return invalid_properties\n end", "def errors\n @attributes[:errors]\n end", "def test_grouping_without_religion\n religion_obj = Religion.new(:grouping => 'All Anglican')\n assert !religion_obj.valid?\n assert religion_obj.errors.invalid?(:name)\n end", "def errors_for(o);\n mab do\n ul.errors { o.errors.each_full { |er| li er } }\n end if o.errors.any?\n end", "def invalid_items\n @items.select { |item| item.valid == false }\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @accounts_date.nil?\n invalid_properties.push(\"invalid value for 'accounts_date', accounts_date cannot be nil.\")\n end\n\n if @reporting_period.nil?\n invalid_properties.push(\"invalid value for 'reporting_period', reporting_period cannot be nil.\")\n end\n\n if @currency.nil?\n invalid_properties.push(\"invalid value for 'currency', currency cannot be nil.\")\n end\n\n if @consolidated_accounts.nil?\n invalid_properties.push(\"invalid value for 'consolidated_accounts', consolidated_accounts cannot be nil.\")\n end\n\n if @audit_qualification.nil?\n invalid_properties.push(\"invalid value for 'audit_qualification', audit_qualification cannot be nil.\")\n end\n\n if @number_of_employees.nil?\n invalid_properties.push(\"invalid value for 'number_of_employees', number_of_employees cannot be nil.\")\n end\n\n if @turnover.nil?\n invalid_properties.push(\"invalid value for 'turnover', turnover cannot be nil.\")\n end\n\n if @cost_of_sales.nil?\n invalid_properties.push(\"invalid value for 'cost_of_sales', cost_of_sales cannot be nil.\")\n end\n\n if @sga_plus_other_net_costs.nil?\n invalid_properties.push(\"invalid value for 'sga_plus_other_net_costs', sga_plus_other_net_costs cannot be nil.\")\n end\n\n if @operating_profit.nil?\n invalid_properties.push(\"invalid value for 'operating_profit', operating_profit cannot be nil.\")\n end\n\n if @interest_receivable.nil?\n invalid_properties.push(\"invalid value for 'interest_receivable', interest_receivable cannot be nil.\")\n end\n\n if @interest_payable.nil?\n invalid_properties.push(\"invalid value for 'interest_payable', interest_payable cannot be nil.\")\n end\n\n if @pre_tax_profit.nil?\n invalid_properties.push(\"invalid value for 'pre_tax_profit', pre_tax_profit cannot be nil.\")\n end\n\n if @taxation.nil?\n invalid_properties.push(\"invalid value for 'taxation', taxation cannot be nil.\")\n end\n\n if @post_tax_profit.nil?\n invalid_properties.push(\"invalid value for 'post_tax_profit', post_tax_profit cannot be nil.\")\n end\n\n if @dividends_payable.nil?\n invalid_properties.push(\"invalid value for 'dividends_payable', dividends_payable cannot be nil.\")\n end\n\n if @retained_profits.nil?\n invalid_properties.push(\"invalid value for 'retained_profits', retained_profits cannot be nil.\")\n end\n\n if @intangible_assets.nil?\n invalid_properties.push(\"invalid value for 'intangible_assets', intangible_assets cannot be nil.\")\n end\n\n if @tangible_assets.nil?\n invalid_properties.push(\"invalid value for 'tangible_assets', tangible_assets cannot be nil.\")\n end\n\n if @investments_and_other_assets.nil?\n invalid_properties.push(\"invalid value for 'investments_and_other_assets', investments_and_other_assets cannot be nil.\")\n end\n\n if @fixed_assets.nil?\n invalid_properties.push(\"invalid value for 'fixed_assets', fixed_assets cannot be nil.\")\n end\n\n if @stock.nil?\n invalid_properties.push(\"invalid value for 'stock', stock cannot be nil.\")\n end\n\n if @trade_debtors.nil?\n invalid_properties.push(\"invalid value for 'trade_debtors', trade_debtors cannot be nil.\")\n end\n\n if @other_debtors.nil?\n invalid_properties.push(\"invalid value for 'other_debtors', other_debtors cannot be nil.\")\n end\n\n if @miscellaneous_current_assets.nil?\n invalid_properties.push(\"invalid value for 'miscellaneous_current_assets', miscellaneous_current_assets cannot be nil.\")\n end\n\n if @cash.nil?\n invalid_properties.push(\"invalid value for 'cash', cash cannot be nil.\")\n end\n\n if @current_assets.nil?\n invalid_properties.push(\"invalid value for 'current_assets', current_assets cannot be nil.\")\n end\n\n if @total_assets.nil?\n invalid_properties.push(\"invalid value for 'total_assets', total_assets cannot be nil.\")\n end\n\n if @bank_loans_and_overdrafts.nil?\n invalid_properties.push(\"invalid value for 'bank_loans_and_overdrafts', bank_loans_and_overdrafts cannot be nil.\")\n end\n\n if @trade_creditors.nil?\n invalid_properties.push(\"invalid value for 'trade_creditors', trade_creditors cannot be nil.\")\n end\n\n if @miscellaneous_current_liabilities.nil?\n invalid_properties.push(\"invalid value for 'miscellaneous_current_liabilities', miscellaneous_current_liabilities cannot be nil.\")\n end\n\n if @other_short_term_finances.nil?\n invalid_properties.push(\"invalid value for 'other_short_term_finances', other_short_term_finances cannot be nil.\")\n end\n\n if @current_liabilities.nil?\n invalid_properties.push(\"invalid value for 'current_liabilities', current_liabilities cannot be nil.\")\n end\n\n if @contingent_liabilities.nil?\n invalid_properties.push(\"invalid value for 'contingent_liabilities', contingent_liabilities cannot be nil.\")\n end\n\n if @other_long_term_finances.nil?\n invalid_properties.push(\"invalid value for 'other_long_term_finances', other_long_term_finances cannot be nil.\")\n end\n\n if @total_long_term_liabilities.nil?\n invalid_properties.push(\"invalid value for 'total_long_term_liabilities', total_long_term_liabilities cannot be nil.\")\n end\n\n if @total_liabilities.nil?\n invalid_properties.push(\"invalid value for 'total_liabilities', total_liabilities cannot be nil.\")\n end\n\n if @net_assets.nil?\n invalid_properties.push(\"invalid value for 'net_assets', net_assets cannot be nil.\")\n end\n\n if @equity_paid_up.nil?\n invalid_properties.push(\"invalid value for 'equity_paid_up', equity_paid_up cannot be nil.\")\n end\n\n if @revaluation_reserve.nil?\n invalid_properties.push(\"invalid value for 'revaluation_reserve', revaluation_reserve cannot be nil.\")\n end\n\n if @sundry_reserves.nil?\n invalid_properties.push(\"invalid value for 'sundry_reserves', sundry_reserves cannot be nil.\")\n end\n\n if @profit_and_loss_account_reserve.nil?\n invalid_properties.push(\"invalid value for 'profit_and_loss_account_reserve', profit_and_loss_account_reserve cannot be nil.\")\n end\n\n if @shareholder_funds.nil?\n invalid_properties.push(\"invalid value for 'shareholder_funds', shareholder_funds cannot be nil.\")\n end\n\n if @depreciation.nil?\n invalid_properties.push(\"invalid value for 'depreciation', depreciation cannot be nil.\")\n end\n\n if @amortisation_of_intangibles.nil?\n invalid_properties.push(\"invalid value for 'amortisation_of_intangibles', amortisation_of_intangibles cannot be nil.\")\n end\n\n if @ebitda.nil?\n invalid_properties.push(\"invalid value for 'ebitda', ebitda cannot be nil.\")\n end\n\n if @working_capital.nil?\n invalid_properties.push(\"invalid value for 'working_capital', working_capital cannot be nil.\")\n end\n\n if @capital_employed.nil?\n invalid_properties.push(\"invalid value for 'capital_employed', capital_employed cannot be nil.\")\n end\n\n if @wages_and_salaries.nil?\n invalid_properties.push(\"invalid value for 'wages_and_salaries', wages_and_salaries cannot be nil.\")\n end\n\n if @directors_emoluments.nil?\n invalid_properties.push(\"invalid value for 'directors_emoluments', directors_emoluments cannot be nil.\")\n end\n\n if @audit_fees.nil?\n invalid_properties.push(\"invalid value for 'audit_fees', audit_fees cannot be nil.\")\n end\n\n if @bank_overdraft_and_long_term_loans.nil?\n invalid_properties.push(\"invalid value for 'bank_overdraft_and_long_term_loans', bank_overdraft_and_long_term_loans cannot be nil.\")\n end\n\n if @net_cash_flow_from_operations.nil?\n invalid_properties.push(\"invalid value for 'net_cash_flow_from_operations', net_cash_flow_from_operations cannot be nil.\")\n end\n\n if @net_cash_flow_before_financing.nil?\n invalid_properties.push(\"invalid value for 'net_cash_flow_before_financing', net_cash_flow_before_financing cannot be nil.\")\n end\n\n if @net_cash_flow_from_financing.nil?\n invalid_properties.push(\"invalid value for 'net_cash_flow_from_financing', net_cash_flow_from_financing cannot be nil.\")\n end\n\n if @increase_in_cash.nil?\n invalid_properties.push(\"invalid value for 'increase_in_cash', increase_in_cash cannot be nil.\")\n end\n\n if @debtor_days.nil?\n invalid_properties.push(\"invalid value for 'debtor_days', debtor_days cannot be nil.\")\n end\n\n if @exports.nil?\n invalid_properties.push(\"invalid value for 'exports', exports cannot be nil.\")\n end\n\n if @gross_margin_percentage.nil?\n invalid_properties.push(\"invalid value for 'gross_margin_percentage', gross_margin_percentage cannot be nil.\")\n end\n\n if @operating_profit_margin_percentage.nil?\n invalid_properties.push(\"invalid value for 'operating_profit_margin_percentage', operating_profit_margin_percentage cannot be nil.\")\n end\n\n if @ebitda_margin_percentage.nil?\n invalid_properties.push(\"invalid value for 'ebitda_margin_percentage', ebitda_margin_percentage cannot be nil.\")\n end\n\n if @pre_tax_profit_margin_percentage.nil?\n invalid_properties.push(\"invalid value for 'pre_tax_profit_margin_percentage', pre_tax_profit_margin_percentage cannot be nil.\")\n end\n\n if @net_margin_percentage.nil?\n invalid_properties.push(\"invalid value for 'net_margin_percentage', net_margin_percentage cannot be nil.\")\n end\n\n if @return_on_assets_percentage.nil?\n invalid_properties.push(\"invalid value for 'return_on_assets_percentage', return_on_assets_percentage cannot be nil.\")\n end\n\n if @return_on_capital_employed_percentage.nil?\n invalid_properties.push(\"invalid value for 'return_on_capital_employed_percentage', return_on_capital_employed_percentage cannot be nil.\")\n end\n\n if @return_on_equity.nil?\n invalid_properties.push(\"invalid value for 'return_on_equity', return_on_equity cannot be nil.\")\n end\n\n if @current_ratio.nil?\n invalid_properties.push(\"invalid value for 'current_ratio', current_ratio cannot be nil.\")\n end\n\n if @cash_to_current_liabilities_ratio.nil?\n invalid_properties.push(\"invalid value for 'cash_to_current_liabilities_ratio', cash_to_current_liabilities_ratio cannot be nil.\")\n end\n\n if @cash_to_total_assets_percentage.nil?\n invalid_properties.push(\"invalid value for 'cash_to_total_assets_percentage', cash_to_total_assets_percentage cannot be nil.\")\n end\n\n if @liquidity_ratio.nil?\n invalid_properties.push(\"invalid value for 'liquidity_ratio', liquidity_ratio cannot be nil.\")\n end\n\n if @gearing_percentage_on_liability_basis.nil?\n invalid_properties.push(\"invalid value for 'gearing_percentage_on_liability_basis', gearing_percentage_on_liability_basis cannot be nil.\")\n end\n\n if @gearing_percentage_on_gross_debt_basis.nil?\n invalid_properties.push(\"invalid value for 'gearing_percentage_on_gross_debt_basis', gearing_percentage_on_gross_debt_basis cannot be nil.\")\n end\n\n if @gearing_percentage_on_net_debt_basis.nil?\n invalid_properties.push(\"invalid value for 'gearing_percentage_on_net_debt_basis', gearing_percentage_on_net_debt_basis cannot be nil.\")\n end\n\n if @debt_to_capital_percentage.nil?\n invalid_properties.push(\"invalid value for 'debt_to_capital_percentage', debt_to_capital_percentage cannot be nil.\")\n end\n\n if @inventory_turnover_ratio.nil?\n invalid_properties.push(\"invalid value for 'inventory_turnover_ratio', inventory_turnover_ratio cannot be nil.\")\n end\n\n if @cash_to_turnover_percentage.nil?\n invalid_properties.push(\"invalid value for 'cash_to_turnover_percentage', cash_to_turnover_percentage cannot be nil.\")\n end\n\n if @days_inventory_outstanding.nil?\n invalid_properties.push(\"invalid value for 'days_inventory_outstanding', days_inventory_outstanding cannot be nil.\")\n end\n\n if @days_sales_outstanding.nil?\n invalid_properties.push(\"invalid value for 'days_sales_outstanding', days_sales_outstanding cannot be nil.\")\n end\n\n if @days_payable_outstanding.nil?\n invalid_properties.push(\"invalid value for 'days_payable_outstanding', days_payable_outstanding cannot be nil.\")\n end\n\n if @cash_conversion_cycle.nil?\n invalid_properties.push(\"invalid value for 'cash_conversion_cycle', cash_conversion_cycle cannot be nil.\")\n end\n\n if @revenue_per_employee.nil?\n invalid_properties.push(\"invalid value for 'revenue_per_employee', revenue_per_employee cannot be nil.\")\n end\n\n if @human_capital_value_added.nil?\n invalid_properties.push(\"invalid value for 'human_capital_value_added', human_capital_value_added cannot be nil.\")\n end\n\n if @interest_coverage_ratio.nil?\n invalid_properties.push(\"invalid value for 'interest_coverage_ratio', interest_coverage_ratio cannot be nil.\")\n end\n\n if @net_debt_to_ebitda_ratio.nil?\n invalid_properties.push(\"invalid value for 'net_debt_to_ebitda_ratio', net_debt_to_ebitda_ratio cannot be nil.\")\n end\n\n if @cfo_to_sales_ratio.nil?\n invalid_properties.push(\"invalid value for 'cfo_to_sales_ratio', cfo_to_sales_ratio cannot be nil.\")\n end\n\n if @auditor.nil?\n invalid_properties.push(\"invalid value for 'auditor', auditor cannot be nil.\")\n end\n\n if @joint_auditor.nil?\n invalid_properties.push(\"invalid value for 'joint_auditor', joint_auditor cannot be nil.\")\n end\n\n if @solicitor.nil?\n invalid_properties.push(\"invalid value for 'solicitor', solicitor cannot be nil.\")\n end\n\n if @accountant.nil?\n invalid_properties.push(\"invalid value for 'accountant', accountant cannot be nil.\")\n end\n\n return invalid_properties\n end", "def invalid_record_errors(record)\n record.errors.map do |invalid_field, message| #=> [:name, \"can't be blank\"]\n {\n \"status\" => \"422\",\n \"source\" => {\"pointer\" => \"/data/attributes/#{invalid_field}\"},\n \"title\" => \"Invalid Attribute\",\n \"detail\" => message\n }\n end\n end", "def validate\n\t\t\t# time always exists\n\t\t\tsyms = { 't' => Parameter.new('t', 0) }\n\t\t\tidents = []\n\t\t\[email protected] {|k, v| syms[k] = v}\n\t\t\[email protected] do |k, v| \n\t\t\t\traise \"Parameter and species share id: #{k}\" if syms[k]\n\t\t\t\tsyms[k] = v\n\t\t\tend\n\t\t\tsyms.each do |k, v|\n\t\t\t\traise \"Symbol #{v.to_s} mapped to wrong id: #{k}\" if v.name != k\n\t\t\tend\n\n\t\t\trule_output_names = {}\n\n\t\t\[email protected] do |rule|\n\t\t\t\tif rule_output_names.key? (rule.output.name)\n\t\t\t\t\traise \"Two rules for one output (#{rule.output.name})\"\n\t\t\t\tend\n\t\t\t\trule_output_names[rule.output.name] = 1\n\n\t\t\t\tif !syms.key?(rule.output.name)\n\t\t\t\t\traise \"rule #{rule.to_s} has undefined output: #{rule.output.name}\"\n\t\t\t\tend\n\n\t\t\t\tif syms[rule.output.name] != rule.output\n\t\t\t\t\traise \"Inconsistent model: rule #{rule.to_s} does not output to the correct variable #{syms[rule.output.name]}\"\n\t\t\t\tend\n\n\t\t\t\trule.equation.all_idents.each do |id|\n\t\t\t\t\tidents = idents | [id]\n\t\t\t\t\tif !syms.key?(id)\n\t\t\t\t\t\traise \"rule #{rule.to_s} has undefined input: #{id}\"\n\t\t\t\t\t# else\n\t\t\t\t\t# \tputs \"#{id} used in #{rule.to_s}\\n\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tunused = idents.reject { |e| syms.key?(e) }\n\t\t\tunused = unused | (syms.keys.reject { |e| idents.index(e) })\n\t\t\t# dawn dusk and force are in every model (at least after sassy opens it)\n\t\t\tunused = unused.reject { |e| e == 't' || e == 'dawn' || e == 'dusk' || e == 'force' \\\n\t\t\t\t|| rule_output_names.key?(e) || @species.key?(e) }\n\t\t\tif unused.length > 0\n\t\t\t\tputs \"[W] Model has unused symbols: #{unused}\\n\"\n\t\t\tend\n\t\t\tself\n\t\tend", "def validate_suppliers!\n data.each do |supplier_name, config|\n REQUIRED_FIELDS.each do |field|\n result = config[field]\n raise MissingFieldError.new(supplier_name, field) if (result.nil? || result.to_s.empty?)\n end\n \n validate_workers!(supplier_name, config[\"workers\"])\n end\n end", "def errors\n p = build_payment\n p.valid?\n p.errors\n end", "def list_invalid_properties\r\n invalid_properties = Array.new\r\n return invalid_properties\r\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @ir.nil?\n invalid_properties.push('invalid value for \"ir\", ir cannot be nil.')\n end\n\n if @loi.nil?\n invalid_properties.push('invalid value for \"loi\", loi cannot be nil.')\n end\n\n if @approval_id.nil?\n invalid_properties.push('invalid value for \"approval_id\", approval_id cannot be nil.')\n end\n\n if @calculated_max_price.nil?\n invalid_properties.push('invalid value for \"calculated_max_price\", calculated_max_price cannot be nil.')\n end\n\n if @completes.nil?\n invalid_properties.push('invalid value for \"completes\", completes cannot be nil.')\n end\n\n if @event_id.nil?\n invalid_properties.push('invalid value for \"event_id\", event_id cannot be nil.')\n end\n\n if @id.nil?\n invalid_properties.push('invalid value for \"id\", id cannot be nil.')\n end\n\n if @new_estimated_cost.nil?\n invalid_properties.push('invalid value for \"new_estimated_cost\", new_estimated_cost cannot be nil.')\n end\n\n if @original_cpi.nil?\n invalid_properties.push('invalid value for \"original_cpi\", original_cpi cannot be nil.')\n end\n\n if @original_estimated_cost.nil?\n invalid_properties.push('invalid value for \"original_estimated_cost\", original_estimated_cost cannot be nil.')\n end\n\n if @project_id.nil?\n invalid_properties.push('invalid value for \"project_id\", project_id cannot be nil.')\n end\n\n if @quota_group_id.nil?\n invalid_properties.push('invalid value for \"quota_group_id\", quota_group_id cannot be nil.')\n end\n\n if @reason.nil?\n invalid_properties.push('invalid value for \"reason\", reason cannot be nil.')\n end\n\n if @request_new_price.nil?\n invalid_properties.push('invalid value for \"request_new_price\", request_new_price cannot be nil.')\n end\n\n if @required_completes.nil?\n invalid_properties.push('invalid value for \"required_completes\", required_completes cannot be nil.')\n end\n\n invalid_properties\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @aperture_value.nil?\n invalid_properties.push('invalid value for \"aperture_value\", aperture_value cannot be nil.')\n end\n\n if @brightness_value.nil?\n invalid_properties.push('invalid value for \"brightness_value\", brightness_value cannot be nil.')\n end\n\n if !@cfa_pattern.nil? && @cfa_pattern !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"cfa_pattern\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if !@components_configuration.nil? && @components_configuration !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"components_configuration\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @compressed_bits_per_pixel.nil?\n invalid_properties.push('invalid value for \"compressed_bits_per_pixel\", compressed_bits_per_pixel cannot be nil.')\n end\n\n if !@device_setting_description.nil? && @device_setting_description !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"device_setting_description\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @digital_zoom_ratio.nil?\n invalid_properties.push('invalid value for \"digital_zoom_ratio\", digital_zoom_ratio cannot be nil.')\n end\n\n if !@exif_version.nil? && @exif_version !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"exif_version\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @exposure_bias_value.nil?\n invalid_properties.push('invalid value for \"exposure_bias_value\", exposure_bias_value cannot be nil.')\n end\n\n if @exposure_index.nil?\n invalid_properties.push('invalid value for \"exposure_index\", exposure_index cannot be nil.')\n end\n\n if @exposure_time.nil?\n invalid_properties.push('invalid value for \"exposure_time\", exposure_time cannot be nil.')\n end\n\n if @f_number.nil?\n invalid_properties.push('invalid value for \"f_number\", f_number cannot be nil.')\n end\n\n if @flash_energy.nil?\n invalid_properties.push('invalid value for \"flash_energy\", flash_energy cannot be nil.')\n end\n\n if !@flashpix_version.nil? && @flashpix_version !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"flashpix_version\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @focal_length.nil?\n invalid_properties.push('invalid value for \"focal_length\", focal_length cannot be nil.')\n end\n\n if @focal_length_in35_mm_film.nil?\n invalid_properties.push('invalid value for \"focal_length_in35_mm_film\", focal_length_in35_mm_film cannot be nil.')\n end\n\n if @focal_plane_x_resolution.nil?\n invalid_properties.push('invalid value for \"focal_plane_x_resolution\", focal_plane_x_resolution cannot be nil.')\n end\n\n if @focal_plane_y_resolution.nil?\n invalid_properties.push('invalid value for \"focal_plane_y_resolution\", focal_plane_y_resolution cannot be nil.')\n end\n\n if @gps_altitude.nil?\n invalid_properties.push('invalid value for \"gps_altitude\", gps_altitude cannot be nil.')\n end\n\n if !@gps_area_information.nil? && @gps_area_information !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"gps_area_information\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @gpsdop.nil?\n invalid_properties.push('invalid value for \"gpsdop\", gpsdop cannot be nil.')\n end\n\n if @gps_dest_bearing.nil?\n invalid_properties.push('invalid value for \"gps_dest_bearing\", gps_dest_bearing cannot be nil.')\n end\n\n if @gps_dest_distance.nil?\n invalid_properties.push('invalid value for \"gps_dest_distance\", gps_dest_distance cannot be nil.')\n end\n\n if @gps_differential.nil?\n invalid_properties.push('invalid value for \"gps_differential\", gps_differential cannot be nil.')\n end\n\n if @gps_img_direction.nil?\n invalid_properties.push('invalid value for \"gps_img_direction\", gps_img_direction cannot be nil.')\n end\n\n if !@gps_processing_method.nil? && @gps_processing_method !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"gps_processing_method\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @gps_speed.nil?\n invalid_properties.push('invalid value for \"gps_speed\", gps_speed cannot be nil.')\n end\n\n if !@gps_version_id.nil? && @gps_version_id !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"gps_version_id\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @gamma.nil?\n invalid_properties.push('invalid value for \"gamma\", gamma cannot be nil.')\n end\n\n if @iso_speed.nil?\n invalid_properties.push('invalid value for \"iso_speed\", iso_speed cannot be nil.')\n end\n\n if @iso_speed_latitude_yyy.nil?\n invalid_properties.push('invalid value for \"iso_speed_latitude_yyy\", iso_speed_latitude_yyy cannot be nil.')\n end\n\n if @iso_speed_latitude_zzz.nil?\n invalid_properties.push('invalid value for \"iso_speed_latitude_zzz\", iso_speed_latitude_zzz cannot be nil.')\n end\n\n if @photographic_sensitivity.nil?\n invalid_properties.push('invalid value for \"photographic_sensitivity\", photographic_sensitivity cannot be nil.')\n end\n\n if !@maker_note_raw_data.nil? && @maker_note_raw_data !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"maker_note_raw_data\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @max_aperture_value.nil?\n invalid_properties.push('invalid value for \"max_aperture_value\", max_aperture_value cannot be nil.')\n end\n\n if [email protected]? && @oecf !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"oecf\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @pixel_x_dimension.nil?\n invalid_properties.push('invalid value for \"pixel_x_dimension\", pixel_x_dimension cannot be nil.')\n end\n\n if @pixel_y_dimension.nil?\n invalid_properties.push('invalid value for \"pixel_y_dimension\", pixel_y_dimension cannot be nil.')\n end\n\n if @recommended_exposure_index.nil?\n invalid_properties.push('invalid value for \"recommended_exposure_index\", recommended_exposure_index cannot be nil.')\n end\n\n if @scene_type.nil?\n invalid_properties.push('invalid value for \"scene_type\", scene_type cannot be nil.')\n end\n\n if @sensitivity_type.nil?\n invalid_properties.push('invalid value for \"sensitivity_type\", sensitivity_type cannot be nil.')\n end\n\n if @sharpness.nil?\n invalid_properties.push('invalid value for \"sharpness\", sharpness cannot be nil.')\n end\n\n if @shutter_speed_value.nil?\n invalid_properties.push('invalid value for \"shutter_speed_value\", shutter_speed_value cannot be nil.')\n end\n\n if !@spatial_frequency_response.nil? && @spatial_frequency_response !~ Regexp.new(/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/)\n invalid_properties.push('invalid value for \"spatial_frequency_response\", must conform to the pattern /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/.')\n end\n\n if @standard_output_sensitivity.nil?\n invalid_properties.push('invalid value for \"standard_output_sensitivity\", standard_output_sensitivity cannot be nil.')\n end\n\n if @subject_distance.nil?\n invalid_properties.push('invalid value for \"subject_distance\", subject_distance cannot be nil.')\n end\n\n invalid_properties\n end", "def handle_incorrect_constraints(specification)\n specification.inject(Mash.new) do |acc, (cb, constraints)|\n constraints = Array(constraints)\n acc[cb] = (constraints.empty? || constraints.size > 1) ? [] : constraints.first\n acc\n end\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @quantity.nil?\n invalid_properties.push('invalid value for \"quantity\", quantity cannot be nil.')\n end\n\n if @unit_price.nil?\n invalid_properties.push('invalid value for \"unit_price\", unit_price cannot be nil.')\n end\n\n invalid_properties\n end", "def remove_invalid_decks\n @decks.select! do |deck|\n deck.is_a?(ZombieBattleground::Api::Models::Deck) &&\n deck.valid? &&\n deck.errors.size.zero?\n end\n end", "def add_validation_errors(value); end", "def errors\n self.class.validator.call self\n end", "def validate\r\n validate! rescue false\r\n end", "def parameter_validations\n @parameter_validations ||= []\n end", "def audit_errant_product_option_values\n counter = 0\n Product.in_taxon(\"Tires\").each do |product|\n if product.has_variants?\n product.variants.each do |variant|\n v = variant.option_values.find_by_option_type_id(OptionType.find_by_name('wheel-color').id)\n ap \"#{v.id} is a bad option value for variant #{variant.id}\" unless v.nil?\n end\n end\n end\n puts \"Removed #{counter} Erroneous Option Values from Tire Products\\n\"\n end", "def validation_errors(reset = false)\n self.errors = [] if reset\n self.errors\n end", "def validations\n options_to_validations(@options)\n end", "def valid_sets; end", "def validation_rules\n []\n end", "def validate_filters_clause(errors)\n errors\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @campaign_id.nil?\n invalid_properties.push('invalid value for \"campaign_id\", campaign_id cannot be nil.')\n end\n\n if @csp_id.nil?\n invalid_properties.push('invalid value for \"csp_id\", csp_id cannot be nil.')\n end\n\n if !@reseller_id.nil? && @reseller_id.to_s.length > 8\n invalid_properties.push('invalid value for \"reseller_id\", the character length must be smaller than or equal to 8.')\n end\n\n if @brand_id.nil?\n invalid_properties.push('invalid value for \"brand_id\", brand_id cannot be nil.')\n end\n\n if @brand_id.to_s.length > 8\n invalid_properties.push('invalid value for \"brand_id\", the character length must be smaller than or equal to 8.')\n end\n\n if @usecase.nil?\n invalid_properties.push('invalid value for \"usecase\", usecase cannot be nil.')\n end\n\n if @usecase.to_s.length > 20\n invalid_properties.push('invalid value for \"usecase\", the character length must be smaller than or equal to 20.')\n end\n\n if @sub_usecases.nil?\n invalid_properties.push('invalid value for \"sub_usecases\", sub_usecases cannot be nil.')\n end\n\n if @description.nil?\n invalid_properties.push('invalid value for \"description\", description cannot be nil.')\n end\n\n if @description.to_s.length > 4096\n invalid_properties.push('invalid value for \"description\", the character length must be smaller than or equal to 4096.')\n end\n\n if [email protected]? && @sample1.to_s.length > 1024\n invalid_properties.push('invalid value for \"sample1\", the character length must be smaller than or equal to 1024.')\n end\n\n if [email protected]? && @sample2.to_s.length > 1024\n invalid_properties.push('invalid value for \"sample2\", the character length must be smaller than or equal to 1024.')\n end\n\n if [email protected]? && @sample3.to_s.length > 1024\n invalid_properties.push('invalid value for \"sample3\", the character length must be smaller than or equal to 1024.')\n end\n\n if [email protected]? && @sample4.to_s.length > 1024\n invalid_properties.push('invalid value for \"sample4\", the character length must be smaller than or equal to 1024.')\n end\n\n if [email protected]? && @sample5.to_s.length > 1024\n invalid_properties.push('invalid value for \"sample5\", the character length must be smaller than or equal to 1024.')\n end\n\n if !@message_flow.nil? && @message_flow.to_s.length > 2048\n invalid_properties.push('invalid value for \"message_flow\", the character length must be smaller than or equal to 2048.')\n end\n\n if !@help_message.nil? && @help_message.to_s.length > 255\n invalid_properties.push('invalid value for \"help_message\", the character length must be smaller than or equal to 255.')\n end\n\n if !@reference_id.nil? && @reference_id.to_s.length > 50\n invalid_properties.push('invalid value for \"reference_id\", the character length must be smaller than or equal to 50.')\n end\n\n if @mock.nil?\n invalid_properties.push('invalid value for \"mock\", mock cannot be nil.')\n end\n\n invalid_properties\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @company_name.nil?\n invalid_properties.push('invalid value for \"company_name\", company_name cannot be nil.')\n end\n\n if @is_diligence_attested.nil?\n invalid_properties.push('invalid value for \"is_diligence_attested\", is_diligence_attested cannot be nil.')\n end\n\n if @products.nil?\n invalid_properties.push('invalid value for \"products\", products cannot be nil.')\n end\n\n if @legal_entity_name.nil?\n invalid_properties.push('invalid value for \"legal_entity_name\", legal_entity_name cannot be nil.')\n end\n\n if @website.nil?\n invalid_properties.push('invalid value for \"website\", website cannot be nil.')\n end\n\n if @application_name.nil?\n invalid_properties.push('invalid value for \"application_name\", application_name cannot be nil.')\n end\n\n if @address.nil?\n invalid_properties.push('invalid value for \"address\", address cannot be nil.')\n end\n\n if @is_bank_addendum_completed.nil?\n invalid_properties.push('invalid value for \"is_bank_addendum_completed\", is_bank_addendum_completed cannot be nil.')\n end\n\n invalid_properties\n end", "def errors\n @errors ||= []\n end", "def errors\n @errors ||= []\n end" ]
[ "0.63097167", "0.6293907", "0.61331475", "0.6056487", "0.6026165", "0.5996127", "0.597741", "0.5968141", "0.5892118", "0.5881377", "0.58289206", "0.5689792", "0.5637729", "0.561269", "0.5610069", "0.5550691", "0.55502665", "0.5539877", "0.5533672", "0.55164504", "0.5509881", "0.548967", "0.5480729", "0.54788804", "0.54403776", "0.54233944", "0.5419819", "0.5396367", "0.53959733", "0.53872955", "0.5372051", "0.53706455", "0.53643984", "0.53551", "0.5343823", "0.5334466", "0.53314567", "0.5324454", "0.532341", "0.5317199", "0.53130674", "0.53110945", "0.5300283", "0.52974004", "0.5295756", "0.5284675", "0.5284413", "0.5281423", "0.5281234", "0.527833", "0.5275317", "0.52651805", "0.5264813", "0.52504766", "0.52496445", "0.5244887", "0.523382", "0.5233689", "0.5226926", "0.5223703", "0.52187216", "0.5206183", "0.5204428", "0.5204428", "0.52026886", "0.52005535", "0.52005166", "0.52005166", "0.51989776", "0.5198403", "0.5190651", "0.5184556", "0.5183922", "0.51747805", "0.51746136", "0.51649225", "0.5159883", "0.5158023", "0.5157218", "0.5156993", "0.5153715", "0.5152794", "0.5149607", "0.5145632", "0.5144722", "0.5144504", "0.5141837", "0.51410204", "0.513615", "0.51359123", "0.51354903", "0.5124154", "0.5116325", "0.51128244", "0.5109449", "0.5099571", "0.50989246", "0.509802", "0.5097853", "0.5095618", "0.5095618" ]
0.0
-1
Data passes through the filter untouched.
def test_no_raise_empty_result r = Ruote.filter( [ { 'field' => 'x', 't' => 'array', 'has' => 'a' } ], { 'x' => %w[ a b c ] }, :no_raise => true) assert_equal( { 'x' => %w[ a b c ] }, r) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_filter\n end", "def filter (data)\n # leave the data untouched if we don't support the required filter\n return data if @filter.nil?\n\n # decode the data\n self.send(@filter, data)\n end", "def filter\n end", "def filter\n super\n end", "def preprocess_data\n # Remove things if needed\n if @filter_keys\n @input = @input.delete_if{|k, v| !@filter_keys.include?(k)}\n end\n end", "def Filter=(arg0)", "def filter; end", "def filter; end", "def filter; end", "def _update_dataset\n apply_instance_filters(super)\n end", "def get_filtered_data(data)\n self.get_filter_backends.each do |filter_class|\n filter = filter_class.new(controller: self)\n data = filter.get_filtered_data(data)\n end\n\n return data\n end", "def filter!; end", "def filter_data(data, action)\n params_combinator = ParamsOperators::Retriever.new(data, action)\n params_combinator.run\n end", "def add_filter\n @filter = true \n end", "def filter\n @filter\n end", "def filter_argument; end", "def filters=(_arg0); end", "def filters=(_arg0); end", "def filters; end", "def filters; end", "def filter_parameters; end", "def filter_parameters; end", "def get_filtered_data(data)\n ordering = self._get_ordering\n reorder = [email protected](:ordering_no_reorder)\n\n if ordering && !ordering.empty?\n return data.send(reorder ? :reorder : :order, _get_ordering)\n end\n\n return data\n end", "def get_filtered_data(data)\n filter_params = self._get_filter_params\n unless filter_params.blank?\n return data.where(**filter_params)\n end\n\n return data\n end", "def filters\n end", "def filterable?; @filterable; end", "def after_update\n super\n clear_instance_filters\n end", "def _refresh(ds)\n clear_instance_filters\n super\n end", "def apply_filter(type, request, ds)\n if filter = filter_for\n ds = filter.call(ds, type, request)\n end\n ds\n end", "def populate_filters(_inputs)\n super.tap do\n self.class.filters.each do |name, filter|\n next if given?(name)\n\n model_field = self.class.model_field_cache_inverse[name]\n next if model_field.nil?\n\n value = public_send(model_field)&.public_send(name)\n public_send(\"#{name}=\", filter.clean(value, self))\n end\n end\n end", "def unfiltered_content; end", "def unfiltered_content; end", "def unfiltered_content; end", "def filter_parameters=(_arg0); end", "def filter_parameters=(_arg0); end", "def to_filter\n to_hash.to_filter\n end", "def filter\n\t\treturn @filter\n\tend", "def filtered_dataset\n dataset\n end", "def filter(options={})\n super\n end", "def filtered_entries; end", "def validate_filter\n ensure_filter_only_attributes\n ensure_no_unsupported_filters\n end", "def strict_filters=(_arg0); end", "def prepare_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n self.data_grid.in_data.each do |d|\n if col.sort_by.class == Symbol\n col.filter_data << d.send(col.sort_by)\n else\n # Call lambda\n col.filter_data << col.field.call(d, self.data_grid)\n end\n end\n\n col.filter_data.uniq!\n col.filter_data.sort!\n end\n end\n end", "def unfiltered\n cached_dataset(:_unfiltered_ds){clone(:where => nil, :having => nil)}\n end", "def filter(record)\n true\n end", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def filter_data\n case params[:filter][:info]\n when 'Public'\n @tag = Tag.find_by(tag: 'Public')\n when 'Basketball Courts'\n @tag = Tag.find_by(tag: 'Basketball Courts')\n when 'Book Store'\n @tag = Tag.find_by(tag: 'Book Store')\n end\n\n @joins = Tagtoilet.where('tag_id = ?', @tag.id)\n @toilets = @joins.map{|join| Toilet.find(join.toilet_id)}\n @toilets.to_json\n end", "def strict_filters; end", "def prepare_filters\n params = instance_values.symbolize_keys\n filters = clean_params(params)\n validate_filters(filters)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n end", "def filter(data)\n data.delete_if { |key, value| value.nil? }\n %w(plot tagline overview).each do |key|\n if data[key].respond_to?('first')\n data[key] = data[key].first\n end\n data[key] = data[key].gsub(FILTER_HTML, '') unless data[key].blank?\n end\n data\n end", "def filter_items\n @filter_items ||= []\n end", "def clean_filters\n cleaned_filters = {}\n self.filters.each do |name, value|\n if (self.filter_options[name.to_sym][:fields].detect{|f| f[:value] == value } rescue false)\n cleaned_filters[name.to_sym] = value\n end\n end\n self.filters = cleaned_filters\n end", "def entry_filter; end", "def filters_halted\n end", "def autofilter\n true\n end", "def _filter_display\n @apotomo_emit_raw_view = true\n render :view => '_filters'\n end", "def clear_filter\n @filter_string = ''\n @found_count = -1\n model.refilter\n filter\n end", "def filterhash\n @filter_hash\n end", "def set_filter(opts)\n opts = check_params(opts,[:filters])\n super(opts)\n end", "def filter_params\n @filter_params_cache ||= clean_hash(params[:filter]).with_indifferent_access\n end", "def filter_callback=(value)\r\n @filter = value\r\n end", "def reset_filters\n @_filters = []\n end", "def filter\n params['filter_field'] || '*'\n end", "def filter(value)\n @filter_rx = value\n end", "def filtered_parameters; end", "def global_filter=(_arg0); end", "def update!(**args)\n @composite_filter = args[:composite_filter] if args.key?(:composite_filter)\n @value_filter = args[:value_filter] if args.key?(:value_filter)\n end", "def update!(**args)\n @composite_filter = args[:composite_filter] if args.key?(:composite_filter)\n @value_filter = args[:value_filter] if args.key?(:value_filter)\n end", "def freeze\n instance_filters.freeze\n super\n end", "def filter\n do_authorize_class\n\n filter_response, opts = Settings.api_response.response_advanced(\n api_filter_params,\n Access::ByPermission.dataset_items(current_user, dataset_id: params[:dataset_id]),\n DatasetItem,\n DatasetItem.filter_settings(:reverse_order)\n )\n\n respond_filter(filter_response, opts)\n end", "def filter_for(item)\n self.class.filter_for filter, item\n end", "def filter(value)\n true\n end", "def filtered_for_json\n self\n end", "def update_filter_values!\n values = self.get_unique_filter_values\n unless values.empty?\n if self.is_numeric?\n self.update(min: values[:MIN], max: values[:MAX])\n else\n self.update(filters: values.to_a)\n end\n else\n false # did not get any results back, meaning :retrieve_unique_filter_values encountered an error\n end\n end", "def collect_data( data )\n data\n end", "def reset_filter!\n skip_before_action(:filter_access_filter) if method_defined?(:filter_access_filter)\n before_action :filter_access_filter\n end", "def filter=(val)\n set_filter(val)\n val\n end", "def cache_content_filter_data\n if name && name_id_changed?\n self.lifeform = name.lifeform\n self.text_name = name.text_name\n self.classification = name.classification\n end\n self.where = location.name if location && location_id_changed?\n end", "def filter(field, value)\n @filters << [field, value]\n @loaded = false\n self\n end", "def global_filter; end", "def filter\n @filter = params[:q]\n end", "def filter_cache; end", "def reloadTableOnFilteredData(notification)\n self.filteredData = notification.object.filteredData\n reloadTable\n end", "def before filter\n @station.before filter\n end", "def filter=(value)\n # nil and false disable the filter\n return @filter = false unless value # rubocop:disable Lint/ReturnInVoidContext\n\n @filter = value.to_s.downcase\n end", "def remove_filters!\n @filters = []\n end", "def filters\n @filters ||= {}\n end", "def filtered_dataset\n filter_args_from_query.inject(@dataset) do |filter, cond|\n filter.filter(cond)\n end\n end", "def filter(*args)\n raise NotImplementedError, 'Subclass should implement.'\n end", "def process_chain(data, filter_chain)\n # First we extract the data through the chain...\n filter_chain.each do |filter|\n data = filter.extract(data)\n end\n\n # Then we process the data through the chain *backwards*\n filter_chain.reverse.each do |filter|\n data = filter.process(data)\n end\n\n # Finally, a little bit of cleanup, just because\n data.gsub!(/<p><\\/p>/) do\n ''\n end\n\n data\n end", "def named_filter; end", "def getResponse(request)\n filter(request) || super\n end", "def filter\n Options.new(yield self)\n end", "def parse_filter(filter_argument = T.unsafe(nil), &filter_proc); end", "def filter_collection!\n return if filtering_params.blank?\n\n filtering_params.each do |key, value|\n filter_key = \"filter_#{key}\"\n next if value.blank? || !collection.respond_to?(filter_key)\n\n self.collection = collection.public_send(filter_key, value)\n end\n end", "def apply_filter(data, filter_model)\n filter_type = filter_model.filter_type\n variable_name = filter_model.variable_name;\n value1 = filter_model.value1\n value2 = filter_model.value2\n\n case filter_type\n when 'equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where(filter_hash)\n\n when 'not_equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where.not(filter_hash)\n\n when 'greater_than'\n data = data.where(\"#{variable_name} > ?\", value1)\n\n when 'greater_than_or_equal'\n data = data.where(\"#{variable_name} >= ?\", value1)\n\n when 'less_than'\n data = data.where(\"#{variable_name} < ?\", value1)\n\n when 'less_than_or_equal'\n data = data.where(\"#{variable_name} <= ?\", value1)\n\n when 'from_to'\n data = data.where(\"#{variable_name} >= ? AND #{variable_name} <= ?\", value1, value2)\n\n else\n data\n end\n end" ]
[ "0.73198223", "0.727851", "0.6986365", "0.69258344", "0.68093973", "0.67999554", "0.67747253", "0.67747253", "0.67747253", "0.66480863", "0.6638826", "0.65939313", "0.6557193", "0.64786696", "0.6453575", "0.6348987", "0.63480335", "0.63480335", "0.6346679", "0.6346679", "0.63219064", "0.63219064", "0.6289964", "0.6283038", "0.6257855", "0.6212346", "0.61433375", "0.614261", "0.6131446", "0.61256886", "0.6124843", "0.6124843", "0.6124843", "0.6124551", "0.6124551", "0.6111539", "0.61028564", "0.6083573", "0.6078815", "0.60677665", "0.60629404", "0.6041419", "0.6039752", "0.60269743", "0.6007306", "0.59926236", "0.59926236", "0.59926236", "0.59926236", "0.593819", "0.590338", "0.5893532", "0.5892048", "0.58910906", "0.58809763", "0.5870454", "0.58683586", "0.58535033", "0.5843823", "0.583211", "0.58233684", "0.58151424", "0.58067536", "0.5794926", "0.5780834", "0.57752985", "0.5767812", "0.5754734", "0.5754226", "0.5753329", "0.57512033", "0.5745911", "0.5745911", "0.5734418", "0.5730021", "0.57298374", "0.57234323", "0.5720907", "0.5713599", "0.5696909", "0.56847143", "0.56732506", "0.5666815", "0.5656476", "0.56498086", "0.56427556", "0.5640988", "0.56274396", "0.5627191", "0.56149757", "0.5609468", "0.5601201", "0.5595954", "0.5594602", "0.5588454", "0.5586816", "0.5581748", "0.55714333", "0.55633736", "0.5555757", "0.5551675" ]
0.0
-1
Returns a list of repository names which match `regexp`
def repository_names list_repos .select { |repo| repo["name"] =~ regexp } .map { |repo| repo["name"] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(*pattern)\n pattern = pattern.join('*')\n pattern << '*' unless pattern =~ /\\*$/\n \n packages = []\n @repositories.select{|label,_| @active.include? label }.each do |label, repos|\n repos.each do |repo|\n packages.concat(repo.scan(pattern))\n end\n end\n packages\n end", "def project_names\n repositories.map { |s| s.match(/[^\\/]*$/)[0] }\n end", "def select_regexp_matching_images(re_hn)\n Docker::Image.all.select { |img|\n info_map = img.info\n info_map && info_map['RepoTags'] && info_map['RepoTags'].any? { |n| n.match re_hn }\n }\nend", "def list(pattern = /.*/)\n if Gem::Specification.respond_to?(:each)\n Gem::Specification.select{|spec| spec.name =~ pattern }\n else\n Gem.source_index.gems.values.select{|spec| spec.name =~ pattern }\n end\n end", "def find_gems(match, options={})\n return [] unless defined?(::Gem)\n ::Gem.search(match)\n end", "def search_repo(query)\n repos = load_and_cache_user_repos\n results = repos.select do |repo|\n repo['name'] =~ Regexp.new(query, 'i')\n end\n results += search_all_repos(query) if query =~ %r{\\/}\n results.uniq\n end", "def find_projects(regex, match_attribute=:name)\n project_list = projects\n\n project_list.find_all do |project|\n project[match_attribute] =~ regex\n end\n end", "def container_repository_name_regex\n @container_repository_regex ||= %r{\\A[a-z0-9]+((?:[._/]|__|[-])[a-z0-9]+)*\\Z}\n end", "def get_all(regexp)\n Jamie::Config::Collection.new(\n __getobj__.find_all { |i| i.name =~ regexp }\n )\n end", "def static_list_repositories\n %w[https://github.com/iwc-workflows/sars-cov-2-variation-reporting.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-ont-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-se-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/parallel-accession-download.git\n https://github.com/iwc-workflows/sars-cov-2-consensus-from-variation.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-ivar-analysis.git\n https://github.com/iwc-workflows/fragment-based-docking-scoring.git\n https://github.com/iwc-workflows/protein-ligand-complex-parameterization.git\n https://github.com/iwc-workflows/gromacs-mmgbsa.git\n https://github.com/iwc-workflows/gromacs-dctmd.git].map { |r| { 'clone_url' => r }}\n end", "def list_repositories(file)\n repository_text = file.read\n int, varchar, function = self.int, self.varchar, self.function\n fields = [int, varchar, varchar, function, function]\n record_re = /#{'\\\\((' + fields.join( '),(' ) + ')\\\\)'}/\n results = []\n repository_text.scan(record_re) do |id_match, abbreviation_match, short_description_match, created_at_match, updated_at_match|\n id = Integer(id_match)\n abbreviation = abbreviation_match[1..-2]\n short_description = short_description_match[1..-2]\n created_at = created_at_match\n updated_at = updated_at_match\n #puts id_match, abbreviation_match, short_description_match, created_at_match, updated_at_match\n results << [id, abbreviation, short_description, created_at, updated_at]\n end\n results\n end", "def github_url_matching(url)\n matches = /github\\.com.(.*?)\\/(.*)/.match(url)\n matches ? [matches[1], matches[2].sub(/\\.git\\z/, '')] : [nil, nil]\n end", "def find_all_regex(sCOMMAND)\n array = Array.new()\n search =/#{sCOMMAND}/\n @commands.each do |command|\n if (command.commandName.match(search) )\n array.push(command)\n end\n\n end\n return array\n end", "def filterRepositories\n\tEnumerator.new { |repos|\n\t\twhile (gets)\n\t\t\trepo = Repo.new\n\t\t\t$_.sub!(/\\(via.*?\\)/, '') # Remove 'via' annotation in line.\n\t\t\trepo.name, repo.type, repo.url = $_.split(/\\s+/)\n\t\t\t\n\t\t\trepo.score = 0\n\t\t\t\n\t\t\trepos << repo\n\t\tend\n\t}.group_by{|repo| repo.name}.values.each{|repoList|\n\t\tprintBest repoList\n\t}\nend", "def list_namespace(regex = '.*')\n pattern = java.util.regex.Pattern.compile(regex)\n list = @admin.listNamespaces\n list.select { |s| pattern.match(s) }\n end", "def parse_sources(filename, regex)\n results = search(\"filename:#{filename} #{@github_search_query}\")\n log \"Parsing #{results.count} #{filename}s\"\n files = results.reduce({}) do |memo, result|\n # We might have more than one dep file in a repository...\n memo[result[:name]] ||= []\n memo[result[:name]] += extract_deps(result[:content], regex)\n log '.'\n memo\n end\n log \"done!\\n\"\n files\n end", "def git_grep\n # grep on the root object implies searching on HEAD\n grep = @repo.grep(query, nil, ignore_case: true)\n grep.map do |treeish, matches|\n _sha, filename = treeish.split(':', 2)\n SearchResult.new(filename, @score, *matches)\n end.sort\n end", "def extract_svn_contributor_names_from_text(text)\n text =~ /\\[([^\\]]+)\\]\\s*$/ ? [$1] : []\n end", "def repo_names_for_dev_mode(list, devmode)\n if devmode =~ /\\//\n [devmode]\n else\n list[0..1]\n end\n end", "def possible_regexes(w)\n possible = []\n w_as_regex = escape_regex(w)\n\n # Here we specify many different functions that generate regex criterias,\n #\n # For example, /\\$10/ and /\\$[0-9]+/ for $10\n possible << w_as_regex\n possible << w_as_regex.gsub(/[0-9]/, \"[0-9]+\")\n\n possible.uniq.map { |p| Regexp.new(p, Regexp::IGNORECASE) }\n end", "def config_list(regex)\n\t\tcmd = \"git config -f #{@config_file} \" +\n\t\t \"--get-regexp 'environment.#{@env}.#{regex}'\"\n\n\t\tbegin\n\t\t\t@command.\n\t\t\t run_command_stdout(cmd).\n\t\t\t split(\"\\n\").\n\t\t\t map { |l| l.split(/\\s+/, 2) }.\n\t\t\t map { |item|\t[item[0].gsub(\"environment.#{@env}.\", ''), item[1]] }\n\t\trescue Giddyup::CommandWrapper::CommandFailed => e\n\t\t\tif e.status.exitstatus == 1\n\t\t\t\t# \"Nothing found\", OK then\n\t\t\t\treturn []\n\t\t\telse\n\t\t\t\traise RuntimeError,\n\t\t\t\t \"Failed to get config list environment.#{@env}.#{regex}\"\n\t\t\tend\n\t\tend\n\tend", "def grep(word)\n git(\"grep --ignore-case --word-regexp --extended-regexp \\\"#{word}\\\"\").chomp.split(\"\\n\").map {|match|\n name, line = match.split /:\\s*/, 2\n\n if name =~ /binary file (.+) matches/i\n name = $1\n line = \"&lt;binary file&gt;\"\n end\n\n [object_for(name), line]\n }\n end", "def match(regexp); end", "def dir_git(git,branch='master',reg=nil)\n path = http_uri + git + '/trees/master' \n raw = raw_file(path)\n # find all files\n array = Array.new\n reg = Regexp.new(reg) if reg.is_a?(String)\n raw.scan(/file.*\\n.*<a href=\"\\/.*>(.*)<\\/a>.*<\\/td>/) do |name|\n if reg\n array << name.to_s if name.to_s.match(reg)\n else \n array << name.to_s\n end\n end\n return array\n end", "def regexify(glob)\n glob.gsub! '.', '\\\\.'\n rx = glob.split '*'\n rs = '^' + rx[0]\n rs << '.*'\n rs << rx[-1] if rx.length == 2\n rs << '$'\n Regexp.new rs\nend", "def search(gem_pattern, platform_only = T.unsafe(nil)); end", "def find_repo_by_keyword(keyword)\n Repo.all.select do |repo|\n if repo.description != nil\n repo.description.downcase.include?(keyword)\n end\n end\n end", "def search_regex\n str = ArchiveConfig.autocomplete[:separator] + search_param\n Regexp.new(Regexp.escape(str) + \"$\", Regexp::IGNORECASE)\n end", "def extract_field(field, regexp, save_path = false)\n lambda do |release, links|\n possible_releases = links.select do |link|\n link.content =~ regexp\n end\n possible_releases.map do |link|\n result = {\n link: link,\n field => link.content.match(regexp).captures.first\n }\n result[:repo_url] = \"#{release[:url]}#{link[:href]}\" if save_path\n result\n end\n end\n end", "def get_local_files regexp\n Dir[File.join(dir, '*')].select do |path|\n name = File.basename path\n File.file?(path) and name =~ regexp\n end\n end", "def find_by_matching_url(url)\n [url, url.sub('.git', ''), \"#{url.sub('.git', '')}.git\"].uniq.map do |lookup_url|\n find_by_clone_url(lookup_url) || find_by_url(lookup_url)\n end.compact.first\n end", "def grep(file, regexp, &block)\n if block_given?\n File.open(file, 'r').each {|line| line.chomp!; block[line] if line =~ regexp }\n else\n lines = []\n File.open(file, 'r').each {|line| line.chomp!; lines << line if line =~ regexp }\n lines\n end\n end", "def list_tags (git, pattern)\n\n\tis_tag = /refs\\/tags\\//\n\tis_release = Regexp.new (pattern ||= \".+\")\n\n\tbegin\n\n\t\twalker = Rugged::Walker.new(git)\n\t\twalker.push(git.head.target_id)\n\n\trescue Rugged::ReferenceError => err\n\t\t# -- there are likely no commits in the repo,\n\t\t# -- and no HEAD reference. Say there are no tags.\n\n\t\treturn [ ]\n\n\trescue Exception => err\n\n\t\tputs err.message\n\t\texit 1\n\n\tend\n\n\tcommits = walker.map do |commit|\n\t\t{\n\t\t\t:sha => commit.oid,\n\t\t\t:date => commit.time.to_time.to_i\n\t\t}\n\tend\n\n\twalker.reset\n\n\tgit\n\t.references\n\t.select {|ref| is_tag .match(ref.name)}\n\t.select {|ref| is_release.match(File.basename(ref.name))}\n\t.map {|ref|\n\n\t\ttarget_commit = git.lookup(ref.target.oid).target\n\n\t\t{\n\t\t\t:time => target_commit.time.to_time.to_i,\n\t\t\t:sha => target_commit.oid,\n\t\t\t:name => File.basename(ref.name)\n\t\t}\n\t}\n\nend", "def find_substring_matching_artifact( artifacts, pattern )\n\t\tpattern = Regexp.new( Regexp.escape(pattern), Regexp::IGNORECASE )\n\n\t\treturn artifacts.find do |obj|\n\t\t\t(obj.respond_to?( :names ) && obj.names.find {|name| name.to_s =~ pattern} ) ||\n\t\t\t(obj.respond_to?( :name ) && obj.name.to_s =~ pattern ) ||\n\t\t\t(obj.respond_to?( :oid ) && obj.oid =~ pattern )\n\t\tend\n\tend", "def repository\n if ladnn?\n ['University of California, Los Angeles. Library. Department of Special Collections']\n else\n # Replace marc codes with double dashes and no surrounding spaces\n map_field(:repository)&.map { |a| a.gsub(/ \\$[a-z] /, ' ') }\n end\n end", "def find_files(search_pattern, opts = {})\n fetch!\n search_pattern = Regexp.new(search_pattern)\n res = []\n unless @repo.empty?\n tree = @repo.head.target.tree\n _find_files(search_pattern, tree, nil, res)\n end\n res\n end", "def search(gem_pattern, version_requirement=Version::Requirement.new(\">= 0\"))\n #FIXME - remove duplication between this and RemoteInstaller.search\n gem_pattern = /#{ gem_pattern }/i if String === gem_pattern\n version_requirement = Gem::Version::Requirement.create(version_requirement)\n result = []\n @gems.each do |full_spec_name, spec|\n next unless spec.name =~ gem_pattern\n result << spec if version_requirement.satisfied_by?(spec.version)\n end\n result = result.sort\n result\n end", "def pids_by_regexp(regexp)\n matched = {}\n process_tree.each do |pid,process|\n matched[pid] = process if process[:cmd] =~ regexp\n end\n matched\n end", "def find_all_plugin_names(*pattern)\n find_all_plugin_specs(*pattern).map do |spec|\n spec.plugin_name\n end\n end", "def search(gem_pattern, version_requirement=Version::Requirement.new(\">= 0\"))\n gem_pattern = /#{ gem_pattern }/i if String === gem_pattern\n version_requirement = Gem::Version::Requirement.create(version_requirement)\n result = []\n @gems.each do |full_spec_name, spec|\n next unless spec.name =~ gem_pattern\n result << spec if version_requirement.satisfied_by?(spec.version)\n end\n result = result.sort\n result\n end", "def find(*pattern)\n # Create a glob pattern from the user's input, for instance\n # [\"rails\",\"2.3\"] => \"rails*2.3*\"\n pattern = pattern.join('*')\n pattern << '*' unless pattern =~ /\\*$/\n \n packages = []\n repositories = Qwandry::Configuration.repositories\n repositories.each do |repo|\n packages.concat(repo.scan(pattern))\n end\n \n differentiate packages\n packages\n end", "def find_regex(words)\n Array(words).map do |w|\n regexes_for_word = []\n\n possible_regexes(w).each do |regex|\n #puts \"Word: #{w} against #{regex} -> #{w =~ regex}\"\n if w =~ regex\n regexes_for_word << regex\n end\n end\n\n regexes_for_word.uniq\n end\n end", "def repo_named(full_name)\n pry(Git::Multi.repositories.find { |repo| repo.full_name == full_name })\nend", "def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end", "def repositories\n octokit.repositories('zold-io').map { |json| json['full_name'] }\n end", "def matches(directory, extension)\n matches = []\n Find.find(directory) do |path|\n ext = File.extname(path)\n matches << path if ext && ext.downcase == extension\n end\n matches\n end", "def extract_contributor_names(repo)\n names = extract_candidates(repo)\n names = canonicalize(names)\n names.uniq\n end", "def reprepro_registered_files(debian_pkg_name, release_name,\n suffix_regexp)\n reprepro_dir = File.join(deb_repository, release_name)\n Dir.glob(File.join(reprepro_dir,\"pool\",\"main\",\"**\",\"#{debian_pkg_name}#{suffix_regexp}\"))\n end", "def regex_files(files, regex=nil)\n array = files.nil? ? [] : files\n if !files.nil? && !regex.nil?\n exp = Regexp.new(regex)\n array = files.select do |file|\n file_name = File.basename(file, \".*\")\n match = exp.match(file_name)\n !match.nil? # return this line\n end\n end\n return array\nend", "def matching_lines(regex); end", "def matches(s, re)\r\n start_at = 0\r\n matches = [ ]\r\n while(m = s.match(re, start_at))\r\n matches.push(m)\r\n start_at = m.end(0)\r\n end\r\n return matches\r\n end", "def ovl_glob(rel_pattern)\n gem_files = Dir.glob(File.join(GEM_ROOT, rel_pattern)).map do |path|\n path.sub(GEM_ROOT+\"/\", \"\")\n end\n\n (gem_files + Dir.glob(rel_pattern)).uniq\n end", "def ovl_glob(rel_pattern)\n gem_files = Dir.glob(File.join(GEM_ROOT, rel_pattern)).map do |path|\n path.sub(GEM_ROOT+\"/\", \"\")\n end\n\n (gem_files + Dir.glob(rel_pattern)).uniq\n end", "def search(match)\n if File.directory?(match)\n name = File.basename(match)\n return [Template.new(name, match, :type=>:project)]\n end\n\n hits = templates.select do |template|\n match == template.name\n end\n if hits.size == 0\n hits = templates.select do |template|\n /^#{match}/ =~ template.name\n end\n end\n return hits\n end", "def files_regex_search\n page = params[:page].to_i.positive? ? params[:page] : 1\n files = user_real_files(params, @context).files_conditions\n begin\n regexp = Regexp.new(params[:search_string], params[:flag])\n direction = params[:order_by_name]\n\n search_result = files.\n eager_load(:license, user: :org).\n order(name: direction.to_s).\n map do |file|\n describe_for_api(file) if file.name.downcase.scan(regexp).present?\n end\n\n result = []\n if search_result.compact.present?\n result = UserFile.files_search_results(search_result, direction)\n end\n\n paginated_result = Kaminari.paginate_array(result).page(page).per(20)\n uids = params[:uids].present? && to_bool(params[:uids]) ? result.compact.pluck(:uid) : []\n\n render json: { search_result: paginated_result, uids: uids }\n rescue RegexpError => e\n fail \"RegEx Invalid: #{e}\"\n end\n end", "def create_match(nominee)\n names = []\n pname = nominee[:name]\n names << pname\n names << pname.sub(%r{ [A-Z]\\. }, ' ') # drop initial\n personname = ASF::Person.find(nominee[:id]).public_name\n names << personname if personname\n list = names.uniq.map{|name| Regexp.escape(name)}.join('|')\n # N.B. \\b does not match if it follows ')', so won't match John (Fred)\n # TODO: Work-round is to also look for EOS, but this needs to be improved\n %r{\\b(#{list})(\\b|$)}i\nend", "def multireg(regpexp, str)\n result = []\n while regpexp.match(str)\n result.push regpexp.match(str)\n str = regpexp.match(str).post_match\n end\n result\n end", "def from_with_regex(cmd, *regex_list)\n regex_list.flatten.each do |regex|\n _status, stdout, _stderr = run_command(command: cmd)\n return \"\" if stdout.nil? || stdout.empty?\n\n stdout.chomp!.strip\n md = stdout.match(regex)\n return md[1]\n end\n end", "def get_repos\n\t\trepo_list = []\n\t\tparsed_config = begin\n\t\t\tYAML.load(File.open(@path_to_config_yml))\n\t\trescue ArgumentError => e\n \t\t\tputs \"Could not parse YAML: #{e.message}\"\n\t\tend\n\t\tparsed_config['sections'].each do |section|\n\t\t\trepo_list.push(section['repository']['name'].gsub(/\\w*-?\\w*\\//,''))\n\t\tend\n\t\trepo_list.sort\n\tend", "def regexp; end", "def regexp; end", "def scan\n list = []\n io.each do |input|\n # TODO: limit to text files, how?\n begin\n text = read(input)\n text.scan(regex) do\n list << Match.new(input, $~)\n end\n rescue => err\n warn(input.inspect + ' ' + err.to_s) if $VERBOSE\n end\n end\n list\n end", "def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend", "def list\n Dir.chdir @root do\n cmd = \"git branch\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.split.map { |s|\n # Remove trailing/leading whitespace and astericks\n s.sub('*', '').strip\n }.reject { |s|\n # Drop elements created due to trailing newline\n s.size == 0\n }\n end\n end", "def obtainDrivers(contents)\n\n # variable to hold the list of drivers\n drivers = []\n\n # for every line...\n contents.each do |line|\n\n # use regex to ensure the line matches the expected\n captures = /^Driver ([A-Za-z]{1,64})$/.match(line)\n\n # safety check, ensure the capture isn't nil\n if captures.nil?\n next\n end\n\n # if the regex capture has a length of at least one,\n # push it to the list of drivers\n if captures.length > 0\n drivers.push(captures[1])\n end\n end\n\n # return the list drivers\n return drivers\nend", "def find_repos( datasets )\n repos = []\n datasets.each do |dataset|\n league_key = dataset[0]\n league = Writer::LEAGUES[ league_key ]\n pp league\n path = league[:path]\n\n ## use only first part e.g. europe/belgium => europe\n repos << path.split( %r{[/\\\\]})[0]\n end\n pp repos\n repos.uniq ## note: remove duplicates (e.g. europe or world or such)\nend", "def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end", "def grep(pattern, treeish=head) # :yields: path, blob\n options = pattern.respond_to?(:merge) ? pattern.dup : {:e => pattern}\n options.delete_if {|key, value| nil_or_empty?(value) }\n options = options.merge!(\n :cached => true,\n :name_only => true,\n :full_name => true\n )\n \n unless commit = grit.commit(treeish)\n raise \"unknown commit: #{treeish}\"\n end\n \n sandbox do |git, work_tree, index_file|\n git.read_tree({:index_output => index_file}, commit.id)\n git.grep(options).split(\"\\n\").each do |path|\n yield(path, (commit.tree / path))\n end\n end\n self\n end", "def cmd_list pattern = '.'\n puts \"Following mnemo's #{pattern && \"matching regexp /#{pattern}/\"} are present\"\n puts\n references_by_pattern(pattern).each do |reference|\n puts (\" \" * 4) + reference\n end\n\n puts\n puts \"Done ..\"\n end", "def url_pattern\n %r{\n (?:^|\\W) # beginning of string or non-word char\n (?:(#{qualifier_regex})(?:\\s))? # qualifier (optional)\n https://github.com/\n (#{REPOSITORY_NAME}) # repository name\n /(?:issues|pulls)/\n (\\d+) # issue number\n (?=\n \\.+[ \\t]| # dots followed by space or non-word character\n \\.+$| # dots at end of line\n [^0-9a-zA-Z_.]| # non-word character except dot\n $ # end of line\n )\n }ix\n end", "def extract_svn_contributor_names_diffing(repo)\n extract_changelog!(repo) unless changelog\n changelog.split(\"\\n\").map do |line|\n extract_svn_contributor_names_from_text(line)\n end.flatten\n end", "def matches(s, re)\n start_at = 0\n matches = []\n while(m = s.match(re, start_at))\n matches.push(m)\n start_at = m.end(0)\n end\n matches\n end", "def get_repo_paths\n\t\t\tpaths = {}\n\t\t\tpathspec = read_command_output( 'hg', 'paths' )\n\t\t\tpathspec.split.each_slice( 3 ) do |name, _, url|\n\t\t\t\tpaths[ name ] = url\n\t\t\tend\n\t\t\treturn paths\n\t\tend", "def get_repo_list\n Chef::Log.debug(\n \"Fetching all versions of #{new_resource.module_name} \" +\n \"from #{new_resource.repository}.\",\n )\n latest = powershell_out!(\n <<-EOH,\n $splat = @{\n Name = \"#{new_resource.module_name}\"\n Repository = \"#{new_resource.repository}\"\n AllVersions = $True\n }\n (Find-Module @splat).Version.ForEach({$_.ToString()})\n EOH\n ).stdout.to_s.chomp.split(\"\\r\\n\")\n Chef::Log.debug(\"Available versions: #{latest.join(', ')}\")\n\n return latest.map { |v| Gem::Version.new(v) }\n end", "def get_patterns(pattern_string)\r\n split_and_strip(pattern_string, \";\").select do |name|\r\n name != \"\"\r\n end.map {|name| Regexp.new(name, true)}\r\n end", "def search_names(logins)\n logins.select { |x| x[0].end_with?(\"_\")}\nend", "def extract_svn_contributor_names_diffing(repo)\n cache_git_show!(repo) unless git_show\n return [] if only_modifies_changelogs?\n extract_changelog.split(\"\\n\").map do |line|\n extract_contributor_names_from_text(line)\n end.flatten\n end", "def searchFor\n %w{*.lua */*.lua}\n end", "def scan(name)\n raise NotImplementedError, \"Repositories must return an Array of matching packages.\"\n end", "def grep(pattern = '.*')\n regexp = Regexp.new(pattern)\n fetch_items_from_filesystem_or_zip\n @items = items.shift(2) + items.select {|i| i.name =~ regexp}\n sort_items_according_to_current_direction\n draw_items\n draw_total_items\n switch_page 0\n move_cursor 0\n end", "def list\n @repos\n end", "def extract_contributor_names(repo)\n names = imported_from_svn? ? extract_svn_contributor_names(repo) : [author]\n names = handle_special_cases(names)\n names = canonicalize(names)\n names.uniq\n end", "def find_reg_ex_matches( reg_ex )\n match_set = Set.new\n @words_set.to_a.each do |word|\n match_set.add word if word.downcase.match(reg_ex)\n end\n match_set\n end", "def add_regexp(regexp)\n starting_chars = regexp.starting_chars\n if starting_chars.kind_of? Symbol \n scanning_table.default = regexp\n else\n common_chars = starting_chars.select { |c| scanning_table.has_key? c } \n starting_chars = starting_chars - common_chars\n starting_chars.each { |c| scanning_table[c] = regexp }\n colliding_states = common_chars.map { |c| scanning_table[c] }\n colliding_states.uniq!\n colliding_states.zip(common_chars).each { |r,c| scanning_table[c] = RegexpSpecification.mix(regexp,r) }\n end\t\n \n if @built\n build\n end\n \n self\n end", "def list(**options)\n result = []\n\n search = options[:pattern].to_s.downcase\n group = options[:group].to_s.downcase\n\n @data.each do |item|\n next if item.empty?\n next unless group.empty? || group.eql?(item.group.to_s.downcase)\n\n host = item.host.to_s.downcase\n comment = item.comment.to_s.downcase\n\n next unless host =~ /^.*#{search}.*$/ || comment =~ /^.*#{search}.*$/\n\n result.push(item)\n end\n\n result\n end", "def get_gem_names\n fetcher = Gem::SpecFetcher.fetcher\n\n list, = fetcher.available_specs(:complete)\n\n tuples = list.values.first\n\n tuples.map do |tuple,|\n tuple = tuple.to_a\n case tuple.last\n when Gem::Platform::RUBY then\n tuple[0, 2]\n else\n tuple\n end.join '-'\n end\n end", "def search(search_string)\n root = EmployeeFolder.root\n result = []\n key = search_string.downcase\n Dir.glob(\"#{root}/*/*\") do |folder|\n next unless Dir.exist? folder\n next unless folder[key]\n\n employee_spec = parse_dir folder\n next if project? employee_spec\n\n result << employee_spec.to_employee\n end\n result\n end", "def extract_candidates(repo)\n names = authors_of_special_cased_commits\n if names.nil?\n names = extract_contributor_names_from_text(message)\n if names.empty?\n names = extract_svn_contributor_names_diffing(repo) if imported_from_svn?\n if names.empty?\n sanitized = sanitize([author])\n names = handle_special_cases(sanitized)\n if names.empty?\n names = sanitized\n end\n end\n end\n end\n names\n end", "def filter_matched_files\n matched_files = []\n\n unless file_extensions.empty?\n extensions = file_extensions.reduce do |total, extension|\n total + \"|\" + extension.downcase\n end\n extensions_regex = \"^(.+\" + extensions + \")$\"\n (git.modified_files + git.added_files).each do |file|\n matched_files += [file] unless file.downcase.match(extensions_regex).nil?\n end\n end\n\n unless file_patterns.empty?\n (git.modified_files + git.added_files).each do |line|\n file_patterns.each do |pattern|\n matched_files += [line] unless line.downcase.match(pattern.downcase).nil?\n end\n end\n end\n\n return [matched_files].flatten.compact\n end", "def matches(ext)\n ext =~ /^\\.org$/i\n end", "def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend", "def find_matches(bucket, word)\n\t\tmatches = bucket.map do |exp, match|\n\t\t\tword =~ exp ? match : nil\n\t\tend\n\t\tmatches.compact\n\tend", "def search(match, options={})\n all = options[:all]\n\n matches = []\n\n each do |name, libs|\n case libs\n when Array\n libs = [libs.max] unless all\n else\n libs = [libs]\n end\n\n libs.sort.each do |lib|\n matches.concat(lib.search(match))\n end\n end\n\n matches.uniq\n end", "def match(regexp)\n return regexp.match(pickle_format)\n end", "def search_packages(pattern)\n packages = RailsPwnerer::Base.all_packages\n Hash[packages.select { |key, value|\n pattern.kind_of?(Regexp) ? (pattern =~ key) : key.index(pattern)\n }.map { |key, value|\n # apt-cache search sometimes leaves version numbers out\n # Update the cache with version numbers.\n if value.nil?\n info = RailsPwnerer::Base.package_info_hash(\n Kernel.`(\"apt-cache show #{key}\"))\n packages[key] = value = info['Version']\n end\n [key, value]\n }]\n end", "def regexp_variables\n return @regexp_variables if @regexp_variables\n @regexp_variables = Array.new\n @base_theme.scan(VARIABLE_MATCHER) { @regexp_variables << $2 }\n @regexp_variables\n end", "def find_cartridges(name)\n logger.debug \"Finding cartridge #{name}\" if @mydebug\n regex = nil\n if name.is_a?(Hash)\n name = name[:name] if name[:name]\n regex = name[:regex] if name[:regex]\n end\n\n filtered = Array.new\n cartridges.each do |cart|\n if regex\n filtered.push(cart) if cart.name.match(regex)\n else\n filtered.push(cart) if cart.name == name\n end\n end\n return filtered\n end", "def find_test_plans(project_id, regex, match_attribute=:name)\n test_plan_list = test_plans(project_id)\n matched_list = []\n\n if @version >= \"1.0\"\n matched_list = test_plan_list.find_all do |plan|\n plan[match_attribute] =~ regex\n end\n elsif @version < \"1.0\"\n test_plan_list.first.each_value do |plan|\n matched_list << plan if plan[match_attribute] =~ regex\n end\n end\n\n matched_list\n end", "def maybe_matcher *pattern\n submatcher = pattern_matcher(*pattern)\n\n lambda do |string, index = 0, counts:|\n found = submatcher.call(string, index, counts: counts)\n\n if match? found\n found\n else\n []\n end\n end\n end", "def search (pattern)\n\t\tputs \"Search host store based on the regular expression: #{pattern}\" if @verbose\n\t\tpattern=pattern.strip.downcase\n\t\tresults=Array.new\n\t\t@known_hosts.keys.map do |key|\n\t\t\tif key =~ /#{pattern}/i\n\t\t\t\tresults.push(key)\n\t\t\tend\n\t\tend\n\t\treturn results\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn nil\n\tend" ]
[ "0.6415419", "0.5925132", "0.5876544", "0.5816987", "0.58096206", "0.5753673", "0.57511854", "0.573421", "0.5671197", "0.5576498", "0.55317396", "0.5436508", "0.5408711", "0.5378251", "0.53703976", "0.53390735", "0.53325284", "0.53101224", "0.5300954", "0.52593154", "0.5238979", "0.52367073", "0.52327853", "0.5231444", "0.52118385", "0.52039725", "0.51981837", "0.5181132", "0.51696426", "0.51639634", "0.5141943", "0.51353604", "0.5121147", "0.5110165", "0.5099846", "0.5098038", "0.5092234", "0.50765455", "0.50693256", "0.5063252", "0.5042741", "0.50418544", "0.50392103", "0.50344986", "0.50342995", "0.5033097", "0.5021718", "0.5010665", "0.50069267", "0.50061685", "0.49923638", "0.49862838", "0.49862838", "0.49851355", "0.4968773", "0.49548325", "0.49528533", "0.495198", "0.49338204", "0.4917841", "0.4917841", "0.48890057", "0.4887557", "0.48812872", "0.48768076", "0.48728052", "0.48676354", "0.48564208", "0.48515436", "0.48364463", "0.4832522", "0.4829941", "0.4826199", "0.48261458", "0.48155358", "0.48147714", "0.4807141", "0.48066005", "0.47966358", "0.4775766", "0.4775473", "0.4773635", "0.47639278", "0.47624096", "0.47602352", "0.47557437", "0.47549486", "0.47505224", "0.4738387", "0.47368032", "0.47266936", "0.47253823", "0.47242877", "0.472202", "0.47219178", "0.47207958", "0.47189674", "0.4716856", "0.47148433", "0.47043252" ]
0.7954824
0
TODO: figure out a way to only fetch cloudplatform repos deduplicate the code filter out archived repos filter out disabled repos
def list_repos repos = [] end_cursor = nil data = get_repos(end_cursor) repos = repos + data.fetch("nodes") next_page = data.dig("pageInfo", "hasNextPage") end_cursor = data.dig("pageInfo", "endCursor") while next_page do data = get_repos(end_cursor) repos = repos + data.fetch("nodes") next_page = data.dig("pageInfo", "hasNextPage") end_cursor = data.dig("pageInfo", "endCursor") end repos.reject { |r| r.dig("isArchived") || r.dig("isDisabled") } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def get_qualifying_repos\n if !authenticated?\n authenticate!\n end\n\n # Get Github data.\n\n repos = client.repositories\n username = client.user.login\n\n # Compile a list of repositories for projecs that we've already used.\n user = User.find_by(github_id: client.user.id)\n used_repos = Array.new\n my_books = Book.where(\"user_id = ?\", user.id)\n [*my_books].each do |book|\n used_repos << book[:repo_id]\n end\n\n # Identify the names claimed for github user/organization pages. There may\n # be a better way to remove them than string detection, but I'll use it for\n # now, since it looks like that's what github uses and I don't know beter.\n name_match_1 = username + '.github.io' #=> octocat.github.io\n name_match_2 = username + '.github.com' #=> octocat.github.com\n\n # Iterate through our array of github repos and delete ones from the list\n # that don't qualify for a new book-site.\n repos.delete_if do |repo|\n # Remove this repo if it matches the name for a user/org page project.\n if repo.name == name_match_1 || repo.name == name_match_2\n true\n # Remove this repo if it has already been used for a book.\n elsif used_repos.include? repo.id\n true\n # Remove this repo if it doesn't belong to this user. This is designed to\n # remove repos you are a \"collaborator\" on.\n elsif username != repo.full_name.split('/')[0]\n true\n else\n # This repo is good... return false to prevent deleting it.\n false\n end\n end\n\n return repos\nend", "def get_my_repos\n repos = []\n\n (1..get_total_repo_pages_count.to_i).each do |index|\n get_json( \"#{ GITHUB_USER_REPOS_URL }?per_page=100&page=#{ index }\" ).each do |item|\n repos << item[ 'full_name' ]\n end\n end\n\n return repos\nend", "def repositories_with_pull_requests(reponames = [])\n repositories = []\n page = 1\n loop do\n repositories_in_page = load_repos_in_page(page)\n break if repositories_in_page.empty?\n repositories.concat(repositories_in_page)\n page += 1\n end\n repositories.select! { |repo| reponames.include?(repo.name) } unless reponames.empty?\n repositories.select!(&:any_pull_requests?)\n repositories\n end", "def acquire_repo_list\n set_auth\n set_github_repo_name\n repo_list = []\n (@github.repos.list org: GITHUB_ORG).each do |l|\n repo_list << l[:name]\n end\n repo_list\nend", "def get_github_repos_already_cloned\n repos = Array.new\n\n configatron.dir.children.each do |repo_name|\n if repo_name.directory?\n begin\n repo = Github.repos.get(\n user: ENV['GITHUB_ACCOUNT'],\n oauth_token: ENV['GITHUB_API_TOKEN'],\n repo: repo_name.basename.to_s\n )\n rescue Exception => e\n puts \"\\n#{e}\"\n next\n end\n repos << repo if repo.fork\n end\n end # configatron.dir.children.each do |repo_name|\n\n return repos\nend", "def get_repo_names github_username , git_token\n\n Rails.cache.fetch(\"#{self.id}/repo_names\", expires_in: 6.hours) do\n repo_names = Array.new\n github = Github.new :oauth_token => git_token\n\n github.repos.list.body.each do |repo|\n if github_username == repo[\"owner\"][\"login\"]\n repo_names << { :user=>github_username ,:repo=>repo[\"name\"]}\n end\n end\n\n orgs_names = Array.new\n github.orgs.list.each do |org|\n orgs_names << org[\"login\"]\n end\n\n orgs_names.each do |oname|\n url = \"orgs/\"+oname+\"/repos\"\n \n github.get_request(url,Github::ParamsHash.new({})).each do |orepo|\n if oname == orepo[\"owner\"][\"login\"]\n repo_names << { :user=>oname ,:repo=>orepo[\"name\"]}\n end\n end\n end\n repo_names\n end\n end", "def get_repositories\n get(\"#{url_base}/repositories?#{dc}\")[\"data\"]\n end", "def find_repositories\n @repos = GithubApi.call :repos\n end", "def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend", "def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend", "def repos\n client.repos({}, query: { sort: \"asc\" })\n end", "def get_repos(provisioner_server_node, platform, version)\n admin_ip = Chef::Recipe::Barclamp::Inventory.get_network_by_type(provisioner_server_node, \"admin\").address\n web_port = provisioner_server_node[:provisioner][:web_port]\n provisioner_web = \"http://#{admin_ip}:#{web_port}\"\n default_repos_url = \"#{provisioner_web}/suse-#{version}/repos\"\n\n repos = Mash.new\n\n case platform\n when \"suse\"\n repos = Mash.new\n repos_from_attrs = suse_get_repos_from_attributes(provisioner_server_node,platform,version)\n\n case version\n when \"11.3\"\n repo_names = %w(\n SLE-Cloud\n SLE-Cloud-PTF\n SUSE-Cloud-5-Pool\n SUSE-Cloud-5-Updates\n SLES11-SP3-Pool\n SLES11-SP3-Updates\n )\n when \"12.0\"\n repo_names = %w(\n SLE12-Cloud-Compute\n SLE12-Cloud-Compute-PTF\n SLE-12-Cloud-Compute5-Pool\n SLE-12-Cloud-Compute5-Updates\n SLES12-Pool\n SLES12-Updates\n )\n else\n raise \"Unsupported version of SLE/openSUSE!\"\n end\n\n # Add the new (not predefined) repositories from attributes\n repos_from_attrs.each do |name,repo|\n repo_names << name unless repo_names.include? name\n end\n\n # This needs to be done here rather than via deep-merge with static\n # JSON due to the dynamic nature of the default value.\n repo_names.each do |name|\n repos[name] = repos_from_attrs.fetch(name, Mash.new)\n suffix = name.sub(/^SLE-Cloud/, 'Cloud')\n repos[name][:url] ||= default_repos_url + '/' + suffix\n end\n\n # optional repos\n unless provisioner_server_node[:provisioner][:suse].nil?\n [[:hae, :missing_hae], [:storage, :missing_storage]].each do |optionalrepo|\n unless provisioner_server_node[:provisioner][:suse][optionalrepo[1]]\n suse_optional_repos(version, optionalrepo[0]).each do |name|\n repos[name] = repos_from_attrs.fetch(name, Mash.new)\n repos[name][:url] ||= default_repos_url + '/' + name\n end\n end\n end\n end\n end\n\n repos\n end", "def repos\n api.repos.map(&:to_hash)\n end", "def repos(config_hash)\n if config_hash[\"organizations\"]\n repos = []\n config_hash[\"organizations\"][\"orgs\"].each do |org|\n # grab all the full repo names in this org. If no type is specified use public and also skip the forks\n # we also skip anything in the blacklist array\n repos << github.org_repos(org, type: config_hash[\"organizations\"][\"type\"] || \"public\")\n .collect { |x| x[\"full_name\"] unless x[\"fork\"] || x[\"archived\"] || (config_hash[\"organizations\"][\"blacklist\"] && config_hash[\"organizations\"][\"blacklist\"].include?(x[\"full_name\"])) }\n end\n repo_list = repos.flatten.compact.sort # return a single sorted array w/o nils\n puts \"Based on the provided org(s) (#{config_hash[\"organizations\"][\"orgs\"].join(',')}) managing the following repos: #{repo_list.join(', ')}\"\n repo_list\n elsif config_hash[\"repositories\"]\n config_hash[\"repositories\"]\n else\n puts \"Config does not include either 'repositories' or 'organizations' sections. Cannot continue!\"\n exit!\n end\nend", "def repos(opts={ push: false, details: false, orgs: true })\n repos = @client.repositories.map {|repo| parse_repo repo}\n @client.organizations.each do |org|\n repos += @client.organization_repositories(org.login).map {|repo| parse_repo repo}\n end\n repos.reject! {|repo| !repo[:push]} if opts[:push]\n repos.map { |repo| repo[:full_name] } unless opts[:details]\n end", "def list_repositories\n return static_list_repositories if false\n super.select do |repo|\n sleep 1\n begin\n github[\"repos/#{repo['full_name']}/contents/.dockstore.yml\"].head\n sleep 1\n rescue RestClient::NotFound\n output.puts \"No .dockstore.yml found in #{repo['full_name']}, skipping\"\n end\n end\n end", "def get_repos\n\t\t@repos = Repo.all\n\tend", "def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client = Octokit::Client.new(:access_token => user.password)\n repo_list = []\n client.repositories(:user => user.gh_username).each { |repo|\n repo_list.push(repo.name)\n }\n render :json => {:repos => repo_list}\n end", "def pull_requests repo\n name = full_name repo\n \n %w[open closed].reduce([]) do |memo, state|\n memo | octokit.pulls(name, state, :per_page=>100)\n end\n end", "def get_app_repositories\n json_response = @client.list_installation_repos\n\n repository_list = []\n if json_response.count > 0\n json_response[\"repositories\"].each do |repo|\n repository_list.push(repo[\"full_name\"])\n end\n else\n puts json_response\n end\n\n repository_list\nend", "def all\n repos = self.class.load_json(repos_url)\n repos.map! { |repo| self.class.filter_repo_info(repo) }\n self.class.slice_in(repos, 3)\n end", "def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end", "def show_repo_list\n # Synchronize user's id_github with Git Hub (4 days between refreshs)\n @owner.sync_github!(4.days).save!\n \n # Synchronize list of user's projects (4 hours between refreshs)\n if @owner.sync_projects_delay?(4.hours)\n github_projects = @owner.get_github_projects\n \n if github_projects\n @owner.upd_projectlist_at = Time.now\n repos = CacheRepo.where(path: github_projects)\n \n # Drop any projects than no more exist in the user space\n if repos.length > 0\n CacheRepo.where.not(id: repos.map(&:id)).where(owner: @owner).delete_all\n end\n \n # Add any new project to this user\n (github_projects - repos.map(&:path)).each do |github_project_new|\n new_project = CacheRepo.new(path: github_project_new, owner: @owner)\n # Alway be aware of we have multiple workers and possibility concurrent insert\n if !new_project.save\n new_project = CacheRepo.where(path: github_project_new).first\n new_project.owner = @owner\n new_project.save!\n end\n end\n end\n @owner.save!\n end\n \n # Repository information will be refreshed only if the user request it\n # So, this action is more light than #show_repo_details\n @projects = CacheRepo.where(owner: @owner)\n respond_to do |format|\n format.html { render }\n format.json { render :show_repo_list, status: :ok, location: @owner }\n end\n end", "def repos\n @repos ||= (user_repos + org_repos).flatten\n end", "def travis_repos\n x = $travis_conn.get 'owner/ropenscibot/repos'\n x.travis_raise\n return MultiJson.load(x.body)\nend", "def fetch_syncables\n gh_client.repos.list.select{|repo| repo.permissions.admin}.map(&:full_name)\n end", "def repos\n @client.repos.all.collect(&:clone_url)\n end", "def get_supported_addons_from_github\n uri_per_page = \"#{AddonsReposForksURI}&per_page=#{@github_results_per_page}\"\n all_forks = execute_request_uri( URI.parse(uri_per_page) )\n\n print \"[INFO] NB Fork Repositories in exo-addons organization (supported and not supported): \",all_forks.length,\"\\n\\n\"\n print \"[INFO][SUPPORTED_ADDONS] --------\\n\"\n all_forks.each {\n |fork_repo|\n # Each supported Addon repository is a fork from eXo blessed (exoplatform organization).\n # This method gets the repository details form GitHub to find parent url information.\n result = execute_request_uri( URI.parse(fork_repo[\"url\"]) )\n parent_ssh_url = result[\"parent\"][\"ssh_url\"];\n\n #check if the parent is in exoplatform organization\n if(parent_ssh_url.include? \"github.com:exoplatform\")\n fork_repo[\"ssh_url_fork_parent\"] = parent_ssh_url\n self.log(INFO,fork_repo[\"name\"], \"git ssh-url: #{result[\"parent\"][\"ssh_url\"]}\")\n @addons_supported.push(fork_repo)\n end\n }\n print \"[INFO][SUPPORTED_ADDONS] --------\\n\"\n end", "def static_list_repositories\n %w[https://github.com/iwc-workflows/sars-cov-2-variation-reporting.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-ont-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-se-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/parallel-accession-download.git\n https://github.com/iwc-workflows/sars-cov-2-consensus-from-variation.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-ivar-analysis.git\n https://github.com/iwc-workflows/fragment-based-docking-scoring.git\n https://github.com/iwc-workflows/protein-ligand-complex-parameterization.git\n https://github.com/iwc-workflows/gromacs-mmgbsa.git\n https://github.com/iwc-workflows/gromacs-dctmd.git].map { |r| { 'clone_url' => r }}\n end", "def find_repos(user)\n user.repos\n end", "def get_my_pull_requests\n repos_to_get = GITHUB_REPOS.kind_of?( Array ) ? GITHUB_REPOS : get_my_repos\n\n repos_to_get.each do |repo|\n status = []\n pulls_url = \"#{ GITHUB_REPOS_URL }/#{ repo }/pulls?state=open\"\n\n get_json( pulls_url ).each_with_index do |item, index|\n sha = item[ 'head' ][ 'sha' ]\n status_url = \"#{ GITHUB_REPOS_URL }/#{ repo }/commits/#{ sha }/status\"\n\n status << get_json( status_url )\n\n unless item[ 'assignee' ].nil?\n if item[ 'assignee' ][ 'login' ] == ENV[ 'GITHUB_USERNAME' ]\n color = ''\n state = status[ index ][ 'state' ]\n\n unless status[ index ][ 'statuses' ].empty?\n color = \"| color=#{ determine_status_color( state )}\"\n end\n\n puts \"#{ repo }: ##{ item[ 'number' ] } #{ item[ 'title' ] } #{ color } | href=#{ item[ 'html_url' ] }\"\n end\n end\n end\n end\nend", "def fetch_projects!\n projects.destroy_all\n\n if github?\n result = YAML.load open(\"http://github.com/api/v2/yaml/repos/show/#{github}/\")\n\n result['repositories'].each do |repository|\n projects.create! :name => repository[:name], :description => repository[:description]\n end\n end\n rescue OpenURI::HTTPError # user not found, ignore\n end", "def get_repo(repo_id)\n response=client.extensions.repository.retrieve_with_details(repo_id)\n code=response.code\n body=response.body\n case code\n when 200\n repo=JSON.parse(body.to_json)\n type = repo[\"notes\"][\"_repo-type\"]\n #puts repos\n repo_data=nil\n case type\n when REPO_TYPE_RPM\n yum_distributor = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'yum_distributor'}[0]\n yum_importer = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'yum_importer'}[0]\n distributor = nil\n if yum_distributor\n distributor = {\n :auto_publish => yum_distributor[\"auto_publish\"],\n :last_publish => yum_distributor[\"last_publish\"],\n :config => yum_distributor[\"config\"]\n }\n end\n importer = nil\n if yum_importer\n importer = {\n :last_sync => yum_importer[\"last_sync\"],\n :config => yum_importer[\"config\"]\n }\n end\n\n repo_data={\n :id => repo[\"id\"],\n :name => repo[\"display_name\"],\n :description => repo[\"description\"],\n :content_unit_counts => repo[\"content_unit_counts\"],\n :type => REPO_TYPE_RPM,\n :last_unit_removed => repo[\"last_unit_removed\"],\n :last_unit_added => repo[\"last_unit_added\"],\n :distributor => distributor,\n :importer => importer,\n }\n #puts repos\n when REPO_TYPE_PUPPET\n puppet_distributor = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'puppet_distributor'}[0]\n distributor =nil\n if puppet_distributor\n distributor = {\n :auto_publish => puppet_distributor[\"auto_publish\"],\n :last_publish => puppet_distributor[\"last_publish\"],\n :config => puppet_distributor[\"config\"]\n }\n end\n repo_data={\n :id => repo[\"id\"],\n :name => repo[\"display_name\"],\n :description => repo[\"description\"],\n :content_unit_counts => repo[\"content_unit_counts\"],\n :type => REPO_TYPE_PUPPET,\n :last_unit_removed => repo[\"last_unit_removed\"],\n :last_unit_added => repo[\"last_unit_added\"],\n :distributor => distributor\n }\n else\n end\n repo_data\n else\n raise \"Exception: cannot get repository detail: response code :#{code}\"\n end\n end", "def repos\n super.sort\n end", "def list\n @repos\n end", "def get_list\n @list_of_repos\n end", "def repos\n @repos ||= OY.repos\n end", "def repos\n pry(Git::Multi.repositories)\nend", "def repos\n ReposAPI.new(self)\n end", "def get_repos\n begin\n @repos ||= github_api_setup.repos.list\n rescue Exception => e\n logger.error \"Github #get_repos error #{e}\"\n end\n end", "def get_repos\n @api.list_repositories\n end", "def repositories\n # TODO : merge with current data\n load_repos\n end", "def all_repos\n\t\tif GitHosting.multi_repos?\n\t\t repositories\n\t\telse\n\t\t [ repository ].compact\n\t\tend\n\t end", "def get_repos\n\t\tif current_user.nil?\n\t\t\t@repos = Repo.where(:user_id => nil)\n\t\telse\n\t\t\t@repos = current_user.repos\n\t\tend\n\tend", "def repositories\n Repository.where(user_id: group_ids).or(membered_repositories).order(\"updated_at desc\")\n end", "def repositories\n @repositories ||= (organization.exists? ? organization.repositories : client.list_repositories)\n end", "def repos\n @repos ||= get(\"/repos/show/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def process_repos\n url_template = if @options.preview\n 'https://api.github.com/search/issues?q=is:pr+repo:cockpit-project/REPO+label:release-note'\n else\n 'https://api.github.com/search/issues?q=is:pr+repo:cockpit-project/REPO+label:release-note+is%3Aclosed'\n end\n tags_template = 'https://api.github.com/repos/cockpit-project/REPO/tags'\n\n @repos.map do |repo|\n # Grab relevant issues for the repo\n url = url_template.sub('REPO', repo)\n\n # Process versions\n url_tags = tags_template.sub('REPO', repo)\n versions = get_json(url_tags).map { |tag| tag['name'].to_i }.sort\n # Set the Cockpit version from the first repo (which is always Cockpit)\n @cockpit_version ||= versions.last + @increment\n\n notes = get_json(url)['items']\n .map { |issue| format_issue(issue, repo) }\n\n process_meta(repo, versions) unless notes.empty?\n\n notes\n end\nend", "def execute\n get_repo(repo_name).repo.fetch\n end", "def gather_repos(books)\n\tbooks.each do |book|\n\t\tYAML.load(File.open(Dir.home + '/workspace/' + book + '/config.yml'))['sections'].each do |section| \n\t\t\t@repo_list.push(section['repository']['name'])\n\t\tend\n\tend\n\t@repo_list.delete('cloudfoundry/uaa')\n\treview_check @repo_list.uniq\nend", "def fetch_watched_repos\n toggle! :fetching_repos\n\n sidekiq_logger.info { \"[#{username}] Fetching watched repos...\" }\n\n github_watched.each do |wr|\n attrs = wr.slice(:name, :language, :description, :fork, :private, :size,\n :forks, :open_issues, :pushed_at, :created_at, :updated_at)\n\n if repo = Repo.find_by_id(wr.id)\n repo.attributes = attrs.merge({:watchers_count => wr.watchers})\n else\n repo = Repo.new(attrs.merge({:watchers_count => wr.watchers}))\n repo.id = wr.id\n end\n\n repo.owner = User.find_or_create_by_username(wr.owner.login)\n repo.save\n\n unless watchings.exists?(repo.id)\n watchings << repo\n sidekiq_logger.info { \"[#{username}] now watching #{wr.name}\" }\n end\n end\n\n sidekiq_logger.info { \"[#{username}] Completed fetching watched repos\" }\n\n prune_unwatched_repos\n\n toggle! :fetching_repos\n end", "def projects_with_repository_enabled\n Project.has_module(:repository).find(:all, :include => :repository, :order => 'identifier')\n end", "def find_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # get user input from API\n user_input_string = request.params[:_json]\n input_arr = user_input_string.gsub(/\\s+/, \"\").split(\",\")\n\n # search repos using user input\n repoids = input_arr.map do |input|\n repo = @client.repository(input)\n \"#{repo.to_hash[:id]}\"\n end\n\n # Save user search input and repos to UserPreference\n @current_user.UserPreference.search_input = user_input_string\n @current_user.UserPreference.repos = repoids.join(\",\")\n @current_user.UserPreference.save\n\n respond_to do |format|\n format.json {\n render json: repoids.to_json, status: 200\n }\n end\n end", "def repo_commits(repos)\n repos_commits = []\n repos.each do |repo|\n repos_commits << HTTParty.get(repo[\"commits_url\"].gsub(\"{/sha}\", \"\"))[0]\n end\n repos_commits\nend", "def get_public_repos(user_name)\n get(\"/users/#{user_name}/repos\")\n end", "def filterRepositories\n\tEnumerator.new { |repos|\n\t\twhile (gets)\n\t\t\trepo = Repo.new\n\t\t\t$_.sub!(/\\(via.*?\\)/, '') # Remove 'via' annotation in line.\n\t\t\trepo.name, repo.type, repo.url = $_.split(/\\s+/)\n\t\t\t\n\t\t\trepo.score = 0\n\t\t\t\n\t\t\trepos << repo\n\t\tend\n\t}.group_by{|repo| repo.name}.values.each{|repoList|\n\t\tprintBest repoList\n\t}\nend", "def org_repos\n @org_repos ||= (\n talk 'org repos'\n logins = orgs.map { |org| org[:login] }\n\n logins.map do |login|\n talk \"repos for #{login}\"\n client.organization_repositories login.to_s\n end.flatten\n )\n end", "def show_repo_details\n # Synchronize repo with Git Hub (1 day between refreshs)\n @repo.sync_github!(1.day).save!\n \n # Synchronize contributors (1 hour between refreshs)\n if @repo.sync_contribs_delay?(1.hour)\n github_contributors_login = @repo.get_github_contributors\n \n if github_contributors_login\n users = CacheUser.where(login: github_contributors_login)\n\n # Drop any relation with old contributors - I think i've wasted my time\n if users.length > 0\n CacheContrib.where(cache_repo_id: @repo).where.not(cache_user_id: users.map(&:id)).delete_all\n end\n\n # Add new contributors with empty personal data\n new_users = github_contributors_login - users.map(&:login)\n new_users.each do |github_login_new|\n CacheUser.create(login: github_login_new)\n end\n \n # Make link for each contributor\n current_contribs = CacheUser.joins(:cache_contribs).where(cache_contribs: {cache_repo_id: @repo.id})\n CacheUser.where(login: github_contributors_login).where.not(id: current_contribs).each do |user|\n user.cache_contribs.build(cache_repo: @repo)\n user.save\n end\n end\n \n @repo.upd_userlist_at = Time.now\n @repo.save!\n end\n \n # Load contributors from cache, contributors without personal data or too old are first\n # Nota : I use this method because a simple select order by synced_on show nil in first\n # but I read than oracle put them at the end depending server configuration. This suck !\n @users = CacheUser.never_synced.only_repo(@repo).order(:updated_at)\n @users.merge CacheUser.synced_from(4.days).only_repo(@repo).order(:synced_on, :updated_at)\n \n # Update contributors personal data if too old or never updated\n if @users.length > 0\n maxlist = @users.length <= 148 ? @users.length : 148 # Not exceed 148 personal data requests\n \n # Synchronize personal data of contributors : Old method\n # -> not enought efficient with large contributors list\n # @users[0...maxlist].each {|contributor| contributor.reload.sync_github!(4.days).save!}\n\n # Synchronize personal data of contributors : Use threads for concurrent requests\n work_queue = Queue.new \n # Add to the working queue all logins to proceed by threads\n @users[0...maxlist].map(&:login).each {|github_login| work_queue.push github_login}\n \n # Launch up to 10 threads\n # Warning : Each worker use a connection from ActiveRecord's pool. See database.yml for\n # set the pool size (count also the connection for this main thread).\n workers = (0...10).map do\n Thread.new do\n until work_queue.empty? do\n github_login = work_queue.pop(true) rescue nil\n if github_login\n user = CacheUser.where(login: github_login).first\n if user\n user.sync_github!(4.days).save!\n end\n end\n end\n end\n end\n workers.map(&:join) # Wait all threads finished before proceeding further \n end\n # Reload fresh data.\n @users = CacheUser.only_repo(@repo)\n respond_to do |format|\n format.html { render }\n format.json { render :show_repo_details, status: :ok, location: @repo }\n end\n end", "def repos(show_commits = false)\n response = @github.repos.list(user: 'siakaramalegos', sort: 'updated', direction: 'desc', page: 1, per_page: 10)\n repos = response.body\n\n repos.each_with_index do |repo, index|\n puts '-' * 80\n date_string = repo.updated_at\n date = DateTime.parse(date_string).to_date\n puts \"(#{index + 1}) #{repo.name}: #{repo.description} (updated: #{date.stamp('12/30/99')})\"\n\n if show_commits\n repo_commits = @github.repos.commits.list('siakaramalegos', repo.name, page: 1, per_page: 10).body\n\n repo_commits.each do |c|\n date_string = c.commit.author.date\n date = DateTime.parse(date_string).to_date\n puts \" #{c.commit.message} (#{date.stamp('12/30/99')})\"\n end\n end\n end\n puts '-' * 80\n repos\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def all_repos\n if GitHosting.multi_repos?\n repositories\n else\n [ repository ].compact\n end\n end", "def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end", "def github_projects\n Rails.cache.fetch(\"/users/#{self.id}/github_projects\", :expires_in => 1.day) {\n gh = Github.new(authentications.where(:provider => 'github').first.provider_token)\n gh.repos\n }\n end", "def get_watched_repos\n @repos.each do |r|\n if r.name.downcase == 'txtout'\n @watched.store('txtout', r.id)\n end\n if r.name.downcase == 'resumemonster'\n @watched.store('resumemonster', r.id)\n end\n end\n end", "def get_repo_list(token, user)\n query = %{\n query ($user: String!, $cursor: String) {\n user(login: $user) {\n repositories(first: 100, after: $cursor) {\n edges {\n node {\n name\n owner {\n login\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n }\n\n vars = { user: user, cursor: nil }\n\n repos = []\n\n loop do\n result = Github.query(token, query, vars)\n repos += result.dig(\"data\", \"user\", \"repositories\", \"edges\") || []\n break unless result.dig(\"data\", \"user\", \"repositories\", \"pageInfo\", \"hasNextPage\")\n vars[:cursor] = result.dig(\"data\", \"user\", \"repositories\", \"pageInfo\", \"endCursor\")\n end\n\n repos.map { |e| { owner: e.dig(\"node\", \"owner\", \"login\"), name: e.dig(\"node\", \"name\") } }\nend", "def user_repos\n @user_repos ||= (\n talk 'user repos'\n client.repos\n )\n end", "def repos(*args)\n params = arguments(args, required: [:q]).params\n params['q'] ||= arguments.q\n\n get_request('/search/repositories', arguments.params)\n end", "def filter_out_used_repos\n Yast::SourceManager.ReadSources\n\n @repositories.delete_if do |repo|\n Yast::SourceManager.getSourceId(repo.url) != -1\n end\n end", "def clone_repos(repos, shallow=true)\n repos.each do |repo|\n name = repo['name']\n subtitle \"Cloning #{name}\"\n url = repo['clone_url']\n if File.exist?(name)\n puts 'Already cloned'\n else\n if shallow\n system(\"git\", \"clone\", url, \"--depth\", \"1\", \"--recursive\")\n else\n system(\"git\", \"clone\", url)\n end\n end\n end\nend", "def request_repo_data\n self.class.get(\"/#{@repo}\", headers: {\n 'Authorization' => \"token #{@token}\",\n 'User-Agent' => 'stefanrush/weightof.it'\n })\n end", "def fetch_repositories(repos = nil)\n # Init git settings\n Git.configure do |config|\n config.binary_path = \"#{@config['git']['path']}\"\n end\n @return_repos = []\n # Loop through repos and fetch it\n repos_to_fetch = repos.nil? ? self.repositories_to_fetch : repos\n repos_to_fetch.each do |repo|\n if File.directory?(repo)\n # Get branches\n g = Git.bare(\"#{repo}\", :log => @log)\n g.remotes.each do |remote|\n # Determine which \"remote\" to fetch e.g. \"git fetch github\"\n if @config['provider'].include?(\"#{remote}\")\n @log.info(\"Fetching remote #{remote} in #{repo}\")\n g.remote(remote).fetch\n @return_repos << repo\n end\n end\n end\n end\n @return_repos\n end", "def repos(name=nil, params={})\n params = name if name.is_a?Hash\n prefix = name.is_a?(String) ? \"./repos/#{self[\"login\"]}/#{name}\" : \"#{path_prefix}/repos\" \n Ghee::API::Repos::Proxy.new(connection,prefix, params)\n end", "def ensure_repo_listing (repo)\n data, code = get_json(@all_repos_path)\n return code if code > 399 && code != 404\n # putting repo in the list\n if code == 404\n data = { 'repos' => { repo => 1 } }\n else\n data['repos'][repo] = 1\n end\n code = put_json_in_path(@all_repos_path, data)\n end", "def repos(*args)\n params = args.extract_options!\n normalize! params\n assert_required_keys %w[ keyword ], params\n\n get_request(\"/legacy/repos/search/#{params.delete('keyword')}\", params)\n end", "def load_repos_in_page(page)\n GitHubAPI.load_repos_in_page(name, page)\n end", "def owned_repositories_with_user(user)\n repos = owned_repositories.publics\n repos = repos.or(user.membered_repositories.where(user_id: id)) if user\n repos\n end", "def clone_repos repos\n $logger.info \"Detecting if clones repos #{repos}\"\n failed_repos = []\n repos.each do |repo|\n repo_path = \"#{GIT_DIR}/#{repo}\"\n # TODO: Use ssh instead of http\n clone_url = \"http://#{GIT_USER}:#{GIT_PASSWORD}@#{BASE_GIT_URL}:#{BASE_GIT_PORT}/scm/#{PROJECT_ID}/#{repo}.git\"\n unless `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' config --get remote.origin.url`.to_s.strip == clone_url\n $logger.info \"No git repo found or invalid git repo detected at #{repo_path}. Deleting and recloning project #{repo}\"\n # If for some reason we didn't detect that it's a git repo, just clear the whole directory\n # And reclone (note that we only need to clone the latest commit on the master branch)\n successfully_cloned = system \"git clone #{clone_url} --branch master --single-branch --depth 1 #{repo_path}\"\n unless successfully_cloned\n $logger.warn \"Could not git clone repo #{clone_url} to #{repo_path}\"\n failed_repos.push repo\n FileUtils.rm_rf repo_path\n end\n end\n # Make sure the git repos are unmodified before we do anything\n `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' reset --hard HEAD`\n end\n $logger.info \"Removing failed repos #{failed_repos}\"\n repos -= failed_repos\n return repos\nend", "def fetch\n return nil if !repo || !user\n if fetched?\n pull\n else\n clone\n end\n end", "def getprojects()\n printRepoHeader\n \n loop do\n # Print each of the new returned repositories\n begin\n get.each do |repo|\n printRepo(repo) if (@slugs.add?(repo['slug']))\n\n # Flush to prevent data loss if we crash\n STDOUT.flush\n end\n rescue Exception => msg\n STDERR.puts \"WARNING: Poll failed at #{Time.now}\"\n STDERR.puts msg\n end\n\n # Poll every 5 minutes\n sleep 300\n end\n end", "def owned_repositories_with_user(user)\n repos = self.owned_repositories.publics\n repos = repos.or(user.membered_repositories.where(user_id: self.id)) if user\n repos\n end", "def process_github_clones\n repos = get_github_repos_already_cloned\n repos.each do |r|\n # SMELL: does not work if the working copy directory does\n # not match the repo name\n clone_path = configatron.dir + r.name\n set_upstream(clone_path, r.parent.html_url)\n end\nend", "def repo_named(full_name)\n pry(Git::Multi.repositories.find { |repo| repo.full_name == full_name })\nend", "def repository_faceted_on\n return unless try(:search_state)\n repos = facets_from_request.find { |f| f.name == 'repository_sim' }.try(:items)\n faceted = repos && repos.length == 1 && repos.first.value\n Arclight::Repository.find_by(name: repos.first.value) if faceted\n end", "def repo; end", "def repo; end", "def repo; end", "def repo; end", "def get_repo_details\n user = User.find_by(uuid: params[:uuid])\n client = Octokit::Client.new(:access_token => user.password)\n repo_map = {}\n client.repository(:user => user.gh_username, :repo => params[:repo_name]).each { |detail|\n repo_map[detail[0]] = detail[1]\n }\n repo_map['languages'] = client.languages(:user => user.gh_username, :repo => params[:repo_name]).map{ |langArray|\n langArray[0]\n }\n render :json => repo_map\n end", "def repository_urls(pom:, exclude_inherited: false)\n repo_urls_in_pom =\n Nokogiri::XML(pom.content).\n css(REPOSITORY_SELECTOR).\n map { |node| node.at_css(\"url\").content.strip.gsub(%r{/$}, \"\") }.\n select { |url| url.start_with?(\"http\") }\n\n return repo_urls_in_pom + [CENTRAL_REPO_URL] if exclude_inherited\n\n unless (parent = parent_pom(pom, repo_urls_in_pom))\n return repo_urls_in_pom + [CENTRAL_REPO_URL]\n end\n\n repo_urls_in_pom + repository_urls(pom: parent)\n end", "def only(repos)\n @list = [repos].flatten\n self\n end", "def do_your_stuff! organization_name\n get_members_for_org organization_name\n get_repositories_for_all_members\n get_stats_for_repositories\n end", "def prepare_cache # {:url=>'git://github.com/ddssda', :branch=>'master', :commit=>'ad452bcd'}\n\t\t\turl = @params['repo_url']\n\t\t\tsite = @params['site']\n\t\t\twd = @core.working_dir_from_site(site)\n\n\t\t\t@repo = DesignShell::Repo.new\n\t\t\tsuitable = if File.exists?(wd)\n\t\t\t\[email protected] wd\n\t\t\t\[email protected]==url\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\n\t\t\tif suitable\n\t\t\t\[email protected]\n\t\t\telse\n\t\t\t\tif File.exists? wd\n\t\t\t\t\traise RuntimeError.new('almost did bad delete') if [email protected]_dir || @core.cache_dir.length<3 || !wd.begins_with?(@core.cache_dir)\n\t\t\t\t\tFileUtils.rm_rf wd\n\t\t\t\tend\n\t\t\t\[email protected](url, wd)\n\t\t\tend\n\t\tend", "def itemsUrl(url, repo_name)\n url + '/api/repos/' + repo_name + '/items'\nend", "def query_pull_requests\n # This line is where we want to add :accept => 'application/vnd.github.shadow-cat-preview+json' for draft PRs\n pull_requests = github_query(@client) { @client.pull_requests(@repository, :state => 'open', :per_page => 50) }\n\n @pull_request_details = []\n\n pull_requests.each do |p|\n issue = github_query(@client) { @client.issue(@repository, p.number) }\n\n $logger.debug(\"Issue loaded: #{issue}\")\n\n notification_users = Set.new\n\n notification_users << issue.assignee.login if issue.assignee\n\n notification_users << p.user.login if p.user.login\n\n aging_pull_requests_notify = true\n aging_pull_requests_num_days = 7\n\n # TODO: p.head.repo can be null if the fork repo is deleted. Need to protect that here.\n if p.head.repo.nil?\n $logger.info(\"Skipping potential PR (#{p.number}): Forked repo is null (deleted?)\")\n else\n begin\n pb = PotentialBuild.new(@client, @token, p.head.repo.full_name, nil, p.head.sha, p.head.ref, p.head.user.login, nil, nil, p.number, p.base.repo.full_name, p.base.ref)\n configured_notifications = pb.configuration.notification_recipients\n unless configured_notifications.nil?\n $logger.debug(\"Merging notifications user: #{configured_notifications}\")\n notification_users.merge(configured_notifications)\n end\n\n aging_pull_requests_notify = pb.configuration.aging_pull_requests_notification\n aging_pull_requests_num_days = pb.configuration.aging_pull_requests_numdays\n\n if p.head.repo.full_name == p.base.repo.full_name\n $logger.info(\"Skipping pull-request originating from head repo: #{p.number}\")\n else\n $logger.info(\"Found an external PR to add to potential_builds: #{p.number}\")\n @potential_builds << pb\n end\n rescue DecentCIKnownError => e\n $logger.info(\"Skipping potential PR (#{p.number}): #{e}\")\n rescue => e\n $logger.info(\"Skipping potential PR (#{p.number}): #{e} #{e.backtrace}\")\n end\n end\n # TODO: Should this be here?\n @pull_request_details << {\n :id => p.number,\n :creator => p.user.login,\n :owner => (issue.assignee ? issue.assignee.login : nil),\n :last_updated => issue.updated_at,\n :repo => @repository,\n :notification_users => notification_users,\n :aging_pull_requests_notification => aging_pull_requests_notify,\n :aging_pull_requests_numdays => aging_pull_requests_num_days\n }\n end\n end", "def only(repos)\n @repositories.only repos\n\n repositories\n end", "def fetch(uuid, repo, repo_uuid = nil)\n repo_uuid ||= repo.uuid\n missing_versions = [repo.head(uuid, repo_uuid)].compact\n while true\n missing_versions = missing_versions.select do |mv|\n !has_version?(mv)\n end\n break if missing_versions.empty?\n docs = repo.get_versions(missing_versions)\n docs.each do |v,doc|\n store(v, uuid, doc, repo_uuid)\n end\n missing_versions = repo.ancestors(missing_versions)\n end\n end", "def gl_repos\n all_repos.select{|x| x.is_a?(Repository::Git)}\n end", "def list_repositories\n JSON.parse(request(:get, ''))\n end", "def normalized_repos\n v = config[:repos]\n if not v.has_key?(:CRAN)\n v[:CRAN] = config[:cran]\n end\n # If the version is less than 3.2 we need to use http repositories\n if r_version_less_than('3.2')\n v.each {|_, url| url.sub!(/^https:/, \"http:\")}\n config[:bioc].sub!(/^https:/, \"http:\")\n end\n v\n end" ]
[ "0.7197054", "0.716235", "0.70380896", "0.7015823", "0.698643", "0.6893655", "0.6891649", "0.6846303", "0.6794351", "0.6733624", "0.6726266", "0.66737413", "0.6654283", "0.6618503", "0.657773", "0.65514547", "0.65508056", "0.6537788", "0.65242136", "0.65232396", "0.6492289", "0.64828455", "0.64738756", "0.6465201", "0.6433662", "0.6425295", "0.6419641", "0.64173734", "0.6407483", "0.64071965", "0.63849056", "0.63845724", "0.6384312", "0.6377721", "0.63536483", "0.63486016", "0.63127124", "0.63094413", "0.63040197", "0.6302757", "0.6302074", "0.63005775", "0.62971735", "0.62927186", "0.62838364", "0.62817395", "0.62427145", "0.62422985", "0.6228758", "0.62188995", "0.6214343", "0.6182655", "0.616012", "0.61501133", "0.6149148", "0.6114487", "0.60789627", "0.605211", "0.6024514", "0.6013936", "0.6002817", "0.59901583", "0.5985925", "0.5964539", "0.5946592", "0.59435356", "0.59424657", "0.5941291", "0.59366125", "0.59318596", "0.59025675", "0.5886507", "0.5885701", "0.58816415", "0.5876024", "0.5875046", "0.58714676", "0.58668536", "0.5859324", "0.5855319", "0.5853601", "0.58485436", "0.5844469", "0.5844325", "0.58401316", "0.58401316", "0.58401316", "0.58401316", "0.58371866", "0.5834677", "0.5831109", "0.58240414", "0.5814875", "0.5812221", "0.5810915", "0.580421", "0.5796829", "0.5792272", "0.57831186", "0.578127" ]
0.6827068
8
TODO: it should be possible to exclude disabled/archived repos in this query, but I don't know how to do that yet, so I'm just fetching everything and throwing away the disabled/archived repos later. We should also be able to only fetch repos whose names match the pattern we're interested in, at this stage.
def repositories_query(end_cursor) after = end_cursor.nil? ? "" : %[, after: "#{end_cursor}"] %[ { organization(login: "#{organization}") { repositories(first: #{PAGE_SIZE} #{after}) { nodes { id name isLocked isArchived isDisabled } pageInfo { hasNextPage endCursor } } } } ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_repo(query)\n repos = load_and_cache_user_repos\n results = repos.select do |repo|\n repo['name'] =~ Regexp.new(query, 'i')\n end\n results += search_all_repos(query) if query =~ %r{\\/}\n results.uniq\n end", "def all\n repos = self.class.load_json(repos_url)\n repos.map! { |repo| self.class.filter_repo_info(repo) }\n self.class.slice_in(repos, 3)\n end", "def repository_names\n list_repos\n .select { |repo| repo[\"name\"] =~ regexp }\n .map { |repo| repo[\"name\"] }\n end", "def list_repos\n repos = []\n end_cursor = nil\n\n data = get_repos(end_cursor)\n repos = repos + data.fetch(\"nodes\")\n next_page = data.dig(\"pageInfo\", \"hasNextPage\")\n end_cursor = data.dig(\"pageInfo\", \"endCursor\")\n\n while next_page do\n data = get_repos(end_cursor)\n repos = repos + data.fetch(\"nodes\")\n next_page = data.dig(\"pageInfo\", \"hasNextPage\")\n end_cursor = data.dig(\"pageInfo\", \"endCursor\")\n end\n\n repos.reject { |r| r.dig(\"isArchived\") || r.dig(\"isDisabled\") }\n end", "def filterRepositories\n\tEnumerator.new { |repos|\n\t\twhile (gets)\n\t\t\trepo = Repo.new\n\t\t\t$_.sub!(/\\(via.*?\\)/, '') # Remove 'via' annotation in line.\n\t\t\trepo.name, repo.type, repo.url = $_.split(/\\s+/)\n\t\t\t\n\t\t\trepo.score = 0\n\t\t\t\n\t\t\trepos << repo\n\t\tend\n\t}.group_by{|repo| repo.name}.values.each{|repoList|\n\t\tprintBest repoList\n\t}\nend", "def repos(*args)\n params = arguments(args, required: [:q]).params\n params['q'] ||= arguments.q\n\n get_request('/search/repositories', arguments.params)\n end", "def repos(*args)\n params = args.extract_options!\n normalize! params\n assert_required_keys %w[ keyword ], params\n\n get_request(\"/legacy/repos/search/#{params.delete('keyword')}\", params)\n end", "def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end", "def repositories_with_pull_requests(reponames = [])\n repositories = []\n page = 1\n loop do\n repositories_in_page = load_repos_in_page(page)\n break if repositories_in_page.empty?\n repositories.concat(repositories_in_page)\n page += 1\n end\n repositories.select! { |repo| reponames.include?(repo.name) } unless reponames.empty?\n repositories.select!(&:any_pull_requests?)\n repositories\n end", "def get_repo_names github_username , git_token\n\n Rails.cache.fetch(\"#{self.id}/repo_names\", expires_in: 6.hours) do\n repo_names = Array.new\n github = Github.new :oauth_token => git_token\n\n github.repos.list.body.each do |repo|\n if github_username == repo[\"owner\"][\"login\"]\n repo_names << { :user=>github_username ,:repo=>repo[\"name\"]}\n end\n end\n\n orgs_names = Array.new\n github.orgs.list.each do |org|\n orgs_names << org[\"login\"]\n end\n\n orgs_names.each do |oname|\n url = \"orgs/\"+oname+\"/repos\"\n \n github.get_request(url,Github::ParamsHash.new({})).each do |orepo|\n if oname == orepo[\"owner\"][\"login\"]\n repo_names << { :user=>oname ,:repo=>orepo[\"name\"]}\n end\n end\n end\n repo_names\n end\n end", "def filter(filter, repo)\n\n return ( (filter == 'all') || ( repo.has_key?('tags') && repo['tags'].include?(filter) ) || repo['name'] == filter )\n\nend", "def repos\n client.repos({}, query: { sort: \"asc\" })\n end", "def repositories\n Repository.where(user_id: group_ids).or(membered_repositories).order(\"updated_at desc\")\n end", "def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend", "def find(*pattern)\n pattern = pattern.join('*')\n pattern << '*' unless pattern =~ /\\*$/\n \n packages = []\n @repositories.select{|label,_| @active.include? label }.each do |label, repos|\n repos.each do |repo|\n packages.concat(repo.scan(pattern))\n end\n end\n packages\n end", "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def get_repositories\n get(\"#{url_base}/repositories?#{dc}\")[\"data\"]\n end", "def get_qualifying_repos\n if !authenticated?\n authenticate!\n end\n\n # Get Github data.\n\n repos = client.repositories\n username = client.user.login\n\n # Compile a list of repositories for projecs that we've already used.\n user = User.find_by(github_id: client.user.id)\n used_repos = Array.new\n my_books = Book.where(\"user_id = ?\", user.id)\n [*my_books].each do |book|\n used_repos << book[:repo_id]\n end\n\n # Identify the names claimed for github user/organization pages. There may\n # be a better way to remove them than string detection, but I'll use it for\n # now, since it looks like that's what github uses and I don't know beter.\n name_match_1 = username + '.github.io' #=> octocat.github.io\n name_match_2 = username + '.github.com' #=> octocat.github.com\n\n # Iterate through our array of github repos and delete ones from the list\n # that don't qualify for a new book-site.\n repos.delete_if do |repo|\n # Remove this repo if it matches the name for a user/org page project.\n if repo.name == name_match_1 || repo.name == name_match_2\n true\n # Remove this repo if it has already been used for a book.\n elsif used_repos.include? repo.id\n true\n # Remove this repo if it doesn't belong to this user. This is designed to\n # remove repos you are a \"collaborator\" on.\n elsif username != repo.full_name.split('/')[0]\n true\n else\n # This repo is good... return false to prevent deleting it.\n false\n end\n end\n\n return repos\nend", "def get_repo_list(token, user)\n query = %{\n query ($user: String!, $cursor: String) {\n user(login: $user) {\n repositories(first: 100, after: $cursor) {\n edges {\n node {\n name\n owner {\n login\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n }\n\n vars = { user: user, cursor: nil }\n\n repos = []\n\n loop do\n result = Github.query(token, query, vars)\n repos += result.dig(\"data\", \"user\", \"repositories\", \"edges\") || []\n break unless result.dig(\"data\", \"user\", \"repositories\", \"pageInfo\", \"hasNextPage\")\n vars[:cursor] = result.dig(\"data\", \"user\", \"repositories\", \"pageInfo\", \"endCursor\")\n end\n\n repos.map { |e| { owner: e.dig(\"node\", \"owner\", \"login\"), name: e.dig(\"node\", \"name\") } }\nend", "def list_repositories\n return static_list_repositories if false\n super.select do |repo|\n sleep 1\n begin\n github[\"repos/#{repo['full_name']}/contents/.dockstore.yml\"].head\n sleep 1\n rescue RestClient::NotFound\n output.puts \"No .dockstore.yml found in #{repo['full_name']}, skipping\"\n end\n end\n end", "def projects_with_repository_enabled\n Project.has_module(:repository).find(:all, :include => :repository, :order => 'identifier')\n end", "def static_list_repositories\n %w[https://github.com/iwc-workflows/sars-cov-2-variation-reporting.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-ont-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-se-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/parallel-accession-download.git\n https://github.com/iwc-workflows/sars-cov-2-consensus-from-variation.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-ivar-analysis.git\n https://github.com/iwc-workflows/fragment-based-docking-scoring.git\n https://github.com/iwc-workflows/protein-ligand-complex-parameterization.git\n https://github.com/iwc-workflows/gromacs-mmgbsa.git\n https://github.com/iwc-workflows/gromacs-dctmd.git].map { |r| { 'clone_url' => r }}\n end", "def repo_named(full_name)\n pry(Git::Multi.repositories.find { |repo| repo.full_name == full_name })\nend", "def repos(opts={ push: false, details: false, orgs: true })\n repos = @client.repositories.map {|repo| parse_repo repo}\n @client.organizations.each do |org|\n repos += @client.organization_repositories(org.login).map {|repo| parse_repo repo}\n end\n repos.reject! {|repo| !repo[:push]} if opts[:push]\n repos.map { |repo| repo[:full_name] } unless opts[:details]\n end", "def get_my_repos\n repos = []\n\n (1..get_total_repo_pages_count.to_i).each do |index|\n get_json( \"#{ GITHUB_USER_REPOS_URL }?per_page=100&page=#{ index }\" ).each do |item|\n repos << item[ 'full_name' ]\n end\n end\n\n return repos\nend", "def find_repositories\n @repos = GithubApi.call :repos\n end", "def find_repo_by_keyword(keyword)\n Repo.all.select do |repo|\n if repo.description != nil\n repo.description.downcase.include?(keyword)\n end\n end\n end", "def repos(config_hash)\n if config_hash[\"organizations\"]\n repos = []\n config_hash[\"organizations\"][\"orgs\"].each do |org|\n # grab all the full repo names in this org. If no type is specified use public and also skip the forks\n # we also skip anything in the blacklist array\n repos << github.org_repos(org, type: config_hash[\"organizations\"][\"type\"] || \"public\")\n .collect { |x| x[\"full_name\"] unless x[\"fork\"] || x[\"archived\"] || (config_hash[\"organizations\"][\"blacklist\"] && config_hash[\"organizations\"][\"blacklist\"].include?(x[\"full_name\"])) }\n end\n repo_list = repos.flatten.compact.sort # return a single sorted array w/o nils\n puts \"Based on the provided org(s) (#{config_hash[\"organizations\"][\"orgs\"].join(',')}) managing the following repos: #{repo_list.join(', ')}\"\n repo_list\n elsif config_hash[\"repositories\"]\n config_hash[\"repositories\"]\n else\n puts \"Config does not include either 'repositories' or 'organizations' sections. Cannot continue!\"\n exit!\n end\nend", "def pull_requests repo\n name = full_name repo\n \n %w[open closed].reduce([]) do |memo, state|\n memo | octokit.pulls(name, state, :per_page=>100)\n end\n end", "def acquire_repo_list\n set_auth\n set_github_repo_name\n repo_list = []\n (@github.repos.list org: GITHUB_ORG).each do |l|\n repo_list << l[:name]\n end\n repo_list\nend", "def fetch_watched_repos\n toggle! :fetching_repos\n\n sidekiq_logger.info { \"[#{username}] Fetching watched repos...\" }\n\n github_watched.each do |wr|\n attrs = wr.slice(:name, :language, :description, :fork, :private, :size,\n :forks, :open_issues, :pushed_at, :created_at, :updated_at)\n\n if repo = Repo.find_by_id(wr.id)\n repo.attributes = attrs.merge({:watchers_count => wr.watchers})\n else\n repo = Repo.new(attrs.merge({:watchers_count => wr.watchers}))\n repo.id = wr.id\n end\n\n repo.owner = User.find_or_create_by_username(wr.owner.login)\n repo.save\n\n unless watchings.exists?(repo.id)\n watchings << repo\n sidekiq_logger.info { \"[#{username}] now watching #{wr.name}\" }\n end\n end\n\n sidekiq_logger.info { \"[#{username}] Completed fetching watched repos\" }\n\n prune_unwatched_repos\n\n toggle! :fetching_repos\n end", "def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client = Octokit::Client.new(:access_token => user.password)\n repo_list = []\n client.repositories(:user => user.gh_username).each { |repo|\n repo_list.push(repo.name)\n }\n render :json => {:repos => repo_list}\n end", "def find_repos(user)\n user.repos\n end", "def archived_repositories_for(multi_repo = nil)\n repositories_for(multi_repo).find_all(&:archived)\n end", "def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend", "def search_github_repos(search_names, language, output_file_name)\n search_names.each do |name|\n # get results for first page\n response = query_api(name, language, 1)\n\n # figure out how many pages exist\n last_page = results_last_page(response[:headers])\n\n # process first page\n # response[:results] is JSON object\n # method is responsible for writing repo data to csv\n process_page_results(output_file_name, response[:results]['items'])\n\n # process results for each successive page\n (2..last_page).each do |page|\n # query api for results for the specified page\n response = query_api(name, page)\n\n # process results from the page\n # response[:results] is JSON object\n # method is responsible for writing repo data to csv\n process_page_results(output_file_name, response[:results]['items'])\n end\n end\nend", "def only(repos)\n @repositories.only repos\n\n repositories\n end", "def list\n @repos\n end", "def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end", "def repos\n @repos ||= get(\"/repos/show/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def find_commits(repos=@repo_array)\n repos.each do |repo|\n commit_list = @github.repos.commits.list user: @user_name, repo: repo\n @repos_and_commits[repo] = commit_list.body.to_s.scan(/message=\"([^\"]*)\"/)\n sleep @delay\n end\n end", "def repos\n pry(Git::Multi.repositories)\nend", "def find_all(repo, options = {})\n refs = []\n already = {}\n Dir.chdir(repo.path) do\n files = Dir.glob(prefix + '/**/*')\n files.each do |ref|\n next if !File.file?(ref)\n id = File.read(ref).chomp\n name = ref.sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => id)\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n\n if File.file?('packed-refs')\n File.readlines('packed-refs').each do |line|\n if m = /^(\\w{40}) (.*?)$/.match(line)\n next if !Regexp.new('^' + prefix).match(m[2])\n name = m[2].sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => m[1])\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n end\n end\n end\n\n refs\n end", "def get_list\n @list_of_repos\n end", "def repos\n super.sort\n end", "def index\n if (params[:search]) && (params[:search].empty? == false) \n urlformated = URI.encode(params[:search])\n uri = URI.parse(\"https://api.github.com/legacy/repos/search/#{urlformated}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n \n \n request = Net::HTTP::Get.new(uri.request_uri)\n \n res = http.request(request)\n response = JSON.parse(res.body)\n \n\n repository = response['repositories'].map {|rd|\\\n GithubRepository.new( rd['owner'], rd['name'],\\\n rd['description'], rd['language'], rd['url'])} \n \n @github_repositories = repository\n else\n @github_repositories = nil\n end \n end", "def repos\n @repos ||= OY.repos\n end", "def get_repo_list(ssh: false)\n CSV.generate do |csv|\n self.groupings.includes(:group).each do |grouping|\n group = grouping.group\n data = [group.group_name, group.repository_external_access_url]\n data << group.repository_ssh_access_url if ssh\n csv << data\n end\n end\n end", "def repos\n api.repos.map(&:to_hash)\n end", "def list_repositories\n JSON.parse(request(:get, ''))\n end", "def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end", "def owned_repositories_with_user(user)\n repos = owned_repositories.publics\n repos = repos.or(user.membered_repositories.where(user_id: id)) if user\n repos\n end", "def repos(name=nil, params={})\n params = name if name.is_a?Hash\n prefix = name.is_a?(String) ? \"./repos/#{self[\"login\"]}/#{name}\" : \"#{path_prefix}/repos\" \n Ghee::API::Repos::Proxy.new(connection,prefix, params)\n end", "def all_repos\n\t\tif GitHosting.multi_repos?\n\t\t repositories\n\t\telse\n\t\t [ repository ].compact\n\t\tend\n\t end", "def repos(show_commits = false)\n response = @github.repos.list(user: 'siakaramalegos', sort: 'updated', direction: 'desc', page: 1, per_page: 10)\n repos = response.body\n\n repos.each_with_index do |repo, index|\n puts '-' * 80\n date_string = repo.updated_at\n date = DateTime.parse(date_string).to_date\n puts \"(#{index + 1}) #{repo.name}: #{repo.description} (updated: #{date.stamp('12/30/99')})\"\n\n if show_commits\n repo_commits = @github.repos.commits.list('siakaramalegos', repo.name, page: 1, per_page: 10).body\n\n repo_commits.each do |c|\n date_string = c.commit.author.date\n date = DateTime.parse(date_string).to_date\n puts \" #{c.commit.message} (#{date.stamp('12/30/99')})\"\n end\n end\n end\n puts '-' * 80\n repos\n end", "def get_repos\n\t\t@repos = Repo.all\n\tend", "def get_repos\n @api.list_repositories\n end", "def find_available_repo(product, repository_key)\n @repos.find_all do |elem|\n elem[1]['product'] == product['name'] &&\n elem[1]['platform'] + '^' + elem[1]['platform_version'] == repository_key\n end\n end", "def index\n @repositories = Repository.all\n @path_repos = request.path.starts_with? '/repos'\n end", "def repo_commits(repos)\n repos_commits = []\n repos.each do |repo|\n repos_commits << HTTParty.get(repo[\"commits_url\"].gsub(\"{/sha}\", \"\"))[0]\n end\n repos_commits\nend", "def get_watched_repos\n @repos.each do |r|\n if r.name.downcase == 'txtout'\n @watched.store('txtout', r.id)\n end\n if r.name.downcase == 'resumemonster'\n @watched.store('resumemonster', r.id)\n end\n end\n end", "def find_repositories\n project = find_project\n repositories = git_repositories(project)\n\n # if a specific repository id is passed in url parameter \"repository_id\",\n # then try to find it in the list of current project repositories and use\n # only this and not all to pull changes from (issue #54)\n if params.key?(:repository_id)\n param_repo = repositories.select do |repo|\n repo.identifier == params[:repository_id]\n end\n\n if param_repo.nil? || param_repo.length == 0\n logger.info {\n \"GithubHook: The repository '#{params[:repository_id]}' isn't \" \\\n \"in the list of projects repos. Updating all repos instead.\"\n }\n\n else\n repositories = param_repo\n end\n end\n\n repositories\n end", "def fetch_syncables\n gh_client.repos.list.select{|repo| repo.permissions.admin}.map(&:full_name)\n end", "def watched_repos\n @repos ||= get(\"/repos/watched/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def all\n return @raw_repos unless @raw_repos.empty?\n return [Template.root.basename.to_s] if Template.project?\n Template.root.join(Meta.new({}).repos_dir).children.map do |path|\n path.basename.to_s\n end\n\n rescue Errno::ENOENT\n then raise(\n Error::RepoNotFound\n )\n end", "def project_names\n repositories.map { |s| s.match(/[^\\/]*$/)[0] }\n end", "def projects_by_name(name, opts={})\n @projects_cache[name] ||= begin\n user_query = @allowed_users.collect{|user| \"user:#{user}\"}.join(' ')\n repos = Octokit.search_repos \"#{name} in:name language:ruby #{user_query}\"\n repos = repos.items.select do |repo|\n repo.name == name\n end\n\n repos.collect{|repo| Models::RepoCookbook.new(repo.id, repo.full_name, \"metadata.rb\")}\n end\n end", "def repository_urls(pom:, exclude_inherited: false)\n repo_urls_in_pom =\n Nokogiri::XML(pom.content).\n css(REPOSITORY_SELECTOR).\n map { |node| node.at_css(\"url\").content.strip.gsub(%r{/$}, \"\") }.\n select { |url| url.start_with?(\"http\") }\n\n return repo_urls_in_pom + [CENTRAL_REPO_URL] if exclude_inherited\n\n unless (parent = parent_pom(pom, repo_urls_in_pom))\n return repo_urls_in_pom + [CENTRAL_REPO_URL]\n end\n\n repo_urls_in_pom + repository_urls(pom: parent)\n end", "def find_all(ids, optional = {})\n optional[:include_repos] = optional.fetch(:include_repos, true)\n search(content_type, { :filters => {'id' => {'$in' => ids}} }, optional)\n end", "def get_my_pull_requests\n repos_to_get = GITHUB_REPOS.kind_of?( Array ) ? GITHUB_REPOS : get_my_repos\n\n repos_to_get.each do |repo|\n status = []\n pulls_url = \"#{ GITHUB_REPOS_URL }/#{ repo }/pulls?state=open\"\n\n get_json( pulls_url ).each_with_index do |item, index|\n sha = item[ 'head' ][ 'sha' ]\n status_url = \"#{ GITHUB_REPOS_URL }/#{ repo }/commits/#{ sha }/status\"\n\n status << get_json( status_url )\n\n unless item[ 'assignee' ].nil?\n if item[ 'assignee' ][ 'login' ] == ENV[ 'GITHUB_USERNAME' ]\n color = ''\n state = status[ index ][ 'state' ]\n\n unless status[ index ][ 'statuses' ].empty?\n color = \"| color=#{ determine_status_color( state )}\"\n end\n\n puts \"#{ repo }: ##{ item[ 'number' ] } #{ item[ 'title' ] } #{ color } | href=#{ item[ 'html_url' ] }\"\n end\n end\n end\n end\nend", "def repos\n @repos ||= (user_repos + org_repos).flatten\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def get_repo_content(type, username, repo_name) # :yields: String\n case type\n\n when Api_options::REPO::LANGUAGES\n \"#{BASE_URL}\" + \"#{REPOS}\" + \"#{username}/\" + \"#{repo_name}/languages\"\n when Api_options::REPO::CONTRIBUTORS\n BASE_URL + REPOS + \"#{username}\" + \"/\" + \"#{repo_name}\" + \"/\" + \"contributors\"\n when Api_options::REPO::README\n BASE_URL + REPOS + \"#{username}\" + \"/\" + \"#{repo_name}\" + \"/\" + \"readme\"\n end\n end", "def gl_repos\n all_repos.select{|x| x.is_a?(Repository::Git)}\n end", "def find_repo_by_project_name(project_name)\n Repo.all.find_by(project_name: project_name)\n end", "def owned_repositories_with_user(user)\n repos = self.owned_repositories.publics\n repos = repos.or(user.membered_repositories.where(user_id: self.id)) if user\n repos\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def query_string(name, language, page)\n \"https://api.github.com/search/repositories?q=#{name}+language:#{language}&page=#{page}&per_page=100\"\nend", "def excess_repositories_for(multi_repo = nil)\n repository_full_names = repositories_for(multi_repo).map(&:full_name)\n local_repositories_for(multi_repo).reject { |repo|\n repository_full_names.include? repo.full_name\n }\n end", "def repositories\n # TODO : merge with current data\n load_repos\n end", "def get_repos\n\t\trepo_list = []\n\t\tparsed_config = begin\n\t\t\tYAML.load(File.open(@path_to_config_yml))\n\t\trescue ArgumentError => e\n \t\t\tputs \"Could not parse YAML: #{e.message}\"\n\t\tend\n\t\tparsed_config['sections'].each do |section|\n\t\t\trepo_list.push(section['repository']['name'].gsub(/\\w*-?\\w*\\//,''))\n\t\tend\n\t\trepo_list.sort\n\tend", "def only(repos)\n @list = [repos].flatten\n self\n end", "def all(slug = @curry_with[0])\n response = @connection.get(\"/repos/#{slug}/pulls\", per_page: 100)\n PullRequest.parse(@connection, response.body)\n end", "def repositories_for(multi_repo = nil)\n case (owner = superproject = full_names = multi_repo)\n when nil\n repositories # all of them\n when Array\n repositories.find_all { |repository|\n full_names.include?(repository.full_name)\n }\n when *USERS, *ORGANIZATIONS\n repositories.find_all { |repository|\n repository.owner.login == owner\n }\n when *SUPERPROJECTS\n repositories_for(full_names_for(superproject))\n else\n raise ArgumentError, multi_repo\n end\n end", "def get_repo(token, owner, repo, authorID)\n query = %{\n query ($owner: String!, $repo: String!, $cursor: String, $author: CommitAuthor) {\n repository(owner: $owner, name: $repo) {\n defaultBranchRef {\n target {\n ... on Commit {\n history(first: 100, after: $cursor, author: $author) {\n edges {\n node {\n authoredDate\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n }\n }\n }\n }\n\n vars = { owner: owner, repo: repo, cursor: nil, author: { id: authorID } }\n\n commits = []\n\n loop do\n result = Github.query(token, query, vars)\n edges = result.dig('data', 'repository', 'defaultBranchRef', 'target', 'history', 'edges')\n info = result.dig('data', 'repository', 'defaultBranchRef', 'target', 'history', 'pageInfo')\n\n commits += edges || []\n break unless info&.dig('hasNextPage')\n vars[:cursor] = info&.dig('endCursor')\n end\n\n dates = commits.map do |commit|\n date = commit.dig('node', 'authoredDate')\n begin\n DateTime.parse(date)\n rescue ArgumentError\n nil\n end\n end\n\n # Remove nil entries where DateTime raised an error\n dates.compact!\n\n CommitTime.new(dates)\nend", "def repositories\n @repositories ||= (organization.exists? ? organization.repositories : client.list_repositories)\n end", "def filter_out_used_repos\n Yast::SourceManager.ReadSources\n\n @repositories.delete_if do |repo|\n Yast::SourceManager.getSourceId(repo.url) != -1\n end\n end", "def has_repo?(local_param)\n !list.find { |r| r.param == local_param }.nil?\n end", "def dormant_repos(days)\n Repository.where(\"updated_at < ?\", (Time.now - days.day))\n end", "def do_your_stuff! organization_name\n get_members_for_org organization_name\n get_repositories_for_all_members\n get_stats_for_repositories\n end", "def get_public_repos(user_name)\n get(\"/users/#{user_name}/repos\")\n end", "def all_repos\n if GitHosting.multi_repos?\n repositories\n else\n [ repository ].compact\n end\n end", "def repository_faceted_on\n return unless try(:search_state)\n repos = facets_from_request.find { |f| f.name == 'repository_sim' }.try(:items)\n faceted = repos && repos.length == 1 && repos.first.value\n Arclight::Repository.find_by(name: repos.first.value) if faceted\n end", "def get_supported_addons_from_github\n uri_per_page = \"#{AddonsReposForksURI}&per_page=#{@github_results_per_page}\"\n all_forks = execute_request_uri( URI.parse(uri_per_page) )\n\n print \"[INFO] NB Fork Repositories in exo-addons organization (supported and not supported): \",all_forks.length,\"\\n\\n\"\n print \"[INFO][SUPPORTED_ADDONS] --------\\n\"\n all_forks.each {\n |fork_repo|\n # Each supported Addon repository is a fork from eXo blessed (exoplatform organization).\n # This method gets the repository details form GitHub to find parent url information.\n result = execute_request_uri( URI.parse(fork_repo[\"url\"]) )\n parent_ssh_url = result[\"parent\"][\"ssh_url\"];\n\n #check if the parent is in exoplatform organization\n if(parent_ssh_url.include? \"github.com:exoplatform\")\n fork_repo[\"ssh_url_fork_parent\"] = parent_ssh_url\n self.log(INFO,fork_repo[\"name\"], \"git ssh-url: #{result[\"parent\"][\"ssh_url\"]}\")\n @addons_supported.push(fork_repo)\n end\n }\n print \"[INFO][SUPPORTED_ADDONS] --------\\n\"\n end", "def display_org_repos(org)\n repos = Commitchamp::Repo.where(organization: org).order(name: :asc)\n puts \"\\n## Repositories for Organization: #{org}\"\n repos.each do |r|\n puts \"#{r.name}\"\n end\n end", "def get_repos\n\t\tif current_user.nil?\n\t\t\t@repos = Repo.where(:user_id => nil)\n\t\telse\n\t\t\t@repos = current_user.repos\n\t\tend\n\tend", "def select_regexp_matching_images(re_hn)\n Docker::Image.all.select { |img|\n info_map = img.info\n info_map && info_map['RepoTags'] && info_map['RepoTags'].any? { |n| n.match re_hn }\n }\nend", "def find_all_collabs_for_repo\n puts \"Enter a repo name with *EXACT* spelling and capitalization:\"\n input = gets_user_input\n repo_by_project_name = find_repo_by_project_name(input)\n if repo_by_project_name == nil\n puts \"No repo found\"\n else\n repo_by_project_name.users.each do |user|\n puts user.github_username\n end\n end\n menu\n end", "def get_contributors_of_a_repository(username,repo_name) # :yields: JSON\n uri=URI.parse(@@uri_builder.get_repo_content(Api_options::REPO::CONTRIBUTORS,username,repo_name))\n http= HttpHandler.initiate_http(uri)\n begin\n response=HttpHandler.get_response(http,uri)\n rescue ArgumentError\n puts \"Request failed with code: #{response.code}\"\n else\n @@responseStatus=true\n return response\n end\n end", "def list_all_registered_repos\n data, code = get_json(@all_repos_path)\n return data,code\n end", "def repository\n if ladnn?\n ['University of California, Los Angeles. Library. Department of Special Collections']\n else\n # Replace marc codes with double dashes and no surrounding spaces\n map_field(:repository)&.map { |a| a.gsub(/ \\$[a-z] /, ' ') }\n end\n end" ]
[ "0.68310064", "0.62287444", "0.61612755", "0.615109", "0.61489034", "0.60716134", "0.6066253", "0.6058215", "0.60254276", "0.6024868", "0.5990243", "0.59705055", "0.5933787", "0.592065", "0.5862471", "0.5850512", "0.5804467", "0.5788592", "0.576378", "0.574639", "0.57455117", "0.57412183", "0.57208353", "0.5707577", "0.56911075", "0.5626846", "0.5623702", "0.5599785", "0.55965906", "0.5591612", "0.55401254", "0.55274", "0.55044", "0.5500539", "0.5492617", "0.54908276", "0.54809195", "0.54729235", "0.54578906", "0.54572064", "0.5373542", "0.53665364", "0.533821", "0.5319232", "0.53144944", "0.53115195", "0.5303443", "0.53017044", "0.5299279", "0.5285506", "0.52826273", "0.5279651", "0.5277034", "0.52752155", "0.5268609", "0.52612317", "0.5257106", "0.5251581", "0.52433425", "0.5237146", "0.5230936", "0.52285105", "0.52259254", "0.52229965", "0.51991886", "0.5199147", "0.51972216", "0.51963574", "0.518964", "0.51864225", "0.5186122", "0.5185228", "0.5180646", "0.51650065", "0.5164488", "0.5158774", "0.5149581", "0.51445276", "0.51399815", "0.5138917", "0.5135158", "0.5133519", "0.51253235", "0.5119636", "0.51083803", "0.5088611", "0.50846094", "0.50762576", "0.50755477", "0.5065301", "0.5060188", "0.5052088", "0.50487447", "0.50445765", "0.503549", "0.5031805", "0.50283325", "0.5022391", "0.5018347", "0.5014191", "0.5011839" ]
0.0
-1
POST /resume_responses POST /resume_responses.json
def create @resume_response = ResumeResponse.new(params[:resume_response]) @resume = Resume.find(params[:id]) @resume_response.resume = @resume @resume_response.sender = @current_user @resume_response.recipient = @resume.user respond_to do |format| if @resume_response.save format.html { redirect_to home_path, notice: 'Отклик на резюме отправлен.' } format.json { render json: @resume_response, status: :created, location: @resume_response } else format.html { render action: "new" } format.json { render json: @resume_response.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @resume = Resume.new(complete_params)\n\n if @resume.save\n render json: @resume, status: :created, location: @resume\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def create\n # puts \"params: #{params}\"\n @resume = Resume.new(resume_params)\n header_build(@resume)\n education_build(@resume)\n work_experience_build(@resume)\n skills_build(@resume)\n if @resume.save\n render json: @resume, status: :created, location: api_v1_resumes_url(@resume)\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def create\n @resume = Resume.new(resume_params)\n\n if @resume.save\n render :show, status: :created, location: @resume\n else\n render json: {errors: errors_as_array_hash(@resume.errors)}, status: :unprocessable_entity\n end\n end", "def create\n @resume = Resume.new(resume_params)\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to @resume, notice: 'Resume was successfully created.' }\n format.json { render action: 'show', status: :created, location: @resume }\n else\n format.html { render action: 'new' }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def cmd_resume argv\n setup argv\n uuid = @hash['uuid']\n response = @api.resume(uuid)\n msg response\n return response\n end", "def resumes_matching\n\t\tresp = @resp\n\t\t# Prcessing keyword values for matching resume list\n\t\tresp = Resume.resumes_matching(resp, params)\n\t\trender :json => resp\n end", "def create\n\t\t@resume = Resume.new(resume_params)\n\n\t\trespond_to do |format|\n\t\t\tif @resume.save\n\t\t\t\tformat.html { redirect_to resumes_url, notice: 'Resume entry was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @resume }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @resume.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @resume = current_user.resumes.new(params[:resume])\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to(@resume, :notice => 'Resume was successfully created.') }\n format.xml { render :xml => @resume, :status => :created, :location => @resume }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @resume = current_user.resumes.build(params[:resume])\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to show_template_path(current_user, @resume) , notice: 'Resume was successfully created.' }\n format.json { render json: @resume, status: :created, location: @resume }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resume = current_user.resumes.build(resume_params)\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to root_path, notice: '履歴書を作成しました。' }\n format.json { render :show, status: :created, location: @resume }\n else\n format.html { render :new }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resumee = Resumee.new(resumee_params)\n\n respond_to do |format|\n if @resumee.save\n format.html { redirect_to @resumee, notice: 'Resumee was successfully created.' }\n format.json { render :show, status: :created, location: @resumee }\n else\n format.html { render :new }\n format.json { render json: @resumee.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload_resume\n respond_to do |format|\n param = params\n format.json {\n @project_application = ProjectApplication.find_by_id(param[:application])\n if @project_application\n @project_application.update_attribute(:resume, param[:file])\n @project_application.update_attribute(:resume_url, @project_application.resume.url)\n\n @project_application.save\n render :json => @project_application\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def create_resume\n @url = { action: \"create_resume\" }\n @resume = current_user.create_resume\n if @resume.update_attributes(params[:resume])\n redirect_to({ action: \"resume\" }, notice: t(\"flash.resume_created\"))\n else\n flash[:notice] = t(\"flash.resume_updated\")\n render action: \"resume\"\n end\n end", "def create_questionnaire_response(data)\n attrs = data.to_h.with_indifferent_access\n response = questionnaire_response_service.create(attrs)\n\n response.tap do |resp|\n if resp.response[:code] == SUCCESS_STATUS\n questionnaire_response.tap do |qr|\n qr.user_uuid = user.uuid\n qr.user_account = user.user_account\n qr.appointment_id = attrs.dig(:appointment, :id)\n qr.questionnaire_response_id = resp.resource.id\n qr.user = user\n qr.questionnaire_response_data = data\n\n qr.save\n end\n end\n end\n end", "def resumes_offered\n\t @resumes = ReqMatch.where(:status => \"OFFERED\")\n\t\trender \"resumes/offered\"\n\tend", "def update\n @resume_response = ResumeResponse.find(params[:id])\n\n respond_to do |format|\n if @resume_response.update_attributes(params[:resume_response])\n format.html { redirect_to @resume_response, notice: 'Resume response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resume_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def resume\n card_id = params[:card_id]\n subscription = UserSubscription.get_my_paused_subscription(current_user, params[:id])\n resumed_sub = subscription.resume_subscription(card_id) if subscription.present?\n\n if resumed_sub.present?\n result = { key: 'success', message: \"#{resumed_sub} has been resumed Successfully. please wait...\" }\n else\n result = { key: 'error', message: \"Sorry, you are not authorized for this subscription.\" }\n end\n\n render json: result.to_json\n end", "def destroy\n @resume_response = ResumeResponse.find(params[:id])\n @resume_response.destroy\n\n respond_to do |format|\n format.html { redirect_to resume_responses_url }\n format.json { head :no_content }\n end\n end", "def send_resume_request\n begin\n request = Net::HTTP::Get.new(\"#{@uri.request_uri}/reattach\")\n response = @http.request(request)\n rescue => e\n puts e\n end\n end", "def responses\n @proposal = current_user.proposals.find(params[:id])\n @responses = @proposal.responses\n\n respond_to do |format|\n format.html # responses.html.erb\n format.xml { render :xml => @responses }\n end\n end", "def resume_params\n params.require(:resume).permit(:user_id, :company_name, :entry_reason, :summary, :request)\n end", "def create\n @response = Response.new\n \n reason = Reason.new\n reason.why = params[:response][:reason][:why]\n reason.critique = params[:response][:reason][:critique]\n @response.reasons = [reason]\n\n @response.who = params[:response][:who]\n @response.ip_address = request.remote_ip\n @response.user_agent = request.env['HTTP_USER_AGENT']\n\n respond_to do |format|\n if @response.save\n format.html { redirect_to root_url, notice: 'Your response was successfully submitted! Thanks for taking the time to affect change in our government.' }\n format.json { render json: @response, status: :created, location: @response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def update_resume\n\n end", "def update_resume\n\n end", "def create\n \n respond_to do |format|\n \n if !params[:questions].nil? \n params[:questions].each {\n |q| \n type = Question.find_by_id(q[0]).question_type\n answer = (type == 2 ? Answer.find_by_id(q[1]).correct : nil)\n Response.new( \n {\n \"question_id\" => q[0],\n \"answer_id\" => type == 2 ? q[1] : nil,\n \"text\" => type == 1 ? q[1] : nil,\n \"user_id\" => current_user.id,\n \"question_group_id\" => params[:response][:question_group_id],\n \"correct\" => answer\n }\n ).save\n }\n format.html { redirect_to '/responses', notice: 'Your responses were successfully saved.' }\n else\n @response = Response.new(params[:response])\n if @response.save\n format.html { redirect_to @response, notice: 'Response was successfully created.' }\n format.json { render json: @response, status: :created, location: @response }\n end\n end\n end\n end", "def create\n @response = current_user.responses.build(response_params)\n\n respond_to do |format|\n if @response.save\n format.html { redirect_to session.delete(:return_to), notice: 'Response was successfully created.' }\n else\n format.html { redirect_to requests_path, notice: 'Response was not saved.' }\n end\n end\n end", "def send_resume\n send_packet(OPCODES[:RESUME],\n { token: @identify_opts[:token], session_id: @session.id, seq: @session.seq })\n end", "def resumes_new\n #@resumes = Resume.where(:nreq_matches => 0).where(:nforwards => 0).where(:status => \"\").order(\"name ASC\")\n @resumes = Resume.where(:nreq_matches => 0, :nforwards => 0, :status => \"\").order(\"name ASC\")\n render \"resumes/_resume_show\"\n end", "def resume\n send_resume(@token, @session.session_id, @session.sequence)\n end", "def update\n if @resume.update(resume_params)\n render :show, status: :ok, location: @resume\n else\n render json: {errors: errors_as_array_hash(@resume.errors)}, status: :unprocessable_entity\n end\n end", "def add_resume\n @resume = Resume.new(:uri => params[:uri])\n\n respond_to do |format|\n if @resume.save\n flash[:notice] = 'Resume was successfully created.'\n format.html { redirect_to(:action => 'resume', :id => @resume) }\n format.xml { render :xml => @resume, :status => :created, :location => @resume }\n else\n flash[:notice][email protected] { |field, error| \"#{field}: #{error}\" }.join('<br />')\n format.html { render :action => \"index\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def resume 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_resume_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::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def response_params\n params.require(:response).permit(:body, :post_id, :user_id)\n end", "def update\n if @resume.update(resume_params)\n render :show, status: :ok, location: @resume\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def create\n @resume = current_user.resumes.new(resume_params)\n @resume.user_id = current_user.id\n\n respond_to do |format|\n if @resume.save\n @content = @resume.create_content\n format.html { redirect_to edit_portfolio_path(@resume), notice: 'Resume was successfully created.' }\n format.json { render :show, status: :created, location: @resume }\n else\n format.html { render :new }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @response = Response.new(params[:response])\n @response.ip_address = request.remote_ip\n @response.survey_id = @survey.id\n @response.user_id = current_user\n \n for param in params do\n if param[0] =~ /^question_id_/\n # handle all question parameters\n # $' represents the value of the question_id\n if param[1].is_a? Hash\n # Valid keys include country, option, year, month, day and numeric option_id\n if param[1].has_key? \"year\" && \"month\" && \"day\"\n # concat year, month and day into one answer\n @response.answers.build(:question_id => $', :answer => Date.new(param[1][\"year\"].to_i, param[1][\"month\"].to_i, param[1][\"day\"].to_i) )\n elsif param[1].has_key? \"option\"\n # look up option id for radio & select questions and build answer\n option_id = Option.find_by_label_and_question_id(param[1][\"option\"], $').id\n @response.answers.build(:question_id => $', :answer => param[1][\"option\"], :option_id => option_id)\n elsif param[1].has_key? \"country\"\n # build country answer\n @response.answers.build(:question_id => $', :answer => param[1][\"country\"])\n else\n # build checkbox and likert answers\n param[1].each do |key, value|\n @response.answers.build(:question_id => $', :answer => value, :option_id => key) unless value == \"0\"\n end\n end\n else\n # build answer without option ie text, textarea\n @response.answers.build(:question_id => $', :answer => param[1] ) #unless param[1].blank?\n end \n end\n if param[0] == 'token'\n @response.survey.update_invitation(param[1])\n end\n end\n\n respond_to do |format|\n if @response.save!\n flash[:notice] = 'Response was successfully created.'\n format.html { redirect_to([@survey, @response]) }\n format.xml { render :xml => @response, :status => :created, :location => @response }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @response.errors, :status => :unprocessable_entity }\n end\n end\n rescue ActiveRecord::RecordInvalid => invalid\n render :action => \"new\"\n end", "def new\n @resume = current_user.resumes.build if signed_in?\n @resume.educations.build\n @resume.experiences.build\n @resume.skills.build\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resume }\n end\n end", "def resume_params\n params.require(:resume).permit(:id, :title, :company, :prawn_content)\n end", "def create\n flash[:notice] = 'Resume Entry Created' if @resume_category.resume_entries.create params[:resume_entry]\n respond_with @resume_category, @resume_entry\n end", "def show\n render json: @resume\n end", "def create\n @resume = Resume.new(params[:resume])\n @seg_id = params[:resume][:segment_id]\n @cat_id = params[:resume][:category_id]\n @type_id = params[:resume][:resume_type]\n # back_link = '/publish/2/add?seg=#{seg_id}&cat=#{cat_id}'\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to @resume, notice: 'Resume was successfully created.' }\n format.json { render json: @resume, status: :created, location: @resume }\n else\n format.html { render action: \"new\"}\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def resume\n action('resume')\n end", "def create\n question_response = QuestionResponse.build_response_essay(current_user, params)\n\n if question_response.try :save\n render json: { message: \"answer saved\" }\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end", "def create\n @resume_recomendation = ResumeRecomendation.new(resume_recomendation_params)\n\n respond_to do |format|\n if @resume_recomendation.save\n format.html { redirect_to @resume_recomendation, notice: 'Рекомендация успешно добавлена' }\n format.json { render :show, status: :created, location: @resume_recomendation }\n else\n format.html { render :new }\n format.json { render json: @resume_recomendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @resume = Resume.find(params[:id])\n\n if @resume.update(resume_params)\n head :no_content\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def create\n @pre_test_answer = PreTestAnswer.new(pre_test_answer_params)\n\n respond_to do |format|\n if @pre_test_answer.save\n format.html { redirect_to @pre_test_answer, notice: 'Pre test answer was successfully created.' }\n format.json { render :show, status: :created, location: @pre_test_answer }\n else\n format.html { render :new }\n format.json { render json: @pre_test_answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def answer\n RecallTest.create(recalled_correctly: params[:answer_correct],\n chunk_id: params[:chunk_id], recall_date: Time.now)\n render nothing: true\n end", "def response_params\n\t#params.require(:subject).permit(:name, :professor_id, :department_id, :descricao)\n\tparams.require(:response).permit(:id, :text, :question_id, :choices)\n\tend", "def create\n @answer = AttemptAnswer.new(answer_params) \n \n if @answer.save\n render json: @answer, status: :created \n else\n head(:unprocessable_entity)\n end\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def create\n @resume_collection = ResumeCollection.new(resume_collection_params)\n\n respond_to do |format|\n if @resume_collection.save\n format.html { redirect_to @resume_collection, notice: 'Resume collection was successfully created.' }\n format.json { render action: 'show', status: :created, location: @resume_collection }\n else\n format.html { render action: 'new' }\n format.json { render json: @resume_collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_and_run(options)\n options[:eval_response] = true\n\n self.post options\n end", "def resumes_rejected\n\t @resumes = Resume.where(:overall_status => \"REJECTED\")\n\t\trender \"resumes/_resume_show\"\n\tend", "def response_params\n params.require(:response).permit(:user_id, :issue_id, :answer, :timestamp)\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def post_prompts_with_http_info(prompts, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PromptsApi.post_prompts ...'\n end\n # verify the required parameter 'prompts' is set\n if @api_client.config.client_side_validation && prompts.nil?\n fail ArgumentError, \"Missing the required parameter 'prompts' when calling PromptsApi.post_prompts\"\n end\n # resource path\n local_var_path = '/prompts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(prompts) \n\n # return_type\n return_type = opts[:return_type] || 'Prompt' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PromptsApi#post_prompts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @request = Request.new(request_params)\n @request.user_id = current_user.id\n @request.assign_json_attributes(params) if @request.resume?\n\n respond_to do |format|\n if @request.save\n @request.set_folio\n format.html { redirect_to @request, notice: 'Request was successfully created.' }\n format.json { render :show, status: :created, location: @request }\n else\n format.html { render :new }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def resume_vm\n respond_to do |format|\n logger.debug \"\\n resume? \\n \"\n result = @vm.resume_vm\n # TODO! check if really resumed\n format.html { \n flash[:notice] = result[:message].html_safe \n redirect_back fallback_location: my_labs_path+(@vm.lab_vmt.lab ? \"/#{@vm.lab_vmt.lab.id}\" : '')+(@vm.lab_vmt.lab && params[:username] ? \"/#{params[:username]}\" : '')\n }\n format.json { render :json => {:success=>result[:success], :message=> result[:message] } }\n end\n end", "def parse_to_candidate(resume_text)\n path = \"resume/parseToCandidateViaJson?format=text\"\n encodedResume = {\"resume\" => resume_text}.to_json\n res = conn.post path, encodedResume\n Hashie::Mash.new JSON.parse(res.body)\n end", "def create\n @user_inference_response = UserInferenceResponse.new(params[:user_inference_response])\n @user_inference_responses = UserInferenceResponse.find(:all, :conditions => [\"user_id = ?\", current_user.id])\n @user_inference_responses = @user_inference_responses.map{|response| response.inference_id}\n\n logger.debug \"Followup = #{params[:user_inference_response]}\"\n logger.debug \"Responses = #{@user_inference_responses}\"\n logger.debug \"Current Response = #{@user_inference_response.inference_id}\"\n\n respond_to do |format|\n if !@user_inference_responses.include?(@user_inference_response.inference_id) && @user_inference_response.save\n format.html { redirect_to @user_inference_response, notice: 'User inference response was successfully created.' }\n format.json { render json: @user_inference_response, status: :created, location: @user_inference_response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_inference_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def resume_replication 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_resume_replication_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 resume_params\n # byebug\n # json_params = ActionController::Parameters.new(JSON.parse(params))\n params.permit(:resume, headers: %i[name phone email location website])\n end", "def new\n @resume = current_user.resumes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resume }\n end\n end", "def resume_params\n params.require(:resume).permit(:user_name, :resume_name, :date_created, :email, :phone, :address, :user_id)\n end", "def response_params\n params.require(:response).permit(:subjnum, :dyad, :whichtest, :condition, :date, :photo, :code, :response, :judgement, :coder)\n end", "def enrollment\n \n connection =\n HTTParty.post('https://eastus.api.cognitive.microsoft.com/speaker/identification/v2.0/text-independent/profiles',\n :body => JSON.generate(\"locale\": 'en-us'),\n :headers => { 'Content-Type' => 'application/json',\n 'Ocp-Apim-Subscription-Key' => \"3c43bca9ad884fe39518a5cf3925e707\" })\n @parsed = JSON.parse(connection.body)\n create_DB_profile();\n create_profile();\n redirect_to ('/speech')\n end", "def received_user_response\n answer = params[:Body]\n phone_number = params[:From]\n\n respondent = Respondent.find_by_phone_number(phone_number.phony_normalized) || raise(RespondentNotFoundError)\n state = respondent.survey_execution_states.find_by(status: [INITIALIZED, IN_PROGRESS]) ||\n raise(SurveyExecutionStateNotFoundError)\n\n survey = state.survey\n question = state.question\n\n if question.response_choices.exists?\n # Lowercase for a case-insensitive comparison against the response choices\n # and persist it this way for consistency\n answer = answer.downcase\n end\n\n survey_response = SurveyResponse.find_or_create_by(survey: survey, respondent: respondent)\n response = Response.new(\n survey_response: survey_response, respondent: respondent, question: question, answer: answer)\n\n if question.is_response_valid?(response)\n response.save!\n next_question = question.next_question(response)\n if next_question.nil?\n message = survey.finished_message\n state.status = FINISHED\n else\n message = next_question.formatted_question_and_responses\n state.question = next_question\n state.status = IN_PROGRESS\n end\n else\n message = 'Invalid response, please try again.'\n state.status = IN_PROGRESS\n end\n state.save\n\n Sms::Client.instance.send(respondent.phone_number, message)\n\n head :ok\n end", "def new_data_request_response(user_id, project_id)\n begin\n @project = Project.find(project_id)\n user = User.find(user_id)\n from DEFAULT_FROM\n reply_to DEFAULT_REPLY_TO\n subject \"SRDR - Update Regarding your Request for Data\"\n recipients user.email \n sent_on Time.now \n rescue Exception => e\n puts \"ERROR SENDING RESPONSE NOTICE: #{e.message}\\n#{e.backtrace}\\n\\n\"\n end\n end", "def profiles_post(options = {})\n\n=begin\n #add access token if it exists\n url = \"\"\n if options[:access_token]\n url = \"https://api.meetup.com/2/profile.json?access_token=#{options[:access_token]}\"\n #url = \"https://api.meetup.com/2/profile.json\"\n else\n url = \"https://api.meetup.com/2/profile.json\"\n end\n=end\n\n url = \"https://api.meetup.com/2/profile.json\"\n\n puts \"profiles post url #{url}\"\n\n response = post_response(url,options)\n\n if response == \"OK\"\n puts \"OK\"\n else\n puts response.to_yaml\n end\n end", "def post_prompts(prompts, opts = {})\n data, _status_code, _headers = post_prompts_with_http_info(prompts, opts)\n data\n end", "def panic_tapped\n\n data = {answer: 1, email: App::Persistence['email'], cohort: App::Persistence['cohort']}\n\n BubbleWrap::HTTP.post(\"http://equanimity.herokuapp.com/users/m/:id/responses\", {payload: data}) do |response|\n\n puts data\n # puts \"response = #{response}\"\n # puts \"response.body = #{response.body.to_str rescue ''}\"\n # puts \"response.error_message = #{response.error_message}\"\n # puts \"response.status_code = #{response.status_code.to_s rescue ''}\"\n # puts \"response ok = #{response.ok?}\"\n\n if response.ok?\n\n App.alert(\"Thanks!\")\n else\n App.alert(\"Something went wrong...\")\n end\n end\n end", "def create\n @oldresume = Resume.find_by_user_id(current_user.id)\n @resume = Resume.new(params[:resume])\n @resume.user = current_user\n respond_to do |format|\n if @resume.save\n @oldresume.destroy if @oldresume\n flash[:notice] = 'Resume was successfully created.'\n format.html { redirect_to(profile_url(current_user.profile)) }\n format.xml { render :xml => @resume, :status => :created, :location => @resume }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def retire_params\n params.require(:retire).permit(:user_id, :telephone,:resume)\n end", "def create\n passed = true\n count = 0\n if params[:status] == \"listOfAnswers\"\n params[:answers].each do |ans|\n @answer = Answer.new(answers_params(ans))\n if @answer.save\n if @answer.correct\n count = count + 1\n # update_result ans[:user_id], ans[:quiz_id]\n end\n else\n passed = false\n end\n end\n if passed\n create_result params[:answers].first[:user_id], params[:answers].first[:quiz_id], count\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n else\n @answer = Answer.new(answer_params)\n if @answer.save\n if @answer.correct\n update_result\n end\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end\n end", "def challenge_response_params\n params.require(:challenge_response).permit({:input => {}}, :asked_at, :completed_at, :challenge_id, :user_id, :course_id, :status)\n end", "def socio_economico_submit\n\n # responding for the first time\n if not session[:current_response_id]\n current_response = nil\n # preparing the object to store the surveys and requests data\n json_response = { 'surveys' => [], 'requests' => [] }\n else\n current_response = FormResponse.find(session[:current_response_id])\n json_response = JSON.parse current_response.json_response\n end\n\n # appending the new response to the array of surveys\n surveys_number = json_response['surveys'].size\n json_response['surveys'] = [] if surveys_number == 0\n json_response['surveys'].push(\n params.merge({\n :attempt => (surveys_number + 1),\n :sent_at => Time.zone.now\n })\n )\n\n if current_response\n current_response.update({\n json_response: json_response.to_json\n })\n else\n # the response must be created only in this form\n # and not in the request form!\n current_response = FormResponse.create({\n form_id: Form.where(reference_model: 'FormVagasRemanescentes').first.id,\n user: current_user.email,\n json_response: json_response.to_json\n })\n\n # storing the response id in session to access it\n # from the other form, the request form\n session[:current_response_id] = current_response.id\n end\n\n redirect_to action: 'pedido'\n end", "def response_params\n params.require(:responses).permit(:event_user, { :event_user => [:event_user, :responses, :user_id, :event_id, :response_reason_id, :response_status_id, :detail] })\n end", "def create\n @section = Section.new(:name => params[:value])\n @section.resume_id = params[:pk]\n\n if @section.save\n render json: { :results => true }\n else\n render json: { :results => false }\n end\n end", "def resume\n\n end", "def create\n @resume_feedback = ResumeFeedback.new(params[:resume_feedback])\n\n respond_to do |format|\n if @resume_feedback.save\n format.html { redirect_to @resume_feedback, notice: 'Resume feedback was successfully created.' }\n format.json { render json: @resume_feedback, status: :created, location: @resume_feedback }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resume_feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def process_response\n job = message.job\n job.data = message.data\n job.message = message.message\n\n if message.ok?\n job.proceed!\n else\n job.error!\n end\n end", "def process!(response_data={})\n @client.post(\"#{path}/process\", response_data)\n end", "def post_arguments(raw_file, filemeta)\n {\n method: :post,\n url: build_url(PARSE_RESUME),\n payload: parse_body(raw_file, filemeta).to_json,\n headers: headers,\n timeout: REQUEST_TIMEOUT_SECONDS\n }\n end", "def resume(id)\n _params = {:id => id}\n return @master.call 'subaccounts/resume', _params\n end", "def create\n @responsavel = Responsavel.new(responsavel_params)\n\n if @responsavel.save\n render json: @responsavel, status: :created, location: @responsavel\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end", "def resume\n execute_prlctl('resume', @uuid)\n end", "def manager_forward_hold\n @req_ids = params[:req_id]\n\t\t@status = params[:r_status]\n\t @resume = params[:resume] \n\t\t@res_id = @resume.to_s\n\t\trespond_to do |format|\n\t\t format.js\n\t\tend\n\tend", "def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to @quiz, notice: \"Quiz was successfully created.\" }\n format.json { render :show, status: :created, location: @quiz }\n\t\tmy_array = []\n\t\tmy_array << @quiz.option1\n\t\tmy_array << @quiz.option2\n\t\tmy_array << @quiz.option3\n\t\tmy_array << @quiz.option4\n\t\t\n\t\tcorrect_respo = my_array[@quiz.correct_response.to_i - 1]\n\t\[email protected]_response_text = correct_respo\n\t\[email protected]\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_resume\n @resume = current_user.resumes.find(params[:id])\n end", "def set_responses\n\t\t@responses = Response.where(question_id: params[:id] ) rescue nil\n\tend", "def set_resume_recomendation\n @resume_recomendation = ResumeRecomendation.find(params[:id])\n end", "def response_params\n params.require(:response).permit(\n :ip, \n :survey_id, \n :answers_attributes => [\n :id, \n :answer, \n {:resp => []}, \n :survey_id, \n :question_id, \n :response_id, \n :user_id \n ])\n end", "def create\n\t\t@resume_entry = ResumeEntry.new(resume_entry_params)\n\t\t#\tlogger.debug \"\\n\\n\\n\\n\\n\\n\\nRESUME ENTRY START IS: #{@resume_entry.start_date}\\n\\n\\n\\n\\n\\n\\n\"\n\n\t\tif resume_entry_params[:is_current].to_i.equal? 1\n\t\t\tResumeEntry.all.update_all(is_current: false)\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tif @resume_entry.save\n\t\t\t\tformat.html { redirect_to resumes_url, notice: 'Resume entry was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @resume_entry }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @resume_entry.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def index\r\n # @resumes = Resume.all\r\n respond_with Resume.all\r\n end", "def create\n @concept = CustomizedConcept.find(params[:test_attempt][:customized_concept_id])\n @tests = @concept.tests\n @test_attempt = @concept.test_attempts.new(test_attempt_params)\n @course = @concept.course\n @answer_records = @test_attempt.answer_records\n \n @error_test = check_answer(params[:select_answers])\n respond_to do |format|\n if (@error_test.length == 0) \n @test_attempt.test_time_sec = Time.now.to_i - @test_attempt.test_time_sec\n if @test_attempt.save\n format.html { redirect_to course_customized_concept_path(@course, @concept), notice: 'Successfully pass' }\n format.json { render :show, status: :created, location: @test_attempt }\n end\n else\n\t\t\t\t@test_attempt.retry_time += 1\n\t\t\t\tbinding.pry\n @error_test.each do |e|\n @answer_records.each do |a|\n a.error_times += 1 if a.test == e\n end\n end\n format.html { render :new }\n format.json { render json: @test_attempt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @response = Response.find(params[:response_id])\n @request_selection = @response.create_request_selection(params[:request_selection])\n #@reward = @request_selection.create_reward(params[:reward])\n \n respond_to do |format|\n if @request_selection.save\n \n format.html { redirect_to _my_requests_path }\n format.json { render json: @request_selection, status: :created, location: @request_selection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @request_selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def resume()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('household', 'resume', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend" ]
[ "0.62504464", "0.6080155", "0.608008", "0.5836236", "0.56991637", "0.5662001", "0.56454825", "0.559175", "0.5591531", "0.55848736", "0.55781996", "0.55646473", "0.54927504", "0.54587626", "0.5437681", "0.54322886", "0.5403665", "0.5387826", "0.53571653", "0.534868", "0.5322084", "0.5321751", "0.5300468", "0.52981913", "0.52981913", "0.52943313", "0.5287593", "0.52836955", "0.5263041", "0.5248996", "0.5241063", "0.5207805", "0.52051276", "0.5185369", "0.51847994", "0.5169489", "0.5152093", "0.5145147", "0.5138701", "0.512565", "0.5106883", "0.5085994", "0.5064503", "0.50635266", "0.5061983", "0.50591224", "0.50549275", "0.5051248", "0.50494635", "0.504689", "0.50452095", "0.50357205", "0.5026636", "0.502427", "0.5018306", "0.50144297", "0.50144297", "0.50144297", "0.50048923", "0.50030816", "0.49985686", "0.4985699", "0.4983035", "0.49764302", "0.49610424", "0.49593875", "0.49567664", "0.4955407", "0.49543178", "0.49538296", "0.49512422", "0.4912747", "0.4906194", "0.49055865", "0.49049306", "0.49031875", "0.4899583", "0.48981896", "0.48969704", "0.4894996", "0.4887096", "0.48851418", "0.4884783", "0.48755845", "0.48753294", "0.48720068", "0.48690227", "0.48670998", "0.48648816", "0.48610377", "0.4859016", "0.48456523", "0.48414472", "0.48350945", "0.4834108", "0.48337963", "0.48304728", "0.48285243", "0.48269257", "0.4822385" ]
0.66263586
0
PUT /resume_responses/1 PUT /resume_responses/1.json
def update @resume_response = ResumeResponse.find(params[:id]) respond_to do |format| if @resume_response.update_attributes(params[:resume_response]) format.html { redirect_to @resume_response, notice: 'Resume response was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @resume_response.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @resume = Resume.find(params[:id])\n\n if @resume.update(resume_params)\n head :no_content\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def update\n if @resume.update(resume_params)\n render :show, status: :ok, location: @resume\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def update\n if @resume.update(resume_params)\n render :show, status: :ok, location: @resume\n else\n render json: {errors: errors_as_array_hash(@resume.errors)}, status: :unprocessable_entity\n end\n end", "def update\n @resume = resume\n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n format.html { redirect_to listings_path, notice: 'Resume was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @resume = Resume.find(params[:id])\n\n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n format.html { redirect_to @resume, notice: 'Resume was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n user = demo? ? demo_user : current_user\n @resume = user.resumes.find(params[:id])\n @resume.update_count += 1\n\n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n format.html { \n redirect_to(html_resume_path(@resume), :notice => 'updated') \n }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @resume.update(resume_params)\n format.html { redirect_to @resume, notice: 'Resume was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @resume.update(resume_params)\n format.html { redirect_to edit_resume_path, notice: 'Resume was successfully updated.' }\n format.json { render :show, status: :ok, location: @resume }\n else\n format.html { render :edit }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @resume = current_user.resumes.find(params[:id])\n\n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n format.html { redirect_to show_template_path(current_user, @resume), notice: 'Resume was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @resume.update(resume_params)\n\t\t\t\tformat.html { redirect_to resumes_url, notice: 'Resume was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @resume }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @resume.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update_resume\n\n end", "def update_resume\n\n end", "def update\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @resume = Resume.find(params[:id])\n\n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n flash[:notice] = 'Resume was successfully updated.'\n format.html { redirect_to(@resume) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def set_resume\n @resume = Resume.find(params[:id])\n end", "def update\n respond_to do |format|\n if @resumee.update(resumee_params)\n format.html { redirect_to @resumee, notice: 'Resumee was successfully updated.' }\n format.json { render :show, status: :ok, location: @resumee }\n else\n format.html { render :edit }\n format.json { render json: @resumee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_resume\n @resume = current_user.resume\n @url = { action: \"update_resume\" }\n #@resume.assign_attributes(params[:resume])\n #if @resume.valid?\n if @resume.update_attributes(params[:resume])\n redirect_to({ action: \"resume\" }, notice: t(\"flash.resume_updated\"))\n else\n flash[:notice] = t(\"flash.resume_updated\")\n render action: \"resume\"\n end\n end", "def update\n respond_to do |format|\n if @resume.update(resume_params)\n format.html { redirect_to root_path, notice: '履歴書を更新しました。' }\n format.json { render :show, status: :ok, location: @resume }\n else\n format.html { render :edit }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload_resume\n respond_to do |format|\n param = params\n format.json {\n @project_application = ProjectApplication.find_by_id(param[:application])\n if @project_application\n @project_application.update_attribute(:resume, param[:file])\n @project_application.update_attribute(:resume_url, @project_application.resume.url)\n\n @project_application.save\n render :json => @project_application\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def cmd_resume argv\n setup argv\n uuid = @hash['uuid']\n response = @api.resume(uuid)\n msg response\n return response\n end", "def update\n respond_to do |format|\n if @resume_collection.update(resume_collection_params)\n format.html { redirect_to @resume_collection, notice: 'Resume collection was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resume_collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resume_response = ResumeResponse.new(params[:resume_response])\n @resume = Resume.find(params[:id])\n @resume_response.resume = @resume\n @resume_response.sender = @current_user\n @resume_response.recipient = @resume.user\n respond_to do |format|\n if @resume_response.save\n format.html { redirect_to home_path, notice: 'Отклик на резюме отправлен.' }\n format.json { render json: @resume_response, status: :created, location: @resume_response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resume_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_resume\n @resume = Resume.friendly.find(params[:id])\n end", "def update\n @request = Request.find_by_id(params[:request_id])\n @response = @request.responses.find(params[:id])\n respond_to do |format|\n if @response.update_attributes(response_params)\n format.html { redirect_to session.delete(:return_to), notice: 'Response was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def destroy\n @resume_response = ResumeResponse.find(params[:id])\n @resume_response.destroy\n\n respond_to do |format|\n format.html { redirect_to resume_responses_url }\n format.json { head :no_content }\n end\n end", "def set_resume\n @resume = current_user.resumes.find(params[:id])\n end", "def set_resume_item\n @resume_item = ResumeItem.find(params[:id])\n end", "def set_resume_entry\n @resume_entry = ResumeEntry.find(params[:id])\n end", "def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end", "def create\n @resume = Resume.new(complete_params)\n\n if @resume.save\n render json: @resume, status: :created, location: @resume\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def set_resumee\n @resumee = Resumee.find(params[:id])\n end", "def update!(**args)\n @simple_responses = args[:simple_responses] if args.key?(:simple_responses)\n end", "def update!(**args)\n @simple_responses = args[:simple_responses] if args.key?(:simple_responses)\n end", "def update \n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n flash[:notice] = '简历更新成功.'\n format.html { redirect_to(edit_resume_path(@resume)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit_item\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end \n end", "def update\n\n\t\tif resume_entry_params[:is_current].to_i.equal? 1\n\t\t\tResumeEntry.all.update_all(is_current: false)\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tif @resume_entry.update(resume_entry_params)\n\t\t\t\tformat.html { redirect_to resumes_url, notice: 'Resume entry was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @resume_entry }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @resume_entry.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n appointment_request = current_user.pending_requests.find(\n params[:request_id]\n )\n\n case params[:answer]\n when 'accept'\n if appointment_request.accept!\n redirect_to root_path\n else\n render status: 500\n end\n when 'reject'\n if appointment_request.reject!\n redirect_to root_path\n else\n render status: 500\n end\n else\n render json: { appointment_request: appointment_request, status: 200 }\n end\n end", "def update\n flash[:notice] = 'Resume Entry Updated' if @resume_entry.update_attributes! params[:resume_entry]\n respond_with @resume_category, @resume_entry\n end", "def create\n @resume = Resume.new(resume_params)\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to @resume, notice: 'Resume was successfully created.' }\n format.json { render action: 'show', status: :created, location: @resume }\n else\n format.html { render action: 'new' }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n request = Request.find_by_id(params[:id])\n if request\n request.status = 1\n if request.save\n render json: {\n status: 'success',\n message: 'Request marked as fulfilled',\n },\n status: :ok\n else\n render json: {\n status: 'error',\n message: 'Request failed',\n data: request.errors,\n },\n status: :unprocessable_entity\n end\n else\n render status: :unauthorized\n end\n end", "def resume\n action('resume')\n end", "def create_resume\n @url = { action: \"create_resume\" }\n @resume = current_user.create_resume\n if @resume.update_attributes(params[:resume])\n redirect_to({ action: \"resume\" }, notice: t(\"flash.resume_created\"))\n else\n flash[:notice] = t(\"flash.resume_updated\")\n render action: \"resume\"\n end\n end", "def set_resume\n @resume = Resume.find(params[:id])\n authorize @resume\n end", "def create\n @resume = Resume.new(resume_params)\n\n if @resume.save\n render :show, status: :created, location: @resume\n else\n render json: {errors: errors_as_array_hash(@resume.errors)}, status: :unprocessable_entity\n end\n end", "def update!(**args)\n @response_status_code = args[:response_status_code] if args.key?(:response_status_code)\n end", "def set_resume_recomendation\n @resume_recomendation = ResumeRecomendation.find(params[:id])\n end", "def update\n @prompt = Prompt.find(params[:id])\n\n respond_to do |format|\n if @prompt.update_attributes(params[:prompt])\n format.html { redirect_to @prompt, notice: 'Prompt was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prompt.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prompt = Prompt.find(params[:id])\n\n respond_to do |format|\n if @prompt.update_attributes(params[:prompt])\n format.html { redirect_to @prompt, notice: 'Prompt was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prompt.errors, status: :unprocessable_entity }\n end\n end\n end", "def put_prompts_id_with_http_info(id, prompts, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PromptsApi.put_prompts_id ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling PromptsApi.put_prompts_id\"\n end\n # verify the required parameter 'prompts' is set\n if @api_client.config.client_side_validation && prompts.nil?\n fail ArgumentError, \"Missing the required parameter 'prompts' when calling PromptsApi.put_prompts_id\"\n end\n # resource path\n local_var_path = '/prompts/{id}'.sub('{' + 'id' + '}', CGI.escape(id.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'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(prompts) \n\n # return_type\n return_type = opts[:return_type] || 'Prompt' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PromptsApi#put_prompts_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n # puts \"params: #{params}\"\n @resume = Resume.new(resume_params)\n header_build(@resume)\n education_build(@resume)\n work_experience_build(@resume)\n skills_build(@resume)\n if @resume.save\n render json: @resume, status: :created, location: api_v1_resumes_url(@resume)\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end", "def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit\n @resume = Resume.find(params[:id])\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @responses = args[:responses] if args.key?(:responses)\n end", "def update\n @resume_feedback = ResumeFeedback.find(params[:id])\n\n respond_to do |format|\n if @resume_feedback.update_attributes(params[:resume_feedback])\n format.html { redirect_to @resume_feedback, notice: 'Resume feedback was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resume_feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@resume = Resume.new(resume_params)\n\n\t\trespond_to do |format|\n\t\t\tif @resume.save\n\t\t\t\tformat.html { redirect_to resumes_url, notice: 'Resume entry was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @resume }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @resume.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @prompt = Prompt.find(params[:id])\n\n respond_to do |format|\n if @prompt.update_attributes(params[:prompt])\n format.html { redirect_to([:scaffold, @prompt], :notice => 'Prompt was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @prompt.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @requirement_id = response_params[:requirement_id]\n @next_requirement_id = params[:next_requirement_id]\n @plan = Plan.find(response_params[:plan_id])\n @requirement = Requirement.find(@requirement_id)\n template_id = @plan.requirements_template_id\n @requirements_template = RequirementsTemplate.find(template_id)\n\n unless @requirements_template.nil?\n @requirements = @requirements_template.requirements\n @last_question = @requirements_template.last_question\n end\n\n if ( params[:save_and_next] == nil && params[:save_only] == nil && params[:save_on_preview] == \"true\")\n if @response.update(response_params)\n @response.plan.touch unless @response.previous_changes.blank?\n format.html { redirect_to preview_plan_path(@plan), notice: 'Response has been updated' }\n format.json { head :no_content }\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to preview_plan_path(@plan) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n\n elsif ( !params[:save_and_next] && !params[:save_only]) && (@requirement.id == @last_question.id)\n if @response.update(response_params)\n @response.plan.touch unless @response.previous_changes.blank?\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { head :no_content }\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n\n elsif (params[:save_and_next] || !params[:save_only]) && (@requirement.id == @last_question.id)\n if @response.update(response_params)\n @response.plan.touch unless @response.previous_changes.blank?\n format.html { redirect_to preview_plan_path(@plan) }\n format.json { head :no_content }\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to preview_plan_path(@plan) }\n format.json { head :no_content }\n end\n\n elsif (params[:save_and_next] || !params[:save_only])\n if @response.update(response_params)\n if @response.previous_changes.blank?\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { render action: 'show', status: :created, location: @response }\n else\n @response.plan.touch\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id), notice: 'Response was successfully updated.' }\n format.json { render action: 'show', status: :created, location: @response }\n end\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n\n else\n if @response.update(response_params)\n if @response.previous_changes.blank?\n format.html { redirect_to details_plan_path(@plan, requirement_id: @requirement_id) }\n format.json { head :no_content }\n else\n @response.plan.touch\n format.html { redirect_to details_plan_path(@plan, requirement_id: @requirement_id), notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n end\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to details_plan_path(@plan, requirement_id: @requirement_id) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end\n\n rescue ActiveRecord::StaleObjectError\n flash[:error] = \"This record changed while you were editing.\"\n redirect_to details_plan_path(@plan, requirement_id: @requirement_id)\n\n end", "def resume_params\n params.require(:resume).permit(:user_id, :company_name, :entry_reason, :summary, :request)\n end", "def destroy\n @resume = Resume.find(params[:id])\n @resume.destroy\n\n respond_to do |format|\n format.html { redirect_to resumes_url }\n format.json { head :no_content }\n end\n end", "def update\n @step = TaskrequestsStep.find(params[:taskrequests_step_id])\n @absence_request = @step.absence_requests.find(params[:id])\n\n respond_to do |format|\n if @absence_request.update_attributes(params[:absence_request])\n format.html { redirect_to(@absence_request, :notice => 'Absence request was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @absence_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @response = Response.find(params[:id])\n\n respond_to do |format|\n if @response.update_attributes(params[:response])\n if @response.run && @response.run.return_url\n # send the data back to the portal\n data = [{\n \"type\" => \"open_response\",\n \"question_id\" => \"1\",\n \"answer\" => params[:response][:answer]\n }]\n bearer_token = 'Bearer %s' % current_user.token\n HTTParty.post(@response.run.return_url, :body => data.to_json, :headers => {\"Authorization\" => bearer_token, \"Content-Type\" => 'application/json'})\n end\n format.html { redirect_to @response, notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @preceed = Preceed.find(params[:id])\n\n respond_to do |format|\n if @preceed.update_attributes(params[:preceed])\n format.html { redirect_to @preceed, notice: 'Preceed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @preceed.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resume = current_user.resumes.new(params[:resume])\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to(@resume, :notice => 'Resume was successfully created.') }\n format.xml { render :xml => @resume, :status => :created, :location => @resume }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @response = Response.find(params[:id])\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question = Question.find(params[:question_id])\n\n respond_to do |format|\n if @response.update_attributes(params[:response])\n format.html { redirect_to(@response, :notice => 'Response was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @response.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @past_request.received_help = true\n if @past_request.update(past_request_params)\n format.html { redirect_to requests_path, notice: \"You spent #{time_ago_in_words(Time.now - (Time.now - @past_request.created_at), include_seconds: true)}\" }\n format.json { render :show, status: :ok, location: @past_request }\n else\n format.html { render :edit }\n format.json { render json: @past_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer = Answer.find(params[:id])\n\n if @answer.update(answer_params)\n head :no_content\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @prompt.update(prompt_params)\n format.html { redirect_to @prompt, notice: 'Prompt was successfully updated.' }\n format.json { render :show, status: :ok, location: @prompt }\n else\n format.html { render :edit }\n format.json { render json: @prompt.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_resume\n @resume = Resume.where(:code=>params[:id].downcase).last\n end", "def update\n update_resource_response(@headline, headline_params)\n end", "def increment_responses_count\n self.responses_count += 1\n save\n end", "def update\n @question_response = QuestionResponse.find(params[:id])\n\n respond_to do |format|\n if @question_response.update_attributes(params[:question_response])\n format.html { redirect_to @question_response, notice: 'Question response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resume = current_user.resumes.build(params[:resume])\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to show_template_path(current_user, @resume) , notice: 'Resume was successfully created.' }\n format.json { render json: @resume, status: :created, location: @resume }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @answer_localized = AnswerLocalized.find(params[:id])\n\n respond_to do |format|\n if @answer_localized.update_attributes(params[:answer_localized])\n flash[:notice] = 'AnswerLocalized was successfully updated.'\n format.html { redirect_to(@answer_localized) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer_localized.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n #raise params.inspect\n params.delete :target_id if params[:target_id].to_s == \"\" \n #raise params.inspect\n\n respond_to do |format| \n if [email protected]? && @provisioningobject.update(provisioningobject_params) \n if @provisioningobject.provisioningtime == Provisioningobject::PROVISIONINGTIME_IMMEDIATE\n if @provisioningobject.provision(:create, @async)\n if @async \n @notice = \"#{@provisioningobject.class.name} is being created (provisioning running in the background).\"\n else\n @notice = \"#{@provisioningobject.class.name} is provisioned.\"\n end\n else # if @provisioningobject.provision(:create, @async)\n @notice = \"#{@provisioningobject.class.name} could not be provisioned\"\n end\n else # if @provisioningobject.provisioningtime == Provisioningobject::PROVISIONINGTIME_IMMEDIATE\n # only save, do not provision:\n @notice = \"#{@provisioningobject.class.name} is created and can be provisioned ad hoc.\"\n @provisioningobject.update_attribute(:status, \"not provisioned\")\n end\n \n format.html { redirect_to @provisioningobject, notice: @notice }\n format.json { render :show, status: :created, location: @provisioningobject } \n else # if @provisioningobject.save\n flash[:error] = \"#{@provisioningobject.class.name} could not be updated (already provisioned?)\"\n format.html { render :edit } \n format.json { render json: @provisioningobject.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @resume.destroy\n respond_to do |format|\n format.html { redirect_to resumes_url }\n format.json { head :no_content }\n end\n end", "def update\n @response_challenge = ResponseChallenge.find(params[:id])\n\n respond_to do |format|\n if @response_challenge.update_attributes(params[:response_challenge])\n format.html { redirect_to @response_challenge, notice: 'Response challenge was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @response_challenge.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @appointment_request = current_user.requests.find_by(\n id: params[:request_id]\n )\n\n if @appointment_request.present?\n render json: { appointment_request: @appointment_request, status: 200 }\n else\n render json: { status: 404, layout: false }, status: 404\n end\n end", "def resume\n @resume=Resume.find(params[:id])\n \n respond_to do |format|\n format.html # resume.html.erb\n format.xml { render :xml => @resume }\n end\n end", "def update\n @responder = Responder.find(params[:id])\n\n respond_to do |format|\n if @responder.update_attributes(params[:responder])\n format.html { redirect_to @responder, :notice => 'Responder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @responder.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @q_response = QResponse.find(params[:id])\n\n respond_to do |format|\n if @q_response.update_attributes(params[:q_response])\n format.html { redirect_to @q_response, notice: 'Q response was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @q_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @resume_recomendation.update(resume_recomendation_params)\n format.html { redirect_to @resume_recomendation.resume, notice: 'Рекомендация успешно отредактирована' }\n format.json { render :show, status: :ok, location: @resume_recomendation }\n else\n format.html { render :edit }\n format.json { render json: @resume_recomendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @request = @skill.requests.find(params[:id])\n\n respond_to do |format|\n if @request.update_attributes(params[:request])\n format.html { redirect_to myrequests_path, notice: 'request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @routine_interview = RoutineInterview.find(params[:id])\n @interview = Interview.find(@routine_interview.interview_id)\n\n respond_to do |format|\n if @routine_interview.update_attributes(params[:routine_interview]) && @interview.update_attributes(params[:interview])\n format.html { redirect_to @routine_interview, notice: 'Followup interview was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @routine_interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def resume\n execute_prlctl('resume', @uuid)\n end", "def add_resume\n @resume = Resume.new(:uri => params[:uri])\n\n respond_to do |format|\n if @resume.save\n flash[:notice] = 'Resume was successfully created.'\n format.html { redirect_to(:action => 'resume', :id => @resume) }\n format.xml { render :xml => @resume, :status => :created, :location => @resume }\n else\n flash[:notice][email protected] { |field, error| \"#{field}: #{error}\" }.join('<br />')\n format.html { render :action => \"index\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to resumes_url, notice: 'Resume was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def create\n @resume = current_user.resumes.build(resume_params)\n\n respond_to do |format|\n if @resume.save\n format.html { redirect_to root_path, notice: '履歴書を作成しました。' }\n format.json { render :show, status: :created, location: @resume }\n else\n format.html { render :new }\n format.json { render json: @resume.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interruption = Interruption.find(params[:id])\n\n respond_to do |format|\n if @interruption.update_attributes(params[:interruption])\n format.html { redirect_to @interruption, notice: 'Interruption was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interruption.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @response.update(response_params)\n format.html { redirect_to survey_response_path(params[:survey_id], @response.id), notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @intake_question = IntakeQuestion.find(params[:id])\n\n respond_to do |format|\n if @intake_question.update_attributes(params[:intake_question])\n format.html { redirect_to @intake_question, notice: 'Intake question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @intake_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def update\n @reminder_phrase = ReminderPhrase.find(params[:id])\n\n respond_to do |format|\n if @reminder_phrase.update_attributes(params[:reminder_phrase])\n format.html { redirect_to @reminder_phrase, notice: 'Reminder phrase was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reminder_phrase.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pre_test_answer.update(pre_test_answer_params)\n format.html { redirect_to @pre_test_answer, notice: 'Pre test answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @pre_test_answer }\n else\n format.html { render :edit }\n format.json { render json: @pre_test_answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_outcome.update(api_v1_outcome_params)\n format.html { redirect_to @api_v1_outcome, notice: 'Outcome was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_outcome }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_outcome.errors, status: :unprocessable_entity }\n end\n end\n end", "def resume\n card_id = params[:card_id]\n subscription = UserSubscription.get_my_paused_subscription(current_user, params[:id])\n resumed_sub = subscription.resume_subscription(card_id) if subscription.present?\n\n if resumed_sub.present?\n result = { key: 'success', message: \"#{resumed_sub} has been resumed Successfully. please wait...\" }\n else\n result = { key: 'error', message: \"Sorry, you are not authorized for this subscription.\" }\n end\n\n render json: result.to_json\n end", "def update\n @user_inference_response = UserInferenceResponse.find(params[:id])\n\n respond_to do |format|\n if @user_inference_response.update_attributes(params[:user_inference_response])\n format.html { redirect_to @user_inference_response, notice: 'User inference response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_inference_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @questionnaire = current_questionnaire\n @questionnaire.step += 1\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to new_questionnaire_path }\n # format.json { head :no_content }\n else\n format.html { render \"questionnaires/steps/step#{@questionnaire.step - 1}\" }\n # format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.69537973", "0.670963", "0.66101074", "0.6558063", "0.65337616", "0.6533588", "0.6477582", "0.64378995", "0.64275306", "0.64152503", "0.6326686", "0.6326686", "0.61933714", "0.6096429", "0.6090138", "0.60326844", "0.60326844", "0.60326844", "0.5991478", "0.5970573", "0.5932008", "0.59319276", "0.5909983", "0.58621806", "0.5815832", "0.5789044", "0.5787802", "0.56836146", "0.567718", "0.5673369", "0.5655378", "0.564498", "0.5636157", "0.5596774", "0.5596616", "0.5596422", "0.555408", "0.5552967", "0.5539403", "0.55293906", "0.5518307", "0.54880035", "0.548163", "0.5477022", "0.5466636", "0.54367983", "0.5424301", "0.5406125", "0.5384278", "0.5384278", "0.53744495", "0.5366787", "0.53566426", "0.5355573", "0.5351092", "0.5350143", "0.53437656", "0.53357184", "0.53279936", "0.5291412", "0.5284533", "0.5268382", "0.52447885", "0.52252245", "0.5222803", "0.5222058", "0.5218606", "0.5213931", "0.52063453", "0.5204848", "0.5202192", "0.5201846", "0.5200224", "0.52001244", "0.5190995", "0.5185977", "0.5179416", "0.5177958", "0.5172244", "0.51716846", "0.51704055", "0.51660097", "0.5160311", "0.5157597", "0.51574486", "0.51527333", "0.51513433", "0.51446563", "0.51360655", "0.513541", "0.5134062", "0.5131683", "0.5129239", "0.5122929", "0.5122468", "0.5122352", "0.5120998", "0.51119447", "0.5110575", "0.5110194" ]
0.6987272
0
DELETE /resume_responses/1 DELETE /resume_responses/1.json
def destroy @resume_response = ResumeResponse.find(params[:id]) @resume_response.destroy respond_to do |format| format.html { redirect_to resume_responses_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @resume.destroy\n respond_to do |format|\n format.html { redirect_to resumes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume = Resume.find(params[:id])\n @resume.destroy\n\n respond_to do |format|\n format.html { redirect_to resumes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume.destroy\n\n head :no_content\n end", "def destroy\n @resume.destroy\n respond_to do |format|\n format.html { redirect_to resumes_url, notice: 'Resume was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume = Resume.find(params[:id])\n @resume.destroy\n\n respond_to do |format|\n format.html { redirect_to current_user }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_attempt_response = QuestionAttemptResponse.find(params[:id])\n @question_attempt_response.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @resume_collection.destroy\n respond_to do |format|\n format.html { redirect_to resume_collections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @resumee.destroy\n respond_to do |format|\n format.html { redirect_to resumees_url, notice: 'Resumee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume_book_url.destroy\n respond_to do |format|\n format.html { redirect_to resume_book_urls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume_recomendation.destroy\n respond_to do |format|\n format.html { redirect_to resume_recomendations_url, notice: 'Resume recomendation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume = current_user.resume.find(params[:id])\n @resume.destroy\n\n respond_to do |format|\n format.html { redirect_to(resumes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n#status_url(Status.find_by_survey_id(protocol.access_code)\n #@p = ResponseSet.where(:user_id => current_user)\n #@protocol = user_id.find_by_survey_id(protocol.access_code)\n #@p = ResponseSet.where(:question_id => @title_questions).first.string_value\n p= ResponseSet.where(:access_code => params[:id])\n p.first.destroy\n \n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume.destroy\n end", "def destroy\n @resume.destroy\n end", "def destroy\n @resume.destroy\n flash[:notice] = '删除成功!'\n respond_to do |format|\n format.html { redirect_to(resumes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @resume.destroy\n respond_to do |format|\n format.html { redirect_to resumes_url, notice: '履歴書を削除しました。' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to resumes_url, notice: 'Resume was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def destroy\n @request_status = RequestStatus.find(params[:id])\n @request_status.destroy\n\n respond_to do |format|\n format.html { redirect_to request_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @resume_feedback = ResumeFeedback.find(params[:id])\n @resume_feedback.destroy\n\n respond_to do |format|\n format.html { redirect_to resume_feedbacks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @additionalinfo = @resume.additionalinfo \n @additionalinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to(resumes_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 delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n @request = @skill.requests.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to myrequests_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqstatus.destroy\n respond_to do |format|\n format.html { redirect_to reqstatuses_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @resume = Resume.find(params[:id])\n @resume.destroy\n @profile = context\n\n respond_to do |format|\n format.html { redirect_to(profiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @verification_request.destroy\n respond_to do |format|\n format.html { redirect_to verification_requests_url, notice: 'Verification request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @responder = Responder.find(params[:id])\n @responder.destroy\n\n respond_to do |format|\n format.html { redirect_to responders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :ok }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @question_response = QuestionResponse.find(params[:id])\n @question_response.destroy\n\n respond_to do |format|\n format.html { redirect_to question_responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Admin::Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @q_response = QResponse.find(params[:id])\n @q_response.destroy\n\n respond_to do |format|\n format.html { redirect_to q_responses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ride_request.destroy\n respond_to do |format|\n format.html { redirect_to ride_requests_url, notice: 'Ride request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @entry_answer = EntryAnswer.find(params[:id])\n @entry_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_answers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @survey_response = SurveyResponse.find(params[:id])\r\n @survey_response.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to survey_responses_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @survey_response = SurveyResponse.find(params[:id])\n @survey_response.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_survey_responses_path(params[:survey_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxirequest = Taxirequest.find(params[:id])\n @taxirequest.destroy\n\n respond_to do |format|\n format.html { redirect_to taxirequests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n render status: 200, json: @request_item.destroy\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reminder_phrase = ReminderPhrase.find(params[:id])\n @reminder_phrase.destroy\n\n respond_to do |format|\n format.html { redirect_to reminder_phrases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @status_request.destroy\n respond_to do |format|\n format.html { redirect_to status_requests_url, notice: 'Status request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sa_request_status.destroy\n respond_to do |format|\n format.html { redirect_to sa_request_statuses_url, notice: 'Sa request status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @completed_quest = CompletedQuest.find(params[:id])\n @completed_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to completed_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @api_v1_outcome.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_outcomes_url, notice: 'Outcome was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @request_call = RequestCall.find(params[:id])\n @request_call.destroy\n\n respond_to do |format|\n format.html { redirect_to request_calls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @req.destroy\n respond_to do |format|\n flash[:notice] = \"Req was successfully destroyed.\"\n format.html { redirect_to reqs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @exprience = Exprience.find(params[:id])\n @exprience.destroy\n\n respond_to do |format|\n format.html { redirect_to expriences_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @replay = Replay.find(params[:id])\n @replay.destroy\n\n respond_to do |format|\n format.html { redirect_to replays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sa_request.destroy\n respond_to do |format|\n format.html { redirect_to sa_requests_url, notice: 'Sa request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @modrequest.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n result = access_token.delete(\"/api/v1/emails/#{params[:id]}\")\n display_api_response( result )\n respond_with(\"\",:location => :back)\n end", "def destroy\n @routine_interview = RoutineInterview.find(params[:id])\n @routine_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to routine_interviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to(responses_url) }\n format.xml { head :ok }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @event_request = EventRequest.find(params[:id])\n @event_request.destroy\n\n respond_to do |format|\n format.html { redirect_to event_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expectation = Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to expectations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reminder = Reminder.find(params[:id])\n @reminder.destroy\n\n \n\n respond_to do |format|\n format.html { redirect_to reminders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Response.find(params[:response_id])\n \n @request_selection = RequestSelection.find(params[:id])\n @request_selection.destroy\n\n respond_to do |format|\n format.html { redirect_to response_request_selections_path(@response) }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@resume_entry.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to resume_entries_url, notice: 'Resume entry was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { message('You have successfully deleted this request') }\n format.json { head :ok }\n end\n end", "def destroy\n @respuestum.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 resume = Resume.find(params[:id])\n resume.destroy\n flash[:success] = 'Resume Successfully Deleted'\n redirect_to profile_resumes_path\n end", "def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @certificate_request.destroy\n respond_to do |format|\n format.html { redirect_to certificate_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_inference_response = UserInferenceResponse.find(params[:id])\n @user_inference_response.destroy\n\n respond_to do |format|\n format.html { redirect_to user_inference_responses_url }\n format.json { head :no_content }\n end\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def destroy\n #@service_request = ServiceRequest.find(params[:id])\n @service_request.destroy\n\n respond_to do |format|\n format.html { redirect_to service_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response_challenge = ResponseChallenge.find(params[:id])\n @response_challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to response_challenges_url }\n format.json { head :ok }\n end\n end", "def destroy\r\n @project_request = ProjectRequest.find(params[:id])\r\n @project_request.delete\r\n \r\n respond_to do |format|\r\n format.html { redirect_to my_requests_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @requisition = Requisition.find(params[:id])\n @requisition.destroy\n\n respond_to do |format|\n format.html { redirect_to requisitions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @app_request.destroy\n respond_to do |format|\n format.html { redirect_to app_requests_url, notice: 'App request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @myb_evl_intake.destroy\n respond_to do |format|\n format.html { redirect_to myb_evl_intakes_url, notice: 'Myb evl intake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vas_response.destroy\n respond_to do |format|\n format.html { redirect_to vas_responses_url, notice: 'Vas response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @past_request.destroy\n respond_to do |format|\n format.html { redirect_to past_requests_url, notice: 'Past request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @early_access_request.destroy\n respond_to do |format|\n format.html { redirect_to early_access_requests_url, notice: 'Anfrage wurde gelöscht.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reminder = Reminder.find(params[:id])\n @reminder.destroy\n\n respond_to do |format|\n format.html { redirect_to reminders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reminder = Reminder.find(params[:id])\n @reminder.destroy\n\n respond_to do |format|\n format.html { redirect_to reminders_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7259041", "0.7218649", "0.706997", "0.70453155", "0.69963515", "0.682667", "0.6775077", "0.6739571", "0.671595", "0.6699357", "0.66386527", "0.65893275", "0.6587377", "0.6587377", "0.6586315", "0.6581614", "0.6569374", "0.6550289", "0.65401787", "0.65401787", "0.6531026", "0.6530993", "0.6523953", "0.65116", "0.6508876", "0.6498153", "0.6494421", "0.64842546", "0.647817", "0.6477197", "0.6468457", "0.6466964", "0.6459225", "0.64566284", "0.64561176", "0.6451961", "0.64483917", "0.64476043", "0.64417225", "0.64417225", "0.64417225", "0.64417225", "0.64417225", "0.64417225", "0.6438058", "0.6436748", "0.64326113", "0.64276904", "0.641597", "0.641597", "0.641597", "0.64090216", "0.6407397", "0.640668", "0.639311", "0.63884646", "0.6387082", "0.6387052", "0.6384662", "0.63846433", "0.63745433", "0.63745433", "0.63745433", "0.63745433", "0.63701046", "0.63701046", "0.63677347", "0.6366504", "0.6361887", "0.63615847", "0.63507235", "0.6349385", "0.6339939", "0.63369167", "0.63366437", "0.6336029", "0.63345134", "0.63341475", "0.6329959", "0.63287884", "0.6324436", "0.6320075", "0.6311842", "0.63070196", "0.63038296", "0.6300729", "0.6297012", "0.6291545", "0.6288726", "0.628647", "0.6284961", "0.6282756", "0.6280781", "0.6269056", "0.62665343", "0.6265945", "0.6264058", "0.6263652", "0.6261841", "0.6261841" ]
0.7750977
0
Create a network of adjacency information from the text.
def initialize(*args) super # Save parameters if focal_word self.focal_word = focal_word.mb_chars.downcase.to_s self.focal_word_stem = focal_word.stem end # Extract the stop list if provided self.stop_words = [] if language self.stop_words = RLetters::Analysis::StopList.for(language) end # Clear final attributes self.nodes = [] self.edges = [] # Run the analysis for each of the gaps gaps.each_with_index do |g, i| add_nodes_for_gap(g) progress&.call((i + 1).to_f / gaps.size.to_f * 100.0) end # Final progress tick progress&.call(100) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_graph(input)\n dg = RGL::AdjacencyGraph[]\n lines = input.split(\"\\n\")\n n = lines[0].to_i\n for i in 1..n do\n data = lines[i].split(\" \")\n next if data[0].to_i <= 0\n data.shift # break data\n data.each{|v| dg.add_edge i, v.to_i }\n end\n dg\nend", "def build_graph\n graph = Graph.new\n f = File.new(filename, \"r\")\n\n # Get every line,\n # cast to integer, split into array,\n # add nodes to graph for each integer,\n # ending with: [node1, node2, node3]\n while line = f.gets\n arr_of_nodes = line.chomp.split(\"\").map do |value|\n graph.find_or_create_by(value.to_i)\n end\n\n arr_of_nodes.each_with_index do |node, i|\n next_node = arr_of_nodes[i+1]\n if next_node\n graph.connect(node, next_node)\n end\n end\n end\n f.close\n graph\n end", "def build(text)\r\n # parse words and then builds weighted links\r\n arr = []\r\n i = 0\r\n while word = parse_string\r\n arr << word\r\n if i == 0\r\n add_first_word()\r\n else\r\n add_word()\r\n end\r\n i = 0 if trim_space == true\r\n end\r\n \r\n end", "def start_graph(words)\n # initialize graph and edge count\n g = nodeset(words)\n gk = g.keys\n\n # initialize edge count\n incoming_edges = {}\n gk.each { |k| incoming_edges[k] = 0 }\n\n words.each_with_index do |w, i|\n w2 = words[i + 1]\n unless i + 1 == words.length\n # grab adjacent words in the dict and split them into arrays of their characters\n chars1, chars2 = w.split(\"\"), w2.split(\"\")\n chars1.each_with_index do |c, j|\n # compare characters in the words\n c2 = chars2[j]\n next if c == c2\n # note the parent/child relationship and increment the in-degree count\n g[c] += c2\n incoming_edges[c2] += 1\n break\n end\n end\n end\n\n alienlang(g, incoming_edges)\nend", "def parse_text(text)\n\t\tNode.destroy_all(work_id: self.id)\n\t\tLink.destroy_all(work_id: self.id)\n\t\tLinkCollection.destroy_all(work_id: self.id)\n\n\t\tstack = Array.new\n\t\tnew_ordering= []\n\t\tlink_colls_queue = []\n\t\ttext.each_line do |line|\n\t\t\t#parser rules: any amount of whitespace followed immediately by < means new node. Otherwise, new note.\n\t\t\t#<TYPE.CATEGORY>TITLE\n\t\t\t#if the occurence of <*> is before the first occurence of \" then it's a new\n\t\t\t#@angleBracketLocation = line.index(/[ ,\\t]*<.*>/)\n\t\t\n\t\t\tfirst_char = get_text_from_regexp(line, /[ ,\\t]*(.)/)\n\t\t\n\t\t\t#if a new node should be made\n\t\t\tif first_char == '.'\n\t\t\t\tnew_node = Node.new\n\t\t\t\tbuild_node(new_node, line)\n\t\t\t\tnew_node.save\n\n\t\t\t\t#get the parent.\n\t\t\t\tdepth = new_node.depth\n\n\t\t\t\tnewNodeDepth = NodeDepth.new(new_node.id, depth)\n\t\t\t\t\n\t\t\t\tif depth == 0 #if it's a base element\n\t\t\t\t\tstack.push(newNodeDepth)\n\t\t\t\telse\n\t\t\t\t\tcurrNodeDepth = stack.pop\n\t\t\t\t\twhile depth <= currNodeDepth.depth do #while you're less deep, therefore it aint yo momma \n\t\t\t\t\t\tcurrNodeDepth = stack.pop\n\t\t\t\t\tend #at this point, @currNodeDepth is the nearest element that's not as deep as the new one, it's parent\n\t\t\t\t\tparentNode = Node.find(currNodeDepth.node_idnum)\n\t\t\t\t\tif parentNode.id == new_node.id #if it didn't find any parent\n\t\t\t\t\t\tparent_id = nil\n\t\t\t\t\telse\n\t\t\t\t\t\tparent_id = parentNode.id\n\t\t\t\t\tend\n\n\t\t\t\t\t#creates the link, and the sets the parent and child relation\n\t\t\t\t\trelation = Link.new(child_id: new_node.id, parent_id: parent_id, work_id: self.id)\n\t\t\t\t\trelation.save\n\t\t\t\t\tnew_node.parent_relationships << relation\n\t\t\t\t\tparentNode.child_relationships << relation\n\n\t\t\t\t\tstack.push(currNodeDepth)#push the parent back in, in case it has siblings\n\t\t\t\t\tstack.push(newNodeDepth)#push self in, in case it has children\n\n\t\t\t\t\t#@new_node.parent_relationships.build(child_id: @new_node.id, parent_id:@parentNode.id)\n\t\t\t\t\t#@new_node.parents << @parentNode\n\t\t\t\t\t#@parent_node.child=\n\t\t\t\t\t#make this nodes id into the parents child.\n\t\t\t\t\t#make the child's parent the parentNode's id.\n\t\t\t\tend\n\t\t\t\tnew_node.save\n\t\t\t\tnew_ordering.push(ObjectPlace.new(\"Node\", new_node.id))\n\n\t\t\t#if it's a note\n\t\t\telsif first_char == '-'\n\t\t\t\tnew_note = Note.new()\n\t\t\t\tbuild_note(new_note, line)\n\n\t\t\t\t#this is a bug. it just gets attached to the previous node without regard for depth\n\t\t\t\t#binding.pry\n\t\t\t\tif (new_note.depth != 0 && !stack.empty?) #if it could have a parent and there are possibilities\n\n\t\t\t\t\tcurrNodeDepth = stack.pop\n\t\t\t\t\twhile new_note.depth <= currNodeDepth.depth do #while you're less deep, therefore it aint yo momma \n\t\t\t\t\t\tcurrNodeDepth = stack.pop\n\t\t\t\t\tend #at this point, @currNodeDepth is the nearest element that's not as deep as the new one, it's parent\n\t\t\t\t\tparentNode = Node.find(currNodeDepth.node_idnum)\n\t\t\t\t\tstack.push(currNodeDepth)\n\t\t\t\t\n\t\t\t\t\tnew_note.node_id = parentNode.id\n\t\t\t\t\t#parentNode.add_note_to_combined(new_note)\n\t\t\t\tend\n\t\t\t\tnew_note.save\n\t\t\t\tnew_ordering.push(ObjectPlace.new(\"Note\", new_note.id))\t\t\t\t\n\t\t\t#for special chars\n\t\t\telsif first_char == ':'\n\n\t\t\t\t#ordering.insert(line_number, ObjectPlace.new(\"LinkCollection\", nil))\n\t\t\t\t#set_order(ordering)\n\t\t\t\t#parent_node = find_element_parent(link_coll_depth, line_number, ordering)\n\n\t\t\t\twhitespace = get_text_from_regexp(text, /(.*):/)\n\t\t\t\tlink_coll_depth = (whitespace.length)/3 #+2?\n\t\t\t\tparentNode = nil\n\t\t\t\tif (link_coll_depth != 0 && !stack.empty?) #if it could have a parent and there are possibilities\n\n\t\t\t\t\tcurrNodeDepth = stack.pop\n\t\t\t\t\twhile link_coll_depth <= currNodeDepth.depth do #while you're less deep, therefore it aint yo momma \n\t\t\t\t\t\tcurrNodeDepth = stack.pop\n\t\t\t\t\tend #at this point, @currNodeDepth is the nearest element that's not as deep as the new one, it's parent\n\t\t\t\t\tparentNode = Node.find(currNodeDepth.node_idnum)\n\t\t\t\t\tstack.push(currNodeDepth)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tlink_coll = self.link_collections.build\n\t\t\t\tbuild_link_collection(link_coll, line, parentNode)\t\n\t\t\t\tlink_colls_queue.append({link_coll: link_coll, text: get_text_from_regexp(line, /:(.*)/)})\n\t\t\t\t#binding.pry\n\t\t\t\tnew_ordering.push(ObjectPlace.new(\"LinkCollection\", link_coll.id))\n\t\t\telse\n\t\t\t\tplace_holder = work.place_holders.create(text:line_content)\n\t\t\t\tnew_ordering.push(ObjectPlace.new(\"PlaceHolder\", place_holder.id))\n\t\t\tend\n\t\tend\n\n\t\tset_order(new_ordering)\n\t\t#at the end, build those links (appending the newly made nodes if needed.) This way, all nodes are mode before it thinks\n\t\t#it needs to be doing this shit\n\t\tlink_colls_queue.each do |link_coll_pair|\n\t\t\t#build its child links\n\t\t\tlink_coll_pair[:link_coll].set_links(link_coll_pair[:text])\n\t\tend\n\n\t\t#should fix this so I can get rid of populate_ordering, only works here because things are produced in order, can do it as I go\n\t\t#o = populate_ordering\n\tend", "def initialize(text='nothing')\n @text = text\n @edges = []\n @name=\"noone\"\n @hash = 0 #int\n @visited= false #boolean\n end", "def Graph(str)\n graph = Graph.new\n nodes = {}\n str.lines.each do |line|\n case line\n when /^\\s*(\\w+):(.*)$/\n name,code = $~[1,2]\n graph << (nodes[name] = eval(code))\n when /^\\s*(\\w+)\\s*->\\s*(\\w+)((\\s*->\\s*\\w+)*)\\s*(#.*)?$/\n name1,name2,others = $~[1,3]\n [name1,name2].each do |name|\n raise \"Undefined node: #{name} on line: #{line}\" if not nodes.key? name\n end\n nodes[name1].out << nodes[name2]\n \n if others != \"\"\n # repeat on the part of this line which we have not processed yet\n line = name2+others\n redo\n end\n when /^\\s*(#.*)?$/\n next\n else\n raise \"Couldn't parse this line: #{line}\"\n end\n end\n raise \"No start node defined! There should be a node called START.\" if not nodes.key? 'START'\n graph.start = nodes['START']\n graph\nend", "def vertex_creation(line)\n x = line.chomp(\"\\n\").split(';')\n id = x[0].to_i\n data = x[1]\n if x[2]\n neighbors = x[2].split(',')\n neighbors = neighbors.map(&:to_i)\n else\n neighbors = []\n end\n [id, data, neighbors]\nend", "def generate_graph(text, pos_tagger, coreNLPTagger, forRelevance, forPatternIdentify)\n #initializing common arrays \n @vertices = Array.new\n @num_vertices = 0\n @edges = Array.new\n @num_edges = 0\n\n @pos_tagger = pos_tagger #part of speech tagger\n @pipeline = coreNLPTagger #dependency parsing\n #iterate through the sentences in the text\n for i in (0..text.length-1)\n if(text[i].empty? or text[i] == \"\" or text[i].split(\" \").empty?)\n next\n end\n unTaggedString = text[i].split(\" \")\n # puts \"UnTagged String:: #{unTaggedString}\"\n taggedString = @pos_tagger.get_readable(text[i])\n# puts \"taggedString:: #{taggedString}\"\n \n #Initializing some arrays\n nouns = Array.new\n nCount = 0\n verbs = Array.new\n vCount = 0\n adjectives = Array.new\n adjCount = 0\n adverbs = Array.new\n advCount = 0\n \n parents = Array.new\n labels = Array.new\n \n #------------------------------------------#------------------------------------------\n #finding parents\n parents = find_parents(text[i])\n parentCounter = 0\n #------------------------------------------#------------------------------------------\n #finding parents\n labels = find_labels(text[i])\n labelCounter = 0\n #------------------------------------------#------------------------------------------\n #find state\n sstate = SentenceState.new\n states_array = sstate.identify_sentence_state(taggedString)\n states_counter = 0\n state = states_array[states_counter]\n states_counter += 1\n #------------------------------------------#------------------------------------------\n \n taggedString = taggedString.split(\" \")\n prevType = nil #initlializing the prevyp\n \n #iterate through the tokens\n for j in (0..taggedString.length-1)\n taggedToken = taggedString[j]\n plainToken = taggedToken[0...taggedToken.index(\"/\")].to_s\n posTag = taggedToken[taggedToken.index(\"/\")+1..taggedToken.length].to_s \n #ignore periods\n if(plainToken == \".\" or taggedToken.include?(\"/POS\") or (taggedToken.index(\"/\") == taggedToken.length()-1) or (taggedToken.index(\"/\") == taggedToken.length()-2))#this is for strings containinig \"'s\" or without POS\n next\n end\n \n #SETTING STATE\n #since the CC or IN are part of the following sentence segment, we set the STATE for that segment when we see a CC or IN\n if(taggedToken.include?(\"/CC\"))#{//|| ps.contains(\"/IN\")\n state = states_array[states_counter]\n states_counter+=1\n end\n # puts(\"**Value:: #{plainToken} LabelCounter:: #{labelCounter} ParentCounter:: #{parentCounter} POStag:: #{posTag} .. state = #{state}\")\n\n #------------------------------------------\n #if the token is a noun\n if(taggedToken.include?(\"NN\") or taggedToken.include?(\"PRP\") or taggedToken.include?(\"IN\") or taggedToken.include?(\"/EX\") or taggedToken.include?(\"WP\"))\n #either add on to a previous vertex or create a brand new noun vertex\n if(prevType == NOUN) #adding to a previous noun vertex\n nCount -= 1 #decrement, since we are accessing a previous noun vertex\n prevVertex = search_vertices(@vertices, nouns[nCount], i) #fetching the previous vertex\n nouns[nCount] = nouns[nCount].to_s + \" \" + plainToken #concatenating with contents of the previous noun vertex\n #checking if the previous noun concatenated with \"s\" already exists among the vertices\n if((nounVertex = search_vertices(@vertices, nouns[nCount], i)) == nil) \n prevVertex.name = prevVertex.name.to_s + \" \" + plainToken #concatenating the nouns\n nounVertex = prevVertex #the current concatenated vertex will be considered\n if(labels[labelCounter] != \"NMOD\" or labels[labelCounter] != \"PMOD\")#resetting labels for the concatenated vertex\n nounVertex.label = labels[labelCounter]\n end\n #fAppendedVertex = 1\n end#if the vertex already exists, just use nounVertex - the returned vertex for ops. \n else #if the previous token is not a noun, create a brand new vertex\n nouns[nCount] = plainToken #this is checked for later on\n nounVertex = search_vertices(@vertices, plainToken, i)\n if(nounVertex == nil) #the string doesn't already exist\n @vertices[@num_vertices] = Vertex.new(nouns[nCount], NOUN, i, state, labels[labelCounter], parents[parentCounter], posTag)\n nounVertex = @vertices[@num_vertices] #the newly formed vertex will be considered\n @num_vertices+=1\n end\n end #end of if prevType was noun\n remove_redundant_vertices(nouns[nCount], i)\n nCount+=1 #increment nCount for a new noun vertex just created (or existing previous vertex appended with new text)\n \n #checking if a noun existed before this one and if the adjective was attached to that noun.\n #if an adjective was found earlier, we add a new edge\n if(prevType == ADJ)\n #set previous noun's property to null, if it was set, if there is a noun before the adjective\n if(nCount > 1)\n v1 = search_vertices(@vertices, nouns[nCount-2], i) #fetching the previous noun, the one before the current noun (therefore -2) \n v2 = search_vertices(@vertices, adjectives[adjCount-1], i) #fetching the previous adjective \n #if such an edge exists - DELETE IT - search_edges_to_set_null() returns the position in the array at which such an edge exists\n if(!v1.nil? and !v2.nil? and (e = search_edges_to_set_null(@edges, v1, v2, i)) != -1) #-1 is when no such edge exists\n @edges[e] = nil #setting the edge to null\n #if @num_edges had been previously incremented, decrement it\n if(@num_edges > 0)\n @num_edges-=1 #deducting an edge count\n end\n end \n end\n #if this noun vertex was encountered for the first time, nCount < 1,\n #so do adding of edge outside the if condition \n #add a new edge with v1 as the adjective and v2 as the new noun\n v1 = search_vertices(@vertices, adjectives[adjCount-1], i)\n v2 = nounVertex #the noun vertex that was just created\n #if such an edge did not already exist\n if(!v1.nil? and !v2.nil? and (e = search_edges(@edges, v1, v2, i)) == -1)\n @edges[@num_edges] = Edge.new(\"noun-property\",VERB)\n @edges[@num_edges].in_vertex = v1\n @edges[@num_edges].out_vertex = v2\n @edges[@num_edges].index = i\n @num_edges+=1\n #since an edge was just added we try to check if there exist any redundant edges that can be removed\n remove_redundant_edges(v1, v2, i)\n end\n end\n #a noun has been found and has established a verb as an in_vertex and such an edge doesnt already previously exist\n if(vCount > 0) #and fAppendedVertex == 0 \n #add edge only when a fresh vertex is created not when existing vertex is appended to\n v1 = search_vertices(@vertices, verbs[vCount-1], i)\n v2 = nounVertex\n #if such an edge does not already exist add it\n if(!v1.nil? and !v2.nil? and (e = search_edges(@edges,v1, v2, i)) == -1)\n @edges[@num_edges] = Edge.new(\"verb\", VERB) \n @edges[@num_edges].in_vertex = v1 #for vCount = 0\n @edges[@num_edges].out_vertex = v2\n @edges[@num_edges].index = i\n @num_edges+=1\n #since an edge was just added we try to check if there exist any redundant edges that can be removed\n remove_redundant_edges(v1, v2, i)\n end\n end\n prevType = NOUN\n #------------------------------------------\n \n #if the string is an adjective\n #adjectives are vertices but they are not connected by an edge to the nouns, instead they are the noun's properties\n elsif(taggedToken.include?(\"/JJ\")) \n adjective = nil\n if(prevType == ADJ) #combine the adjectives\n # puts(\"PREV ADJ here:: #{plainToken}\")\n if(adjCount >= 1)\n adjCount = adjCount - 1\n prevVertex = search_vertices(@vertices, adjectives[adjCount], i) #fetching the previous vertex\n adjectives[adjCount] = adjectives[adjCount] + \" \" + plainToken \n #if the concatenated vertex didn't already exist\n if((adjective = search_vertices(@vertices, adjectives[adjCount], i)).nil?)\n prevVertex.name = prevVertex.name+\" \"+plainToken\n adjective = prevVertex #set it as \"adjective\" for further execution\n if(labels[labelCounter] != \"NMOD\" or labels[labelCounter] != \"PMOD\") #resetting labels for the concatenated vertex\n adjective.label = labels[labelCounter]\n end\n end\n end\n else #new adjective vertex\n adjectives[adjCount] = plainToken\n if((adjective = search_vertices(@vertices, plainToken, i)).nil?) #the string doesn't already exist\n @vertices[@num_vertices] = Vertex.new(adjectives[adjCount], ADJ, i, state, labels[labelCounter], parents[parentCounter], posTag)\n adjective = @vertices[@num_vertices]\n @num_vertices+=1\n end\n end\n remove_redundant_vertices(adjectives[adjCount], i) \n adjCount+=1 #incrementing, since a new adjective was created or an existing one updated.\n \n #by default associate the adjective with the previous/latest noun and if there is a noun following it immediately, then remove the property from the older noun (done under noun condition)\n if(nCount > 0) #gets the previous noun to form the edge\n v1 = search_vertices(@vertices, nouns[nCount-1], i) \n v2 = adjective #the current adjective vertex\n #if such an edge does not already exist add it\n if(!v1.nil? and !v2.nil? and (e = search_edges(@edges, v1, v2, i)) == -1)\n # puts \"** Adding noun-adj edge .. #{v1.name} - #{v2.name}\"\n @edges[@num_edges] = Edge.new(\"noun-property\",VERB)\n @edges[@num_edges].in_vertex = v1\n @edges[@num_edges].out_vertex = v2\n @edges[@num_edges].index = i\n @num_edges+=1 \n #since an edge was just added we try to check if there exist any redundant edges that can be removed\n remove_redundant_edges(v1, v2, i) \n end\n end\n prevType = ADJ\n #end of if condition for adjective\n #------------------------------------------\n \n #if the string is a verb or a modal//length condition for verbs is, be, are...\n elsif(taggedToken.include?(\"/VB\") or taggedToken.include?(\"MD\"))\n verbVertex = nil\n if(prevType == VERB) #combine the verbs \n vCount = vCount - 1\n prevVertex = search_vertices(@vertices, verbs[vCount], i) #fetching the previous vertex\n verbs[vCount] = verbs[vCount] + \" \" + plainToken \n #if the concatenated vertex didn't already exist\n if((verbVertex = search_vertices(@vertices, verbs[vCount], i)) == nil)\n prevVertex.name = prevVertex.name + \" \" + plainToken\n verbVertex = prevVertex #concatenated vertex becomes the new verb vertex\n if(labels[labelCounter] != \"NMOD\" or labels[labelCounter] != \"PMOD\")#resetting labels for the concatenated vertex\n verbVertex.label = labels[labelCounter]\n end\n end\n else\n verbs[vCount] = plainToken\n if((verbVertex = search_vertices(@vertices, plainToken, i)) == nil)\n @vertices[@num_vertices] = Vertex.new(plainToken, VERB, i, state, labels[labelCounter], parents[parentCounter], posTag)\n verbVertex = @vertices[@num_vertices] #newly created verb vertex will be considered in the future\n @num_vertices+=1\n end\n end\n remove_redundant_vertices(verbs[vCount], i)\n vCount+=1\n \n #if an adverb was found earlier, we set that as the verb's property\n if(prevType == ADV)\n #set previous verb's property to null, if it was set, if there is a verb following the adverb\n if(vCount > 1)\n v1 = search_vertices(@vertices, verbs[vCount-2], i) #fetching the previous verb, the one before the current one (hence -2) \n v2 = search_vertices(@vertices, adverbs[advCount-1], i) #fetching the previous adverb \n #if such an edge exists - DELETE IT\n if(!v1.nil? and !v2.nil? and (e = search_edges_to_set_null(@edges, v1, v2, i)) != -1)\n @edges[e] = nil #setting the edge to null\n if(@num_edges > 0)\n @num_edges-=1 #deducting an edge count\n end\n end\n end\n #if this verb vertex was encountered for the first time, vCount < 1,\n #so do adding of edge outside the if condition\n #add a new edge with v1 as the adverb and v2 as the new verb\n v1 = search_vertices(@vertices, adverbs[advCount-1], i)\n v2 = verbVertex\n #if such an edge did not already exist\n if(!v1.nil? and !v2.nil? and (e = search_edges(@edges, v1, v2, i)) == -1)\n @edges[@num_edges] = Edge.new(\"verb-property\",VERB)\n @edges[@num_edges].in_vertex = v1\n @edges[@num_edges].out_vertex = v2\n @edges[@num_edges].index = i\n @num_edges+=1 \n #since an edge was just added we try to check if there exist any redundant edges that can be removed\n remove_redundant_edges(v1, v2, i)\n end\n end\n \n #making the previous noun, one of the vertices of the verb edge\n if(nCount > 0) #and fAppendedVertex == 0 \n #gets the previous noun to form the edge\n v1 = search_vertices(@vertices, nouns[nCount-1], i)\n v2 = verbVertex\n #if such an edge does not already exist add it\n if(!v1.nil? and !v2.nil? and (e = search_edges(@edges, v1, v2, i)) == -1)\n @edges[@num_edges] = Edge.new(\"verb\",VERB)\n @edges[@num_edges].in_vertex = v1 #for nCount = 0;\n @edges[@num_edges].out_vertex = v2 #the verb\n @edges[@num_edges].index = i\n @num_edges+=1\n #since an edge was just added we try to check if there exist any redundant edges that can be removed\n remove_redundant_edges(v1, v2, i)\n end\n end\n prevType = VERB\n #------------------------------------------ \n #if the string is an adverb\n elsif(taggedToken.include?(\"RB\"))\n adverb = nil\n if(prevType == ADV) #appending to existing adverb\n if(advCount >= 1)\n advCount = advCount - 1\n end\n prevVertex = search_vertices(@vertices, adverbs[advCount], i) #fetching the previous vertex\n adverbs[advCount] = adverbs[advCount] + \" \" + plainToken\n #if the concatenated vertex didn't already exist\n if((adverb = search_vertices(@vertices, adverbs[advCount], i)) == nil)\n prevVertex.name = prevVertex.name + \" \" + plainToken\n adverb = prevVertex #setting it as \"adverb\" for further computation\n if(labels[labelCounter] != \"NMOD\" or labels[labelCounter] != \"PMOD\") #resetting labels for the concatenated vertex\n adverb.label = labels[labelCounter]\n end\n end\n else #else creating a new vertex\n adverbs[advCount] = plainToken\n if((adverb = search_vertices(@vertices, plainToken, i)) == nil)\n @vertices[@num_vertices] = Vertex.new(adverbs[advCount], ADV, i, state, labels[labelCounter], parents[parentCounter], posTag);\n adverb = @vertices[@num_vertices]\n @num_vertices+=1\n end\n end \n remove_redundant_vertices(adverbs[advCount], i) \n advCount+=1\n \n #by default associate it with the previous/latest verb and if there is a verb following it immediately, then remove the property from the verb\n if(vCount > 0) #gets the previous verb to form a verb-adverb edge\n v1 = search_vertices(@vertices, verbs[vCount-1], i)\n v2 = adverb\n #if such an edge does not already exist add it\n if(!v1.nil? and !v2.nil? && (e = search_edges(@edges, v1, v2, i)) == -1)\n @edges[@num_edges] = Edge.new(\"verb-property\",VERB)\n @edges[@num_edges].in_vertex = v1 #for nCount = 0;\n @edges[@num_edges].out_vertex = v2 #the verb\n @edges[@num_edges].index = i\n @num_edges+=1\n #since an edge was just added we try to check if there exist any redundant edges that can be removed\n remove_redundant_edges(v1, v2, i)\n end\n end\n prevType = ADV\n #end of if condition for adverb\n end #end of if condition\n #------------------------------------------ \n #incrementing counters for labels and parents\n labelCounter+=1\n parentCounter+=1 \n end #end of the for loop for the tokens\n #puts \"here outside the for loop for tokens\"\n nouns = nil\n verbs = nil\n adjectives = nil\n adverbs = nil\n end #end of number of sentences in the text\n\n @num_vertices = @num_vertices - 1 #since as a counter it was 1 ahead of the array's contents\n if(@num_edges != 0)\n @num_edges = @num_edges - 1 #same reason as for num_vertices\n end\n set_semantic_labels_for_edges\n #print_graph(@edges, @vertices)\n# puts(\"Number of edges:: #{@num_edges}\")\n# puts(\"Number of vertices:: #{@num_vertices}\")\n return @num_edges\nend", "def create_graph(stringSet)\n stringSet.each do |string|\n string.split(\"\").each_with_index do |char, i|\n curr_node = node_with_char(char)\n break if (i == (string.length) - 1)\n for index in (i+1)..(string.length-1) do \n next_node = node_with_char(string[index])\n curr_node.add_vertice(next_node) unless curr_node.contains?(next_node)\n end\n end\n end\n end", "def build_from_string(data)\n\n # Check if string representation of the graph is valid\n raise ArgumentError, 'String representation of the graph is invalid' unless data =~ /\\A(|([a-z0-0A-Z]+=>[a-z0-0A-Z]*)(,[a-z0-0A-Z]+=>[a-z0-0A-Z]*)*)\\z/\n\n pairs = data.split(',')\n\n pairs.each do |value|\n items = value.split('=>')\n self.add_vertex(Vertex.new(items[0])) unless find_index_for_vertex(items[0]) != nil\n\n if (items.length == 2)\n self.add_vertex(Vertex.new(items[1])) unless find_index_for_vertex(items[1]) != nil\n self.add_edge(items[0],items[1])\n end\n end\n end", "def nodes\n NODE_LIST_REGEX.match(@text).to_s.scan(NODE_REGEX).map do |match|\n Node.new(match[1], match[2], match[3].to_i)\n end\n end", "def set_links(text)\n \tchunks = text.split(\",\")\n new_nodes = []\n\n \tchunks.each do |chunk|\n #perhaps have this find all of them\n \t\tchild_node = Node.find_by(title: chunk.strip, work_id:self.work)\n\n if child_node == nil #if the child doesn't exist, create it at the very end\n place = self.work.get_ordering.length\n self.work.add_new_element([place], [\".,\"+chunk])\n child_node = self.work.get_element_in_ordering(place, self.work.get_ordering)\n new_nodes << child_node\n end\n \n link = self.links.build\n #if it has a parent, give the link that parent. otherwise, set it to nil\n if self.node != nil\n link.parent_id = self.node.id\n else\n link.parent_id = nil\n end\n link.work = self.work\n link.child = child_node\n \tlink.save\n\t end\n\n return new_nodes\n end", "def add_adjacency(n1, n2)\n n1.adjacents << n2\n n2.adjacents << n1\n end", "def make_graph\r\n lines.each {|line, stations|\r\n stations.each_with_index {|x, index|\r\n unless stations.at(index+1).nil?\r\n graph.add_edge(find_node(x), find_node(stations.at(index+1)))\r\n end\r\n }\r\n }\r\n end", "def generate_graph(text, coreNLPTagger)\n @pipeline = coreNLPTagger # dependency parsing\n\n @tp = TextPreprocessor.new\n text = StanfordCoreNLP::Annotation.new(text) # the same variable has to be passed into the Annotation.new method\n @pipeline.annotate(text)\n\n text.get(:sentences).each do |sentence|\n # we must keep the order of tokens in the sentence\n @untagged_tokens = sentence.get(:tokens).to_a\n @untagged_tokens.map! { |token| token.to_s.gsub!(/-\\d\\d*/, \"\") }\n @parsed_sentence = sentence.get(:collapsed_c_c_processed_dependencies)\n\n # filter tokens and only keep the ones in parsed sentence\n parsed_tokens = @parsed_sentence.to_s.split(\" \").select.with_index { |t, i| i%3 == 1 }\n untagged_parsed_tokens = parsed_tokens.map { |token| token.split(\"/\").first }\n @untagged_tokens.select! { |token| untagged_parsed_tokens.include?(token) }\n @tagged_tokens = @untagged_tokens.map { |token| parsed_tokens[untagged_parsed_tokens.index(token)] }\n\n @parents = find_parents\n @labels = find_labels\n\n # find state\n sstate = SentenceState.new\n state_array = sstate.identify_sentence_state(@tagged_tokens)\n state = state_array[0]\n state_counter = 1\n prevType = nil\n\n # iterate through the tokens\n @tagged_tokens.each_with_index do |tagged_token|\n str_a = tagged_token.split('/')\n plain_token = str_a[0]\n pos_tag = str_a[1]\n\n next if pos_tag.nil?\n\n # if the token is a noun\n case pos_tag\n # this is for strings containing \"'s\"(\"/POS\" tag)\n when 'POS'\n next\n\n # since the CC or IN are part of the following sentence segment, we set the STATE for that segment when we see a CC or IN\n when 'CC'\n state = state_array[state_counter]\n state_counter += 1\n\n when 'NN', 'PRP', 'IN', 'EX', 'WP'\n # if the previous token is a noun, add to a previous noun vertex\n if prevType == NOUN\n append_to_previous(@noun_vertices[-1], plain_token)\n # if the previous token is not a noun, create a brand new vertex\n else\n create_new_vertex(plain_token, NOUN, state, pos_tag)\n # remove_redundant_vertices(nouns[nCount], i)\n\n # checking if a noun existed before this one and if the adjective was attached to that noun.\n # if an adjective was found earlier, we add a new edge\n if prevType == ADJ\n # set previous noun's property to null, if it was set, if there is a noun before the adjective\n # fetching the previous noun, the one before the current noun (therefore -2)\n v1 = @noun_vertices[-2]\n # fetching the previous adjective\n v2 = @adj_vertices[-1]\n # if such an edge exists - DELETE IT -\n delete_edge(v1,v2)\n\n # add a new edge with v1 as the adjective and v2 as the new noun\n v1 = @adj_vertices[-1]\n v2 = @noun_vertices[-1] # the noun vertex that was just created\n create_edge(v1,v2,\"noun-property\",VERB)\n end\n\n # a noun has been found and has established a verb as an in_vertex and such an edge doesn't already previously exist\n # add edge only when a fresh vertex is created not when existing vertex is appended to\n v1 = @verb_vertices[-1]\n v2 = @noun_vertices[-1]\n create_edge(v1,v2,\"verb\",VERB)\n end\n prevType = NOUN\n\n # if the string is an adjective\n # adjectives are vertices but they are not connected by an edge to the nouns, instead they are the noun's properties\n when 'JJ'\n if prevType == ADJ\n # combine the adjectives\n append_to_previous(@adj_vertices[-1], plain_token)\n else\n # new adjective vertex\n create_new_vertex(plain_token, ADJ, state, pos_tag)\n # remove_redundant_vertices(adjectives[adjCount], i)\n\n # by default associate the adjective with the previous/latest noun and if there is a noun following it immediately,\n # then remove the property from the older noun (done under noun condition)\n v1 = @noun_vertices[-1]\n v2 = @adj_vertices[-1]\n # if such an edge does not already exist add it\n create_edge(v1,v2,\"noun-property\",VERB)\n end\n prevType = ADJ\n\n # if the string is a verb or a modal/length condition for verbs is, be, are...\n when 'VB', 'MD'\n if prevType == VERB\n # combine the verbs\n append_to_previous(@verb_vertices[-1], plain_token)\n else\n create_new_vertex(plain_token, VERB, state, pos_tag)\n # remove_redundant_vertices(verbs[vCount], i)\n\n # if an adverb was found earlier, we set that as the verb's property\n if prevType == ADV\n # set previous verb's property to null, if it was set, if there is a verb following the adverb\n # fetching the previous verb, the one before the current one (hence -2)\n v1 = @verb_vertices[-2]\n # fetching the previous adverb\n v2 = @adj_vertices[-1]\n # if such an edge exists - DELETE IT\n delete_edge(v1,v2)\n\n # if this verb vertex was encountered for the first time, vCount < 1,\n # add a new edge with v1 as the adverb and v2 as the new verb\n v1 = @adv_vertices[-1]\n v2 = @verb_vertices[-1]\n # if such an edge did not already exist\n create_edge(v1,v2,\"verb-property\",VERB)\n end\n\n # making the previous noun, one of the vertices of the verb edge\n # gets the previous noun to form the edge\n v1 = @noun_vertices[-1]\n v2 = @verb_vertices[-1]\n # if such an edge does not already exist add it\n create_edge(v1, v2,\"verb\", VERB)\n end\n prevType = VERB\n\n # if the string is an adverb\n when 'RB'\n if prevType == ADV\n # appending to existing adverb\n append_to_previous(@adv_vertices[-1], plain_token)\n else\n # creating a new vertex\n create_new_vertex(plain_token, ADV, state, pos_tag)\n # remove_redundant_vertices(adverbs[advCount], i)\n\n # by default associate it with the previous/latest verb and if there is\n # a verb following it immediately, then remove the property from the verb\n # form a verb-adverb edge\n v1 = @verb_vertices[-1]\n v2 = @adv_vertices[-1]\n # if such an edge does not already exist add it\n create_edge(v1,v2,\"verb-property\",VERB)\n end\n prevType = ADV\n end\n end\n\n prevType = nil\n end\n\n @vertices = @noun_vertices + @adj_vertices + @adv_vertices + @verb_vertices\n set_semantic_labels_for_edges\n end", "def create_graph(arr)\n nodes = []\n (0...arr.size).each do |i|\n node = Node.new(i)\n nodes.push(node)\n end\n nodes.each_with_index do |node,i|\n arr[i].each {|val| node.connections.push(nodes[val])} \n end\n nodes\nend", "def create_graph(arr)\n nodes = []\n (0...arr.size).each do |i|\n node = Node.new(i)\n nodes.push(node)\n end\n nodes.each_with_index do |node,i|\n arr[i].each {|val| node.connections.push(nodes[val])} \n end\n nodes\nend", "def build_assignment_graph(layer)\n\t\th = @via_positions.length\n\t\tfail if (h == 0) || h.odd?\n\t\tfail if @start_node.pads.min < 0 || @start_node.pads.max >= @layer_count\n\t\tfail if @end_node.pads.min < 0 || @end_node.pads.max >= @layer_count\n\t\tvia_count = h / 2\n\t\tputs via_count\n\t\tlayers = 0..(@layer_count - 1) \n\t\tcolums = 0..(via_count * 2) # F O F O F for via_count == 2 \n\t\t#vp = @via_positions.dup # x,y pairs\n\t\t#vp.unshift(@start_node.y)\n\t\t#vp.unshift(@start_node.x)\n\t\tvp = [@start_node.x, @start_node.y] + @via_positions\n\t\tm = Array.new(@layer_count){Array.new(via_count * 2 + 1)}\n\t\tfor i in colums # from T back to S\n\t\t\tif i.even?\n\t\t\t\ty = vp.pop\n\t\t\t\tx = vp.pop\n\t\t\tend\n\t\t\tfor j in layers\n\t\t\t\tl = Array.new\n\t\t\t\tif i.even? # forward\n\t\t\t\t\tk = i + 1\n\t\t\t\t\twhile k > 0\n\t\t\t\t\t\tk -= 2\n\t\t\t\t\t\tif k == -1 # link forward node to T node\n\t\t\t\t\t\t\tl << @end_node if @end_node.pads.include?(j)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tif (h = m[j][k])\n\t\t\t\t\t\t\t\tl << h # link to up/down node \n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tunless l.empty?\n\t\t\t\t\t\tm[j][i] = F_node.new(x, y, j, l)\n\t\t\t\t\t\tl.each{|el|\n\t\t\t\t\t\t#unless @segment_list.index{|m| m.x1 == && m.y1 == el.y1 & m.x2 == el.x2 && m.y2 == el.y2}\n\t\t\t\t\t\t\t@segment_list << Segment.new(x, y, el.x, el.y)\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\telse #up/down\n\t\t\t\t\tfor k in layers do\n\t\t\t\t\t\tif (k != j) && (h = m[k][i - 1])\n\t\t\t\t\t\t\tl << h\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tunless l.empty?\n\t\t\t\t\t\tm[j][i] = V_node.new(x, y, j, l)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#puts @segment_list.length\n\t\t@segment_list.uniq!{|el| [el.x1, el.y1, el.x2, el.y2]}\n\t\tputs @segment_list.length\n\t\t@all_intersecting_segments = Array.new\n\t\t@segment_list.each{|el|\n\t\t\t@all_intersecting_segments += el.intersecting_segments\n\t\t}\n\t\t@all_intersecting_segments.uniq!\n\n\t\tfor j in layers\n\t\t\tif (h = m[j][-1]) && @start_node.pads.include?(j)\n\t\t\t\t@start_node.next << h\n\t\t\tend\n\t\tend\n\tend", "def make_directed(vertices, directed_edges)\n g = RGL::DirectedAdjacencyGraph.new\n \n vertices.each { |v| g.add_vertex(v) }\n \n directed_edges.each do |source, targets|\n targets.each { |target| g.add_edge(source, target) }\n end\n \n g\nend", "def make_adjlists(layout)\n layout.each do |edge|\n start = edge.village1\n ending = edge.village2\n color = edge.color\n type = edge.type_transit\n layout.each do |surround| \n if surround.village1 == ending && surround.village2 != start\n if surround.color == color || surround.type_transit == type\n edge.add_adjlist(surround)\n end\n end\n end\n end\nend", "def build_adjacency_list\n\n r = join_people_by_relationship_type\n\n h = {}\n r.each {|rr|\n id = rr[0]\n h[id] = {:id => id, :name => rr[1], :children => []} if h[id].nil? # if there's no hash entry for this person, make one.\n h[id][:children] << {:id => rr[2], :name => rr[3], :children => []} # enter the person's subordinates as children into the hash. (source / sink)\n }\n h\n end", "def createNodes\n tabRead(@matrix){|arr|\n name = arr.delete_at(0)\n if @nodeList.key?(name)\n arr = arr.collect{|x| x.to_i}\n @allNodes[name] = Node.new(arr,name)\n end\n }\n \n #add weights to nodes, make bi-directional\n @allEdgeWeightScores.each{|names,score|\n name = names.split(/--/)\n @allNodes[name[0]].conns << name[1]\n @allNodes[name[1]].conns << name[0]\n } \nend", "def sort_alien_language(words)\n vertices ={}\n\n # //b, d, c, a\n words.reduce(:+).split('').uniq.each do |character|\n vertices[character] = Vertex.new(character)\n end\n\n (0...words.length-1).each do |i|\n word1, word2 = words[i], words[i+1]\n smaller = word1.length <= word2.length ? word1.length : word2.length\n\n (0...smaller).each do |j|\n if word1[j] != word2[j]\n Edge.new(vertices[word1[j]], vertices[word2[j]])\n break\n end\n end\n end\n\n topological_sort(vertices.values).map {|v| v.value}\n # [b, d, c, a]\nend", "def make_graph(args)\n # raise TypeError unless args[0].is_a? String\n # check command args\n if args.length == 1\n # check if file\n if File.file?(args[0])\n lines = IO.readlines(args[0])\n\n # tokens: ID, LETTER, NEIGHBORS\n lines.each do |line|\n parse_line_tokens(line)\n end\n else\n puts 'File not found!'\n nil\n end\n else\n puts 'Usage:'\n puts 'ruby word_finder.rb *name_of_file*'\n puts '*name_of_file* should be a file'\n nil\n end\n end", "def initialize(text)\n flag = false\n head = []\n @hits = []\n text.each do |line|\n if flag then\n @hits << Hit.new(line)\n else\n line = line.chomp\n if /\\A\\-+\\s*\\z/ =~ line\n flag = true\n else\n head << line\n end\n end\n end\n @columns = parse_header(head)\n end", "def load_distance_matrix graph, file\n File.open(file, 'r') do |f|\n f.each.reject do |line|\n line.empty? or line.start_with? '#'\n end.each.with_index do |line, i|\n costs = line.split\n costs = costs.collect &:to_i\n costs.each.with_index do |cost, j|\n unless graph.length > j\n graph.add_node\n end\n unless cost.zero? or cost == -1\n graph.add_edge i, j, cost\n end\n end\n end\n end\n return graph\nend", "def initialize(pairs)\n @nodes = {}\n @edges = {}\n \n IO.foreach(pairs) do |line|\n from, to = *(line.strip.split(/\\s+/).map { |x| x.to_i })\n @nodes[from] = true\n @nodes[to] = true\n @edges[edge_key(from,to)] = true\n @edges[edge_key(to, from)] = true\n end\n @nodes = @nodes.keys\n end", "def initialize\n network = {}\n tree = WordTree.new\n networkUndefined = true\n\n ARGF.each_line do |line|\n line.delete!(\"\\n\")\n\n if (line == \"END OF INPUT\")\n networkUndefined = false\n elsif (networkUndefined == true)\n network[line] = []\n else\n tree.insert(line)\n end\n end\n\n wordSearch = WordSearch.new(tree);\n\n network.each do |key, val|\n network[key] = wordSearch.search(key, DISTANCE).select do |result|\n result[:distance] == DISTANCE\n end\n end\n\n writeResults(network)\n end", "def build_node(node, text)\n\t\t#node.type = :BasicNode\n\n\t\twhitespace = text.partition(\".\").first\n\t\tpure_text = text.partition(\".\").last\n\t\tnode.depth = (whitespace.length)/3 #+2?\n\n\t\t#get the category string, use it to pull a category id\n\t\tif pure_text.include?(\",\") #split by the comma if there is one\n\t\t\tcategory_name = pure_text.partition(\",\").first\n\t\t\ttitle = pure_text.partition(\",\").last\n\t\telse #default to no category\n\t\t#\tcategory_name = pure_text.partition(\" \").first\n\t\t\ttitle = pure_text\n\t\t\tcategory_name = \"\"\n\t\tend\n\n\t\t#need to make these only the categories that belong to the user\n\t\tcategory = self.categories.find_by name: category_name.downcase\n\t\tif category == nil\n\t\t\tcategory = self.categories.create(name: category_name.downcase)\n\t\tend\n\t\tnode.category = category\n\t\ttitle = title.strip\t\n\t\t\n\t\tnode.title = title\n\t\tnode.work_id = self.id\n\t\treturn node\n\tend", "def numbered_pairs_to_adjacency_list(pairs, directed=false)\n nodes = entities(pairs).sort\n n = nodes[-1] + 1\n array = Array.new(n) { Array.new }\n pairs.each do |a, b| \n array[a] << b\n array[b] << a if !directed\n end\n return array\nend", "def numbered_pairs_to_adjacency_list(pairs, directed=false)\n nodes = entities(pairs).sort\n n = nodes[-1] + 1\n array = Array.new(n) { Array.new }\n pairs.each do |a, b| \n array[a] << b\n array[b] << a if !directed\n end\n return array\nend", "def numbered_pairs_to_adjacency_matrix(pairs, directed=false)\n nodes = entities(pairs).sort\n n = nodes[-1] + 1\n matrix = Array.new(n) { Array.new(n) { 0 } }\n pairs.each do |a, b| \n matrix[a][b] = 1\n matrix[b][a] = 1 if !directed\n end\n return matrix\nend", "def numbered_pairs_to_adjacency_matrix(pairs, directed=false)\n nodes = entities(pairs).sort\n n = nodes[-1] + 1\n matrix = Array.new(n) { Array.new(n) { 0 } }\n pairs.each do |a, b| \n matrix[a][b] = 1\n matrix[b][a] = 1 if !directed\n end\n return matrix\nend", "def readfile(file=\"SCC.txt\")\n\tg = Graph.new\n\tFile.open(file, \"r\") do |infile|\n\t\twhile (line = infile.gets)\n\t\t\tverts = line.split\n\t\t\tg.add_edge(verts[0], verts[1])\n\t\tend\n\tend\n\treturn g\nend", "def setup_network(word_ids, url_ids)\n # value lists\n @word_ids = word_ids\n @hidden_ids = get_all_hidden_ids(word_ids, url_ids)\n @url_ids = url_ids\n\n # node outputs\n @all_in = @word_ids.map { |w| 1.0 }\n @all_hidden = @hidden_ids.map { |h| 1.0 }\n @all_out = @url_ids.map { |u| 1.0 }\n\n # create weights matrices\n @weights_in = word_ids.map do |word_id|\n hidden_ids.map do |hidden_id|\n get_strength(word_id, hidden_id, 0)\n end\n end\n\n @weights_out = hidden_ids.map do |hidden_id|\n url_ids.map do |url_id|\n get_strength(hidden_id, url_id, 1)\n end\n end\n end", "def adj_let(str)\n index = 0\n adjArray = []\n while index < str.length do\n if str[index + 1] \n adjArray.push(\"#{str[index]}#{str[index+1]}\")\n end\n index += 1\n end\n p adjArray\nend", "def read_edges(start, finish)\n graphfile[num_vertices + 2..-1].each do |edge|\n vertex1name, vertex2name = edge.split[start], edge.split[finish]\n weight = edge.split[2].to_i\n\n vnum1 = vertex_num_for(vertex1name)\n vnum2 = vertex_num_for(vertex2name)\n\n # add vnum2 to front of vnum1's adjacency list\n adj_lists[vnum1].adj_list = Neighbor.new(vnum2, adj_lists[vnum1].adj_list, weight, vertex2name)\n if (graphtype == \"undirected\")\n # for undirected graph, add vnum1 to front of vnum2's adjacency list\n adj_lists[vnum2].adj_list = Neighbor.new(vnum1, adj_lists[vnum2].adj_list, weight, vertex1name)\n end\n end\n adj_lists\n end", "def parse_input(input)\n lines = input.lines.map(&:chomp)\n $n = lines.shift.to_i\n if $n <= 0\n abort \"ERROR: Wrong node number: #{$n}\"\n end\n number_of_lines = $n*($n-1)/2\n if $n*($n-1)/2 != lines.size\n abort \"ERROR: Wrong number of lines: #{lines.size} for #{$n} nodes, should be #{number_of_lines}\"\n end\n matrix = Array.new($n+1) { Array.new($n+1) { 0 } }\n matrix[0] = [0] + (0...$n).to_a\n\n for i in 0...$n\n matrix[i+1][0] = i\n end\n\n lines.each do |line|\n tmp = line.split(\" \").map{ |q| q.to_f }\n matrix[tmp[0]+1][tmp[1]+1] = tmp[2]\n matrix[tmp[1]+1][tmp[0]+1] = tmp[2]\n end\n matrix\nend", "def main\n args = get_input\n directed_graph = create_directed_graph(args.fetch(:raw_edge_list))\n display_adjacency_matrix(args.fetch(:num_nodes), directed_graph)\nend", "def get_adjacency_list\n max_index = find_max_index\n adjacency_list = [nil] * max_index\n @edges.each do |edg|\n from_value = edg.node_from.value\n to_value = edg.node_to.value\n if adjacency_list[from_value]\n adjacency_list[from_value] << [to_value, edg.value]\n else\n adjacency_list[from_value] = [[to_value, edg.value]]\n end\n end\n adjacency_list\n end", "def construct_adj_list(edges)\n map = Hash.new\n edges.each do |edge|\n from = edge[0]\n to = edge[1]\n if map[to].nil?\n map[to] = []\n end\n if map[from].nil?\n map[from] = []\n end\n map[from].push(to)\n end\n map\nend", "def build_from_data(data)\n data.each do |list_data|\n adjacent_list = AdjacentList.new\n list_data.reduce do |ele1, ele2|\n node2 = Node.new(ele2)\n\n if ele1.is_a?(Node)\n ele1.next_node = node2\n else\n node1 = Node.new(ele1, node2)\n adjacent_list.head_node = node1\n self.dict[node1.value] = self.adj_list_array.length\n end\n # return node2 to next reduce iteration\n node2\n end\n self.adj_list_array.push(adjacent_list)\n end\n end", "def initialize\n @n,@m = STDIN.readline.split.map{ |x| x.to_i }\n @nodes = Array.new(@n.to_i+1)\n for i in [email protected]_i\n @nodes[i] = Node.new(i)\n end\n for i in [email protected]_i\n source,dest = STDIN.readline.split.map{ |x| x.to_i }\n @nodes[source].add_child(@nodes[dest])\n end\n end", "def preprocess(text)\n text = text.downcase\n .gsub('.', ' .')\n words = text.split(' ')\n\n word_to_id = {}\n id_to_word = {}\n\n words.each do |word|\n unless word_to_id.include?(word)\n new_id = word_to_id.length\n word_to_id[word] = new_id\n id_to_word[new_id] = word\n end\n end\n\n corpus = Numo::NArray[*words.map { |w| word_to_id[w] }]\n\n [corpus, word_to_id, id_to_word]\nend", "def parse_node(node_text, weight)\n\t\t node_text.gsub(/[^[:alpha:]]/, \" \").downcase.split.each do |word|\n\t\t \tif !word.blank? && [email protected]_words_index.include?(word)\n\t @word_weight[word] += weight\n\t @word_frequency[word] += 1\n end\n\t\t end\n\t\tend", "def test_create_graph\r\n \tnode1 = Node.new(1, 'C', [2, 3])\r\n \tnode2 = Node.new(2, 'A', [3, 4, 6])\r\n \tnode3 = Node.new(3, 'K', [5])\r\n \tnode4 = Node.new(4, 'T', nil)\r\n \tnode5 = Node.new(5, 'E', nil)\r\n \tnode6 = Node.new(6, 'B', nil)\r\n \tsmall_graph = [node1, node2, node3, node4, node5, node6]\r\n \treader = GraphReader.new('small_graph.txt')\r\n \treader.create_graph()\r\n \treader.graph.shift\r\n \tassert_equal reader.graph.map(&:letter), small_graph.map(&:letter)\r\n end", "def to_adj\n full_jsivt= []\n @nodes.each do |id, node_data|\n name = node_data[@name_key]\n data = node_data[:data]\n adjacencies = node_data[@children_key]\n jsivt = {}\n jsivt[\"id\"] = id\n jsivt[\"name\"] = name || \"id: #{id}\" #if no name show id\n jsivt[\"data\"] = data\n jsivt[\"adjacencies\"] = adjacencies\n full_jsivt << jsivt\n end \n full_jsivt.to_json \n end", "def from_s(text)\r\n\t\t@root_vob = \"\"\r\n\t\t@branch = \"\"\r\n\t\t@tag = \"\"\r\n\t\t@checks = []\r\n\t\t@vobs_cfg = {}\r\n\r\n\t\ttext.lines.each do |line|\r\n\t\t\tnext if ! (line =~ /^\\s*element\\s+(.*)/)\r\n\t\t\te = $1.split(/\\s+/)\r\n\t\t\te[0] =~ /[\\/\\\\]([^\\/\\\\]+)[\\/\\\\]\\.\\.\\./\r\n\t\t\tvob = $1\r\n\t\t\ttag = e[1]\r\n\t\t\t\r\n\t\t\tnext if !vob || !tag\r\n\t\t\t@vobs_cfg[vob] = tag\r\n\t\tend\r\n\tend", "def problem_107\n if false\n net = [ \"-,16,12,21,-,-,-\", \"16,-,-,17,20,-,-\", \"12,-,-,28,-,31,-\",\n \"21,17,28,-,18,19,23\", \"-,20,-,18,-,-,11\", \"-,-,31,19,-,-,27\",\n \"-,-,-,23,11,27,-\" ]\n net.map! {|line| line.split(/,/).map {|i| i == '-' ? nil : i.to_i}}\n else\n net = []\n open(\"network.txt\").each do |line|\n net << line.chomp.split(/,/).map {|i| i == '-' ? nil : i.to_i}\n end\n end\n\n # Reformat into an array of nodes, with the their connections\n nodes = Hash.new {|h,k| h[k] = Hash.new }\n net.each_with_index do |row,i| # Each nodes is connected to...\n row.each_index do |col| # For each possible connection....\n # Add the node we are connected to and the cost\n nodes[i][col] = row[col] if row[col]\n end\n end\n\n initial = nodes.reduce(0) do |a,row|\n row[1].reduce(a) {|aa,p| aa + p[1] }\n end / 2\n # add to the 'borg' that is node0\n node0,node0_links = nodes.shift\n ans = []\n node0_contains = Hash.new\n node0_contains[node0] = true\n\n # What we do select the lowest link, the 'merge' it into node0, repeat\n while nodes.length > 0\n n,v = node0_links.min {|a,b| a[1] <=> b[1]}\n ans << [n,v] # Save the link for the answer\n node0_contains[n] = true # add to the 'borg' that is node0\n nodes[n].each_pair do |k,a| # Now merge in new poin, update vertexs\n next if node0_contains[k]\n node0_links[k] = [a, node0_links[k] || 1_000_000].min\n end\n nodes.delete(n) # Remove from free nodes\n node0_links.delete(n) # Remove from vertexes to resolve\n end\n\n now = ans.reduce(0) {|a,v| a + v[1]}\n puts \"initial = #{initial}\"\n puts \"now = #{now}\"\n initial - now\nend", "def readGraph\r\n\tputs \"Please, input the Graph as a comma-separated \" +\r\n\t\t\"sequence of Edges and press Enter\"\r\n\tgraphString = gets\r\n\tpathsString = graphString.split(\",\")\r\n\tgraph0 = Graph.new\r\n\tpathsString.each do |pathString|\r\n\t\tpathString = pathString.strip()\r\n\t\tonode = nil\r\n\t\tdnode = nil\r\n\t\tif graph0.containsNode?(pathString[0])\r\n\t\t\tonode = graph0.getNode(pathString[0])\r\n\t\telse\r\n\t\t\tonode = Node.new(pathString[0])\r\n\t\t\tgraph0.addNode(onode)\r\n\t\tend\r\n\t\tif graph0.containsNode?(pathString[1])\r\n\t\t\tdnode = graph0.getNode(pathString[1])\r\n\t\telse\r\n\t\t\tdnode = Node.new(pathString[1])\r\n\t\t\tgraph0.addNode(dnode)\r\n\t\tend\r\n\t\tweight = pathString[2, pathString.size].to_i()\r\n\t\tp0 = Path.new(onode, dnode, weight)\r\n\t\tonode.addPath(p0)\r\n\tend\r\n\treturn graph0\r\nend", "def adjacencymatrix(mode=:standard, diagonal=false)\n # prepare matrix\n ni = Hash.new\n @nodes.each_with_index { |n,i| ni[n]=i }\n matrix = Array.new(@nodes.length) { Array.new(@nodes.length, 0) }\n @links.each do |(s,d),l| \n i = ni[s]\n j = ni[d]\n if (i!=j) || diagonal\n case mode\n when :standard\n matrix[i][j] = 1 \n matrix[j][i] = 1 unless @directed\n when :linkcount\n matrix[i][j] += 1 \n matrix[j][i] += 1 unless @directed\n when :weight, :reciprocal, :inverted\n matrix[i][j] += l.weight \n matrix[j][i] += l.weight unless @directed\n end\n end\n end\n case mode\n when :reciprocal\n matrix.each do |row|\n row.each_with_index do |v,i|\n row[i] = 1.0/v unless v == 0\n end\n end\n when :inverted\n wmax1 = matrix.flatten.max + 1\n matrix.each do |row|\n row.each_with_index do |v,i|\n row[i] = wmax1 - v unless v == 0\n end\n end\n end\n matrix\n end", "def read_vertices\n (0..num_vertices - 1).map do |v|\n adj_lists[v] = Vertex.new(graphfile[v + 2], nil)\n end\n end", "def adj_vertices(vertex, a_lists)\n adj = []\n a_lists.each do |v|\n if v.name == vertex\n neighbor = v.adj_list\n while !neighbor.nil?\n adj << neighbor.name\n neighbor = neighbor.next\n end\n break\n end\n end\n adj\n end", "def matrix(text)\n row1, row2, row3 = rows_as_char_arrays(text)\n row1.zip(row2, row3)\n end", "def initialize(dag)\n vars = {}\n @net = Sbn::Net.new(title)\n \n vertices.each do |v|\n vars[v] = Sbn::Variable.new(@net, v.name.to_sym)\n end\n \n edges.each do |e|\n vars[e.source].add_child(vars[e.target])\n end\n end", "def add(text)\n\n\t\t# create a new node and set navigation pointers\n\t\t@old = @tree\n\t\t@tree = Node.new(text)\n\t\[email protected] = @old.next\n\t\tif @old.next != nil\n\t\t\[email protected] = @tree\n\t\tend\n\t\[email protected] = @old\n\t\[email protected] = @tree\n\n\t\t# Prune the tree, so it doesn't get too big.\n\t\t# Start by going back.\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.prev\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.next\n\t\t\tx.prev.delete\n\t\tend\n\t\t# now forward\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.next\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.prev\n\t\t\tx.next.delete\n\t\tend\n\tend", "def parse_line_tokens(line)\n return if line.nil? || line.empty? || !line.include?(';')\n\n tokens = line.split(';')\n id = tokens[0]\n letter = tokens[1]\n neighbors = tokens[2]\n\n # create mapping id to letter\n @nmap[id] = letter\n\n # if neighbors is empty, we reached a end node\n @ends << id if neighbors.strip.empty?\n\n # add neighbors if neighbors for that id exist\n @nnmap[id] = neighbors.strip.split(',')\n end", "def attributes text\n flow = @am.flow text.dup\n convert_flow flow\n end", "def read_file(filename, graph)\n File.foreach(filename) do |x|\n id, data, neighbors = vertex_creation(x)\n graph.add_vertex(id, data, neighbors)\n end\n graph\nend", "def adjacent_nodes(node, strings, table)\n path = node.path\n last_x = path[-1]\n choices = all_choices(strings.size).select {|t| !path.include?(t)}\n nodes = create_sorted_ary\n choices.each do |c|\n score = table[last_x][c]\n path = node.path+[c]\n cur_sentence = merge(node.sentence, strings[c])\n nodes << Node.new(path, score, cur_sentence)\n end\n nodes.first(1)\n end", "def to_dot_graph (params = {})\n params['name'] ||= self.class.name.gsub(/:/,'_')\n fontsize = params['fontsize'] ? params['fontsize'] : '8'\n graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params)\n edge_klass = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge\n vertices.each do |v|\n name = v.to_s\n params = {'name' => '\"'+name+'\"',\n 'fontsize' => fontsize,\n 'label' => name}\n v_label = v.to_s\n params.merge!(v_label) if v_label and v_label.kind_of? Hash\n graph << DOT::DOTNode.new(params)\n end\n edges.each do |e|\n params = {'from' => '\"'+ e.source.to_s + '\"',\n 'to' => '\"'+ e.target.to_s + '\"',\n 'fontsize' => fontsize }\n e_label = e.to_s\n params.merge!(e_label) if e_label and e_label.kind_of? Hash\n graph << edge_klass.new(params)\n end\n graph\n end", "def make_graph(all_dependencies)\n graph = RGL::DirectedAdjacencyGraph.new\n all_dependencies.each do |source, targets|\n if targets.empty?\n graph.add_vertex(source)\n else\n targets.each { |target| graph.add_edge(source, target) }\n end\n end\n graph\n end", "def get_adjacency_matrix\n max_index = find_max_index\n adjacency_matrix = [nil] * max_index\n adjacency_matrix.map! { [0] * max_index }\n @edges.each do |edg|\n from_index = edg.node_from.value\n to_index = edg.node_to.value\n adjacency_matrix[from_index][to_index] = edg.value\n end\n adjacency_matrix\n end", "def build_graph\n \n RDF::Graph.load(@options.file).each do |statement|\n subject = statement.subject\n predicate = statement.predicate\n object = statement.object\n \n edge(predicate,node(subject),node(object))\n end\n end", "def build_nodes_two(in_str)\n hash = Hash.new\n x,y = [0,0]\n dx, dy = [0,0]\n in_str.each do |str|\n dir = str[0]\n num = str[1..-1].to_i\n case dir \n when \"R\"\n r = (x + 1..(x + num))\n r.each do |i|\n dx += 1\n hash[[i,y]] = (dx + dy)\n x = i\n end \n when \"L\"\n r = ((x - num)...x)\n r.to_a.reverse.each do |i|\n dx += 1\n hash[[i,y]] = (dx + dy)\n x = i\n end \n when \"U\"\n r = (y + 1..y + num)\n r.each do |i|\n dy += 1\n hash[[x,i]] = (dx + dy)\n y = i\n end \n when \"D\"\n r = ((y - num)...y)\n r.to_a.reverse.each do |i|\n dy += 1\n hash[[x,i]] = (dx + dy)\n y = i\n end \n end \n end \n hash\nend", "def read_graph_file(file)\n File.foreach(file) do |line|\n this_line = line.split\n temp = Edge.new(this_line[0].to_i, this_line[1].to_i,\n this_line[2].to_i, this_line[3].to_i)\n @edge_array.push(temp)\n add(temp)\n end\n end", "def generate_adjacencies(board)\n b2 = duplicate(board)\n b2.each_with_index do |row, y_idx|\n row.each_with_index do |cell, x_idx|\n next unless cell == MINE\n increment_neighbors(b2, [x_idx, y_idx])\n end\n end\nend", "def train(category, text)\n hash = @categories[category.to_sym] ||= Hash.new(0)\n split(text).each{|word| hash[word] += 1 }\n end", "def huffman_codes(text)\n w = Hash.new(0)\n text.each_char { |c| w[c] += 1 }\n tree = w.each_pair.map { |letter, weight| [weight, letter] }\n tree = get_tree(tree)\n print_code(tree)\nend", "def gen_graph(connected: true, directed: false)\n graph = Graph.new(directed: directed)\n\n ('A'..'G').each { |char| graph.add_vertex(Vertex.new(id: char)) }\n\n all_possible_edges = graph.vertices().permutation(2)\n\n all_possible_edges.to_a.shuffle.each do |pair|\n\n break if graph.connected? and connected\n\n graph.add_edge(from: pair[0], to: pair[1])\n\n # adding both directions for undirected edge\n unless graph.directed?\n graph.add_edge(from: pair[1], to: pair[0])\n end\n\n\n # # Graph is guaranteed to be connected if out-degree of each vertext is at least 2\n # # To make graph less connected, introduce a probability for adding\n # # extra edges for vertices which already have an out-degree of 2\n # if graph.degree(pair[0]) < 2 or (graph.degree(pair[0]) >= 2 and rand() < 0.10)\n #\n # graph.add_edge(from: pair[0], to: pair[1])\n #\n # # adding both directions for undirected edge\n # unless graph.directed?\n # graph.add_edge(from: pair[1], to: pair[0])\n # end\n #\n # end\n end\n ap graph.adj_list\n\n graph\nend", "def in_use_graph\n graph = Graph.new\n\n index_to_vertex = build_index\n index_to_vertex.each do |(vrow, vcol), v|\n neighbours_in_use(vrow, vcol)\n .map { |index| index_to_vertex[index] }\n .each { |w| graph.add_edge(v, w) }\n end\n\n graph\n end", "def parse(text); end", "def analyse_string(text)\n current_words = Array.new(depth)\n text_array = split_text_to_array(text)\n until text_array.empty?\n next_word = text_array.shift\n add_words(current_words.dup, next_word)\n current_words.push next_word\n current_words.shift\n end\n end", "def initialize(g, params = {})\n\n require 'set'\n \n params = { :pbar => false, :file => '', :color => true, :circo => false }.merge(params)\n @pbar = params[:pbar]\n file = params[:file]\n color = params[:color]\n circo = params[:circo]\n\n if @pbar\n require 'facets/progressbar'\n @labeling_pbar = Console::ProgressBar.new(\"Labeled nodes\", g.num_vertices)\n end\n\n # initializza etichette e contatori\n @i = 0\n @m = 0\n @l = Hash.new\n @c = Hash.new\n @ude_counter = Hash.new\n @unlabeled_v = g.vertices.to_set\n\n if g.cyclic?\n # applica l'algoritmo generalizzato\n until @unlabeled_v.empty?\n\tlabel_and_counter(g)\n\tinf_label(g)\n\t@i += 1\n end\n else\n # applica l'algoritmo lineare\n succ = Hash.new\n g.vertices.each do |v|\n\tsuccessivi = Array.new\n\tg.adjacent_vertices(v).each do |sv| \n\t successivi << sv\n\tend # each\n\tsucc[v] = successivi\n end # each\n coda = Array.new\n g.vertices.each do |v| \n\tif g.adjacent_vertices(v) == []\n\t @l[v] = 0\n\t @labeling_pbar.inc if @pbar\n\t coda.push(v) \n\tend # if\n end # each\n while coda != [] do\n\tx = coda[0]\n\tcoda.delete(x)\n\tg.prev_vertices(x).each do |v|\n\t succ[v].delete(x)\n\t if succ[v] == []\n\t @l[v] = mes(v,g)\n\t coda.push(v)\n\t @labeling_pbar.inc if @pbar\n\t end # if\n\tend # each\n end # while\n end # if\n @labeling_pbar.finish if @pbar\n count_ude(g)\n\n write_to_graphic_file(g, fmt='png', dotfile=file, color, circo) if (file != '' and file.is_a?(String))\n end", "def add_relation source_label, relation, destination_label, direction = '<->'\n # More popular nodes have more weigth\n @node_weights[source_label] += 1\n @node_weights[destination_label] += 1\n\n @edge_buffer << Edge.new(\n source_label: source_label,\n relation: relation,\n destination_label: destination_label,\n direction: direction\n )\n end", "def identifyAddNps\r\n pd = ParseData.new\r\n @sentences.each do |sentence|\r\n strSent = sentence.strRep\r\n \r\n sentNps = @parseAdapter.parse strSent\r\n \r\n #in the future, do a little better on matching\r\n foundNps = pd.onlyNP sentNps\r\n \r\n foundNps.sort_by{|word| word.length}.each do |foundNp|\r\n #puts \"#{foundNp}\"\r\n\r\n sentence.npAdd foundNp, newId\r\n end\r\n end\r\n\r\n #add the position on here...\r\n pos = 1\r\n @sentences.each do |sentence|\r\n sentence.npModels.each do |npModel|\r\n npModel.position = pos\r\n pos = pos + 1\r\n end\r\n end\r\n end", "def initialize(text)\n\n tagger_model = \"pt-pos-perceptron.bin\"\n if tagger_model == \"pt-pos-maxent.bin\"\n @article_tags = ['ART']\n @verb_tags = ['V']\n @auxiliary_verb_tags = ['VAUX']\n @participle_tags = ['PCP']\n @noun_tags = ['N', 'NPROP']\n @adjective_tags = ['ADJ']\n @adverb_tags = ['ADV', 'ADV-KS' 'ADV-KS-REL']\n @pronoun_tags = ['PROPESS', 'PROSUB', 'PROADJ', 'PRO-KS', 'PRO-KS-REL', ]\n @numeral_tags = ['NUM']\n @conjunction_tags = ['KS', 'KC']\n @preposition_tags = ['PREP', 'PREP+PROPESS', 'PREP+ART']\n @interjection_tags = ['IN']\n @denotative_word_tags = ['PDEN']\n @content_word_tags = @verb_tags + @noun_tags + @adjective_tags + @adverb_tags\n @function_word_tags = @article_tags + @preposition_tags + @pronoun_tags + @conjunction_tags + @interjection_tags\n\n @functions_as_noun_tags = ['N', 'NPROP', 'PROSUB']\n @functions_as_adjective_tags = ['ADJ', 'PROADJ']\n @punctuation_tags = ['PU']\n else\n @article_tags = ['art']\n @finito_tags = ['v-fin']\n @infinitive_tags = ['v-inf']\n @participle_tags = ['v-pcp']\n @gerundio_tags = ['v-ger']\n @noun_tags = ['n', 'prop']\n @adjective_tags = ['adj', 'n-adj']\n @adverb_tags = ['adv']\n @pronoun_tags = ['pron-pers', 'pron-indp']\n @denotative_word_tags = ['pron-det']\n @numeral_tags = ['num']\n @preposition_tags = ['prp']\n @conjunction_tags = ['conj-s', 'conj-c']\n @interjection_tags = ['intj']\n @punctuation_tags = ['punc']\n @functions_as_noun_tags = ['n', 'nprop']\n @functions_as_adjective_tags = ['adj', 'n-adj']\n @verb_tags = @finito_tags + @infinitive_tags + @participle_tags + @gerundio_tags\n @content_word_tags = @verb_tags + @noun_tags + @adjective_tags + @adverb_tags\n @function_word_tags = @article_tags + @preposition_tags + @pronoun_tags + @conjunction_tags + @interjection_tags\n end\n\n @tagger = OpenNLP::POSTaggerME.new(tagger_model)\n @tokenizer = OpenNLP::TokenizerME.new(\"pt-token.bin\")\n\n @tokens = @tokenizer.tokenize(text.gsub(/(\\p{Punct})/,\" \\\\1 \"))\n @part_of_speech = @tagger.tag(@tokens).to_a\n end", "def load_data(filename)\n if File.exist? filename\n File.foreach (filename) do |line|\n line = line.chomp.split(\" \").map(&:to_i)\n if line.length == 1\n @num_vertices = line[0]\n next\n else\n @edges << [line[2], line[0], line[1]]\n if !@groups[line[0]]\n @groups[line[0]] = [line[0]]\n @leader_pointers[line[0]] = line[0]\n end\n if !@groups[line[1]]\n @groups[line[1]] = [line[1]]\n @leader_pointers[line[1]] = line[1]\n end \n end\n end\n end\n # sort edges costs\n @edges.sort! { |a, b| a[0] <=> b[0] }\n end", "def initialize(text)\n @hits = []\n @all_hits = []\n overrun = ''\n text.each(\"\\n\\nseq1 = \") do |str|\n str = str.sub(/\\A\\s+/, '')\n str.sub!(/\\n(^seq1 \\= .*)/m, \"\\n\") # remove trailing hits for sure\n tmp = $1.to_s\n hit = Hit.new(overrun + str)\n overrun = tmp\n unless hit.instance_eval { @data.empty? } then\n @hits << hit\n end\n @all_hits << hit\n end\n @seq1 = @all_hits[0].seq1\n end", "def create_graph\n all_coordinates = get_all_coordinates\n all_coordinates.each do |key|\n neighbors = get_neighbor_arr(key)\n add_vertex(key,neighbors)\n end\n @vertices\n end", "def add_directed_edge(id1,id2)\n @g[id1] ||= Array.new\n @g[id1] << id2\n end", "def get_graph\n @graph = Graph.new\n @tparses.each do |p|\n if p[:args]\n p[:args].each do |type, arg|\n @graph.add_edge(p[:idx], arg, 1) if arg >= 0\n end\n end\n end\n\n g = GraphViz.new(:G, :type => :digraph)\n g.node[:shape] = \"box\"\n g.node[:fontsize] = 11\n g.edge[:fontsize] = 9\n\n n = []\n @tparses.each do |p|\n n[p[:idx]] = g.add_nodes(p[:idx].to_s, :label => \"#{p[:word]}/#{p[:pos]}/#{p[:cat]}\")\n end\n\n @tparses.each do |p|\n if p[:args]\n p[:args].each do |type, arg|\n if arg >= 0 then g.add_edges(n[p[:idx]], n[arg], :label => type) end\n end\n end\n end\n\n g.get_node(@root.to_s).set {|_n| _n.color = \"blue\"} if @root >= 0\n g.get_node(@focus.to_s).set {|_n| _n.color = \"red\"} if @focus >= 0\n\n @graph_rendering = g.output(:svg => String)\n end", "def analyze_text(text)\n hash = Hash.new(Array.new)\n text_array = text.split(/\\s/)\n text_array.each_with_index do |word, i|\n break if i == (text_array.length - 1)\n hash[word] += [text_array[i + 1]]\n end\n hash\n end", "def add_edges(edges)\n edges.each do |edge|\n if [email protected]?(edge)\n @edges << edge\n\n edge.from.neighbours.push(edge.to) if !edge.from.neighbours.include? edge.to\n edge.to.neighbours.push(edge.from) if !edge.to.neighbours.include? edge.from\n\n @vertices << edge.from if !vertex_exist?(edge.from)\n @vertices << edge.to if !vertex_exist?(edge.to)\n end\n end\n\n build_adjacency_matrix.to_a\n end", "def to_directed_graph(adapters)\n node_paths = {}\n adapters.each do |node|\n node_paths[node] = adapters.select{|other_node| other_node.between?(node+1, node+3)}\n end\n node_paths\nend", "def t\n adj_t = Array.new(vertices.length) { [] }\n adj.each_with_index do |adj_j, j|\n adj_j.each do |v|\n adj_t[vertices.index(v)] << vertices[j]\n end\n end\n dup.tap { |g| g.adj = adj_t }\n end", "def debruijn_graph(k, text)\n <<-DOC\n In general, given a genome Text, PathGraphk(Text) is the path consisting of |Text| - k + 1 edges, \n where the i-th edge of this path is labeled by the i-th k-mer in Text and the i-th node of the path \n is labeled by the i-th (k - 1)-mer in Text. \n The de Bruijn graph DeBruijnk(Text) is formed by gluing identically labeled nodes in PathGraphk(Text).\n\n De Bruijn Graph from a String Problem: Construct the de Bruijn graph of a string.\n Input: An integer k and a string Text.\n Output: DeBruijnk(Text). \n DOC\n kmers_a = kmers(text, k-1)\n\n graph = {}\n (0..(kmers_a.length-1-1)).each do |i|\n kmer = kmers_a[i]\n graph[kmer] = [] unless graph.has_key?(kmer)\n graph[kmer] << kmers_a[i+1] \n end\n # puts graph\n return graph\n end", "def populate_adjacency_list_via_array(array)\n @vertices = array.flatten.uniq.map { |v| Vertex.new('WHITE', 1, nil, [], v) }\n # Only directed edges are being added to the edges list\n @edges = array.map { |edge| Edge.new(find(edge[0]), find(edge[1])) }\n populate_adjacency_list\n end", "def make_catgraph()\n File.open(@catgraph_file, \"w\") do |catgraphf|\n i = 0\n @articles_map.keys.each do |title|\n print \"Count = #{i}\\n\"\n if title =~ /Category:/\n cats = extract_categories(title)\n cats_str = \"\"\n cats.each { |c| cats_str += \" #{c}\" }\n catgraphf.puts(\"#{@articles_map[title]}: #{cats_str}\")\n end\n i=i+1\n end\n end\n end", "def load_graph()\n nodes = {}\n vertices = {}\n visualVertices = {}\n edges = []\n visualEdges = []\n bounds = {}\n\n File.open(@filename, 'r') do |file|\n doc = Nokogiri::XML::Document.parse(file)\n\n doc.root.xpath('bounds').each do |bound|\n bounds[:minlon] = bound['minlon']\n bounds[:minlat] = bound['minlat']\n bounds[:maxlon] = bound['maxlon']\n bounds[:maxlat] = bound['maxlat']\n end\n\n doc.root.xpath('node').each do |node|\n nodes[node['id']] = node\n end\n\n doc.root.xpath('way').each do |way_element|\n speed = 50\n oneway = false\n continue = false\n\n way_element.xpath('tag').each do |tag_element|\n speed = tag_element['v'] if tag_element['k'] == 'maxspeed'\n oneway = true if tag_element['k'] == 'oneway'\n continue = true if tag_element['k'] == 'highway' && @highway_attributes.include?(tag_element[\"v\"])\n end\n\n if continue\n (way_element.xpath('nd').count - 1).times do |i|\n from_nd_id = way_element.xpath('nd')[i]\n to_nd_id = from_nd_id.next_element['ref']\n\n from_node = nodes[from_nd_id['ref']]\n to_node = nodes[to_nd_id]\n\n # Create vertex, add into hash\n vertex = Vertex.new(to_nd_id)\n vertex2 = Vertex.new(from_nd_id['ref'])\n vertices[to_nd_id] = vertex unless vertices.has_key?(to_nd_id)\n vertices[from_nd_id['ref']] = vertex2 unless vertices.has_key?(from_nd_id['ref'])\n\n # Create visual vertex\n visual_vertex2 = VisualVertex.new(to_nd_id, to_node, to_node['lat'], to_node['lon'], to_node['lat'], to_node['lon'])\n visual_vertex = VisualVertex.new(from_node['id'], from_node, from_node['lat'], from_node['lon'], from_node['lat'], from_node['lon'])\n visualVertices[from_node['id']] = visual_vertex unless visualVertices.has_key?(from_node['id'])\n visualVertices[to_node['id']] = visual_vertex2 unless visualVertices.has_key?(to_node['id'])\n\n # Create edge\n edge = Edge.new(vertex, vertex2, speed, oneway)\n edges << edge\n edge.distance = calculate_distance([from_node['lat'].to_f, from_node['lon'].to_f], [to_node['lat'].to_f, to_node['lon'].to_f])\n\n # Create visual edge\n visualEdge = VisualEdge.new(edge, visual_vertex, visual_vertex2)\n visualEdges << visualEdge\n end\n end\n end\n end\n\n # Create graph, visual graph\n graph = Graph.new(vertices, edges)\n visualGraph = VisualGraph.new(graph, visualVertices, visualEdges, bounds)\n\n # Find largest component\n largest_comp = find_component(graph)\n\n # Filter vertices and edges from largest component and create graphs from largest component\n filtered_edges = graph.edges.reject { |edge| !largest_comp.include?(edge.v1.id) || !largest_comp.include?(edge.v2.id)}\n filtered_vertices = graph.vertices.reject { |vertex| !largest_comp.include?(vertex)}\n filter_visual_edges = visualGraph.visual_edges.reject { |vis_edge| !largest_comp.include?(vis_edge.v1.id) || !largest_comp.include?(vis_edge.v2.id)}\n filter_visual_vertices = visualGraph.visual_vertices.reject { |vis_vertex| !largest_comp.include?(vis_vertex)}\n\n graph = Graph.new(filtered_edges,filtered_vertices)\n visualGraph = VisualGraph.new(graph, filter_visual_vertices, filter_visual_edges, bounds)\n\n return graph, visualGraph\n end", "def initialize(file)\n @nodes = Hash.new\n\n File.open(file) do |file|\n file.each_with_index do |line, index|\n line_dirty = line.split(' ').map { |n| n.to_i }\n if index == 0\n @num_nodes, @num_edges = line_dirty\n else\n # Destructure the array to grab the nodes and edge cost\n *nodes, edge_cost = line_dirty\n # Pick a random node as start\n @initial_node ||= nodes[0]\n # Inserts the nodes into the hash table with the edge cost\n insert(nodes, edge_cost)\n end\n end\n end\n end", "def mass_tikify(text, destination)\n sentences = text.lines\n i = 0\n sentences.each do |s|\n log (\"Importing: sentence #{i}\") if (i % 1000) == 0\n begin\n# @env.transaction do |trans|\n tokens = NLP.tokenize(s).reject do |t|\n # Don't include usernames/urls as tokens\n (t[0]==('@')) \\\n || (t.include?('://')) \\\n || t.length > 30\n end\n tokstr = tokens.map { |t| tikify(t) }\n destination.add(tokstr)\n# end\n rescue LMDB::Error::MAP_FULL\n destination.expand()\n retry\n end\n i += 1\n end\n destination\n end", "def link( index )\n\t\tLink.new( \n\t\t\tself.words[ self.link_lword(index) ],\n\t\t\tself.words[ self.link_rword(index) ],\n\t\t\tself.link_length(index),\n\t\t\tself.link_label(index),\n\t\t\tself.link_llabel(index),\n\t\t\tself.link_rlabel(index),\n\t\t\tLinkTypes[ self.link_label(index).gsub(/[^A-Z]+/, '').to_sym ]\n\t\t)\n\tend", "def rereverse_graph\n @a_matrix = ca_matrix\n read_vertices\n read_edges(0, 1)\n adj_lists\n end", "def initialize_graph!(rules)\n rules.each do |rule|\n bag, linked_bags = rule\n\n node = find_or_create_node(bag.color)\n\n edges = linked_bags.map do |linked_bag|\n linked_node = find_or_create_node(linked_bag.color)\n\n Edge.new(linked_bag.num, linked_node)\n end\n\n node.edges += edges\n\n @nodes_by_color[bag.color] = node\n end\n end", "def create_adjacency_matrix(raw_state_transition_list)\r\n\r\n\t\tadj_matrix=Hash.new\r\n\r\n\t\t# Compare raw list with Uniq'ed version\r\n\t\t# if shorter then there were duplicates in CSV file\r\n\t\tstate_transition_list = raw_state_transition_list.uniq\r\n\t\tif (state_transition_list.length < raw_state_transition_list.length)\r\n\t\t\tputs_debug(\"Probable duplicate entries in CSV file.\")\r\n\t\tend # end if\r\n\r\n\t\t# Use list of states to create key entries for hash table of states and actions\r\n\t\tself.states_store= extract_states_list(state_transition_list) \r\n\t\t\r\n\t\tself.states_store.each do |a_state|\r\n\t\t\tadj_matrix[a_state] = Array.new\r\n\t\tend # end each state\r\n\t\t\r\n\t\t# Add each state pair and action to the hash of states and actions\r\n\t\tstate_transition_list.each do |a_transition|\r\n\t\t\tadj_matrix[a_transition.start_state].push a_transition\r\n\t\tend # end state table\r\n\r\n\t\treturn adj_matrix\r\n\tend", "def initialize(object)\n @object = object\n @adjacents = []\n end", "def add_node(object, citations: true, identifiers: true)\n @nodes.push graph_node(object)\n\n if citations && object.respond_to?(:citations)\n object.citations.each do |c|\n add_node(c, citations: false, identifiers: false)\n add_node(c.source, citations: false, identifiers: true)\n\n add_edge(c, object)\n add_edge(c.source, c)\n\n if c.source.is_bibtex?\n c.source.authors.each do |p|\n add_node(p, citations: false, identifiers: true)\n add_edge(p, c.source)\n end\n end\n end\n end\n\n if identifiers && object.respond_to?(:identifiers)\n object.identifiers.each do |i|\n add_node(i, citations: false, identifiers: false)\n add_edge(i, object)\n end\n end\n end", "def initialize(params={})\n @network = params.fetch(:network,0)\n @members = params.fetch(:members,'NA')\n @kegg_path = annotate_kegg(ids=@members) #get KEGG pathways annotation of all the members in a network\n @go_terms = annotate_GO(ids=@members) #get GO biological processes annotation of all the members in a network\n @@num += 1 #every time a network object is initialized count it\n @@all_interactions << self #add all the objects to this list\n end", "def parse_text(text)\n current_key = ''\n config = {}\n\n text.gsub!(\"\\r\", \"\\n\")\n text = text.force_encoding('UTF-8')\n text.gsub!(\"\\xEF\\xBB\\xBF\".force_encoding('UTF-8'), '')\n\n text.each_line do |line|\n line.lstrip!\n line.rstrip!\n line.gsub!(/#.*/, '')\n\n next unless line.length.nonzero? && line =~ /[^\\s]/\n\n if line =~ /User-agent:\\s+(.+)/i\n previous_key = current_key\n current_key = $1.downcase\n config[current_key] = [] unless config[current_key]\n\n # If we've seen a new user-agent directive and the previous one\n # is empty then we have a cascading user-agent string. Copy the\n # new user agent array ref so both user agents are identical.\n\n if config.key?(previous_key) && config[previous_key].size.zero?\n config[previous_key] = config[current_key]\n end\n\n else\n config[current_key] << line\n end\n end\n\n config\n end" ]
[ "0.65148467", "0.60605776", "0.60012543", "0.59061736", "0.5707614", "0.5691291", "0.5586348", "0.55596614", "0.5475822", "0.54417366", "0.5420953", "0.5388463", "0.52574134", "0.52276725", "0.52225196", "0.5193617", "0.51821226", "0.51821226", "0.5180534", "0.51776534", "0.5145101", "0.51290214", "0.51281214", "0.51232165", "0.50814146", "0.5052567", "0.49934947", "0.4992688", "0.49836212", "0.49816814", "0.49622962", "0.49622962", "0.4959884", "0.4959884", "0.49429515", "0.49175552", "0.4891139", "0.488969", "0.48753554", "0.48510298", "0.48463598", "0.48462504", "0.4846113", "0.4835031", "0.4833415", "0.48103866", "0.4808348", "0.48078713", "0.47975498", "0.4784312", "0.47751057", "0.4768761", "0.4751215", "0.47476688", "0.47454175", "0.46971345", "0.4674437", "0.467369", "0.46651834", "0.46602017", "0.46534613", "0.464962", "0.4649559", "0.46455947", "0.4640876", "0.46223605", "0.45937672", "0.4590795", "0.4566698", "0.4566615", "0.45653215", "0.4554462", "0.45508626", "0.4544367", "0.45268402", "0.45129842", "0.4510728", "0.45073783", "0.4487905", "0.44826043", "0.4476862", "0.44691646", "0.44633532", "0.4461901", "0.44605687", "0.44602036", "0.4458233", "0.44540596", "0.4443461", "0.44274282", "0.44246164", "0.44198516", "0.4416893", "0.4416237", "0.44099063", "0.4408308", "0.44031394", "0.4397564", "0.4383638", "0.4365231", "0.4364867" ]
0.0
-1
Find a word by its id or its word coverage
def find_node(options) options[:id] = options.delete(:stem) if options[:stem] unless options[:word] || options[:id] raise ArgumentError, 'no find option specified' end if options[:word] word = options[:word].mb_chars.downcase.to_s nodes.find do |n| n.words.include?(word) end else id = options[:id].mb_chars.downcase.to_s nodes.find do |n| n.id == id end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(word)\n findBy :word_text, word\n end", "def find_by_word(word)\n @wordlist[word] if word_exists?(word)\n end", "def search(word)\n \n end", "def get_word_id\n word = @text.downcase.singularize\n @word_id = EnglishWords.find_by(english_meaning: word)\n return @word_id\n end", "def search_for_word(search_word)\n index_of_search_word = words.find_index { |obj| obj.word == search_word }\n words[index_of_search_word]\n end", "def getID(word)\n return Keyword.where(name: word).first.id\n end", "def find_word(word)\n\t\tfc = word[0,1].downcase\n\t\t# check if it's a vowel\n\t\tif fc =~ /[aeiou]/\n\t\t\t# if so, then check in each bucket\n\t\t\t\"aeiou\".split(//).map do |letter|\n\t\t\t\tfind_matches(@dictionary[letter], word)\n\t\t\tend.flatten\n\t\telse\n\t\t\t# else we do the search directly\n\t\t\tfind_matches(@dictionary[fc], word)\n\t\tend\n\tend", "def find_word(lexical_item)\n \n end", "def word\n Word.find_by(text: params[:text])\n end", "def find_word( word )\n word_str = word.to_s\n found_word = nil\n if @words_set.include? word_str\n found_word = word_str\n elsif @words_set.include? word_str.capitalize\n found_word = word_str.capitalize\n elsif @words_set.include? word_str.downcase\n found_word = word_str.downcase\n end\n found_word\n end", "def find_word(word)\n chars = word.chars\n current = @root\n\n word_found =\n chars.all? { |c| current = current.children.find { |n| n.value == c } }\n yield word_found, current if block_given?\n\n current\n end", "def lookup(word)\r\n @word.each do |h|\r\n if h[:Word] == word.to_s\r\n return h[:Definition]\r\n end\r\n end\r\n end", "def lookup(word)\n word.gsub!(/\\s/, \"+\")\n meaning_file = initialize_files(word)[0]\n f = File.open(meaning_file)\n begin\n extract_text(f)\n rescue Exception\n raise\n end\n\n end", "def define_word_CEDICT(word)\n @cedict = 'cedict.txt'\n @word_matches = File.readlines(@cedict).grep(/#{word}/)\n\n @best_match = []\n\n @word_matches.each do |x|\n # CEDICT lists simplified and traditional characters, space delimited\n # 学 = \"學 学 [xue2] /to learn/to study/science/-ology/\"\n @match = x.split\n\n if @match[0] == word || @match[1] == word\n @best_match << x\n end\n end\n\n return @best_match\n end", "def get_matches(word)\n cur = self\n word.each_char do |character|\n modified_char = @@vowels.include?(character) ? '*' : character\n return Set.new if not cur.kids.has_key? modified_char\n cur = cur.kids[modified_char]\n end\n cur.words_here\n end", "def index_for(word)\n poem_words.find_index { |this_word| word == this_word }\nend", "def get_words(text) #no!, two methods named get_words, see word_search.rb\n \twords = text.split('')\n \twords.each do |word|\n \t\t#how to check if word is correct or not?\n \t\tWord.new(name: word, ngsl: false, list: self.id )\n \t\t# example = Wordnik.word.get_top_example(word)['text']\n \tend\n end", "def find_word_in_project(project_id, keyword_id, optional = false)\n keyword = PreferedSynonym.where(\"project_id = ? AND keyword_id = ?\", project_id, keyword_id).first\n if keyword != nil\n if !optional\n return true\n else\n return true, Keyword.find_by_id(keyword.keyword_id)\n end \n else\n if !optional\n return false\n else\n return false, nil\n end\n end \n end", "def find_words words\n\t\t\t\twords.empty? ? [] : App.rdf_collection.find({\n\t\t\t\t\t:\"$or\" => words.map {|i| {:o => i}},\n\t\t\t\t\t:p => RDF::RDFS.label.to_s}).map do |data|\n\t\t\t\t\tRDF::Statement.from_mongo(data)\n\t\t\t\tend\n\t\t\tend", "def define_word_EDICT(word)\n @edict = 'edict2utf8'\n @word_matches = File.readlines(@edict).grep(/#{word}/)\n\n @best_match = []\n \n @word_matches.each do |x|\n @match = x.split(/[ ()\\[\\];]/)\n \n if @match[0] == word || @match[1] == word || @match[2] == word || @match[3] == word\n @best_match << x\n end\n end\n \n return @best_match\n end", "def search(word)\n search_prefix(root, word, 0)\n end", "def check(word)\n\t\tresult = find_word(word)\n\t\treturn \"NO SUGGESTION\" if result.empty?\n\t\t# if the word is in the results, just return it\n\t\treturn word if result.include? word\n\t\tmatches = result.grep(/^#{word}$/i)\n\t\t# if the word is there with swapped caps, return that\n\t\treturn matches.first if matches.size > 0\n\t\t# else return the first one\n\t\t# FIXME: simple selection of a \"good\" match. must improve it!\n\t\tresult.first\n\tend", "def index_for(word)\n words = %w{There was a farmer had a dog and Bingo was his name}\n\n words.find_index {|this_word| word == this_word}\nend", "def search(word)\r\n \r\n end", "def query(word)\n @cosines.include?(word)\n end", "def find_text(id)\n @bibliography[id]\n end", "def search(word)\n result = find(word)\n !!(result && result.isend)\n end", "def search(word)\n Parser.new(query(word)).parse\n end", "def find_word(word, node = @root)\n if word == \"\" && node.end_of_word\n return node\n else\n child = node.find_child(word[0])\n child ? find_word(word[1..-1], child) : nil\n end\n end", "def find_by_word(word, root, root_namespace, options = nil)\n xquery = <<-GENERATED\n import module namespace search = \"http://marklogic.com/appservices/search\" at \"/MarkLogic/appservices/search/search.xqy\";\n search:search(\"#{word}\",\n GENERATED\n search_options = setup_options(options, root, root_namespace)\n xquery << search_options.to_s\n xquery << ')'\n end", "def find_glossary_term!\n @glossary_term = find_or_goto_index(GlossaryTerm,\n params[:id].to_s)\n end", "def index_for(word)\n words.find_index { |this_word| word == this_word }\n end", "def search(word)\n last = word.each_char.inject(@root) do |curr, char|\n curr.is_a?(TrieNode) ? curr[char] : nil\n end \n last && last[:_] || false \n end", "def in_a_word\n WORDS[self]\n end", "def findWord(word, filename)\n regex = Regexp.new(word)\n File.foreach(filename).with_index { |line, line_num|\n p \"#{line_num}: #{line}\" if regex =~ line\n }\nend", "def lookup_word(word)\n h = self.lookup_entry(word)\n [ h[:pronounce], h[:meaning] ]\n end", "def search(word)\n w = word.chars\n w.push('end')\n search_arr(w)\n end", "def find(t)\n text = t\n text.downcase! unless @case_sensitive\n text.gsub!(/\\s+/,' ') # Get rid of multiple spaces.\n @state = 0\n index = 0\n text.each_char do |char|\n # Incrementing now so that I can announce index - @length.\n index += 1\n @state = step(@state,char)\n if @state == @length # Yay, we've got ourselves a match!\n puts \"Match found for #{@word[1,@length]} at #{index - @length}\"\n @state = 0\n end\n end\n end", "def search(word)\n pnt = @r\n word.chars.each do |x|\n return false if !pnt[x]\n pnt = pnt[x]\n end\n return true if pnt['end']\n return false\n end", "def exact_match(user_word)\n @loader.arr.each do |word|\n return word if word == user_word\n end\n end", "def get_definitions\n Dictionary.find_by_word(word_id)\n end", "def find_word\n if @text.match(/\\=\\=#{@language}\\=\\=/i)\n # Easen regexp to avoid end page match\n @text << \"\\n----\"\n\n language_segment = @text.match(/\\=\\=#{@language}\\=\\=([\\S\\s]+?)(?=(?:\\n----)|(?:\\n\\=\\=\\w+\\=\\=))/i)[1]\n\n lemma = find_lemma_word(language_segment)\n\n if lemma\n store_word(lemma)\n else\n store_word(@title)\n end\n end\n end", "def search(word)\n node=@root\n i=0\n while i <word.length \n char=word[i]\n order=char.ord-97\n return false if node[order].nil?\n node=node[order]\n i+=1\n end\n return node[\"value\"] \n end", "def search_word\n @words =\n if login?\n current_user.words.search params[:term]\n else\n Word.search params[:term]\n end\n end", "def include?(word)\n find_word(word) { |found, current| return found && current.is_word }\n end", "def search(word)\n results = []\n @books.each {|item| results << item if item[0].downcase.include?(word) }\n results.empty? ? (puts \"Search returned no results...\") : (results.each {|item| puts \"#{item[0]} (#{item[1]})\"})\n end", "def search_builder(file_added, word)\n\t\t file_data = File.read(file_added)\n\t\t file_2data = File.read(file_added).split(\"\\n\")\n\t\t\tper = \"#{word}: can not find\"\n\n\t\t\tif file_data.downcase.include?(word.downcase)\n\n\t\t\t\tfor j in 0..file_2data.length-1\n\t\t\t\t if file_2data[j].downcase.include?(word.downcase)\n\t\t\t\t\t\tper = file_2data[j].downcase\n\n\t\t\t\t\t\tif per.include?(\":\")\n\t\t\t\t\t\t per = per.capitalize\n\n\t\t\t\t\t\telsif per.downcase.include?(\"#{word.downcase}\")\n\t\t\t\t\t\t per = \"#{word}: found\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn per\n\t\tend", "def find(word, node = @root)\n new_node = nil\n word.each_char do |char|\n new_node = node.find_child_node(char)\n if new_node == nil\n return nil\n end\n node = new_node\n end\n node\n end", "def found_match(str)\n\tif dictionary.include?(str) # returns true if found in the dictionary\n\t\treturn str # don't stop the recursion, but return the word ?\n\tend\n\tfalse\nend", "def find_by_term(str)\n idx = @children.map(&:term).index(str)\n return nil if idx.nil?\n @children[idx]\n end", "def text_search(target_string)\n\t\t# NOTE: always search all entities, not just the ones that are on screen\n\t\t# (not sure how you should let the user know that there are entities that have been found, but which are not currently on the screen)\n\t\ttext_objects = @space.entities.select{|x| x.is_a? ThoughtTrace::Text }\n\t\t\n\t\thighlight_mapping = \n\t\t\ttext_objects.map do |text|\n\t\t\t\ti = text.string.index target_string\n\t\t\t\t\n\t\t\t\t[text, i, i+target_string.size] if i\n\t\t\tend\n\t\thighlight_mapping.compact!\n\t\t\n\t\t\n\t\t\n\t\t# highlight the portions of the string the match the search query\n\t\tcolor = Gosu::Color.argb(0x99FF0000)\n\t\t\n\t\thighlight_mapping.each do |text, start_i, end_i|\n\t\t\t# NOTE: width_of_first may break for i=1, because it handles conversion weird. need to totally overhaul that\n\t\t\tax = text.width_of_first(start_i)\n\t\t\tbx = text.width_of_first(end_i)\n\t\t\t\n\t\t\theight = text[:physics].shape.height\n\t\t\toffset = height / 2\n\t\t\t\n\t\t\tp = text[:physics].body.p\n\t\t\ta = CP::Vec2.new(ax, offset) + p\n\t\t\tb = CP::Vec2.new(bx, offset) + p\n\t\t\t\n\t\t\tThoughtTrace::Drawing.draw_line(\n\t\t\t\t$window, a,b, \n\t\t\t\tcolor:color, thickness:height, line_offset:0.5, z_index:0\n\t\t\t)\n\t\tend\n\tend", "def find_words words\n # We will work with \"DictWord\" objects rather than with raw strings\n @words = words.map{|w| DictWord.new(w)}\n # It tries to find every single word (as long as it's possible because of size of grid) in the grid \n # If running on a UNIX system, we could use fork to improve the performance\n # Process.fork {\n @words.each{|dw| place dw if (dw.word != nil && dw.word.size <= @w )}\n # }\n # We return only the words that were found in the grid \n return @words.select{|w|w.place != nil} \n end", "def find word\n result = {}\n @d.each_pair do|key, value|\n if key =~ /^#{word}/\n result[key] = value\n end\n end\n result\n end", "def find_words(words)\n search_results = SearchResults.new\n \n general = Vector.new\n must_match = Vector.new\n must_not_match = Vector.new\n not_found = false\n \n extract_words_for_searcher(words.join(' ')) do |word|\n case word[0]\n when ?+\n word = word[1,99]\n vector = must_match\n when ?-\n \t word = word[1,99]\n vector = must_not_match\n else\n \t vector = general\n end\n \n index = @dict.find(word.downcase)\n if index\n vector.add_word_index(index)\n else\n not_found = true\n \t search_results.add_warning \"'#{word}' does not occur in the documents\"\n end\n end\n \n if (general.num_bits + must_match.num_bits).zero? \n search_results.add_warning \"No valid search terms given\"\n elsif not not_found\n res = []\n @document_vectors.each do |entry, (dvec, mtime)|\n score = dvec.score_against(must_match, must_not_match, general)\n res << [ entry, score ] if score > 0\n end\n \n res.sort {|a,b| b[1] <=> a[1] }.each {|name, score|\n search_results.add_result(name, score)\n }\n \n search_results.add_warning \"No matches\" unless search_results.contains_matches\n end\n search_results\n end", "def search(word)\n node = @root\n word.each_char { |c|\n unless node.children.key?(c)\n return nil\n end\n node = node.children[c]\n }\n return node\n end", "def english_word?(word)\n # opening the API file with the input word\n result = open(\"https://wagon-dictionary.herokuapp.com/#{word}\")\n # reading the results of the API as a complete HASH\n json = JSON.parse(result.read)\n # returning API result (hash) for a given word, if found then English word\n json['found']\n end", "def get(word)\r\n return \"\" if !@words[word]\r\n follow = @words[word]\r\n sum = follow.inject(0) { |sum,kv | sum +=kv[1] }\r\n random = rand(sum)+1\r\n part_sum = 0\r\n nextWord = follow.find do |word, count|\r\n part_sum += count\r\n part_sum >= random\r\n end.first\r\n nextWord\r\n\r\n end", "def find_word_on_board(word)\n word = word.upcase\n @word_path = nil # reset path of found word on the board if any\n\n for row in 0...@size do\n for col in 0...@size do\n if @board[row][col] == word[0] # if first letter of the word is found, then start search here\n if recursion_part_of_search([[row,col]], word) # pass in row and col of starting location\n self.to_s # update board with cool color showing path of word\n @words_found << word\n @score += word.length\n return true # word was found\n end\n end\n end\n end\n false\n end", "def search_next_word(word)\n @info.focus\n highlight_word word\n cursor = @info.index('insert')\n pos = @info.search_with_length(Regexp.new(Regexp::quote(word), Regexp::IGNORECASE), cursor + ' 1 chars')[0]\n if pos.empty?\n @app.status = 'Cannot find \"%s\"' % word\n else\n set_cursor(pos)\n if @info.compare(cursor, '>=', pos)\n @app.status = 'Continuing search at top'\n else\n @app.status = ''\n end\n end\n end", "def find(id)\n each_descendant(false).detect {|op| op.id == id}\n end", "def find_or_add_node(id, word)\n node = find_node(id: id)\n if node\n node.words << word unless node.words.include?(word)\n node\n else\n nodes << Node.new(id: id, words: [word])\n nodes.last\n end\n end", "def search(word)\n current = @root\n word.chars.each do |c|\n current = current.siblings.find { |node| node.val == c }\n return false unless current\n end\n\n current.end\n end", "def search(wd)\n\tpage = Query::Engine::Baidu.query(wd)\n\t#page.seo_rank #it seems that the seo_rank of baidu is not complete crawled the search page\n\trelated_keywords_baidu = page.related_keywords \n\trelated_keywords_baidu.each do |keywords| # save each keywords into database unless the word is exist already.\n\t\tnext unless RelateWorld.find_by_keyword(keywords) == nil\n\t\trelate = RelateWorld.new\n\t\trelate.keyword = keywords\n\t\trelate.save\n\tend \nend", "def highlight_word(word)\n return if word.empty?\n @info.tag_remove('search', '1.0', 'end')\n _highlight_word(word.downcase, @info.get('1.0', 'end').downcase, 'search')\n end", "def get_word\n dictionary.get_word\n end", "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 find_word(node, curr_word, secret_word_length)\n new_word = curr_word + node.char\n return new_word if(node.vertices.length == 0)\n node.vertices.each do |vertice|\n word = find_word(vertice, new_word, secret_word_length)\n return word if word.length == secret_word_length\n end\n end", "def my_array_finding_method(source, thing_to_find)\n source.select { |word| word.to_s.include? thing_to_find}\nend", "def findWord(query, array_of_strings)\n\t#array_of_strings.select {|str| str.match(query) }\n #array_of_strings.any? {|i| i[query] }\n array_of_strings.reject {|x| x.match (/#{query}/) }\nend", "def find?(word)\n !find(word).empty?\n end", "def collegelookbyID(txtfile, id)\n idstuff = readerIDs(txtfile)\n collegestuff = readercollege(txtfile)\n \n idstuff.each_with_index do |chopper, index|\n idstuff[index] = chopper.chomp\n end\n collegestuff.each_with_index do |chopper, index|\n collegestuff[index] = chopper.chomp\n end\n\n tofindcollege = idstuff.index(id)\n thecollege = collegestuff[tofindcollege]\n\n return thecollege\nend", "def my_array_finding_method(source, thing_to_find)\n source.select { |word| word.to_s.include? thing_to_find }\nend", "def search(word)\n sz = word.size\n return false unless @words.key?(sz)\n @words[sz].keys.any? { |k| ismatch(k, word) }\n end", "def matching_the_word_and\n /WRITE ME/\n end", "def check_if_present(word)\n chars = word.downcase.split('')\n match = false\n char_count = 0\n crawl = root\n\n chars.each do |a_char|\n char_count += 1\n child = crawl.children\n if child.keys.include?(a_char)\n crawl = child[a_char]\n if crawl.is_end && (char_count == chars.length)\n match=true\n end\n else\n break;\n end\n end\n match # returns if the word is in dictionary or not.\n end", "def my_array_finding_method(source, thing_to_find)\n result = source.select{ |word| word.to_s.include? (thing_to_find) }\n result\nend", "def search(word)\n node = @root\n word.each_char do |c|\n node = node[c]\n return false if node.nil?\n end\n !node[END_OF_WORD].nil?\n end", "def selectWord\n\twords = [\n\t\t\"anvil\",\n\t\t\"black\",\n\t\t\"break\",\n\t\t\"clear\",\n\t\t\"doubt\",\n\t\t\"exist\",\n\t\t\"first\",\n\t\t\"girth\",\n\t\t\"heart\",\n\t\t\"icons\",\n\t\t\"joker\",\n\t\t\"loath\",\n\t\t\"mirth\",\n\t\t\"notch\",\n\t\t\"overt\",\n\t\t\"print\",\n\t\t\"qualm\",\n\t\t\"react\",\n\t\t\"solid\",\n\t\t\"trick\",\n\t\t\"until\",\n\t\t\"viola\",\n\t\t\"water\",\n\t\t\"young\",\n\t\t\"zebra\"\n\t]\n\treturn words[Random.rand(words.length)]\nend", "def set_word\n @word = Word.friendly.find(params[:id])\n end", "def include?(word)\n @words[word[0]].include? word\n end", "def searching_single(phrase)\n analyse_result(Ca::SimilarTest.mechanize_work(phrase), phrase)\n end", "def match(keyword); end", "def getWord(word)\n @bits[word]\n end", "def search word\n # No need to enclose the following in a EM.run block b/c TweetStream does this when \n # it initializes the client.\n puts \"entering\"\n q = last_search_query(word) \n current_search = next_search(word, q)\n #jump first one beacause of max_id including last one\n q = q.merge(current_search.next_results)\n current_search = next_search(word, q)\n puts \"#{current_search.attrs[:search_metadata]}\"\n while current_search.next_results? do\n current_search.results.each do |tweet|\n unless same_tweet(tweet)\n raw_tweet_to_tweet(tweet, word).save\n end\n end\n q = q.merge(current_search.next_results)\n current_search = next_search(word, q)\n end\n end", "def find_word(search, word, maxRow, maxCol)\n (0..maxRow).each do |i|\n (0..maxCol).each do |j|\n if starts_here(search, word, i, j)\n puts \"The word '#{word}' starts at (#{i},#{j}).\"\n return\n end\n end\n end\n puts \"The word '#{word}' was not found!\"\nend", "def show\n\t\tresults = Spellchecker.check(params[:id]).first # Spellchecker gem spec http://rubydoc.info/gems/spellchecker/0.1.5/frames \n\t\tresults.delete(:original) # original word is not part of the api spec\n\t\t\n\t\tif results[:correct]\n\t\t\trespond_with(results) # They got it right. Nothing more to be done.\n\t\t\treturn\n\t\tend\n\t\t\n\t\tunless @user = User.find_by_id(params[:user_id])\n\t\t\trespond_with(results) # No one is logged in. Return the results.\n\t\t\treturn\n\t\tend\n\t\t\n\t\tunless @custom_word = @user.custom_words.find_by_word(params[:id])\n\t\t\trespond_with(results) # This is a new word. Return the results.\n\t\t\treturn\n\t\tend\n\t\t\n\t\tif @custom_word.correct\n\t\t\trespond_with( {:correct => false} )\n\t\telse\n\t\t\trespond_with( {:correct => false, :suggestions => @custom_word.top_corrections.concat( results[:suggestions] ).uniq[0..2] })\n\t\tend\n\tend", "def get_word(word)\n chosen = \"\"\n\n if [email protected][word].nil? then\n \n # sum up all values in our word to get range\n total = 0\n @graph.words[word].map { |k,v| total += v }\n\n # grab some random val from said range\n sel = rand(total)\n\n # return the first word that has a\n # weight greater than our 'random number'\n # ensure we remove the weight from random\n # on each iteration\n @graph.words[word].each do |k,v|\n\n if v > sel then\n chosen = k\n break\n end\n\n sel -= v\n\n end\n\n return chosen\n end\n\n end", "def get_char_by_id( id )\n matches = each_char.select{ |c| c.id == id } # XXX not sure why I have to implement this?\n matches.first \n end", "def search(word)\r\n n = start_with_helper(word)\r\n #puts \"n=#{n}\"\r\n #puts \"n=#{n}, n.is_end=#{n.is_end}\"\r\n return !n.nil? && n.is_end\r\n end", "def english_word?(word)\n response = open(\"https://wagon-dictionary.herokuapp.com/#{word}\")\n json = JSON.parse(response.read)\n return json['found']\n end", "def []( word, *args )\n\t\tif word.is_a?( Integer )\n\t\t\t# :TODO: Assumes Synset IDs are all >= 100_000_000\n\t\t\tif word.to_s.length > 8\n\t\t\t\treturn WordNet::Synset[ word ]\n\t\t\telse\n\t\t\t\treturn WordNet::Word[ word ]\n\t\t\tend\n\t\telse\n\t\t\treturn self.lookup_synsets( word, 1, *args ).first\n\t\tend\n\tend", "def word_finder (arr, str)\n arr.select do |value|\n value.include? str\n end\nend", "def lookup_specific(words)\n words = @delimiter_handler.split_path(words.first) if words.size == 1\n load_for_prefix(words)\n tool = @mutex.synchronize { get_tool_data(words, false)&.cur_definition }\n finish_definitions_in_tree(words) if tool\n tool\n end", "def subwords(word, dictionary)\n arr = substrings(word)\n arr.select { |str| dictionary.include?(str) }\nend", "def find_story_id(text)\n find_story_ids(text).first\n end", "def find_with_tag(phrase, opts={})\n phrase = phrase.downcase unless opts[:case_sensitive] == true\n first(:tag_words => phrase)\n end", "def check_for (array, thing_to_find )\n array.select { |word| word.include? thing_to_find }\n end", "def findByWord(word)\n Neo4j::Transaction.run do\n puts \"Find all sentence with #{word}\"\n result = Sentence.find(:text => word)\n\n puts \"Found #{result.size} sentences\"\n \n result.each {|x| puts \"#{x}\"}\n end\nend", "def highlight_search_res(sentence, word)\n count = sentence.split.count{ |matched| matched.downcase.include?('can') }\n capital_word = word.dup.capitialize()\n s = \"\"\n s += sentence.gsub(\"#{word}\", \"(#{word})\").gsub(\"#{capital_word}\", \"(#{capital_word})\")\n s += \"\\n\"\n s += \"Total occurence found : #{count}\"\nend", "def get_word(word)\n word_hash = Digest::SHA1.hexdigest(word)\n word_file_path = ROOT_DATA_FOLDER + word_hash\n return '0' unless File.exist?(word_file_path)\n\n word_file = File.open(word_file_path)\n words = word_file.readlines\n word_index = words.index(word + \"\\n\")\n word_file.close\n return '0' if word_index.nil?\n\n words[word_index + 1].sub \"\\n\", ''\n end" ]
[ "0.7096285", "0.67018825", "0.6616555", "0.65546274", "0.65493053", "0.6429672", "0.64178467", "0.64008355", "0.63831544", "0.63143986", "0.6227664", "0.62243813", "0.62014973", "0.61573446", "0.6040242", "0.60146827", "0.6007114", "0.60044944", "0.5981046", "0.5947938", "0.5927288", "0.5892241", "0.5886872", "0.58817923", "0.58344877", "0.5823529", "0.58235157", "0.58155537", "0.58151853", "0.5814583", "0.5796525", "0.5783267", "0.57787573", "0.57528406", "0.5736662", "0.57316625", "0.57148516", "0.5701121", "0.56903565", "0.5685069", "0.5650118", "0.56418073", "0.56415516", "0.56357396", "0.5625074", "0.56248176", "0.561261", "0.5609204", "0.5602531", "0.5594059", "0.5588674", "0.55809826", "0.5579065", "0.557786", "0.5575711", "0.55732536", "0.5563175", "0.55554676", "0.5554649", "0.55473447", "0.55471253", "0.55409807", "0.5519961", "0.5512203", "0.550829", "0.5495085", "0.549015", "0.5488657", "0.54828984", "0.5480772", "0.5479776", "0.5479371", "0.54782796", "0.54590946", "0.54399425", "0.5433316", "0.54324204", "0.54308665", "0.5423357", "0.5421981", "0.5418206", "0.54172945", "0.5404978", "0.5403402", "0.53902584", "0.5386086", "0.5383873", "0.53821194", "0.53760576", "0.536972", "0.53668725", "0.5362925", "0.5361906", "0.5361079", "0.53522795", "0.5352256", "0.53350395", "0.53314024", "0.5320339", "0.5315829" ]
0.5525924
62
Find the edge connecting the two specified nodes, if it exists Note that our edges are undirected, so the order of the parameters `one` and `two` is not meaningful.
def find_edge(one, two) edges.find do |e| (e.one == one && e.two == two) || (e.two == one && e.one == two) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_edge(node_1, node_2)\n @edges[node_1][node_2] if @edges[node_1]\n end", "def find_or_add_edge(one, two)\n edge = find_edge(one, two)\n if edge\n edge.weight += 1\n edge\n else\n edges << Edge.new(one: one, two: two, weight: 1)\n edges.last\n end\n end", "def findEdge(vertex1, vertex2)\n visualedges = @visualGraph.visual_edges\n visualedges.each do |edge|\n if edge.v1.id == vertex1 && edge.v2.id == vertex2\n # edge from vertex1 to vertex2\n return edge\n elsif edge.v2.id == vertex1 && edge.v1.id == vertex2\n # edge from vertex2 to vertex1\n return edge\n end\n end\n return nil\n end", "def edge_for(left, right)\n edges.detect { |edge| edge.left.equal?(left) && edge.right.equal?(right) }\n end", "def get_connection_to(another_vertex)\n @edges.each do |edge|\n if edge.head == another_vertex || edge.tail == another_vertex\n return edge\n end\n end\n end", "def edge(source, target)\n @edges.each_with_index { |test_edge, index| return test_edge if test_edge.source == source and test_edge.target == target }\n end", "def create_edge(node1, node2)\n @nodes[node1.position].add_edge(node2)\n @nodes[node2.position].add_edge(node1)\n end", "def edge(*coords)\n (coords.size == 1) ? edge_map[coords.first] : edge_map[coords]\n end", "def add_edge(element1, element2)\n index1 = self.dict[element1]\n index2 = self.dict[element2]\n raise Exception.new(\"Nodes not exist!\") unless index1 && index2\n\n head_node2 = self.adj_list_array[index2].head_node\n new_node1 = Node.new(element1, head_node2.next_node)\n head_node2.next_node = new_node1\n\n\n head_node1 = self.adj_list_array[index1].head_node\n new_node2 = Node.new(element2, head_node1.next_node)\n head_node1.next_node = new_node2\n\n self\n end", "def common_point(e1, e2)\n p1, p2 = @edges[e1]\n p3, p4 = @edges[e2]\n if p1 == p3 || p1 == p4\n p1\n elsif p2 == p3 || p2 == p4\n p2\n else\n nil\n end\n end", "def edge?(x, y)\n connected?(x, y)\n end", "def edge?(x, y)\n connected?(x, y)\n end", "def common_point(e1, e2)\n p1, p2 = @points_of_edge[e1]\n p3, p4 = @points_of_edge[e2]\n if p1 == p3 || p1 == p4\n p1\n elsif p2 == p3 || p2 == p4\n p2\n else\n nil\n end\n end", "def add_edge(x, y) # from x to y\n if @nodes.key?(x) and @nodes.key?(y)\n if @edges.key?(x)\n unless @edges[x].include?(y)\n @edges[x] << y\n end\n end\n if @back_edges.key?(y)\n unless @back_edges[y].include?(x)\n @back_edges[y] << x\n end\n end\n else\n raise RuntimeError.new \"#{x} and #{y} not both present\"\n end\n end", "def get_edge(source, target)\n h = @pathway.graph[source]\n h ? h[target] : nil\n end", "def has_edge?(vertex1, vertex2)\n\tend", "def common_face(edge2)\n end", "def common_face(edge2)\n end", "def connect(vert1, vert2)\n # Basically, if the two elements in the edge set are in the @vertices\n # set, then we add the edge to the set.\n edge = [ vert1, vert2 ]\n\n if (edge.to_set & @vertices) == edge.to_set\n @edges.add(edge)\n end\n end", "def each_edge_in_path(node1, node2)\n path = self.path(node1, node2)\n source = path.shift\n path.each do |target|\n edge = self.get_edge(source, target)\n yield source, target, edge\n source = target\n end\n self\n end", "def connects_end_to_end?(first_node_id, second_node_id)\n (first_node_id == @begin_node_id and second_node_id == @end_node_id and\n @begin_node_direction == true and @end_node_direction == false) or\n (first_node_id == @end_node_id and second_node_id = @begin_node_id and\n @begin_node_direction == true and @end_node_direction == false)\n end", "def get_edge(x, y)\n @store[x, y]\n end", "def get_edge_merged(edge1, edge2)\n dist1 = get_edge_distance(edge1)\n dist2 = get_edge_distance(edge2)\n if dist1 and dist2 then\n Edge.new(dist1 + dist2)\n elsif dist1 then\n Edge.new(dist1)\n elsif dist2 then\n Edge.new(dist2)\n else\n Edge.new\n end\n end", "def edge(resource,node1,node2) \n label = fetch_fragment(resource) if(@options.showedges)\n color = colour_map(resource) if (@options.colour_code)\n @root.add_edge(node1,node2,:label=>label,:color=>color)\n end", "def add_edge(node1, node2, weight)\n nodes[node1.value].add_edge(nodes[node2.value], weight)\n nodes[node2.value].add_edge(nodes[node1.value], weight)\n self\n end", "def adjacent?(x, y)\n @edges[x].include?(y) || @edges[y].include?(x)\n end", "def edges_to(node)\n edges.select { |edge| edge.last == node }\n end", "def connect node1, node2\n if !Set.new([node1, node2]).subset? @nodes\n raise BadNodeInput, 'The graph does not have either ' + node1 + ' or ' + node2\n end\n @connections[node1] ||= Array.new\n @connections[node1].push node2\n unless node1.eql? node2\n @connections[node2] ||= Array.new\n @connections[node2].push node1\n end\n end", "def add_edge(id1, id2)\n # YOUR WORK HERE\n end", "def add_edge(a,b)\n @adj_list[a][b] = 1\n end", "def get_edge(x, y)\n edge = get(x, y)\n edge[:weight] if edge\n end", "def edge\n :first if first?\n :last if last?\n nil\n end", "def add_edge(node_a, node_b)\n node_a.adjacents << node_b\n node_b.adjacents << node_a\n end", "def edges_of(node)\n edges_from(node) | edges_to(node)\n end", "def is_neighbour_of(another_vertex)\n @edges.each do |edge| \n if edge.head == another_vertex || edge.tail == another_vertex\n return true\n end\n end\n return false\n end", "def remove_edge(node_1, node_2)\n raise KeyError, \"#{node_1} is not a valid node.\" unless @nodes.key?(node_1)\n raise KeyError, \"#{node_2} is not a valid node\" unless @nodes.key?(node_2)\n raise KeyError, 'The given edge is not a valid one.' unless @adj[node_1].key?(node_2)\n\n @adj[node_1].delete(node_2)\n @pred[node_2].delete(node_1)\n end", "def both_e(*filters, &block)\n Pacer::Route.property_filter(chain_route(:element_type => :edge,\n :pipe_class => Pacer::Pipes::VertexEdgePipe,\n :pipe_args => Pacer::Pipes::VertexEdgePipe::Step::BOTH_EDGES,\n :route_name => 'bothE'),\n filters, block)\n end", "def adjacent(vertex1, vertex2)\n connections = @graph[vertex1]\n return connections && connections.include?(vertex2)\n end", "def add_undirected_edge(id1,id2)\n @g[id1] ||= Set.new\n @g[id2] ||= Set.new\n @g[id1] << id2\n @g[id2] << id1\n end", "def add_edge(e)\n add_vertex(e.from); add_vertex(e.to)\n (@from_store[e.from].add?(e) && @to_store[e.to].add(e) && e) || edge(e.from, e.to)\n end", "def path_from_to(a, b)\n # Work with the fixed anchors of the nodes because that's where the\n # control flow is fixed to.\n\n a = fixed_anchor(a)\n b = fixed_anchor(b)\n\n # We're going to do a depth-first search starting with the first node\n # and we're going to see if we can find the second node. We keep a stack\n # of nodes that we need to visit, and a set of nodes that we've already\n # visited so that we don't visit nodes more than once. We pop a node\n # off the stack, return if it was the node we were looking for, or move\n # on if we've already visited it, if not we push the outputs of the node\n # to visit next.\n\n worklist = [a]\n considered = Set.new\n until worklist.empty?\n node = worklist.pop\n return true if node == b\n if considered.add?(node)\n worklist.push *node.outputs.control_edges.to_nodes\n end\n end\n\n # We traversed the whole graph accessible from the first node and didn't\n # find the second one.\n\n false\n end", "def add_edge(object_1, object_2)\n node_1 = check_object(object_1)\n node_2 = check_object(object_2)\n node_1.adjacents << node_2\n node_2.adjacents << node_1\n end", "def connects_beginning_to_end?(first_node_id, second_node_id)\n (first_node_id == @begin_node_id and second_node_id == @end_node_id and\n @begin_node_direction == false and @end_node_direction == false) or\n (first_node_id == @end_node_id and second_node_id = @begin_node_id and\n @begin_node_direction == true and @end_node_direction == true)\n end", "def add_directed_edge(id1,id2)\n @g[id1] ||= Array.new\n @g[id1] << id2\n end", "def has_edge(from_node, to_node)\n return @nodes[from_node].include?(to_node)\n end", "def add_edge(nodeA, nodeB)\n nodeA.adjacents << nodeB\n nodeB.adjacents << nodeA\n\n @nodes << nodeA\n @nodes << nodeB\n end", "def has_edge(start_vertex_name, end_vertex_name)\n first_vertex_index = find_index_for_vertex(start_vertex_name)\n second_vertex_index = find_index_for_vertex(end_vertex_name)\n\n return false unless (!first_vertex_index.nil? && !second_vertex_index.nil?)\n\n return @vertices[first_vertex_index].neighbours[second_vertex_index] == true\n end", "def add_edge(x, y)\n\t\traise if @x_connections[x] != -1\n\t\traise if @y_connections[yIdx(y)] != -1\n\t\t\n\t\t@x_connections[x] = y\n\t\t@y_connections[yIdx(y)] = x\n\t\t\n\t\t@unconnected_x_vertices -= 1\n\t\t\n#\t\traise if @x_connected_vertices.member?(xy[0])\n#\t\traise if @y_connected_vertices.member?(xy[1])\n\t\n\tend", "def connects_end_to_beginning?(first_node_id, second_node_id)\n # ARC $START_NODE $END_NODE $MULTIPLICITY\n #Note: this one line implicitly represents an arc from node A to B and\n #another, with same multiplicity, from -B to -A.\n (first_node_id == @begin_node_id and second_node_id == @end_node_id and\n @begin_node_direction == true and @end_node_direction == true) or\n (first_node_id == @end_node_id and second_node_id = @begin_node_id and\n @begin_node_direction == false and @end_node_direction == false)\n end", "def get_clockwise_neighbor(id_1, id_2)\n return id_1 if @vertices[id_1].y > @vertices[id_2].y\n return id_1 if @vertices[id_1].x < @vertices[id_2].x\n return id_2\n end", "def get_intersection_node(a, b)\n len_a = len(a)\n len_b = len(b)\n if len_a > len_b\n while(len_b < len_a)\n a = a.next\n len_b += 1\n end\n elsif len_b > len_a\n while(len_a < len_b)\n b = b.next\n len_a += 1\n end\n end\n while a && b\n return a if a == b\n a = a.next\n b = b.next\n end\n return nil\nend", "def create_edge_to_and_from(other, weight = 1.0)\n self.class.edge_class.create!(:from_id => id, :to_id => other.id, :weight => weight)\n self.class.edge_class.create!(:from_id => other.id, :to_id => id, :weight => weight)\n end", "def test_add_edge\n @graph.add_edge('a', 'b');\n vertex_a = @graph.find_vertex('a')\n vertex_b = @graph.find_vertex('b')\n\n # 0 and 1 are indexes of vertex a and vertex b respectively\n assert(@graph.vertices[0].neighbours[1] == true && @graph.vertices[1].neighbours[0] == true)\n end", "def connect_for!(source, edge_args, target)\n edge = Edge(source, edge_args, target)\n\n self[:graph][source][edge] = target\n\n return target, edge\n end", "def get_edge_value(x, y)\n raise\n end", "def edge?( from, to )\n @vertices[from].include? to \n end", "def get_edge(edge)\n return nil unless edge[:from][:name]\n return nil unless edge[:to][:name]\n\n #Get the type of the edge\n type = edge[:type] || Config::DEFAULT_TYPE\n edge[:type] = type\n\n #Check if the edge type exists\n etype = Marshal.load(@db.m_get(\"edge#{type}\") || Marshal.dump({})) \n \n #Integrity check: Check whether the edge direction is not contradictory\n if edge[:directed]\n if etype[:directed] != nil\n if etype[:directed] != edge[:directed]\n return nil\n end\n else\n #If there is no edge of that type then pre-empt the result\n return nil\n end\n else\n if etype[:directed] != nil\n edge[:directed] = etype[:directed]\n else\n #If there is no edge of that type then pre-empt the result\n return 3\n end\n end\n\n #Convert the edge into a Key string and fetch the corresponding data\n key, reverse_key = Keyify.edge(edge)\n value = @db.e_get(key)\n\n if value\n new_edge = Marshal.load(value)\n new_edge[:from] = self.get_node(edge[:from])\n new_edge[:to] = self.get_node(edge[:to])\n new_edge[:type] = edge[:type]\n new_edge[:directed] = etype[:directed] #Pick direction alone from the meta_db for consistency\n new_edge\n end\n end", "def add_edge(x, y, cost: 1)\n raise\n end", "def connects_beginning_to_beginning?(first_node_id, second_node_id)\n (first_node_id == @begin_node_id and second_node_id == @end_node_id and\n @begin_node_direction == false and @end_node_direction == true) or\n (first_node_id == @end_node_id and second_node_id = @begin_node_id and\n @begin_node_direction == false and @end_node_direction == true)\n end", "def has_edge?(edge)\n !find_edge(edge.node_1, edge.node_2).nil?\n end", "def adjacent(x, y)\n raise\n end", "def disconnect node1, node2\n if !nodes.include?(node1) || !nodes.include?(node2)\n raise NodeContainsException, 'The graph does not contain either ' + node1 + ' or ' + node2\n end\n @connections[node1].delete node2\n @connections[node2].delete node1\n end", "def add_edge(vertex1, vertex2)\n if !@graph[vertex1] || !@graph[vertex2]\n raise InvalidVertexException, \"That vertex doesn't exist in the graph\"\n end\n @graph[vertex1].push(vertex2)\n @graph[vertex2].push(vertex1)\n self\n end", "def add_edge(*e)\n raise InvalidArgumentError if e.size > 2\n \n e = [e] if e.size == 2\n @edges.add(e[0])\n end", "def traverse(*args)\n return self if args.none?\n if edges[args.first].kind_of? Addressive::Node\n return edges[args.first].traverse(*args[1..-1])\n else\n raise NoEdgeFound.new(self, args.first)\n end\n end", "def neighbours?(node1, node2, options = {:siblings => false})\n neighbours(node1, options).any? { |set| set.include? node2 }\n end", "def add_edge(x, y, type)\n debug_msg \"adding edge #{x}, #{y}, #{type}\"\n if self[x,y]\n unless self[x,y] == type\n @contradiction = true\n debug_msg \" \\tcontradiction\"\n throw :add_edge_throw, :contradiction\n else\n debug_msg \"\\ti know\"\n throw :add_edge_throw, :i_know\n end\n else\n super(x, y, type)\n end\n end", "def edge?(source, target)\n return false unless vertex?(source) and vertex?(target)\n\n @vertices[source].has_edge?(:out, target)\n end", "def edge?(u,v)\n return @source[u].has_key?(v)\n end", "def render_edge n1, n2, opts = nil\n @edge_count += 1\n\n _logger.debug :e, :prefix => false, :write => true\n\n opts ||= EMPTY_HASH\n\n n1 = dot_name(n1) unless String === n1\n n2 = dot_name(n2) unless String === n2\n\n if opts[:comment]\n edge_puts \" // #{opts[:comment]}\"\n opts.delete(:comment)\n end\n\n edge_puts \" #{n1} -> #{n2} #{dot_opts opts};\"\n end", "def adjacent?(node_city_A, node_city_B)\n bool = false\n if(node_city_B.nil?)\n bool = false\n\n elsif(@edges[node_city_A].nil? or @edges[node_city_B].nil?)\n bool = false\n\n else\n @edges[node_city_A].each do |edge|\n if edge.name == node_city_B\n bool = true\n end\n end\n end\n bool\n end", "def r_edge(other_node)\n (self.edges << other_node) && (other_node.edges << self)\n self\n end", "def has_edge?(u, v)\n each_adjacent(u) do |w|\n return true if v == w\n end\n return false\n end", "def connect(node0, node1)\n @connections << [node0, node1] unless @connections.include? [node0, node1]\n @connections << [node1, node0] unless @connections.include? [node1, node0]\n end", "def delete_edge(vertex1, vertex2)\n if !contains_vertex?(vertex1) || !contains_vertex?(vertex2)\n raise InvalidVertexException, \"The graph does not contain that vertex\"\n elsif !(@graph[vertex1].include?(vertex2))\n raise InvalidEdgeException, \"The graph does not contain that edge\" \n end\n @graph[vertex1].delete(vertex2)\n @graph[vertex2].delete(vertex1)\n self\n end", "def add_edge(x, y)\n if([email protected]_key?(x)) then \n @g[x] = []\n end\n if(!@g[x].include? y) then\n @g[x] << y\n end\nend", "def other_vertex(direction, edge)\n case direction\n when :in; edge.source\n else\n edge.target\n end\n end", "def remove_edge(x, y)\n raise\n end", "def add_edge(start_vertex_name, end_vertex_name)\n\n # Check if graph is not empty\n if (@vertices.length == 0)\n raise GraphError.new('No edges can be added to an empty graph', GraphError::ERROR_ADD_EDGE_FAILURE)\n end\n\n first_vertex_index = find_index_for_vertex(start_vertex_name)\n second_vertex_index = find_index_for_vertex(end_vertex_name)\n\n if (first_vertex_index == nil)\n raise GraphError.new('Edge cannot be added. First vertex could not be found', GraphError::ERROR_ADD_EDGE_FAILURE)\n end\n\n if (second_vertex_index == nil)\n raise GraphError.new('Edge cannot be added. Second vertex could not be found', GraphError::ERROR_ADD_EDGE_FAILURE)\n end\n\n add_edge_by_indexes(first_vertex_index,second_vertex_index)\n end", "def edge?( from, to )\n @vertices[ from ].include?( to )\n end", "def join(t1, t2)\n e1, e2, e3 = @edges_of_triangle[t1]\n\n # we want the two edges that are not e3\n raise \"edge not shared\" if ! @edges_of_triangle[t2].include?(e3)\n e4, e5 = @edges_of_triangle[t2].select{|x| x != e3}\n\n # swap e4/e5 if necessary so that e1 and e4 share a point\n if common_point(e1, e4).nil?\n e4, e5 = e5, e4\n end\n\n adjacent = common_point(e1, e2)\n opposite = common_point(e4, e5)\n\n remove_triangle(t1)\n remove_triangle(t2)\n remove_edge(e3)\n\n e6 = add_edge(opposite, adjacent)\n\n add_triangle(e1, e4, e6)\n add_triangle(e2, e5, e6)\n\n # sanity_check\n end", "def add_edge(left, right)\n left.blocked_by(right)\n right.blocking(left)\n \n @edges << [left, right]\n end", "def connects_to_end?(node_id)\n (node_id == @begin_node_id and @begin_node_direction) or\n (node_id == @end_node_id and !@end_node_direction)\n end", "def c_edge(other_node, wt = 0)\n (self.outbound_edges.add(other_node, wt) &&\n other_node.inbound_edges.add(self, wt))\n self\n end", "def edge_exists?(src, dest)\n\t\treturn false if @e.empty?\n\t\[email protected] do |edge|\n\t\t\tif edge.src == src and edge.dest == dest\n\t\t\t\treturn true\n\t\t\tend\n\t\tend\n\t\tfalse\n\tend", "def test_adding_edge\n \n # Start a new graph with no vertices\n graph = Graph.new()\n \n # Add 2 vertices to the graph\n origin = { \"code\" => \"NYC\" ,\n \"name\" => \"New York\" ,\n \"country\" => \"US\" ,\n \"continent\" => \"North America\" ,\n \"timezone\" => -5 ,\n \"coordinates\" => { \"N\" => 41, \"W\" => 74 } ,\n \"population\" => 22200000 ,\n \"region\" => 3 }\n \n destination = { \"code\" => \"WAS\" ,\n \"name\" => \"Washington\" ,\n \"country\" => \"US\" ,\n \"continent\" => \"North America\" ,\n \"timezone\" => -5 ,\n \"coordinates\" => {\"N\" => 39, \"W\" => 77} ,\n \"population\" => 8250000 ,\n \"region\" => 3 } \n graph.add_node(origin)\n graph.add_node(destination)\n \n assert_equal( graph.nodes().size, 2)\n \n # Add a two-way edge for the two vertices\n distance = 1370 \n graph.add_edge(origin[\"code\"] , destination[\"code\"], distance)\n graph.add_edge(destination[\"code\"] , origin[\"code\"], distance)\n \n assert_equal( graph.nodes[\"NYC\"].neighbors.size, 1)\n assert_equal( graph.nodes[\"WAS\"].neighbors.size, 1)\n assert_equal( graph.nodes[\"NYC\"].neighbors[\"WAS\"], distance)\n assert_equal( graph.nodes[\"WAS\"].neighbors[\"NYC\"], distance)\n \n end", "def edge_key(a,b)\n \"#{a}_#{b}\".to_sym\n end", "def test_add_edge\n @dgraph.add_edge('a', 'b');\n\n # 0 and 1 are indexes of vertex a and vertex b respectively\n assert(@dgraph.vertices[0].neighbours[1] == true && @dgraph.vertices[1].neighbours[0] == nil)\n end", "def create_edge_to(other, weight = 1.0)\n self.class.edge_class.create!(:from_id => id, :to_id => other.id, :weight => weight)\n end", "def create_edge origin, destiny\n return GraphElements::EdgeDefault.new origin, destiny\n end", "def follow(edge)\n if edge.nodes.first == self\n edge.nodes.last\n else\n edge.nodes.first\n end\n end", "def contract edge\n vertex_1 = edge[0]\n vertex_2 = edge[1]\n #puts \"contracting edge \" + vertex_1.id.to_s + \", \" + vertex_2.id.to_s\n remove_vertex vertex_2\n\n vertex_2.adjacent_vertices.each{ |adjacent_vertex|\n vertex = find(adjacent_vertex)\n vertex_2_index = vertex.adjacent_vertices.index(vertex_2.id)\n vertex.adjacent_vertices[vertex_2_index] = vertex_1.id\n }\n vertex_1.adjacent_vertices.concat(vertex_2.adjacent_vertices)\n vertex_1.adjacent_vertices.delete_if {|adjacent_vertex| adjacent_vertex == vertex_1.id }\n end", "def remove_edge(start_vertex_name, end_vertex_name)\n\n first_vertex_index = find_index_for_vertex(start_vertex_name)\n second_vertex_index = find_index_for_vertex(end_vertex_name)\n\n if (first_vertex_index == nil)\n raise GraphError.new('Edge removal error. First vertex could not be found', GraphError::ERROR_REMOVE_EDGE_FAILURE)\n end\n\n if (second_vertex_index == nil)\n raise GraphError.new('Edge removal error. Second vertex could not be found', GraphError::ERROR_REMOVE_EDGE_FAILURE)\n end\n\n remove_edge_by_indexes(first_vertex_index, second_vertex_index)\n end", "def edge?(i,j)\n\t\tif(edge(i,j) != @no_edge_val)\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend", "def add_edge(source, target = nil, label = nil)\n @reversal = nil\n if target\n edge = Puppet::Relationship.new(source, target, label)\n else\n edge = source\n end\n [edge.source, edge.target].each { |vertex| setup_vertex(vertex) unless vertex?(vertex) }\n @vertices[edge.source].add_edge :out, edge\n @vertices[edge.target].add_edge :in, edge\n @edges << edge\n true\n end", "def test_add_edge_with_cycles\n @graph.add_edge('a', 'b');\n @graph.add_edge('b', 'c');\n @graph.add_edge('c', 'a');\n\n # 0 and 2 are indexes of vertex a and vertex c respectively\n assert(@graph.vertices[0].neighbours[2] == true && @graph.vertices[2].neighbours[0] == true)\n end", "def add_edge(source, destiny, weigth)\n source, destiny, weigth = convert_values(source, destiny, weigth)\n\n add_vertex(source)\n add_vertex(destiny)\n\n make_edge(source, destiny, weigth)\n end", "def find_node(*args)\n nodes = find_all_nodes(*args)\n raise AmbiguousNode if nodes.size > 1\n nodes.first\n end", "def has_edge?(from, to)\n @vertices.has_key?(from) && @vertices[from].include?(to)\n end", "def edges(direction, *labels)\n edges = directed_value direction, @out_edges, @in_edges\n if labels.empty?\n edges\n else\n edges.select {|e| labels.include? e.label}\n end\n end" ]
[ "0.7645755", "0.7172728", "0.68479484", "0.66183007", "0.6327788", "0.6204899", "0.6167555", "0.61288065", "0.6118278", "0.61089617", "0.60141027", "0.60141027", "0.60116744", "0.5994023", "0.5950963", "0.5850298", "0.58221346", "0.58221346", "0.5820249", "0.5803314", "0.5759806", "0.5715546", "0.57052433", "0.5696629", "0.5692045", "0.56626827", "0.5626249", "0.56019664", "0.55771", "0.55742836", "0.5562421", "0.55421036", "0.5528906", "0.55153656", "0.55085754", "0.55013514", "0.54917705", "0.5477982", "0.5406807", "0.5403768", "0.53831744", "0.5376202", "0.5368859", "0.5355377", "0.53516924", "0.5339123", "0.5324377", "0.5303358", "0.5270529", "0.52595854", "0.52585375", "0.52521235", "0.5245598", "0.5237358", "0.52104837", "0.5197593", "0.51970494", "0.5192322", "0.51913345", "0.5177525", "0.5167563", "0.51611847", "0.51587373", "0.51358205", "0.51346296", "0.5117715", "0.51158166", "0.5096925", "0.50890726", "0.50854814", "0.5083292", "0.50462323", "0.50400156", "0.50387955", "0.50380355", "0.5038", "0.50327474", "0.50282186", "0.50280344", "0.5025001", "0.502268", "0.50150645", "0.5008789", "0.49973795", "0.49964607", "0.4989855", "0.49678394", "0.4963757", "0.49543428", "0.49503586", "0.49406612", "0.49366263", "0.49353105", "0.49328852", "0.49120206", "0.4908279", "0.49029794", "0.4898439", "0.4894998", "0.4883811" ]
0.8362846
0
Return the maximum edge weight in the graph
def max_edge_weight edges.map(&:weight).max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weighted_max_score\n max_score * weight\n end", "def maxweight(w)\n @weight = w if w>@weight\n end", "def edge_weight(start_node, end_node)\n relationships = @adj_list[start_node]\n relationships.length.times do |r|\n relationship = relationships.read(r)\n return relationship.weight if relationship.id == end_node\n end\n 'None'\n end", "def max_score\n problem.weight\n end", "def edge_weight(source, target)\r\n\t\[email protected] do |edge|\r\n\t\t\treturn edge.weight if edge.source == source and edge.target == target\r\n\t\tend\r\n\t\tnil\r\n\tend", "def edge_class\n WeightedDirectedEdge\n end", "def w(edge)\n i, j = edge\n raise ArgumentError, \"Invalid edge: #{edge}\" if i.nil? || j.nil?\n raise \"Edge not found: #{edge}\" unless has_edge?(*edge)\n init_weights if @weight.nil?\n @weight[i - 1][j - 1]\n end", "def get_edge(x, y)\n edge = get(x, y)\n edge[:weight] if edge\n end", "def edge_weight(from_id, to_id)\n node = @list[from_id].read_node_at(to_id)\n node.nil? ? nil : node.weight\n end", "def currentWeight() weighins.last.weight end", "def max\n node = @root\n while node.right\n node = node.right\n end\n node\n end", "def weights\n return @weights if @weights\n return @weights = [] if array.empty?\n\n lo = edges.first\n step = edges[1] - edges[0]\n\n max_index = ((@max - lo) / step).floor\n @weights = Array.new(max_index + 1, 0)\n\n array.each do |x|\n index = ((x - lo) / step).floor\n @weights[index] += 1\n end\n\n return @weights\n end", "def find_max_path_length_recursively\n if self.outgoing_edges.exists?\n available_path_lengths = self.next_vertices.map do |vertex|\n [vertex.id, 1 + vertex.find_max_path_length_recursively]\n end\n longest = available_path_lengths.max{|a,b| a[1] <=> b[1]}[1]\n return longest\n else\n return 0;\n end\n end", "def max_weight_for_country(country)\n 0\n end", "def max_weight_for_country(country)\n 0\n end", "def edge_weight(a,b)\n @words[a][b] or Throw NoRelation\n end", "def weight_function\n\t\tif @weightFunction != nil\n\t\t\t@weightFunction\n\t\telse\n\t\t\tlambda do |u,v|\n\t\t\t\[email protected]{|f| return f.weight if (f.s==u && f.d == v)}\n\t\t\t\treturn nil\n\t\t\tend\n\t\tend\n\tend", "def max_weight_for_country(country)\n return WEIGHT_LIMITS[country.iso]\n end", "def max_weight_for_country(country)\n return WEIGHT_LIMITS[country.iso]\n end", "def weight\n return @weight\n end", "def max\n return nil if @root.nil?\n\n max_node(@root).key\n end", "def max\n\t w=0\n\t for i in(0..@n_elem-1)\n\t if(w < @elem[i])\n\t w = @elem[i]\n\t end\n\t end\n\t w\n\tend", "def maximum\n sides.map(&:value).max\n end", "def weight\n @graph.weight(source, target)\n end", "def get_max\n return if is_empty?\n return @root.val\n end", "def max_score\n return nil if metrics.empty?\n metrics.sum(&:weighted_max_score)\n end", "def weight\n 0\n end", "def weight\n return data.weight\n end", "def edge_weight(id_1, id_2)\n @arr[id_1][id_2]\n end", "def last\n last = 0\n @vertices.each_index do |i|\n last = [get_max_from_neighbours(i), i, last].max\n end\n last\n end", "def size(is_weighted=false)\n if is_weighted\n graph_size = 0\n @adj.each do |_, hash_val|\n hash_val.each { |_, v| graph_size += v[:weight] if v.key?(:weight) }\n end\n return graph_size\n end\n number_of_edges\n end", "def max\n MSPhysics::Newton::Hinge.get_max(@address)\n end", "def path_weight_to(other)\n shortest_path_to(other,:method => :djikstra).map{|edge| edge.weight.to_f}.sum\n end", "def maximum(node = @root)\n maximus = node\n maximus = maximus.right until maximus.right.nil?\n maximus\n end", "def max\n return nil if empty?\n\n root = @root\n while root\n return root unless root.right\n root = root.right\n end\n\n root\n end", "def max\n #sees if current head is furthest right node and assigns\n #the values of title and score to a hash\n if @head.right_link == nil\n max_hash = Hash.new\n max_hash[@head.title] = @head.score\n max_hash\n else\n #Searches tree for furthest right node\n @head = @head.right_link\n max\n end\n end", "def depth_max; depths.max end", "def get_max_from_neighbours(index)\n get_neighbours(index).max || 0\n end", "def max_under_node node\n current = node.left\n while current.right\n current = current.right\n end\n current\n end", "def weight\n @weight || @confines.length\n end", "def find_max_index\n return @node_names.length unless @node_names.empty?\n\n max_index = -1\n unless @nodes.empty?\n @nodes.each do |node|\n max_index = node.value if node.value > max_index\n end\n end\n max_index >= 0 ? (return max_index + 1) : (return -1)\n end", "def maximum(tree_node = @root)\n end", "def maximum(tree_node = @root)\n end", "def top_weighted(max)\n nsize = necessary_words.size\n sorted_by_weight.take(max - nsize) | necessary_words\n end", "def max_weight_for_country(country)\n 2400 # 150 lbs\n end", "def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end", "def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end", "def maximum(tree_node = @root)\n max = tree_node\n until max.right.nil?\n max = max.right\n end\n max\n end", "def wiggle_max\n 0.5\n end", "def maximum\n return @maximum\n end", "def maximum(tree_node = @root)\n max_node = tree_node\n while max_node.right != nil\n max_node = max_node.right\n end\n max_node\n end", "def max_value\n if @head.nil?\n return nil\n else\n if head.right\n max_value = max_search(head.right).data\n else\n max_value = head.data\n end\n end\n return max_value\n end", "def findMaximum(weights)\n\t\n\tputs \"Weights\" if DEBUG_OUTPUT\n\tprintMatrix(weights) if DEBUG_OUTPUT\n\t# l(x) == l[x]\n\t\t\n\teq = EqualityGraph.new(weights)\n\teq.generateLabelFunctions()\n\t\n\t#Generate equality graph\n\t\n\teq.generateEqualityGraph()\n\t\n\t#Pick an abitrary matching in the equality subgraph\n\t\n\teq_match = MatchGraph.new(eq.x_vertices, eq.y_vertices)\n\t\n\teq.initialMatch(eq_match)\t\n\t\n\tputs \"Equality Match\\n#{eq_match.to_s}\" if DEBUG_OUTPUT\n\t\n\t#puts \"Is Equality Match perfect? #{eq_match.isPerfectMatch}\" if DEBUG_OUTPUT\n\t\t\t\n\tuntil(eq_match.isPerfectMatch)\n\t\t#Pick a free vertex in X\n\t\tfreeX = eq_match.get_free_x_vertex\n\t\t\n\t\teq_match.alt_tree_x_nodes.push(freeX)\n\t\t\t\n\t\tputs \"\\nMAJOR STEP Picked a free X: #{freeX}\" if DEBUG_OUTPUT\n\t\t\n\t\ts_vertices = [ freeX ]\n\t\tt_vertices = Array.new\n\t\t\n\t\t#Though sets s and t should be enough, will keep track of the alternating paths \n\t\t#originating at freeX\n\t\t\n\t\t\n\t\ts_neighbors = eq.get_neighbors_of_x_vertices(s_vertices).to_set\n\t\t\n\t\ts_neighbors_not_in_t = s_neighbors.to_a\n\t\t\n\t\tuntil(false)\n\t\t\tputs \"S = #{s_vertices.to_a} N(S) = #{s_neighbors.to_a} T= #{t_vertices.to_a}\" if DEBUG_OUTPUT\n\t\t\t\t\n\t\t\tif s_neighbors.size == t_vertices.size\n\t\t\t\tputs \"\\nSTEP No more s_neighbors to process, growing eq\" if DEBUG_OUTPUT\n\t\t\t\told_size = s_neighbors.size\n\t\t\t\t\n\t\t\t\teq.growEqualityGraph(s_vertices, t_vertices, s_neighbors, s_neighbors_not_in_t)\n\t\t\t\t\n\t\t\t\traise \"s neighbors did not increase\" if s_neighbors.size <= old_size\t\t\t\t\t\t\n\t\t\telse\n\t\t\t\tputs \"\\nSTEP Picking a new Y not yet in T from S neighbors\" if DEBUG_OUTPUT\n\t\t\t\t#pick y\n\t\t\t\ty = s_neighbors_not_in_t.pop #(s_neighbors - t_vertices).find { true } \n\t\t\t\tif eq_match.is_y_vertex_free(y)\n\t\t\t\t\t#Reset S and T\n\t\t\t\t\traise \"T and S are out of wack\" if s_vertices.size != t_vertices.size + 1\t\t\t\t\t\n\t\t\t\t\teq_match = growMatch(y, eq_match, eq, freeX)\n\t\t\t\t\tputs \"Grew match Equality Graph was #{eq}\" if DEBUG_OUTPUT\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tputs \"y[#{y}] is matched\" if DEBUG_OUTPUT\n\t\t\t\t\tnew_s_node = growTree(s_vertices, t_vertices, y, eq, eq_match)\n\t\t\t\t\t\n\t\t\t\t\tnew_s_neighbors = eq.get_neighbors_of_x_vertices( [new_s_node] )# - t_vertices\n\t\t\t\t\ts_neighbors.merge( new_s_neighbors )\n\t\t\t\t\t#new_s_neighbors could intesect with t\n\t\t\t\t\ts_neighbors_not_in_t = (s_neighbors - t_vertices).to_a\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\tend\n\t\n\tputs \"Sum is #{eq_match.sumEdgeWeights(weights)}\" if DEBUG_OUTPUT\n\t\n\treturn eq_match.sumEdgeWeights(weights)\nend", "def edges\n edges = 0\n @graph.each_value do |v|\n edges += v.size\n end\n edges\n end", "def weight\n sides.map(&:weight).reduce(&:+)\n end", "def get_path_weight(graph, path_array)\n result = graph.get_path_weight(path_array)\n result.nil? ? \"NO SUCH ROUTE\" : result\nend", "def edge_number\n @edge_number\n end", "def num_weights(); 0;end", "def maximum(tree_node = @root)\n BinarySearchTree.max(tree_node)\n end", "def find_max_element_DFS(root)\n return if !root\n root_value = root.value\n left_max = root.value\n right_max = root.value\n\n left_max = find_max_element_DFS(root.left_child) if root.left_child\n right_max = find_max_element_DFS(root.right_child) if root.right_child\n\n maximum(root_value, maximum(left_max, right_max))\nend", "def maximum(tree_node = @root)\n while tree_node.right\n tree_node = tree_node.right\n end\n tree_node\n end", "def maximum(tree_node = @root)\n while tree_node.right\n tree_node = tree_node.right\n end\n tree_node\n end", "def weight; end", "def maximum(tree_node = @root)\n while tree_node.right \n tree_node = tree_node.right\n end \n return tree_node\n end", "def maximum(node = @root)\n if node.right\n max_node = maximum(node.right)\n else\n max_node = node\n end\n\n max_node\n end", "def <=>(otherEdge)\n @weight <=> otherEdge.weight\n end", "def number_of_edges\n @adj.values.map(&:length).inject(:+)\n end", "def get_max\n @max\n end", "def get_max()\n end", "def calc_total_weight\n @weight + @node_link.calc_total_weight\n end", "def one_rep_max(weight, reps)\n\t\tif reps > 10 # reps need to be below 11 for accurate result.\n\t\t\treturn nil \n\t\telse\n\t\t\treturn (weight/ (1.0279 - (0.0278 * reps)))\n\t\tend\n\tend", "def maximum(tree_node = @root)\n return maximum(tree_node.right) if tree_node.right\n return tree_node\n end", "def max(key)\n key = find(key) if !key.is_a? Node\n return key if key.right.nil?\n max(key.right)\n end", "def get_weight( nbr )\n @connected_to[ nbr ]\n end", "def maximum\n object.maximum.to_f\n end", "def maximize; end", "def find_max()\r\n self.max\r\n end", "def maximum(tree_node = @root)\n current_node = tree_node\n next_node = current_node.right\n until current_node.right == nil\n current_node = next_node\n next_node = current_node.right\n end\n current_node\n end", "def edge_count\n @adjacency_list.flatten.count / 2\n end", "def maximum(tree_node = @root)\n curr = tree_node\n until curr.right.nil? \n curr = curr.right\n end\n curr \n end", "def maximum(tree_node = @root)\n\t\t\t\t\treturn tree_node.right ? maximum(tree_node.right) : tree_node\n end", "def max\n @n[0]\n end", "def max_element\n self.to_a.max\n end", "def weight\n 2 # ounces\n end", "def max(hill)\n (2 * (hill.size - 1)).to_s\n end", "def effective_maximum\n maximum_bound ? maximum_bound.value : Infinity\n end", "def maximum(tree_node = @root)\n tree_node = tree_node.right while tree_node.right\n tree_node\n end", "def num_edges()\n edgeNum = 0\n @source.values.each do |x|\n edgeNum += x.size()\n end\n return edgeNum/2\n end", "def getNodeWeights()\n # (two possible sources: flipped and negated, so \n # add them for each node)\n \n tabRead(@edges){|arr|\n ordered = [arr[0],arr[2]].sort\n @allEdgeWeightScores[ordered.join(\"--\")] += arr[3].to_f\n @nodeList[arr[0]] = 1\n @nodeList[arr[2]] = 1\n }\nend", "def max_index\n max :vector\n end", "def maximum(tree_node = @root)\n until tree_node.right.nil?\n tree_node = tree_node.right\n end\n return tree_node\n end", "def max\n if self.root.right_child.nil?\n return {self.root.title => self.root.score}\n else\n recursive_max(self.root.right_child)\n end\n end", "def max\n data.max\n end", "def maximum(tree_node = @root)\n until tree_node.right.nil?\n tree_node = tree_node.right\n end\n tree_node\n end", "def max\n @keys[@keys.size-1]\n end", "def maximum(tree_node = @root)\n until tree_node.right.nil?\n tree_node = tree_node.right\n end\n\n tree_node\n end", "def maximum(tree_node = @root)\n until tree_node.right == nil\n tree_node = tree_node.right\n end\n tree_node\n end", "def maximum(tree_node = @root)\n until tree_node.right == nil\n tree_node = tree_node.right\n end\n tree_node\n end", "def best_result(triplet)\n triplet.max\nend", "def item_max() @item_max end" ]
[ "0.7142364", "0.7119911", "0.6974494", "0.6931505", "0.6800333", "0.6675541", "0.655177", "0.64820033", "0.6364242", "0.6350356", "0.6324943", "0.6283164", "0.6260426", "0.6222856", "0.6222856", "0.6164321", "0.6162874", "0.61587054", "0.61587054", "0.6118615", "0.61082864", "0.6106704", "0.6104838", "0.60739285", "0.60687757", "0.60393614", "0.60088706", "0.600525", "0.6001054", "0.5996774", "0.5980039", "0.5967797", "0.59546924", "0.59424144", "0.5934061", "0.5916271", "0.59070444", "0.58959264", "0.5892246", "0.58898586", "0.5868828", "0.5853228", "0.5853228", "0.58433676", "0.5836386", "0.5803089", "0.5803089", "0.5777748", "0.5750874", "0.57444346", "0.57303256", "0.5728654", "0.57149917", "0.57098454", "0.57084984", "0.57050955", "0.5698355", "0.569662", "0.56889045", "0.56758046", "0.5665363", "0.5665363", "0.56639975", "0.5655115", "0.56497955", "0.563975", "0.56372374", "0.56226087", "0.5616119", "0.56050485", "0.5600078", "0.5597304", "0.5587572", "0.5586299", "0.5585361", "0.5581249", "0.55802935", "0.55765766", "0.55722296", "0.5567531", "0.556555", "0.5561781", "0.5553671", "0.55492437", "0.55492157", "0.5545383", "0.5536914", "0.5533475", "0.55308306", "0.5529724", "0.55180126", "0.55039614", "0.55019116", "0.54952276", "0.5489058", "0.548675", "0.54783875", "0.54783875", "0.5468868", "0.54685897" ]
0.92122024
0
Add nodes and edges for a given gap This function adds nodes and edges to the graph for a given size of sliding window.
def add_nodes_for_gap(gap) analyzer = Frequency.call( dataset: dataset, ngrams: gap, num_blocks: 1, split_across: true, progress: ->(p) { progress&.call((p.to_f / 100 * 33).to_i + 33) } ) ngrams = analyzer.blocks[0] ngrams.each do |(gram, _)| gram_words = gram.split(' ') stemmed_gram_words = gram_words.map(&:stem) next if focal_word && !stemmed_gram_words.include?(focal_word_stem) nodes = stemmed_gram_words.zip(gram_words).map do |w| find_or_add_node(*w) end nodes.combination(2).each do |pair| find_or_add_edge(pair[0].id, pair[1].id) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increase_gap\n\n @gap = @gap + 50\n\n end", "def increase_gap\n\n @gap = @gap + 50\n\n end", "def create_knight_tour_graph(board_size)\n new_graph = Graph.new()\n board_size.times do |x|\n board_size.times do |y|\n new_graph.add_vertex([x,y])\n end\n end\n knight_legal_moves(new_graph)\n new_graph\nend", "def insert(data)\n @nodes << data\n heapify_up\n end", "def add_to_neighbors(node)\n @neighbors << node\n end", "def fillWindow(dest_ip, seqNum, data, wSize)\n\twindow = Array.new\n\n\tfor i in 0..wSize-1\n\t\tpacket = Packet.new\n\n\t\tpacket.dest_ip = dest_ip\n\t\tpacket.src_ip = $local_ip\n\t\tpacket.type = 1\n\t\tpacket.seqNum = seqNum + i\n\t\tpacket.ackNum = seqNum + i + 1\n\t\tpacket.data = data[seqNum + i]\n\n\t\twindow.push(packet)\n\tend\n\n\treturn window\nend", "def gap(count = 1)\n\t\t\t1.upto(count) { @order.push(nil) }\n\t\tend", "def gap_width\n @gap_width ||= 150\n end", "def add_edges(node, neighbours)\n # we store edges and (for easier lookup) always use the lower index first\n neighbours.each do |n|\n v1 = [node, n].min\n v2 = [node, n].max\n @edges.push([v1, v2])\n end\n end", "def insert_edge(new_edge_val, node_from_val, node_to_val)\n nodes = { node_from_val => nil, node_to_val => nil }\n @nodes.each do |node|\n next unless nodes.include?(node.value)\n nodes[node.value] = node\n break if nodes.all? { |_node_val, node_obj| node_obj }\n end\n nodes.each do |node_val, _node_obj|\n nodes[node_val] = nodes[node_val] || insert_node(node_val)\n end\n node_from = nodes[node_from_val]\n node_to = nodes[node_to_val]\n new_edge = Edge.new(new_edge_val, node_from, node_to)\n node_from.edges << new_edge\n node_to.edges << new_edge\n @edges << new_edge\n new_edge\n end", "def move_node!(tg,tga,i)\n #first just add node i in\n tga[0].each_index do |ii|\n if (i == tga[0][ii][0])\n tg[0].push(tga[0][ii])\n tga[0][ii] = nil\n break\n end\n end\n #then add the edges, only add edges for which both nodes exist in tg \n tga[1].each_index do |ii|\n if tg[0].index{|item| item[0] == tga[1][ii][0]} && tg[0].index{|item| item[0] == tga[1][ii][1]}\n tg[1].push(tga[1][ii])\n tga[1][ii] = nil\n end\n end\n tga[0].compact!\n tga[1].compact!\nend", "def tune_sliding_widow(datapoints)\n\n window_value = params[:parList][\"windowValue\"].to_i > 0 ? params[:parList][\"windowValue\"].to_i : 1;\n st_time, st_val = [],[];\n moving_sum, count = 0, 0;\n datapoints_tune = []\n\n for k in 0..datapoints.size-1\n if count < window_value and datapoints[k][\"Val\"] != nil\n moving_sum += datapoints[k][\"Val\"]\n st_time << datapoints[k][\"StartTime\"]\n st_val << datapoints[k][\"Val\"]\n count += 1 \n elsif datapoints[k][\"Val\"] != nil\n if datapoints_tune.size==0\n avg = moving_sum/window_value;\n final = st_time[st_time.size-1]\n datapoints_tune.push({\"StartTime\"=>final, \"Val\"=>avg, \"Total\"=>moving_sum})\n end\n moving_sum -= st_val.shift;\n st_val << datapoints[k][\"Val\"]\n moving_sum += datapoints[k][\"Val\"];\n avg = moving_sum/window_value;\n datapoints_tune.push({\"StartTime\"=>datapoints[k][\"StartTime\"], \"Val\"=>avg,\"Total\"=>moving_sum}) \n else\n datapoints_tune.push({\"StartTime\"=>datapoints[k][\"StartTime\"], \"Val\"=>nil,\"Total\"=>moving_sum})\n end\n end\n # Corner case, if window points is equal or larger than the size of total datapoints\n if datapoints_tune.size==0\n avg = moving_sum/window_value;\n final = st_time[st_time.size-1]\n datapoints_tune.push({\"StartTime\"=>final, \"Val\"=>avg,\"Total\"=>moving_sum})\n end\n return datapoints_tune\n end", "def add_edge(from_node, to_node)\n add_node(from_node)\n add_node(to_node)\n @nodes[from_node] << to_node\n @node_dir_ancestors[to_node] << from_node\n\n if self.has_cycle\n puts \"No longer DAG\"\n end\n end", "def add_edge(from, to)\n from.adjacents << to\n end", "def build_sketch_graph\n\t@temp_hop_record = Hash.new\n\t@processed_list = Hash.new\n\t$node_list.each do |n|\n\t\t#Nodes in sketched graph: queries, user_inputs\n\t\t#if n.getInstr.getFromUserInput or (n.isQuery? and n.isWriteQuery?) or (n.getInstr.instance_of?AttrAssign_instr and n.getInstr.getFuncname.index('!') == nil)\n\t\tif n.isQuery? #or n.getInstr.getFromUserInputor isTableAttrAssign(n) \n\t\t\tn.Tnode = TreeNode.new(n)\n\t\t\t$sketch_node_list.push(n.Tnode)\t\n\t\t\t@temp_hop_record[n] = Array.new\n\t\t\t@processed_list[n] = Array.new\n\t\t\t@temp_hop_record[n].push(n)\n\t\tend \n\tend\n\tfor i in 0...$node_list.length\n\t\tadded_edge = false\n\t\tno_changes = true\n\t\t$node_list.each do |n|\n\t\t\tif n.Tnode != nil\n\t\t\t\t@temp_hop_record[n].push(nil)\n\t\t\t\ttemp_node = @temp_hop_record[n].shift\n\t\t\t\tstep = 0\n\t\t\t\twhile temp_node != nil and step < 10000 do\n\t\t\t\t\tstep += 1\n\t\t\t\t\tno_changes = false\n\t\t\t\t\ttemp_node.getDataflowEdges.each do |e|\n\t\t\t\t\t\tif e.getToNode.Tnode != nil and e.getToNode != n\n\t\t\t\t\t\t\tif n.Tnode.hasChildren(e.getToNode.Tnode) == false and (n.getIndex < e.getToNode.getIndex)\n\t\t\t\t\t\t\t\tn.Tnode.addChildren(e.getToNode.Tnode, i)\n\t\t\t\t\t\t\t\t#puts \"\\tAdd edge: #{n.getIndex}:#{n.getInstr.toString} -> #{e.getToNode.getIndex}:#{e.getToNode.getInstr.toString}\"\n\t\t\t\t\t\t\t\tadded_edge = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tif e.getToNode != n \n\t\t\t\t\t\t\t\tif @processed_list[n].include?e\n\t\t\t\t\t\t\t\telsif e.getToNode.getIndex < e.getFromNode.getIndex #returnv\n\t\t\t\t\t\t\t\t\te.getToNode.getDataflowEdges.each do |e1|\n\t\t\t\t\t\t\t\t\t\tif e1.getToNode.getIndex > temp_node.getIndex\n\t\t\t\t\t\t\t\t\t\t\t@temp_hop_record[n].push(e1.getToNode)\n\t\t\t\t\t\t\t\t\t\t\t@processed_list[n].push(e1)\n\t\t\t\t\t\t\t\t\t\tend \n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t@temp_hop_record[n].push(e.getToNode)\n\t\t\t\t\t\t\t\t\t@processed_list[n].push(e)\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\tend\n\t\t\t\t\ttemp_node = @temp_hop_record[n].shift\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tif added_edge\n\t\t\t#puts \"iteration #{i} ||\"\n\t\tend\n\t\tif no_changes\n\t\t\tbreak\n\t\tend\n\tend\n=begin\n\tgraph_write($graph_file, \"digraph sketch {\\n\")\n\t$node_list.each do |n|\n\t\tif n.Tnode != nil\n\t\t\tif n.isQuery?\n\t\t\t\tcolor = \"blue\"\n\t\t\telsif n.getInstr.instance_of?AttrAssign_instr\n\t\t\t\tcolor = \"darkorange\"\n\t\t\telse\n\t\t\t\tcolor = \"crimson\"\n\t\t\tend\n\t\t\tgraph_write($graph_file, \"\\tn#{n.getIndex} [label=<<i>#{n.getIndex}__#{n.getInstr.toString2}</i>> color=#{color}]; \\n\")\n\t\t\tn.Tnode.children.each do |c|\n\t\t\t\tgraph_write($graph_file, \"\\tn#{n.getIndex} -> n#{c.node.node.getIndex} [label=\\\"#{c.dist}\\\"]\\n\")\n\t\t\tend\n\t\tend\n\tend\n\tgraph_write($graph_file, \"}\")\n=end\nend", "def add_to_graph\n connection.execute <<-EOS\n REPLACE INTO #{oqgraph_table_name} (origid, destid, weight) \n VALUES (#{self.send(self.class.from_key)}, #{self.send(self.class.to_key)}, #{self.send(self.class.weight_column) || 1.0})\n EOS\n end", "def add_edge!(from, to)\n protected_add_edge!(from, to)\n @edge_number += 1\n end", "def add_edge(from, to, weight = 1.0)\n\t\t\tadd_node(from)\n\t\t\tadd_node(to)\n\t\t\t@size += 1 if connect(from, to, weight)\n\t\t\tself\n\t\tend", "def build_edges(users, start_time, finish_time)\n users.each do |user|\n schedule = ModelFabric.get_class(SocialFramework.schedule_class).find_or_create_by(user_id: user.id)\n\n events = schedule.events_in_period(start_time, finish_time)\n i = 0\n\n @slots.each do |slot|\n if events.empty? or slot_empty?(slot, events[i])\n slot.add_edge(user)\n slot.attributes[:gained_weight] += user.attributes[:weight] if user.attributes[:weight] != :fixed\n end\n if not events.empty? and((slot.id + @slots_size).to_datetime >= events[i].finish.to_datetime)\n events.clear if events[i] == events.last\n i += 1\n end\n end\n end\n end", "def push(*xs)\n xs.each { |x| @nodes.push x }\n end", "def complete_weighted_bigraph(n)\n g = GraphMatching::Graph::WeightedBigraph.new\n max_u = (n.to_f / 2).ceil\n min_v = max_u + 1\n weight = 1\n 1.upto(max_u) do |i|\n min_v.upto(n) do |j|\n g.add_edge(i, j)\n g.set_w([i, j], weight)\n weight += 1\n end\n end\n g\nend", "def add_connections(start_cell, end_cell)\n start_cell.connected_cells.each do |cell|\n (@cells_to_visit << cell).sort_by! { |cell| cell.distance_to(end_cell) } unless cell_array_visited.include?(cell)\n end\n end", "def AddNodes(nodes)\n\tnodes.each do |n|\n\t\tn.id=@lastId\n\t\tDefineGroup(n)\n\t\t@lastId=@lastId+1\n\tend\n\treturn nodes\n end", "def sg_pad_ends(half_window)\n start = self[1..half_window]\n start.reverse!\n start.map! {|v| self[0] - (v - self[0]).abs }\n\n fin = self[(-half_window-1)...-1]\n fin.reverse!\n fin.map! {|v| self[-1] + (v - self[-1]).abs }\n start.push(*self, *fin)\n end", "def expand\n expanding_vertices, @apical_vertices, @dist_thresh = @apical_vertices.clone, [], @dist_thresh.next\n expanding_vertices.each {|vertex| merge_with_edges(generate_subgraph(vertex))}\n self\n end", "def dirgap( gap = @gap )\n if @pack == :d || @pack == :u\n Pos.set( 0, gap )\n else\n Pos.set( gap, 0 )\n end\n end", "def make_adjlists(layout)\n layout.each do |edge|\n start = edge.village1\n ending = edge.village2\n color = edge.color\n type = edge.type_transit\n layout.each do |surround| \n if surround.village1 == ending && surround.village2 != start\n if surround.color == color || surround.type_transit == type\n edge.add_adjlist(surround)\n end\n end\n end\n end\nend", "def addNodeAtPos(xml, toAdd, nodeOver)\n\n size = xml[\"childCount\"].to_i\n if(xml[\"nodeName\"] == nodeOver)\n\n xml[\"childCount\"] = size+1\n xml[size] = toAdd\n return\n end\n for j in 0..size\n\n values = xml[j]\n if(values[\"nodeName\"] == nodeOver)\n addNodeAtPos(values, toAdd, nodeOver)\n break\n else\n\n countVals = values[\"childCount\"].to_i\n for k in 0..countVals\n addNodeAtPos(values[k], toAdd,nodeOver)\n end\n end\n end\n end", "def new_generation\n neighbors_alive = 0\n new_generation = initiate_grid\n insert_to_temp\n @width.times do |x|\n @height.times do |y|\n neighbors_alive = get_neighbors_alive(x+1,y+1)\n apply_rules(x, y, neighbors_alive, new_generation)\n end\n end\n @generation += 1\n update_generation(new_generation)\n end", "def insert(node,path)\n if path[:edge_list].empty?\n path[:edge_list] << [node,node]\n else\n deleted_edge = path[:edge_list].min_by{|edge| distance(edge.first,node) + distance(node,edge.last) - distance(edge.first,edge.last)}\n deleted_distance = distance(deleted_edge.first,deleted_edge.last)\n path[:edge_list].delete(deleted_edge)\n path[:edge_list] << [deleted_edge.first,node]\n path[:edge_list] << [node, deleted_edge.last]\n path[:length] += (distance(deleted_edge.first,node) + distance(node,deleted_edge.last) - distance(deleted_edge.first,deleted_edge.last))\n end\n end", "def add_nodes(*nodes)\n @nodes.merge nodes\n end", "def merge_nodes(graph, x, y)\n new_edges = graph.neighbors(x).inject([]) do |new_edges, neighbor|\n graph.remove(x, neighbor)\n graph.remove(neighbor, x)\n new_edges << Edge.new(neighbor, y)\n end\n\n graph.each_edge{|edge| new_edges << edge }\n\n Graph.new(new_edges)\nend", "def place_nodes\n x = 0\n y = 0\n nodes = []\n\n 64.times do\n id = [x, y]\n\n nodes << Node.new(id)\n\n if y < 7\n y += 1\n else\n x += 1\n y = 0\n end\n end\n nodes\n end", "def add_edge(node)\n @adj_nodes.push(node.position)\n end", "def insertVertice(node, distance, predecessor)\n\t\t@graph << @vertice.new(node, distance, predecessor)\n\tend", "def insert(ary, low, right, gap)\n loc = low + gap\n\n while loc <= right\n i = loc - gap\n value = ary[loc]\n\n while i >= low && (cur_val = ary[i]) > value\n ary[i + gap] = cur_val\n i -= gap\n end\n\n ary[i + gap] = value\n loc += gap\n end\n end", "def add(*nodes)\n @nodes.push(*nodes)\n end", "def build_graph\n @matrix.each_with_index do |row, x|\n row.each_with_index do |move, y|\n move = Coordinate.new(x,y)\n @matrix[x][y] = possible_moves(move)\n end\n end\n\tend", "def minimum_spanning_tree(known_weights)\n starting_node = Node.new(nodes.first.label)\n tree = WeightedGraph.new([ starting_node ])\n \n candidates = nodes.first.connected_nodes.map { |n| [ nodes.first, n, n.distance_between(nodes.first) ] }\n \n while tree.nodes.length < nodes.length\n print \"#{tree.nodes.length} \" if tree.nodes.length % 10 == 0\n # Pick the first suitable edge\n next_edge = nil\n known_weights.each do |weight|\n next_edge = candidates.detect { |edge| edge.last == weight }\n break if next_edge\n end\n \n # Break it down\n connected_existing_node, connected_new_node, distance = next_edge \n \n # Add to the tree\n new_node = Node.new(connected_new_node) \n existing_node = tree.get_node(connected_existing_node)\n tree.nodes << new_node\n tree.connect!(existing_node, new_node, distance)\n \n # Remove edges that would now create cycles:\n dropping = tree.nodes.map do |node|\n connected_node = get_node(node)\n [ connected_node, connected_new_node, connected_new_node.distance_between(connected_node) ]\n end\n candidates -= dropping\n \n # Add unlocked edges:\n connected_new_node.connected_nodes.each do |node|\n candidates << [ connected_new_node, node, node.distance_between(connected_new_node) ] unless tree.nodes.index(tree.get_node(node))\n end \n end\n \n tree\n end", "def make_graph\r\n lines.each {|line, stations|\r\n stations.each_with_index {|x, index|\r\n unless stations.at(index+1).nil?\r\n graph.add_edge(find_node(x), find_node(stations.at(index+1)))\r\n end\r\n }\r\n }\r\n end", "def add_edge(s, t, w)\n\n if (not @graph.has_key? s)\n @graph[s] = {t => w}\n else\n @graph[s][t] = w\n end\n\n @nodes.merge [s,t]\n\n end", "def create_graph(arr)\n nodes = []\n (0...arr.size).each do |i|\n node = Node.new(i)\n nodes.push(node)\n end\n nodes.each_with_index do |node,i|\n arr[i].each {|val| node.connections.push(nodes[val])} \n end\n nodes\nend", "def create_graph(arr)\n nodes = []\n (0...arr.size).each do |i|\n node = Node.new(i)\n nodes.push(node)\n end\n nodes.each_with_index do |node,i|\n arr[i].each {|val| node.connections.push(nodes[val])} \n end\n nodes\nend", "def gap(g, inf, sup, generator = nil)\n #byebug\n generator.nil? ? gen = prime_range(inf) : gen = generator\n recent = gen.next\n gen.peek > sup ? (return nil) : current = gen.peek\n return [recent, current] if current - recent == g\n gap(g, inf, sup, gen)\nend", "def build_nodes!\n @nodes.sort_by(&:key).each { |node| add_node(@graph, node) }\n end", "def build_nodes!\n @nodes.sort_by(&:key).each { |node| add_node(@graph, node) }\n end", "def partition_edges\n\n par = RangePartition.new\n\n stateSet = @start_state.reachable_states\n\n stateSet.each do |s|\n s.edges.each {|lbl,dest| par.addSet(lbl) }\n end\n\n par.prepare\n\n stateSet.each do |s|\n newEdges = []\n s.edges.each do |lbl, dest|\n newLbls = par.apply(lbl)\n newLbls.each {|x| newEdges.push([x, dest]) }\n end\n s.clearEdges()\n\n newEdges.each do |lbl,dest|\n s.addEdge(lbl,dest)\n end\n end\n\n end", "def AddLinksInRange(range)\n\t\tputs(\"Adding links in range\")\n\t\[email protected] do |x|\n\t \t\[email protected] do |y|\n\t\t \t\tif (x.id!=y.id and Distance(x,y)<=range)\n\t\t \t\t\tputs(\"Adding link between node #{x.id} and node #{y.id}\")\n\t\t\t\t\t@links << Link.new(x,y, @rate)\n\t\t \t\tend\t\n\t\t\tend\n\t\tend \n\n\tend", "def insert(intervals, new_interval)\n intervals << new_interval\n intervals.select { |x| x.end < new_interval.start } +\n [intervals.select { |x| overlaps?(x, new_interval) }.reduce { |acc, x|\n Interval.new([acc.start, x.start].min, [acc.end, x.end].max)\n }] +\n intervals.select { |x| new_interval.end < x.start}\nend", "def add_location(source, target, weight)\n connect_graph(source, target, weight) #directional graph\n connect_graph(target, source, weight) #non directed graph (inserts the other locations too)\n end", "def create_list\n list = SinglyLinkedList.new\n list.insert_at_start 1\n list.insert_at_start 2\n list.insert_at_start 3\n list.insert_at_end 4\n list.insert_at_start 4\n list.insert_at_end 5\n list\nend", "def sg_pad_xvals(array, half_window)\n deltas = array[0..half_window].each_cons(2).map {|a,b| b-a }\n start = array[0]\n prevals = deltas.map do |delta|\n newval = start - delta\n start = newval\n newval\n end\n prevals.reverse!\n\n deltas = array[(-half_window-1)..-1].each_cons(2).map {|a,b| b-a }\n start = array[-1]\n postvals = deltas.reverse.map do |delta|\n newval = start + delta\n start = newval\n newval\n end\n\n prevals.push(*array, *postvals)\n end", "def insert_gaps_between( features )\n features_with_gaps = []\n gap_feature = AlleleImage::Feature.new( Bio::Feature.new( \"misc_feature\", \"1..1\" ).append( Bio::Feature::Qualifier.new( \"note\", \"gap\" ) ) )\n\n return features_with_gaps if features.nil?\n\n features.each_index do |current_index|\n features_with_gaps.push( features[current_index] )\n next_index = current_index + 1\n unless features[next_index].nil?\n consecutive_names = [ features[current_index].feature_name, features[next_index].feature_name ]\n consecutive_types = [ features[current_index].feature_type, features[next_index].feature_type ]\n if consecutive_names.include?(\"loxP\") ||\n consecutive_names.include?(\"FRT\") ||\n consecutive_names.include?(\"Rox\") ||\n consecutive_names.include?(\"F3\") ||\n consecutive_names.include?(\"AttP\") ||\n consecutive_names.include?(\"intervening sequence\") ||\n consecutive_types.include?(\"exon\")\n features_with_gaps.push( gap_feature )\n end\n end\n end\n\n return features_with_gaps\n end", "def add_edge(src, dest, weight)\n @v << src if [email protected]?(src)\n @v << dest if [email protected]?(dest)\n new_edge = Edge.new(src,dest, weight)\n src.out_edges << new_edge\n dest.in_edges << new_edge\n @e << new_edge\n end", "def append_edge(edge)\n @meeting_edges << edge\n end", "def generate_adjacencies(board)\n b2 = duplicate(board)\n b2.each_with_index do |row, y_idx|\n row.each_with_index do |cell, x_idx|\n next unless cell == MINE\n increment_neighbors(b2, [x_idx, y_idx])\n end\n end\nend", "def add_edge(x, y)\n if([email protected]_key?(x)) then \n @g[x] = []\n end\n if(!@g[x].include? y) then\n @g[x] << y\n end\nend", "def to_directed_graph(adapters)\n node_paths = {}\n adapters.each do |node|\n node_paths[node] = adapters.select{|other_node| other_node.between?(node+1, node+3)}\n end\n node_paths\nend", "def attach_graph(attach_point, fsm)\r\n node_count = get_node_count\r\n raise \"#{attach_point} out of graph bounds.\" if attach_point >= node_count\r\n raise \"going to break everything by attaching to myself!\" if fsm == self\r\n #dfa = fsm.subsetify #.subsetify\r\n dfa = fsm # Before, we were subsetifying\r\n dfa.increment_node_labels(node_count)\r\n #@graph_hash[attach_point] = {LAMBDA => dfa.origin} # THIS IS OUR CULPRIT!\r\n #puts \"before #{@graph_hash[attach_point]}\"\r\n \r\n #if (@graph_hash[attach_point]!=nil)\r\n # lambdas = [@graph_hash[attach_point][LAMBDA]] || [] # this is an array!\r\n # lambdas << dfa.origin\r\n # lambdas = lambdas.flatten.find{|entry| !entry.nil?}\r\n # @graph_hash[attach_point][LAMBDA] = lambdas\r\n #else\r\n # @graph_hash[attach_point] = {LAMBDA => dfa.origin}\r\n #end\r\n\r\n # if attach point was on the graph w/o outgoing edges\r\n @graph_hash[attach_point] = Hash.new if @graph_hash[attach_point].nil?\r\n \r\n if @graph_hash[attach_point][LAMBDA].nil?\r\n @graph_hash[attach_point][LAMBDA] = [dfa.origin]\r\n else # attach point already has outgoing lambda edges\r\n @graph_hash[attach_point][LAMBDA] << dfa.origin\r\n end\r\n \r\n #@graph_hash[attach_point][\"foo\"] = lambdas\r\n #puts \"after #{@graph_hash[attach_point]}\"\r\n #puts \"@gh = #{graph_hash}\\ndfah = #{dfa.graph_hash}\"\r\n #puts \"merged: #{@graph_hash.merge(dfa.graph_hash)}\"\r\n @graph_hash.merge!(dfa.graph_hash)\r\n #@graph_hash.merge!({4=>{\"L\"=>21}})\r\n @accept_states.merge!(dfa.accept_states)\r\n #subsetify!\r\n get_node_count\r\n end", "def add_edge(node, weight)\n @adjacent_nodes[node.value] = { weight: weight, node: node }\n self\n end", "def growing\n new_outer_nodes = []\n @outer_nodes.each do |o_n|\n new_partial_outer_nodes = set_outer_nodes(@neighbors_hash[o_n])\n new_outer_nodes << check_partial_outer_nodes(new_partial_outer_nodes, o_n)\n new_outer_nodes.flatten!\n end\n @outer_nodes = new_outer_nodes.compact\n end", "def add_edge(a,b)\n @adj_list[a][b] = 1\n end", "def enqueue_neighbours(n, m, d)\n get_neighbours(n, m).each do |vertex|\n if blank?(vertex)\n graph[*vertex] = VISITED\n queue << [vertex, d] \n end\n end\n end", "def push(node)\n new_index = (@nodeset << node).length - 1\n heapify_up new_index\n self\n end", "def build_graph(node = @root)\n node.make_knights(@target)\n if node.connected_knights.empty?\n return\n else\n node.connected_knights.each do |knight|\n build_graph(knight)\n end\n end\n end", "def add_edge( from_key, to_key, weight = 0 )\n add_vertex(from_key) unless @vertices.include? from_key\n add_vertex(to_key) unless @vertices.include? to_key\n @vertices[from_key].add_neighbor( @vertices[to_key], weight )\n end", "def add_edge(source, dest, weight)\n edges << Edge.new(source, dest, weight)\n end", "def insert(intervals, new_interval)\r\n left, right = [], []\r\n intervals.each do |i_start, i_end|\r\n # Left\r\n if i_end < new_interval[0]\r\n left << [i_start, i_end]\r\n # Right\r\n elsif i_start > new_interval[1]\r\n right << [i_start, i_end]\r\n elsif \r\n new_interval[0] = [new_interval[0], i_start].min\r\n new_interval[1] = [new_interval[1], i_end].max\r\n end\r\n end\r\n\r\n left + [new_interval] + right\r\nend", "def generate_arr_of_all_combinations(start_range, end_range, gap)\n combinations = []\n\n start_range.upto(end_range - gap) do |x|\n x.upto(end_range) do |y|\n next if (x + gap) > y\n combinations.push([x, y])\n end\n end\n\n combinations\nend", "def addNodeStartingAt(xml, toAdd, toStartAt, nodeName)\n\n count = 0\n size = xml[\"childCount\"].to_i\n for j in 0..size\n\n values = xml[j]\n if(values[\"nodeName\"] == toStartAt)\n addNodeAtPos(values,toAdd,nodeName)\n else\n countVals = values[\"childCount\"].to_i\n for k in 0..countVals\n addNodeStartingAt(values[k], toAdd,nodeName,toStartAt)\n end\n end\n end\n end", "def make_blank_graph\n ISSUE_NAMES.each_with_index {|name, i| @nodes[i] = Graph::Node.new(i, name, \"\") unless name.blank? }\n\n #testing\n #@edges[1] = Graph::Edge.new(1, @nodes[0], @nodes[3], MapvisualizationsHelper::INCREASES)\n\n @nodes[START].location = Vector[(@width-200)/2, @height/2] #pull out Menhaden Population and center\n grid_nodes_in_box(@nodes.reject{|k,v| k==START},Vector[@width-200+50, 130],Vector[200, @height-130+50]) #hard-coded starting box\n end", "def create_list arr\n list = SinglyLinkedList.new\n arr.each do |i|\n list.insert_at_end i\n end\n list\nend", "def create_list arr\n list = SinglyLinkedList.new\n arr.each do |i|\n list.insert_at_end i\n end\n list\nend", "def create_list arr\n list = SinglyLinkedList.new\n arr.each do |i|\n list.insert_at_end i\n end\n list\nend", "def maze_maker number_of_nodes\n return_maze = Hash.new{ |h, k| h[k] = [] }\n\n nodes = gen_first_path number_of_nodes\n\n nodes.each do |k, v|\n return_maze[k] = add_nodes_to_node(return_maze, k, 4, nodes)\n end\n\n end_marker return_maze\n\n return_maze\nend", "def generate_graph\n end", "def pad!(min_size, value = nil)\n spaces = min_size - self.length\n spaces.times do \n self.push(value)\n end\n self\nend", "def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end", "def insert_between(s1, s2, add=false)\n if not add\n if s1 and s2\n StorylineLinks.where('from_id = ? AND to_id = ?', s1, s2).update_all(:to_id => self.id)\n elsif s1\n insert_after(s1, add)\n elsif s2\n insert_before(s2)\n end\n else\n StorylineLinks.new(:from_id => s1.id, :to_id => self.id).save if s1\n end\n StorylineLinks.new(:from_id => self.id, :to_id => s2.id).save if s2\n end", "def remove_preceding(node_or_range, size); end", "def insert_next prev_node, data\n\t\tnew_node = Node.new data\n\t\tif self.length == 0\n\t\t\tself.head = new_node.next = new_node\n\t\telse\n\t\t\tnew_node.next = prev_node.next\n\t\t\tprev_node.next = new_node\n\t\tend\n self.length += 1\n \n new_node\n\tend", "def insert_at(node, index)\n target = self.at(index)\n target_prev = target.prev\n set_next_and_prev(target_prev, node)\n set_next_and_prev(node, target)\n self.size += 1\n end", "def add_edge(element1, element2)\n index1 = self.dict[element1]\n index2 = self.dict[element2]\n raise Exception.new(\"Nodes not exist!\") unless index1 && index2\n\n head_node2 = self.adj_list_array[index2].head_node\n new_node1 = Node.new(element1, head_node2.next_node)\n head_node2.next_node = new_node1\n\n\n head_node1 = self.adj_list_array[index1].head_node\n new_node2 = Node.new(element2, head_node1.next_node)\n head_node1.next_node = new_node2\n\n self\n end", "def expand\n @state.neighbors.map{|n|\n AStarNode.new(n, self)\n }\n end", "def add_edge(source_vertex, destination_vertex)\n @adjacent_list[source_vertex].push(destination_vertex)\n @indegree[destination_vertex] += 1\n end", "def add_edge(id1, id2)\n # YOUR WORK HERE\n end", "def gap(g, m, n)\n (m..n).each do |i|\n next unless is_prime(i)\n return [i, i+g] if is_prime(i+g) && (i+1..i+g-1).none? { |num| is_prime num }\n end\n nil\nend", "def generate_nodes!\n 7.times do |index|\n game.nodes.create(\n position: index,\n land_ids: land_ids_for_node(index)\n )\n end\n end", "def insert_next prev_node, data\n\t\tnew_node = Node.new data\n\t\tif self.length == 0\n\t\t\tself.head = new_node.next = new_node\n\t\telse\n\t\t\tnew_node.next = prev_node.next\n\t\t\tprev_node.next = new_node\n\t\tend\n\t\tself.length += 1\n self.hash[data] = new_node\n new_node\n\tend", "def build_paths(start)\n step = 0\n visited = []\n unvisited = [[board_node_by_location(start),step]]\n \n while !unvisited.empty?\n node = unvisited[0][0]\n step = unvisited[0][1] + 1\n \n node.neighbors.each do |x|\n if not_visited(board_node_by_location(x),visited, unvisited)\n unvisited << [board_node_by_location(x),step]\n end\n end\n visited << unvisited.shift\n end\n return visited\nend", "def make_nodes(nodes = [])\n positions = []\n (0..7).each {|x| (0..7).each {|i| positions << [x,i] }}\n \n positions.each do |x|\n nodes << Node.new(x)\n end\n nodes\nend", "def inject_graph_values!\n end", "def burst!(times)\n @burst_length += times\n end", "def concat(nodes); end", "def add_node(n)\n @nodes.push n unless @nodes.include? n\n end", "def connect(params)\n order = params[:order]; from = params[:from]; to = params[:to]\n\n if to.kind_of?(Enumerable)\n to.each do |singularized_to|\n connect :from => from, :to => singularized_to, :order => order\n end\n else\n edges.add(from, to, order)\n end\n end", "def create_sub_graph(spec_edges, move_dist = nil)\n # declare locals\n time = Time.now\n m = $game_map\n map_width,map_height = m.width, m.height\n MoveUtils.init_ev_passables\n \n if !move_dist\n dist = spec_edges[:move] ||= TactBattleManager::Defaults::Move\n else\n dist = move_dist\n end\n \n x_low = x_high = y_low = y_high = nil\n if @source\n x_low, x_high = [@source.x-dist, 0].max, [@source.x+dist,map_width-1].min\n y_low, y_high = [@source.y-dist, 0].max, [@source.y+dist,map_height-1].min \n else\n x_low, x_high = 0, [dist,map_width-1].min\n y_low, y_high = 0, [dist,map_height-1].min\n end\n \n @jump_time = 0\n @optim_cache = {}\n x_low.upto(x_high).each do |x|\n y_low.upto(y_high).each do |y|\n expand_graph_adj(v=Vertex.new(x,y, m.terrain_tag(x,y)), spec_edges[:pass])\n add_adjacent_jumpables(v.x,v.y,dist,spec_edges)if spec_edges[:jump_length]>0\n end\n end\n self\n end", "def remove_leading(node_or_range, size); end", "def populate_inbound_archs\n new_vertices = []\n @a.each do |key, value|\n value[0].each do |vertex|\n # puts vertex\n # @a[vertex].insert(1, Array.new()) if @a[vertex][1] == false\n if @a[vertex]\n @a[vertex][1] << key\n # puts @a[vertex].inspect\n else\n # puts \"detected alone vertex '#{vertex}'\"\n new_vertices << [vertex, [[], [key], false]]\n end\n end\n end\n new_vertices.each do |data|\n @a[data[0]] = data[1]\n end\n end", "def insert_at(i,data)\n if i<0 || i>= @size\n \treturn nil\n end\n node=Node.new\n node.value=data\n if i==0\n \tnode.next_node=@root\n \t@root=node\n else\n pre_node=at(i-1)\n node.next_node=pre_node.next_node\n pre_node.next_node=node\n end\n @size+=1\n end" ]
[ "0.552551", "0.552551", "0.5385118", "0.4994156", "0.49828216", "0.49427024", "0.4939581", "0.48757485", "0.48162365", "0.47926322", "0.47401768", "0.47324634", "0.47183073", "0.4689046", "0.46799418", "0.46649724", "0.4655176", "0.4638918", "0.46381128", "0.46278125", "0.4623478", "0.461035", "0.46077645", "0.45983642", "0.45734474", "0.4523504", "0.45208448", "0.4509837", "0.44841835", "0.44736445", "0.44725856", "0.44634333", "0.44338107", "0.44300342", "0.44273505", "0.4396216", "0.43943432", "0.43723914", "0.4365131", "0.4361696", "0.43477303", "0.4346", "0.4346", "0.4345943", "0.4333916", "0.4333916", "0.43336564", "0.43299046", "0.43265086", "0.431814", "0.43107387", "0.4305607", "0.4304083", "0.4290753", "0.42894936", "0.4286605", "0.4284778", "0.42847207", "0.42770436", "0.42647284", "0.42631304", "0.4257366", "0.42558607", "0.4241959", "0.42374992", "0.42334795", "0.4232358", "0.4223441", "0.4222814", "0.42215106", "0.4211982", "0.42112005", "0.42112005", "0.42112005", "0.42108595", "0.42107767", "0.42062512", "0.4205516", "0.42050183", "0.41995057", "0.41916835", "0.41849226", "0.41779935", "0.41773582", "0.41749728", "0.41731846", "0.41699952", "0.41673732", "0.4163778", "0.41636375", "0.41624522", "0.41622895", "0.41535884", "0.41457048", "0.4138449", "0.41363198", "0.41335717", "0.41332978", "0.41330996", "0.4132139" ]
0.6652222
0
Find a node and return it, or add it if needed
def find_or_add_node(id, word) node = find_node(id: id) if node node.words << word unless node.words.include?(word) node else nodes << Node.new(id: id, words: [word]) nodes.last end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_node(*args)\n node = @nodes.find_node(*args)\n node if context?(node)\n end", "def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end", "def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end", "def add_or_find_duplicate(node)\n @nodes[node.path] ||= node\n @nodes[node.path]\n end", "def find(needle)\n #return the Node object whose value == needle\n node = @head\n while node\n return node if node.value == needle\n node = node.next\n end\n #Return nil if cannot find it\n nil\n end", "def find(id)\n node = @nodes[id]\n return node if node\n\n addr = Directory[id]\n return unless addr\n\n if id == DCell.id\n node = DCell.me\n else\n node = Node.new(id, addr)\n end\n\n @nodes[id] ||= node\n @nodes[id]\n end", "def find_node(op=nil)\n visit_nodes do |node|\n if !op || node.op == op\n if !block_given? || yield(node)\n return node\n end\n end\n end\n end", "def find_node(*args)\n nodes = find_all_nodes(*args)\n raise AmbiguousNode if nodes.size > 1\n nodes.first\n end", "def node(name)\n return node_manager.find(name)\n end", "def node(node_name)\n nodes(node_name).first\nend", "def find(value)\n self.each {|node| return node if node.value == value}\n end", "def find(needle) # returns the node with value=value or nil if not found\n next_node = @head\n while next_node && next_node.needle != needle\n next_node = next_node.next\n end\n next_node\n end", "def get_node(object)\n @nodes.each do |node|\n return node if node.object == object\n end\n end", "def find_node(value)\n current = @anchor.next_node\n while current != @anchor\n return current if current.value == value\n current = current.next_node\n end\n end", "def find_node(node_number)\n @_node_map[node_number]\n end", "def node_by_id(id)\r\n @nodes.each do |n|\r\n return n if n.attributes['id'] == id \r\n end\r\n end", "def find_node(calling_node, key)\n @router.touch(calling_node)\n return @router.get_closest_nodes(key)\n end", "def find(key, node = root)\n return nil if node.nil?\n if key == node.data\n return node\n else\n find(key, left_right(key, node))\n end\n end", "def find_node(heads, node_tag, parent_tag = nil)\n heads.flat_map { |item, head| head.nodes.to_a }.find do |node|\n node.to_s == node_tag && (parent_tag.nil? || node.parent.to_s == parent_tag)\n end\n end", "def deep_find\n ([self] + all_subtrees.to_a).each do |node|\n return node if yield(node)\n end\n nil\n end", "def find_node_by_name(name)\n @nodes[name]\n end", "def find(value)\n node = @head\n while node\n if node.value == value\n return node\n end\n node = node.next\n end\n\n return nil\n end", "def find(key)\n find_node(checked_get_node(key))\n end", "def depth_first(value_to_find)\r\n @children.each do |child|\r\n found_node = child.depth_first(value_to_find)\r\n if found_node != nil\r\n return found_node\r\n end\r\n end\r\n\r\n if payload == value_to_find\r\n return self\r\n else\r\n return nil\r\n end\r\n end", "def find_node(key)\n return nil if @root == nil\n node = @root.find_vertical(key)\n (node.nil? || node.value.nil? ? nil : node)\n end", "def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end", "def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end", "def nodeWithID(pageID, node)\n if node.pageID == pageID\n return node\n end\n node.childNodes.each do |childNode|\n res = nodeWithID(pageID, childNode)\n if res\n return res\n end\n end\n return nil\nend", "def find_node ast, klass\n ast.find {|n| n.content.class == klass }\nend", "def find_node(nd_name)\n chef_nodes.find{|nd| nd.name == nd_name }\n end", "def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end", "def find(el)\n BinarySearchTree.find!(@root, el)\n end", "def find(value)\n current_node = head\n while current_node != nil\n return current_node if current_node.value == value\n current_node = current_node.next\n end\n nil\n end", "def find(key)\n if root.nil?\n return nil\n else\n root.find(key)\n end\n end", "def find(key)\n current_node = @root \n return find_helper(current_node, key)\n end", "def get_node(node)\n\t\t\t@nodes[node]\n\t\tend", "def node(path)\n current_nodes = root_nodes\n matching_node = nil\n path.each_with_index do |target_node, index|\n case current_nodes\n when Array\n matching_node = current_nodes.find {|node| node.name == target_node} #TODO: make this work with regexes as well as strings...\n raise Bewildr::ElementDoesntExist if matching_node.nil?\n when Bewildr::Element\n if current_nodes.name == target_node #TODO: make this work with regexes as well as strings...\n matching_node = current_nodes\n else\n raise Bewildr::ElementDoesntExist\n end\n end\n raise Bewildr::ElementDoesntExist if matching_node.nil?\n if path.size != index + 1\n matching_node.expand\n load_all_items_hack\n current_nodes = matching_node.child_nodes\n end\n end\n return matching_node\n end", "def find(value, node = root)\n return node if node.nil? || node.data == value\n \n value < node.data ? find(value, node.left) : find(value, node.right)\n end", "def find (data)\n current_node = @head\n\n while current_node\n return current_node if current_node.data == data\n current_node = current_node.next\n end\n\n return nil\n end", "def find_node(index)\n counter = 0\n current_node = @first\n while counter < index \n current_node = current_node.next_node\n counter += 1\n end\n current_node\n\n end", "def find(key)\n # If we are already on nil, just add it here\n return nil if @root.nil?\n #Return the root value if it is the value we are looking for\n return @root.value if @root.key == key\n #Otherwise, call in reinforcements\n return find_helper(@root, key)\n end", "def search_node(ip)\n found = nil\n @known_nodes.each do |node|\n if node.is_you? ip\n found = node\n end\n end\n return found\n end", "def find_node(target)\n if @num_nodes == 0\n return nil\n else\n current = 0\n current_node = @head\n while current < @num_nodes\n if current_node.get_Data() == target\n return current, current_node\n end\n \n current_node = current_node.get_Next()\n current += 1\n end\n return nil\n end\n end", "def find(selector)\n nodes = @_node.getByXPath(selector).map { |node| Node.new(node) }\n @nodes << nodes\n nodes\n end", "def find_node(index)\n\n\t\t#start at the head\n\t\tcounter = 0\n\t\tcurrent_node = @head\n\n\t\t# crawl to index position\n\t\t# outputs each node value for visibility\n\t\twhile counter < index\n\t\t\tcurrent_node = current_node.next\n\t\t\tcounter += 1\n\t\tend\n\n\t\tputs \"Found node at index #{index} with value: #{current_node.data}\"\n\t\tcurrent_node\n\tend", "def find_node(options)\n options[:id] = options.delete(:stem) if options[:stem]\n\n unless options[:word] || options[:id]\n raise ArgumentError, 'no find option specified'\n end\n\n if options[:word]\n word = options[:word].mb_chars.downcase.to_s\n nodes.find do |n|\n n.words.include?(word)\n end\n else\n id = options[:id].mb_chars.downcase.to_s\n nodes.find do |n|\n n.id == id\n end\n end\n end", "def lookup_node(request_path)\n\t\t\tname = request_path.last\n\t\t\tname_xnode = name.to_s + XNODE_EXTENSION\n\n\t\t\tnode_path = File.join(@root, request_path.dirname.components, name_xnode)\n\n\t\t\tif File.exist? node_path\n\t\t\t\treturn Node.new(self, request_path.dirname + name, request_path, node_path)\n\t\t\tend\n\n\t\t\treturn nil\n\t\tend", "def find(word, node = @root)\n new_node = nil\n word.each_char do |char|\n new_node = node.find_child_node(char)\n if new_node == nil\n return nil\n end\n node = new_node\n end\n node\n end", "def lookup_node_by_hw_id(options = { :hw_id => [] })\n unless options[:hw_id].count > 0\n return nil\n end\n matching_nodes = []\n nodes = get_data.fetch_all_objects(:node)\n nodes.each do\n |node|\n matching_hw_id = node.hw_id & options[:hw_id]\n matching_nodes << node if matching_hw_id.count > 0\n end\n\n if matching_nodes.count > 1\n # uh oh - we have more than one\n # This should have been fixed during reg\n # this is fatal - we raise an error\n resolve_node_hw_id_collision\n matching_nodes = [lookup_node_by_hw_id(options)]\n end\n\n if matching_nodes.count == 1\n matching_nodes.first\n else\n nil\n end\n end", "def find_node_at(index)\n current_index = 0\n node = @head\n until current_index == index\n puts current_index\n node = node.next\n current_index += 1\n end\n puts \"returning node at #{current_index}\"\n node\n end", "def get_node_by_name(str)\n self.each_node do |node|\n if get_node_name(node) == str\n return node\n end\n end\n nil\n end", "def find_node(results, node_name)\n document = ::Nokogiri::XML(results.body)\n document.remove_namespaces!\n document.xpath(\"//#{node_name}\").first\n end", "def find(value, current_index = 0, node = @head)\n return nil if node.nil?\n return current_index if node.value == value\n\n find(value, current_index + 1, node.next_node)\n end", "def find value, root_node=@root\n case value <=> root_node.data\n when -1\n find(value, root_node.left)\n when 1\n find(value, root_node.right)\n when 0\n return root_node\n else\n return\n end\n end", "def get_node\n # @@neo = Neography::Rest.new\n begin\n # qur = \"MATCH (n {object_id: \"+self.id.to_s+\", object_type: \\'\"+self.class.to_s+\"\\' }) RETURN n LIMIT 1\"\n # response = @@neo.execute_query(qur)\n # node_id = response[\"data\"].flatten.first[\"metadata\"][\"id\"]\n node_id = self.get_node_id\n node = (node_id ? Neography::Node.load(node_id, @@neo) : nil)\n return node\n rescue Exception\n return nil\n end\n end", "def get_node(id)\n get_object('node', id)\n end", "def get_node_by_name(name, options={})\n options[:exactget] ||= {}\n options[:exactget][:name] = name\n ret = get_nodes(options)\n if ret.empty?\n warn \"Cannot find node #{name}\"\n ret = nil\n elsif ret.values.size == 1\n ret = ret.values[0]\n else\n raise \"Multiple nodes returned for #{name}\"\n end\n ret \n end", "def find(key)\n if @root.nil?\n return nil\n elsif @root.key == key\n return @root.value\n else\n find_helper(@root, key)\n end\n end", "def find(root, data)\n return unless root && data \n if root.title != data\n target ||= self.find(root.right, data)\n return target if target\n target ||= self.find(root.left, data)\n else\n return root\n end\n end", "def board_node_by_location(location)\n $board.each { |x| return x if x.location == location }\n return nil\nend", "def fetch_node(key)\n node = fetch_node_nt(key)\n raise unless node\n node\n end", "def find(val)\n return val if root?(val)\n parent[val] = find parent[val]\n end", "def find_node(root,path)\n name_array = path.split('.')\n node = root[name_array[0]]\n name_array.each do |n|\n node.children.each do |c|\n if c.name == n\n node = c\n break\n end\n end\n end\n node\n end", "def find(identifier)\n # start at the begining of the list\n current = @first_node\n previous = @first_node\n \n if not list_empty?\n while current.identifier != identifier \n # advance the node one along\n previous = current\n current = current.next \n\n # we need to exit the while loop if the next node is nil\n # as the list has reached the end of the line\n return nil if (current == nil) \n end\n\n # we want to yield the previous and current pointer if a block is\n # given so that we cna toy around with indexing and identifiers\n yield(previous, current) if block_given?\n \n # return the current node as we have a hit\n return current\n end\n end", "def find(root, data)\n return if data == nil || root == nil\n\n if root.title == data\n @searched_node = root\n end\n\n if root.left\n find(root.left, data)\n end\n if root.right\n find(root.right, data)\n end\n\n return @searched_node\n end", "def find(value)\n return nil if @head.nil?\n found = nil\n index = 0\n current_node = @head\n while !node.nil? do\n if node.data == value\n found = true\n break\n end\n index += 1\n current_node = node.next\n end\n found == true ? \"#{value} found at index #{index}!\" : nil\n end", "def find(key)\n return nil if @root.nil?\n return find_helper(@root, key)\n end", "def get_node_by_id(id, options={})\n options[:exactget] ||= {}\n options[:exactget][:id] = id.to_s\n ret = get_nodes(options)\n if ret.empty?\n warn \"Cannot find node #{name}\"\n ret = nil\n elsif ret.values.size == 1\n ret = ret.values[0]\n else\n raise \"Multiple nodes returned for #{name}\"\n end\n ret\n end", "def find_node(node, type, first, last, depth: 0)\n child_nodes = node.children.select { |c| c.is_a?(RubyVM::AbstractSyntaxTree::Node) }\n # @logger.debug(\"D: #{depth} #{node.type} has #{child_nodes.size} children and spans #{node.first_lineno}:#{node.first_column} to #{node.last_lineno}:#{node.last_column}\")\n\n if node.type == type && first >= node.first_lineno && last <= node.last_lineno\n return node\n end\n\n child_nodes.map { |n| find_node(n, type, first, last, depth: depth + 1) }.flatten\n end", "def find_node(search_key)\n x = @header\n @level.downto(0) do |i|\n #puts \"on level #{i}\"\n while x.forward[i] and x.forward[i].key < search_key\n #puts \"walked node #{x.key} on level #{i}\"\n x = x.forward[i]\n end\n end \n x = x.forward[0] if x.forward[0].key == search_key\n return x\n end", "def find_next node\r\n return if node == nil\r\n\r\n if node.left != nil\r\n return node.left\r\n end\r\n\r\n node.right\r\nend", "def get_or_create_node(conn, index, value)\n # look for node in the index\n r = conn.get(\"/db/data/index/node/#{index}/name/#{CGI.escape(value)}\")\n node = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n unless node\n # no indexed node found, so create a new one\n r = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => value}), HEADER)\n node = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n # add new node to an index\n node_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\",\n \\\"value\\\" : \\\"#{CGI.escape(value)}\\\"}\"\n conn.post(\"/db/data/index/node/#{index}\", node_data, HEADER)\n end\n node\nend", "def breadth_first(value_to_find)\r\n current_node = self\r\n queue = MyQueue.new \r\n\r\n while current_node != nil\r\n if current_node.payload == value_to_find\r\n return current_node\r\n end\r\n current_node.children.each do |child|\r\n queue.enqueue(child)\r\n end\r\n current_node = queue.dequeue\r\n end\r\n end", "def get_or_create_node(conn, index, value)\n # look for node in the index\n r = conn.get(\"/db/data/index/node/#{index}/name/#{CGI.escape(value)}\")\n node = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n unless node\n # no indexed node found, so create a new one\n r = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => value}), HEADER)\n node = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n # add new node to an index\n node_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \n \\\"key\\\" : \\\"name\\\", \n \\\"value\\\" : \\\"#{CGI.escape(value)}\\\"}\"\n conn.post(\"/db/data/index/node/#{index}\", node_data, HEADER)\n end\n node\nend", "def find(value, node = @root)\n if node.nil?\n return nil\n end\n\n if value < node.value\n return find(value, node.left_node)\n elsif value > node.value\n return find(value, node.right_node)\n else\n return node\n end\n end", "def find(value, current_node = root)\n return current_node if current_node.nil? || current_node.value == value\n value < current_node.value ? find(value, current_node.left) : find(value, current_node.right)\n\n end", "def find(root, data)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n return node if node.title == data\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\n\n end", "def find(key)\n return find_helper(@root, key)\n end", "def find(key)\n return find_helper(@root, key)\n end", "def find(key)\n return find_helper(@root, key)\n end", "def find(key)\n return find_helper(@root, key)\n end", "def find(key)\n return find_helper(@root, key)\n end", "def get_node(node,path)\n name = path.split(\"/\")[0]\n rest = path.split(\"/\")\n rest.delete(name)\n rest = rest.join(\"/\")\n node.each_element do |element|\n if element.name == name\n if rest == \"\"\n return element\n else\n return get_node(element,rest)\n end\n end\n end\n end", "def find_node(value)\n return false if @head.nil?\n curr_node = @head\n match = false\n while curr_node\n break if match = (curr_node.value == value)\n curr_node = curr_node.next\n end\n\n match\n end", "def get_node(locator)\n return nil if @dirties > 0\n case locator\n when /^id=/, /^name=/\n locator = locator.gsub(\"'\",\"\\\\\\\\'\").gsub(/([a-z]+)=([^ ]*) */, \"[@\\\\1='\\\\2']\")\n locator = locator.sub(/\\]([^ ]+) */, \"][@value='\\\\1']\")\n return @studied_page.at_xpath(\"//*#{locator}\")\n when /^link=/\n # Parse the link through loc (which may simplify it to an id or something).\n # Then try get_studied_node again. It should not return to this spot.\n return get_node(loc(locator[5,locator.length], 'link'))\n when /^css=/\n return @studied_page.at_css(locator[4,locator.length])\n when /^xpath=/, /^\\/\\//\n return @studied_page.at_xpath(locator.sub(/^xpath=/,''))\n when /^dom=/, /^document\\./\n # Can't parse dom=\n return nil\n else\n locator = locator.sub(/^id(entifier)?=/,'')\n retval = @studied_page.at_xpath(\"//*[@id='#{locator}']\")\n retval = @studied_page.at_xpath(\"//*[@name='#{locator}']\") unless retval\n return retval\n end\n end", "def find_node(node_name)\n puts \"*\"*80\n raise(Thor::Error, \"Node not specified.\") if node_name.nil? || node_name.empty?\n return {node_name => nodes_in_stage[node_name]} if nodes_in_stage[node_name]\n puts \"-\"*80\n nodes_in_stage.each do |key, value|\n puts key\n return {key => value} if key.start_with?(node_name)\n end\n raise(Thor::Error, \"Not found: #{node_name} in #{stage_name}.\")\n end", "def find(value)\n node = @head \n for i in 0..@size-1 \n return i if node.value == value\n node = node.link \n end\n return nil\n end", "def find(root, data)\n current_node = root\n if current_node.title == data\n return current_node\n elsif current_node.left != nil\n find(current_node.left, data)\n elsif current_node.right != nil\n find(current_node.right, data)\n end\n\n end", "def get_or_create_node(conn, index, data)\n\n\tvalue = data.object.to_s.unpack('U*').pack('C*').force_encoding(\"UTF-8\")\n\turi = data.subject.to_s\n\n\t# look for node in the index\n\t#r = conn.get(\"/db/data/index/node/#{index}/name/#{URI.escape(value).gsub(\"?\",\"%3F\")}\")\n\tr = conn.get(\"/db/data/index/node/#{index}/uri/#{CGI.escape(uri)}\")\n\tnode = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n\t\n\tunless node\n\t\t# no indexed node found, so create a new one\n\t\tr = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => value, \"uri\" => uri}), HEADER)\n\n\t\tnode = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n\t\t# add new node to an index\n\t\tnode_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\", \\\"value\\\" : \\\"#{value}\\\"}\"\n\t\tconn.post(\"/db/data/index/node/#{index}_names\", node_data, HEADER)\n\n\t\tnode_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"uri\\\", \\\"value\\\" : \\\"#{uri}\\\"}\"\n\t\tconn.post(\"/db/data/index/node/#{index}\", node_data, HEADER)\t\n\n\t\tnode_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\", \\\"value\\\" : \\\"#{value}\\\"}\"\t\t\n\t\tconn.post(\"/db/data/index/node/fulltext\",node_data,HEADER)\n\t\tconn.post(\"/db/data/index/node/#{index}_fulltext\",node_data,HEADER)\n\tend\n\tnode\nend", "def get_node_containing(node,path,content)\n if path == \"\" then\n return nil\n end\n name = path.split(\"/\")[0]\n rest = path.split(\"/\")\n rest.delete(name)\n rest = rest.join(\"/\")\n node.each_element do |element|\n if element.name == name\n if rest == \"\" && element.content == content\n return element.parent\n else\n node = get_node_containing(element,rest,content)\n if node == nil\n next\n else\n return node\n end\n end\n end\n end\n end", "def node_get(node)\n nodes.fetch prepare_key(node), nil\n end", "def node_at(index)\n if index >= self.size\n puts \"index out of range.\"\n else\n each_with_index do |node, i|\n return node if index == i \n end\n end\n end", "def get_node(string)\n # Let's do a case insensitive search..\n string = string.downcase()\n results = @graph.vertices[0].select { |k,v|\n d = v.description\n d.downcase().include? string\n }\n if results.count >= 1\n if results.count > 1\n puts \"WARNING: More than one node matches '#{string}'! Simply using the first one...\"\n end\n # Just use the \"first\" node available, whatever that might mean...\n node = Array(results)[0][1]\n else\n puts \"WARNING: No nodes matches '#{string}'!\"\n node = nil\n end\n return node\n end", "def find id\n return nil if node.ids.empty?\n node.send(:orm_class).find id\n end", "def find(root, data)\n return root if root && root.title == data\n\n found_node = nil\n\n found_node = find(root.left, data) if root.left\n found_node = find(root.right, data) if !found_node && root.right\n\n return found_node\n end", "def find(value, node = @root)\n return nil if node.nil?\n return node if node.value.eql?(value)\n\n node.value > value ? find(value, node.left) : find(value, node.right)\n end", "def find(root, data)\n node = root\n if !root.nil?\n if root.title != data\n node = find(root.left, data)\n if node.nil?\n node = find(root.right, data)\n end\n end\n end\n return node\n end", "def get_node(key); end", "def find_node(vrt_id:, preferred_version: nil, max_depth: 'variant', version: nil) # rubocop:disable Lint/UnusedMethodArgument\n new_version = preferred_version || current_version\n if get_map(version: new_version).valid?(vrt_id)\n get_map(version: new_version).find_node(vrt_id, max_depth: max_depth)\n elsif deprecated_node?(vrt_id)\n find_deprecated_node(vrt_id, preferred_version, max_depth)\n else\n find_valid_parent_node(vrt_id, new_version, max_depth)\n end\n end", "def find(root, data)\n node = root\n if !root.nil? && root.title != data # gracefully handle nil, skips if match\n if !root.left.nil? #if left child exists\n node = find(root.left, data) # recursive left as root\n elsif !root.right.nil?\n node = find(root.right, data)\n else\n node = nil # if end of the tree\n end\n end\n return node\n end" ]
[ "0.7215733", "0.70468134", "0.70468134", "0.70105124", "0.6986623", "0.679843", "0.67912114", "0.6739654", "0.6701905", "0.6690912", "0.66753453", "0.66639364", "0.6650414", "0.6626188", "0.6600094", "0.6599497", "0.6557516", "0.655419", "0.6541449", "0.64871466", "0.64793766", "0.64738756", "0.64523697", "0.6450672", "0.6398533", "0.63971496", "0.63971496", "0.63918984", "0.63833314", "0.6374623", "0.6370679", "0.634136", "0.6337117", "0.6309865", "0.63085824", "0.62972057", "0.62751806", "0.6267824", "0.6266275", "0.6231944", "0.62264085", "0.62171274", "0.62106204", "0.6204958", "0.6202", "0.6199256", "0.6157001", "0.6142109", "0.6117769", "0.6093849", "0.6090558", "0.6089857", "0.6088473", "0.6080541", "0.60753554", "0.6067837", "0.6067724", "0.6046921", "0.6036894", "0.60316557", "0.60229653", "0.601675", "0.6010445", "0.60043055", "0.599489", "0.5992377", "0.5978365", "0.5975073", "0.5972454", "0.5970526", "0.5970279", "0.5961899", "0.59491146", "0.59291035", "0.5920929", "0.59086335", "0.5907153", "0.5899513", "0.5899513", "0.5899513", "0.5899513", "0.5899513", "0.58984834", "0.5888696", "0.5887118", "0.58854586", "0.58768576", "0.58687496", "0.58670884", "0.586327", "0.5856669", "0.58562636", "0.58514476", "0.5849165", "0.58479846", "0.5838785", "0.58376193", "0.58345747", "0.58341163", "0.5832505" ]
0.69655776
5
Find an edge and increment its weight, or add it if needed
def find_or_add_edge(one, two) edge = find_edge(one, two) if edge edge.weight += 1 edge else edges << Edge.new(one: one, two: two, weight: 1) edges.last end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hyperball_on_edge(edge)\n update_node = @counters.get_counter(edge[1])\n neighbor_node = @counters.get_counter(edge[0])\n\n update_node.merge(neighbor_node)\n end", "def add_edge(node, weight)\n @adjacent_nodes[node.value] = { weight: weight, node: node }\n self\n end", "def add_edge(source, destination, weight)\n super(source, destination, weight) if weight > 0\n end", "def addweight(w)\n @weight += w\n end", "def relax(edge)\n #If the distance currently is lower than the added distance,\n #Don't increase it.\n return if @dist_to[edge.dest] <= @dist_to[edge.source] + edge.weight\n \n #Update the distance and add it back to the queue\n @dist_to[edge.dest] = @dist_to[edge.source] + edge.weight\n @path[edge.dest] = edge.source\n @queue.insert(edge.dest, @dist_to[edge.dest])\n end", "def edge_weight(start_node, end_node)\n relationships = @adj_list[start_node]\n relationships.length.times do |r|\n relationship = relationships.read(r)\n return relationship.weight if relationship.id == end_node\n end\n 'None'\n end", "def update_edge?(from, to ,weight)\n bool = false\n @edges.each() do |edge|\n if (edge.from() == from and edge.to() == to) or (edge.from() == to and edge.to() == from)\n edge.weight = weight\n bool = true\n end\n end\n return bool\n end", "def edge_weight(id_1, id_2)\n @arr[id_1][id_2]\n end", "def edge_weight(a,b)\n @words[a][b] or Throw NoRelation\n end", "def relax(edge)\n return if @distance_to[edge.to] <= @distance_to[edge.from] + edge.weight\n\n @distance_to[edge.to] = @distance_to[edge.from] + edge.weight\n @path_to[edge.to] = edge.from\n\n # If the node is already in this priority queue, the only that happens is\n # that its distance is decreased.\n @pq.insert(edge.to, @distance_to[edge.to])\n end", "def next_edge_index\n # starting at zero\n @next_edge_index ||= 0\n\n @next_edge_index += 1\n\n (@next_edge_index - 1)\n end", "def add_edge(a,b)\n @adj_list[a][b] = 1\n end", "def set_w(edge, weight)\n if edge[0].nil? || edge[1].nil?\n raise ArgumentError, \"Invalid edge: #{edge}\"\n end\n unless weight.is_a?(Integer)\n raise TypeError, 'Edge weight must be integer'\n end\n init_weights if @weight.nil?\n i = edge[0] - 1\n j = edge[1] - 1\n raise \"Edge not found: #{edge}\" unless has_edge?(*edge)\n @weight[i] ||= []\n @weight[j] ||= []\n @weight[i][j] = weight\n @weight[j][i] = weight\n end", "def w(edge)\n i, j = edge\n raise ArgumentError, \"Invalid edge: #{edge}\" if i.nil? || j.nil?\n raise \"Edge not found: #{edge}\" unless has_edge?(*edge)\n init_weights if @weight.nil?\n @weight[i - 1][j - 1]\n end", "def path_weight_to(other)\n shortest_path_to(other,:method => :djikstra).map{|edge| edge.weight.to_f}.sum\n end", "def edge_weight(source, target)\r\n\t\[email protected] do |edge|\r\n\t\t\treturn edge.weight if edge.source == source and edge.target == target\r\n\t\tend\r\n\t\tnil\r\n\tend", "def add_edge(src, dest, weight)\n @v << src if [email protected]?(src)\n @v << dest if [email protected]?(dest)\n new_edge = Edge.new(src,dest, weight)\n src.out_edges << new_edge\n dest.in_edges << new_edge\n @e << new_edge\n end", "def edge_weight(from_id, to_id)\n node = @list[from_id].read_node_at(to_id)\n node.nil? ? nil : node.weight\n end", "def weight\n @graph.weight(source, target)\n end", "def getNodeWeights()\n # (two possible sources: flipped and negated, so \n # add them for each node)\n \n tabRead(@edges){|arr|\n ordered = [arr[0],arr[2]].sort\n @allEdgeWeightScores[ordered.join(\"--\")] += arr[3].to_f\n @nodeList[arr[0]] = 1\n @nodeList[arr[2]] = 1\n }\nend", "def add_edge(from, to, weight = 1.0)\n\t\t\tadd_node(from)\n\t\t\tadd_node(to)\n\t\t\t@size += 1 if connect(from, to, weight)\n\t\t\tself\n\t\tend", "def get_edge(x, y)\n edge = get(x, y)\n edge[:weight] if edge\n end", "def add_edge(u, v, w)\n super(u,v)\n @weights[[u,v]] = w\n end", "def add_edge(u,v,weight)\n @source[u] = Hash.new unless @source.has_key?(u)\n @source[v] = Hash.new unless @source.has_key?(v)\n @source[u][v]=weight\n @source[v][u]=weight\n end", "def increment_by(node, weight)\n raise ArgumentError.new('please use #decrement_by') if weight < 0\n change_by node, weight\n end", "def add_edge(node1, node2, weight)\n nodes[node1.value].add_edge(nodes[node2.value], weight)\n nodes[node2.value].add_edge(nodes[node1.value], weight)\n self\n end", "def calc_total_weight\n @weight + @node_link.calc_total_weight\n end", "def add_edge(source, dest, weight)\n edges << Edge.new(source, dest, weight)\n end", "def connect(a, b, weight=1)\n if @words[a][b].nil? then\n @words[a][b] = weight\n else\n @words[a][b] += weight\n end\n end", "def connectWith(node, weight = 0)\n edge = Edge.new(self, node, weight)\n @edges << edge\n\n edge\n end", "def weight\n sides.map(&:weight).reduce(&:+)\n end", "def add(x, y, weight)\n @store[x] ||= EdgeBag.new\n @store[x].add(y, weight)\n @store[y] ||= EdgeBag.new if undirected?\n @store[y].add(x, weight) if undirected?\n end", "def add_edge(x, y, cost: 1)\n raise\n end", "def add_edge!(from, to)\n protected_add_edge!(from, to)\n @edge_number += 1\n end", "def max_edge_weight\n edges.map(&:weight).max\n end", "def edge_count\n @adjacency_list.flatten.count / 2\n end", "def add_weighted_elem(elem, weight)\n # (native code)\n end", "def add_weighted_elem(elem, weight)\n # (native code)\n end", "def add_weighted_elem(elem, weight)\n # (native code)\n end", "def add_edge(source, target, weight = 1)\r\n\t\tself.push source unless self.include?(source)\r\n\t\tself.push target unless self.include?(target)\r\n\t\[email protected] Edge.new(source, target, weight)\r\n\tend", "def select_edge w\n\t# Sum up the partial weights ~ O(n)\n\ttotal_w = 0\n\t(1..w.n).each do |w_i|\n\t\ttotal_w += w.get_W(w_i)\n\tend\n\n\t# Draw random number between 0 and total_w ~ O(1)\n\trnd = Random.rand * total_w\t\n\n\t# search the column where this weight is located ~ O(n)\n\tsum_up = w.get_W(1)\n\trow_index = 1\n\twhile sum_up < rnd\n\t\trow_index += 1\n\t\tsum_up += w.get_W(row_index)\n\tend\n\n\t# now we have the correct row\n\tcol_index = w.n\n\twhile sum_up > rnd\n\t\tsum_up -= w.get_w(row_index, col_index)\n\t\tcol_index -= 1\n\tend\n\n\t# compensate for -1 too much\n\t[row_index, col_index + 1]\nend", "def add_neighbor( nbr, weight = 0)\n @connected_to[ nbr ] = weight\n end", "def numPaths(start_from, vertices,edge_weights)\n graph = RGL::DirectedAdjacencyGraph.new\n graph.add_vertices vertices\n edge_weights.each { |(bag1, bag2), w| graph.add_edge(bag1, bag2) }\n\n num_paths = 0\n vertices.map do |vert|\n unless vert.eql?(start_from)\n num_paths+=1 if graph.path?(start_from,vert)\n end\n end\n num_paths\nend", "def add_edge( from_key, to_key, weight = 0 )\n add_vertex(from_key) unless @vertices.include? from_key\n add_vertex(to_key) unless @vertices.include? to_key\n @vertices[from_key].add_neighbor( @vertices[to_key], weight )\n end", "def add_relation source_label, relation, destination_label, direction = '<->'\n # More popular nodes have more weigth\n @node_weights[source_label] += 1\n @node_weights[destination_label] += 1\n\n @edge_buffer << Edge.new(\n source_label: source_label,\n relation: relation,\n destination_label: destination_label,\n direction: direction\n )\n end", "def edge_class\n WeightedDirectedEdge\n end", "def add_edge(source_vertex, destination_vertex)\n @adjacent_list[source_vertex].push(destination_vertex)\n @indegree[destination_vertex] += 1\n end", "def add_undirected_edge(vertex_a, vertex_b, weight)\n super(vertex_a, vertex_b, weight) if weight > 0\n end", "def c_edge(other_node, wt = 0)\n (self.outbound_edges.add(other_node, wt) &&\n other_node.inbound_edges.add(self, wt))\n self\n end", "def add_edge(source, target, edge = Edge.new)\n _clear_cache\n @pathway.append(Bio::Relation.new(source, target, edge))\n edge\n end", "def add_edge(edge)\n @edges << edge\n add_node(edge.n1) unless @nodes.find_index(edge.n1)\n add_node(edge.n2) unless @nodes.find_index(edge.n2)\n @incident_map[edge.n1] << edge\n @incident_map[edge.n2] << edge\n end", "def increment_hits\n @node.increment_hits! if @node\n end", "def get_weight( nbr )\n @connected_to[ nbr ]\n end", "def edgeuUpdate(msg)\n msg = msg.split(' ')\n dst = msg[0]\n cost = msg[1].to_i\n $dist[dst] = cost\n $neighbors[dst] = cost\nend", "def add_edge(id1, id2)\n # YOUR WORK HERE\n end", "def reduce_weight \n @weight -= WEIGHT_INCREMENT\n # increment could be confusing and imply an increase rather than a decrease \n # but it is being reduced by increments of 10 so it makes sense??? \n # It's the best of the names that came to mind.\n end", "def number_of_edges\n @adj.values.map(&:length).inject(:+)\n end", "def edge_number\n @edge_number\n end", "def create_edge_to(other, weight = 1.0)\n self.class.edge_class.create!(:from_id => id, :to_id => other.id, :weight => weight)\n end", "def <=>(otherEdge)\n @weight <=> otherEdge.weight\n end", "def increment_probability(a,b)\n\n # are we tracking this yet?\n if @graph.words[a].nil? then\n @graph.add_node(a)\n end\n \n @graph.connect(a, b, 1)\n end", "def add_edge(e)\n add_vertex(e.from); add_vertex(e.to)\n (@from_store[e.from].add?(e) && @to_store[e.to].add(e) && e) || edge(e.from, e.to)\n end", "def add_edge(e)\n @edges[e.from] << e\n end", "def anything\n EDGE_LIST.each do |record|\n from, to, weight = record\n @adj_matrix[from.id][to.id] = weight\n @adj_matrix[to.id][from.id] = weight\n end\n end", "def complete_weighted_bigraph(n)\n g = GraphMatching::Graph::WeightedBigraph.new\n max_u = (n.to_f / 2).ceil\n min_v = max_u + 1\n weight = 1\n 1.upto(max_u) do |i|\n min_v.upto(n) do |j|\n g.add_edge(i, j)\n g.set_w([i, j], weight)\n weight += 1\n end\n end\n g\nend", "def weight_function\n\t\tif @weightFunction != nil\n\t\t\t@weightFunction\n\t\telse\n\t\t\tlambda do |u,v|\n\t\t\t\[email protected]{|f| return f.weight if (f.s==u && f.d == v)}\n\t\t\t\treturn nil\n\t\t\tend\n\t\tend\n\tend", "def add_edge(s, t, w)\n\n if (not @graph.has_key? s)\n @graph[s] = {t => w}\n else\n @graph[s][t] = w\n end\n\n @nodes.merge [s,t]\n\n end", "def add_edge(v, w)\n if ([email protected]?(v))\n @vertices.push(v)\n @adjacency_list[@vertices.find_index(v)] = []\n end\n if ([email protected]?(w))\n @vertices.push(w)\n @adjacency_list[@vertices.find_index(w)] = []\n end\n if (!@adjacency_list[@vertices.find_index(v)].include?(w))\n @adjacency_list[@vertices.find_index(v)].push(w)\n end\n end", "def currentWeight() weighins.last.weight end", "def add_edge(edge)\n # pp @access_paths\n # pp edge\n added = false\n return added if @edges.include?(edge)\n visited_path = @access_paths.each_with_index.select{|p,idx| !(p & edge).empty? }\n if visited_path.count == 2\n # if the two vertexes are visited in 2 paths\n # We'll combine the 2 paths\n new_path =[]\n to_del_idx =[]\n visited_path.each do |p|\n idx = p[1]\n v_path = p[0]\n new_path = new_path + v_path\n to_del_idx << idx\n end\n @access_paths.delete_if.with_index{|p,idx| to_del_idx.include?(idx)}\n @access_paths << new_path\n @edges << edge unless @edges.include?(edge)\n added = true\n elsif visited_path.count == 1\n v_path = visited_path[0][0]\n # binding.pry\n if (v_path & edge).count() == 2\n # binding.pry\n # add edge only when it does not create cycle\n puts \"Refuse to add edge #{edge.to_s} as it create cycle\"\n else\n # v_path = visited_path[0][1]\n vertext = edge - v_path\n v_path = v_path + vertext\n idx = visited_path[0][1]\n @access_paths.delete_at(idx)\n @access_paths << v_path\n @edges << edge unless @edges.include?(edge)\n added = true\n end\n elsif visited_path.count == 0\n @access_paths << edge\n @edges << edge unless @edges.include?(edge)\n added = true\n end\n # puts \"added is #{added}\"\n\n return added\n\tend", "def add_edge(u, v, weight = 1)\n\t\t@edges[u] = {} unless @edges.has_key?(u)\n\t\t@edges[v] = {} unless @edges.has_key?(v)\n\t\t@edges[u].update({v => Edge.new(u, v, weight)})\n\t\t@edges[v].update({u => Edge.new(v, u, weight)})\n\tend", "def count_edge\n count = 0\n @f_net.each_with_index do |followees, follower|\n count += followees_of(follower).count\n end\n count\n end", "def weight\n order_lines.inject(0) { |sum, l| sum + l.weight }\n end", "def add_edge(x, y)\n if([email protected]_key?(x)) then \n @g[x] = []\n end\n if(!@g[x].include? y) then\n @g[x] << y\n end\nend", "def add_edge(source, destiny, weigth)\n source, destiny, weigth = convert_values(source, destiny, weigth)\n\n add_vertex(source)\n add_vertex(destiny)\n\n make_edge(source, destiny, weigth)\n end", "def add_weight(type, group, item, weight = 1)\n @weights[type][group] ||= Hash.new(0)\n\n @weights[type][group][item] += Integer weight\n end", "def weight(i, j)\n return 1\n end", "def increment(node)\n change_by node, 1\n end", "def add_edge(edge)\n @edges.push(edge)\n end", "def add_edge(x, y)\n\t\traise if @x_connections[x] != -1\n\t\traise if @y_connections[yIdx(y)] != -1\n\t\t\n\t\t@x_connections[x] = y\n\t\t@y_connections[yIdx(y)] = x\n\t\t\n\t\t@unconnected_x_vertices -= 1\n\t\t\n#\t\traise if @x_connected_vertices.member?(xy[0])\n#\t\traise if @y_connected_vertices.member?(xy[1])\n\t\n\tend", "def add_edge(element1, element2)\n index1 = self.dict[element1]\n index2 = self.dict[element2]\n raise Exception.new(\"Nodes not exist!\") unless index1 && index2\n\n head_node2 = self.adj_list_array[index2].head_node\n new_node1 = Node.new(element1, head_node2.next_node)\n head_node2.next_node = new_node1\n\n\n head_node1 = self.adj_list_array[index1].head_node\n new_node2 = Node.new(element2, head_node1.next_node)\n head_node1.next_node = new_node2\n\n self\n end", "def weights\n return @weights if @weights\n return @weights = [] if array.empty?\n\n lo = edges.first\n step = edges[1] - edges[0]\n\n max_index = ((@max - lo) / step).floor\n @weights = Array.new(max_index + 1, 0)\n\n array.each do |x|\n index = ((x - lo) / step).floor\n @weights[index] += 1\n end\n\n return @weights\n end", "def add_edge(direction, edge)\n opposite_adjacencies(direction, edge) << edge\n end", "def check_add_edge(anEdge)\n anEdge\n end", "def addEdge from, to, directed, weight=nil\n\t\treturn false if !isNode?(to) || !isNode?(from)\n\t\tgetNode(from).addConnection(to,weight)\n\t\tgetNode(to).addConnection(from,weight) if(!directed)\n\tend", "def minweight(w)\n @weight = w if w<@weight\n end", "def add(edge)\n source = edge.source\n if @contained_vertices.include? source\n @vertex_array.at(source).add_edge(edge)\n else\n new_vertex = Vertex.new(source)\n new_vertex.add_edge(edge)\n @contained_vertices.push(source)\n if @vertex_array.size < source\n @vertex_array.insert(source, new_vertex)\n else\n @vertex_array[source] = new_vertex\n end\n end\n end", "def add(clusterPoint, weight)\n @values.merge(clusterPoint.values).keys.each { |i| @values[i] = ( @values[i] * (1-weight) ) + (clusterPoint.values[i] * weight)}\n end", "def connect_graph(source, target, weight)\n if (!graph.has_key?(source))\n graph[source] = {target => weight}\n else\n graph[source][target] = weight\n end\n if (!locations.include?(source))\n locations << source\n end\n end", "def generate_adjacencies(board)\n b2 = duplicate(board)\n b2.each_with_index do |row, y_idx|\n row.each_with_index do |cell, x_idx|\n next unless cell == MINE\n increment_neighbors(b2, [x_idx, y_idx])\n end\n end\nend", "def relation_weight(relation)\n # @@neo = Neography::Rest.new\n # self_node_id = self.get_node_id \n begin\n total_relations = self.distinct_relations\n if total_relations\n total_relations_weights = total_relations.map{|u| u[1]}.flatten.sum\n rel_count = total_relations.select{|u| u[0]==relation}.first\n rel_magnitude = rel_count[2]\n rel_count.empty? ? rel_count=0 : rel_count=rel_count[1]\n rel_count = rel_count.to_f\n total_relations_weights = total_relations_weights.to_f\n # rel_count = self.relation_count(relation)\n if ( !rel_magnitude || rel_magnitude > 0 )\n rel_magnitude = 1.0\n end\n if rel_count\n return ( (rel_count/total_relations_weights)*rel_magnitude )\n else\n return 0\n end\n else\n return 0\n end\n rescue Exception\n return 0\n end\n end", "def path_weight(p)\n unless path?(p)\n return nil\n else\n weight = 0\n p.each_cons(2){|x|\n weight += @source[x[0]][x[1]]}\n return weight\n end\n end", "def add_edge( edge )\n super( edge.source, edge.target, edge )\n __add_edge__( edge )\n end", "def weight; end", "def weight\n 0\n end", "def edge_label_number\n @edge_labels.count\n end", "def test_add_edge_with_cycles\n @graph.add_edge('a', 'b');\n @graph.add_edge('b', 'c');\n @graph.add_edge('c', 'a');\n\n # 0 and 2 are indexes of vertex a and vertex c respectively\n assert(@graph.vertices[0].neighbours[2] == true && @graph.vertices[2].neighbours[0] == true)\n end", "def calculate_weight\n update_attribute :weight, votes.sum(:value)\n weight\n end", "def connect edge\n self.add edge.src\n self.add edge.dst\n @nodes[edge.src] << edge\n edge\n end", "def update_neighbors_count!\n @neighbors_count = neighbor_mines_count\n end" ]
[ "0.68839383", "0.68835115", "0.68623716", "0.6738664", "0.66191673", "0.65683854", "0.65471256", "0.6526162", "0.6449443", "0.644654", "0.64417714", "0.6428381", "0.6422983", "0.6420932", "0.63979197", "0.6375651", "0.6351983", "0.6310793", "0.62784505", "0.6257984", "0.625513", "0.62294126", "0.6224598", "0.6209466", "0.6192282", "0.6172612", "0.6119771", "0.6100302", "0.60932666", "0.6085986", "0.60813934", "0.6063012", "0.60627675", "0.6060093", "0.60338104", "0.60289717", "0.5999918", "0.5999918", "0.5999918", "0.5941994", "0.59279174", "0.59206176", "0.5889829", "0.5835498", "0.58322966", "0.58199495", "0.5775255", "0.5774181", "0.57468647", "0.57377625", "0.57344764", "0.5724099", "0.5719374", "0.57118905", "0.56685513", "0.56513435", "0.562388", "0.5612818", "0.5612797", "0.56029683", "0.5602811", "0.55957884", "0.5588372", "0.55746764", "0.55729693", "0.55523676", "0.55517566", "0.5547483", "0.5534757", "0.55143076", "0.551346", "0.54932547", "0.5492365", "0.5441214", "0.5421826", "0.54216415", "0.54144484", "0.54075724", "0.53990936", "0.53810716", "0.53787893", "0.5376344", "0.53725654", "0.5357621", "0.53514165", "0.5331901", "0.5326939", "0.53224623", "0.5313201", "0.53124416", "0.5310231", "0.5307315", "0.52940965", "0.5291363", "0.52904993", "0.5282277", "0.5278427", "0.52726644", "0.5271882", "0.5251703" ]
0.74529654
0
The algorithm adds leaf nodes in order
def addLeaf(node, value, offset) result = newChild(node, value, @suffixOffset, offset, Node::CURRENT_ENDING_OFFSET) # optional configuration based properties result.leafCount = 1 if (@configuration[:leafCount]) result.previousValue = (@dataSource.valueAt(@suffixOffset - 1)) if ((@suffixOffset > 0) && @configuration[:previousValue]) result.dataSourceBit = @dataSourceBit if @configuration[:dataSourceBit] @suffixOffset += 1 if ((@nextDataSourceSwitch != nil) && ((@suffixOffset % @nextDataSourceSwitch) == 0)) then self.nextDataSourceBit end persist(result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_leaf(leaf, defer_update = false)\n raise \"node is not lowest level and can therefore not get a leaf: #{self}\" unless lowest_level?\n children.insert(children.find_index {|child| child.shash > leaf.shash} || -1, leaf) #insertion_sort here\n leaf.parent = self\n divide_if_needed(defer_update)\n end", "def leafify(n)\n n.extend(Leaf)\n end", "def sort_leafs!\n leafs.sort! { |a, b| a.position.to_i <=> b.position.to_i }\n end", "def grow( )\n\t\tnew_leaves = [ ]\n\t\[email protected] do |leaf|\n\t\t\tif @forward\n\t\t\t\tsearch = lambda { |song| leaf.song.last == song.first }\n\t\t\telse\n\t\t\t\tsearch = lambda { |song| leaf.song.first == song.last }\n\t\t\tend\n\t\t\t$songs.find_all(&search).each do |next_song|\n\t\t\t\tnew_leaves << leaf.add_next(next_song)\n\t\t\tend\n\t\tend\n\t\t@leaves = new_leaves\n\tend", "def structure_reform(curNode, addNode)\n # reset branches for reform\n @branches = []\n @branch_count = 0\n # puts 'before cleanup'\n # lNode.print_tree\n # rNode.print_tree\n # rNode.print_tree\n # remove_PH_node(lNode)\n # remove_PH_node(rNode)\n # remove_PH_node(curNode)\n # puts 'after cleanup'\n # curNode.print_tree\n # addNode.print_tree\n # rNode.print_tree\n curChildren = curNode.children.count == 0 ? [curNode] : curNode.children\n addChildren = addNode.children.count == 0 ? [addNode] : addNode.children\n count = 0\n # p 'lnode'\n # pp lChildren\n # p 'rnode'\n curChildren.each do |ln|\n curNode.remove!(ln)\n addChildren.each do |rn|\n # p '--------------'\n # p 'ln'\n # ln.print_tree\n # p 'rn'\n # rn.print_tree\n # binding.pry\n # phName=\"PH#{@branch_count}\"\n # ph =Tree::TreeNode.new(phName, '')\n ln_append = ln.detached_subtree_copy\n # p 'ln_append before'\n # ln_append.print_tree\n append_to_end(ln_append, rn)\n # p 'ln_append'\n # ln_append.print_tree\n # ph<<ln_append #unless curNode==newNode\n ln_append = add_branch(ln_append)\n # p 'ln_append after'\n # ln_append.print_tree\n curNode << ln_append\n # p 'ph'\n # ph.print_tree\n # p 'curNode'\n # curNode.print_tree\n end\n end\n end", "def leaf(node, tag)\r\n end", "def build_nodes!\n @nodes.sort_by(&:key).each { |node| add_node(@graph, node) }\n end", "def build_nodes!\n @nodes.sort_by(&:key).each { |node| add_node(@graph, node) }\n end", "def addLeaves(root, node, newTrees)\n return if (!node)\n # base case\n if (!node.left && !node.right)\n # add 2 children\n node.left = TreeNode.new(0)\n node.right = TreeNode.new(0)\n # copy the tree\n newTree = Marshal.load(Marshal.dump(root))\n # add the copy to newTrees\n newTrees.push(newTree)\n # remove the children from original tree\n node.left = nil\n node.right = nil\n puts \"🍎 newTrees: #{newTrees}\"\n\n end\n\n # recursive calls\n addLeaves(root, node.left, newTrees)\n addLeaves(root, node.right, newTrees)\nend", "def _level_order(root, ary=[], lbd)\n ary, q = [], BST::MyQueue.new\n q.enqueue root\n loop do\n break if q.empty?\n node = q.dequeue\n ary << lbd.call(node.val)\n q.enqueue node.lnode if node.lnode \n q.enqueue node.rnode if node.rnode\n end\n ary \n end", "def leaf_node_id(leaf_id)\n @leaf_count + leaf_id\n end", "def grow_tree(root, nodes, adopt_fn)\n kids = nodes.select { |w| adopt_fn.call(root, w) }\n branches = kids.map { |k| grow_tree(k, nodes - [root], adopt_fn) }\n { root => branches.reduce(&:merge) }\nend", "def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end", "def leaf?; @leaf; end", "def AddNodes(nodes)\n\tnodes.each do |n|\n\t\tn.id=@lastId\n\t\tDefineGroup(n)\n\t\t@lastId=@lastId+1\n\tend\n\treturn nodes\n end", "def grow_tree\n dataset.order_transaction_items(candidate_items).each do |transaction|\n add_transaction(transaction, root)\n end\n calculate_header_support\n end", "def remove_unused_leaves\n each_node do |n|\n n.pin([]) if n.weight == 0 && n.children.empty?\n end\n end", "def produce_tree(ary); end", "def post_order_traversal\n nodes = []\n nodes += @left.post_order_traversal if @left\n nodes += @right.post_order_traversal if @right\n nodes.push(@root_value)\n nodes\n end", "def is_leaf\n true\n end", "def is_leaf\n true\n end", "def each_leaf(&block)\n each_leaf_node([], @root, block)\n end", "def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end", "def add(text)\n\n\t\t# create a new node and set navigation pointers\n\t\t@old = @tree\n\t\t@tree = Node.new(text)\n\t\[email protected] = @old.next\n\t\tif @old.next != nil\n\t\t\[email protected] = @tree\n\t\tend\n\t\[email protected] = @old\n\t\[email protected] = @tree\n\n\t\t# Prune the tree, so it doesn't get too big.\n\t\t# Start by going back.\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.prev\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.next\n\t\t\tx.prev.delete\n\t\tend\n\t\t# now forward\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.next\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.prev\n\t\t\tx.next.delete\n\t\tend\n\tend", "def sum_of_left_leaves(root)\nend", "def postorder\n postorder_traversal(@root, [])\n end", "def leaf?; false end", "def leaf_at(xml, leaf_name, order, ns: 'xmlns')\n el = xml.at(\"./#{ns}:#{leaf_name}\")\n el || begin\n el = Nokogiri::XML::Node.new(ns == 'xmlns' ? leaf_name : \"#{ns}:#{leaf_name}\", xml)\n (previous = find_previous(xml, leaf_name, order)) ? previous.after(el) : xml.prepend_child(el)\n el\n end\n end", "def convert_binary_tree_to_double_linked_list(root)\nend", "def each_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf\n end\n end", "def recalculate(inode)\n full_count = 0\n inode.list_of_children.each do |node|\n#p node\n komvos = self.get(node)\n#p komvos\n if komvos.normalize==0\n puts \"node #{node} is not leaf\"\n # if not leaf\n #recalc(holon.searchFor(node).listOfChildren)\n self.recalculate(komvos)\n else \n # exw kanei: node.normalize kai einai leaf\n puts \"node #{node} is leaf\"\n \n end\n # uplogizw to sum of coun and re-normalize\n full_count = full_count + komvos.weight\n end\n inode.weight = full_count\n end", "def all\n result = []\n\n queue = []\n current_node = self.find_root\n queue << current_node\n\n until queue.empty?\n current_node = queue[0]\n result << current_node.val\n # use empty nodes to maintain two-childs for each node so it's easier to read the array output\n if current_node.val != \"E\"\n if current_node.left\n queue << current_node.left\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.right\n end\n if current_node.right\n queue << current_node.right\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.left\n end\n end\n queue.shift\n end\n\n result\n end", "def update(leaf_id, new_value)\n @nodes[@leaf_count + leaf_id] = new_value\n visit_path_to_root(leaf_id) do |node|\n next if leaf_node?(node)\n \n @nodes[node] = HashTree.node_hash node, @nodes[HashTree.left_child(node)],\n @nodes[HashTree.right_child(node)]\n end\n self\n end", "def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end", "def add(k)\n # create new node\n n = AvlNode.new k\n # start recursive procedure for inserting the node\n insert_avl(@root, n)\n end", "def post_order_traversal(tree=root, ordering=[])\n end", "def build_move_tree\n queue = [@root_node]\n until queue.empty?\n current_node = queue.shift\n possible_positions = new_move_positions(current_node.value) #[]\n possible_positions.each do |position| #[1,2]\n child_node = PolyTreeNode.new(position) #node object(value = 1,2)\n child_node.parent = current_node\n current_node.add_child(child_node)\n queue << child_node\n end\n end\n end", "def level_order(root)\n res = []\n return res if root.nil?\n queue = [root]\n tmp = [root.val]\n until queue.empty?\n res << tmp\n parent = queue\n queue = []\n tmp = []\n parent.each do |nodes|\n queue << nodes.left unless nodes.left.nil?\n queue << nodes.right unless nodes.right.nil?\n tmp << nodes.left.val unless nodes.left.nil?\n tmp << nodes.right.val unless nodes.right.nil?\n end\n end\n res\nend", "def add_node(new_node)\n @nodes[new_node] ||= Array.new #only adds if not in graph\n @node_dir_ancestors[new_node] ||= Array.new\n end", "def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend", "def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end", "def add_children(anEnumerable, theBacklog)\n anEnumerable.reverse_each do |elem|\n theBacklog.unshift(elem)\n end\n end", "def add_node(node); end", "def _leaf(name, rx, ignorable: false, boundary: false, tests: [], preconditions: [], process: nil)\n raise Error, 'tests must be an array' unless tests.is_a? Array\n raise Error, 'preconditions must be an array' unless preconditions.is_a? Array\n\n init\n init_check(name)\n name = name.to_sym\n return if dup_check(:leaf, name, rx, tests + preconditions)\n\n tests << [process] if process\n @leaves << Leaf.new(name, rx, ignorable: ignorable, boundary: boundary, tests: tests, preconditions: preconditions)\n end", "def post_order(root=@root, arr=[])\n return root if root.nil?\n post_order(root.left_child, arr)\n post_order(root.right_child, arr)\n arr << root.value\n arr\n end", "def preorder\n preorder_traversal(@root, [])\n end", "def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end", "def build_move_tree\n self.root_node = PolyTreeNode.new(start_pos) #instance variable\n \n queue = [root_node]\n until queue.empty?\n #pop,queue\n cur_node = queue.shift\n move_list = new_move_positions(cur_node.value)\n move_list.each do |pos|\n child_node = PolyTreeNode.new(pos)\n cur_node.add_child(child_node)\n queue << child_node\n end\n end\n end", "def prepend(root); end", "def recurse_nodes(parent_names, source_tmp_geo_area)\n if parent_names.count > 1\n parents = parent_names.dup # Tricky! \n name = parents.shift\n puts \"building internal node: #{name} : #{parents} \"\n add_item(\n name: name,\n parent_names: parents,\n source_table: source_tmp_geo_area.source_table,\n source_table_gid: source_tmp_geo_area.source_table_gid,\n is_internal_node: true\n )\n recurse_nodes(parents, source_tmp_geo_area)\n end\n end", "def build_move_tree # Node[0,0]\n @root_node = PolyTreeNode.new(@start_pos)\n tree = [@root_node] #after first round tree = []\n while !tree.empty?\n #after line 39 => tree => [N(v(2,1)), N(v(1,2))]\n res = tree.shift #tree = [] # res => TreeNode with the value of [2,1]\n positions = new_move_positions(res.value) # positions => [[0,2],[1,3], [3,3], [4,2], [5,0]]\n #tree => [N(v(1,2))]\n positions.each do |n| # n=> [2,1]\n nd = PolyTreeNode.new(n) # nd=> Node with with the value of [2,1]\n res.add_child(nd)\n tree << nd\n end # tree => [N(v(1,2)),N [0,2],[1,3], [3,3], [4,2], [5,0]]\n end\n end", "def assign_leaf(node)\n if node.left && node.right\n @leaf_parent = node\n @replacer_leaf = node.right\n assign_leaf(node.left)\n assign_leaf(node.right)\n else\n return\n end\n end", "def _pre_order(root, ary=[], lbd)\n return ary if root.nil?\n #\n s, h = [], 1 \n s.push [root, h]\n ary = [ h ] if lbd.nil?\n loop do\n break if s.empty?\n node, h = s.pop\n if lbd \n ary << lbd.call(node.val)\n elsif ary.first < h\n ary[0] = h\n end\n s.push [node.rnode, h+1] if node.rnode\n s.push [node.lnode, h+1] if node.lnode\n end\n ary \n end", "def preorder\n # raise NotImplementedError\n return preorder_helper(@root, [])\n end", "def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end", "def level_order(root)\n ordered = []\n return ordered unless root\n queue = [[root]]\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n ordered << vals\n queue << same_level unless same_level.empty?\n end\n\n ordered\nend", "def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end", "def branch\n descendents.unshift(self)\n end", "def zigzag_level_order(root)\n return [] unless root\n\n zigzag_array = [[root.val]]\n\n traverse(root.left, zigzag_array, 1) && traverse(root.right, zigzag_array, 1)\nend", "def leaf_node_id(leaf_id)\n # NOTE: internal node count = number of leaves - 1, and the nodes are\n # numbered from 1 to leaves - 1, so the node ID of the first leaf is\n # equal to the tree's capacity (number of leaves)\n capacity + leaf_id\n end", "def rebalance\n order = self.level_order\n return build_tree(order)\n end", "def minimum_tree_for_leafs(ids)\n # 1. Find all ids in leafs id_path\n # 2. Fetch those ids by tree depth order.\n id_in = ids.join(',')\n leafs = self.find(:all, :conditions => \"id in (#{id_in})\")\n id_paths = leafs.collect{ |l| l.id_path }\n id_in_paths = id_paths.join(',')\n self.find(:all, :conditions => \"id in (#{id_in_paths})\", :order => \"id_path asc\")\n end", "def add_tree!(tree, compute = true)\n @list.each_value do |partition|\n partition.add_tree!(tree, compute)\n end\n self\n end", "def growing\n new_outer_nodes = []\n @outer_nodes.each do |o_n|\n new_partial_outer_nodes = set_outer_nodes(@neighbors_hash[o_n])\n new_outer_nodes << check_partial_outer_nodes(new_partial_outer_nodes, o_n)\n new_outer_nodes.flatten!\n end\n @outer_nodes = new_outer_nodes.compact\n end", "def order_tree(value)\n\n (0..t.children().length-1).each do |i|\n\n if (t.children[i].value.to_s==\"\")\n\n (i..t.children().length).each do |j|\n if(j+1<t.children().length)\n aux=t.children[j+1].value.to_s\n t.children[j+1].value=t.children[j].value.to_s\n t.children[j].value=aux\n end\n end\n\n end\n puts t.children[i].value.to_s\n end\n end", "def sum_root_to_leaf_paths(tree)\n stack = [tree]\n result = []\n hash = Hash.new\n\n until stack.empty?\n node = stack.pop\n\n if !node.left && !node.right\n pointer = node\n array = [node.val]\n until !hash[pointer]\n array.unshift(hash[pointer].val) \n pointer = hash[pointer]\n end\n result << array\n end\n\n if node.right\n stack.push(node.right) \n hash[node.right] = node\n end\n if node.left\n stack.push(node.left)\n hash[node.left] = node\n end\n end\n\n return result.map { |i| i.join.to_i(2) }.reduce(:+)\nend", "def just_add_child(node)\n return if @children.member?(node)\n @children << node\n node.parent = self\n update_boxes \n end", "def build_leaf(tiles_order, prev_board)\n template = {tiles_order: nil, branch: [], m_distance: nil}\n template[:tiles_order] = tiles_order\n template[:branch] += prev_board[:branch]\n template[:branch] << tiles_order\n template[:m_distance] = manhattan_distance(tiles_order) + prev_board[:branch].length\n return template\n end", "def propagation_leafs\n trace.each_vertex.find_all { |v| trace.leaf?(v) }\n end", "def new_leaf(payload, **kwargs)\n factory.leaf_node(payload, **kwargs)\n end", "def test_return_array_root_node\n @tree.insert(\"f\")\n assert_equal [\"f\"], @tree.sort\n end", "def append_tree( newtree )\n\t\t\tnewtree.each do |node|\n\t\t\t\tself.node_stack.last << node\n\t\t\tend\n\t\tend", "def build_tree(unit, node, level = 0)\r\n return nil if level > @max_depth\r\n \t\r\n unit.next_move(node.current_case).each do |next_case|\r\n next if next_case[0] < 0 || next_case[0] > 7 ||\r\n next_case[1] < 0 || next_case[1] > 7 \r\n \r\n next_node = Node.new(next_case, node)\r\n node.children << next_node\r\n\r\n build_tree(unit, next_node, level + 1)\r\n end \r\n end", "def add_iteratively_to_bst(root, value)\n if root.nil?\n root = TreeNode.new(value)\n else\n current_node = root\n while current_node\n if value < current_node.value\n if current_node.left == nil\n # Adding the new value to the tree\n current_node.left = TreeNode.new(value)\n return root# Added the element, retrun reference to root of the tree\n else\n current_node = current_node.left\n end\n else\n if current_node.right == nil\n # Adding the new value to the tree\n current_node.right = TreeNode.new(value)\n return root# Added the element, retrun reference to root of the tree\n else\n current_node = current_node.right\n end\n end\n end\n end\n return root\n end", "def level_order_bottom(root)\n return [] unless root\n \n ordered = nil\n queue = [[root]]\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n ordered = ordered ? ([vals] + ordered) : [vals]\n queue << same_level unless same_level.empty?\n end\n\n ordered\nend", "def level_order(root)\n return [] if root.nil?\n queue = [[root, 0]]\n response = []\n until queue.empty?\n # node is the current node, level is the number associated with it\n node, level = queue.pop\n # level acts as a index for the response array\n # if there's no element (array) with that index, we create it\n response[level] ||= []\n # if it exists, we add current node to it\n response[level] << node.val\n # then we add children to queue and increase the level by 1\n queue << [node.right, level + 1] if node.right\n queue << [node.left, level + 1] if node.left\n end\n response\nend", "def sort_children\n @children.sort! do |a, b|\n if (a.leaf? && b.leaf?) || (!a.leaf? && !b.leaf?)\n a.name <=> b.name\n elsif a.leaf? && !b.leaf?\n -1\n else\n 1\n end\n end\n @children.each(&:sort_children)\n end", "def build_tree(s)\n bytes = s.bytes\n uniq_b = bytes.uniq\n nodes = uniq_b.map { |byte| Leaf.new(byte, bytes.count(byte)) }\n until nodes.length == 1\n node1 = nodes.delete(nodes.min_by(&:count))\n node2 = nodes.delete(nodes.min_by(&:count))\n nodes << Node.new(node1, node2, node1.count + node2.count)\n end\n nodes.fetch(0)\nend", "def leaf_node?(node_id)\n @leaf_count < node_id\n end", "def add(leaf, track = false)\n n = leaf\n h = 0\n r = acc[h]\n proofs << Utreexo::Proof.new(num_leaves, leaf) if track\n until r.nil? do\n # Update siblings for tracking proofs\n p1 = find_proof(r)\n p1.each{|p|p.siblings << n}\n p2 = find_proof(n)\n p2.each{|p|p.siblings << r}\n\n n = Utreexo.parent(r, n)\n acc[h] = nil\n h += 1\n r = acc[h]\n end\n acc[h] = n\n @num_leaves += 1\n end", "def link_nodes(child, parent)\n # link the child's siblings\n child.left.right = child.right\n child.right.left = child.left\n \n child.parent = parent\n \n # if parent doesn't have children, make new child its only child\n if parent.child.nil?\n parent.child = child.right = child.left = child\n else # otherwise insert new child into parent's children list\n current_child = parent.child\n child.left = current_child\n child.right = current_child.right\n current_child.right.left = child\n current_child.right = child\n end\n parent.degree += 1\n child.marked = false\n end", "def nodes\n left_nodes + [self] + right_nodes\n end", "def build_move_tree\n self.root_node = PolyTreeNode.new(@start_pos)\n\n nodes = [root_node]\n until nodes.empty?\n current_node = nodes.shift\n current_pos = current_node.value\n\n new_move_positions(current_pos).each do |pos|\n next_node = PolyTreeNode.new(pos)\n current_node.add_child(next_node)\n nodes << next_node\n end\n end\n end", "def leaf?\n true\n end", "def level_order(node)\n return if !node # return if the node is nil\n queue = Queue.new() # create an empty queue\n queue.enqueue(node) # add the node to the queue\n while !queue.is_empty? # loop as long as the queue is not empty\n temporal_node = queue.dequeue # remove an element from the queue and save it as temporal_node\n print temporal_node.value, \" \" # print the value of temporal_node\n # add both the left and right nodes (if they are not nil) to the queue\n queue.enqueue(temporal_node.left_child) if temporal_node.left_child\n queue.enqueue(temporal_node.right_child) if temporal_node.right_child\n end\n end", "def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end", "def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end", "def expand_children node=:current_index\n $multiplier = 999 if !$multiplier || $multiplier == 0\n node = row_to_node if node == :current_index\n return if node.children.empty? # or node.is_leaf?\n #node.children.each do |e| \n #expand_node e # this will keep expanding parents\n #expand_children e\n #end\n node.breadth_each($multiplier) do |e|\n expand_node e\n end\n $multiplier = 0\n _structure_changed true\n end", "def level_order(root)\n return [] if root.nil? #\"If there is no root return an empty array\"\n queue = [ root ] #\" Our Queue starts with the root inside of it\"\n level = [] #\"All nodes per level go here\"\n order = [] #\"Our return value for all levels\"\n children = [] # All the nodes children go here\"\n\n while queue.length > 0 #\"Until our queue is empty\"\n node = queue.shift #\"We must Shift(FIFO), Our current Node, and how we escape out of the loop\"\n level.push(node.val) #\"Collect the node's value, one by one\"\n\n children.push(node.left) if !node.left.nil? #\"Notice we push it into the children Array if there is a left child\"\n children.push(node.right) if !node.right.nil? #\"Same for the right child\"\n\n if queue.empty? #\"Important. Once the queue is empty we know the level is complete\"\n order.push(level) #\"Push our level into our Order Array and reset its value below\"\n level = [] \n\n if children.length > 0 #\"When the queue is empty(above) and IF there are children\"\n queue.push(*children) #\"We push the children into our Queue...we are ready for the next level, also notice we are using the spread operator to push the children in as arguements and not an array\"\n children = [] #\" Reset the children value.\n end\n end\n end\n\n return order #\"Once we are out of the loop we have collected all our levels\"\n\nend", "def pre_order(root=@root, arr=[])\n return root if root.nil?\n arr << root.value\n pre_order(root.left_child, arr)\n pre_order(root.right_child, arr)\n arr\n end", "def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend", "def consolidate\n roots = []\n root = @next\n min = root\n # find the nodes in the list\n loop do\n roots << root\n root = root.right\n break if root == @next\n end\n degrees = []\n roots.each do |root|\n min = root if @compare_fn[root.key, min.key]\n # check if we need to merge\n if degrees[root.degree].nil? # no other node with the same degree\n degrees[root.degree] = root\n next\n else # there is another node with the same degree, consolidate them\n degree = root.degree\n until degrees[degree].nil? do\n other_root_with_degree = degrees[degree]\n if @compare_fn[root.key, other_root_with_degree.key] # determine which node is the parent, which one is the child\n smaller, larger = root, other_root_with_degree\n else\n smaller, larger = other_root_with_degree, root\n end\n link_nodes(larger, smaller)\n degrees[degree] = nil\n root = smaller\n degree += 1\n end\n degrees[degree] = root\n min = root if min.key == root.key # this fixes a bug with duplicate keys not being in the right order\n end\n end\n @next = min\n end", "def leaf_count\n @leaf_count\n end", "def postorder\n return [] if @root == nil\n\n current = @root \n array = []\n \n return postorder_helper(current, array)\n end", "def visit_path_to_root(leaf_id)\n node = @leaf_count + leaf_id\n while node > 0\n yield node\n node = HashTree.parent(node)\n end\n self\n end", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def pre_order_traversal\n nodes = []\n nodes.push(@root_value)\n nodes += @left.pre_order_traversal if @left\n nodes += @right.pre_order_traversal if @right\n nodes\n end", "def create_level_linked_list (root, lists, level)\n return if root == nil\n\n list = nil\n if lists.length == level\n list = LinkedList.new\n lists.add(list)\n else\n list = lists[level]\n end\n list.append(root)\n create_level_linked_list(root.left, lists, level + 1)\n create_level_linked_list(root.righ, lists, level + 1)\nend", "def inorder\n # raise NotImplementedError\n return inorder_helper(@root, [])\n end", "def level_order\n explored = []\n queue = Queue.new\n explored.push(@root.value)\n queue << @root\n\n until queue.empty? do\n temp = queue.pop\n\n unless temp.left_node.nil? || explored.include?(temp.left_node.value)\n explored.push(temp.left_node.value)\n queue << temp.left_node\n end\n\n unless temp.right_node.nil? || explored.include?(temp.right_node.value)\n explored.push(temp.right_node.value)\n queue << temp.right_node\n end\n end\n\n return explored\n end", "def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend" ]
[ "0.7001168", "0.692979", "0.6651891", "0.6468201", "0.63526684", "0.6251386", "0.6214225", "0.6214225", "0.62011975", "0.6180848", "0.61718875", "0.61216074", "0.60703385", "0.60478944", "0.6040133", "0.60288537", "0.60275966", "0.5959344", "0.59506744", "0.5942456", "0.5942456", "0.59358704", "0.5935601", "0.59280306", "0.5920009", "0.5912219", "0.5892067", "0.58917654", "0.58778286", "0.5867402", "0.58620185", "0.5851377", "0.58445066", "0.584026", "0.5835931", "0.5828471", "0.5804966", "0.5802355", "0.57958704", "0.57953", "0.5794384", "0.5789", "0.57730466", "0.5772831", "0.57596564", "0.5750593", "0.57503545", "0.57438225", "0.5739898", "0.57393605", "0.5737569", "0.573232", "0.57307744", "0.5728101", "0.57232594", "0.5721408", "0.57210106", "0.5718026", "0.57176995", "0.57165164", "0.5714579", "0.57074714", "0.57022125", "0.570129", "0.5700073", "0.5696645", "0.56951493", "0.56932384", "0.5690809", "0.56858253", "0.5681602", "0.56810546", "0.5674349", "0.5663614", "0.5661653", "0.56516194", "0.56506276", "0.56486654", "0.5648466", "0.5648339", "0.564043", "0.5636221", "0.5633963", "0.5628859", "0.56258434", "0.5621359", "0.56072634", "0.5606443", "0.56047565", "0.56041646", "0.5602251", "0.56004703", "0.55991495", "0.55976", "0.55976", "0.5596204", "0.5595981", "0.5594913", "0.5594748", "0.5588529", "0.5587928" ]
0.0
-1
return a sequence of all values on the path to this node
def valuePath(node, delimiter=' ') result = [] while (node.parent != nil) do reverseAddValues(result, node.incomingEdgeStartOffset, node.incomingEdgeEndOffset) node = node.parent end result.reverse! return result.join(delimiter) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def values\n @children\n end", "def values\n root.values\n end", "def values\n attribute_nodes.map(&:value)\n end", "def each\n return [] if root.nil?\n root.traverse do |node|\n yield node.value\n end\n end", "def values\n if node_type == :leaf\n [payload]\n else\n payload.values\n end\n end", "def values\n return @values\n end", "def values\n return @values\n end", "def values\n return @values\n end", "def values_array\n @_field_path.map{ |field_| @_values[field_.name] }\n end", "def values\n @values ||= []\n end", "def values\n @values ||= []\n end", "def values\n @values\n end", "def values\n self\n end", "def nodes\n @pathway.graph.keys\n end", "def path_arr()\n return @paths\n end", "def value\n ret=\"\"\n for c in @children\n ret+=c.value\n end\n return ret\n end", "def values\n []\n end", "def values\n @values.values\n end", "def values\n @values.values\n end", "def pathlist\n @path\n end", "def values\n @values.values\n end", "def patharray\n return @pathArray\n end", "def values\n self[:values]\n end", "def values\n end", "def values\n @@values\n end", "def values\n map(&:last)\n end", "def all\n root.to_a\n end", "def values\n list = []\n each_value{|value| list << value}\n list\n end", "def values\n @values\n end", "def values\n @values\n end", "def values\n [0, 1, -node.value]\n end", "def values() end", "def all_data_paths(path)\n each_data_path(path).to_a\n end", "def paths\n @attributes[:paths]\n end", "def paths\n @attributes[:paths]\n end", "def children()\n bag.ls(path).map { |pat| bag.get(pat) }.compact\n end", "def values\n vals = []\n each{|k,v| vals << v}\n vals\n end", "def get_all_vals(node, arr)\n # add the value of the node to the array\n arr << node.val\n \n # using a ternary operator, check if there is another node in the list\n # if so, recursively run the function again\n # if not, return the array\n return node.next ? get_all_vals(node.next, arr) : arr\n end", "def rest\n @values.rest\n end", "def values\n [@left, @right]\n end", "def all\n Maglev::PERSISTENT_ROOT[self].values\n end", "def get_values_for_verification\n \t@intermediate_nodes = self.get_intermediate_nodes\n @array = []\n\n @intermediate_nodes.each do |node|\n @array << node.sha.to_s\n if node.is_right_child\n @array << \"rchild\"\n else\n @array << \"lchild\"\n end\n end\n\n \t@array << Node.get_root_node.sha.to_s\n @array << \"root\"\n\n \treturn @array\n #return @intermediate_nodes\n end", "def paths\n @traversal_result = :paths\n @raw = true\n self\n end", "def path_array\n path = []\n yield_path do |x, y|\n path << [x,y]\n end\n path.reverse\n end", "def values\n @navigable_map.values.to_a\n end", "def values\n end", "def values\n entries.map {|e| e.value }\n end", "def values\n @ledger.values\n end", "def values; end", "def values; end", "def values; end", "def values; end", "def values; end", "def values; end", "def values; end", "def all\n Maglev::PERSISTENT_ROOT[self].values\n end", "def paths()\n assert( @maximum.exists?, \"you cannot obtain paths() for an infinite Repeater\" )\n assert( @maximum <= 10, \"if you really need to obtain paths() for a Repeater with greater than 10 elements, change this assertion\" )\n \n #\n # First, compile the element to its paths. We will end up with a BranchPoint.\n \n element_paths = nil\n if @element.is_an?(ExpressionForm) then\n element = @element.paths\n else\n element = BranchPoint.new( Sequence.new(@element) )\n end\n \n #\n # Next, produce a BranchPoint with a Sequence for each count we are doing.\n \n run = Sequence.new()\n minimum.times do\n run << element\n end\n \n result = BranchPoint.new( run )\n (maximum - minimum).times do\n run = Sequence.new( run, element )\n run.minimal = false\n result << run\n end\n \n \n #\n # Finally, get the paths of the produced Sequence.\n \n return result.paths\n end", "def values\n @store.all_values\n end", "def values\n @hash.values\n end", "def values\n @data.values\n end", "def values\n self.map('lambda{|(_, value)| value}')\n end", "def to_a\n nodes.map(&:at)\n end", "def values\n keys.map {|key| self[key] }\n end", "def values(context, xpath)\n enum = context.find(xpath) if context\n (enum || []).map { |node| node.value }\n end", "def values\n rows.map{|r| r.value}\n end", "def values\n @hash.values\n end", "def to_a\n _evaluated_nodes\n end", "def values\n @observables.map{|observable| @values[observable] }\n end", "def nodes\n nodes_by_id.values\n end", "def all_paths\n\t\t\t\treturn @all_paths if @all_paths.length > 0\n\n\t\t\t\t# Looks like we have to build a list of paths!\n\t\t\t\tputs \"[MacroDeck::TurkResponseTree::Tree] Getting all paths...\"\n\t\t\t\[email protected]_path do |path, value|\n\t\t\t\t\tif !@all_paths.include?(path)\n\t\t\t\t\t\tputs \"[MacroDeck::TurkResponseTree::Tree] Adding path #{path}\"\n\t\t\t\t\t\t@all_paths << path\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def values(*) end", "def values\n to_enum(:each_value).to_a\n end", "def elements\n @resolver.elements\n end", "def paths\n end_verts = ends\n paths = []\n vertices.each do |v|\n end_verts.each do |e|\n x = path?(v.id, e.id)\n if x.is_a?(Array)\n x[1] << v.data\n paths << x[1]\n end\n end\n end\n end_verts.each { |e| paths << e.data }\n paths\n end", "def values\n @observables.map{|observable| @values[observable] }\n end", "def entries\n ary = []\n self.each{|*val|\n # __svalue is an internal method\n ary.push val.__svalue\n }\n ary\n end", "def each\n attribute_nodes.each { |node|\n yield [node.node_name, node.value]\n }\n end", "def values\n to_a\n end", "def path\n @path || []\n end", "def to_a\n array = [@value]\n \n list = self\n while list.next != nil\n list = list.next\n array << list.value\n end\n \n array\n end", "def nodes\n @current\n end", "def path\n result = []\n obj = self\n while obj\n result.unshift(obj.__parent_name)\n obj = obj.__parent_struct\n end\n result.shift # we alwas add a nil for one-after-the-root\n result\n end", "def outputs\n [Graph::OperationOutput.from_index(self.value_handle, 0)]\n end", "def path\n return @path_array if @path_array\n parent_category = self\n @path_array = [parent_category]\n while (parent_category = parent_category.parent) != nil do\n @path_array.insert(0, parent_category) \n end\n @path_array\n end", "def cache_nodes_to_array\n arr = []\n node = @rear_node\n begin\n arr << node.value\n node = node.parent\n end while !node.nil?\n return arr\n end", "def path_states\n @__cache__[:path] ||= @superstate ? [*@superstate.path_states, self] : [self] # recursion\n end", "def find_all_paths\n found_paths = []\n \n explore(found_paths, nil, @start_node)\n \n found_paths\n end", "def path\n @value[:value]\n end", "def values\n @heap.values\n end", "def get_array(element, path='.')\n return unless element\n \n result = element/path\n if (result.is_a? Nokogiri::XML::NodeSet) || (result.is_a? Array)\n result.collect { |item| self.get(item) }\n else\n [self.get(result)]\n end\n end", "def items\n self.attrs[:value].items\n end", "def children\n @ref.children.to_ruby\n end", "def returnList\n\t\telements = []\n\t\tcurrent = @head\n\t\twhile current != nil\n\t\t\telements << current.value\n\t\t\tcurrent = current.nnode\n\t\tend\n\t\treturn elements\n\tend", "def next_paths\n Operations.list.map do |operation|\n new_value = Operations.send(operation, @current_value)\n operation_history = @operation_history + [operation]\n Path.new(new_value, @target_value, operation_history: operation_history)\n end\n end", "def descendents\n respond_to?(:values) ? values.map { |d| d.branch }.flatten : []\n end", "def return_list\n entries = []\n current_node = @head\n\n while current_node.next != nil\n entries << current_node.value\n current_node = current_node.next\n end\n entries << current_node.value\n end", "def sequence()\n if !defined?(@sequence) or @sequence.nil? then\n @sequence = []\n each_sequence_member() {|member| @sequence << member }\n end\n \n return @sequence\n end", "def sequence()\n if !defined?(@sequence) or @sequence.nil? then\n @sequence = []\n each_sequence_member() {|member| @sequence << member }\n end\n \n return @sequence\n end", "def values\n [0.0, 1.0] << -node.value\n end", "def values\n\n self.to_h.values\n end" ]
[ "0.7139397", "0.6800723", "0.66421354", "0.6624869", "0.654528", "0.6463912", "0.6463803", "0.6463803", "0.64038974", "0.6389843", "0.6373345", "0.6357579", "0.6349133", "0.63451654", "0.6336964", "0.63289005", "0.6327196", "0.6311051", "0.63000196", "0.62671226", "0.6247252", "0.6227491", "0.62244624", "0.6197724", "0.6196675", "0.6194477", "0.61639905", "0.61335284", "0.61305904", "0.61305904", "0.6128653", "0.61047876", "0.6099339", "0.60989964", "0.60989964", "0.6080157", "0.60748637", "0.60578084", "0.60513103", "0.6039483", "0.6005556", "0.5999749", "0.5995895", "0.599306", "0.5980256", "0.5973714", "0.5963314", "0.5955582", "0.59388584", "0.59388584", "0.59388584", "0.59388584", "0.59388584", "0.59388584", "0.59388584", "0.59379655", "0.59367", "0.5927585", "0.5907907", "0.5899767", "0.58898294", "0.5887933", "0.58818585", "0.58762836", "0.58730155", "0.5852722", "0.5845294", "0.5830082", "0.5827224", "0.58078593", "0.57967895", "0.5794974", "0.57724875", "0.5771567", "0.576183", "0.57617515", "0.57521254", "0.5749134", "0.5742301", "0.5732415", "0.5726233", "0.57128215", "0.5710921", "0.57045496", "0.56933", "0.5693177", "0.5692916", "0.56814045", "0.5678345", "0.5672999", "0.565676", "0.5652713", "0.56517625", "0.5650378", "0.56490636", "0.5647254", "0.56469834", "0.56469834", "0.5643299", "0.5624048" ]
0.6242129
21
return edge value sequence in reverse (used when getting path to root from a node)
def reverseAddValues(result, startOffset, endOffset) if (endOffset == Node::CURRENT_ENDING_OFFSET) then result << @dataSource.valueAt(startOffset) else scanner = endOffset while (scanner >= startOffset) do result << @dataSource.valueAt(scanner) scanner -= 1 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse\n\t self.class.new(*(edges.reverse.map! {|edge| edge.reverse! }))\n\tend", "def reverse_direction node\n case node\n when :up\n :down\n when :down\n :up\n when :left\n :right\n when :right\n :left\n else\n nil\n end\n end", "def trace_path_back(node)\n node.path_values.reverse\n end", "def reverse_sequence\n revcom(sequence)\n end", "def reverse_1 node\n prev = nil\n while node\n node.next, prev, node = prev, node, node.next\n end\n prev\n end", "def each_reversed\n\n this_node = @tail\n\n size.times do |i|\n yield this_node.value\n this_node = this_node.previous\n end\n\n return self\n end", "def valuePath(node, delimiter=' ')\n result = []\n while (node.parent != nil) do\n reverseAddValues(result, node.incomingEdgeStartOffset, node.incomingEdgeEndOffset)\n node = node.parent\n end\n result.reverse!\n return result.join(delimiter)\n end", "def nodes_downward\n LinkEnumerator.new :down, self\n end", "def reverse\n return self unless directed?\n result = DirectedAdjacencyGraph.new\n each_vertex { |v| result.add_vertex v }\n each_edge { |u,v| result.add_edge(v, u) }\n result\n end", "def reverse\n reverseDiGraph = DiGraph.new\n @vertices.each {|x| adj(x).each { |y| reverseDiGraph.add_edge(y, x) } }\n reverseDiGraph\n end", "def reverse!\n\t vertices.reverse!\n\t edges.reverse!.map! {|edge| edge.reverse! }\n\t self\n\tend", "def rev\n self[:rev]\n end", "def reverse() end", "def reverse() end", "def reverse\n #reassign first node to point to nil\n prior_node=nil\n current_node = @first\n next_node = @first.next_node\n current_node.next_node=nil\n\n while next_node\n prior_node = current_node\n current_node = next_node\n next_node = current_node.next_node\n current_node.next_node = prior_node\n end\n last=@last\n @last=@first\n @first=last\n end", "def reverse_print\n\t\taux = @tail\n\t\t\n\t\twhile aux != nil do\n\t\t\tputs aux.value.to_s\n\t\t\taux = aux.prev\n\t\tend\n\tend", "def reversal\n result = self.class.new\n vertices.each { |vertex| result.add_vertex(vertex) }\n edges.each do |edge|\n newedge = edge.class.new(edge.target, edge.source, edge.label)\n result.add_edge(newedge)\n end\n result\n end", "def reverse_traversal\n list_array = []\n recurse_reverse(@head)do |val|\n list_array << val\n end\n list_array\n end", "def rev\n end", "def rev\n self[:_rev]\n end", "def rev; self['_rev']; end", "def reverse node\n prev = nil\n while node\n tmp = node.next\n node.next = prev\n prev = node\n node = tmp\n end\n prev # not in book\n end", "def reverse\n current_node = @head\n @tail, @head = @head, @tail\n last_node = nil\n until current_node == nil\n next_node = current_node.next\n current_node.next = last_node\n\n last_node = current_node\n current_node = next_node\n end\n\n end", "def rev\n self[:_rev]\n end", "def reverse; end", "def reverse; end", "def reverse\n end", "def reverse\n end", "def reverse\n reversed = LinkedList.new \n each {|v| reversed.insert(0, v)}\n reversed\n end", "def inversed; end", "def reverse_binary\n binary.reverse\n end", "def edge\n :first if first?\n :last if last?\n nil\n end", "def edge_down(from, to)\n @edges_up[from].store(to, false)\n end", "def reverse\r\n \r\n # if the list is empty \r\n return nil if @head.nil?\r\n \r\n # if the list has one node\r\n return if @head.next.nil?\r\n \r\n current = @head\r\n previous = nil\r\n \r\n until current == nil\r\n # move temp forward one node\r\n temp = current.next\r\n # make next node point to previous / reverse the direction of the arrow\r\n current.next = previous\r\n # make previous current node\r\n previous = current\r\n # move current forward one node to 'temp'\r\n current = temp\r\n end\r\n # make formerly last node the head\r\n @head = previous\r\n end", "def reverse\n\n @last = @head\n\n # start at first node\n prior_node = nil\n current_node = @head\n next_node = current_node.next\n current_node.next = nil # flip pointer\n\n loop do\n prior_node = current_node\n current_node = next_node\n next_node = current_node.next\n current_node.next = prior_node # flip pointer\n break if next_node.nil?\n end\n\n @head = current_node\n\n end", "def path(from, to)\n prev = bfs(from)[0]\n return nil unless prev[to]\n rev_path = []\n current_vertex = to\n while current_vertex\n rev_path << current_vertex\n current_vertex = prev[current_vertex]\n end\n rev_path.reverse\n end", "def reverse\n current = @top\n prev = nil\n \n until current == nil\n n_node = current.next_node\n current.next_node = prev\n prev = current\n current = n_node\n end\n @head = prev\n end", "def explore_downwards(node)\n node = node.left until node.left.nil?\n node.data\nend", "def get_edge_list\n e_list = []\n\n @edges.each do |e|\n e_list << [e.value, e.node_from.value, e.node_to.value]\n end\n\n e_list\n end", "def reverse\n current_node = @head\n prev_node = nil\n loop do\n next_node = current_node.next\n break if current_node.next.nil?\n current_node.next = prev_node\n prev_node = current_node\n current_node = next_node\n end\n @last = @head\n @head = prev_node\n end", "def reverse\n previous = nil\n current = @head\n nxt = current.next_node\n\n return current if nxt.nil?\n current.next_node = previous\n\n while nxt != nil\n previous = current\n current = nxt\n nxt = nxt.next_node\n end\n\n current.next_node = previous\n @head = current\n end", "def reverse_property\n @data[\"reverse_property\"]\n end", "def edge_vertices( edge )\r\n if edge_reversed?( edge )\r\n edge.vertices.reverse\r\n else\r\n edge.vertices\r\n end\r\n end", "def edges_to(node)\n edges.select { |edge| edge.last == node }\n end", "def reverse\n reverse_list = SinglyLinkedList.new\n node = @head\n while node\n reverse_list.prepend(node.value)\n node = node.next\n end\n reverse_list\n end", "def convert_node_to_rev(node)\n %x(git rev-list --reverse HEAD | grep -n #{node} | cut -d: -f1).to_i\n end", "def reverse\n `return self.split('').reverse().join('');`\n end", "def reverse\n `return self.split('').reverse().join('');`\n end", "def to_s\n edges.collect {|e| e.to_s}.sort.join\n end", "def trace_path_back(end_pos)\n last_node = self.find_path(end_pos)\n return \"we can't find the end pos\" if last_node == nil\n path_arr = [last_node.pos]\n\n until last_node.parent == nil\n path_arr << last_node.parent.pos\n last_node = last_node.parent\n end\n\n path_arr.reverse\n end", "def reverse\r\n if !@head || [email protected] \r\n # if 0 or 1 node, then nothing to reverse\r\n return\r\n end\r\n \r\n prev = @head\r\n curr = @head.next \r\n \r\n # first make the @head point to nil since it's the new tail now\r\n @head.next = nil\r\n \r\n # traverse the SLL\r\n while curr \r\n \r\n if curr.next\r\n upcoming = curr.next # needed to define upcoming so it's anchored down\r\n else\r\n upcoming = nil\r\n end\r\n \r\n # flip the direction of curr.next arrow\r\n curr.next = prev \r\n \r\n # redefine the prev/curr focus \r\n prev = curr\r\n if upcoming \r\n curr = upcoming \r\n else \r\n # reached the end of SLL, which is the new @head\r\n @head = curr\r\n return\r\n end\r\n end\r\n end", "def backward\n direction(:backward)\n end", "def reverse\n return nil if @head.nil?\n\n current = @head\n\n until current.next.nil?\n temp = current.next\n current.next = current.previous\n current.previous = temp\n current = temp\n end\n\n current.next = current.previous\n current.previous = nil\n @head = current\n\n return @head\n end", "def edge_number\n @edge_number\n end", "def e33_reverse_iter(root)\n previous_node = nil\n current = root\n while current != nil\n next_node = current.next\n current.next = previous_node\n previous_node = current\n current = next_node\n end\n\n return previous_node\n end", "def reverse!\n low = 0\n high = self.__size - 1\n while low < high\n a = self.__at(low)\n b = self.__at(high)\n self.__at_put(high, a)\n self.__at_put(low, b)\n low = low + 1\n high = high - 1\n end\n self\n end", "def rightascensionascendingnode\n (@line2[17...25]).to_f\n end", "def e33_reverse_recur(node)\n # if the list is null, return null\n return nil if node.nil?\n # if reached the end of the list, return the node\n return node if node.next.nil?\n\n # get the next node\n next_node = node.next\n\n # reverse the rest of the nodes\n rest = e33_reverse_recur(next_node)\n # reverse the current pair of nodes\n next_node.next = node\n # set node as the new tail\n node.next = nil\n\n # return the new root\n return rest\n end", "def decode_path(goal_node)\n path = []\n until goal_node.nil?\n path.unshift goal_node\n goal_node = goal_node.previous\n end\n return path\nend", "def reverse\n new_graph = NetworkX::DiGraph.new(@graph)\n @nodes.each { |u, attrs| new_graph.add_node(u, attrs) }\n @adj.each do |u, edges|\n edges.each { |v, attrs| new_graph.add_edge(v, u, attrs) }\n end\n new_graph\n end", "def path_to(v)\n return nil if not @visited[v]\n path = [v]\n while @path[v]\n path << @path[v]\n v = @path[v]\n end\n return path.reverse\n end", "def reverse_rec node, prev=nil\n return prev unless node\n tmp = node.next\n node.next = prev\n reverse_rec tmp, node\n end", "def reverse_graph\n copy_graph # clone copy of old graph in cadj_lists, ca_matrix\n read_vertices\n read_edges(1, 0)\n @a_matrix = a_matrix.transpose\n end", "def reverse_2(head)\n current = head\n previous = nil\n next_node = nil\n\n while current do\n # copy current.nextnode to variable\n next_node = current.nextnode\n current.nextnode = previous\n previous = current\n current = next_node\n end\n\n return previous\n\nend", "def reverse\n new(map { |direction| direction.reverse })\n end", "def reverse\n cursor = @tail\n @head = cursor\n until !cursor.prev do\n\n temp = cursor.next\n cursor.next = cursor.prev\n cursor.prev = temp\n cursor = cursor.next\n \n end\n cursor.prev = cursor.next\n cursor.next = nil\n\n @tail = cursor \n \n end", "def reverse!\n a = return_list.reverse\n\n @head = Node.new(a.first, nil)\n \n a[1..-1].each do |i|\n add(i)\n end\n end", "def opposite_adjacencies(direction, edge)\n opposite_vertex = other_vertex(direction, edge)\n vertex_adjacencies(direction, opposite_vertex)\n end", "def values\n [0, 1, -node.value]\n end", "def trace_path_back(end_node)\n path = []\n\n current_node = end_node\n until current_node.nil?\n path << current_node\n current_node = current_node.parent\n end\n\n path\n end", "def end_vertices(edge)\n from = edge.from\n to = edge.to\n return from, to\n end", "def reverse!(opts = {})\n iv = out_vertex\n ov = in_vertex\n id = element_id if opts[:reuse_id]\n new_label = opts.fetch(:label, label)\n props = properties\n delete!\n graph.create_edge id, ov, iv, new_label, props\n end", "def reverse\n closed!\n @leds.reverse!\n self\n end", "def reverse_iter_e33(root)\n\t\t\tprevious_node = nil\n\t\t\tcurrent = root\n\t\t\twhile current != nil\n\t\t\t\tnext_node = current.next\n\t\t\t\tcurrent.next = previous_node\n\t\t\t\tprevious_node = current\n\t\t\t\tcurrent = next_node\n\t\t\tend\n\t\t\treturn previous_node\n\t\tend", "def edges\n @pathway.relations.collect do |rel|\n [ rel.node[0], rel.node[1], rel.relation ]\n end\n end", "def reverse(head)\n return nil if head.nil?\n current = head\n previous_node = nil\n \n until current.nil?\n next_node = current.next_node\n current.next_node = previous_node\n previous_node = current\n current = next_node\n \n \n end\n \n return previous_node\nend", "def output_route( node )\n if @visited[node].previous\n return output_route( @visited[node].previous ) + \" -> \" + node.to_s\n else\n return node.to_s\n end\n end", "def reversed_each\r\n record = @tail\r\n while record\r\n yield record[:key], record[:value]\r\n record = record[:previous]\r\n end\r\n end", "def find_path(end_pos)\n end_node = self.root_node.dfs(end_pos)\n final_arr = trace_back(end_node).map{ |el| el.value }\n final_arr.reverse\n end", "def backward\n recursive_set(*@in) { |n| n.in }\n end", "def print_path path\n reverse = { north: 'N', south: 'S', east: 'E', west: 'W' }\n puts path.map { |i| reverse[i] }.join \"\"\nend", "def reverse()\r\n self.reduce(List.new) { |new_list, item| new_list.cons(item) }\r\n end", "def reverse!() end", "def reverse!() end", "def reverse_each\n\t\treturn nil unless block_given?\n\n\t\tcurrent = self.tail\n\t\twhile current\n\t\t\tyield current\n\t\t\tcurrent = current.prev\n\t\tend\n\tend", "def reverse\r\n prev = nil\r\n cursor = @head\r\n while cursor do\r\n temp = cursor.next\r\n cursor.next = prev \r\n prev = cursor\r\n cursor = temp \r\n end\r\n @head = prev\r\n end", "def get_edges\n getEdges.to_route(:graph => self, :element_type => :edge)\n end", "def get_edges\n getEdges.to_route(:graph => self, :element_type => :edge)\n end", "def reverse\n current = @head\n previous = nil\n while current != nil\n temp = current.next # save state\n current.next = previous # update link\n\n # move to next\n previous = current\n current = temp\n end\n @head = previous\n end", "def reverse!\n old_list = self\n new_list = List.new(self.last_node)\n previous_node = self.get_previous_node(self.last_node)\n old_list.remove(old_list.last_node)\n reverse_util(old_list, new_list, previous_node)\n end", "def get_edge(edge)\n return nil unless edge[:from][:name]\n return nil unless edge[:to][:name]\n\n #Get the type of the edge\n type = edge[:type] || Config::DEFAULT_TYPE\n edge[:type] = type\n\n #Check if the edge type exists\n etype = Marshal.load(@db.m_get(\"edge#{type}\") || Marshal.dump({})) \n \n #Integrity check: Check whether the edge direction is not contradictory\n if edge[:directed]\n if etype[:directed] != nil\n if etype[:directed] != edge[:directed]\n return nil\n end\n else\n #If there is no edge of that type then pre-empt the result\n return nil\n end\n else\n if etype[:directed] != nil\n edge[:directed] = etype[:directed]\n else\n #If there is no edge of that type then pre-empt the result\n return 3\n end\n end\n\n #Convert the edge into a Key string and fetch the corresponding data\n key, reverse_key = Keyify.edge(edge)\n value = @db.e_get(key)\n\n if value\n new_edge = Marshal.load(value)\n new_edge[:from] = self.get_node(edge[:from])\n new_edge[:to] = self.get_node(edge[:to])\n new_edge[:type] = edge[:type]\n new_edge[:directed] = etype[:directed] #Pick direction alone from the meta_db for consistency\n new_edge\n end\n end", "def reverse_each\n return nil unless block_given? current = self.tail\n while current\n yield current\n current = current.prev\n end\nend", "def reverse_even\n even.reverse\n end", "def parent_reversed!\n \n return @sort_order_reversed = ! @sort_order_reversed\n \n end", "def sequence\n if !sequence?\n raise NotImplementedException, \"Attempted to get the sequence of a velvet node that is too short, such that the sequence info is not fully present in the node object\"\n end\n kmer_length = @parent_graph.hash_length\n\n # Sequence is the reverse complement of the ends_of_kmers_of_twin_node,\n # Then the ends_of_kmers_of_node after removing the first kmer_length - 1\n # nucleotides\n length_to_get_from_fwd = corresponding_contig_length - @ends_of_kmers_of_twin_node.length\n fwd_length = @ends_of_kmers_of_node.length\n raise \"Programming error\" if length_to_get_from_fwd > fwd_length\n revcom(@ends_of_kmers_of_twin_node)+\n @ends_of_kmers_of_node[-length_to_get_from_fwd...fwd_length]\n end", "def create_path(node)\n path = []\n until node == nil\n path << node.data\n node = node.parent\n end\n path.reverse\n end", "def reverse_post\n @reverse_post.reverse\n end", "def backwards(input)\n input.reverse\nend", "def edgesymbol\n directed ? '->' : '--'\n end", "def descendants\n ascendants.reverse\n end", "def edges\n @structure.reduce([]) do |acc, node|\n acc + node[1].map { |dest| [node[0], dest] }\n end\n end" ]
[ "0.66804945", "0.6627718", "0.6606265", "0.6590033", "0.6417159", "0.6351281", "0.6344506", "0.62929296", "0.6169757", "0.60766906", "0.604789", "0.6007824", "0.600764", "0.600764", "0.6007551", "0.5992082", "0.59778845", "0.5970679", "0.59269124", "0.5868154", "0.5859796", "0.5841432", "0.58377194", "0.58316106", "0.582647", "0.582647", "0.5818564", "0.5818564", "0.5794454", "0.5771113", "0.5768345", "0.5762928", "0.5720532", "0.5694536", "0.5686045", "0.56847066", "0.56828624", "0.5667766", "0.5666193", "0.56593305", "0.56574786", "0.5646809", "0.5646575", "0.56345606", "0.5626142", "0.560847", "0.5585562", "0.5585562", "0.5566661", "0.55661035", "0.5538993", "0.5531843", "0.55301", "0.55085", "0.5502282", "0.5497286", "0.54773974", "0.54761595", "0.5466498", "0.54416233", "0.54362005", "0.54190195", "0.54143333", "0.5391686", "0.53897035", "0.537742", "0.537609", "0.53637964", "0.5343748", "0.5341144", "0.53400666", "0.53398436", "0.53386647", "0.5337742", "0.53324324", "0.5331542", "0.53282535", "0.5327026", "0.5319272", "0.5312751", "0.5310888", "0.53100663", "0.530427", "0.530427", "0.5296392", "0.5289655", "0.5273007", "0.5273007", "0.52636904", "0.5263633", "0.5261648", "0.52597517", "0.52592707", "0.5256589", "0.5255737", "0.5254429", "0.5251573", "0.52472526", "0.5244936", "0.52399904", "0.52380794" ]
0.0
-1
1 84 12 76 451 089 46 46 = (97 1841276451089) % 97 remainder of the division of (97 ssn_without_key) by 97
def valid_key?(match_data) match_data[:key].to_i == (97 - match_data[1..-2].join.to_i) % 97 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index(key, size)\n #true_index = hash(key) % k\n code = 0\n key.split(%r{\\s*}).each do |letter|\n code += letter.ord \n end\n puts code\n return code % size\n\n end", "def ssn_key_valid?(ssn_number)\n key = ssn_number[-2..-1].to_i\n ssn_without_key = ssn_number[0..-3].delete(\" \").to_i\n remainder_of_calculation = (97 - ssn_without_key) % 97\n remainder_of_calculation == key\nend", "def int_to_key(num)\n #10s digit = num/26\n d1 = num/26 + 97\n\n #1s digit = num%26\n d2 = num%26 + 97\n result = d1.chr + d2.chr\n\n return result\nend", "def hashify(key)\n array = key.split('')\n count = array.count\n index = array.inject(0) do |object,char|\n object += char.ord ** count\n count -= 1\n object\n end\n index % 89\n end", "def index(key, size)\n #sums up the ascii values of each char in a string\n code = key.sum\n return code % size\n end", "def get_lh_hash(key)\n res = 0\n key.upcase.bytes do |byte|\n res *= 37\n res += byte.ord\n end\n return res % 0x100000000\n end", "def decode(numbers, key)\n result = \"\"\n numbers.each_with_index do |n, i|\n result += (n ^ key[i % 3].ord).chr\n end\n result\nend", "def index(key, size)\n hash_code = 0\n array_of_characters = key.split('')\n array_of_characters.each do |letter|\n hash_code += letter.ord\n end\n hash_code % size\n end", "def index(key, size)\n ascii_value = 0\n hash_key = 0\n\n key.split(\"\").each do |letter|\n ascii_value += letter.ord #Method to retrieve ascii\n end\n\n hash_key = ascii_value % size\n\n return hash_key\n end", "def index(key, size)\n ascii = 0\n \n key.each_byte do |x|\n ascii += x\n end\n \n return ascii % size\n end", "def wrapping_round( offset )\n\n # z == 122 ascii\n # 26 letters\n # a == 97 ascii\n # offset the amount to change the letter to\n # e.g. offset = 3 and letter = a so, 97 + 3 = 100 == d\n\n number = ( 122 - 97 + offset ) % 26\n\n p number\n\nend", "def hard(string)\n hasher = KnotHash.new(256, string.bytes + [17, 31, 73, 47, 23])\n 64.times { hasher.round }\n hasher.hash\nend", "def kidmod10(base); end", "def index(key, size)\n ascii_sum = 0\n key.split(\"\").each do |word|\n ascii_sum += word.ord\n end\n ascii_sum % size\n end", "def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n\n sum % size\n end", "def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n\n sum % size\n end", "def crypt(text,key,operator = :+)\n index = 0\n text.upcase.each_byte.reduce(\"\") do |res, c|\n res << (65 + (c.send(operator, key[index % key.length].ord)) % 26).chr\n index += 1\n res\n end\nend", "def partify key\n nums = key.scan(/[0-9]/).join.to_i\n spaces = key.scan(/ /).size\n \n raise \"Key Error: #{key} has no spaces\" if spaces == 0\n raise \"Key Error: #{key} nums #{nums} is not an integral multiple of #{spaces}\" if (nums % spaces) != 0\n\n [nums / spaces].pack(\"N*\")\n end", "def get_hash(str, elem_num)\n tmp = 0\n s = str.unpack(\"C*\")\n for i in 1..s.size\n tmp += s[i-1]\n end\n return tmp % elem_num\n end", "def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n\n sum % size\n\n end", "def vigenere(key, txt)\n shift_array = key.get_shift\n count = 0\n\n txt_array = txt.split('')\n ciph=[]\n\n txt_array.each do |a|\n a = a.ord\n shift = shift_array[count % shift_array.size]\n case a\n when (64..90) \n new_char = ((a - 64 + shift) % 26) + 64 \n count += 1\n when (97..122)\n new_char = ((a- 97 + shift) % 26) + 97\n count += 1\n else \n new_char = a \n end\n ciph.push(new_char.chr)\n end\n\n ciph = ciph.join('')\n puts \"#{ciph}\"\nend", "def index(key, size)\n char_value = 0\n # Adds together all of the ASCII values for each character into char_value.\n for letter in key.chars do\n char_value += letter.ord\n end\n # Increments char_value until its length equals desired size.\n until char_value.to_s.length == 7\n char_value*=11\n end\n\n return char_value%size\n end", "def index(key, size) #take the asscii value % size to come up with index\n total = 0\n key.each_byte do |c|\n total = c + total\n end\n total % size\n\n end", "def add_key_to_ascii(ascii_num, key)\n\tif (ascii_num + key).between?(91, 96) or (ascii_num + key)> 122\n\t\t# si la somme == entre 91 et 96 ou si la somme > à 122\n\t\tascii_num + key - 26\n\t\t# soustraire 26\n\t\t# fait une boucle entre l'alphabet minuscule et majuscule\n\t\t# alphabet minuscule de 97 à 122 : revient à 97 quand > à 12\n\t\t# ALPHABET de 65 à 90 : permet de squeezer la tranche 91-96 avec charactère spéciaux\n\telse\n\t\tascii_num + key \n\t\t# pour le reste, pas de soucis de boucle d'alphabet\t\t\n\tend\n\t\nend", "def encrypt_single_key(key,value)\n offset,encrypted, off_i = key,[] , 1\n value.split('').each_with_index do |val, i|\n val.ord >= 97 && val.ord <= 122 ? dist = val.ord - (offset % 26) : dist = val.ord\n dist < 97 && dist != val.ord ? (encrypted.push (122 - (97 - (dist+1))).chr) : (encrypted.push dist.chr)\n end\n return encrypted.join\n end", "def hash\n num = 0\n self.each do |k,v|\n if k.is_a?(Integer) && v.is_a?(Integer)\n num += k * 26 + v\n elsif k.is_a?(Integer) && !v.is_a?(Integer)\n num += k * 26 + ALPHA_NUMBERS[v.to_s.downcase]\n elsif v.is_a?(Integer) && !k.is_a?(Integer)\n num += v * 26 + ALPHA_NUMBERS[k.to_s.downcase]\n elsif !k.nil? && !v.nil?\n num += ALPHA_NUMBERS[k.to_s.downcase] * ALPHA_NUMBERS[v.to_s.downcase]\n end\n end\n num\n end", "def find_inverse(key_1)\r\n\t(1..26).each do |d|\r\n\t\treturn d if(((d * key_1) % 26) == 1) \r\n\tend\r\n\traise StandardError, \"#{key_1} has no inverse mod 26\"\r\nend", "def title_to_number(s)\n i = - 1\n s.chars.reverse.inject(0) { |agg, c|\n i += 1\n agg + 26 ** i * (c.ord - 'A'.ord + 1)\n } \nend", "def vigenere_cipher(message, keys)\n alpha = (\"a\"..\"z\").to_a\n count = 0\n message.each_char.with_index do |char, idx|\n pos = alpha.index(char)\n #rather than count we can do key alpha[(pos + key[idx % key.length] )% 26]\n message[idx] = alpha[(pos + keys[count]) % alpha.length]\n count += 1\n count = 0 if count == keys.length\n end\n message\nend", "def calculate_percentage(string) #def calculate_percentage(\"Aand\")\n characters = sanitize(string) #characters = sanitize(\"Aand\") --> {\"a\" => 2, \"n\" => 1, \"d\" => 1}\n characters.each do |letter, count| #|a, 2| |n, 1| |d,2|\n characters[letter] = count.to_f/string.length # 2/4 1/4 1/4\n end\nend", "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 index(key, size)\n # Takes the string 'key', creates an array of individual characters (split), maps to an array of ascii values (map), and then sums them (reduce)\n # Reaminder from dividing above amount by array size produces the array index\n (key.split(//).map { |char| char.ord }.reduce(:+)) % size\n end", "def index(key, size)\n sum = 0\n key.each_char do |x|\n sum += x.ord\n end\n sum % size\n end", "def vigenere_cipher(str,keys)\n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n\n str.each_char.with_index do |char,idx|\n old_pos = alpha.index(char)\n new_pos = old_pos + keys[idx % keys.length]\n new_str += alpha[new_pos % alpha.length]\n end\n\n new_str\n\nend", "def modulo(p0) end", "def encode_int rsakey, x\n e,n = rsakey\n return fastexp_mod x,e,n\nend", "def saveThePrisoner(n, m, s)\n mod = (m % n == 0) ? n : (m % n)\n return ((mod + s -1) % n == 0) ? n : (mod + s -1) % n\n\nend", "def add_nums_mod(string1, string2)\n s1, s2 = string1.split, string2.split\n s1.size.times.map { |i| (s1[i].to_i + s2[i].to_i) % 26 }\n .join(' ')\n end", "def sha_to_b62 sha\n sint = sha.to_i(16)\n res = \"\"\n digits = (\"0\"..\"9\").to_a + (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a\n while sint > 0\n rest,units = sint.divmod(62)\n res = digits[units] + res\n sint = rest\n end\n return res\nend", "def raw_crypt(number) \n number.powmod @e, @n\n end", "def breakXORCipher(cipherText)\n scoredTexts = Hash.new\n \n #Try all ASCII keys from \n for i in 32..126 do\n keyChar = i.chr\n \n possiblePlaintext = hexToASCII(singleByteXOR(cipherText.upcase, keyChar))\n scoredTexts[keyChar] = scorePlaintext(possiblePlaintext)\n \n if(scoredTexts[keyChar] == possiblePlaintext.length)\n puts cipherText\n puts possiblePlaintext \n puts keyChar + \" scored \" + scoredTexts[keyChar].to_s\n end\n end\nend", "def encode(byte,sz = schluessel) # given are the to be encoded bytecode and the key\n # only letters will be encoded, numbers & special characters won't\n if ('A'..'Z').include?(byte.chr) || ('a'..'z').include?(byte.chr)\n start = (byte > 96) ? 'a'.ord : 'A'.ord # determine the start-value for decoding a-z & A-Z\n anzahl_zeichen = 26 # das deutsche Alphabet\n\n (byte + sz - start) % anzahl_zeichen + start\n else\n byte\n end\n end", "def movingShift(s, shift)\nres = ''\n s.chars.each do |x|\n ord = x.ord\n if x.ord > 64 && x.ord < 91\n ord = ((ord - 65 + shift) % 26) + 65\n else\n if x.ord > 96 && x.ord < 123\n ord = ((ord - 97 + shift) % 26) + 97\n end\n end\n shift+=1\n res += ord.chr\n end\n l = (res.length/5.0).ceil\nputs l\nputs res\n [res[0..l-1], res[l..2*len-1],res[2*l..3*l-1],res[3*l..4*len-1],res[4*l..-1]]\nend", "def vigenere_cipher(message, keys)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n cycle = 0\n result = \"\"\n\n message.each_char do |char|\n result += alphabet[(alphabet.index(char) + keys[cycle % keys.length]) % alphabet.length]\n cycle += 1\n end\n\n return result\nend", "def convert_to_title(n)\n result = []\n while n > 0\n n = n - 1\n div, mod = n.divmod(26)\n result.unshift((mod + 'A'.ord).chr)\n n = div\n end\n\n return result.join(\"\")\nend", "def letter_percentages(string)\n chars = string.split('')\n\n hash_of_percentages = { lowercase: 0.0, uppercase: 0.0, neither: 0.0}\n hash_of_percentages = calculate_chars(chars, hash_of_percentages)\n\n total_chars = chars.length\n hash_of_percentages = calculate_percentages(hash_of_percentages, total_chars)\n\n return hash_of_percentages\nend", "def letter_percentages(str)\n count_lowercase = 0\n count_uppercase = 0\n count_neither = 0\n\n str.each_char do |char|\n if %w(1 2 3 4 5 6 7 8 9 0).include?(char)\n count_neither += 1\n elsif ('A'..'Z').include?(char)\n count_uppercase += 1\n elsif ('a'..'z').include?(char)\n count_lowercase += 1\n else\n count_neither += 1\n end\n\n end\n\n percent_lowercase = (count_lowercase.to_f / str.length) * 100\n percent_uppercase = (count_uppercase.to_f / str.length) * 100\n percent_neither = (count_neither.to_f / str.length) * 100\n\n hsh = {\n lowercase: percent_lowercase,\n uppercase: percent_uppercase,\n neither: percent_neither\n }\nend", "def vigenere_cipher(str, arr)\n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n str.each_char.with_index do |char, i|\n pos = alpha.index(char)\n key = arr[i % arr.length]\n new_pos = (pos + key) % alpha.length\n new_str += alpha[new_pos]\n end\n new_str\nend", "def encode(ch, shift)\n\tif $lowr.include?(ch)\t\t# not the most effiecient, but easy to read\n\t\ti = $lowr.index(ch)\n\t\tj = ( i + shift ) % 26\n\t\treturn $lowr[j]\n\telsif $uppr.include?(ch)\n\t\ti = $uppr.index(ch)\n\t\tj = ( i + shift) % 26\n\t\treturn $uppr[j]\n\telsif ( ch.ord >=48 && ch.ord <= 57 )\t# a number , checking this way because non-number.to_a == '0'\n\t\ti = $nums.index(ch.to_i)\n\t\tj = ( i + shift ) % 10\n\t\treturn $nums[j].to_s\t\t\n\telse\n\t\treturn ch \t\t\t# leaves every other possible character unchanged\n\tend\nend", "def index(key, size)\n key_array = []\n key.each_byte {|c| key_array << c }\n total = 0\n key_array.each do |i|\n \ttotal += i\n end\n return total % size\n end", "def calculate_hash(input, prep_hashes)\n result = 0\n input.unpack('U*').each do |x|\n result += prep_hashes.hash(x)\n end\n (result % MOD_VALUE).to_s(HEX)\nend", "def saveThePrisoner(n, m, s)\n res = ((m - 1) + s) % n\n res == 0 ? n : res \nend", "def vigenere_cipher(message, keys)\n alpha = (\"a\"..\"z\").to_a\n new_string = \"\"\n message.each_char.with_index do |char, i|\n old_i = alpha.index(char)\n new_i = (old_i + keys[i % keys.length]) % 26\n new_string += alpha[new_i]\n end\n new_string\nend", "def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n sum % size\n end", "def best_letter string\n alphabet = ('a'..'z').to_a\n frequency_hash = Hash['a' => 1]\n alphabet.each do |x|\n frequency_hash[x] = alphabet_frequency(string, x)\n end\n #puts frequency_hash\n number_alphabet [(alphabet_number(frequency_hash.min_by{|k,v| v}.first.split(\"\")).first + 1) % 26]\nend", "def caesar_wrapper(symbol, step)\r\n\tupcase_range = (65..90)\r\n\tdowncase_range = (97..122)\r\n\t\r\n\tif (upcase_range === symbol.ord)\r\n\t\tif (symbol.ord + step > upcase_range.end)\r\n\t\t\tnew_ascii_value = upcase_range.begin + (symbol.ord + step - 1) % upcase_range.end\r\n\t\t\treturn new_ascii_value.chr\r\n\t\telse\r\n\t\t\treturn (symbol.ord + step).chr\r\n\t\tend\r\n\tend\r\n\t\r\n\tif (downcase_range === symbol.ord)\r\n\t\tif (symbol.ord + step > downcase_range.end)\r\n\t\t\tnew_ascii_value = downcase_range.begin + (symbol.ord + step - 1) % downcase_range.end\r\n\t\t\treturn new_ascii_value.chr\r\n\t\telse\r\n\t\t\treturn (symbol.ord + step).chr\r\n\t\tend\r\n\tend\r\n\t\r\n\treturn symbol\r\nend", "def s1 num\n\tnum % 2\nend", "def index(key, size)\n asc = 0\n key.each_byte do |c|\n asc += c\n end\n return asc % size\n end", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n indices = message.split(\"\").map {|char| alphabet.index(char)}\n \n ciphered_message = \"\"\n indices.each_with_index do |n, i|\n shift_amount = keys[i % keys.length]\n new_index = (n + shift_amount) % alphabet.length\n ciphered_message += alphabet[new_index]\n end\n\n ciphered_message\nend", "def sherlock(str)\n str_len = str.length\n str_arr = str.split('')\n substrings_count = {}\n result = 0\n str_arr.each_with_index do |alpha, index|\n n = str_len - index\n n.times do |pos|\n ss = str_arr[index..(index+pos)].sort.join('')\n substrings_count[ss] = substrings_count[ss] ? substrings_count[ss]+1 : 1\n end\n end\n\n substrings_count.each do |key, val|\n result = result + ((val*(val-1))/2) if val > 1\n end\n result\nend", "def cipher(char, key)\n alpha = (\"a\"..\"z\").to_a\n idx = alpha.index(char)\n new_idx = (idx + key) % 26\n alpha[new_idx]\nend", "def key_for_string str\n Digest::MD5.hexdigest(str).to_i(16) & KEY_MAX\n end", "def calculate_doublepulsar_xor_key(s)\n x = (2 * s ^ (((s & 0xff00 | (s << 16)) << 8) | (((s >> 16) | s & 0xff0000) >> 8)))\n x & 0xffffffff # this line was added just to truncate to 32 bits\n end", "def decrypt_single_key(key,value)\n offset,decrypted, off_i = key,[] , 1\n value.split('').each_with_index do |val, i|\n val.ord >= 97 && val.ord <= 122 ? dist = (val.ord + offset % 26) : dist = val.ord\n dist > 122 && dist!= val.ord ? (decrypted.push (122 - (26 - (dist - 122))).chr) : (decrypted.push dist.chr)\n end\n return decrypted.join\n end", "def letter_to_number(letter)\n letter.ord - 64\nend", "def encode(plaintext, key)\n cipher = key.chars.uniq + (('a'..'z').to_a - key.chars)\n ciphertext_chars = plaintext.chars.map do |char|\n (65 + cipher.find_index(char)).chr\n end\n puts ciphertext_chars.join\nend", "def rsa_public(input, n, e)\n input_bn = OpenSSL::BN.new(input.to_s)\n n_bn = OpenSSL::BN.new(n.to_s)\n e_bn = OpenSSL::BN.new(e.to_s)\n (input_bn.mod_exp(e_bn, n_bn)).to_i\nend", "def scoobydoo(villian, villians)\n letters = ('a'..'z').to_a\n numbers = (0..25).to_a\n letters_to_numbers = letters.zip(numbers).to_h\n numbers_to_letters = numbers.zip(letters).to_h\n\n villians_downcase = villians.map { |v| v.downcase.delete(' ') }\n villians_hash = (villians_downcase).zip(villians).to_h\n\n s = villian.reverse.chars.rotate(5)\n new = []\n (0...s.size).each do |i|\n if i.even?\n new[i] = s[i]\n else\n num = (letters_to_numbers.fetch(s[i]) + 5) % 26\n new[i] = numbers_to_letters.fetch(num)\n end\n end\n\n villians_hash.fetch(new.join)\n\nend", "def s1 number\n number % 2\nend", "def distinct_subseq_ii(s)\n alphabets = ('a'..'z').to_a\n dict = Array.new(27, 0)\n mod = 10 ** 9 + 7\n total = 1\n s.chars.each do |char|\n index = alphabets.index(char) + 1\n combo = total * 2 - dict[index]\n dict[index] = total # if 'c' ever appears again, it will clash with the current combos.\n total = combo < 0 ? 0 + mod : combo % mod\n end\n total - 1 # subtract empty string\nend", "def vigenere_cipher(message, keys)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n vigenere = \"\"\n\n message.each_char.with_index do |char, i|\n index = alphabet.index(char)\n key = keys[i % keys.length].to_i\n new_char = alphabet[(index + key) % 26] \n vigenere += new_char\n end\n\n vigenere\nend", "def hornerHash( key, tableSize)\n\tsize = key.length\n\th = 0\n\ti = 0\n\twhile (i < size)\n\t\th = (32 * h + key[i].ord) % tableSize\n\t\ti += 1\n\tend\n\treturn h\nend", "def from_alpha(col)\n result = 0\n col = col.split(//)\n col.each_with_index do |c,i|\n result += (c.ord - 64) * (26 ** (col.length - (i+1)))\n end\n result\n end", "def vigenere_cipher(message, key)\n key_index = 0 \n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n\n message.each_char.with_index do|char,idx|\n new_str += alpha[(alpha.index(char) + key[key_index % key.length])%26]\n key_index += 1\n end\n new_str\nend", "def index(key, size)\n total_sum = 0\n key.each_byte do |x|\n total_sum += x\n end\n return total_sum % size\n end", "def final_letter_grades(grade_hash)\n grade_hash.transform_values{|nums| letter_grade(nums.reduce(:+) / nums.length)}\nend", "def get_hash(s)\r\n\t\tvals = s.unpack('U*').map {|x| ((x ** 2000) * ((x + 2) ** 21) - ((x + 5) ** 3))}\r\n\t\tvals = vals.inject(0, :+) % 65536\r\n\t\treturn vals.to_s(16)\r\n\tend", "def decode1(str)\n num = 0\n i = 0\n while i < str.length\n pow = BASE ** (str.length - i -1)\n num += KEYS.index(str[i]) * pow\n i += 1\n end\n return num\nend", "def prev_char c, number\n new_ord = c.ord - filter_by_95(number)\n if new_ord < 32\n new_ord += (126 - 31)\n end\n return new_ord.chr\nend", "def hashfunction(key, size)\n #key.hash % size\n key % size\n end", "def v_decode message, key\n message_array = alphabet_number(message.split(\"\"))\n key_array = alphabet_number(make_key_repeat(key.split(\"\"), message_array.length)).take(message_array.length)\n number_alphabet(message_array.map.with_index{ |m,i| (m.to_i - key_array[i].to_i + 1) % 26}).take(message_array.length).join(\"\")\nend", "def key_byte\n @i = (@i + 1) % 256\n @j = (@j + @sbox[@i]) % 256\n @sbox[@i], @sbox[@j] = @sbox[@j], @sbox[@i]\n @sbox[(@sbox[@i] + @sbox[@j]) % 256]\n end", "def sort_key\n # Make sure sequence is at least 12 long to maintain numeric sorting\n @code&.rjust(12, '0')\n end", "def generateKey(string)\r\n key = {}\r\n stringIterator = 0\r\n\r\n (string.length).times do\r\n charactersIterator = string[stringIterator] - 1\r\n divisorsIterator = 0\r\n divisors = {} # Possible divisors of the array's numbers\r\n\r\n # Check which numbers are possible divisors\r\n while charactersIterator > 0\r\n\r\n if string[stringIterator] % charactersIterator == 0\r\n divisors[divisorsIterator] = charactersIterator\r\n divisorsIterator += 1\r\n end\r\n charactersIterator -= 1\r\n end\r\n key[stringIterator] = divisors[rand(divisors.length)] # Choosing random divisor to be the primary key\r\n stringIterator += 1\r\n end\r\n\r\n return key\r\nend", "def rampant_repeats(str, hash)\n\n new_str = \"\"\n\n str.each_char { |char| new_str += char * ( hash[char] || 1) }\n\n new_str\n\nend", "def convert_to_character_code(word)\n code_array = []\n word.each_char do |character|\n character_code = character.ord\n code_array.push(character_code)\n end\n average_code = code_array.inject(0.0) { |sum, el| sum + el } / code_array.size\n average_code = average_code.ceil\nend", "def vigenere_cipher(message, keys)\n alphabet = ('a'..'z').to_a\n vigenere_str = \"\"\n\n message.each_char.with_index do |char, idx|\n old_idx = alphabet.index(char)\n temp_key = keys.shift\n keys.push(temp_key)\n new_idx = (old_idx + temp_key) % 26\n vigenere_str += alphabet[new_idx]\n end\n vigenere_str\nend", "def caesar_ciphar(string, k)\n result = ''\n string.each_char do |char|\n # Character is capital\n if char.ord <= 'Z'.ord && char.ord >= 'A'.ord\n encrypt = char.ord + (k % 26)\n if encrypt > 'Z'.ord\n result += ('A'.ord + (encrypt - 'Z'.ord) - 1).chr\n else\n result += encrypt.chr\n end\n # Character is small\n elsif char.ord <= 'z'.ord && char.ord >= 'a'.ord\n encrypt = char.ord + (k % 26)\n if encrypt > 'z'.ord\n result += ('a'.ord + (encrypt - 'z'.ord) - 1).chr\n else\n result += encrypt.chr\n end\n else\n result += char\n end\n end\n return result\nend", "def rampant_repeats(str, hash)\n n_str = ''\n str.each_char do |char|\n if hash.has_key?(char) \n n_str += char * hash[char]\n else\n n_str += char\n end\n end\n n_str\nend", "def vigenere_cipher(string, keys)\n alpha = ('a'..'z').to_a\n new_word = \"\"\n\n string.each_char.with_index do |char, idx|\n old_idx = alpha.index(char)\n new_idx = old_idx + keys[idx % keys.length]\n new_char = alpha[new_idx % alpha.length]\n new_word += new_char\n end\n\n new_word\nend", "def chinese_remainder_theorem(a, n)\n big_n = n.reduce(1, :*)\n y = n.map { |n_i| big_n / n_i }\n z = y.zip(n).map { |y_i, n_i| invmod(y_i, n_i) }\n\n a.zip(y, z).sum { |a_i, y_i, z_i| a_i * y_i * z_i } % big_n\nend", "def secure_div(divident, divisor)\n return nil if divisor == 0\n divident.to_f/divisor\n end", "def s(n)\n ((9*n-1)*(10**n)+1)/9\nend", "def replace_weight(_test_digits)\n return modulus_weight\n end", "def hashing_decode(s)\n \n i = 0\n base = ALPHABET.length\n s.each_char { |c| i = i * base + ALPHABET.index(c) }\n i\n end", "def vigenere_cipher(string, key_sequence)\n alphabet = ('a'..'z').to_a\n keys = key_sequence.dup\n result = \"\"\n while result.length < string.length\n c = string[result.length] \n offset = (alphabet.index(c) + keys.first) % 26 \n result += alphabet[offset]\n keys.push(keys.shift)\n end\n result\nend", "def decode(str)\n num = 0\n i = 0\n len = str.length - 1\n while i < str.length\n pow = BASE ** (len - i)\n num += KEYS_HASH[str[i]] * pow\n i += 1\n end\n return num\nend", "def encipher(char, shift) \n if char >= 65 && char <= 90 \n index = char - 65\n shifted_char = (index + shift) % 26\n if shifted_char < 0 \n shifted_char += 26\n enciphered_char = shifted_char + 65\n else\n enciphered_char = shifted_char + 65\n end\n elsif char >= 97 && char <= 122\n index = char - 97\n shifted_char = (index + shift) % 26\n if shifted_char < 0\n shifted_char += 26\n enchiphered_char = shifted_char + 97\n else \n enciphered_char = shifted_char + 97\n end\n else\n char = char \n end\nend", "def decode5(str)\n num = 0\n i = 0\n str.each_char do |char|\n pow = BASE ** (str.length - i -1)\n num += KEYS_HASH[char] * pow\n i += 1\n end\n return num\nend", "def hashify(key)\n array = key.split('')\n count = array.count\n array.inject(0) do |object,char|\n object += char.ord ** count\n count -= 1\n object\n end\n end" ]
[ "0.68382895", "0.680752", "0.6728683", "0.66868496", "0.6550961", "0.6449259", "0.6264985", "0.6228745", "0.62222534", "0.6213291", "0.61714464", "0.61265904", "0.6108481", "0.6100893", "0.60812724", "0.60812724", "0.60565156", "0.60534143", "0.60465074", "0.60419214", "0.60212815", "0.6000458", "0.5934163", "0.59270483", "0.5921233", "0.59009933", "0.5894868", "0.58904904", "0.58791226", "0.5857661", "0.58574563", "0.583569", "0.58328944", "0.58275455", "0.58164984", "0.5789173", "0.5787847", "0.5785048", "0.5780421", "0.57755077", "0.57730645", "0.57725483", "0.5771891", "0.5762196", "0.5754625", "0.575098", "0.57493293", "0.5746123", "0.5737438", "0.57332116", "0.5732304", "0.5725414", "0.57172805", "0.57118124", "0.5708251", "0.57073665", "0.5685506", "0.56850684", "0.5684267", "0.5680682", "0.5679492", "0.5658774", "0.56567276", "0.5648968", "0.5648434", "0.5645843", "0.5639592", "0.56395525", "0.56326014", "0.5624953", "0.56212145", "0.5617285", "0.5608852", "0.5598722", "0.55928427", "0.5591274", "0.5589405", "0.5589284", "0.5584822", "0.55825776", "0.5578175", "0.55718446", "0.55634415", "0.55424726", "0.5539142", "0.55364394", "0.5533206", "0.55294275", "0.55289894", "0.55266666", "0.55234635", "0.5520668", "0.5520205", "0.5520131", "0.5506581", "0.55048907", "0.5503634", "0.55022454", "0.54896075", "0.5488325" ]
0.56110144
72
Returns an array of items which have a paid quantity greater than zero. That is, any items which have nonbonus components.
def candidate_items sku_items.select {|i| i.paid_quantity > 0} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def items_no_sale\r\n sale = Array.new\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (!val.is_active )\r\n sale.push(val)\r\n end\r\n }\r\n end\r\n\r\n return sale\r\n end", "def get_products_bought\n res = []\n\n @data.product_qty.each do |prd_id, qty|\n qty = qty.to_i\n if qty > 0\n res << [ qty, @data.products.with_id(prd_id) ]\n end\n end\n\n res\n end", "def unpaid_line_items\n @unpaid_line_items ||= line_items.find_all_by_paid(false)\n end", "def people_not_paid\n all_paid? ? [] : people - paid_infos.keys\n end", "def paid_quantity\n map(&:paid_quantity).sum\n end", "def paid_expense_items\n paid_details.map{|pd| pd.expense_item }\n end", "def buyable_items(_entity)\n []\n end", "def aqty\n self.qty.reject(&:empty?) rescue []\nend", "def test_growthItemNullValue\n f = ItemFilter.new(\"growth\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def incomplete_products\n return self.products.select do |product|\n !product.passing? && !product.failing?\n end\n end", "def available_coins\n coins.select { |coin, quantity| quantity > 0 }.keys\n .map { |coin| Components::Coin.new(coin) }\n .reverse\n end", "def tested_products\n return self.products.select do |product|\n product.incomplete_tests.count == 0\n end\n end", "def required_expense_items\n egs = ExpenseGroup.for_competitor_type(@registrant.competitor?)\n\n egs.select { |expense_group| expense_group.expense_items.count == 1 }\n .map{ |expense_group| expense_group.expense_items.first }\n end", "def invoices_all_paid?\n self.invoices.pluck(:paid_at).map {|i| not i.nil?}.reduce(:&)\n end", "def required_item_from_expense_groups(_registrant_age)\n []\n end", "def sufficient_quantity_present?(item_quantities)\n all_items_present = true\n not_sufficient_item = nil\n item_quantities.each do |ingredient_name, quantity|\n if !@ingredients[ingredient_name] || @ingredients[ingredient_name] < quantity\n all_items_present = false\n not_sufficient_item = ingredient_name\n break\n end\n end\n return all_items_present, not_sufficient_item\n end", "def supplies_excluding_tax\n self.supplies.select{|p| not p[:including_tax]}\n end", "def unpaid_bills\n\t\tCuenta.where.not(:id_cuenta => Detalle.where(:id_pago => Pago.select(:id_pago)).select(:id_cuenta)).where(:rut_cliente => rut)\n\tend", "def unfilled_meals\n required_meals.reject{ |k,v| v <= 0 }\n end", "def due_payments\n Payments.where(is_paid: false)\n \n end", "def reject_zero(attributes)\n attributes['quantity'] == '0' || attributes['quantity'].blank?\n end", "def incompleteItemsWithAndWithoutDates\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @to_do_items.select!{|item| item.done? == 'Item incomplete'}\n @incomplete_array = @due_items.concat(@to_do_items)\n end", "def test_growthItem\n f = ItemFilter.new(\"growth\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 6\n end", "def quantity_listed\n item_hash.deep_find(:quantity, 0)\n end", "def item_bonus\n features_sum(:item_bonus)\n end", "def displaceable_items\n return [] unless fund_item && fund_request\n# fund_item.siblings.\n# select { |i| fund_request.fund_editions.map(&:fund_item).include? i }\n fund_item.siblings.where { |i| i.id.in fund_request.fund_editions.scoped.select { fund_item_id } }\n end", "def has_unpaid_bills\r\n return self.get_unpaid_bills.size > 0\r\n end", "def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend", "def list_items_inactive\n return_list = Array.new\n for s in self.offers\n unless s.auction\n if !s.active && !s.auction\n return_list.push(s)\n end\n end\n end\n return return_list\n end", "def collect_eligible(items)\n items.select{|item| eligible?(item) }\n end", "def items_waiting\n order_items.lot_codes_first.select { |item| item.waiting? }\n end", "def get_active_items\r\n self.items.select { |i| i.active? } #TODO only fixed or only auction\r\n end", "def add_mandatory_items\n @items.select { |item| item.rule.min.positive? }.each do |item|\n item.rule.min.times { add_item_to_card(item) }\n end\n end", "def fully_paid?\n amount_owed <= 0\n end", "def all_items_for_sell\r\n list = Array.new\r\n items.each{ |item|\r\n if item.active == true\r\n list.push(item)\r\n end}\r\n list\r\n end", "def quantity_check_availabilty(shop_id)\n a = sub_products.map do |p|\n p.quantity if p.shop_id == shop_id\n end.reject(&:blank?)\n rv = a[0]\n end", "def uncompleted_items\n new? ? Array.new : Item.uncompleted(@id)\n end", "def filtered_items\n @filtered_items ||= coverage_items.select do |item|\n (include_item_prefix?(item) || include_target_prefix?(item)) && !item.name.include?(\"$\")\n end\n end", "def get_active_items\n self.items.select { |i| i.active? } #TODO only fixed or only auction\n end", "def rep_items(array, rep_bills)\n array << rep_bills.reject {|bill| bill.introduced_on.nil? }.size\n array << rep_bills.reject {|bill| bill.referred_to_committee_on.nil? }.size\n array << rep_bills.reject {|bill| bill.committee_hearing_held_on.nil? }.size\n array << rep_bills.reject {|bill| bill.committee_markup_held_on.nil? }.size\n array << rep_bills.reject {|bill| bill.reported_by_committee_on.nil? }.size\n array << rep_bills.reject {|bill| bill.referred_to_subcommittee_on.nil? }.size\n array << rep_bills.reject {|bill| bill.subcommittee_hearing_held_on.nil? }.size\n array << rep_bills.reject {|bill| bill.subcommittee_markup_held_on.nil? }.size\n array << rep_bills.reject {|bill| bill.forwarded_from_subcommittee_to_committee_on.nil? }.size\n array << rep_bills.reject {|bill| bill.committee_hearing_held_on.nil? and bill.committee_markup_held_on.nil? and bill.reported_by_committee_on.nil? and bill.subcommittee_hearing_held_on.nil? and bill.subcommittee_markup_held_on.nil? and bill.forwarded_from_subcommittee_to_committee_on.nil? }.size\n array << rep_bills.reject {|bill| bill.reported_by_committee_on.nil? and bill.rule_reported_on.nil? and bill.rules_suspended_on.nil? and bill.considered_by_unanimous_consent_on.nil? and bill.passed_house_on.nil? and bill.failed_house_on.nil? and bill.received_in_senate_on.nil? and bill.placed_on_union_calendar_on.nil? and bill.placed_on_house_calendar_on.nil? and bill.placed_on_private_calendar_on.nil? and bill.placed_on_corrections_calendar_on.nil? and bill.placed_on_discharge_calendar_on.nil? and bill.placed_on_consent_calendar_on.nil? and bill.placed_on_senate_legislative_calendar_on.nil? }.size\n array << rep_bills.reject {|bill| bill.placed_on_union_calendar_on.nil? }.size\n array << rep_bills.reject {|bill| bill.placed_on_house_calendar_on.nil? }.size\n array << rep_bills.reject {|bill| bill.placed_on_private_calendar_on.nil? }.size\n array << rep_bills.reject {|bill| bill.placed_on_corrections_calendar_on.nil? }.size\n array << rep_bills.reject {|bill| bill.placed_on_discharge_calendar_on.nil? }.size\n array << rep_bills.reject {|bill| bill.rule_reported_on.nil? }.size\n array << rep_bills.reject {|bill| bill.rule_passed_on.nil? }.size\n array << rep_bills.reject {|bill| bill.rules_suspended_on.nil? }.size\n array << rep_bills.reject {|bill| bill.considered_by_unanimous_consent_on.nil? }.size\n array << rep_bills.reject {|bill| bill.passed_house_on.nil? }.size\n array << rep_bills.reject {|bill| bill.failed_house_on.nil? }.size\n array << rep_bills.reject {|bill| bill.received_in_senate_on.nil? }.size\n array << rep_bills.reject {|bill| bill.passed_senate_on.nil? }.size\n array << rep_bills.reject {|bill| bill.failed_senate_on.nil? }.size\n array << rep_bills.reject {|bill| bill.sent_to_conference_committee_on.nil? }.size\n array << rep_bills.reject {|bill| bill.conference_committee_report_issued_on.nil? }.size\n array << rep_bills.reject {|bill| bill.conference_committee_passed_house_on.nil? }.size\n array << rep_bills.reject {|bill| bill.conference_committee_passed_senate_on.nil? }.size\n array << rep_bills.reject {|bill| bill.presented_to_president_on.nil? }.size\n array << rep_bills.reject {|bill| bill.signed_by_president_on.nil? }.size\n array << rep_bills.reject {|bill| bill.vetoed_by_president_on.nil? }.size\n array << rep_bills.reject {|bill| bill.house_veto_override_on.nil? }.size\n array << rep_bills.reject {|bill| bill.senate_veto_override_on.nil? }.size\n array << rep_bills.reject {|bill| bill.house_veto_override_failed_on.nil? }.size\n array << rep_bills.reject {|bill| bill.senate_veto_override_failed_on.nil? }.size\n array << rep_bills.reject {|bill| bill.passed == false }.size\n end", "def test_emptyItem\n f = ItemFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def without_approvals(items)\n items.without_approvals\n end", "def remove_simple_dominance(items, already_sorted = false)\n # the vector HAS TO BE sorted by non-increasing profitability first AND\n # non-decreasing weight after to this code work\n items = sort_items_by_profitability!(items.clone) unless already_sorted\n \n # If an item i dominate an item j, then pi/wi >= pj/wj. Note that NOT every\n # case we have an item i and item j and pi/wi >= pj/wj i dominates j\n # (if this was the case every UKP problem could be reduced to the best item).\n # This only means that, if i is the index of the item when the items are\n # ordered by pi/wi, then it can't be simple or multiple dominated by any\n # item of index j where j > i.\n undominated = [items[0]]\n # if this was C++ would be interesting to already reserve the n capacity\n # on the vector above\n items.each do | i |\n dominated = false\n wi = i[:w]\n pi = i[:p]\n undominated.each do | u |\n wu = u[:w]\n pu = u[:p]\n if Rational(wi,wu).floor * pu >= pi then\n dominated = true\n break\n end\n end\n undominated << i unless dominated\n end\n\n undominated\nend", "def show_not_completed_items\n return @to_do_item.select { |x| x.is_done? == false }\n end", "def get_apts_less_than apts, amount\n return apts.select { |apt| apt.monthly_rent < amount }\n end", "def all_expense_items\n owing_expense_items + paid_expense_items\n end", "def has_items?\n total_items > 0\n end", "def has_items?\n total_items > 0\n end", "def test_emptyUsableItem\n f = UsableItemFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def test_healingSkillNullValue\n f = SkillFilter.new(\"healing\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def unfulfilled_line_items\n return self.order_line_items.where('status != ?', 'shipped').all\n end", "def fulfilled_line_items\n return self.order_line_items.where(:status => 'shipped').all\n end", "def checks_having_payers\r\n checks = []\r\n jobs.each do |job|\r\n check = job.check_informations.first\r\n checks << check if !check.payer.blank?\r\n end\r\n checks = checks.flatten.compact\r\n end", "def filter(items)\r\n\tnew_items = Array.new\r\n\titems.each { |item| new_items.push(item) unless should_ban(item) }\r\n\tnew_items\r\nend", "def products_not_used\n @products_not_used ||= object\n .products\n .select { |p| p.inventory_id == current_inventory.id && !p.used? }\n end", "def prepaid_liabilities_total\n voucher_groups.inject(Money.new(0)) { |sum, vg| sum + ( vg.cogs * vg.quantity ) }\n end", "def take_off\n invoice_items\n .joins(:bulk_discounts)\n .where('invoice_items.quantity >= bulk_discounts.quantity_threshold')\n .group('invoice_items.id')\n .pluck(Arel.sql('max(invoice_items.quantity * invoice_items.unit_price * bulk_discounts.percentage_discount)'))\n end", "def unanswered_check_in_questions\n action_items.where(component_type:Check::COMPONENT_TYPE, day:1..day.to_i).select{|i| !i.complete?}\n end", "def active_items\n @items.values.select { |value| value.state == :active || value.state == :auction}\n end", "def items_on_sale\r\n sale = Array.new\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (val.is_active )\r\n sale.push(val)\r\n end\r\n }\r\n end\r\n\r\n return sale\r\n end", "def invalid_items\n @items.select { |item| item.valid == false }\n end", "def test_healingItemNullValue\n f = ItemFilter.new(\"healing\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def mark_monthlyinvitems_for_removal \n monthlyinvitems.each do |monthlyinvitem|\n monthlyinvitem.mark_for_destruction if monthlyinvitem.qty.to_f == 0.0\n end \n end", "def under_five(cart)\n\tcart.all? do |item|\n\t\titem.all? do |name, data|\n\t\t\tdata[:price] <= 5\n\t\tend\n\tend\nend", "def noncommissionable_adjustment\n total = Money.new(0)\n self.adjustments.each do |a| \n total += a[:amount] if a[:commissionable] == false \n end\n total\n end", "def noncommissionable_adjustment\n total = Money.new(0)\n self.adjustments.each do |a| \n total += a[:amount] if a[:commissionable] == false \n end\n total\n end", "def true_cost\n # convert to array so it doesn't try to do sum on database directly\n #items.to_a.reject{|item|item.itemable_type == \"ServiceGroup\"}.sum(&:cost)\n items.collect.sum(&:cost)\n end", "def value_paid\n self.sale.bitcoin_payments.select{|x| x.confirmations >= 6}.map{|x| x['value']}.sum\n end", "def satisfy\n if @items.instance_of?(Array)\n if @items.length > 0\n return @items.sample\n end\n end\n\n return ''\n end", "def borrowable_items\n# items.where(\"borrower_id = 0\")\n Item.all.where(\"borrower_id = 0 and lender_id != :owner\", {owner: self.id})\n end", "def list_items_inactive\r\n return_list = Array.new\r\n for s in self.item_list\r\n if !s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def list_items_inactive\r\n return_list = Array.new\r\n for s in self.item_list\r\n if !s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def supplies_including_tax\n self.supplies.select{|p| p[:including_tax]}\n end", "def test_healingItem\n f = ItemFilter.new(\"healing\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 6\n end", "def equips_for_enchant\n return [] if @enchant_item.nil?\n $game_party.items.select { |item|\n item.enchantable? && item.tier == @enchant_item.enchant_tier\n }\n end", "def keep_arr(arr)\n # keep all non negative elements ( >= 0)\n arr.keep_if { |x| x >= 0 }\n end", "def unowned_purchasable_companies(_entity)\n []\n end", "def big_investors\n investors.select do |investor| \n investor.total_worth > 10000000000\n end\n end", "def filter_order_items(merchant)\n self.orderitems.to_a.select { |orderitem| orderitem.product.merchant == merchant}\n end", "def reject_total(array)\n array.reject { |string| string == 'total' }\n end", "def partial_short_items\n lines = @doc.xpath('ql:SOResult/ql:Line', 'ql' => NAMESPACE)\n lines = lines.select { |l| Integer(l['Quantity']) == 0 }\n lines.map do |line|\n {\n ql_item_number: line['ItemNumber'],\n }\n end\n end", "def get_valid_items\n list = []\n @items.each do |id, number|\n item = $data_items[id]\n list << item if item.for_friend? || item.for_opponent?\n end\n return list\n end", "def not_covered\n items = Array.new\n\n vehicles.each do |v|\n unless v.covered?\n items << v\n end\n end\n\n items\n end", "def total_paid\n payments.collect{|i| i.total_amount or i.calculate_total_amount}.sum + credit_notes.collect{|i| i.total_amount or i.calculate_total_amount}.sum\n end", "def backorder_availability items\n\titems.select do |item|\n\t\tbackorders = item['product']['inventories'].select do |inv_avail|\n\t\t\tinv_avail['availability'] == 'backorder'\n\t\tend\n\t\tbackorders.length > 0\n\tend\nend", "def line_items_for_customer(customer_id)\n ret_line_items = []\n my_line_items = delivery_details.find_all_by_customer_id(customer_id)\n my_line_items.each do |my_line_item|\n my_line_item.order_items.each do |order|\n if order.quantity > 0\n ret_line_items.push(order) unless ret_line_items.include? order\n end\n end\n end\n return ret_line_items\n end", "def eligible_items\n @eligible_items ||= ::InventoryItem.where(vendor: promotion.vendors)\n end", "def check_items_balances\n details.select(&:marked_for_destruction?)\n .all?(&:valid_for_destruction?)\n end", "def failing_products\n return self.products.select do |product|\n product.failing?\n end\n end", "def filter_matched_items(items)\n []\n end", "def paid_up?\n if payment_item.is_a? GeneralPaymentItem\n outstanding_amount <= 0.0\n else\n nil\n end\n end", "def test_healingSkill\n f = SkillFilter.new(\"healing\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 11\n end", "def items\n result = []\n for i in @items.keys.sort\n result.push($data_items[i]) if @items[i] > 0\n end\n for i in @weapons.keys.sort\n result.push($data_weapons[i]) if @weapons[i] > 0\n end\n for i in @armors.keys.sort\n result.push($data_armors[i]) if @armors[i] > 0\n end\n return result\n end", "def proper_items\n items.where.not(sort: ['self', 'pdf_destination'])\n .where.not(start_time: nil)\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def total_item\n @items.reject {|item| item.quantity == 0}\n invoice_total = @items.sum {|item| item.sale_price * item.quantity}\n\n end", "def sum_price_non_groceries(items)\n sum = 0\n items.each do |item|\n sum += item.get_price unless item.get_category == :groceries\n end\n\n return sum\n end", "def clear_free_items\n free_items = @order.line_items.select {|item| item.price == 0}\n @order.line_items.delete(*free_items)\n end", "def purchased usr\n Listing.where(\"listings.status not in (?)\", closed_arr(false)).joins(:invoices)\n .where(\"invoices.buyer_id = ? AND invoices.status = ?\", usr.id, 'paid').uniq\n end", "def zero?\n moneys.all? {|_, money| money.zero?}\n end" ]
[ "0.6286385", "0.61376476", "0.61366105", "0.60251176", "0.58752483", "0.5799775", "0.5756575", "0.57485896", "0.57201076", "0.57199156", "0.5716697", "0.5714918", "0.56775546", "0.565848", "0.5619463", "0.56134444", "0.56097525", "0.55814415", "0.55751985", "0.5562453", "0.55619144", "0.55543953", "0.55431104", "0.55219775", "0.5519227", "0.5517487", "0.5506368", "0.5505843", "0.547935", "0.5477294", "0.54496616", "0.5427498", "0.53850055", "0.53812724", "0.5368496", "0.53659403", "0.5364921", "0.53624344", "0.5348336", "0.5339799", "0.53381085", "0.5337884", "0.5337819", "0.5325776", "0.5318701", "0.5315254", "0.5309867", "0.5309867", "0.5303179", "0.5280225", "0.52522194", "0.5238847", "0.5238186", "0.52353764", "0.5225821", "0.5223562", "0.52217543", "0.52178854", "0.5213224", "0.5207339", "0.5200023", "0.5198458", "0.5195884", "0.51783454", "0.5169447", "0.5169447", "0.51676124", "0.5160406", "0.5154823", "0.5144068", "0.51396", "0.51396", "0.5136571", "0.51290125", "0.5128003", "0.5121124", "0.51199543", "0.5114729", "0.51097935", "0.5105865", "0.51046413", "0.5102586", "0.5101927", "0.509217", "0.50881404", "0.50868", "0.5082977", "0.50798965", "0.50793", "0.507299", "0.5067877", "0.5057529", "0.50572926", "0.50526017", "0.50518405", "0.5049654", "0.50456905", "0.5044753", "0.5038547", "0.50192815" ]
0.7494559
0
The promotions that have been applied since the order was last serialised.
def new_promotions @new_promotions ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def promotions\n @promotions ||= order.promotions\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def current_promotions\n promotions.where([\"start_on IS NOT NULL AND start_on <= ? AND (end_on >= ? OR end_on IS NULL OR end_on = '')\", Date.today, Date.today]).order(\"start_on\")\n end", "def processed_items\n @processed.to_a\n end", "def promotions\n Spree::Promotion.find_by_sql(\"#{order.promotions.active.to_sql} UNION #{Spree::Promotion.active.where(code: nil, path: nil).to_sql}\")\n connected_order_promotions | sale_promotions\n end", "def applied\n @applied ||= []\n end", "def processed\n return @defaults.objectForKey(:processed)\n end", "def saved_changes\n mutations_before_last_save.changes\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def pending_modified_values\n data[:pending_modified_values]\n end", "def pending_modified_values\n data[:pending_modified_values]\n end", "def promotion_id_dump\n pending_promotions.map(&:id)\n end", "def transferred_properties\n @properties.transferred_properties\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def getOrderExtraAdded\n\t\treturn @extra_added \n\tend", "def promotions\n adjustments.where( promotion: true )\n end", "def applied_policies\n return @applied_policies\n end", "def per_message_merge_data\n @per_message_merge_data\n end", "def cur_ordering\r\n @orderings\r\n end", "def previous_promotion_ids\n @previous_promotion_ids ||= []\n end", "def profils()\n return @profils\n end", "def receipts_sent\n receipts.sent_messages_receipts\n end", "def merit_order\n order = Merit::Order.new\n\n producers.each do |producer|\n order.add(producer) unless producer.marginal_costs == Float::NAN\n end\n\n order.add(local_demand_user)\n\n order\n end", "def backtrack_consumed_change_records\n data[:backtrack_consumed_change_records]\n end", "def modified_properties\n return @modified_properties\n end", "def procs\n @procs\n end", "def last_invoiced\n processed_orders.last.try(:Created)\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end", "def transactions\n\t\treturn MessagePack.unpack( self.payload ).map {|tr| tr.transform_keys(&:to_sym) }\n\tend", "def unprocessed_transactions\n\t\tself.transactions.where(approved: true, processed: false)\n\tend", "def processing_metadata\n return @processing_metadata\n end", "def to_be_reconciled\n @params.select { |_order_detail_id, params| params[:reconciled] == \"1\" }\n end", "def observed_exchange\n nil\n end", "def payment_items\n\t\t\t\t\treturn self.order_items\n\t\t\t\tend", "def original_order\n end", "def delivered_products\n @delivered_products ||= begin\n products = order['OrderDetails']['OrderRows']\n products.each do |ol|\n if ol['OrderRowId'].to_s == line_id.to_s\n ol['QuantityToDeliver'] = quantity\n ol['PackageId'] = track_and_trace_reference\n end\n\n if ol['ProductId'] == 'Postage'\n ol['QuantityToDeliver'] = 1\n ol['PackageId'] = track_and_trace_reference\n end\n end\n products.collect do |pr|\n pr.slice 'OrderRowId', 'QuantityToDeliver', 'PackageId'\n end\n end\n end", "def orders_completed\n result = Array.new\n self.job_applications.each do |j|\n j.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end", "def order\n return @order\n end", "def pledges\r\n\t@received_pledges.values.reduce(0, :+) #I'm not sure what the :+ does\r\nend", "def current_workflow_processes\n wf_processes = []\n RuoteKit.engine.processes.each do |wfp|\n wf_processes << wfp if wfp.target == self\n end\n\n wf_processes\n end", "def attr_orders\n @attr_orders\n end", "def order\n @order ||= if session['order']\n OrderBasket.load(session['order']).tap(&:apply_promotions!)\n else\n OrderBasket.new\n end\n end", "def future_position_summaries\n []\n end", "def processed_promos\n respond_to do |format|\n @taken_promos = TakenPromo.get_taken_promos_for_user current_user\n format.html { }\n end\n end", "def stored_payment_methods\n return [] unless @member && @member.customer\n @member.customer.payment_methods.stored.map do |m|\n {\n id: m.id,\n last_4: m.last_4,\n instrument_type: m.instrument_type,\n card_type: m.card_type,\n email: m.email\n }\n end\n end", "def applied\n @collection.select(&:applied?)\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 pending_modified_values\n @dbi.pending_modified_values\n end", "def pending_modified_values\n @dbi.pending_modified_values\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def orders_completed\n # TODO:\n # How about service ?\n result = Array.new\n self.jobs.unscoped.each do |j|\n j.orders.each do |o|\n if !o.workspace.blank?\n result << o if o.workspace.completed?\n end\n end\n end\n result\n end", "def quantity_inflation_end_of_promotion\n ord_qty_hash = []\n variant = Spree::Variant.find(params[:variant_id])\n quantity_inflation = variant.quantity_inflations.where(:market_place_id=>params[:market_place_id]).try(:first)\n ord_qty_hash << quantity_inflation.end_of_promotion\n Spree::DataImportMailer::promotion_quantity_inflation_end(ord_qty_hash).deliver\n flash[:notice] = \"Promotion is ended for selected product and all respective marketplaces\"\n redirect_to :back\n end", "def changes_applied\n unless defined?(@attributes)\n mutations_from_database.finalize_changes\n end\n @mutations_before_last_save = mutations_from_database\n forget_attribute_assignments\n @mutations_from_database = nil\n end", "def affects\n return @affects.to_a\n end", "def active_exploits_observed\n return @active_exploits_observed\n end", "def meta_pending()\n old_meta = current[:meta] || current['meta'] || {}\n new_meta = @application_json['meta'] || {}\n old_debug = old_meta[:debug] || old_meta['debug']\n new_debug = new_meta['debug']\n debug_change = \"#{old_debug} => #{new_debug}\" if old_debug != new_debug\n \n old_restage_on_service_change = old_meta[:restage_on_service_change]\n old_restage_on_service_change = old_meta['restage_on_service_change'] unless old_restage_on_service_change == false\n old_restage_on_service_change = old_restage_on_service_change.to_s unless old_restage_on_service_change.nil?\n new_restage_on_service_change = new_meta['restage_on_service_change']\n restage_on_service_change_change = \"#{old_restage_on_service_change} => #{new_restage_on_service_change}\" if old_restage_on_service_change != new_restage_on_service_change\n \n return if debug_change.nil? && restage_on_service_change_change.nil?\n return { \"debug\" => debug_change } if restage_on_service_change_change.nil?\n return { \"restage_on_service_change\" => restage_on_service_change_change } if debug_change.nil?\n return { \"debug\" => debug_change, \"restage_on_service_change\" => restage_on_service_change_change }\n end", "def tracked_attributes\n @tracked_attributes || []\n end", "def changed_associations\n data['associations'].try(:keys) || []\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def service_orders_completed\n result = Array.new\n self.services.each do |s|\n s.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end", "def workflow\n return @@WORKFLOW.collect(&:values).flatten\n end", "def promotion_directives\n context[:promotion_directives] ||= {}\n end", "def poem\n if !self.previous_line.nil?\n self.previous_line.poem + [self]\n else\n [self]\n end\n end", "def index\n @transferred_event_orders = TransferredEventOrder.all\n end", "def added_properties\n\t\treturn @added_properties unless @added_properties.nil?\n\t\tcalculate_changes\n\t\treturn @added_properties\n\tend", "def changed_associations\n self.data['associations'].try(:keys) || []\n end", "def additions()\n return @additions\n end", "def stock_mutations\n StockMutation.where( \n :source_document_id => self.id , \n :source_document => self.class.to_s,\n :mutation_case => MUTATION_CASE[:sales_return],\n :mutation_status => MUTATION_STATUS[:addition], \n :item_status => ITEM_STATUS[:ready]\n ).order(\"created_at ASC\")\n \n end", "def extract_behaviors!\n # Get the behaviors.\n behs = self.each_behavior.to_a\n # Remove them from the scope.\n # behs.each { |beh| self.delete_behavior!(beh) }\n self.delete_all_behaviors!\n # Return the behaviors.\n return behs\n end", "def operations\n @operations ||= stream.operations\n end", "def changes\n if @changes\n @changes.dup\n else\n []\n end\n end", "def redelivered; @message_impl.getRedelivered; end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def convos\n if self[:convo]\n payload = self[:convo].to_hash\n payload[:convo_messages] = self[:convo].unsent_messages.members.collect { |msg| \n msg.sensitive!\n #msg.content = msg.content.to_s.linkify\n msg\n }\n [payload]\n else\n ret = VendorInfo.global.convos.revmembers.collect do |convo|\n payload = convo.to_hash\n payload[:convo_messages] = convo.sent_messages.members.collect { |msg| \n msg.sensitive!\n #msg.content = msg.content.to_s.linkify\n msg\n }\n payload[:convoid] = convo.id\n payload[:news_date] = newsdate(convo.updated)\n payload\n end\n ret\n end\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def show\n @promotions = @condition.promotions\n @coefficients = @condition.coefficients\n end", "def added_pairs\n return @added_pairs\n end", "def transferred_properties; end", "def transferred_properties; end", "def propositional_symbols\n symbols = []\n @classified.each do |el|\n symbols.push el if el.instance_of? Proposition\n end\n symbols\n end", "def requested_modalities\n return @requested_modalities\n end", "def changed_associations\n @changed_associations ||= []\n end", "def all_sent_messages\n self.all_classes_and_modules.flat_map do |klassmod|\n klassmod.all_messages.as_array\n end.uniq\n end", "def messages\n @queue.messages.select { |m| m.claim == self }\n end", "def list\n @processors.keys\n end", "def phases\n lifecycle.phases \n end", "def get_cout_total_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_total_parcelle(self)\n end\n end\n sum\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def transmissions\n # Return only directly sent message (via #transmit)\n connection.transmissions.filter_map { |data| data[\"message\"] }\n end", "def modifications\n\t\treturn unless self.modified?\n\t\tself.log.debug \"Gathering modifications...\"\n\n\t\tmods = []\n\t\[email protected]_by {|k, _| k.to_s }.each do |attribute, vals|\n\t\t\tself.log.debug \" finding mods for %s\" % [ attribute ]\n\t\t\tmod = self.diff_with_entry( attribute, vals ) or next\n\t\t\tmods << mod\n\t\tend\n\n\t\treturn mods\n\tend", "def ordered_values; end" ]
[ "0.74322355", "0.64474356", "0.6032609", "0.5961645", "0.59524673", "0.58857894", "0.5866804", "0.5596451", "0.55283207", "0.54836804", "0.54635763", "0.5424442", "0.53949225", "0.53949225", "0.53160316", "0.52711594", "0.526471", "0.5252012", "0.5236463", "0.52051806", "0.51767725", "0.5145472", "0.50992274", "0.50557643", "0.5018575", "0.50182974", "0.49820143", "0.49674246", "0.4966633", "0.4960257", "0.49321494", "0.49316272", "0.49249524", "0.4910521", "0.49049416", "0.49005938", "0.49005628", "0.48740858", "0.48709732", "0.4865048", "0.4857539", "0.48553577", "0.4852552", "0.48440936", "0.4836573", "0.48239204", "0.4820483", "0.48200688", "0.48129633", "0.48119137", "0.4810538", "0.4801408", "0.47942787", "0.47928825", "0.4790882", "0.4790882", "0.4783294", "0.4772389", "0.47436705", "0.47222355", "0.47092658", "0.470902", "0.46961942", "0.4689534", "0.46748757", "0.46732894", "0.46553892", "0.46354502", "0.4632747", "0.46191207", "0.46160102", "0.46084842", "0.46079773", "0.46027496", "0.45985115", "0.45976382", "0.45872617", "0.45802695", "0.4565729", "0.45538762", "0.45538762", "0.45538762", "0.45510575", "0.45468393", "0.45461252", "0.45425302", "0.45382336", "0.45382336", "0.45379525", "0.45378342", "0.45377898", "0.45366272", "0.45327294", "0.45316675", "0.45312825", "0.45244685", "0.4523973", "0.4523622", "0.45220485", "0.45132768" ]
0.62009275
2
Checks to see if any new promotions have been applied to the order.
def new_promotions? !new_promotions.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def existing_promotions?\n !existing_promotions.empty?\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def promotions\n @promotions ||= order.promotions\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def can_be_added?(order)\n eligible?(order) &&\n (can_combine?(order) || order.promotion_credits.empty?) &&\n Credit.count(:conditions => {\n :adjustment_source_id => self.id,\n :adjustment_source_type => self.class.name,\n :order_id => order.id\n }) == 0\n end", "def apply\n assign_order_attributes\n assign_payments_attributes\n\n if order.save\n order.set_shipments_cost if order.shipments.any?\n true\n else\n @errors = order.errors\n false\n end\n end", "def punch_out_order_message?\n !punch_out_order_message.nil?\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def is_under_process?\n #if true then this sub has got orders which are under process(by payment / shipment)\n self.orders.where('(delivery_date <= ? and delivery_date > ?) or (state = ? and payment_state = ?)', ORDER_UPDATE_LIMIT.days.from_now.to_date, Time.now, 'placed', 'paid').present?\n end", "def check_new_actions\n MeritAction.where(:processed => false).each do |merit_action|\n merit_action.check_rules(defined_rules)\n end\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def update_phase!()\n @involved_entities.each do |involved_entity|\n return false unless ( !involved_entity.has_to_update || execute_update!( involved_entity.entity_class ) )\n end\n return true\n end", "def checkout_allowed?\n order_items.count > 0\n end", "def on_order?\n !self.paid?\n end", "def deliver_store_owner_order_notification_email?\n store.new_order_notifications_email.present? && !store_owner_notification_delivered?\n end", "def test_cleanup_promotion_order_finished\n # Setup - add promotion and complete order\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n @o.order_status_code = order_status_codes(:ordered_paid_to_ship)\n assert @o.save\n \n # Now expire the promo\n assert promo.update_attributes({\n :start => Date.today - 2.weeks,\n :end => Date.today - 1.week\n })\n promo.reload\n @o.reload\n \n # Update something on the order, like an admin would.\n # Maybe we shipped out the order and changed the status code.\n @o.order_status_code = order_status_codes(:sent_to_fulfillment)\n assert [email protected]_promotion_be_applied?(promo)\n assert @o.save\n \n @o.reload\n \n # Check to see if promotion is still applied (it should be!)\n assert_equal promo, @o.promotion\n assert_kind_of OrderLineItem, @o.promotion_line_item\n end", "def check_for_processor_update(updated_task)\n (self.completed != updated_task.completed ||\n self.cae_model != updated_task.cae_model ||\n self.cad_model != updated_task.cad_model)\n end", "def valid_order?\n order.coupon.nil? && coupon.cancelled_at.nil?\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def update_ok?(order_hash)\n\t\tif !order_hash[:order_number]\n\t\t\treturn false\n\t\telsif order_hash[:status] == 'SH' \n\t\t\t\treturn true unless order_hash[:tracking_number] == nil || order_hash[:ship_method] == nil\n\t\telse\n\t\t\treturn true\n\t\tend \n\tend", "def update_ok?(order_hash)\n\t\tif !order_hash[:order_number]\n\t\t\treturn false\n\t\telsif order_hash[:status] == 'SH' \n\t\t\t\treturn true unless order_hash[:tracking_number] == nil || order_hash[:ship_method] == nil\n\t\telse\n\t\t\treturn true\n\t\tend \n\tend", "def candidates_exist_for_all_forced_changes?\n forced_packages_missing_candidates.empty?\n end", "def exact_change_required?\n PRODUCTS.map do |_, value|\n change = make_change(value)\n change.nil? || change.empty?\n end.all?\n end", "def check_for_processor_update(updated_task)\n (self.completed != updated_task.completed)\n end", "def complete?()\n if (self.order_in_lines.length == 0)\n return false\n end\n self.order_in_lines.each do | line |\n if (line.qty < line.qty_in)\n return false\n end\n end\n return true\n end", "def new_promotions\n @new_promotions ||= []\n end", "def has_confirmed_order?\n confirmed_order = false\n open_orders.each do |o|\n if o.confirmed\n confirmed_order = true\n break\n end\n end\n confirmed_order\n end", "def any_eob_processed?\n self.insurance_payment_eobs.length >= 1\n end", "def is_conflict?\n from_json\n (@order && @order.paid?).tap do |x|\n @error = true if x\n end\n end", "def no_proposals_unless_manages_proposals\n return true if manages_proposals or proposals.empty?\n errors.add(:manages_proposals,\n _('This conference already has received %d proposals (%s) - ' +\n 'Cannot specify not to handle them.') %\n [self.proposals.size, self.proposals.map {|p| p.id}.join(', ')])\n end", "def anything_to_do?\n (pending.length + state_check.length) > 0\n end", "def unappliable_order?\n order.bought? == false\n end", "def ready_to_exchange?\n self.balance >= self.promotion.points_to_exchange\n end", "def has_order_items?\n @cores != nil || @ram != nil || @max_port_speed != nil\n end", "def available_for_order?(_order)\n true\n end", "def handle_stock_counts?\n current_shipment.order.completed? && current_stock_location != desired_stock_location\n end", "def needs_promotion?\n !!@promotion_coords\n end", "def update_preorders?\n get_edited_preorders.each { |unpermitted_params|\n permitted_params = permitted_update_preorder_params(unpermitted_params)\n @preorder = @menu.preorders.find_by_id(permitted_params[:id])\n render body: nil, status: :not_found and return false if @preorder.nil?\n\n if @preorder.has_started?\n render json: { error: \"You cannot update a preorder that has started!\" }, status: :unprocessable_entity\n return false\n end\n\n if @preorder.update(permitted_params)\n # If successful, no need to give response\n else\n # Status code: 422\n render json: { errors: @preorder.errors }, status: :unprocessable_entity\n return false\n end\n }\n\n return true\n end", "def probe?\n self.order == -1\n end", "def has_changes_to_save?\n mutations_from_database.any_changes?\n end", "def commit_required?\n @entry_set.each do |e|\n return true if e.dirty\n end\n @comment != @stored_comment || @entry_set != @stored_entries || @create\n end", "def has_been_recorded?(order)\n unless Validation.validate(order.to_s) && Order.is_a_valid_item_code?(order.to_s)\n return false\n end\n @customer_order.push order.to_s\n return true\n end", "def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend", "def unredeemable?\n payment_owed? && !(ProductStrategy === self.order.promotion.strategy) \n end", "def eligible?(options = {})\n return unless order = options[:order]\n quantity_ordered = product.variants_including_master.inject(0) do |sum, v|\n sum + order.quantity_of(v)\n end\n quantity_ordered >= preferred_quantity\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def local_clean_new_order(mail)\n local_clean_extract_from_body(mail)\n return false unless @order_number\n logger.info \"Cleanup of #{@order_number}\"\n true\n end", "def products_covered?(dep_prods, man_prods)\n if dep_prods.nil? || man_prods.nil?\n return false\n end\n\n return (dep_prods - man_prods).empty?\n end", "def orders?\n return orders.any?\n end", "def update_required?\n any?(&:update_required?)\n end", "def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end", "def capture_pending_payments\n success = true\n order.payments.pending.each do |payment|\n unless payment.capture!\n copy_errors(payment)\n success = false\n end\n end\n success\n end", "def capture\n begin \n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # go through all order_payments\n order_payments = self.order_payments\n if order_payments.size == 0\n p \"No order_payments to process.\"\n raise PaymentError, \"No order_payments to process.\"\n end\n for order_payment in order_payments\n order_payment.capture!\n end\n self.upgrade_coupons!\n # update order\n self.update_attributes!(:state => Order::PAID, :paid_at => Time.zone.now)\n end\n # send confirmation email\n user = User.find_by_id(self.user_id)\n if user and user.send_confirmation(self.deal_id)\n return true\n else\n logger.error \"Order.capture: Confirmation email failed to send: #{self.inspect}\"\n return false\n end\n rescue PaymentError => pe\n p \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n rescue ActiveRecord::RecordInvalid => invalid\n p \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end", "def to_be_performed?\n self.research_billing_qty > 0\n end", "def done?\n @possibles.all? do |ops_modifiers, count|\n count.zero? || !all_ops_modifiers_qualify?(ops_modifiers, count)\n end\n end", "def compute_on_promotion?\n @compute_on_promotion ||= calculable.respond_to?(:promotion)\n end", "def check_unattended_orders\n if session.delete(:just_logined) == true && @current_user\n if @current_user.is_merchant\n @unattended_orders = @current_user.products.collect(&:orders).first.\n where(\"(status is null OR status = 1) AND orders.created_at >= ?\", @current_user.last_signed_out_at)\n end\n end\n end", "def can_update_basket?\n !(\n needs_shipping_quote? || quote? || payment_on_account? || pay_by_phone? ||\n payment_received?\n )\n end", "def advance_charges_modified?(lot)\n charges = lot.advance_charge\n charges.attributes.each_pair do |attribute, value|\n logger.info(\"advance charge #{attribute} changed to #{value}\") if charges.send(\"#{attribute}_changed?\".to_sym)\n end\n changed = charges.additional_fee_changed? || charges.additional_fee_vat_changed? ||\n charges.labor_changed? || charges.labor_vat_changed? || \n charges.storage_amount_changed? || charges.storage_amount_vat_changed? || charges.storage_daily_changed? || \n charges.tear_down_estimate_changed? || charges.tear_down_estimate_vat_changed? || \n charges.towing_changed? || charges.towing_vat_changed? || \n charges.yard_gate_changed? || charges.yard_gate_vat_changed? ||\n charges.storage_from_date_changed? || charges.storage_thru_date_changed?\n if changed\n # the initial saving will create this scenario, and we don't want to send in this scenario\n logger.info(\"advance charges changed for lot of num/id #{lot.lot_num}/#{lot.id}\")\n all_nil = charges.additional_fee.nil? && charges.additional_fee_vat.nil? &&\n charges.labor.nil? && charges.labor_vat.nil? &&\n charges.storage_amount.nil? && charges.storage_amount_vat.nil? &&\n charges.tear_down_estimate.nil? && charges.tear_down_estimate_vat.nil? &&\n charges.towing.nil? && charges.towing_vat.nil? &&\n charges.yard_gate.nil? && charges.yard_gate_vat.nil? &&\n charges.total_charges.nil? && charges.total_tax.nil?\n if all_nil\n logger.info(\"all charges are nil (not zero) for lot of num/id #{lot.lot_num}/#{lot.id}, this is not an actual modification\")\n changed = false\n end\n end\n logger.info(\"advance_charges_modified? for lot of num/id #{lot.lot_num}/#{lot.id}: #{changed}\")\n changed\n end", "def processed?\n processed\n end", "def confirmed?\n self.contributions.each do |contribution|\n return false if contribution.isPending?\n end\n return true\n end", "def updated_values?(order)\n super or submitted_assets_have_changed?(order)\n end", "def already_processed?(transaction)\n transaction['type'] != 'AA'\n end", "def check_paid\n self.paid_amount = 0\n self.paid = false\n payments.each do |payment|\n self.paid_amount += payment.amount\n end\n \n if self.paid_amount - self.gross_amount >= 0\n self.paid = true\n end\n end", "def check_current_order\t\n\t\t# TODO: Introduce a proper way to check the order payment status\n\t\t# Currently the order get removed from the session the moment the\n\t\t# spree receives payment and no way of tracking. Might have to introduce\n\t\t# other means of checking for payment receival for orders. A possible\n\t\t# method would be to have session id sent along with IPN secret and\n\t\t# mark a flag on payment notifications after displaying payment received\n\t\t# message\n\t\t# if current_order \\\n\t\t# && current_order.completed? \n\t\t# # && ((current_order.payment_state == \"paid\") or (current_order.payment_state == \"credit_owed\"))\n\t\t# \tflash[:notice] = t(:pp_ws_payment_received)\n\t\t# \t@order = current_order\n\t\t# \tsession[:order_id] = nil\n\n\t\t# \tif current_user\n\t\t# \t\tredirect_to spree.order_path(@order)\n\t\t# \telse\n\t\t# \t\tredirect_to root_path\n\t\t# \tend\n\t\t\t\n\t\t# end\n\tend", "def applicable?\n adjustment_source && adjustment_source.eligible?(order) && super\n end", "def reject_promotion_if_not_enough_items\n promotion = Promotion.find(@basket_item.promotion_id)\n if !promotion.item_id.nil?\n items_count = BasketItem.where( basket_id: @basket_item.basket_id,\n item_id: promotion.item_id)\n .count\n # count pieces of the item for which promotions already applied\n item_promotions_count = 0\n Promotion.where(item_id: promotion.item_id).each do | p |\n item_promotions_count += BasketItem.where(basket_id: @basket_item.basket_id,\n promotion_id: p.id)\n .count * promotion.item_quantity\n end\n\n if items_count - item_promotions_count < promotion.item_quantity\n flash[:danger] = \"Not enough items in the basket to apply the promotion!\"\n @reject = true\n end\n end\n end", "def delivered?\n check_elements_for_compliance { |e| !e.delivered? }\n end", "def update_processes\n return true if set_later?\n return true if using_skill?\n return true if gaining_exp?\n return true if update_screen\n end", "def verify()\n if has_order_items?\n order_template = order_object\n order_template = yield order_object if block_given?\n @virtual_server.softlayer_client[:Product_Order].verifyOrder(order_template)\n end\n end", "def ready_to_approve?\n status = self.units.map(&:unit_status) & ['condition', 'copyright', 'unapproved']\n return status.empty?\n end", "def fetch_saved?\n super and available_quantity_changed?\n end", "def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end", "def uncommitted_changes?\n inform \"Checking for any uncommitted changes...\"\n if nothing_to_commit?\n inform \"All changes committed :)\"\n false\n else\n inform \"You have uncommitted changes. Please commit them first, then run `rake release` again.\"\n true\n end\n end", "def check_product_dependencies\n # Iterate though the products associated to this SO, that are not deleted.\n products.visible.each do |p|\n # throw(:abort) will make the destroy method return false and the controller will know the destroy didn't work.\n throw(:abort) if p.shippingoptions.count == 1\n end\n end", "def normal_and_standalone_promo?\n # Guard clause to ensure promo code is definitely a standalone promo\n return unless promotion.stand_alone_promo(self[:promotion_id])\n if !promotions.empty? && !promotions.map(&:standalone).include?(true)\n return errors.add(:promotion_id, '..other promo exists!')\n end\n end", "def any_updates?\n change_history.size > 1\n end", "def any_updates?\n change_history.size > 1\n end", "def ensure_not_referenced_by_any_ordered_item\n if ordered_items.empty?\n return true\n else\n errors.add(:base, \"Ordered items present.\")\n return false\n end\n end", "def before_save\n changed_fields?\n if(@changed_fields && @changed_fields.keys.include?('rmt_product_id') && ((bins = Bin.find_all_by_delivery_id(self.id)).length>0))\n raise \"sorry cannot change rmt_product of this delivery , #{bins.length} bin(s) have already been scanned for this delivery\"\n end\n puts\n end", "def update_order\n # If there is no adjustment for the current gift package, just create one here unless there already is one for the gift package\n if self.gift_package_id && self.gift_package_id > 0 && self.adjustments.gift_packaging.where(:originator_id => self.gift_package_id).count == 0\n self.gift_package.adjust(self) \n end \n # Then update all adjustments\n self.update_adjustments\n # update the order totals, etc.\n order.update!\n end", "def ensure_not_referenced\n if order_items.empty?\n true\n else\n errors.add(:base, 'Line Order present')\n false\n end\n end", "def has_added_item_positions?(goods_receipt_positions_added)\n\t\tif goods_receipt_positions_added.empty?\n\t\t\t errors.add_to_base(\"debe seleccionar al menos un material\")\n\t\t\t false\n\t\tend\n\t\ttrue\n\tend", "def saved_changes?\n mutations_before_last_save.any_changes?\n end", "def check_for_proposals\n if ProposalDetail.where(\"service_id = ?\", self.id).exists? \n errors.add(:base,\"You can't delete a service once it's been used in a proposal\")\n return false\n end\n end", "def update!\n update_totals\n update_payment_state\n # update_adjustments\n # update totals a second time in case updated adjustments have an effect on the total\n update_totals\n \n update_attributes_without_callbacks({\n :state => \"complete\"\n }) \n \n logger.info 'UPDATED ORDER'\n # update_hooks.each { |hook| self.send hook }\n end", "def processed?\n return self.processed\n end", "def update_order_status\n carts = Cart.where(:order_id => self.id)\n order_complete = true\n\n #go through the cart to check state of carts\n carts.each do |cart|\n if cart.status != 5 then\n order_complete = false\n break\n end \n end\n\n if order_complete then\n self.update_attribute( :status, 3) \n end\n\n return order_complete\n end", "def package_delivered\n self.status = CONSTANT['BOX_DELIVERED']\n self.package.status = CONSTANT['PACKAGE_DELIVERED_DELIVERY']\n if self.package.save\n if self.save\n pin = self.access.generate_pin\n if pin\n self.package.user.send_pick_up_pin pin #TODO\n return true\n end\n end\n end\n return false\n end", "def ready_for_merge?(order_detail)\n case order_detail.product\n when Service\n order_detail.valid_service_meta?\n when Instrument\n order_detail.valid_reservation?\n else\n true\n end\n end", "def order_completed_not_changed\n\t\tself.errors.add(:order_completed, \"you cannot change the order status to completed, this is automatically derived\") if self.changed_attributes.include? \"order_completed\"\n\tend", "def validate_on_update\n quantity_count = SupplierOrderFulfillment.sum(:quantity,\n :conditions => ['supplier_order_id=?',supplier_order_id])\n #total quantity in order >= all quantity in fulfillment\n current_quantity = SupplierOrderFulfillment.find(id).quantity\n puts quantity_count\n if supplier_order.total_quantity >= quantity_count + quantity - current_quantity\n return true\n else\n errors.add_to_base('total quantity < fulfillment quantity')\n return false\n end\n end", "def has_queued_events?\n [email protected]?\n end" ]
[ "0.70721054", "0.7056001", "0.69980675", "0.6493094", "0.63931346", "0.63828385", "0.6347391", "0.61738896", "0.60555255", "0.59602386", "0.5910393", "0.5874006", "0.5748538", "0.5730938", "0.5692966", "0.5688312", "0.5688093", "0.56499726", "0.56438255", "0.56414473", "0.5633923", "0.5628754", "0.56245637", "0.5618586", "0.559408", "0.5575484", "0.55650586", "0.55650586", "0.55632436", "0.5547952", "0.5544909", "0.55314", "0.55155265", "0.5509636", "0.55069304", "0.548285", "0.5481256", "0.5479377", "0.5477384", "0.5465983", "0.54581845", "0.5444922", "0.54429424", "0.5440072", "0.5439721", "0.54381984", "0.54349667", "0.54342204", "0.5418959", "0.54142547", "0.5398799", "0.53962964", "0.53937185", "0.5386328", "0.53831565", "0.5379012", "0.5376618", "0.53687394", "0.53678715", "0.53475606", "0.5324882", "0.5324147", "0.5313816", "0.5281275", "0.5278536", "0.5268674", "0.5264838", "0.5259011", "0.5258384", "0.52503", "0.52466863", "0.5241079", "0.523841", "0.5237074", "0.52363425", "0.52324617", "0.52320504", "0.5226789", "0.52081543", "0.5196144", "0.5193108", "0.5188403", "0.51792145", "0.51744556", "0.51744556", "0.51732934", "0.5173249", "0.51703876", "0.5162871", "0.5162089", "0.51541644", "0.5145505", "0.5141187", "0.5138671", "0.51381326", "0.5137236", "0.5133418", "0.5130365", "0.512969", "0.5127125" ]
0.7135606
0
Retrieve the promotions that have been applied, but before the order is persisted.
def pending_promotions @pending_promotions ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def promotions\n @promotions ||= order.promotions\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def promotions\n Spree::Promotion.find_by_sql(\"#{order.promotions.active.to_sql} UNION #{Spree::Promotion.active.where(code: nil, path: nil).to_sql}\")\n connected_order_promotions | sale_promotions\n end", "def promotions\n adjustments.where( promotion: true )\n end", "def new_promotions\n @new_promotions ||= []\n end", "def current_promotions\n promotions.where([\"start_on IS NOT NULL AND start_on <= ? AND (end_on >= ? OR end_on IS NULL OR end_on = '')\", Date.today, Date.today]).order(\"start_on\")\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def index\n @promotions = current_shop_owner.promotions.all\n end", "def order\n @order ||= if session['order']\n OrderBasket.load(session['order']).tap(&:apply_promotions!)\n else\n OrderBasket.new\n end\n end", "def applied\n @applied ||= []\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def applied_policies\n return @applied_policies\n end", "def promoted_products\n promoted.is_a?(Product) ? [promoted] : promoted.products.all\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def Order_all\n\t\t@all_products = Cart.where(:user_id => current_user.id) \n\tend", "def previous_promotion_ids\n @previous_promotion_ids ||= []\n end", "def merit_order\n order = Merit::Order.new\n\n producers.each do |producer|\n order.add(producer) unless producer.marginal_costs == Float::NAN\n end\n\n order.add(local_demand_user)\n\n order\n end", "def matching_products\n if compute_on_promotion?\n calculable.promotion.rules.map do |rule|\n rule.respond_to?(:products) ? rule.products : []\n end.flatten\n end\n end", "def participatory_processes\n @participatory_processes ||= filtered_processes.includes(attachments: :file_attachment)\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def load_previous_provisions\n @ciservice.provisionings = @data_store.transaction { @data_store.fetch(:provisionings, @ciservice.provisionings) }\n end", "def payment_items\n\t\t\t\t\treturn self.order_items\n\t\t\t\tend", "def current_workflow_processes\n wf_processes = []\n RuoteKit.engine.processes.each do |wfp|\n wf_processes << wfp if wfp.target == self\n end\n\n wf_processes\n end", "def unprocessed_transactions\n\t\tself.transactions.where(approved: true, processed: false)\n\tend", "def get_all_scoped_privileges_and_prohibitions(user_or_attribute, object_or_attribute, options = {})\n if policy_machine_storage_adapter.respond_to?(:scoped_privileges)\n policy_machine_storage_adapter.scoped_privileges(user_or_attribute.stored_pe, object_or_attribute.stored_pe, options).map do |op|\n operation = PM::Operation.convert_stored_pe_to_pe(op, policy_machine_storage_adapter, PM::Operation)\n [user_or_attribute, operation, object_or_attribute]\n end\n else\n operations.grep(->operation{is_privilege_ignoring_prohibitions?(user_or_attribute, operation, object_or_attribute)}) do |op|\n [user_or_attribute, op, object_or_attribute]\n end\n end\n end", "def delivered_products\n @delivered_products ||= begin\n products = order['OrderDetails']['OrderRows']\n products.each do |ol|\n if ol['OrderRowId'].to_s == line_id.to_s\n ol['QuantityToDeliver'] = quantity\n ol['PackageId'] = track_and_trace_reference\n end\n\n if ol['ProductId'] == 'Postage'\n ol['QuantityToDeliver'] = 1\n ol['PackageId'] = track_and_trace_reference\n end\n end\n products.collect do |pr|\n pr.slice 'OrderRowId', 'QuantityToDeliver', 'PackageId'\n end\n end\n end", "def proefssorted\n \tproefs.order(:position)\n end", "def get_deleted_preorders\n params.require(:menu).delete(:deleted_preorders) || []\n end", "def related_promotions\n @related_promotions ||= Promotions::Relevance.to_category(self)\n end", "def api_promotions_get(params, opts = {})\n data, _status_code, _headers = api_promotions_get_with_http_info(params, opts)\n return data\n end", "def processed_items\n @processed.to_a\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def proppatch(nodes)\n init_pstore unless exists?\n\n actions = { set: [], remove: [] }\n\n @store.transaction do\n @store[:properties] = {} unless @store[:properties].is_a? Hash\n\n add_remove_properties nodes, actions\n end\n\n get_custom_property nil\n actions\n end", "def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end", "def get_undelivered_order_ids\n\n #enable this one for previous restricted conditioned(pause/resume)\n #orders =self.orders.select('id, delivery_date').where('spree_orders.delivery_date > ?', Time.now).limit(3)\n orders = self.orders.select('id, delivery_date').where('spree_orders.state in (?) ', ['confirm', 'placed']).limit(3)\n\n order_ids = {}\n\n orders.each_with_index do |order, index|\n order_ids.merge!(index => order.id)\n end\n\n order_ids\n end", "def entities\n ordering.map(&:entity).compact\n end", "def unpromoted_order\n @unpromoted_order ||= if session['order']\n OrderBasket.load(session['order'])\n else\n OrderBasket.new\n end\n end", "def stock_mutations\n StockMutation.where( \n :source_document_id => self.id , \n :source_document => self.class.to_s,\n :mutation_case => MUTATION_CASE[:sales_return],\n :mutation_status => MUTATION_STATUS[:addition], \n :item_status => ITEM_STATUS[:ready]\n ).order(\"created_at ASC\")\n \n end", "def relation\n context = Order\n context = context.where(from_group_id: from_group_id) if from_group_id\n context = context.where(to_producer_id: to_producer_id) if to_producer_id\n context = context.where(confirm_before: confirm_before) if confirm_before\n context = context.order(:updated_at)\n context\n end", "def cur_ordering\r\n @orderings\r\n end", "def request_orders\n @player.request_orders\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def applied\n @collection.select(&:applied?)\n end", "def index\n @product_promotions = ProductPromotion.all\n end", "def to_store_orders\n Order.where(:status => 'picked')\n end", "def get_edited_preorders\n params.require(:menu).delete(:edited_preorders) || []\n end", "def promotions\n # Promotion.in(id: user_promotions.pluck(:promotion_id))\n Promotion.where({'id'=> {'$in'=> UserPromotion.pluck(:promotion_id)}, 'end_date'=> {'$gt'=> DateTime.now}, 'start_date'=> {'$lt'=> DateTime.now}})\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def products\n @products ||= rules.of_type('Spree::Promotion::Rules::Product').map(&:products).flatten.uniq\n end", "def processed_promos\n respond_to do |format|\n @taken_promos = TakenPromo.get_taken_promos_for_user current_user\n format.html { }\n end\n end", "def retrieve_prioritary_pursuit_actions\n pursuit_selector = proc { |action| action[:type] == :attack && action[:skill].db_symbol == :pursuit }\n pursuit_actions = @actions.select(&pursuit_selector)\n @actions.reject!(&pursuit_selector)\n non_prio_pursuit = pursuit_actions.select! do |action|\n !battler(action[:target_bank], action[:target_position]).switching?\n end\n @actions.concat(non_prio_pursuit || [])\n return pursuit_actions\n end", "def all_preorder\n inject([]) do |a, resource_template|\n a += resource_template.all_preorder\n end\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def index\n if @customer.nil?\n @promotions = Promotion.all\n else \n @promotions = @customer.promotions\n end\n render 'promotions/promotions', :locals => { :promotions => @promotions }\n end", "def load_data\n @promotions = Promotion.find(:all)\n @products = Product.find(:all, :conditions => ProductFilter.website_conditions(@website))\n end", "def products\n @products ||= rules.of_type('Promotion::Rules::Product').map(&:products).flatten.uniq\n end", "def order\n return @order\n end", "def profils()\n return @profils\n end", "def get_orders\n orders\n end", "def tracking_orders\n return [] if !is_employee?\n employee.orders\n end", "def coupons\n @items = @product.product_coupons\n end", "def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end", "def matching_products\n # Regression check for #1596\n # Calculator::PerItem can be used in two cases.\n # The first is in a typical promotion, providing a discount per item of a particular item\n # The second is a ShippingMethod, where it applies to an entire order\n #\n # Shipping methods do not have promotions attached, but promotions do\n # Therefore we must check for promotions\n if self.calculable.respond_to?(:promotion)\n self.calculable.promotion.rules.map(&:products).flatten\n end\n end", "def index\r\n @models_have_products = []\r\n @models_no_products = []\r\n Model.all.each do |model|\r\n if products_available(model)\r\n @models_have_products << model\r\n else\r\n @models_no_products << model\r\n end\r\n end \r\n @models = Model.all.order(:priority)\r\n end", "def changes_applied\n unless defined?(@attributes)\n mutations_from_database.finalize_changes\n end\n @mutations_before_last_save = mutations_from_database\n forget_attribute_assignments\n @mutations_from_database = nil\n end", "def managed_app_policies\n return @managed_app_policies\n end", "def buys\n orders[:buys]\n end", "def requested_modalities\n return @requested_modalities\n end", "def fulfilled_line_items\n return self.order_line_items.where(:status => 'shipped').all\n end", "def all_objects_in_order\n all_objects\n end", "def orders_completed\n result = Array.new\n self.job_applications.each do |j|\n j.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end", "def elements\n # execute query\n ordered_objects.compact.uniq\n end", "def checkout\n # assumes that an in_process must have at least one line_item\n # and therefore a basket\n raise \"An in_process order should have a basket.\" unless basket\n\n basket.moderators_or_next_in_line.each do |user|\n UserNotifier.deliver_in_process(self, user)\n end\n\n end", "def procs\n @procs\n end", "def products\n products_at_market = []\n vendors_at_market = self.vendors\n vendors_at_market.each do |vendor|\n products_at_market << vendor.products\n end\n return products_at_market.flatten\n end", "def get_new_preorders\n params.require(:menu).delete(:new_preorders) || []\n end", "def processOrder\n \n end", "def promotion_directives\n context[:promotion_directives] ||= {}\n end", "def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end", "def saved_changes\n mutations_before_last_save.changes\n end", "def my_order\n @orders = Order.where(user: current_user)\n end", "def extract_behaviors!\n # Get the behaviors.\n behs = self.each_behavior.to_a\n # Remove them from the scope.\n # behs.each { |beh| self.delete_behavior!(beh) }\n self.delete_all_behaviors!\n # Return the behaviors.\n return behs\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def remove_quantity_promotions\n if @basket_item.type == \"PurchasingItem\"\n using_promotions_count = UsingPromotion.where(basket_id: @basket_item.basket_id)\n .group(:promotion_id)\n .count\n using_promotions_count.each do | promotion_id, cnt |\n promotion = Promotion.find(promotion_id)\n item_cnt = BasketItem.where(basket_id: @basket_item.basket_id,\n item_id: @basket_item.item_id)\n .count - 1\n if promotion.item_id == @basket_item.item_id &&\n cnt * promotion.item_quantity > item_cnt\n UsingPromotion.where( basket_id: @basket_item.basket_id,\n promotion_id: promotion.id)\n .first\n .destroy\n end\n end\n end\n end", "def to_be_reconciled\n @params.select { |_order_detail_id, params| params[:reconciled] == \"1\" }\n end", "def index\n @pop_elements = PopElement.all\n @orders = Order.user_order(current_user)\n end", "def propositional_symbols\n symbols = []\n @classified.each do |el|\n symbols.push el if el.instance_of? Proposition\n end\n symbols\n end", "def check_unattended_orders\n if session.delete(:just_logined) == true && @current_user\n if @current_user.is_merchant\n @unattended_orders = @current_user.products.collect(&:orders).first.\n where(\"(status is null OR status = 1) AND orders.created_at >= ?\", @current_user.last_signed_out_at)\n end\n end\n end", "def perspectives\n @perspectives ||= {}\n end", "def promotion_id_dump\n pending_promotions.map(&:id)\n end", "def policies\n @policies = Policy.all\n end", "def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end" ]
[ "0.80131304", "0.7216369", "0.6728518", "0.6685051", "0.6642239", "0.6181208", "0.6127939", "0.60987204", "0.5899521", "0.5784074", "0.5725257", "0.548562", "0.5454655", "0.5454505", "0.54490453", "0.54270303", "0.54270303", "0.54270303", "0.5412441", "0.5309505", "0.52762616", "0.52700645", "0.5184079", "0.5153356", "0.514789", "0.51332897", "0.51056224", "0.5079705", "0.50771654", "0.5058094", "0.50507176", "0.50417", "0.5030022", "0.50288117", "0.50231326", "0.50160795", "0.5007611", "0.49952", "0.49941424", "0.49898416", "0.49605903", "0.4951773", "0.49401507", "0.49361116", "0.49338737", "0.4902871", "0.489923", "0.48845574", "0.487876", "0.48725343", "0.48404393", "0.4826242", "0.481064", "0.48013297", "0.4797634", "0.47889662", "0.47668323", "0.47519305", "0.4746695", "0.4745552", "0.47397408", "0.47117642", "0.4707835", "0.47045907", "0.46993828", "0.46967036", "0.4691237", "0.46618083", "0.46469042", "0.46420804", "0.46392095", "0.46362758", "0.46275428", "0.46259782", "0.46232563", "0.46160865", "0.46140864", "0.46087354", "0.4600293", "0.4600108", "0.45983404", "0.45971078", "0.45937714", "0.4586746", "0.4581566", "0.45808664", "0.45731068", "0.4566534", "0.45663032", "0.4559102", "0.45564008", "0.4551702", "0.45492473", "0.4546114", "0.4546058", "0.45391795", "0.45388013", "0.4536507", "0.45362064", "0.45345414" ]
0.6606123
5
Checks to see if there are any promotions pending/applied to the order.
def pending_promotions? !pending_promotions.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def checkout_allowed?\n order_items.count > 0\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def is_under_process?\n #if true then this sub has got orders which are under process(by payment / shipment)\n self.orders.where('(delivery_date <= ? and delivery_date > ?) or (state = ? and payment_state = ?)', ORDER_UPDATE_LIMIT.days.from_now.to_date, Time.now, 'placed', 'paid').present?\n end", "def anything_to_do?\n (pending.length + state_check.length) > 0\n end", "def has_pending\n\t\tget_cart_pending_balance > 0\n\tend", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def capture_pending_payments\n success = true\n order.payments.pending.each do |payment|\n unless payment.capture!\n copy_errors(payment)\n success = false\n end\n end\n success\n end", "def has_any_pending_tickets?\r\n TicketOrder.where(user: self).requires_attention.any?\r\n end", "def pending_data?\n !pending_queues.empty?\n end", "def punch_out_order_message?\n !punch_out_order_message.nil?\n end", "def has_pending_requests?\n received_requests.pending.any?\n end", "def ready_to_approve?\n status = self.units.map(&:unit_status) & ['condition', 'copyright', 'unapproved']\n return status.empty?\n end", "def promotions\n @promotions ||= order.promotions\n end", "def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def is_pending?\n return self.status == Erp::QuickOrders::Order::STATUS_PENDING\n end", "def valid_order?\n order.coupon.nil? && coupon.cancelled_at.nil?\n end", "def has_confirmed_order?\n confirmed_order = false\n open_orders.each do |o|\n if o.confirmed\n confirmed_order = true\n break\n end\n end\n confirmed_order\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end", "def check_unattended_orders\n if session.delete(:just_logined) == true && @current_user\n if @current_user.is_merchant\n @unattended_orders = @current_user.products.collect(&:orders).first.\n where(\"(status is null OR status = 1) AND orders.created_at >= ?\", @current_user.last_signed_out_at)\n end\n end\n end", "def has_order_items?\n @cores != nil || @ram != nil || @max_port_speed != nil\n end", "def has_transactions?\n queue.any?\n end", "def pending?\n self.pending\n end", "def isPending?\n self.pending\n end", "def pending?\n self.pending\n end", "def has_unpaid_bills\r\n return self.get_unpaid_bills.size > 0\r\n end", "def pending_financials?\n shop && shop.pending_products.any?\n end", "def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end", "def orders?\n return orders.any?\n end", "def deliver_store_owner_order_notification_email?\n store.new_order_notifications_email.present? && !store_owner_notification_delivered?\n end", "def pending\n !as_stripe_subscription.pending_update.nil?\n end", "def pending_actions?\n return true if @log.pending_actions?\n @derivative_builds.each do |d|\n return true if d.pending_actions?\n end\n return false\n end", "def confirmed?\n self.contributions.each do |contribution|\n return false if contribution.isPending?\n end\n return true\n end", "def any_eob_processed?\n self.insurance_payment_eobs.length >= 1\n end", "def unappliable_order?\n order.bought? == false\n end", "def is_pending?\n generated_at.nil? && !paid_on.nil?\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def ready_to_exchange?\n self.balance >= self.promotion.points_to_exchange\n end", "def pact_pending?\n pact_pending\n end", "def pending?\n pending\n end", "def on_order?\n !self.paid?\n end", "def entirely_unshipped?\n line_items_uncancelled.empty?.not && line_items_uncancelled.detect {|li| ! li.shipment.nil? }.nil?\n end", "def delivered?\n check_elements_for_compliance { |e| !e.delivered? }\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def check_watting_order(kraken, order_waiting)\n order_waiting.each do |o|\n state = kraken.check_order_status(o.txid)\n next unless state\n o.order_done! if state == 'closed'\n end\n end", "def pending_shop_request?\n !launched_shop? && latest_pending_shop_request\n end", "def due_status?(order)\n order.relevant_delivery_date &&\n (order.shippable? || order.collectable?) &&\n !order.shipped_at &&\n order.collection_ready_emails.empty?\n end", "def available_for_order?(_order)\n true\n end", "def delivered?\n processed? && !held? && !bounced? && message.present?\n end", "def check_current_order\t\n\t\t# TODO: Introduce a proper way to check the order payment status\n\t\t# Currently the order get removed from the session the moment the\n\t\t# spree receives payment and no way of tracking. Might have to introduce\n\t\t# other means of checking for payment receival for orders. A possible\n\t\t# method would be to have session id sent along with IPN secret and\n\t\t# mark a flag on payment notifications after displaying payment received\n\t\t# message\n\t\t# if current_order \\\n\t\t# && current_order.completed? \n\t\t# # && ((current_order.payment_state == \"paid\") or (current_order.payment_state == \"credit_owed\"))\n\t\t# \tflash[:notice] = t(:pp_ws_payment_received)\n\t\t# \t@order = current_order\n\t\t# \tsession[:order_id] = nil\n\n\t\t# \tif current_user\n\t\t# \t\tredirect_to spree.order_path(@order)\n\t\t# \telse\n\t\t# \t\tredirect_to root_path\n\t\t# \tend\n\t\t\t\n\t\t# end\n\tend", "def empty?\n order_items.empty?\n end", "def empty?\n order_items.empty?\n end", "def paid_in_full?\n !payment_outstanding?\n end", "def pending?\n !trailing.nil?\n end", "def pending?\n self[:pending]\n end", "def pending!\n return false if purchased?\n\n assign_attributes(status: :pending)\n self.addresses.clear if addresses.any? { |address| address.valid? == false }\n save!\n\n if send_payment_request_to_buyer?\n after_commit { send_payment_request_to_buyer! }\n end\n\n true\n end", "def has_notifications?\n !notification_queue.empty?\n end", "def pending?\n self.pending\n end", "def need_send_status_mail?\n Project.owned_by(self).count > 0 ||\n Project.executed_by(self).count.present?\n end", "def confirm_all_pending_purchases\r\n self.pending_purchases.each{|purchase| purchase.confirm}\r\n end", "def check_order_status(id)\n @order = Order.find_by_id(id)\n\n incomplete = 0\n @order.order_items.each do |item|\n if item.ship_status == false\n incomplete += 1\n end\n end\n\n if incomplete == 0\n @order.status = 'complete'\n @order.save\n else\n @order.status = 'paid'\n @order.save\n end\n return @order\n end", "def settled?\n return !self.pending?\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def pending?\n tangible? && pending != 0\n end", "def can_be_added?(order)\n eligible?(order) &&\n (can_combine?(order) || order.promotion_credits.empty?) &&\n Credit.count(:conditions => {\n :adjustment_source_id => self.id,\n :adjustment_source_type => self.class.name,\n :order_id => order.id\n }) == 0\n end", "def pending?\n return self.settled_at.nil?\n end", "def work_pending?\n !buffer.empty?\n end", "def pending?\n !approved? && !not_approved?\n end", "def payment_in_progress?\n\t\t\t\t\treturn !self.payment_id.nil?\n\t\t\t\tend", "def notify_not_delivered\n @not_delivered = not_delivered\n\n emails = Settings.first.notify_scans_not_delivered_to\n\n if !@not_delivered.empty? && emails.any?\n ScanMailer.notify_not_delivered(emails, @not_delivered).deliver_later\n else\n false\n end\n end", "def has_pending?\n self.class.job_run_class.has_pending?(@job, @batch)\n end", "def all_jobs_hve_been_processed?(queue)\n (job_count(queue) == 0) && (working_job_count(queue) <= 1)\n end", "def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end", "def pending?\n pending\n end", "def is_pending_confirmation?\n\n self.publishing_state == PublishingState::PENDING_CONFIRMATION\n\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def already_processed?(transaction)\n transaction['type'] != 'AA'\n end", "def check_for_completeness\n mark_complete(Time.now) if paid? && received?\n end", "def incomplete?\n running? || pending? || initialized?\n end", "def eligible?(order)\n order.completed? or (!expired? and rules_are_eligible?(order))\n end", "def pending?\n response = rpc(action: :pending_exists, param_name: :hash)\n !response.empty? && response[:exists] == '1'\n end", "def capture\n begin \n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # go through all order_payments\n order_payments = self.order_payments\n if order_payments.size == 0\n p \"No order_payments to process.\"\n raise PaymentError, \"No order_payments to process.\"\n end\n for order_payment in order_payments\n order_payment.capture!\n end\n self.upgrade_coupons!\n # update order\n self.update_attributes!(:state => Order::PAID, :paid_at => Time.zone.now)\n end\n # send confirmation email\n user = User.find_by_id(self.user_id)\n if user and user.send_confirmation(self.deal_id)\n return true\n else\n logger.error \"Order.capture: Confirmation email failed to send: #{self.inspect}\"\n return false\n end\n rescue PaymentError => pe\n p \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n rescue ActiveRecord::RecordInvalid => invalid\n p \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end", "def request_sent?(_user_id)\n pending_user_relationships.where(user_id: _user_id).any?\n end", "def handle_stock_counts?\n current_shipment.order.completed? && current_stock_location != desired_stock_location\n end", "def complete?()\n if (self.order_in_lines.length == 0)\n return false\n end\n self.order_in_lines.each do | line |\n if (line.qty < line.qty_in)\n return false\n end\n end\n return true\n end", "def paid_up?\n if payment_item.is_a? GeneralPaymentItem\n outstanding_amount <= 0.0\n else\n nil\n end\n end", "def processings?\n @processings.any?\n end", "def pending?\n payment_status == 'Pending'\n end", "def pending?\n status == PENDING_STATE\n end", "def to_be_performed?\n self.research_billing_qty > 0\n end", "def no_proposals_unless_manages_proposals\n return true if manages_proposals or proposals.empty?\n errors.add(:manages_proposals,\n _('This conference already has received %d proposals (%s) - ' +\n 'Cannot specify not to handle them.') %\n [self.proposals.size, self.proposals.map {|p| p.id}.join(', ')])\n end", "def reject_promotion_if_not_enough_items\n promotion = Promotion.find(@basket_item.promotion_id)\n if !promotion.item_id.nil?\n items_count = BasketItem.where( basket_id: @basket_item.basket_id,\n item_id: promotion.item_id)\n .count\n # count pieces of the item for which promotions already applied\n item_promotions_count = 0\n Promotion.where(item_id: promotion.item_id).each do | p |\n item_promotions_count += BasketItem.where(basket_id: @basket_item.basket_id,\n promotion_id: p.id)\n .count * promotion.item_quantity\n end\n\n if items_count - item_promotions_count < promotion.item_quantity\n flash[:danger] = \"Not enough items in the basket to apply the promotion!\"\n @reject = true\n end\n end\n end", "def any_requested_booking_confirmed_not_completed?\n count = 0\n index\n @requested_bookings.each do |booking|\n count += 1 if booking.confirmed && !booking.completed\n end\n true if count.positive?\n end" ]
[ "0.7250044", "0.6820905", "0.67420924", "0.6575087", "0.63620156", "0.62685466", "0.6214691", "0.62023866", "0.6189956", "0.61802685", "0.61587554", "0.61482704", "0.614073", "0.61390716", "0.61282104", "0.61171407", "0.6091816", "0.60823596", "0.6051234", "0.6018808", "0.6002395", "0.5990904", "0.59670126", "0.5936481", "0.59226286", "0.5915062", "0.5909796", "0.59017056", "0.58836836", "0.5866472", "0.5854282", "0.5847519", "0.5844154", "0.5834801", "0.5829579", "0.5822231", "0.5821541", "0.58069736", "0.5789637", "0.57869685", "0.57861334", "0.57799417", "0.5777251", "0.5769005", "0.57612306", "0.57599676", "0.5750625", "0.5743656", "0.57306844", "0.5717393", "0.57145345", "0.5710635", "0.5705614", "0.56981784", "0.5696753", "0.5696108", "0.568663", "0.56864905", "0.56864905", "0.5683397", "0.56669915", "0.5666237", "0.56593275", "0.5656998", "0.56523573", "0.5646218", "0.5645892", "0.56344366", "0.56285924", "0.56277555", "0.56242514", "0.56152666", "0.5589854", "0.55810827", "0.5571151", "0.55601907", "0.55598146", "0.5555513", "0.5552854", "0.554684", "0.5541907", "0.55316484", "0.5523502", "0.5523236", "0.5507203", "0.55031544", "0.55014205", "0.5501417", "0.5501101", "0.54999185", "0.5489987", "0.5481239", "0.54764766", "0.5470866", "0.54685354", "0.546804", "0.54678", "0.5467428", "0.54673", "0.54653645" ]
0.7923248
0
Any promotions that have been previously applied to the order.
def existing_promotions @existing_promotions ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def promotions\n @promotions ||= order.promotions\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def new_promotions\n @new_promotions ||= []\n end", "def promotions\n Spree::Promotion.find_by_sql(\"#{order.promotions.active.to_sql} UNION #{Spree::Promotion.active.where(code: nil, path: nil).to_sql}\")\n connected_order_promotions | sale_promotions\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end", "def applied\n @applied ||= []\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def processOrder\n \n end", "def order\n @order ||= if session['order']\n OrderBasket.load(session['order']).tap(&:apply_promotions!)\n else\n OrderBasket.new\n end\n end", "def promotions\n adjustments.where( promotion: true )\n end", "def current_promotions\n promotions.where([\"start_on IS NOT NULL AND start_on <= ? AND (end_on >= ? OR end_on IS NULL OR end_on = '')\", Date.today, Date.today]).order(\"start_on\")\n end", "def original_order\n end", "def process_pending\n process_nested and process_relations\n pending_nested.clear and pending_relations.clear\n _reset_memoized_descendants!\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def tidy_up!\n antecedence.each_key do |entry|\n antecedence[entry].uniq!\n end\n end", "def merit_order\n order = Merit::Order.new\n\n producers.each do |producer|\n order.add(producer) unless producer.marginal_costs == Float::NAN\n end\n\n order.add(local_demand_user)\n\n order\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def related_promotions\n @related_promotions ||= Promotions::Relevance.to_category(self)\n end", "def unpromoted_order\n @unpromoted_order ||= if session['order']\n OrderBasket.load(session['order'])\n else\n OrderBasket.new\n end\n end", "def rewrite_order_relations\n return unless(@ordered_objects) # If this is nil, the relations weren't loaded in the first place\n objects = ordered_objects # Fetch them before deleting\n # Now destroy the existing elements\n SemanticRelation.destroy_all(['subject_id = ? AND rel_order IS NOT NULL', self.id])\n SemanticRelation.destroy_all(['subject_id = ? AND predicate_uri = ?', self.id, N::DCT.hasPart.to_s])\n # rewrite from the relations array\n objects.each_index do |index|\n if(obj = objects.at(index)) # Check if there's a value to handle\n # Create a new relation with an order\n self[index_to_predicate(index)].add_record(obj, index)\n self[N::DCT.hasPart] << obj\n end\n end\n end", "def unprocessed_transactions\n\t\tself.transactions.where(approved: true, processed: false)\n\tend", "def unapply\n return return_with(:error, I18n.t('coupon.cannot_remove')) unless unappliable_order?\n return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless reset_order! && reset_coupon!\n return_with(:success)\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def add_commands_for_products_to_be_removed!\n current_state.each do |profile|\n\n # We need to issue refunds before cancelling profiles\n refund_options = issue_refunds_if_necessary(profile)\n remaining_products = remove_products_from_profile(profile)\n\n if remaining_products.empty? # all products in payment profile needs to be removed\n\n @command_list << cancel_recurring_payment_command(profile, refund_options)\n\n elsif remaining_products.size == profile.products.size # nothing has changed\n #\n # do nothing\n #\n else # only some products are being removed and the profile needs to be updated\n\n if remaining_products.size >= 1\n\n @command_list << remove_product_from_payment_profile(profile.identifier,\n removed_products_from_profile(profile),\n refund_options)\n else\n\n @command_list << cancel_recurring_payment_command(profile, refund_options)\n @command_list << create_recurring_payment_command(remaining_products, \n :paid_until_date => profile.paid_until_date,\n :period => extract_period_from_product_list(remaining_products))\n end\n end\n end\n end", "def align_all_global\n @results = []\n @proteins.each { |protein|\n @results << align_global(protein)\n }\n @results = @results.sort_by { |evaluated_protein| evaluated_protein.value }\n end", "def before_delivery\r\n return if params[:order].present?\r\n \r\n if @order.bill_address.address1 == 'dummy_address1' or @order.bill_address.city == 'dummy_city' or @order.bill_address.address2.include? \"CityBox\"\r\n @disable_all_except_citybox = true\r\n end\r\n\r\n packages = @order.shipments.map { |s| s.to_package }\r\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\r\n end", "def extract_behaviors!\n # Get the behaviors.\n behs = self.each_behavior.to_a\n # Remove them from the scope.\n # behs.each { |beh| self.delete_behavior!(beh) }\n self.delete_all_behaviors!\n # Return the behaviors.\n return behs\n end", "def apply_coupon!(order, coupon)\n CouponHandler.new(nil, order.coupon, order).update_order!\n CouponHandler.new(nil, order.coupon, order).update_coupon!\nend", "def process_coupom\n @orders_csv.each do |oc|\n coupom = @coupons[oc.coupom_id]\n @orders_hash[oc.id].compute(coupom) if coupom && coupom.valid?\n end\n end", "def get_undelivered_order_ids\n\n #enable this one for previous restricted conditioned(pause/resume)\n #orders =self.orders.select('id, delivery_date').where('spree_orders.delivery_date > ?', Time.now).limit(3)\n orders = self.orders.select('id, delivery_date').where('spree_orders.state in (?) ', ['confirm', 'placed']).limit(3)\n\n order_ids = {}\n\n orders.each_with_index do |order, index|\n order_ids.merge!(index => order.id)\n end\n\n order_ids\n end", "def previous_promotion_ids\n @previous_promotion_ids ||= []\n end", "def checkout\n # assumes that an in_process must have at least one line_item\n # and therefore a basket\n raise \"An in_process order should have a basket.\" unless basket\n\n basket.moderators_or_next_in_line.each do |user|\n UserNotifier.deliver_in_process(self, user)\n end\n\n end", "def matching_products\n if compute_on_promotion?\n calculable.promotion.rules.map do |rule|\n rule.respond_to?(:products) ? rule.products : []\n end.flatten\n end\n end", "def compact!\n return unless applied\n applied.compact!\n self.pending = applied.next\n end", "def emit_when_branch_presence_mutations\n return if one?\n when_branches.each_index do |index|\n dup_branches = dup_when_branches\n dup_branches.delete_at(index)\n emit_self(receiver, dup_branches, else_branch)\n end\n end", "def processed_items\n @processed.to_a\n end", "def to_be_reconciled\n @params.select { |_order_detail_id, params| params[:reconciled] == \"1\" }\n end", "def proefssorted\n \tproefs.order(:position)\n end", "def sanitize_and_merge_order(*orders)\n self.class.sanitize_and_merge_order(*orders)\n end", "def test_cleanup_promotion_order_finished\n # Setup - add promotion and complete order\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n @o.order_status_code = order_status_codes(:ordered_paid_to_ship)\n assert @o.save\n \n # Now expire the promo\n assert promo.update_attributes({\n :start => Date.today - 2.weeks,\n :end => Date.today - 1.week\n })\n promo.reload\n @o.reload\n \n # Update something on the order, like an admin would.\n # Maybe we shipped out the order and changed the status code.\n @o.order_status_code = order_status_codes(:sent_to_fulfillment)\n assert [email protected]_promotion_be_applied?(promo)\n assert @o.save\n \n @o.reload\n \n # Check to see if promotion is still applied (it should be!)\n assert_equal promo, @o.promotion\n assert_kind_of OrderLineItem, @o.promotion_line_item\n end", "def prepare_chain\n chain = []\n chain << NomenclatureChange::OutputTaxonConceptProcessor.new(@primary_output)\n chain << NomenclatureChange::OutputTaxonConceptProcessor.new(@secondary_output)\n\n chain << reassignment_processor(@secondary_output)\n\n chain <<\n if @primary_output.new_name_status == 'A'\n linked_names = @secondary_output ? [@secondary_output] : []\n NomenclatureChange::StatusUpgradeProcessor.new(@primary_output, linked_names)\n else\n accepted_names = @secondary_output ? [@secondary_output] : []\n NomenclatureChange::StatusDowngradeProcessor.new(@primary_output, accepted_names)\n end\n chain.compact\n end", "def update_order\n # If there is no adjustment for the current gift package, just create one here unless there already is one for the gift package\n if self.gift_package_id && self.gift_package_id > 0 && self.adjustments.gift_packaging.where(:originator_id => self.gift_package_id).count == 0\n self.gift_package.adjust(self) \n end \n # Then update all adjustments\n self.update_adjustments\n # update the order totals, etc.\n order.update!\n end", "def set_cleanup_reproduction_associations\n @cleanup_reproduction_associations = nil\n if @order.order_type.name == 'reproduction' &&\n params[:order][:order_type_id] != @order.order_type_id\n @cleanup_reproduction_associations = true\n end\n end", "def setup_deliveries(order)\n recent_deliveries = order.market.deliveries.recent.active.uniq\n future_deliveries = order.market.deliveries.future.active.uniq\n\n @deliveries = recent_deliveries | future_deliveries | [order.delivery]\n end", "def applied\n @collection.select(&:applied?)\n end", "def changes_applied\n unless defined?(@attributes)\n mutations_from_database.finalize_changes\n end\n @mutations_before_last_save = mutations_from_database\n forget_attribute_assignments\n @mutations_from_database = nil\n end", "def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end", "def align_all_local\n @results = []\n @proteins.each { |protein|\n @results << align_local(protein)\n }\n @results = @results.sort_by { |evaluated_protein| evaluated_protein.value }\n end", "def proppatch(nodes)\n init_pstore unless exists?\n\n actions = { set: [], remove: [] }\n\n @store.transaction do\n @store[:properties] = {} unless @store[:properties].is_a? Hash\n\n add_remove_properties nodes, actions\n end\n\n get_custom_property nil\n actions\n end", "def promotion_directives\n context[:promotion_directives] ||= {}\n end", "def merge!(order)\n if self.line_items.count > 0\n order.destroy\n else\n self.billing_address = self.billing_address || order.billing_address\n self.shipping_address = self.shipping_address || order.shipping_address\n order.line_items.each do |line_item|\n next unless line_item.currency == currency\n line_item.order_id = self.id\n line_item.save\n end\n\n end\n end", "def activate_orders(token, coupon,card_id)\n order_with_coupon = self.orders.where(\"state = ? and coupon_id is not ?\", \"paused\", nil).first\n order_with_coupon.assign_attributes(coupon_id: coupon[\"id\"]) if coupon.present? && order_with_coupon.present?\n order_with_coupon.assign_attributes(coupon_id: nil) if order_with_coupon.present? && coupon.blank?\n\n\n if order_with_coupon.present?\n order_with_coupon.save(validate: false)\n order_with_coupon.update_total_and_item_total\n end\n\n paused_orders = self.orders.where(state: 'paused')\n\n paused_orders.each_with_index do |order, index|\n order.assign_attributes(state: \"confirm\",\n delivery_date: FIRST_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 0\n order.assign_attributes(state: \"confirm\",\n delivery_date: SECOND_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 1\n order.assign_attributes(state: \"confirm\",\n delivery_date: THIRD_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 2\n order.assign_attributes(creditcard_id: card_id)\n order.save(validate: false)\n end\n end", "def remove_from_old_order\n coupon.orders&.first&.update(\n coupon_discount: 0,\n coupon_applied_at: nil,\n coupon_id: nil\n )\n end", "def delivered_products\n @delivered_products ||= begin\n products = order['OrderDetails']['OrderRows']\n products.each do |ol|\n if ol['OrderRowId'].to_s == line_id.to_s\n ol['QuantityToDeliver'] = quantity\n ol['PackageId'] = track_and_trace_reference\n end\n\n if ol['ProductId'] == 'Postage'\n ol['QuantityToDeliver'] = 1\n ol['PackageId'] = track_and_trace_reference\n end\n end\n products.collect do |pr|\n pr.slice 'OrderRowId', 'QuantityToDeliver', 'PackageId'\n end\n end\n end", "def preOrder(instruction)\n @orderMethods.preOrder(instruction)\n end", "def expire_associated(order)\n expirable = EXPIRABLE_FIELDS.any? do |key|\n order.changed_attributes.include?(key)\n end\n\n if expirable\n ASSOCIATED_CLASSES.each {|ac|\n publish :purge_cache, ActiveSupport::JSON.encode( {:subject_class => order.class.name, :subject_id => order.id, :associated_class => \"#{ac}\" }) \n }\n end\n end", "def process_all_tx\n result = []\n while tx = process_next_tx\n result.push(tx)\n end\n result\n end", "def checkout \n \t@order_items = current_order.order_items\n end", "def instructions_order\n instructions.each_with_index do |i, index|\n i.order = index + 1\n end\n end", "def Order_all\n\t\t@all_products = Cart.where(:user_id => current_user.id) \n\tend", "def update!\n update_totals\n update_payment_state\n # update_adjustments\n # update totals a second time in case updated adjustments have an effect on the total\n update_totals\n \n update_attributes_without_callbacks({\n :state => \"complete\"\n }) \n \n logger.info 'UPDATED ORDER'\n # update_hooks.each { |hook| self.send hook }\n end", "def matching_products\n # Regression check for #1596\n # Calculator::PerItem can be used in two cases.\n # The first is in a typical promotion, providing a discount per item of a particular item\n # The second is a ShippingMethod, where it applies to an entire order\n #\n # Shipping methods do not have promotions attached, but promotions do\n # Therefore we must check for promotions\n if self.calculable.respond_to?(:promotion)\n self.calculable.promotion.rules.map(&:products).flatten\n end\n end", "def maybe_promote\n return unless promote?\n promote!\n end", "def all_preorder\n inject([]) do |a, resource_template|\n a += resource_template.all_preorder\n end\n end", "def c(memo)\n each do |order|\n unless memo.keys.include?(order[0])\n memo << order\n end\n end\n end", "def associate_past_orders\n orders = Spree::Order.where(\"email = ?\", @user.email)\n unless orders == nil\n orders.each { |order|\n order.associate_user!(@user)\n }\n end\n end", "def inorder\n #Return an empty array if our root is nil\n return [] if @root == nil\n #Otherwise, call in reinforcements, and tell them where they can put the results\n return inorder_helper(@root, [])\n end", "def normalize_order\n # TODO: should Query::Path objects be permitted? If so, then it\n # should probably be normalized to a Direction object\n @order = @order.map do |order|\n case order\n when Operator\n target = order.target\n property = target.kind_of?(Property) ? target : @properties[target]\n\n Direction.new(property, order.operator)\n\n when Symbol, String\n Direction.new(@properties[order])\n\n when Property\n Direction.new(order)\n\n when Direction\n order.dup\n end\n end\n end", "def prepare_update\n # All elder broadcasts are trash...\n tmp = @broadcasts; \n @broadcasts = []\n @to_destroy = tmp.reject {|bc| bc.dirty?}\n\n # Get rid of unsolved, conflicts with unactivated broadcasts\n @conflicts = @conflicts.reject{|c| c.active_broadcast.nil?}\n\n # Clean all unactivated broadcasts from remaining conflicts\n @conflicts.each {|c| c.new_broadcasts = [] }\n\n # unless somebody used them\n tmp.select { |bc| bc.dirty? }.each do |bc|\n self.add_conflict( :conflict => find_or_create_conflict_by_active_broadcast(bc) )\n end\n end", "def queue_item_intentions()\n next_step_intentions.each { |i| queue_intention(i) }\n end", "def remove_from(order)\n Spree::Deprecation.warn(\"#{self.class.name.inspect} does not define #remove_from. The default behavior may be incorrect and will be removed in a future version of Solidus.\", caller)\n [order, *order.line_items, *order.shipments].each do |item|\n item.adjustments.each do |adjustment|\n if adjustment.source == self\n item.adjustments.destroy(adjustment)\n end\n end\n end\n end", "def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end", "def remove_quantity_promotions\n if @basket_item.type == \"PurchasingItem\"\n using_promotions_count = UsingPromotion.where(basket_id: @basket_item.basket_id)\n .group(:promotion_id)\n .count\n using_promotions_count.each do | promotion_id, cnt |\n promotion = Promotion.find(promotion_id)\n item_cnt = BasketItem.where(basket_id: @basket_item.basket_id,\n item_id: @basket_item.item_id)\n .count - 1\n if promotion.item_id == @basket_item.item_id &&\n cnt * promotion.item_quantity > item_cnt\n UsingPromotion.where( basket_id: @basket_item.basket_id,\n promotion_id: promotion.id)\n .first\n .destroy\n end\n end\n end\n end", "def preorder\n yield self\n each do |child|\n unless pre_terminal?\n child.preorder {|c| yield c}\n else\n each {|c| yield c}\n end\n end\n end", "def observed_exchange\n nil\n end", "def distribute_all_answers_if_none_pending\n # only execute if text changed\n if self.changes.keys.include?(\"text\") && self.changes[\"text\"].first.blank?\n answers = self.question.answers\n if answers.pending.count == 0\n AnswerMailer.all_answers(self.question, answers.pluck(:email)).deliver\n end\n end\n end", "def pre_hooks\n @to_perform.map do |hook|\n next unless hook.type.eql? :pre\n hook\n end.compact\n end", "def recalculate(order)\n order.respond_to?(:recalculate) ? order.recalculate : order.update!\n end", "def apply!\n return if @already_applied\n pointcuts.each do |pc| pc.apply! end\n @already_applied = true\n end", "def remove_preconditions_fulfilled_by action\r\n\t\taction[\"effect\"].each do |effect|\r\n\t\t\t@open_preconditions.each { |precon| @open_preconditions.delete(precon) if precon.to_s == effect.to_s }\r\n\t\tend\r\n\tend", "def process exp\n @processors.each do |processor|\n exp = processor.process(exp)\n end\n exp\n end", "def order_upgrade\n @order.next\n @order.complete!\n # Since we dont rely on state machine callback, we just explicitly call this method for spree_store_credits\n if @order.respond_to?(:consume_users_credit, true)\n @order.send(:consume_users_credit)\n end\n @order.finalize!\n end", "def action_processed(_action)\n @entities.each(&:unpass!)\n end", "def compute_order(_order)\n raise 'Spree::TaxCloud is designed to calculate taxes at the shipment and line-item levels.'\n end", "def process(items)\n found = false\n to_process = items.select {|item| found ||= (item.checksum == self.checksum) }\n to_process.blank? ? to_process = items : to_process.shift\n to_process.each {|entry| store(entry) }\n end", "def parts_with_order_remove part\n self.parts_with_order = self.parts_with_order.reject{|master_file| master_file.pid == part.pid }\n end", "def orders_completed\n result = Array.new\n self.job_applications.each do |j|\n j.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end", "def order_unordered\n self.reset_column_information\n self.group(self.orderable_scope).each do |obj|\n unordered_conditions = \"#{self.orderable_column} IS NULL OR #{self.table_name}.#{self.orderable_column} = 0\"\n ordered_conditions = \"#{self.orderable_column} IS NOT NULL AND #{self.table_name}.#{self.orderable_column} != 0\"\n order_nr = obj.all_orderable.order(self.orderable_column).last[self.orderable_column] || 0\n obj.all_orderable.where(unordered_conditions).find_each do |item|\n order_nr += 1\n raw_orderable_update(item.id, order_nr)\n end\n end\n end", "def apply_coupon\n if self.behavior == 'coupon'\n item = self.item\n \n # coitem is the OrderItem to which the coupon acts upon\n coitem = self.order.order_items.visible.find_by_sku(item.coupon_applies)\n log_action \"apply_coupon: coitem was not found\" and return if coitem.nil?\n\n unless coitem.coupon_amount.zero? then\n log_action \"apply_coupon: This item is a coupon, but a coupon_amount has already been set\"\n return\n end\n \n log_action \"apply_coupon: Starting to apply coupons. total before is #{ coitem.total_cents }\"\n \n ctype = self.item.coupon_type\n if ctype == 1\n # percent rebate\n factor = self.price_cents / 100.0 / 100.0\n if self.vendor.net_prices\n coitem.coupon_amount_cents = coitem.net.fractional * factor\n else\n coitem.coupon_amount_cents = coitem.gross.fractional * factor\n end\n log_action \"apply_coupon: Applying Percent rebate coupon: price_cents is #{ self.price_cents }, factor is #{ factor }, coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 2\n # fixed amount\n coitem.coupon_amount_cents = self.price_cents\n log_action \"apply_coupon: Applying Fixed amount coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 3\n # buy x get y free\n log_action \"apply_coupon: Applying B1G1\"\n x = 2\n y = 1\n if coitem.quantity >= x\n if self.vendor.net_prices\n coitem.coupon_amount_cents = y * coitem.net.fractional / coitem.quantity\n else\n coitem.coupon_amount_cents = y * coitem.gross.fractional / coitem.quantity\n end\n log_action \"apply_coupon: Applying B1G1 coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n end\n end\n if self.vendor.net_prices\n coitem.total = coitem.net - coitem.coupon_amount\n else\n # log_action \"XXXXXXXXX #{ coitem.gross.inspect } #{ coitem.coupon_amount.inspect }\"\n coitem.total = coitem.gross - coitem.coupon_amount\n end\n log_action \"apply_coupon: OrderItem Total after coupon applied is: #{coitem.total_cents} and coupon_amount is #{coitem.coupon_amount_cents}\"\n coitem.calculate_tax\n coitem.save!\n else\n self.total -= self.coupon_amount\n end\n end", "def sent_proposals\n reversed_matches = Array.new(@group_size)\n @best_proposals.each_with_index do |e, i|\n reversed_matches[e] = i if e\n end\n reversed_matches\n end" ]
[ "0.7774569", "0.71423966", "0.64846826", "0.64373976", "0.6110704", "0.6079696", "0.59247124", "0.5845418", "0.57443726", "0.56175625", "0.5494148", "0.5487398", "0.54260784", "0.5349717", "0.53291535", "0.5309231", "0.52346736", "0.5227379", "0.52169615", "0.52048796", "0.51724875", "0.51496685", "0.51319927", "0.5105088", "0.50862217", "0.507449", "0.5012797", "0.49674127", "0.4935792", "0.49228218", "0.49085408", "0.4895869", "0.48710638", "0.48648912", "0.48025042", "0.47948772", "0.47815603", "0.47795135", "0.47610524", "0.47591108", "0.4756606", "0.47541624", "0.4753552", "0.47425815", "0.4728185", "0.47276697", "0.4717953", "0.47112995", "0.4707924", "0.4701341", "0.47006607", "0.4695437", "0.46794835", "0.46701786", "0.4662945", "0.46570835", "0.46465793", "0.46447888", "0.46431032", "0.4641361", "0.46372542", "0.4633699", "0.4630016", "0.46264747", "0.46181965", "0.46140838", "0.4597496", "0.45961258", "0.4594012", "0.45937625", "0.4584405", "0.45773298", "0.45739046", "0.45571733", "0.4545379", "0.45402348", "0.4535864", "0.45331696", "0.45299244", "0.45270604", "0.452021", "0.45191416", "0.45150632", "0.45135516", "0.4510309", "0.45051882", "0.45037478", "0.45029318", "0.45027095", "0.44972047", "0.44935188", "0.44932565", "0.44927916", "0.44891974", "0.44857708", "0.44844675", "0.44807613", "0.44772846", "0.44744387", "0.4473" ]
0.6589946
2
Checks for any promotions that have already been applied to the order.
def existing_promotions? !existing_promotions.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def promotions\n @promotions ||= order.promotions\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def reject_promotion_if_no_conjunction\n if Promotion.where( id: BasketItem\n .where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion')\n .pluck(:promotion_id),\n conjunction: false).any? ||\n Promotion.find(@basket_item.promotion_id).conjunction == false &&\n BasketItem.where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion').any?\n flash[:danger] = \"Promotion cannot be used in conjunction with already applied promotions!\"\n @reject = true\n end\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def can_be_used_jointly?\n ids = order.order_promo_codes.collect(&:promo_code_id).uniq\n singular_promo_codes = PromoCode.where(id: ids).where(combined: false)\n # cant use count since that data isnt saved yet and count would fire an query\n if order.order_promo_codes.size > 1 and singular_promo_codes.count > 0\n self.errors.add(:promo_code_id, 'Cant be used with conjuction with other codes') unless self.promo_code.combined\n end\n end", "def can_be_added?(order)\n eligible?(order) &&\n (can_combine?(order) || order.promotion_credits.empty?) &&\n Credit.count(:conditions => {\n :adjustment_source_id => self.id,\n :adjustment_source_type => self.class.name,\n :order_id => order.id\n }) == 0\n end", "def punch_out_order_message?\n !punch_out_order_message.nil?\n end", "def test_cleanup_promotion_order_finished\n # Setup - add promotion and complete order\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n @o.order_status_code = order_status_codes(:ordered_paid_to_ship)\n assert @o.save\n \n # Now expire the promo\n assert promo.update_attributes({\n :start => Date.today - 2.weeks,\n :end => Date.today - 1.week\n })\n promo.reload\n @o.reload\n \n # Update something on the order, like an admin would.\n # Maybe we shipped out the order and changed the status code.\n @o.order_status_code = order_status_codes(:sent_to_fulfillment)\n assert [email protected]_promotion_be_applied?(promo)\n assert @o.save\n \n @o.reload\n \n # Check to see if promotion is still applied (it should be!)\n assert_equal promo, @o.promotion\n assert_kind_of OrderLineItem, @o.promotion_line_item\n end", "def normal_and_standalone_promo?\n # Guard clause to ensure promo code is definitely a standalone promo\n return unless promotion.stand_alone_promo(self[:promotion_id])\n if !promotions.empty? && !promotions.map(&:standalone).include?(true)\n return errors.add(:promotion_id, '..other promo exists!')\n end\n end", "def reject_promotion_if_not_enough_items\n promotion = Promotion.find(@basket_item.promotion_id)\n if !promotion.item_id.nil?\n items_count = BasketItem.where( basket_id: @basket_item.basket_id,\n item_id: promotion.item_id)\n .count\n # count pieces of the item for which promotions already applied\n item_promotions_count = 0\n Promotion.where(item_id: promotion.item_id).each do | p |\n item_promotions_count += BasketItem.where(basket_id: @basket_item.basket_id,\n promotion_id: p.id)\n .count * promotion.item_quantity\n end\n\n if items_count - item_promotions_count < promotion.item_quantity\n flash[:danger] = \"Not enough items in the basket to apply the promotion!\"\n @reject = true\n end\n end\n end", "def needs_promotion?\n !!@promotion_coords\n end", "def checkout\n # assumes that an in_process must have at least one line_item\n # and therefore a basket\n raise \"An in_process order should have a basket.\" unless basket\n\n basket.moderators_or_next_in_line.each do |user|\n UserNotifier.deliver_in_process(self, user)\n end\n\n end", "def eligible?(options = {})\n return unless order = options[:order]\n quantity_ordered = product.variants_including_master.inject(0) do |sum, v|\n sum + order.quantity_of(v)\n end\n quantity_ordered >= preferred_quantity\n end", "def check_product_dependencies\n # Iterate though the products associated to this SO, that are not deleted.\n products.visible.each do |p|\n # throw(:abort) will make the destroy method return false and the controller will know the destroy didn't work.\n throw(:abort) if p.shippingoptions.count == 1\n end\n end", "def ensure_not_referenced_by_any_ordered_item\n if ordered_items.empty?\n return true\n else\n errors.add(:base, \"Ordered items present.\")\n return false\n end\n end", "def new_promotions\n @new_promotions ||= []\n end", "def verify()\n if has_order_items?\n order_template = order_object\n order_template = yield order_object if block_given?\n @virtual_server.softlayer_client[:Product_Order].verifyOrder(order_template)\n end\n end", "def no_proposals_unless_manages_proposals\n return true if manages_proposals or proposals.empty?\n errors.add(:manages_proposals,\n _('This conference already has received %d proposals (%s) - ' +\n 'Cannot specify not to handle them.') %\n [self.proposals.size, self.proposals.map {|p| p.id}.join(', ')])\n end", "def apply\n assign_order_attributes\n assign_payments_attributes\n\n if order.save\n order.set_shipments_cost if order.shipments.any?\n true\n else\n @errors = order.errors\n false\n end\n end", "def unredeemable?\n payment_owed? && !(ProductStrategy === self.order.promotion.strategy) \n end", "def compute_on_promotion?\n @compute_on_promotion ||= calculable.respond_to?(:promotion)\n end", "def unapply\n return return_with(:error, I18n.t('coupon.cannot_remove')) unless unappliable_order?\n return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless reset_order! && reset_coupon!\n return_with(:success)\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def local_clean_new_order(mail)\n local_clean_extract_from_body(mail)\n return false unless @order_number\n logger.info \"Cleanup of #{@order_number}\"\n true\n end", "def test_remove_promotion_multiple_items\n setup_new_order_with_items()\n editable_order_codes = (1..5)\n editable_order_codes.each do |status_id|\n o_status = OrderStatusCode.find(status_id)\n assert_kind_of OrderStatusCode, o_status\n\n @o.order_status_code = o_status\n assert @o.is_editable?\n \n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n assert @o.save\n assert_kind_of OrderLineItem, @o.promotion_line_item\n # Add dupe line item.\n dupe_item = @o.promotion_line_item.clone\n @o.order_line_items << dupe_item\n assert_equal 2, @o.order_line_items.count(\n :conditions => [\"name = ?\", @o.promotion.description]\n )\n # Remove\n @o.remove_promotion()\n assert_nil @o.promotion_line_item\n end\n end", "def can_combine?(order)\n self.combine &&\n order.credits(:join => :adjustment_source).all?{|pc| pc.adjustment_source.combine}\n end", "def on_order?\n !self.paid?\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def available_for_order?(_order)\n true\n end", "def is_under_process?\n #if true then this sub has got orders which are under process(by payment / shipment)\n self.orders.where('(delivery_date <= ? and delivery_date > ?) or (state = ? and payment_state = ?)', ORDER_UPDATE_LIMIT.days.from_now.to_date, Time.now, 'placed', 'paid').present?\n end", "def checkout_allowed?\n order_items.count > 0\n end", "def standalone_promo?\n errors.add(:promotion_id, \"#{unique} exists!\") if !promotions.empty? && promotions.map(&:standalone).include?(true)\n end", "def unappliable_order?\n order.bought? == false\n end", "def reject_promotion_if_basket_empty\n if BasketItem.where(basket_id: @basket_item.basket_id).empty?\n flash[:danger] = \"Basket is empty - promotion cannot be applied!\"\n @reject = true\n end\n end", "def has_order_items?\n @cores != nil || @ram != nil || @max_port_speed != nil\n end", "def valid_order?\n order.coupon.nil? && coupon.cancelled_at.nil?\n end", "def ensure_not_referenced\n if order_items.empty?\n true\n else\n errors.add(:base, 'Line Order present')\n false\n end\n end", "def is_conflict?\n from_json\n (@order && @order.paid?).tap do |x|\n @error = true if x\n end\n end", "def before_delivery\r\n return if params[:order].present?\r\n \r\n if @order.bill_address.address1 == 'dummy_address1' or @order.bill_address.city == 'dummy_city' or @order.bill_address.address2.include? \"CityBox\"\r\n @disable_all_except_citybox = true\r\n end\r\n\r\n packages = @order.shipments.map { |s| s.to_package }\r\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\r\n end", "def already_processed?(transaction)\n transaction['type'] != 'AA'\n end", "def distribute_all_answers_if_none_pending\n # only execute if text changed\n if self.changes.keys.include?(\"text\") && self.changes[\"text\"].first.blank?\n answers = self.question.answers\n if answers.pending.count == 0\n AnswerMailer.all_answers(self.question, answers.pluck(:email)).deliver\n end\n end\n end", "def check_new_actions\n MeritAction.where(:processed => false).each do |merit_action|\n merit_action.check_rules(defined_rules)\n end\n end", "def pending_any_confirmation\n if (!confirmed? || pending_reactivation?)\n yield\n else\n self.errors.add(:phone, :already_confirmed)\n false\n end\n end", "def e_validate_related_orders\n errors.add(:base, I18n.t('plugins.ecommerce.message.not_deletable_product')) if Plugins::Ecommerce::ProductItem.where(product_id: id).any?\n end", "def applicable?\n adjustment_source && adjustment_source.eligible?(order) && super\n end", "def already_notified(order) \r\n @notified_orders_set.include? order[\"order_id\"]\r\nend", "def any_eob_processed?\n self.insurance_payment_eobs.length >= 1\n end", "def process(items)\n found = false\n to_process = items.select {|item| found ||= (item.checksum == self.checksum) }\n to_process.blank? ? to_process = items : to_process.shift\n to_process.each {|entry| store(entry) }\n end", "def capture_pending_payments\n success = true\n order.payments.pending.each do |payment|\n unless payment.capture!\n copy_errors(payment)\n success = false\n end\n end\n success\n end", "def candidates_exist_for_all_forced_changes?\n forced_packages_missing_candidates.empty?\n end", "def capture\n begin \n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # go through all order_payments\n order_payments = self.order_payments\n if order_payments.size == 0\n p \"No order_payments to process.\"\n raise PaymentError, \"No order_payments to process.\"\n end\n for order_payment in order_payments\n order_payment.capture!\n end\n self.upgrade_coupons!\n # update order\n self.update_attributes!(:state => Order::PAID, :paid_at => Time.zone.now)\n end\n # send confirmation email\n user = User.find_by_id(self.user_id)\n if user and user.send_confirmation(self.deal_id)\n return true\n else\n logger.error \"Order.capture: Confirmation email failed to send: #{self.inspect}\"\n return false\n end\n rescue PaymentError => pe\n p \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n rescue ActiveRecord::RecordInvalid => invalid\n p \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end", "def check_for_processor_update(updated_task)\n (self.completed != updated_task.completed ||\n self.cae_model != updated_task.cae_model ||\n self.cad_model != updated_task.cad_model)\n end", "def set_cleanup_reproduction_associations\n @cleanup_reproduction_associations = nil\n if @order.order_type.name == 'reproduction' &&\n params[:order][:order_type_id] != @order.order_type_id\n @cleanup_reproduction_associations = true\n end\n end", "def deliver_store_owner_order_notification_email?\n store.new_order_notifications_email.present? && !store_owner_notification_delivered?\n end", "def positions_not_to_check\n @positions_not_to_check ||= begin\n positions = []\n positions.concat(do_not_check_block_arg_pipes)\n positions.concat(do_not_check_param_default)\n positions.concat(do_not_check_class_lshift_self)\n positions.concat(do_not_check_def_things)\n positions.concat(do_not_check_singleton_operator_defs)\n positions\n end\n end", "def process_coupom\n @orders_csv.each do |oc|\n coupom = @coupons[oc.coupom_id]\n @orders_hash[oc.id].compute(coupom) if coupom && coupom.valid?\n end\n end", "def call_unless_condition \n\t\t\tOrder.where(notification_id: self.id).exists? \n end", "def has_ordered?(item_to_check)\n if item_to_check.class == Item\n @order.any? {|item| item.name == item_to_check.name}\n else \n false\n end \nend", "def check_unattended_orders\n if session.delete(:just_logined) == true && @current_user\n if @current_user.is_merchant\n @unattended_orders = @current_user.products.collect(&:orders).first.\n where(\"(status is null OR status = 1) AND orders.created_at >= ?\", @current_user.last_signed_out_at)\n end\n end\n end", "def promotions\n Spree::Promotion.find_by_sql(\"#{order.promotions.active.to_sql} UNION #{Spree::Promotion.active.where(code: nil, path: nil).to_sql}\")\n connected_order_promotions | sale_promotions\n end", "def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end", "def orders?\n return orders.any?\n end", "def ready_for_merge?(order_detail)\n case order_detail.product\n when Service\n order_detail.valid_service_meta?\n when Instrument\n order_detail.valid_reservation?\n else\n true\n end\n end", "def order?\n !order.nil?\n end", "def remove_quantity_promotions\n if @basket_item.type == \"PurchasingItem\"\n using_promotions_count = UsingPromotion.where(basket_id: @basket_item.basket_id)\n .group(:promotion_id)\n .count\n using_promotions_count.each do | promotion_id, cnt |\n promotion = Promotion.find(promotion_id)\n item_cnt = BasketItem.where(basket_id: @basket_item.basket_id,\n item_id: @basket_item.item_id)\n .count - 1\n if promotion.item_id == @basket_item.item_id &&\n cnt * promotion.item_quantity > item_cnt\n UsingPromotion.where( basket_id: @basket_item.basket_id,\n promotion_id: promotion.id)\n .first\n .destroy\n end\n end\n end\n end", "def products_covered?(dep_prods, man_prods)\n if dep_prods.nil? || man_prods.nil?\n return false\n end\n\n return (dep_prods - man_prods).empty?\n end", "def check_not_applied\n LOCK.synchronize do\n ( hooks.keys - applied ).each do |rkey|\n calls = hooks[ rkey ].map { |blk, clr| clr }\n yield( rkey, calls )\n end\n end\n end", "def probe?\n self.order == -1\n end", "def check_for_too_many_processors(config, hash); end", "def sanitize_and_merge_order(*orders)\n self.class.sanitize_and_merge_order(*orders)\n end", "def test_say_if_is_discounted\n setup_new_order_with_items()\n promo = promotions(:percent_rebate)\n \n assert [email protected]_discounted?\n @order.promotion_code = promo.code\n assert @order.is_discounted?\n end", "def has_confirmed_order?\n confirmed_order = false\n open_orders.each do |o|\n if o.confirmed\n confirmed_order = true\n break\n end\n end\n confirmed_order\n end", "def process_order_payment\n \n return \"No Order Paid Date not found, order NOT PROCESSED\" if self.paid_date.blank?\n return \"No Order Paid Amount not found, order NOT PROCESSED\" if self.paid_amount.blank?\n return \"No Order Ref Name not found, order NOT PROCESSED\" if self.name.blank? \n return \"No Order Ref Id not found, order NOT PROCESSED\" if self.order_master_id.blank? \n \n return \"Paid Amount #{self.paid_amount} is less than ORDER AMOUNT #{self.order_master.grand_total}\" if self.paid_amount.to_i < self.order_master.grand_total.to_i\n \n order_master = OrderMaster.new\n return order_master.process_order self.order_master_id\n \n end", "def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend", "def confirm(args)\n ack_or_nack, delivery_tag, multiple = *args\n loop do\n tag = @unconfirmed.pop(true)\n break if tag == delivery_tag\n next if multiple && tag < delivery_tag\n\n @unconfirmed << tag # requeue\n rescue ThreadError\n break\n end\n return unless @unconfirmed.empty?\n\n ok = ack_or_nack == :ack\n @unconfirmed_empty.push(ok) until @unconfirmed_empty.num_waiting.zero?\n end", "def do_workflow(message)\n raise \"Parameter 'order' is required\" if message[:order].blank?\n order = message[:order]\n incomplete_units = Array.new\n\n order.units.each do |unit|\n # If an order can have both patron and dl-only units (i.e. some units have an intended use of \"Digital Collection Building\")\n # then we have to remove from consideration those units whose intended use is \"Digital Collection Building\"\n # and consider all other units.\n if not unit.intended_use.description == \"Digital Collection Building\"\n if not unit.unit_status == \"canceled\"\n if unit.date_patron_deliverables_ready.nil?\n incomplete_units.push(unit.id)\n end\n end\n end\n end\n\n if incomplete_units.empty?\n if order.date_customer_notified\n # The order appears to have been delivered to the customer already\n on_failure(\"The date_customer_notified field on order #{message[:order_id]} is filled out. The order appears to have been delivered already.\")\n else\n # The 'patron' units within the order are complete\n on_success(\"All units in order #{message[:order_id]} are complete and will now begin the delivery process.\")\n order.update_attribute(:date_patron_deliverables_complete, Time.now)\n QaOrderData.exec_now({ :order => order }, self)\n end\n else\n # Order incomplete. List units incomplete units in message\n on_success(\"Order #{message[:order_id]} is incomplete with units #{incomplete_units.join(\", \")} still unfinished\")\n end\n end", "def matching_products\n # Regression check for #1596\n # Calculator::PerItem can be used in two cases.\n # The first is in a typical promotion, providing a discount per item of a particular item\n # The second is a ShippingMethod, where it applies to an entire order\n #\n # Shipping methods do not have promotions attached, but promotions do\n # Therefore we must check for promotions\n if self.calculable.respond_to?(:promotion)\n self.calculable.promotion.rules.map(&:products).flatten\n end\n end", "def check_current_order\t\n\t\t# TODO: Introduce a proper way to check the order payment status\n\t\t# Currently the order get removed from the session the moment the\n\t\t# spree receives payment and no way of tracking. Might have to introduce\n\t\t# other means of checking for payment receival for orders. A possible\n\t\t# method would be to have session id sent along with IPN secret and\n\t\t# mark a flag on payment notifications after displaying payment received\n\t\t# message\n\t\t# if current_order \\\n\t\t# && current_order.completed? \n\t\t# # && ((current_order.payment_state == \"paid\") or (current_order.payment_state == \"credit_owed\"))\n\t\t# \tflash[:notice] = t(:pp_ws_payment_received)\n\t\t# \t@order = current_order\n\t\t# \tsession[:order_id] = nil\n\n\t\t# \tif current_user\n\t\t# \t\tredirect_to spree.order_path(@order)\n\t\t# \telse\n\t\t# \t\tredirect_to root_path\n\t\t# \tend\n\t\t\t\n\t\t# end\n\tend", "def done?\n @possibles.all? do |ops_modifiers, count|\n count.zero? || !all_ops_modifiers_qualify?(ops_modifiers, count)\n end\n end", "def skip_pub_task_and_post_process_only?\n !pub_options['push_metadata'] && !pub_options['push_files']\n end", "def update_order\n # If there is no adjustment for the current gift package, just create one here unless there already is one for the gift package\n if self.gift_package_id && self.gift_package_id > 0 && self.adjustments.gift_packaging.where(:originator_id => self.gift_package_id).count == 0\n self.gift_package.adjust(self) \n end \n # Then update all adjustments\n self.update_adjustments\n # update the order totals, etc.\n order.update!\n end", "def apply_coupon!(order, coupon)\n CouponHandler.new(nil, order.coupon, order).update_order!\n CouponHandler.new(nil, order.coupon, order).update_coupon!\nend", "def check_process_environments\n unless @_processed_environments\n Environment[].each do |env|\n env.process\n end\n @_processed_environments = true\n end\n end", "def apply_coupon\n if self.behavior == 'coupon'\n item = self.item\n \n # coitem is the OrderItem to which the coupon acts upon\n coitem = self.order.order_items.visible.find_by_sku(item.coupon_applies)\n log_action \"apply_coupon: coitem was not found\" and return if coitem.nil?\n\n unless coitem.coupon_amount.zero? then\n log_action \"apply_coupon: This item is a coupon, but a coupon_amount has already been set\"\n return\n end\n \n log_action \"apply_coupon: Starting to apply coupons. total before is #{ coitem.total_cents }\"\n \n ctype = self.item.coupon_type\n if ctype == 1\n # percent rebate\n factor = self.price_cents / 100.0 / 100.0\n if self.vendor.net_prices\n coitem.coupon_amount_cents = coitem.net.fractional * factor\n else\n coitem.coupon_amount_cents = coitem.gross.fractional * factor\n end\n log_action \"apply_coupon: Applying Percent rebate coupon: price_cents is #{ self.price_cents }, factor is #{ factor }, coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 2\n # fixed amount\n coitem.coupon_amount_cents = self.price_cents\n log_action \"apply_coupon: Applying Fixed amount coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 3\n # buy x get y free\n log_action \"apply_coupon: Applying B1G1\"\n x = 2\n y = 1\n if coitem.quantity >= x\n if self.vendor.net_prices\n coitem.coupon_amount_cents = y * coitem.net.fractional / coitem.quantity\n else\n coitem.coupon_amount_cents = y * coitem.gross.fractional / coitem.quantity\n end\n log_action \"apply_coupon: Applying B1G1 coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n end\n end\n if self.vendor.net_prices\n coitem.total = coitem.net - coitem.coupon_amount\n else\n # log_action \"XXXXXXXXX #{ coitem.gross.inspect } #{ coitem.coupon_amount.inspect }\"\n coitem.total = coitem.gross - coitem.coupon_amount\n end\n log_action \"apply_coupon: OrderItem Total after coupon applied is: #{coitem.total_cents} and coupon_amount is #{coitem.coupon_amount_cents}\"\n coitem.calculate_tax\n coitem.save!\n else\n self.total -= self.coupon_amount\n end\n end", "def check_pickups\n @game_state.pickups.select { |pickup| pickup.collides?(self) }.each do |pickup|\n pickup.apply!(self)\n @game_state.pickups.delete(pickup)\n end\n end", "def expire_associated(order)\n expirable = EXPIRABLE_FIELDS.any? do |key|\n order.changed_attributes.include?(key)\n end\n\n if expirable\n ASSOCIATED_CLASSES.each {|ac|\n publish :purge_cache, ActiveSupport::JSON.encode( {:subject_class => order.class.name, :subject_id => order.id, :associated_class => \"#{ac}\" }) \n }\n end\n end", "def valid_emotion?\n (EMOTIONS - emotion).size != EMOTIONS.size\n # -> any matching pairs\n end" ]
[ "0.66147894", "0.6596519", "0.65890914", "0.65631324", "0.6498255", "0.634031", "0.6302131", "0.62207687", "0.60311466", "0.6003467", "0.5800548", "0.5784076", "0.5779233", "0.57785434", "0.56835026", "0.5454023", "0.5436384", "0.5376852", "0.53672314", "0.5353282", "0.52969384", "0.52518016", "0.5247823", "0.52383894", "0.5234142", "0.5228034", "0.52144647", "0.52144045", "0.5204046", "0.51855445", "0.5158722", "0.51559925", "0.51387864", "0.5127552", "0.5125493", "0.5115073", "0.5112528", "0.5108091", "0.5105747", "0.509964", "0.5087608", "0.5086131", "0.5078419", "0.5075654", "0.50706106", "0.507", "0.5041106", "0.50317025", "0.5026583", "0.5009185", "0.5003898", "0.50022584", "0.49964398", "0.49955827", "0.49950227", "0.49937376", "0.4976039", "0.49667937", "0.4954564", "0.49530175", "0.49498305", "0.4949568", "0.49488443", "0.49447694", "0.49415818", "0.49368936", "0.49345273", "0.49281344", "0.4928032", "0.49221203", "0.4917081", "0.49164993", "0.49033186", "0.490229", "0.4900206", "0.48967445", "0.48874184", "0.4881691", "0.48777238", "0.48757967", "0.48735383", "0.48699564", "0.48527136", "0.4848004", "0.48474783", "0.48275605", "0.4827544", "0.48151958", "0.4795619", "0.47806796", "0.4776979", "0.4770597", "0.47687826", "0.4767896", "0.4765793", "0.4763756", "0.47608867", "0.4760747", "0.4744872", "0.47410545" ]
0.6743173
0
Returns the results from checking promotions.
def promotion_results @promotion_results ||= Promotions::CheckResultCollection.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def result_of_checking; end", "def effects\n results = []\n \n if @difficulty\n results << \"Success\" if result >= @difficulty\n end\n \n @possibilities.each do |poss|\n results.concat(check(poss))\n end\n \n results.compact!\n\n if results.empty?\n results = nil\n end\n results\n end", "def health_check\n ret = {}\n unready = []\n NodeObject.all.each do |node|\n unready << node.name unless node.ready?\n end\n ret[:nodes_not_ready] = unready unless unready.empty?\n failed = Proposal.all.select { |p| p.active? && p.failed? }\n ret[:failed_proposals] = failed.map(&:display_name) unless failed.empty?\n ret\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def health_check\n ret = {}\n unready = []\n # We are ignoring the ceph nodes, as they should already be in crowbar_upgrade state\n NodeObject.find(\"NOT roles:ceph-*\").each do |node|\n unready << node.name unless node.ready?\n end\n ret[:nodes_not_ready] = unready unless unready.empty?\n failed = Proposal.all.select { |p| p.active? && p.failed? }\n ret[:failed_proposals] = failed.map(&:display_name) unless failed.empty?\n ret\n end", "def passed_checks\n self.completeness_checks.inject([]) do |passed, check| \n case check[:check]\n when Proc\n passed << translate_check_details(check) if check[:check].call(self)\n when Symbol\n passed << translate_check_details(check) if self.send check[:check]\n end\n \n passed\n end\n end", "def promotions\n @promotions ||= order.promotions\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def check\n check_results\n .reject { |r| r.length.zero? }\n .map { |r| send_comment r }\n end", "def check_results\n bin = prettier_path\n raise \"prettier is not installed\" unless bin\n return run_check(bin, \".\") unless filtering\n ((git.modified_files - git.deleted_files) + git.added_files)\n .select { |f| f[matching_file_regex] }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", \"\") }\n .map { |f| run_check(bin, f) }\n end", "def result_msg\n msgs = []\n results.each { |re| msgs.push(re[:msg]) unless re[:passed]}\n msgs\n end", "def process_result res\n call = res[-1]\n\n check = check_call call\n\n if check and not @results.include? call\n @results << call\n\n if include_user_input? call[3]\n confidence = CONFIDENCE[:high]\n else\n confidence = CONFIDENCE[:med]\n end\n \n warn :result => res, \n :warning_type => \"Mass Assignment\", \n :message => \"Unprotected mass assignment\",\n :line => call.line,\n :code => call, \n :confidence => confidence\n end\n res\n end", "def check\n each { |m| m.check }\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def checks\r\n checks = []\r\n jobs.each do |job|\r\n checks << job.check_informations.first\r\n end\r\n checks = checks.flatten.compact\r\n end", "def result\n \n if not self.verification_id.nil?\n verification = Diagnostics::Verification.find(self.verification_id)\n assoc_verification = self.exam.scenario.scenarios_verifications.find_by_verification_id(self.verification_id) rescue nil\n message = ((assoc_verification.nil? or assoc_verification.result.empty?) ? verification.result : assoc_verification.result)\n \n elsif not self.identification_id.nil?\n identification = Diagnostics::Identification.find(self.identification_id)\n assoc_identification = self.exam.scenario.scenarios_identifications.find_by_identification_id(self.identification_id) rescue nil\n message = ((assoc_identification.nil? or assoc_identification.result.empty?) ? identification.result : assoc_identification.result)\n \n elsif not self.rectification.nil?\n rectification = Diagnostics::Rectification.find(self.rectification_id)\n assoc_rectification = self.exam.scenario.scenarios_rectifications.find_by_rectification_id(self.rectification_id) rescue nil\n message = ((assoc_rectification.nil? or assoc_rectification.result.empty?) ? rectification.result : assoc_rectification.result)\n \n end\n \n message\n end", "def check_plagiarism(force = false)\n # Get each task...\n return if not active\n\n # need pwd to restore after cding into submission folder (so the files do not have full path)\n pwd = FileUtils.pwd\n\n begin\n logger.info \"Checking plagiarsm for unit #{code} - #{name} (id=#{id})\"\n task_definitions.each do |td|\n next if td.plagiarism_checks.length == 0\n # Is there anything to check?\n\n logger.debug \"Checking plagiarism for #{td.name} (id=#{td.id})\"\n tasks = tasks_for_definition(td)\n tasks_with_files = tasks.select { |t| t.has_pdf }\n if tasks_with_files.count > 1 && (tasks.where(\"tasks.file_uploaded_at > ?\", last_plagarism_scan ).select { |t| t.has_pdf }.count > 0 || force )\n # There are new tasks, check these\n\n logger.debug \"Contacting MOSS for new checks\"\n td.plagiarism_checks.each do |check|\n next if check[\"type\"].nil?\n\n type_data = check[\"type\"].split(\" \")\n next if type_data.nil? or type_data.length != 2 or type_data[0] != \"moss\"\n\n # Create the MossRuby object\n moss = MossRuby.new(Doubtfire::Application.config.moss_key)\n\n # Set options -- the options will already have these default values\n moss.options[:max_matches] = 7\n moss.options[:directory_submission] = true\n moss.options[:show_num_matches] = 500\n moss.options[:experimental_server] = false\n moss.options[:comment] = \"\"\n moss.options[:language] = type_data[1]\n\n tmp_path = File.join( Dir.tmpdir, 'doubtfire', \"check-#{id}-#{td.id}\" )\n\n begin\n # Create a file hash, with the files to be processed\n to_check = MossRuby.empty_file_hash\n add_done_files_for_plagiarism_check_of(td, tmp_path, force, to_check)\n\n FileUtils.chdir(tmp_path)\n\n # Get server to process files\n logger.debug \"Sending to MOSS...\"\n url = moss.check(to_check, lambda { |line| puts line })\n\n td.plagiarism_report_url = url\n td.plagiarism_updated = true\n td.save\n rescue => e\n logger.error \"Failed to check plagiarism for task #{td.name} (id=#{td.id}). Error: #{e.message}\"\n ensure\n FileUtils.chdir(pwd)\n FileUtils.rm_rf tmp_path\n end\n end\n end\n end\n update_student_max_pct_similar()\n self.last_plagarism_scan = DateTime.now\n self.save!\n ensure\n if FileUtils.pwd() != pwd\n FileUtils.chdir(pwd)\n end\n end\n\n self\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def list_processes\n check_connection\n @fields = @protocol.process_info_command\n @result_exist = true\n store_result\n end", "def process_notations\n results = []\n @queries.each { |query| results << Result.new(query, @classifications) }\n results\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def code_promotion_successful?\n promotion_results.code_based.successful?\n end", "def promotions\n adjustments.where( promotion: true )\n end", "def check_all(message, admins, backlog)\n\n\t\tif @plugins.length == 0\n\t\t\treturn []\n\t\tend\n\n\t\tresponse = []\n\n\t\t# this is incredibly inneficient but it makes check_plugin flexible\n\t\[email protected] { |a| response.push(check_plugin(a.name, message, admins, backlog)) }\n\n\t\treturn response\n\tend", "def check\n @checks = [ [@signs[0][0], @signs[1][1], @signs[2][2]], [@signs[0][2], @signs[1][1], @signs[2][0]], @signs[0], @signs[1], @signs[2], @signs.collect{|i| i[0]}, @signs.collect{|i| i[1]}, @signs.collect{|i| i[2]}] \n end", "def passed_checks\n all_checks_which_pass\n end", "def checks; end", "def checkmate(k,a)\n # Checkmate test where king may be: k_attacks - used - king_attaks - cells_behind_the_king\n all = all_position\n p used = [k,a]\n k_attacks = king_position(k).uniq \n a_attacks = (amazon_postion(a) - free_cells(k,a)).uniq\n stand_positions = a_attacks - k_attacks - used\n safe_squares = (all - k_attacks - a_attacks - used).uniq\n ans = stand_positions.reduce([]){ |acc,x| \n if (safe_squares & king_position(x)).empty?\n p x\n acc.push(x) \n end\n acc\n }\n p ans\n ans.size\n \nend", "def results\n @results ||= { ok: [], warning: [], critical: [], unknown: [] }\n end", "def processed_promos\n respond_to do |format|\n @taken_promos = TakenPromo.get_taken_promos_for_user current_user\n format.html { }\n end\n end", "def evaluate!\n eval_start = Time.now\n\n reset\n\n @@checks.each do |name,check|\n @status_code = [check.evaluate!, @status_code].max\n end\n\n @finished = Time.now.utc\n @ms = (Time.now - eval_start) * 1000\n\n if @@checks.size == 0\n @status = :unknown\n @status_code = self.class.valid_status_map[@status]\n else\n @status = self.class.valid_status_map.invert[@status_code]\n end\n end", "def new_promotions\n @new_promotions ||= []\n end", "def check\n megamgw_health\n #megamceph_health\n overall\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def calculate_results\n Repository::Config.new(@repo, @log, @process, @type).status(5) {\n files = files_to_analyze\n puts '-----Files to analyze done (Step 1)'\n files = prepare_files_to_rate files\n puts '-----Prepare files to rate done (Step 2)'\n files = count_total_lines files\n puts '-----Count total lines done (Step 3)'\n files = count_errors files\n puts '-----Count errors done (Step 4)'\n files = grade_categories files\n puts '-----Grade categories done (Step 5)'\n files = grade_files files\n puts '-----Grade files done (Step 6)' + files.to_s\n gpa = grade_repo files\n puts '-----Grade repos done (Step 7)' + gpa.to_s\n gpa_percent = get_overall_grades files\n puts '-----Grade overall percentage done (Step 8)' + gpa_percent.to_s\n cat_issues = get_category_issues files\n puts '-----Get categories issues done (Step 9)' + cat_issues.to_s\n store_cat_issues cat_issues\n puts '-----Store category issues done (Step 10)'\n store_grades gpa, gpa_percent\n puts '-----Store grades done (Step 11)'\n }\n end", "def results(progA, progB); @results[@progs[progA], @progs[progB]]; end", "def process_command(cmd)\n cmd.process(self)\n result = cmd.result()\n \n @@log.debug {\"cmd: #{cmd.class.name}, check_id: #{cmd.check.id}\"}\n\n (@check_results[result.check] = [result] unless\n @check_results[result.check]) or\n @check_results[result.check] << result\n\n process_check_finished_command(cmd) if cmd.class == CheckFinishedCommand\n end", "def check(message)\n lines = send_message(\"CHECK\", message)\n\n result = SaResult.new()\n\n if lines[0].chop =~ /(.+)\\/(.+) (.+) (.+)/\n result.response_version = $2\n result.response_code = $3\n result.response_message = $4\n end\n\n if lines[1].chop =~ /^Spam: (.+) ; (.+) . (.+)$/\n result.score = $2\n result.spam = $1\n result.threshold = $3\n end\n\n return result\n\n end", "def execute\n @checkup = {}\n\n case @publisher\n when 'sql'\n begin\n @d = I2X::SQLDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n when 'csv'\n begin\n @d = I2X::CSVDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n when 'xml'\n begin\n @d = I2X::XMLDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n when 'json'\n begin\n @d = I2X::JSONDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n end\n\n\n # Start checkup\n begin\n unless content.nil? then\n @d.content = content\n end\n @checkup = @d.checkup\n rescue Exception => e\n I2X::Config.log.error(self.class.name) {\"Checkup error: #{e}\"}\n end\n\n # Start detection\n begin\n @d.objects.each do |object|\n @d.detect object\n end\n\n @checkup[:templates] = @d.templates.uniq\n rescue Exception => e\n I2X::Config.log.error(self.class.name) {\"Detection error: #{e}\"}\n end\n\n begin\n if @checkup[:status] == 100 then\n process @checkup\n end\n rescue Exception => e\n I2X::Config.log.error(self.class.name) {\"Process error: #{e}\"}\n end\n response = {:status => @checkup[:status], :message => \"[i2x][Checkup][execute] All OK.\"} \n end", "def calculate_results\n Logger.info \"Probing finished. Calculating results.\"\n calculate_startup_time\n calculate_results_stalling\n calculate_results_switching\n print_results\n # TODO what to do with the results?\n end", "def checks_having_payers\r\n checks = []\r\n jobs.each do |job|\r\n check = job.check_informations.first\r\n checks << check if !check.payer.blank?\r\n end\r\n checks = checks.flatten.compact\r\n end", "def sanity_check_registered_vps\n registered_vps = []\n under_quarantine = []\n ProbeController.issue_to_controller do |controller|\n registered_vps = controller.hosts.clone\n under_quarantine = controller.under_quarantine.clone\n end\n\n if registered_vps.empty?\n Emailer.isolation_warning(\"No VPs are registered with the controller!\").deliver\n elsif Set.new(under_quarantine) == Set.new(registered_vps)\n Emailer.isolation_warning(\"All VPs are quarentined!\").deliver\n end\n\n registered_vps\n end", "def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end", "def check_ins\n check_in_responses\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def box_set_results_for(set_of_boxes)\n set_of_boxes.map { |box| is_there_a_check_on(box) }\nend", "def poisonAllPokemon(event=nil)\n for pkmn in $Trainer.ablePokemonParty\n next if pkmn.hasType?(:POISON) || pkmn.hasType?(:STEEL) ||\n pkmn.hasAbility?(:COMATOSE) || pkmn.hasAbility?(:SHIELDSDOWN) || pkmn.hasAbility?(:IMMUNITY)\n pkmn.status!=0\n pkmn.status = 2\n pkmn.statusCount = 1\n end\nend", "def check_the_check\n self.find_attacks(\"white\")\n self.find_attacks(\"black\")\n self.find_king_in_check\n end", "def check\n \n end", "def check\n \n end", "def matching_products\n if compute_on_promotion?\n calculable.promotion.rules.map do |rule|\n rule.respond_to?(:products) ? rule.products : []\n end.flatten\n end\n end", "def query_snmp(opts=nil)\n self.options = opts unless opts.nil?\n\n exit_code = nil\n exit_message = []\n index = 0\n has_rollup = false\n\n if results_cache.empty?\n debug(\"No results\\n\")\n exit_code = Nagios::UNKNOWN\n exit_message = [\"Invalid SNMP community string specified or snmp is disabled\"]\n else\n\n # concrete subclasses implement checks method\n checks.each do |check|\n unless results = results_cache[check[:name]]\n debug(\"No results for check %s\\n\" % check[:name])\n next\n end\n\n # Loop on possibly multiple lines of output\n results.each_line do |line|\n next unless line =~ check[:response]\n status = $1\n\n # Iterate over the expected return codes from a check.\n # line_exit_code,line_message = check[:codes][status]\n check[:codes].keys.each do |code|\n # Might want to support regex codes.\n # For now add support for 'any' value.\n next unless status == code || code == :any\n\n # Map to a nagios code\n # check[:codes][code] maps to a pair of ( nagios_code, message )\n line_exit_code = check[:codes][code][0]\n\n # Does it matter that index = 0?\n # Yes, currently rollup check must be first\n if index == 0 && check[:rollup]\n # Base the overall exit code only on the first check if it is marked as rollup.\n exit_code = line_exit_code\n exit_message = [\"OK\"] if exit_code == Nagios::OK\n has_rollup = true\n else\n\n # Sub checks only affect the message but not the exit code for rollups\n unless has_rollup\n exit_code = Status.worst_case(line_exit_code, exit_code)\n end\n\n # Only affect the message if not OK\n if exit_code != Nagios::OK && line_exit_code != Nagios::OK\n\n # Here, instead of the message being static, we generalized this\n # to call a custom function by symbol name, sending it the check value.\n # Main application thus far is to blow up a bit string.\n line_exit_message = build_message(check[:codes][code][1], status)\n prefix = \"\"\n\n unless check[:display].nil? || check[:display].empty?\n prefix = \"%s:\" % check[:display]\n end\n unless line_exit_message.empty?\n exit_message << \"%s%s\" % [prefix, line_exit_message]\n end\n end\n\n end\n end\n end\n index += 1\n end\n end\n # In case no checks ran or other pathological\n # cases lead to no assignments\n exit_code ||= Nagios::UNKNOWN\n if exit_message.empty?\n if exit_code == Nagios::OK\n exit_message = \"OK\"\n else\n exit_message = \"Unknown\"\n end\n else\n exit_message = exit_message.uniq.join(\",\")\n end\n\n Status.new(exit_code, exit_message)\n end", "def verificaciones_approved\n return false unless self.verificaciones_valid?\n self.verificaciones_valid.collect { |i|\n i if i['resultado'] != 'RECHAZO'\n }.compact \n end", "def api_promotions_get(params, opts = {})\n data, _status_code, _headers = api_promotions_get_with_http_info(params, opts)\n return data\n end", "def competition_results\n results.select(&:competition_result?)\n end", "def percentage_of_promoters\n calculator.percentage_of_promoters\n end", "def info_checks\n checks.select { |ctx| ctx.respond_to?(:info) }\n end", "def perform_validation(_token, certname, raw_csr)\n results = []\n @log.debug 'validating using multiplexed external executables'\n policy_executables.each do |executable|\n @log.debug \"attempting to validate using #{executable}\"\n results << IO.popen(executable + ' ' + certname.to_s, 'r+') { |obj| obj.puts raw_csr; obj.close_write; obj.read; obj.close; $CHILD_STATUS.to_i }\n @log.debug \"exit code from #{executable}: #{results.last}\"\n end\n bool_results = results.map { |val| val == 0 }\n validate_using_strategy(bool_results)\n end", "def show\n @promotions = @condition.promotions\n @coefficients = @condition.coefficients\n end", "def functional_checks\n checks.select(&:functional?)\n end", "def success_message\n if nagios_mode?\n puts \"OK: All packages match checksums\"\n else\n msg \"metadata_check: ok\"\n end\n end", "def compare\n @unit_numbers = @property.unit_numbers.to_set\n @manager_inspections = @property.manager_inspections.to_a\n @inspections = @property.current_inspections\n \n @current_inspections = []\n @stack = []\n \n @unit_numbers.each do |num|\n in_we_go = @inspections.find_by_unit_number(num) || Inspection.new({unit_number: num})\n @current_inspections << in_we_go\n end\n \n filter = Proc.new do |arr|\n arr.select!{|inspection| @unit_numbers.include? inspection.unit_number }\n end\n\n filter.call @manager_inspections\n \n @unit_numbers.each do |num|\n hereArr = []\n hereArr << num\n hereArr << @current_inspections.shift\n hereArr << @manager_inspections.shift\n\n # collector.call(@current_inspections, num, hereArr)\n # collector.call(@manager_inspections, num, hereArr)\n \n if hereArr[-2][:id] == nil\n hereArr << \"no-inspection\"\n elsif hereArr[-2].eql_manager_inspection(hereArr[-1])\n hereArr << \"matches\"\n else\n hereArr << \"mismatch\"\n end\n \n @stack << hereArr \n end\n \n render \"compare\"\n end", "def verify_all_checks\n \n now = Time.now\n\n self.trim_checklist_for_design_type\n self.design_checks each do | design_check |\n if design_check.check.is_peer_check?\n design_check.auditor_result = 'Verified'\n design_check.auditor_checked_on = now\n end\n if design_check.check.is_self_check?\n design_check.designer_result = 'Verified'\n design_check.designer_checked_on = now\n end\n design_check.save\n end\n\n completed_checks = self.completed_check_count\n self.auditor_completed_checks = completed_checks[:peer]\n self.auditor_complete = true\n self.designer_completed_checks = completed_checks[:self]\n self.designer_complete = true\n self.save\n\n end", "def process_results(results)\n\n if results.length > 5\n return \"More than 5 results, please be more specific.\"\n elsif results.length == 0\n return \"No runs found.\"\n end\n return make_reply(results)\n\nend", "def compute(object)\n return 0, [] if self.preferred_buy_number_of_items_x.blank? or \n self.preferred_buy_number_of_items_x == 0 or\n self.preferred_get_number_of_items_y.blank? or \n self.preferred_get_number_of_items_y == 0 or\n self.preferred_at_z_percent_off.blank? or\n self.preferred_at_z_percent_off == 0\n \n #puts \"Buy #{self.preferred_buy_number_of_items_x} Get #{self.preferred_get_number_of_items_y} at #{self.preferred_at_z_percent_off}% Off\"\n \n save_test = lambda do |calculator, options={}|\n #puts \" save test: #{options[:count] % (self.preferred_buy_number_of_items_x + self.preferred_get_number_of_items_y) >= self.preferred_buy_number_of_items_x}\"\n options[:count] % (self.preferred_buy_number_of_items_x + self.preferred_get_number_of_items_y) >= self.preferred_buy_number_of_items_x\n end\n \n save_value = lambda do |calculator, line_item|\n #puts \" save value: #{calculator.preferred_at_z_percent_off / 100.0 * line_item.price}\"\n calculator.preferred_at_z_percent_off / 100.0 * line_item.price\n end\n \n add_false_items_to_current = lambda do |calculator, line_item|\n true\n end\n \n compute_line_items(object, save_value, linked_object: LineItemPromotionCredit, save_test: save_test, add_false_items_to_current: add_false_items_to_current)\n end", "def release_pr_check\n\n result = CheckResult.new(\"Release PR Check Result\")\n\n ## PR should be sent from `develop` branch\n result.message << \"Head Branch check |\"\n is_from_develop = github.branch_for_head == \"develop\"\n if is_from_develop\n result.message += \":o:\\n\"\n else\n fail \"Please send the PR from `develop` branch.\"\n result.message += \":x:\\n\"\n result.errors += 1\n end\n\n ## PR should be sent to `master` branch\n result.message << \"Base Branch check |\"\n is_to_master = github.branch_for_base == \"master\"\n if is_to_master\n result.message += \":o:\\n\"\n else\n fail \"Please send the PR to `master` branch.\"\n result.message += \":x:\\n\"\n result.errors += 1\n end\n\n ## Release modification check\n release_modification_check_into_result(result)\n\n return result\n\nend", "def scan_for_check\n # determine each pieces' moves\n scan_moves\n\n # locate the kings\n find_kings\n\n # white in check?\n white_in_check\n\n # black in check?\n black_in_check\n end", "def check_p2 operations, vol\n operations.running.each do |op|\n if op.temporary[vol] < 0.4\n return \"There are volumes smaller than 0.4; please use the P2!\"\n end\n end\n end", "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 verificarMensagens\n\t\tputs \"Verificando mensagens enviadas.\"\n\t\tif @im.received_messages?\n\t\t\[email protected]_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\[email protected](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 acquire_check_proposed_code_result\n result_pair = check_proposed_code(@secret_code)\n @iteration_correct_value_and_position = result_pair[0]\n @iteration_correct_value_wrong_position = result_pair[1]\n puts \"Number of correct colors with correct position is: #{@iteration_correct_value_and_position}\"\n puts \"Number of correct colors with wrong position is: #{@iteration_correct_value_wrong_position}\"\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def call_check_multi\n\t\t\t\t$log.debug \"calling: #{$plugin_path}/check_multi -s libexec=#{$plugin_path} -s WARN=#{$warning} -s CRIT=#{$critical} #{$multi_opts} -t 20 -f #{$config_path}/#{@host}_disks.cfg\"\n\t\t\t\tdata = `#{$plugin_path}/check_multi -s libexec=#{$plugin_path} -s WARN=#{$warning} -s CRIT=#{$critical} #{$multi_opts} -t 20 -f #{$config_path}/#{@host}_disks.cfg`\n\t\t\t\t$status = $? >> 8\n\t\t\t\t$log.debug \"return code of check_multi was #{$status}\"\n\t\t\t\treturn data.gsub(\"\\n\", \"<br />\") if $html == true\n\t\t\t\treturn data if $html == false\n\t\tend", "def desired_result\n CodeEvaluator.evaluate(result)\n end", "def index\n @promotions = current_shop_owner.promotions.all\n end", "def get_VerificationStatus()\n \t return @outputs[\"VerificationStatus\"]\n \tend", "def get_VerificationStatus()\n \t return @outputs[\"VerificationStatus\"]\n \tend", "def evaluate_checks\n log.info(\"Evaluating Checks: '#{@config['checks'].length}'\")\n\n @config['checks'].each do |check|\n check_name = check['check']\n check_cfg = check['cfg']\n\n collect_metrics(check_name, check_cfg).each do |metric|\n status = 0\n\n # on service it will come with \"state_required\" flag\n if check_name == 'service'\n # adding defaults in case they are not set\n check_cfg = check_cfg.merge(\n 'state' => 'active',\n 'state_required' => 1\n )\n # giving a service hint by adding it's name\n check_name = \"service_#{check_cfg['name']}\"\n status = equals(metric['value'], check_cfg['state_required'])\n else\n # normal threshold evaluation\n status = evaluate(\n metric['value'],\n check_cfg['warn'],\n check_cfg['crit']\n )\n end\n\n template_variables = metric\n template_variables['cfg'] = check_cfg\n\n append_event(\n \"check_#{check_name}\",\n @tmpl.render(check['check'], template_variables),\n status,\n metric['source']\n )\n end\n end\n end", "def verify_output()\n STDERR.print \"Checking output \"\n expected = IO.popen(%W(ls -1UA #{TARGET_DIR})) {|c| c.read }\n\n [ true, false ].each do |with_std|\n cmd = [ BIN_PATH, \"-p\" ]\n cmd << \"-s\" if with_std\n cmd << TARGET_DIR\n\n output = IO.popen(%W(ls -1UA #{TARGET_DIR})) {|c| c.read }\n if expected != output\n STDERR.puts \" [failed] #{cmd * \" \"}\"\n exit 1\n end\n\n STDERR.print \".\"\n end\n\n STDERR.puts \" OK\"\nend", "def pbAllFainted\n return $Trainer.ablePokemonCount==0\nend", "def pids_from_status_mismatch_by_horizontal\n procedures = Array.new\n\n if @db != nil\n is_ok = false\n\n begin\n stm = @db.prepare( 'SELECT DISTINCT R1.qProcId FROM qryResults As R1, qryResults As R2 WHERE R1.qTestId = R2.qTestId AND R1.qStepId = R2.qStepId AND R1.qStatus != R2.qStatus')\n rs = stm.execute\n\n rs.each do |row|\n procedures.push row['R1.qProcId']\n end\n\n stm.close\n is_ok = true\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an SELECT Procedure IDs by Mismatched Status Code error (#{e.message}).\")\n end\n end\n\n return procedures\n end", "def check_p2 operations, vol\n operations.each do |op| \n if op.temporary[vol] < 0.4\n return \"There are volumes smaller than 0.4; please use the P2!\"\n end\n end\n \"\"\n end", "def process_result\n end", "def check \n @checker.check @program_node\n end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def process(result)\n result\n end", "def perform_checks\n # tests & checks are only meaningful if the input can be varied\n return unless @input_can_change\n @checks.each_with_index do |check, i|\n output, time, error = run_with_benchmark(check[:input])\n @checks[i].merge!({ output: output, time: time, error: error })\n end\n @checks\n end", "def validate()\n validation_errors = []\n @expected_results.each_pair do |key,expected_result|\n result_key = expected_result[\"population_ids\"].dup\n\n reported_result, errors = extract_results_by_ids(expected_result['measure_id'], result_key)\n @reported_results[key] = reported_result\n validation_errors.concat match_calculation_results(expected_result,reported_result)\n end\n\n validation_errors\n end", "def gather_proof\n proof = ''\n begin\n Timeout.timeout(5) do\n proof = ssh_socket.exec!(\"id\\n\").to_s\n if (proof =~ /id=/)\n proof << ssh_socket.exec!(\"uname -a\\n\").to_s\n if (proof =~ /JUNOS /)\n # We're in the SSH shell for a Juniper JunOS, we can pull the version from the cli\n # line 2 is hostname, 3 is model, 4 is the Base OS version\n proof = ssh_socket.exec!(\"cli show version\\n\").split(\"\\n\")[2..4].join(\", \").to_s\n elsif (proof =~ /Linux USG /)\n # Ubiquiti Unifi USG\n proof << ssh_socket.exec!(\"cat /etc/version\\n\").to_s.rstrip\n end\n temp_proof = ssh_socket.exec!(\"grep unifi.version /tmp/system.cfg\\n\").to_s.rstrip\n if (temp_proof =~ /unifi\\.version/)\n proof << temp_proof\n # Ubiquiti Unifi device (non-USG), possibly a switch. Tested on US-24, UAP-nanoHD\n # The /tmp/*.cfg files don't give us device info, however the info command does\n # we dont call it originally since it doesnt say unifi/ubiquiti in it and info\n # is a linux command as well\n proof << ssh_socket.exec!(\"grep board.name /etc/board.info\\n\").to_s.rstrip\n end\n else\n # Cisco IOS\n if proof =~ /Unknown command or computer name/\n proof = ssh_socket.exec!(\"ver\\n\").to_s\n # Juniper ScreenOS\n elsif proof =~ /unknown keyword/\n proof = ssh_socket.exec!(\"get chassis\\n\").to_s\n # Juniper JunOS CLI\n elsif proof =~ /unknown command: id/\n proof = ssh_socket.exec!(\"show version\\n\").split(\"\\n\")[2..4].join(\", \").to_s\n # Brocade CLI\n elsif proof =~ /Invalid input -> id/ || proof =~ /Protocol error, doesn't start with scp\\!/\n proof = ssh_socket.exec!(\"show version\\n\").to_s\n if proof =~ /Version:(?<os_version>.+).+HW: (?<hardware>)/mi\n proof = \"Model: #{hardware}, OS: #{os_version}\"\n end\n # Arista\n elsif proof =~ /% Invalid input at line 1/\n proof = ssh_socket.exec!(\"show version\\n\").split(\"\\n\")[0..1]\n proof = proof.map {|item| item.strip}\n proof = proof.join(\", \").to_s\n # Windows\n elsif proof =~ /is not recognized as an internal or external command/\n proof = ssh_socket.exec!(\"systeminfo\\n\").to_s\n /OS Name:\\s+(?<os_name>.+)$/ =~ proof\n /OS Version:\\s+(?<os_num>.+)$/ =~ proof\n if os_name && os_num\n proof = \"#{os_name.chomp} #{os_num.chomp}\"\n end\n # mikrotik\n elsif proof =~ /bad command name id \\(line 1 column 1\\)/\n proof = ssh_socket.exec!(\"/ system resource print\\n\").to_s\n /platform:\\s+(?<platform>.+)$/ =~ proof\n /board-name:\\s+(?<board>.+)$/ =~ proof\n /version:\\s+(?<version>.+)$/ =~ proof\n if version && platform && board\n proof = \"#{platform.strip} #{board.strip} #{version.strip}\"\n end\n else\n proof << ssh_socket.exec!(\"help\\n?\\n\\n\\n\").to_s\n end\n end\n end\n rescue ::Exception\n end\n proof\n end", "def make_result_info\n gold = 0\n treasures = $game_troop.make_drop_items\n for en_dead in tactics_dead\n if en_dead.actor? or en_dead.hidden?\n # Add amount of gold obtained\n gold += en_dead.gold\n end\n end\n show_gold_gain(gold)\n show_item_gain(treasures)\n end", "def ping()\n\n ip = Resolv.getaddress(@host)\n puts ('ip: ' + ip.inspect).debug if @debug\n valid = pingecho(ip)\n puts ('valid: ' + valid.inspect).debug if @debug \n \n @results[:ping] = if valid then\n a = [valid]\n 4.times {sleep 0.01; a << pingecho(ip)}\n (a.min * 1000).round(3)\n else\n nil\n end\n\n end", "def content_that_affects_verification_results\n if interactions || messages\n cont = {}\n cont[\"interactions\"] = interactions if interactions\n cont[\"messages\"] = messages if messages\n cont[\"pact_specification_version\"] = pact_specification_version if pact_specification_version\n cont\n else\n pact_hash\n end\n end", "def check_puppet_postrun_command\n val = Facter::Core::Execution.exec('puppet config print | grep postrun_command')\n check_value_string(val, 'none')\nend", "def check_all_here\n end", "def check_policies(options = {})\n wss_client = WssAgent::Client.new\n result = wss_client.check_policies(\n WssAgent::Specifications.list(options),\n options\n )\n if result.success?\n WssAgent.logger.debug result.data\n puts result.message\n else\n WssAgent.logger.debug \"check policies errors occur: #{result.status}, message: #{result.message}, data: #{result.data}\"\n ap \"error: #{result.status}/#{result.data}\", color: { string: :red }\n end\n\n result\n end", "def current_promotions\n promotions.where([\"start_on IS NOT NULL AND start_on <= ? AND (end_on >= ? OR end_on IS NULL OR end_on = '')\", Date.today, Date.today]).order(\"start_on\")\n end" ]
[ "0.6750584", "0.620899", "0.5768815", "0.5749897", "0.5721719", "0.5678921", "0.56720024", "0.5670942", "0.5648633", "0.5573138", "0.5554325", "0.5480299", "0.5477295", "0.54757434", "0.5419931", "0.53364265", "0.53291214", "0.5318578", "0.5292041", "0.5289208", "0.5272878", "0.52268", "0.5195173", "0.5191639", "0.5184768", "0.51706606", "0.5163394", "0.5140698", "0.51342547", "0.5121537", "0.5110227", "0.51063156", "0.50911605", "0.5080109", "0.5074763", "0.50698495", "0.5061484", "0.505711", "0.50483644", "0.5047648", "0.50287443", "0.5013345", "0.50041485", "0.49982876", "0.49975988", "0.49931818", "0.49911004", "0.4988114", "0.4979981", "0.49698138", "0.49655268", "0.49655268", "0.49470899", "0.49411207", "0.49290136", "0.49219728", "0.49129024", "0.49118975", "0.49118057", "0.4911357", "0.48972476", "0.4889276", "0.48870474", "0.48725897", "0.48710567", "0.4870591", "0.48538852", "0.48461607", "0.48436204", "0.48425177", "0.4828018", "0.48204902", "0.48158434", "0.47995168", "0.47991857", "0.47937468", "0.4793489", "0.4792824", "0.4792824", "0.47905913", "0.47890335", "0.47888014", "0.47832614", "0.4781626", "0.47770447", "0.47724405", "0.47716743", "0.47716743", "0.47716743", "0.4770648", "0.47702533", "0.476521", "0.4761509", "0.47590283", "0.47587374", "0.47497985", "0.47452202", "0.47443882", "0.47425818", "0.4738627" ]
0.58418167
2
An array of IDs of the promotions that have been applied, used to dump the previous promotion state to session.
def promotion_id_dump pending_promotions.map(&:id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def previous_promotion_ids\n @previous_promotion_ids ||= []\n end", "def promotion_id_dump=(ids)\n @previous_promotion_ids = ids.map(&:to_i)\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def promotions\n @promotions ||= order.promotions\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def new_promotions\n @new_promotions ||= []\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def promotions\n adjustments.where( promotion: true )\n end", "def promotions\n Spree::Promotion.find_by_sql(\"#{order.promotions.active.to_sql} UNION #{Spree::Promotion.active.where(code: nil, path: nil).to_sql}\")\n connected_order_promotions | sale_promotions\n end", "def current_promotions\n promotions.where([\"start_on IS NOT NULL AND start_on <= ? AND (end_on >= ? OR end_on IS NULL OR end_on = '')\", Date.today, Date.today]).order(\"start_on\")\n end", "def promotions\n # Promotion.in(id: user_promotions.pluck(:promotion_id))\n Promotion.where({'id'=> {'$in'=> UserPromotion.pluck(:promotion_id)}, 'end_date'=> {'$gt'=> DateTime.now}, 'start_date'=> {'$lt'=> DateTime.now}})\n end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def index\n @promotions = Promotion.all\n end", "def set_discounts_arr\n cart.discounts.where(kind: 'set').map { |set| set[:product_ids].push(set[:id].to_s + 's') }\n end", "def equivalent_phenotype_ids id\n if @skip_table.has_key?(id)\n skip_ids = @skip_table[id]\n if skip_ids.is_a?(Array)\n skip_ids + [id]\n else\n [skip_ids, id]\n end\n else\n [id]\n end\n end", "def workflow_ids\n approval_access = RBAC::Access.new('workflows', 'approve').process\n approval_access.send(:generate_ids)\n\n Rails.logger.info(\"Approvable workflows: #{approval_access.id_list}\")\n\n approval_access.id_list\n end", "def applied\n @applied ||= []\n end", "def index\n @promotions = current_shop_owner.promotions.all\n end", "def promoted_products\n promoted.is_a?(Product) ? [promoted] : promoted.products.all\n end", "def prisoner_ids\n @prisoner_ids || prisoners.collect{|p| p.id}\n end", "def current_cart_pids\n pids = {}\n\n @gears.each do |gear|\n gear.carts.values.each do |cart|\n Dir.glob(\"#{$home_root}/#{gear.uuid}/#{cart.directory}/{run,pid}/*.pid\") do |pid_file|\n $logger.info(\"Reading pid file #{pid_file} for cart #{cart.name}\")\n pid = IO.read(pid_file).chomp\n proc_name = File.basename(pid_file, \".pid\")\n\n pids[proc_name] = pid\n end\n end\n end\n\n pids\n end", "def current_workflow_processes\n wf_processes = []\n RuoteKit.engine.processes.each do |wfp|\n wf_processes << wfp if wfp.target == self\n end\n\n wf_processes\n end", "def pmids \n @pmids ||= []\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def users\n User.in(id: user_promotions.pluck(:user_id))\n end", "def pids\n return [] unless @pid\n return @component_objects.clone if manifest.content_model == PAGE_CONTENT_MODEL || manifest.content_model == NEWSPAPER_PAGE_CONTENT_MODEL\n return ([ @pid ] + @component_objects.clone)\n end", "def pivotal_tracker_delivered_story_ids\n pivotal_tracker_ids('state:delivered includedone:true')\n end", "def prereq_ids\n return [] unless scoped_course\n scoped_course.prereq_ids\n end", "def workflow_ids\n approval_access = RBAC::Access.new('workflows', 'approve').process\n approval_access.send(:generate_ids)\n\n Rails.logger.info(\"Accessible workflows: #{approval_access.id_list}\")\n\n approval_access.id_list\n end", "def get_ps_pids(pids = [])\n current_pids = session.sys.process.get_processes.keep_if { |p| p['name'].casecmp('powershell.exe').zero? }.map { |p| p['pid'] }\n # Subtract previously known pids\n current_pids = (current_pids - pids).uniq\n current_pids\n end", "def property_ids\n result = Array.new\n self.properties.each do |p|\n result << p.id\n end\n result\n end", "def pids\n @pids ||= {}\n end", "def get_selected_song_ids\n return get_songs_relation.pluck( 'songs.id' )\n end", "def processed_items\n @processed.to_a\n end", "def ids_to_accept\n git_log_delivered_story_ids & pivotal_tracker_delivered_story_ids\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def player_ids\n\t\tmy_ids = []\n\t\tplayers.each { |player|\n\t\t\tmy_ids << player.id\n\t\t}\n\t\treturn my_ids\n\tend", "def product_ids\n new_record? ? (@products_cache ? @products_cache.map(&:id) : []) : self.products.map(&:id)\n end", "def taken_menu_items\n menu_items.map {|menu_item| menu_item.id if menu_item.dish_assignment}.compact\n end", "def pivotal_ids\n options[:pivotal_ids] || []\n end", "def mastered_weapon_proficiencies\n self.weapon_categories.map(&:common_weapons).flatten.map(&:id) + self.common_weapons.map(&:id)\n end", "def upserted_ids\n @results[UPSERTED_IDS] || []\n end", "def operator_ids\n @operator_ids ||= extract_operator_ids\n end", "def index\n @cpanel_promotions = Cpanel::Promotion.all\n end", "def approver_request_ids\n Request.where(:workflow_id => workflow_ids).pluck(:id).sort\n end", "def approver_request_ids\n Request.where(:workflow_id => workflow_ids).pluck(:id).sort\n end", "def index\n @product_promotions = ProductPromotion.all\n end", "def get_undelivered_order_ids\n\n #enable this one for previous restricted conditioned(pause/resume)\n #orders =self.orders.select('id, delivery_date').where('spree_orders.delivery_date > ?', Time.now).limit(3)\n orders = self.orders.select('id, delivery_date').where('spree_orders.state in (?) ', ['confirm', 'placed']).limit(3)\n\n order_ids = {}\n\n orders.each_with_index do |order, index|\n order_ids.merge!(index => order.id)\n end\n\n order_ids\n end", "def inserted_ids\n @results[INSERTED_IDS]\n end", "def matching_products\n if compute_on_promotion?\n calculable.promotion.rules.map do |rule|\n rule.respond_to?(:products) ? rule.products : []\n end.flatten\n end\n end", "def current_parties_ids\n current_cites_additions.map(&:party_id).compact.uniq\n end", "def resolved_ids\n return get_and_remove_done(@resolvers).map(&:id)\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def current_opponent_effect_descriptors\n []\n end", "def assign_prisoners\n if @prisoner_ids\n\n new_ids = @prisoner_ids\n old_ids = prisoners.collect{|p| p.id}\n ids_to_delete = old_ids - (old_ids & new_ids)\n ids_to_add = new_ids - (old_ids & new_ids)\n\n game_id = id\n \n ids_to_delete.each do |prisoner_id|\n GamePrisoner.destroy_all(:game_id => game_id, :prisoner_id => prisoner_id)\n end\n\n ids_to_add.each do |prisoner_id|\n GamePrisoner.create(:game_id => game_id, :prisoner_id => prisoner_id)\n end\n end\n end", "def list_pids\n access_processes do |processes|\n processes.keys\n end\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def get_promotions_list\n # get params for paging\n unless params[:id].blank?\n @client_id = params[:id]\n else\n @client_id = @clients[0].id\n end\n\n rows = Array.new\n rows = get_rows(Promotion.get_by_client(@client_id).active.\n order_id_desc.page(params[:page]).per(params[:rp]), @client_id)\n count = Promotion.get_by_client(@client_id).active.order_by_promotion_name.count\n\n render json: {page: params[:page], total: count, rows: rows}\n end", "def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end", "def pids\n @pids ||= @lines.keys\n end", "def sent_proposals\n reversed_matches = Array.new(@group_size)\n @best_proposals.each_with_index do |e, i|\n reversed_matches[e] = i if e\n end\n reversed_matches\n end", "def extra_discounts_arr\n extras = cart.discounts.where(kind: 'extra').map do |extra|\n extra[:product_ids].each_slice(1).map { |e| (e * extra[:count]).push(extra[:id].to_s + 'e') }\n end\n extras.flatten(1)\n end", "def create_many\n ids = []\n promotions_errors = []\n promotionable_ids = params.require(:promotionable_ids)\n promotionable_type = promotion_params[:promotionable_type]\n promotionable_ids.each do |id|\n promotion = Promotion.where(promotionable_id: id, promotionable_type: promotionable_type).first\n if promotion.blank?\n promotion = Promotion.new(promotionable_id: id, promotionable_type: promotionable_type)\n unless promotion.save\n promotions_errors << promotion.errors\n end\n end\n ids << promotion.id\n end\n @promotions = Promotion.find(ids)\n respond_to do |format|\n unless promotions_errors.count > 0\n format.json { render :index, status: :created, location: promotions_url }\n else\n format.json { render json: promotions_errors, status: :unprocessable_entity }\n end\n end\n end", "def count_of_procedures_through_steps\n self.steps.map{|step| Procedure.unarchived.find_by_id(step.procedure_id)}.compact.uniq.count\n end", "def active_vendors_ids\n @active_vendors_ids ||= flatten_calls.collect { |c| c[:vendor_acc_id] }.uniq\n end", "def did_not_submit_ids\n @did_not_submit.map(&:id)\n end", "def workflow_ids\n AccessControlEntry.where(:aceable_type => 'Workflow', :permission => 'approve', :group_uuid => assigned_group_refs).pluck(:aceable_id)\n end", "def available_ids\n %w(bounce deliver drop spam unsubscribe click open).map(&:to_sym)\n end", "def ids\n @ids ||= []\n end", "def new_puzzle_ids\n\t\t@puzzle_ids - @puzzle_packet_ids\n\tend", "def promotion_item(promotions)\n promotions.first['barcodes']\n end", "def favorite_ids\n @favorite_ids ||= user_favorites.pluck(:job_id).to_set\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def preload_preferred_identifiers\n @constellation.EntityType.map{|k, et| et.preferred_identifier }\n end", "def profils()\n return @profils\n end", "def promoter_shows\n Show.where(promoter_id: id)\n end", "def discount_ids\n discount_sources.map { |att| send(att) }\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def source_affects\n return @source_affects.to_a\n end", "def uniq_pep_sequences\n unless self.peptide_evidences.empty?\n return self.peptide_evidences.map{|pep_ev| pep_ev.peptide_sequence.sequence}.uniq\n end\n end", "def product_ids\n new_record? ? (@products ? @products.map(&:id) : []) : self.root.products.map(&:id)\n end", "def awaiting_confirmation\n @awaiting_confirmation ||= []\n end", "def build_promotion_codes\n codes.map do |code|\n promotion.codes.build(value: code)\n end\n end", "def destroy_many\n promotionable_ids = params.require(:promotionable_ids)\n promotionable_type = promotion_params[:promotionable_type]\n @promotions = Promotion.where(promotionable_id: promotionable_ids, promotionable_type: promotionable_type)\n @promotions.destroy_all\n respond_to do |format|\n format.html { redirect_to after_destroy_path, notice: 'Promotions where successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def visible_request_ids_for_approver\n visible_states = [ApprovalStates::NOTIFIED_STATE, ApprovalStates::COMPLETED_STATE]\n Request.where(:workflow_id => workflow_ids, :state => visible_states).pluck(:id)\n end", "def worker_pids\n work_units.all(:select => 'worker_pid').map(&:worker_pid)\n end", "def reproduction(selected_to_breed)\n offsprings = []\n 0.upto(selected_to_breed.length/2-1) do |i|\n offsprings << Chromosome.reproduce(selected_to_breed[2*i], selected_to_breed[2*i+1])\n end\n offsprings.flatten! #reproduce is returning an array with 2 children\n @population.each do |individual|\n Chromosome.mutate(individual)\n end\n return offsprings\n end", "def opponent_effect_sources\n []\n end", "def reproduction(selected_to_breed)\n offsprings = []\n 0.upto(selected_to_breed.length/2-1) do |i|\n offsprings << @chromosomeClass.reproduce(selected_to_breed[2*i], selected_to_breed[2*i+1])\n end\n @population.each do |individual|\n @chromosomeClass.mutate(individual)\n end\n return offsprings\n end", "def qing_ids\n questionings.collect{|qing| qing.id}\n end", "def to_similarity_ids\n @to_similarity_ids ||= similarities.map(&:id)\n end", "def all_processes\n `ps -eo pid,ppid`.lines.reduce(Hash.new []) do |hash, line|\n pid, ppid = line.split.map(&:to_i)\n hash[ppid] = [] unless hash.key?(ppid)\n hash[ppid] << pid\n hash\n end\n end", "def calculated_permutations\n permutations = model.analyzed_callbacks.inject([]) do |results, (key, analyzed_callbacks)|\n results << 2 ** number_of_unique_conditionals(analyzed_callbacks)\n end.sum - number_of_unique_conditionals(model.analyzed_callbacks_array)\n end", "def replicant_id\n [self.class.name, id]\n end", "def procs\n @procs\n end", "def ids\n pluck(:id)\n end", "def pending_refund_payments_projects\n pending_refund_payments.map(&:project)\n end" ]
[ "0.69574535", "0.6845519", "0.6559235", "0.6446942", "0.64211804", "0.64093024", "0.63725805", "0.6210528", "0.60376173", "0.5691419", "0.56717986", "0.56485", "0.55175287", "0.55175287", "0.55175287", "0.5483183", "0.546651", "0.54416454", "0.54339087", "0.54246724", "0.5387887", "0.5387169", "0.5375718", "0.53454024", "0.5317677", "0.5285216", "0.5281056", "0.5241888", "0.52198374", "0.5215802", "0.5210964", "0.5191734", "0.51836795", "0.51692593", "0.5155511", "0.51490456", "0.51259696", "0.5107649", "0.50996304", "0.5097559", "0.50927585", "0.5069358", "0.506477", "0.5050566", "0.5037627", "0.5027142", "0.5011189", "0.5011189", "0.5006847", "0.5005807", "0.49904722", "0.49875805", "0.49619654", "0.49589908", "0.4951035", "0.4944017", "0.49421078", "0.49358276", "0.49233648", "0.49102753", "0.49031526", "0.4899795", "0.48986816", "0.48942158", "0.48918527", "0.4891084", "0.48909467", "0.48767072", "0.48480505", "0.4846819", "0.484362", "0.48395738", "0.48276207", "0.4827328", "0.48231152", "0.4822673", "0.48226607", "0.48224336", "0.48153755", "0.48081037", "0.48081037", "0.48024994", "0.47932488", "0.47930464", "0.4778525", "0.47650638", "0.47645974", "0.47638363", "0.47519365", "0.47479934", "0.47457454", "0.47358942", "0.47312978", "0.4723499", "0.47196934", "0.47180414", "0.4709403", "0.47082114", "0.47053662", "0.47028533" ]
0.71284246
0
When loading up an order from session, this accessor is used to cache the previous promotion state:
def promotion_id_dump=(ids) @previous_promotion_ids = ids.map(&:to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_order\n @current_order ||= load_order_from_session unless @current_order == false\n end", "def store!\n session['order'] = unpromoted_order.dump\n end", "def unpromoted_order\n @unpromoted_order ||= if session['order']\n OrderBasket.load(session['order'])\n else\n OrderBasket.new\n end\n end", "def order\n @order ||= if session['order']\n OrderBasket.load(session['order']).tap(&:apply_promotions!)\n else\n OrderBasket.new\n end\n end", "def order\n @order ||= Order.find_by(id: session[:order_id]) if session[:order_id]\n end", "def load_order\n\t\tparams[:order_param] ||= session[:order_param]\n\t\tsession[:order_param] = params[:order_param]\n\tend", "def current_order=(new_order)\n session[order_session_param] = new_order ? new_order.id : nil\n @current_order = new_order || false\n end", "def set_order\n @order = Order.find(session[:order_id])\n end", "def set_order\n @order = Order.find(session[:order_id])\n end", "def set_order\n @order = current_order\n\n if @order.new_record?\n @order.save!\n session[:order_id] = @order.id\n end\n end", "def simple_current_order\n @order ||= Spree::Order.find_by(id: session[:order_id], currency: current_currency)\n end", "def current_order\n if session[:order_id]\n Order.find(session[:order_id])\n else\n Order.new\n end\n end", "def current_order\n if session[:order_id]\n Order.find(session[:order_id])\n else\n Order.new\n end\n end", "def show\n #respond_with @order if stale? @order # another method of caching\n fresh_when @order\n end", "def transfer_order_items_from_previous_session\n if session[:cart_id].present? && Cart.find_by(id: session[:cart_id]).order_items.present?\n \n @cart = Cart.first_or_create(user_id: current_user.id)\n \n #we iterate through order_items of the cart which was in previous session, \n #and we add order items to our current_user cart (if order_item is present \n #in current_user cart then we update quantity of that order_item)\n #debugger\n Cart.find_by(id: session[:cart_id]).order_items.each do |order_item|\n if @cart.order_items.find_by(product_id: order_item.product_id).present?\n\n @cart.order_items.find_by(product_id: order_item.product_id).update_attributes(quantity: @cart.order_items.find_by(product_id: order_item.product_id).quantity + order_item.quantity)\n \n else\n \n order_item.update_attributes(cart_id: @cart.id)\n end \n end\n session[:cart_id] = @cart.id\n end\n end", "def current_order\n current_customer.incomplete_order\n end", "def simple_current_order\n return @simple_current_order if @simple_current_order\n\n @simple_current_order = find_order_by_token_or_user\n\n if @simple_current_order\n @simple_current_order.last_ip_address = ip_address\n return @simple_current_order\n else\n @simple_current_order = current_store.orders.new\n end\n end", "def customer_order\n @customer_order\n end", "def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end", "def current_order\n @current_order ||= Order.find_by(id: user_id)\n end", "def order\n @order ||= Glysellin::Order.where(id: order_id).first\n end", "def current_order\n \torders = self.orders\n \t@current_order = nil\n \tfor order in orders\n \t\t@current_order = order if order.current?\n \tend\n \t\n \tif @current_order == nil\n \t\t@current_order = self.orders.create\n \t\t@current_order.current = true\n \t\t@current_order.save\n \tend\n \t@current_order\n end", "def order_session_param\n :order_id\n end", "def set_order\n @order = Order.find(params[:id])\n OrderStateMgr.instance(self).set_curr_state(@order)\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def active_order_id\n last_transition ? last_transition.order_id : nil\n end", "def get_promo_code order\n order ? order[:promo_code] ? order[:promo_code] : nil : nil\n end", "def edit\n@order = current_order || Order.incomplete.find_or_initialize_by(guest_token: cookies.signed[:guest_token])\nassociate_user\nend", "def previous_promotion_ids\n @previous_promotion_ids ||= []\n end", "def active_promotion\n @active_promotion ||= OpenStruct.new(credit: 100.00)\n end", "def store_order_details(order)\n details = {}\n stored_attributes.each do |attribute|\n details[attribute.to_sym] = order.try(attribute)\n end\n cookies.permanent[\"last_#{order.class.name.underscore}_details\"] = ActiveSupport::JSON.encode(details)\n end", "def checkout \n \t@order_items = current_order.order_items\n end", "def current_order(create_order_if_necessary = false)\n return @current_order if @current_order\n if session[:order_id]\n @current_order = Spree::Order.find_by_id(session[:order_id], :include => :adjustments)\n end\n if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)\n @current_order = Spree::Order.new\n before_save_new_order\n @current_order.save!\n after_save_new_order\n end\n session[:order_id] = @current_order ? @current_order.id : nil\n @current_order\n end", "def set_authed_order\n @order = current_user.orders.find(params[:id])\n end", "def set_order\n @order = Order::Preorder.find(params[:id])\n end", "def current_order(options = {})\n options[:create_order_if_necessary] ||= false\n options[:lock] ||= false\n\n return @current_order if @current_order\n\n if session[:order_id]\n current_order = Spree::Order.includes(:adjustments).lock(options[:lock]).find_by(id: session[:order_id], currency: current_currency)\n @current_order = current_order unless current_order.try(:completed?)\n end\n\n if options[:create_order_if_necessary] and (@current_order.nil? or @current_order.completed?)\n @current_order = Spree::Order.new(currency: current_currency)\n @current_order.user ||= try_spree_current_user\n # See issue #3346 for reasons why this line is here\n @current_order.created_by ||= try_spree_current_user\n @current_order.save!\n\n # make sure the user has permission to access the order (if they are a guest)\n if try_spree_current_user.nil?\n session[:access_token] = @current_order.token\n end\n end\n\n if @current_order\n @current_order.last_ip_address = ip_address\n session[:order_id] = @current_order.id\n return @current_order\n end\n end", "def load_cart_from_session\n #--- leave due to YAML bug\n CartLineItem\n Product\n #--- end leave due to YAML bug\n persisted_cart = YAML.load(session[cart_session_param].to_s)\n # rebuild cart as persisted cart line items cannot be saved\n persisted_cart.line_items.each_with_index do |line_item, index|\n persisted_cart.line_items[index] = line_item.clone\n end if persisted_cart\n self.current_cart = persisted_cart\n end", "def original_transaction\n\t\t\t\t@original_transaction ||= Purchase.find(self.original_transaction_id)\n\t\t\tend", "def state\n \n session[ flow_session_name ].fetch( state_session_name )\n \n end", "def confirmation\n @order = Order.find_by(id: session[:order_id])\n @order.assign_attributes(order_update_params[:order])\n\n #updates status if shipping info exists(after order confirmation)\n @order.assign_attributes(order_state: \"paid\") if params[:order][:carrier_code] != nil\n\n if @order.save\n reset_cart\n render :order_confirmation\n else\n @user = User.find_by(id: session[:user_id])\n render :shipping\n end\n end", "def promote_cached(**options)\n promote(**options) if promote?\n end", "def promotion\n @promotion ||= Interface::Promotion.new(self)\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def order_upgrade\n @order.next\n @order.complete!\n # Since we dont rely on state machine callback, we just explicitly call this method for spree_store_credits\n if @order.respond_to?(:consume_users_credit, true)\n @order.send(:consume_users_credit)\n end\n @order.finalize!\n end", "def inherit!(order)\n self.bill_address ||= order.bill_address\n self.ship_address ||= order.ship_address\n self.payment ||= order.payment\n self.shipments = order.shipments if shipments.empty?\n\n stated?(order.state) ? save! : next_state!\n end", "def original_order\n end", "def update\n if @order.completed?\n process_and_add_store_credit(@order)\n end\n\n return orig_update\n end", "def order\n # Or equals is used so that if an order has been assigned previously, return that instance (find) but if it\n # is nil, we create one in the database on the token. \n @order ||= Order.find_or_create_by(token: @token) do |order|\n order.sub_total = 0\n end\n end", "def promotions\n @promotions ||= order.promotions\n end", "def setup_order\n @user = current_user\n country_short = current_user.account.country_short\n total_amount = 0\n promotion_code = false\n @price_plan = false\n\n if params[:promotion_code] && params[:price_plan_id]\n country = Country.where(short: country_short).first\n @price_plan = country.price_plans.find(params[:price_plan_id])\n\n if params[:promotion_code].present?\n code = params[:promotion_code].upcase\n promotion_code = @price_plan.promotion_codes.where(code: code).first\n end\n\n if promotion_code.nil?\n @price_plans = Country.get_paid_plans_for_country(current_user.account.country_short)\n @no_promotion_code = true\n @order = Order.new(\n upgrade: params[:upgrade],\n renewal: params[:renewal]\n )\n\n return render(action: 'upgrade', layout: 'registration') if params[:upgrade] == \"true\"\n return render(action: 'renew', layout: 'registration') if params[:renewal] == \"true\"\n return render(layout: 'registration')\n else\n\n if params[:promotion_code].blank?\n promotion_code = nil\n end\n\n base_price = params[:renewal] == \"true\" ? renew_or_base_price(@user, @price_plan) : @price_plan.base_price\n total_amount = promotion_code ? promotion_code.discounted_price.to_f : base_price\n\n if @price_plan.country.paypal_email.blank?\n express_subject = Rails.application.config.paypal_options[:subject]\n else\n express_subject = @price_plan.country.paypal_email\n end\n\n @order = Order.create!(\n price_plan_id: @price_plan.id,\n currency: @price_plan.country.currency,\n total_amount: total_amount,\n promotion_code: promotion_code.nil? ? nil : promotion_code.code,\n upgrade: params[:upgrade],\n renewal: params[:renewal],\n state: 'started',\n ip_address: request.remote_ip,\n country_short: @user.account.country_short,\n order_number: Order.make_order_number(@price_plan.country.short),\n express_subject: express_subject,\n user_id: @user.id\n )\n\n redirect_to payment_options_url(@order)\n end\n end\n end", "def current_shopping_cart\n Order.where(user_id: current_user.id, complete: false).first_or_create\n end", "def complete_order_step(order, order_step)\n original_state = order.state\n order.state = order_step\n\n if !order.next\n order.state = original_state\n order.save(validate: false) # store data from paypal. user will be redirect to 'personal' tab\n end\n end", "def remove_from_old_order\n coupon.orders&.first&.update(\n coupon_discount: 0,\n coupon_applied_at: nil,\n coupon_id: nil\n )\n end", "def current_cart\n session[:cart] ||= []\n end", "def current_reorder\n inventory_reorders.active.first\n end", "def after_complete\n session[:order_id] = nil\n end", "def after_complete\n session[:order_id] = nil\n end", "def after_complete\n session[:order_id] = nil\n end", "def create\n @order = Order.new(order_params)\n @order.user_id = current_user.id if @order.user_id == 0\n @order.price = @order.product.price\n another_order = current_user.orders.in_cart.where(product_id: @order.product_id).first\n logger.debug(\"----------------#{@order.price}..........\")\n if another_order\n another_order.quantity += @order.quantity\n another_order.price += (@order.quantity*@order.price)\n logger.debug(\"----------------#{@order.price}..........\")\n @order = another_order\n end\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t('Order was successfully created') }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_order_info\n @order_info = OrderInfo.where(id: params[:id]).first\n @order_info ||= OrderInfo.find_by!(enc_id: params[:id])\n end", "def cart\n session[:cart] ||= []\n end", "def cart\n session[:cart] ||= []\n end", "def cart\n session[:cart] ||= []\n end", "def cart\n session[:cart] ||= []\n end", "def set_promoted(promoted)\n @promoted = promoted\n @movetype = :promotion\n end", "def auto_dispute_order_details\n nil\n end", "def current_cart\r\n\r\n #session[:cart_id] = nil\r\n\r\n if session[:cart_id]\r\n @current_cart ||= Cart.find(session[:cart_id])\r\n session[:cart_id] = nil if @current_cart.purchased_at\r\n end\r\n if session[:cart_id].nil?\r\n @current_cart = Cart.create!\r\n session[:cart_id] = @current_cart.id\r\n end\r\n @current_cart\r\n end", "def create\n @order.attributes = order_params\n if !session[:promocode_id].nil?\n @order.promocode_id = session[:promocode_id]\n end\n\n respond_to do |format|\n if @order.save\n session[:order_id] = @order.id\n format.html { redirect_to new_charge_path}\n #format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def current_order(options = {})\n options[:create_order_if_necessary] ||= false\n options[:includes] ||= true\n\n if @current_order\n @current_order.last_ip_address = ip_address\n return @current_order\n end\n\n @current_order = find_order_by_token_or_user(options, true)\n\n if options[:create_order_if_necessary] && (@current_order.nil? || @current_order.completed?)\n @current_order = current_store.orders.create!(current_order_params)\n @current_order.associate_user! try_spree_current_user if try_spree_current_user\n @current_order.last_ip_address = ip_address\n end\n\n @current_order\n end", "def set_promotion\n @promotion = current_shop_owner.promotions.find(params[:id])\n end", "def set_order\n @order = ShopOrder.find(params[:id])\n end", "def find_order \n unless session[:order_id].blank?\n @order = Order.find_or_create_by_id(session[:order_id])\n else \n @order = Order.create\n end\n session[:order_id] = @order.id\n @order\n end", "def order\n return @order\n end", "def cart_op\n session[:cart] = yield(get_cart)\n end", "def test_order\n @@test_orders[self] || AVAILABLE_ORDERS.first\n end", "def determine_state(order)\n return 'pending' if self.inventory_units.any? { |unit| unit.backordered? }\n return 'shipped' if state == 'shipped'\n return 'delivered' if state == 'delivered'\n # Original, that resulted in emails being delivered several times:\n # order.payment_state == 'balance_due' ? 'pending' : 'ready'\n # Updated version that should prevent that from happening:\n order.payment_state == 'balance_due' ? 'pending' : 'ready'\n \n end", "def edit\r\n @order = current_order(true)\r\n end", "def cache_delivery_pricing!\n cache_delivery_pricing\n save!\n end", "def order\n @order ||= Elong::API::GHotel::Order.new(@client)\n end", "def show\n @order = Cache.get 'order_' + params[:id].to_s\n unless @order\n @order = Order.find(params[:id])\n Cache.put 'order_' + params[:id].to_s, @order\n end\n redirect_to :controller => :sessions, :action => :new and return unless @order.user == current_user\n @products = Cache.get 'order_' + @order.id.to_s + '_products'\n unless @products\n @products = @order.products\n Cache.put 'order_' + @order.id.to_s + '_products', @products\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @order }\n end\n end", "def set_to_ordered\n self.status = \"ordered\"\n self.save\n end", "def recalculate(order)\n order.respond_to?(:recalculate) ? order.recalculate : order.update!\n end", "def after_update(order)\n expire(order)\n expire_associated(order)\n end", "def cart\n # x ||= y this means x || x = y so if x is nil or false set x to be the value of y.\n #session[:cart] ||= [] # if session[:cart].nil? than set session[:cart] = []\n if session[:cart].nil? \n session[:cart] = []\n else \n session[:cart]\n end\n \n end", "def build_order\n @order ||= ManagementCenter::Order.new\n end", "def cart\n #cart is the session cart or equal to an empty array\n session[:cart] ||= []\n end", "def load_previous_provisions\n @ciservice.provisionings = @data_store.transaction { @data_store.fetch(:provisionings, @ciservice.provisionings) }\n end", "def set_order\n @cart = current_cart\n @order = Order.find(params[:id])\n @orders = Order.where(\"cart_id=? AND id<>?\", @cart.id, params[:id])\n end", "def restore #:nodoc:#\n @session_data = Cachetastic::Caches::RailsSessionCache.get(@session_key) do\n {}\n end\n end", "def show\n @order = Order.find(params[:id])\n session[:change_status] = @order\n unless session[:order_new].nil?\n @order_new=session[:order_new]\n session[:order_new] = nil\n else\n @order_new = Order.new\n @order.order_details.each do |p|\n product_var = @order_new.order_details.build\n product_var.product_id = p.product_id\n product_var.quantity = p.quantity\n end\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end", "def order\n @order ||= Order.find_or_initialize_by(token: @token) do |order|\n order.sub_total = 0\n end\n end", "def order_state(order)\n state = order.state.present? ? order.state : 'pending'\n t(\"order_states.#{state}\")\n end", "def cart\n cart = super\n if cart.nil?\n cart = Cart.new\n\n self.cart = cart\n self.save!\n else\n # TODO: Refactor out this duration to a class variable\n if cart.updated_at < DateTime.now - 12.hours\n cart.clear!\n end\n end\n\n cart\n end", "def order\n @order ||= detect_order(params[:order]) || default_order\n end", "def current_basket\n @current_basket = current_basket_or_nil\n if @current_basket.nil?\n @current_basket = Basket.new(:kori_type => \"Order\")\n @current_basket.save!\n session[:current_basket] = @current_basket.id\n end\n @current_basket\n end", "def logging_in\n guest_order = guest_user.current_order_in_progress\n current_order = current_user.current_order_in_progress\n current_order.merge guest_order\n end", "def after_save_new_order\n end", "def current_cart\n @current_cart ||= load_cart_from_session unless @current_cart == false\n end", "def after_complete\n #remove the order from the session\n session[:order_id] = nil\n\n #add the order access token to the session so user can see thank you window\n #and order status, all through the orders controller.\n session[:access_token] ||= @order.token\n\n # trigger the photo copy and preparation, this is done here because normal state machine transitions\n # happen in a transaction and could allow resque work to begin too soon. See comment in order_decorator.rb\n @order.prepare!\n\n if current_user\n # If a user is looged in, save addresses and creditcard as default\n # Backup order addresses with addresses that cannot be modified by user.\n # creditcards are non editable just erasable.\n #(no need to do this for guests)\n original_ship = @order.ship_address\n original_bill = @order.bill_address\n\n new_ship = Address.create( original_ship.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n @order.ship_address_id = new_ship.id\n if original_ship.id == original_bill.id\n @order.bill_address_id = new_ship.id\n else\n if original_ship.same_as?( original_bill )\n @order.bill_address.id = new_ship.id\n else\n @order.bill_address = Address.create( original_bill.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n end\n end\n @order.save\n\n # new creditcards should be saved in the user's wallet\n if @order.payment.source.user.nil?\n @order.payment.source.update_attributes!(\n :user_id => current_user.id\n )\n end\n\n #make addresses, creditcard user's default\n @order.user.update_attributes!(\n :bill_address_id => original_bill.id,\n :ship_address_id => original_ship.id,\n :creditcard_id => @order.payment.source.id\n )\n end\n end", "def index\n @feeling = true\n order_id = session[:order_id]\n order = Order.find(order_id) rescue nil \n if order \n @pending_order = order\n else \n session[:order_id] = nil\n end\n end", "def set_order\n @my_order = Order.find(params[:id])\n end" ]
[ "0.6729885", "0.65770745", "0.64915246", "0.6378865", "0.6232437", "0.6157209", "0.6114791", "0.6102917", "0.6048155", "0.5995375", "0.57756704", "0.5747136", "0.5747136", "0.5727835", "0.572282", "0.5688659", "0.5673539", "0.5666001", "0.5639347", "0.562938", "0.5616615", "0.55874866", "0.5550367", "0.553353", "0.5531732", "0.55253065", "0.5516825", "0.54930395", "0.54930055", "0.547725", "0.5474927", "0.54742837", "0.54516155", "0.5430943", "0.5428103", "0.54010266", "0.5375593", "0.5374858", "0.53677195", "0.5354738", "0.53350955", "0.5321415", "0.532044", "0.5315076", "0.53055173", "0.53052425", "0.5270522", "0.5263868", "0.5262294", "0.526194", "0.524917", "0.52421135", "0.524004", "0.5234975", "0.5230674", "0.52236474", "0.52236474", "0.52236474", "0.51960325", "0.5190966", "0.5178011", "0.5178011", "0.5178011", "0.5178011", "0.51716137", "0.51690954", "0.51652336", "0.51624775", "0.51607823", "0.51498955", "0.51451135", "0.51425403", "0.51340973", "0.5129512", "0.51282704", "0.51282185", "0.51165414", "0.51134926", "0.51129985", "0.5107005", "0.51025623", "0.5100987", "0.5098178", "0.5093893", "0.50923276", "0.50884056", "0.5085207", "0.50846225", "0.50748587", "0.50651896", "0.5062744", "0.5061128", "0.505446", "0.5053853", "0.5052383", "0.5042027", "0.5028288", "0.50209916", "0.5014956", "0.50137055", "0.5013154" ]
0.0
-1
Returns the IDs of promotions that were previously applied to the order.
def previous_promotion_ids @previous_promotion_ids ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def promotions\n @promotions ||= order.promotions\n end", "def promotion_id_dump\n pending_promotions.map(&:id)\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def new_promotions\n @new_promotions ||= []\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def pids\n @pids ||= @lines.keys\n end", "def get_undelivered_order_ids\n\n #enable this one for previous restricted conditioned(pause/resume)\n #orders =self.orders.select('id, delivery_date').where('spree_orders.delivery_date > ?', Time.now).limit(3)\n orders = self.orders.select('id, delivery_date').where('spree_orders.state in (?) ', ['confirm', 'placed']).limit(3)\n\n order_ids = {}\n\n orders.each_with_index do |order, index|\n order_ids.merge!(index => order.id)\n end\n\n order_ids\n end", "def promotions\n Spree::Promotion.find_by_sql(\"#{order.promotions.active.to_sql} UNION #{Spree::Promotion.active.where(code: nil, path: nil).to_sql}\")\n connected_order_promotions | sale_promotions\n end", "def get_ps_pids(pids = [])\n current_pids = session.sys.process.get_processes.keep_if { |p| p['name'].casecmp('powershell.exe').zero? }.map { |p| p['pid'] }\n # Subtract previously known pids\n current_pids = (current_pids - pids).uniq\n current_pids\n end", "def current_cart_pids\n pids = {}\n\n @gears.each do |gear|\n gear.carts.values.each do |cart|\n Dir.glob(\"#{$home_root}/#{gear.uuid}/#{cart.directory}/{run,pid}/*.pid\") do |pid_file|\n $logger.info(\"Reading pid file #{pid_file} for cart #{cart.name}\")\n pid = IO.read(pid_file).chomp\n proc_name = File.basename(pid_file, \".pid\")\n\n pids[proc_name] = pid\n end\n end\n end\n\n pids\n end", "def promotion_id_dump=(ids)\n @previous_promotion_ids = ids.map(&:to_i)\n end", "def prereq_ids\n return [] unless scoped_course\n scoped_course.prereq_ids\n end", "def count_of_procedures_through_steps\n self.steps.map{|step| Procedure.unarchived.find_by_id(step.procedure_id)}.compact.uniq.count\n end", "def operator_ids\n @operator_ids ||= extract_operator_ids\n end", "def non_cabinet_position_ids\n non_cabinet_positions.map { |r| r[:id] }\n end", "def get_order_ids_for_cancel_or_pause\n #here sending back the order ids which are supposed to be marked canceled.\n #delivery_date > (ORDER_UPDATE_LIMIT+1).days.from_now.to_date)\n self.orders.where(\"state = ? and payment_state = ? and shipment_state = ? and delivery_date > ?\",\n 'confirm', 'pending', 'pending',(ORDER_UPDATE_LIMIT+1).days.from_now.to_date).pluck(:id)\n end", "def equivalent_phenotype_ids id\n if @skip_table.has_key?(id)\n skip_ids = @skip_table[id]\n if skip_ids.is_a?(Array)\n skip_ids + [id]\n else\n [skip_ids, id]\n end\n else\n [id]\n end\n end", "def identities\n results = @ordered.keys.sort\n return results\n end", "def product_ids\n new_record? ? (@products_cache ? @products_cache.map(&:id) : []) : self.products.map(&:id)\n end", "def resolved_ids\n return get_and_remove_done(@resolvers).map(&:id)\n end", "def uniq_pep_sequences\n unless self.peptide_evidences.empty?\n return self.peptide_evidences.map{|pep_ev| pep_ev.peptide_sequence.sequence}.uniq\n end\n end", "def propositional_symbols\n symbols = []\n @classified.each do |el|\n symbols.push el if el.instance_of? Proposition\n end\n symbols\n end", "def pids\n @pids ||= {}\n end", "def did_not_submit_ids\n @did_not_submit.map(&:id)\n end", "def sent_proposals\n reversed_matches = Array.new(@group_size)\n @best_proposals.each_with_index do |e, i|\n reversed_matches[e] = i if e\n end\n reversed_matches\n end", "def current_promotions\n promotions.where([\"start_on IS NOT NULL AND start_on <= ? AND (end_on >= ? OR end_on IS NULL OR end_on = '')\", Date.today, Date.today]).order(\"start_on\")\n end", "def prisoner_ids\n @prisoner_ids || prisoners.collect{|p| p.id}\n end", "def inserted_ids\n @results[INSERTED_IDS]\n end", "def list_pids\n access_processes do |processes|\n processes.keys\n end\n end", "def get_ids_of_all_jobs_old\r\n ids_of_jobs = []\r\n \r\n if parent_job_id.blank?\r\n child_jobs = Job.where(\"jobs.parent_job_id = #{id}\").all \r\n ids_of_jobs << id\r\n else\r\n child_jobs = Job.where(\"jobs.parent_job_id = #{parent_job_id}\").all\r\n ids_of_jobs << parent_job_id\r\n end\r\n\r\n child_jobs.each do |child_job|\r\n ids_of_jobs << child_job.id\r\n end\r\n\r\n ids_of_jobs\r\n end", "def current_workflow_processes\n wf_processes = []\n RuoteKit.engine.processes.each do |wfp|\n wf_processes << wfp if wfp.target == self\n end\n\n wf_processes\n end", "def pivotal_tracker_delivered_story_ids\n pivotal_tracker_ids('state:delivered includedone:true')\n end", "def worker_pids\n work_units.all(:select => 'worker_pid').map(&:worker_pid)\n end", "def property_ids\n result = Array.new\n self.properties.each do |p|\n result << p.id\n end\n result\n end", "def unconnected_sequences\n observed_sequences = Set.new\n connections.each do |conn|\n observed_sequences << conn.probe1.sequence_index\n observed_sequences << conn.probe2.sequence_index\n end\n return @sequence_ids.to_a - observed_sequences.to_a\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def ordered_products_total_arr\n ordered_products_arr = cart.items.map { |item| item[:product_id] }\n ordered_products_arr.map { |id| [id] * Item.where(product_id: id)[0].quantity }.flatten\n end", "def to_similarity_ids\n @to_similarity_ids ||= similarities.map(&:id)\n end", "def consumed_positions\n return @ring_positions.keys\n end", "def workflow_ids\n approval_access = RBAC::Access.new('workflows', 'approve').process\n approval_access.send(:generate_ids)\n\n Rails.logger.info(\"Approvable workflows: #{approval_access.id_list}\")\n\n approval_access.id_list\n end", "def promotions\n adjustments.where( promotion: true )\n end", "def pids\n return [] unless @pid\n return @component_objects.clone if manifest.content_model == PAGE_CONTENT_MODEL || manifest.content_model == NEWSPAPER_PAGE_CONTENT_MODEL\n return ([ @pid ] + @component_objects.clone)\n end", "def instructions_order\n instructions.each_with_index do |i, index|\n i.order = index + 1\n end\n end", "def pmids \n @pmids ||= []\n end", "def omim_ids\n @table.keys\n end", "def get_selected_song_ids\n return get_songs_relation.pluck( 'songs.id' )\n end", "def active_order_id\n last_transition ? last_transition.order_id : nil\n end", "def get_deleted_preorders\n params.require(:menu).delete(:deleted_preorders) || []\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def approver_request_ids\n Request.where(:workflow_id => workflow_ids).pluck(:id).sort\n end", "def approver_request_ids\n Request.where(:workflow_id => workflow_ids).pluck(:id).sort\n end", "def generate_related_products\n related_product_scores.delete_all\n\n purchase_counts = Hash.new(0)\n\n orders.uniq.each do |order|\n order\n .order_lines\n .where(\"product_id != #{id} AND product_id IS NOT NULL\")\n .pluck(:product_id)\n .uniq\n .each { |product_id| purchase_counts[product_id] += 1 }\n end\n\n scores = purchase_counts.map { |product_id, purchased|\n [product_id, relatedness(orders.count, purchased)]\n }.to_h\n\n scores.each_pair do |related_id, score|\n RelatedProductScore.create(product_id: id, related_product_id: related_id, score: score)\n end\n end", "def new_puzzle_ids\n\t\t@puzzle_ids - @puzzle_packet_ids\n\tend", "def cur_ordering\r\n @orderings\r\n end", "def _referenced_object_ids\n @data.each.select do |v|\n v&.respond_to?(:is_poxreference?)\n end.map(&:id)\n end", "def qing_ids\n questionings.collect{|qing| qing.id}\n end", "def dependency_ids\n ids = {}\n\n @dependencies.each do |type, jobs|\n ids[type] = jobs.map(&:pbsid).compact\n end\n\n ids.keep_if { |k,v| ! v.empty? }\n end", "def original_order\n end", "def result_ids\n @ranks_and_ids ||= load_result_ids_from_cache\n end", "def product_ids\n new_record? ? (@products ? @products.map(&:id) : []) : self.root.products.map(&:id)\n end", "def get_ids_of_all_child_jobs_old\r\n ids_of_child_jobs = []\r\n if parent_job_id.blank?\r\n child_jobs = Job.where(\"jobs.parent_job_id = #{id}\").all\r\n child_jobs.each do |child_job|\r\n ids_of_child_jobs << child_job.id\r\n end\r\n end\r\n \r\n ids_of_child_jobs\r\n end", "def proefssorted\n \tproefs.order(:position)\n end", "def processed_items\n @processed.to_a\n end", "def calculate_reorder_steps(ordered_ids, current)\n steps = []\n current.each_with_index do |source, idx|\n new_idx = ordered_ids.index(source.id)\n steps << [source, new_idx] if idx != new_idx\n end\n steps\n end", "def get_has_many_ids_changes(obj, previous_h_m_ids)\n changes = {}\n # reload the object for the deleting case\n obj.reload\n obj.class.reflect_on_all_associations(:has_many).each do |reflect|\n reflect_ids = obj.send reflect.name\n # Don't save if the relation m_to_m not changed\n changes[reflect.name] = [previous_h_m_ids, reflect_ids.map(&:id)] unless previous_h_m_ids.sort == reflect_ids.map(&:id).sort\n end\n changes\n end", "def get_edited_preorders\n params.require(:menu).delete(:edited_preorders) || []\n end", "def order_id\n order.global_e_id\n end", "def calculated_permutations\n permutations = model.analyzed_callbacks.inject([]) do |results, (key, analyzed_callbacks)|\n results << 2 ** number_of_unique_conditionals(analyzed_callbacks)\n end.sum - number_of_unique_conditionals(model.analyzed_callbacks_array)\n end", "def current_parties_ids\n current_cites_additions.map(&:party_id).compact.uniq\n end", "def modalities\n return @modalities\n end", "def calculate_reorder_steps(ordered_ids, current)\n steps = []\n current.each_with_index do |source, idx|\n new_idx = ordered_ids.index(source.id.to_s)\n steps << [source, new_idx] if idx != new_idx\n end\n steps\n end", "def all_processes\n `ps -eo pid,ppid`.lines.reduce(Hash.new []) do |hash, line|\n pid, ppid = line.split.map(&:to_i)\n hash[ppid] = [] unless hash.key?(ppid)\n hash[ppid] << pid\n hash\n end\n end", "def involved_people_ids\n (\n [self.scrum_master_id.to_s, self.product_owner_id.to_s] + self.team_member_ids + self.stakeholder_ids\n ).select {|u_id| !u_id.blank?}\n end", "def prompt_ids_for_dependencies\n #hardcode for now\n d = [\n \"p:a:*\",\n \"p:b:yes\",\n \"p:c:yes p:d:no AND\"\n ]\n prompt_slugs = d.map{|x|x.scan(/p:\\d+/)}\n .flatten\n .uniq\n .map{|x| x[2..-1]}\n\n Prompt.where(\"slug in (?)\", prompt_slugs).pluck(:id)\n end", "def order_count\n self.order_ids.count\n end", "def order_taxons(order)\n taxon_ids = Spree::Classification.where(product_id: order.product_ids).pluck(:taxon_id).uniq\n\n order.store.taxons.where(id: taxon_ids)\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def potential_subscriber_ids\n Subscriber.where(phone_number: from_phone).order(updated_at: :desc).map(&:id)\n end", "def repetition_positions(first:)\n rest = Repetition.where(parent_id: first.parent_id, card_content: first.card_content, task: first.task)\n .where.not(id: first.id)\n\n if first.destroyed?\n rest\n else\n [first] + rest\n end\n end", "def get_ids_of_all_jobs\r\n result = [id, parent_job_id].compact\r\n result << Job.where([\"parent_job_id in (?)\",result]).select(:id).collect(&:id)\r\n result.flatten.uniq\r\n end", "def currently_persisted_parent_uids\n DigitalObject.where(id: currently_persisted_parent_ids).pluck(:uid)\n end", "def current_track_ids\n tracks.where.not(id: nil).ids\n end", "def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end", "def workflow_ids\n approval_access = RBAC::Access.new('workflows', 'approve').process\n approval_access.send(:generate_ids)\n\n Rails.logger.info(\"Accessible workflows: #{approval_access.id_list}\")\n\n approval_access.id_list\n end", "def participant_ids\n self.report_participant_relationships.collect { |r| r.participant_id }.uniq\n end", "def network_message_ids\n return @network_message_ids\n end", "def unread_receipt_ids\n read_statuses = read_status.split(',')\n receipt_ids = @receipt_ids.split(',')\n read_statuses.zip(receipt_ids).map{|status, id| status == '0' ? id.to_i : nil}.compact\n end", "def pivotal_ids\n options[:pivotal_ids] || []\n end", "def update_ids\n self.task_id = @task_number\n self.order_id = @order_number\n end", "def ordered_file_set_ids\n results = ActiveFedora::SolrService.query(\n \"{!field f=has_model_ssim}FileSet\",\n fl: \"id\",\n fq: \"{!join from=ordered_targets_ssim to=id}id:\\\"#{id}/list_source\\\"\")\n results.flat_map { |x| x.fetch(\"id\", []) }\n end", "def remove_quantity_promotions\n if @basket_item.type == \"PurchasingItem\"\n using_promotions_count = UsingPromotion.where(basket_id: @basket_item.basket_id)\n .group(:promotion_id)\n .count\n using_promotions_count.each do | promotion_id, cnt |\n promotion = Promotion.find(promotion_id)\n item_cnt = BasketItem.where(basket_id: @basket_item.basket_id,\n item_id: @basket_item.item_id)\n .count - 1\n if promotion.item_id == @basket_item.item_id &&\n cnt * promotion.item_quantity > item_cnt\n UsingPromotion.where( basket_id: @basket_item.basket_id,\n promotion_id: promotion.id)\n .first\n .destroy\n end\n end\n end\n end", "def player_ids\n\t\tmy_ids = []\n\t\tplayers.each { |player|\n\t\t\tmy_ids << player.id\n\t\t}\n\t\treturn my_ids\n\tend", "def deleted_record_ids(objs)\n [objs.last.id + 1]\n end", "def order\n return @order\n end", "def requested_modalities\n return @requested_modalities\n end", "def parentsOrders(memberID, project)\n result = []\n if memberID\n if memberID[0] == \"G\"\n result = parentsOrders(project.groups.find(memberID).parentID, project) + [(@groupIDs.index(memberID)+1).to_s]\n else\n result = parentsOrders(project.leafs.find(memberID).parentID, project) + [@leafs[memberID][:memberOrder].to_s]\n end\n end\n return result\n end", "def ordered_ids\n Array(solr_document[\"member_ids_ssim\"])\n end", "def orders_completed\n result = Array.new\n self.job_applications.each do |j|\n j.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end" ]
[ "0.70147043", "0.60357255", "0.60298723", "0.5873947", "0.57972443", "0.5661478", "0.56314117", "0.55912", "0.55706793", "0.55138034", "0.5462903", "0.5376086", "0.5363145", "0.5344974", "0.5310175", "0.52990013", "0.5268256", "0.5255847", "0.5232396", "0.52301896", "0.52039945", "0.5197911", "0.51976407", "0.51972425", "0.51950645", "0.5147153", "0.511457", "0.5079395", "0.5067284", "0.50527775", "0.50276005", "0.5003771", "0.49979934", "0.4980316", "0.4971325", "0.49712116", "0.49644485", "0.49563935", "0.4924244", "0.49201688", "0.4914396", "0.4908941", "0.49041015", "0.49040794", "0.4890261", "0.4888544", "0.4886096", "0.48779637", "0.48775262", "0.48508233", "0.4843043", "0.48405638", "0.48405638", "0.48292682", "0.48186314", "0.48146683", "0.48000735", "0.47943228", "0.47922572", "0.47878158", "0.4787026", "0.47794077", "0.47502115", "0.47375605", "0.47360805", "0.4730462", "0.47242555", "0.47107857", "0.4701394", "0.47008246", "0.47008106", "0.46959862", "0.4695726", "0.46921155", "0.46889788", "0.46842784", "0.4682496", "0.4671581", "0.46637163", "0.4646727", "0.46458238", "0.46439004", "0.46415642", "0.46394187", "0.4636844", "0.46223596", "0.46214196", "0.4617858", "0.46172896", "0.46141762", "0.4608925", "0.4606201", "0.46040538", "0.4599715", "0.45892712", "0.45889735", "0.45875818", "0.45854247", "0.45834446", "0.45768464" ]
0.66303337
1
Checks to see if there is a code promotion applied to the order and that it is successful.
def code_promotion_successful? promotion_results.code_based.successful? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code_promotion_failed?\n !promo_code.blank? and promotion_results.code_based.failed?\n end", "def test_say_if_is_discounted\n setup_new_order_with_items()\n promo = promotions(:percent_rebate)\n \n assert [email protected]_discounted?\n @order.promotion_code = promo.code\n assert @order.is_discounted?\n end", "def normal_and_standalone_promo?\n # Guard clause to ensure promo code is definitely a standalone promo\n return unless promotion.stand_alone_promo(self[:promotion_id])\n if !promotions.empty? && !promotions.map(&:standalone).include?(true)\n return errors.add(:promotion_id, '..other promo exists!')\n end\n end", "def test_cleanup_promotion_order_finished\n # Setup - add promotion and complete order\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n @o.order_status_code = order_status_codes(:ordered_paid_to_ship)\n assert @o.save\n \n # Now expire the promo\n assert promo.update_attributes({\n :start => Date.today - 2.weeks,\n :end => Date.today - 1.week\n })\n promo.reload\n @o.reload\n \n # Update something on the order, like an admin would.\n # Maybe we shipped out the order and changed the status code.\n @o.order_status_code = order_status_codes(:sent_to_fulfillment)\n assert [email protected]_promotion_be_applied?(promo)\n assert @o.save\n \n @o.reload\n \n # Check to see if promotion is still applied (it should be!)\n assert_equal promo, @o.promotion\n assert_kind_of OrderLineItem, @o.promotion_line_item\n end", "def code_promotion_unchecked?\n promo_code.blank?\n end", "def can_be_added?(order)\n eligible?(order) &&\n (can_combine?(order) || order.promotion_credits.empty?) &&\n Credit.count(:conditions => {\n :adjustment_source_id => self.id,\n :adjustment_source_type => self.class.name,\n :order_id => order.id\n }) == 0\n end", "def check_for_coupon\n coupon = self.orders.where(state: \"paused\").first.coupon\n valid_coupon = Coupon.is_valid?(coupon.coupon_code) if coupon.present?\n valid_coupon.present? ? valid_coupon.coupon_code : nil\n end", "def apply_coupon_code\n if params[:order] && params[:order][:coupon_code]\n @order.coupon_code = params[:order][:coupon_code]\n\n handler = PromotionHandler::Coupon.new(@order).apply\n\n if handler.error.present?\n flash.now[:error] = handler.error\n respond_with(@order) { |format| format.html { render :edit } } && return\n elsif handler.success\n flash[:success] = handler.success\n end\n end\n end", "def apply_coupon_code\n if params[:order] && params[:order][:coupon_code]\n @order.coupon_code = params[:order][:coupon_code]\n\n handler = PromotionHandler::Coupon.new(@order).apply\n\n if handler.error.present?\n flash.now[:error] = handler.error\n respond_with(@order) { |format| format.html { render :edit } } and return\n elsif handler.success\n flash[:success] = handler.success\n end\n end\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def valid_order?\n order.coupon.nil? && coupon.cancelled_at.nil?\n end", "def compute_on_promotion?\n @compute_on_promotion ||= calculable.respond_to?(:promotion)\n end", "def standalone_promo?\n errors.add(:promotion_id, \"#{unique} exists!\") if !promotions.empty? && promotions.map(&:standalone).include?(true)\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def has_been_recorded?(order)\n unless Validation.validate(order.to_s) && Order.is_a_valid_item_code?(order.to_s)\n return false\n end\n @customer_order.push order.to_s\n return true\n end", "def apply_promotion( promotion )\n unless has_promotion?\n promotion.adjustment_class.create! adjustable: self, \n basis: promotion.discount_amount, \n message: \"Promotional Code: #{ promotion.promotional_code }\", \n promotion: true\n end\n end", "def test_set_promo_code_fixed_rebate\n # Setup\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n # Exercise\n @o.promotion_code = promo.code\n assert @o.save\n assert_equal promo, @o.promotion\n # Verify\n expected_total = @totals[:order] - promo.discount_amount\n assert_equal(\n expected_total.round(2),\n @o.total, \n \"Fixed rebate verification error.\"\n )\n end", "def setup_order\n @user = current_user\n country_short = current_user.account.country_short\n total_amount = 0\n promotion_code = false\n @price_plan = false\n\n if params[:promotion_code] && params[:price_plan_id]\n country = Country.where(short: country_short).first\n @price_plan = country.price_plans.find(params[:price_plan_id])\n\n if params[:promotion_code].present?\n code = params[:promotion_code].upcase\n promotion_code = @price_plan.promotion_codes.where(code: code).first\n end\n\n if promotion_code.nil?\n @price_plans = Country.get_paid_plans_for_country(current_user.account.country_short)\n @no_promotion_code = true\n @order = Order.new(\n upgrade: params[:upgrade],\n renewal: params[:renewal]\n )\n\n return render(action: 'upgrade', layout: 'registration') if params[:upgrade] == \"true\"\n return render(action: 'renew', layout: 'registration') if params[:renewal] == \"true\"\n return render(layout: 'registration')\n else\n\n if params[:promotion_code].blank?\n promotion_code = nil\n end\n\n base_price = params[:renewal] == \"true\" ? renew_or_base_price(@user, @price_plan) : @price_plan.base_price\n total_amount = promotion_code ? promotion_code.discounted_price.to_f : base_price\n\n if @price_plan.country.paypal_email.blank?\n express_subject = Rails.application.config.paypal_options[:subject]\n else\n express_subject = @price_plan.country.paypal_email\n end\n\n @order = Order.create!(\n price_plan_id: @price_plan.id,\n currency: @price_plan.country.currency,\n total_amount: total_amount,\n promotion_code: promotion_code.nil? ? nil : promotion_code.code,\n upgrade: params[:upgrade],\n renewal: params[:renewal],\n state: 'started',\n ip_address: request.remote_ip,\n country_short: @user.account.country_short,\n order_number: Order.make_order_number(@price_plan.country.short),\n express_subject: express_subject,\n user_id: @user.id\n )\n\n redirect_to payment_options_url(@order)\n end\n end\n end", "def test_promo_code_negative_value_bug\n # Setup / preverify\n promo = promotions(:fixed_rebate)\n promo_discount = 5000.00\n assert promo.update_attribute(:discount_amount, promo_discount)\n setup_new_order_with_items()\n assert promo.discount_amount > @o.total\n # Exercise\n @o.promotion_code = promo.code\n assert @o.save\n # Verify\n assert @o.total >= 0, \"Order total was: #{@o.total}\"\n end", "def check_for_promo_payment\n if !self.service_promo_id.nil? && !self.payed_booking_id.nil? && self.payed && self.trx_id != \"\"\n return true\n else\n return false\n end\n end", "def test_set_promo_code_fixed_min_value\n # Setup\n setup_new_order_with_items() \n @promo = promotions(:minimum_rebate)\n assert @totals[:order] >= @promo.minimum_cart_value\n # Exercise\n assert @o.should_promotion_be_applied?(@promo)\n @o.promotion_code = @promo.code\n assert @o.save\n @o.reload\n assert_equal @promo, @o.promotion\n # Verify\n expected_total = @totals[:order] - @promo.discount_amount\n assert_equal(\n expected_total.round(2), \n @o.total, \n \"Fixed rebate with minimum cart value verification error.\"\n )\n end", "def check_coupon\n return true if @coupon.blank?\n validate_coupon_referral_code(@coupon, :coupon)\n end", "def can_be_used_jointly?\n ids = order.order_promo_codes.collect(&:promo_code_id).uniq\n singular_promo_codes = PromoCode.where(id: ids).where(combined: false)\n # cant use count since that data isnt saved yet and count would fire an query\n if order.order_promo_codes.size > 1 and singular_promo_codes.count > 0\n self.errors.add(:promo_code_id, 'Cant be used with conjuction with other codes') unless self.promo_code.combined\n end\n end", "def promotion_credit_exists?(promotion)\n !! adjustments.promotion.reload.detect { |credit| credit.originator.promotion.id == promotion.id }\n end", "def order_success\n begin\n @order = (flash[:order_id] ? Order.find(flash[:order_id]) : @customer.orders.last)\n\n flash.keep(:order_id) # Keep the order ID around in case of a reload\n\n if request.post?\n if params[:customer]\n @order.customer.update_attributes( params[:customer] )\n end\n end\n\n rescue Exception => e\n ExceptionNotifier::Notifier.exception_notification(request.env, e).deliver\n @order = nil\n end\n\n @upsell_products = []\n if ! @order.andand.university_id\n @upsell_products = @customer.andand.postcheckout_upsell_recommend(1, 2, @order)\n end\n end", "def needs_promotion?\n !!@promotion_coords\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def claim_code\n\n coupon = Coupon.find_by_code(params[:code])\n\n if (coupon)\n\n # Make sure it's 0) a coupon 1) active 2) in date range 3) not\n # previously used by anyone if it's single-use 4) not being used by\n # an old customer if for first-timers-only and 5) not previously\n # used by this customer\n\n if (!coupon.active? || Date.today < coupon.start_date || Date.today > coupon.end_date)\n # XXXFIX P2: Display coupon errors and successes near coupon? (here and below)\n return redirect_with_message('Error: coupon code is not valid', :action => 'checkout')\n end\n\n if ((coupon.single_use_only? && coupon.uses.size > 0) || (coupon.used_by?(@customer)))\n return redirect_with_message('Error: this coupon code has already been used', :action => 'checkout')\n end\n\n if (coupon.new_customers_only? && @customer.orders.size > 0)\n return redirect_with_message('Error: this coupon can only be used by new customers', :action => 'checkout')\n end\n\n session[:coupon_id] = coupon.id\n\n return redirect_with_message('Your coupon has successfully been applied!', :action => 'checkout')\n\n else\n\n # Not a coupon, see if it's a gift certificate\n gc = GiftCertificate.find_by_code(params[:code])\n\n if (gc)\n\n # Make sure the gift certificate has not been used before\n\n if (gc.used?)\n return redirect_with_message('This gift certificate has already been converted to an account credit, ' +\n 'see your account credits below', :action => 'checkout')\n end\n\n @customer.add_account_credit(gc)\n return redirect_with_message('Your gift certificate is now an account credit that will be used for this order, ' +\n 'see your account credits below', :action => 'checkout')\n\n else\n\n return redirect_with_message('Error: no matching coupon or gift certificate code was found', :action => 'checkout')\n\n end\n\n end\n\n end", "def redsys_confirm\n logger.info \"==== REDSYS#CONFIRM ==== order##{params[:order_id]} params# #{params.inspect}\"\n @order ||= Spree::Order.find_by_number!(params[:order_id])\n if check_signature\n unless @order.payments.any?(&:completed?)\n payment_upgrade\n @order.updater.update_payment_total\n end\n @order.next\n if @order.completed?\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:order_completed] = true\n session[:order_id] = nil\n redirect_to completion_route(@order)\n else\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to checkout_state_path(@order.state) and return\n end\n else\n flash[:alert] = Spree.t(:spree_gateway_error_flash_for_checkout)\n redirect_to checkout_state_path(@order.state)\n end\n end", "def apply\n assign_order_attributes\n assign_payments_attributes\n\n if order.save\n order.set_shipments_cost if order.shipments.any?\n true\n else\n @errors = order.errors\n false\n end\n end", "def custom_order?\n order_items.all? { |oi| oi.purchasable_type == 'Effective::Product' }\n end", "def get_promo_code order\n order ? order[:promo_code] ? order[:promo_code] : nil : nil\n end", "def has_promotion?\n adjustments.where( promotion: true ).any?\n end", "def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )\n parsed_discount = discount.nil? ? 0.to_d : discount.to_d\n BigDecimal.new( original_gross ) == order_amount && parsed_discount == order_discount\n end", "def customer_order?\n if Order.where(id: order.id, user_id: current_user.id).first.nil?\n redirect_to navigation.back(1)\n return\n end\n end", "def apply_coupon\n if self.behavior == 'coupon'\n item = self.item\n \n # coitem is the OrderItem to which the coupon acts upon\n coitem = self.order.order_items.visible.find_by_sku(item.coupon_applies)\n log_action \"apply_coupon: coitem was not found\" and return if coitem.nil?\n\n unless coitem.coupon_amount.zero? then\n log_action \"apply_coupon: This item is a coupon, but a coupon_amount has already been set\"\n return\n end\n \n log_action \"apply_coupon: Starting to apply coupons. total before is #{ coitem.total_cents }\"\n \n ctype = self.item.coupon_type\n if ctype == 1\n # percent rebate\n factor = self.price_cents / 100.0 / 100.0\n if self.vendor.net_prices\n coitem.coupon_amount_cents = coitem.net.fractional * factor\n else\n coitem.coupon_amount_cents = coitem.gross.fractional * factor\n end\n log_action \"apply_coupon: Applying Percent rebate coupon: price_cents is #{ self.price_cents }, factor is #{ factor }, coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 2\n # fixed amount\n coitem.coupon_amount_cents = self.price_cents\n log_action \"apply_coupon: Applying Fixed amount coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 3\n # buy x get y free\n log_action \"apply_coupon: Applying B1G1\"\n x = 2\n y = 1\n if coitem.quantity >= x\n if self.vendor.net_prices\n coitem.coupon_amount_cents = y * coitem.net.fractional / coitem.quantity\n else\n coitem.coupon_amount_cents = y * coitem.gross.fractional / coitem.quantity\n end\n log_action \"apply_coupon: Applying B1G1 coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n end\n end\n if self.vendor.net_prices\n coitem.total = coitem.net - coitem.coupon_amount\n else\n # log_action \"XXXXXXXXX #{ coitem.gross.inspect } #{ coitem.coupon_amount.inspect }\"\n coitem.total = coitem.gross - coitem.coupon_amount\n end\n log_action \"apply_coupon: OrderItem Total after coupon applied is: #{coitem.total_cents} and coupon_amount is #{coitem.coupon_amount_cents}\"\n coitem.calculate_tax\n coitem.save!\n else\n self.total -= self.coupon_amount\n end\n end", "def check_promo_code\n if current_account.promo_code.blank?\n redirect_to waiting_pages_path\n end\n end", "def coupon_code_is_applicable?(code, cart)\n coupon = Coupon.find_by_code(code)\n \n # Check if amount in cart exceed coupon least amount\n if coupon.condition_at_least_amount && cart.price < coupon.condition_at_least_amount.to_f\n @coupon_error = \"Coupon #{code} is allowed on order which has amount $#{coupon.condition_at_least_amount} or higher.\"\n return false\n # TODO: other conditions may applied here\n else\n return true\n end\n end", "def test_cleanup_successful\n\t\[email protected]_successful\n\t\tassert_equal @order.order_status_code_id, 5\n\t assert_equal @order.notes.include?(\"Order completed.\"), true\n\t assert_equal @order.product_cost, @order.line_items_total\n\tend", "def valid_order?(order)\n valid_orders.include? order.to_s\n end", "def red_pencil_promotion?\n\t\t if valid_date? && valid_discount_amount? && valid_promotion_length?\n\t\t \treturn true\n\t\t else\n\t\t \treturn false\t\t \t\n\t\t end \n\tend", "def applicable?\n adjustment_source && adjustment_source.eligible?(order) && super\n end", "def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end", "def confirm\n @payment_gateway = @order.payment_gateway_class.new(order: @order)\n if @payment_gateway.collect_payment?\n head :bad_request\n else\n @order.complete!\n head :ok\n end\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )\n BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount.to_s ) == order_discount\n end", "def promotion_action_credit_exists?(promotion_action)\n !! adjustments.promotion.reload.detect do |credit|\n credit.originator_id == promotion_action.id && credit.originator.promotion.id == promotion_action.promotion.id\n end\n end", "def is_conflict?\n from_json\n (@order && @order.paid?).tap do |x|\n @error = true if x\n end\n end", "def apply\n return return_with(:error, I18n.t('coupon.cannot_apply_reseller')) if reseller_order?\n unless reached_minimum_order?\n return return_with(:error, I18n.t('coupon.no_minimum_price', minimum: coupon.minimum_order.in_euro.to_yuan(exchange_rate: order.exchange_rate).display))\n end\n return return_with(:error, I18n.t('coupon.cannot_apply_user')) unless valid_user?\n return return_with(:error, I18n.t('coupon.cannot_apply_shop')) unless valid_shop?\n return return_with(:error, I18n.t('coupon.cannot_apply')) unless valid_order?\n return return_with(:error, I18n.t('coupon.not_valid_anymore')) unless valid_coupon?\n return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless update_order! && update_referrer! && update_coupon!\n return_with(:success)\n end", "def promotion_credit_exists?(adjustable)\n self.adjustments.where(:adjustable_id => adjustable.id).exists?\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end", "def validate_order!\n _validate_order!\n rescue AASM::InvalidTransition => e\n false\n end", "def purchase_order_required?\n if self.solution.purchase_order_required && self.purchase_order.blank?\n errors.add(:purchase_order_required, \"PROBLEM: A purchase order is required for solution #{self.solution.name}.\")\n end\n end", "def update_ok?(order_hash)\n\t\tif !order_hash[:order_number]\n\t\t\treturn false\n\t\telsif order_hash[:status] == 'SH' \n\t\t\t\treturn true unless order_hash[:tracking_number] == nil || order_hash[:ship_method] == nil\n\t\telse\n\t\t\treturn true\n\t\tend \n\tend", "def update_ok?(order_hash)\n\t\tif !order_hash[:order_number]\n\t\t\treturn false\n\t\telsif order_hash[:status] == 'SH' \n\t\t\t\treturn true unless order_hash[:tracking_number] == nil || order_hash[:ship_method] == nil\n\t\telse\n\t\t\treturn true\n\t\tend \n\tend", "def test_should_finish_order_with_authorize_with_error\n # Execute an earlier test as this one deppends on it.\n test_should_set_shipping_method_without_confirmation\n \n # Now we say that we will use authorize. Mock the method.\n assert Preference.save_settings({ \"cc_processor\" => \"Authorize.net\" })\n Order.any_instance.expects(:run_transaction_authorize).once.returns(false)\n\n # Save initial quantity\n an_order_line_item = assigns(:order).order_line_items.first\n initial_quantity = an_order_line_item.item.quantity\n\n # Post to the finish order action.\n post :finish_order\n assert_redirected_to :action => :checkout\n assert flash[:notice].include?(\"Sorry, but your transaction\")\n\n # Quantity should NOT be updated.\n an_order_line_item.item.reload\n assert_equal initial_quantity, an_order_line_item.item.quantity\n end", "def process_order\n result = begin\n JSON.parse(@response)['Result'].first\n rescue\n nil\n end\n return if result.blank?\n result['Status'].casecmp('success').zero? ? update_order(result) : create_asendia_shipment_record(result['Status'], result['Error'])\n end", "def capture\n begin \n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # go through all order_payments\n order_payments = self.order_payments\n if order_payments.size == 0\n p \"No order_payments to process.\"\n raise PaymentError, \"No order_payments to process.\"\n end\n for order_payment in order_payments\n order_payment.capture!\n end\n self.upgrade_coupons!\n # update order\n self.update_attributes!(:state => Order::PAID, :paid_at => Time.zone.now)\n end\n # send confirmation email\n user = User.find_by_id(self.user_id)\n if user and user.send_confirmation(self.deal_id)\n return true\n else\n logger.error \"Order.capture: Confirmation email failed to send: #{self.inspect}\"\n return false\n end\n rescue PaymentError => pe\n p \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n rescue ActiveRecord::RecordInvalid => invalid\n p \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end", "def promotion\r\n\r\n end", "def eligible?(options = {})\n return unless order = options[:order]\n quantity_ordered = product.variants_including_master.inject(0) do |sum, v|\n sum + order.quantity_of(v)\n end\n quantity_ordered >= preferred_quantity\n end", "def test_successful_purchase_with_processing_mode_gateway\n response = @gateway.purchase(@amount, @credit_card, @options.merge(@processing_options))\n assert_success response\n assert_equal 'accredited', response.message\n end", "def process_order_payment\n \n return \"No Order Paid Date not found, order NOT PROCESSED\" if self.paid_date.blank?\n return \"No Order Paid Amount not found, order NOT PROCESSED\" if self.paid_amount.blank?\n return \"No Order Ref Name not found, order NOT PROCESSED\" if self.name.blank? \n return \"No Order Ref Id not found, order NOT PROCESSED\" if self.order_master_id.blank? \n \n return \"Paid Amount #{self.paid_amount} is less than ORDER AMOUNT #{self.order_master.grand_total}\" if self.paid_amount.to_i < self.order_master.grand_total.to_i\n \n order_master = OrderMaster.new\n return order_master.process_order self.order_master_id\n \n end", "def unredeemable?\n payment_owed? && !(ProductStrategy === self.order.promotion.strategy) \n end", "def deactivate!\n return unless storage[:auto_apply_promo_code]\n return unless current_order\n\n time = Time.at(storage[:auto_apply_promo_code_started_at].to_i) + storage[:auto_apply_promo_code_duration].to_i.hours\n return if time >= Time.now # promotion is still active\n\n current_order.adjustments.where(originator_type: 'Spree::PromotionAction').destroy_all\n\n storage.delete(:auto_apply_promo_code)\n storage.delete(:auto_apply_promo_code_duration)\n storage.delete(:auto_apply_promo_code_started_at)\n storage.delete(:auto_apply_promo_code_message)\n storage.delete(:auto_apply_promo_code_title)\n end", "def execute_promotion\n begin\n self.product.promotions.where(send_post_registration_message: true).find_each do |promo|\n if self.created_at.to_date >= promo.start_on.to_date && self.created_at.to_date <= promo.end_on.to_date\n SiteMailer.delay.promo_post_registration(self, promo)\n end\n end\n rescue\n logger.debug \"problem executing a promotion\"\n end\n end", "def process_authorization(options)\n gateway = options[:gateway]\n transaction_type = options[:transaction_type]\n amount = options[:amount]\n confirmation_code = options[:confirmation_code]\n transaction_id = options[:transaction_id]\n begin\n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # ignore any order state besides created - page refresh\n if self.state == Order::CREATED\n # create order_payment\n OrderPayment.create!(:user_id => self.user_id, :order_id => self.id, :gateway => gateway, \n :transaction_type => transaction_type, :confirmation_code => confirmation_code, \n :transaction_id => transaction_id, :amount => amount)\n # create coupons\n self.create_coupons!\n # update order\n self.update_attributes!(:state => Order::AUTHORIZED, :authorized_at => Time.zone.now)\n end\n end\n return true\n rescue ActiveRecord::RecordInvalid => invalid\n logger.error \"Order.process_authorization: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end", "def validate_tags_from_order_confirmation(params)\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n case true\n when params[\"do_optimizely\"]\n check_for_optimizely_function\n when params[\"do_adroll\"]\n check_for_adroll_function\n when params[\"do_ci\"]\n channel_intelligence_script.should_exist\n end\n end", "def publish!\n # Transaction ensures we do not create an order without order_items\n begin\n Order.transaction do\n order.save!\n create_order_items(order)\n calculate_total\n\n apply_promotion_to_order(params) if params[:promotion_code]\n end\n order\n rescue ActiveRecord::RecordInvalid => e\n order.tap { |o| o.errors.add(:base, \"This Product does not exist.\") }\n rescue ActiveRecord::RecordNotFound => e\n order.tap { |o| o.errors.add(:base, \"This Product does not exist.\") }\n rescue NoOrderItemsGiven => e\n order.tap { |o| o.errors.add(:base, e.message) }\n rescue InvalidPromoCodeGiven => e\n order.tap { |o| o.errors.add(:base, e.message) }\n rescue ActionController::ParameterMissing => e\n order.tap { |o| o.errors.add(:base, e.message) }\n end\n end", "def test_should_finish_order_with_authorize\n # Execute an earlier test as this one deppends on it.\n test_should_set_shipping_method_without_confirmation\n \n order = Order.find(session[:order_id])\n\n # Now we say that we will use authorize. Mock the method.\n assert Preference.save_settings({ \"cc_processor\" => \"Authorize.net\" })\n Order.any_instance.expects(:run_transaction_authorize).once.returns(true)\n \n # Save initial quantity\n oli = assigns(:order).order_line_items.first\n initial_quantity = oli.item.quantity\n\n # Post to the finish order action.\n post :finish_order\n assert_response :success\n assert_select \"p\", :text => /Card processed successfully/\n \n # Ensure items still in order\n assert !order.empty?, \"Order items were emptied when they shouldn't be.\"\n \n # Ensure customer has been logged in, so they may download their files\n assert_not_nil session[:customer], \"Customer was not logged in after successful purchase.\"\n end", "def available_for_order?(_order)\n true\n end", "def ready_to_approve?\n status = self.units.map(&:unit_status) & ['condition', 'copyright', 'unapproved']\n return status.empty?\n end", "def _apply_promo_code(promo)\n self[:total] = _promo_type(promo)\n self.save!\n end", "def can_combine?(order)\n self.combine &&\n order.credits(:join => :adjustment_source).all?{|pc| pc.adjustment_source.combine}\n end", "def test_promotion_line_item\n # Setup\n promo = promotions(:percent_rebate)\n setup_new_order_with_items()\n # Exercise\n @o.promotion_code = promo.code\n assert @o.save\n assert_kind_of Promotion, @o.promotion\n # Verify\n assert_equal @o.promotion_line_item.name, promo.description\n end", "def test_promo_code_minimum_bug\n test_set_promo_code_fixed_min_value()\n # Remove expensive item\n assert @o.order_line_items.delete(@li_2)\n assert @promo.minimum_cart_value > @o.total\n assert @o.save\n # Verify\n @o.reload\n assert_nil @o.promotion\n assert_equal 1, @o.order_line_items.size\n assert @o.order_line_items.include?(@li)\n end", "def checkout_allowed?\n order_items.count > 0\n end", "def confirm!\n return false if purchased?\n confirmed!\n end", "def validate_coupon_referral_code!(code)\n return false if subscription.blank?\n if code.start_with?(Freemium.referral_code_prefix)\n #lets check referrals\n\n u = eval(\"#{acts_as_subscriber_options[:find_referral_code]} '#{code}'\") rescue nil\n if u.blank?\n raise ReferralNotAppliedException, \"The referral key '#{code}' could not be found.\"\n end\n \n #you cannot apply your own referral code on yourself! nice try....\n if u == self\n raise ReferralNotAppliedException, \"You cannot apply your own referral code for yourself. Try again!\"\n end\n\n if acts_as_subscriber_options[:disable_referral_when_method] && self.send(acts_as_subscriber_options[:disable_referral_when_method])\n raise ReferralNotAppliedException, \"You can no longer add a referral code to your account.\"\n end\n\n #lets make sure they haven't used it already....\n subscription.coupon_referrals.count(:conditions => {:referring_user_id => u.id}) > 0\n if subscription.coupon_referrals.count(:conditions => {:referring_user_id => u.id}) > 0\n raise ReferralNotAppliedException, \"You have already used this referral code.\"\n end\n\n else\n c = FreemiumCoupon.find_by_coupon_code(code)\n if c.blank?\n raise CouponNotAppliedException, \"The coupon code '#{code}' could not be found.\"\n end\n \n #make sure it hasn't been applied before\n if subscription.coupon_referrals.count(:conditions => {:coupon_id => c.id}) > 0\n raise CouponNotAppliedException, \"You have already used this coupon code.\"\n end\n #other checks like usage limit, expired, etc\n end\n end", "def punch_out_order_message?\n !punch_out_order_message.nil?\n end", "def process_payment_status\n order = Spree::Order.find_by_number(params[:order_id])\n payment_id = order.payments.last.response_code\n \n mollie = Spree::PaymentMethod.find_by_type(\"Spree::Gateway::Mollie\")\n mollie_payment = mollie.provider.payments.get(payment_id)\n \n spree_payment = Spree::Payment.find_by_response_code(payment_id)\n\n # Translate Mollie status to Spree status and safe is to the order\n if mollie_payment.paid?\n spree_payment.complete! unless spree_payment.completed?\n spree_payment.order.next! unless spree_payment.order.complete?\n\n elsif mollie_payment.open? == false\n flash[:error] = t(\"payment.cancelled\", {default: \"Payment cancelled\"})\n spree_payment.failure! unless spree_payment.failed?\n \n else\n spree_payment.pend! unless spree_payment.pending?\n end\n\n redirect_to order.reload.paid? ? order_path(order) : checkout_state_path(:payment)\n end", "def test_remove_promotion_multiple_items\n setup_new_order_with_items()\n editable_order_codes = (1..5)\n editable_order_codes.each do |status_id|\n o_status = OrderStatusCode.find(status_id)\n assert_kind_of OrderStatusCode, o_status\n\n @o.order_status_code = o_status\n assert @o.is_editable?\n \n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n assert @o.save\n assert_kind_of OrderLineItem, @o.promotion_line_item\n # Add dupe line item.\n dupe_item = @o.promotion_line_item.clone\n @o.order_line_items << dupe_item\n assert_equal 2, @o.order_line_items.count(\n :conditions => [\"name = ?\", @o.promotion.description]\n )\n # Remove\n @o.remove_promotion()\n assert_nil @o.promotion_line_item\n end\n end", "def is_ok\n [\"OK\", \"QueuedForProcessing\"].include?(code);\n end", "def on_order?\n !self.paid?\n end", "def package_delivered\n self.status = CONSTANT['BOX_DELIVERED']\n self.package.status = CONSTANT['PACKAGE_DELIVERED_DELIVERY']\n if self.package.save\n if self.save\n pin = self.access.generate_pin\n if pin\n self.package.user.send_pick_up_pin pin #TODO\n return true\n end\n end\n end\n return false\n end", "def waiting\n code = params[:user] ? user_params[:promo_code] : nil\n if code and Founden::Config.promo_codes.include?(code)\n current_account.update_attributes(user_params)\n notice = _('Code worked! Carry on.')\n redirect_to root_path, :notice => notice\n else\n flash[:alert] = _('Sorry, the code did not work.') if code\n end\n end", "def unappliable_order?\n order.bought? == false\n end", "def burn\n @coupon = Coupon.find_by(code: params[:id])\n if @coupon&.available? && params_present?\n if @coupon.promotion.promotion_expired?\n render json: \"Coupon's promotion is expired.\".to_json,\n status: :precondition_failed\n elsif params[:product_id].to_i == @coupon.promotion.product_id\n @coupon.update order_number: params[:order_number],\n status: :unavailable\n @coupon.create_usage\n render json: { discount: @coupon.promotion.discount }, status: :ok\n else\n render json: 'Coupon does not relate to the product given'.to_json,\n status: :precondition_failed\n end\n else\n message_request_error\n end\n end", "def update\n if @order.update_attributes(object_params)\n fire_event('spree.checkout.update')\n \n unless apply_coupon_code\n respond_with(@order) { |format| format.html { render :edit } }\n return\n end\n\n # Add Klarna invoice cost\n klarna_payments = @order.payments.valid.where(source_type: \"Spree::KlarnaPayment\")\n \n if @order.adjustments.klarna_invoice_cost.count <= 0 && klarna_payments.any?\n @order.adjustments.create(:amount => klarna_payments.first.payment_method.preferred(:invoice_fee),\n :source => @order,\n :originator => klarna_payments.first.payment_method,\n :locked => true,\n :label => I18n.t(:invoice_fee))\n @order.update!\n elsif @order.adjustments.klarna_invoice_cost.count > 0 \n @order.adjustments.klarna_invoice_cost.destroy_all\n @order.update!\n end\n \n if @order.next\n state_callback(:after)\n else\n flash[:error] = @order.get_error # Changed by Noc\n respond_with(@order, :location => checkout_state_path(@order.state))\n return\n end\n\n if @order.state == \"complete\" || @order.completed?\n flash.notice = t(:order_processed_successfully)\n flash[:commerce_tracking] = \"nothing special\"\n respond_with(@order, :location => completion_route)\n else\n respond_with(@order, :location => checkout_state_path(@order.state))\n end\n else\n respond_with(@order) { |format| format.html { render :edit } }\n end\n end", "def check_current_order\t\n\t\t# TODO: Introduce a proper way to check the order payment status\n\t\t# Currently the order get removed from the session the moment the\n\t\t# spree receives payment and no way of tracking. Might have to introduce\n\t\t# other means of checking for payment receival for orders. A possible\n\t\t# method would be to have session id sent along with IPN secret and\n\t\t# mark a flag on payment notifications after displaying payment received\n\t\t# message\n\t\t# if current_order \\\n\t\t# && current_order.completed? \n\t\t# # && ((current_order.payment_state == \"paid\") or (current_order.payment_state == \"credit_owed\"))\n\t\t# \tflash[:notice] = t(:pp_ws_payment_received)\n\t\t# \t@order = current_order\n\t\t# \tsession[:order_id] = nil\n\n\t\t# \tif current_user\n\t\t# \t\tredirect_to spree.order_path(@order)\n\t\t# \telse\n\t\t# \t\tredirect_to root_path\n\t\t# \tend\n\t\t\t\n\t\t# end\n\tend", "def verify()\n if has_order_items?\n order_template = order_object\n order_template = yield order_object if block_given?\n @virtual_server.softlayer_client[:Product_Order].verifyOrder(order_template)\n end\n end", "def confirm_msg\n amt = CalcTotal::get_amt\n msg = amt && amt > 0 ? \"Your credit card \" : \"Your order \"\n msg += \"will be processed. Would you like to proceed?\"\n end", "def promo_offer?\n promotional_offer_id.present?\n end", "def ready_for_merge?(order_detail)\n case order_detail.product\n when Service\n order_detail.valid_service_meta?\n when Instrument\n order_detail.valid_reservation?\n else\n true\n end\n end", "def checkOrder(dealref)\n\n response = RestClient.get(\"#{@host}/gateway/deal/confirms/#{dealref}\", @headers )\n if response.code == 200\n confbody = JSON.parse(response.body)\n { :success => true, :dealstatus => confbody['dealStatus'], \n :reason => confbody['reason'], :status => confbody['status'] }\n else\n { :success => false }\n end\n\n rescue => e\n puts \"checkOrder ERROR: #{e}\"\n { :success => false }\n\n end", "def accept\n load_order\n # If the order has been canceled, the retailer can no longer accept it\n if @order.state == 'canceled'\n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.payments.blank?\n flash[:error] = \"Something went wrong with the payment on this order. Please hold off on shipping and contact ReserveBar.\"\n Spree::OrderMailer.no_payment_error_notification(@order).deliver\n elsif @order.accepted_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n @order.update_attribute(:accepted_at, Time.now)\n @order.create_profit_and_loss\n\n # If the order only has one payment on it (all order here should have only a single payment)\n # and the total order amount is lower than the payment amount, due to adjustments made after the order was submitted\n # reduce the amount in the payment to the order total\n if @order.payments.count == 1 && @order.payment.pending? && @order.total < @order.payment.amount\n @order.payment.update_attribute(:amount, @order.total)\n @order.payments.reload\n end\n\n begin\n @order.payments.each do |payment|\n payment.payment_source.send(\"capture\", payment)\n end\n rescue Spree::Core::GatewayError => error\n # Try to authorize and capture a new payment on the same source\n begin\n unless @order.payments.count > 1\n payment = @order.payment\n credit_card = payment.payment_source\n # check retailer matches merchant account of payment_source, in case order was moved\n if credit_card.bt_merchant_id == @order.retailer.bt_merchant_id\n new_payment = payment.dup\n new_payment.response_code = nil\n new_payment.save\n # authorize and capture new payment\n credit_card.authorize(new_payment.amount, new_payment)\n credit_card.send(\"capture\", new_payment)\n else\n raise 'Order changed Retailers'\n end\n else\n raise 'More than one payment'\n end\n rescue\n @order.update_attribute(:accepted_at, nil)\n # Handle messaging to retailer - error flash that something\n flash[:error] = \"Something went wrong with the payment on this order. Please hold off on shipping and contact ReserveBar.\"\n # Dump error to separate log\n log_payment_error(error)\n # Send email to reservbar that something went wrong\n Spree::OrderMailer.capture_payment_error_notification(@order, error).deliver\n end\n end\n end\n redirect_to admin_order_url(@order)\n end", "def missing_product_code?\n product_code.to_s == ''\n end", "def test_status\n assert_equal @order.status, order_status_codes(:ordered_paid_to_ship).name\n end", "def amount_ok?( order_amount )\n BigDecimal.new( amount ) == order_amount \n end", "def approved?\n if order_status == 'approved'\n return true\n else\n return false\n end\n end" ]
[ "0.6988479", "0.6475755", "0.6407527", "0.63245493", "0.6290344", "0.6088696", "0.5954468", "0.58843946", "0.58774066", "0.58522063", "0.5848439", "0.5763855", "0.5736762", "0.5692154", "0.5674695", "0.5666807", "0.5659416", "0.5636786", "0.5635909", "0.5598773", "0.55513275", "0.5504375", "0.5488659", "0.5487828", "0.54858005", "0.5484002", "0.5483947", "0.546201", "0.545818", "0.54316", "0.5423739", "0.54189974", "0.5399941", "0.5398654", "0.5348515", "0.53423876", "0.53347725", "0.53226256", "0.5309386", "0.5300995", "0.5297246", "0.52913374", "0.52866715", "0.5274879", "0.5272406", "0.52656686", "0.52577907", "0.5256592", "0.52540725", "0.5253626", "0.52456737", "0.5206427", "0.5194232", "0.51845646", "0.51787317", "0.51787317", "0.51696163", "0.5168289", "0.51628864", "0.5152057", "0.5149661", "0.51462066", "0.5145645", "0.5141437", "0.5132104", "0.5124348", "0.5118361", "0.5113928", "0.51045203", "0.51009846", "0.5088314", "0.5083945", "0.5053867", "0.5030452", "0.50015986", "0.500144", "0.49986625", "0.49950185", "0.49931583", "0.49796486", "0.49709433", "0.49616724", "0.4956299", "0.49518517", "0.49427205", "0.4935035", "0.49259955", "0.49240094", "0.4922948", "0.49217758", "0.49216905", "0.4921252", "0.49169976", "0.4915889", "0.49130067", "0.4910413", "0.4907453", "0.4905812", "0.49026966", "0.48967692" ]
0.7242866
0
Checks to see if there is a promotion code set against this order. If it is nil, then code promotions are pending i.e. haven't been checked yet.
def code_promotion_unchecked? promo_code.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code_promotion_failed?\n !promo_code.blank? and promotion_results.code_based.failed?\n end", "def code_promotion_successful?\n promotion_results.code_based.successful?\n end", "def check_for_coupon\n coupon = self.orders.where(state: \"paused\").first.coupon\n valid_coupon = Coupon.is_valid?(coupon.coupon_code) if coupon.present?\n valid_coupon.present? ? valid_coupon.coupon_code : nil\n end", "def normal_and_standalone_promo?\n # Guard clause to ensure promo code is definitely a standalone promo\n return unless promotion.stand_alone_promo(self[:promotion_id])\n if !promotions.empty? && !promotions.map(&:standalone).include?(true)\n return errors.add(:promotion_id, '..other promo exists!')\n end\n end", "def has_promotion?\n adjustments.where( promotion: true ).any?\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def compute_on_promotion?\n @compute_on_promotion ||= calculable.respond_to?(:promotion)\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def standalone_promo?\n errors.add(:promotion_id, \"#{unique} exists!\") if !promotions.empty? && promotions.map(&:standalone).include?(true)\n end", "def can_be_used_jointly?\n ids = order.order_promo_codes.collect(&:promo_code_id).uniq\n singular_promo_codes = PromoCode.where(id: ids).where(combined: false)\n # cant use count since that data isnt saved yet and count would fire an query\n if order.order_promo_codes.size > 1 and singular_promo_codes.count > 0\n self.errors.add(:promo_code_id, 'Cant be used with conjuction with other codes') unless self.promo_code.combined\n end\n end", "def needs_promotion?\n !!@promotion_coords\n end", "def promotion_credit_exists?(promotion)\n !! adjustments.promotion.reload.detect { |credit| credit.originator.promotion.id == promotion.id }\n end", "def ready_to_approve?\n status = self.units.map(&:unit_status) & ['condition', 'copyright', 'unapproved']\n return status.empty?\n end", "def get_promo_code order\n order ? order[:promo_code] ? order[:promo_code] : nil : nil\n end", "def valid_order?\n order.coupon.nil? && coupon.cancelled_at.nil?\n end", "def can_be_added?(order)\n eligible?(order) &&\n (can_combine?(order) || order.promotion_credits.empty?) &&\n Credit.count(:conditions => {\n :adjustment_source_id => self.id,\n :adjustment_source_type => self.class.name,\n :order_id => order.id\n }) == 0\n end", "def check_for_promo_payment\n if !self.service_promo_id.nil? && !self.payed_booking_id.nil? && self.payed && self.trx_id != \"\"\n return true\n else\n return false\n end\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def promotion_action_credit_exists?(promotion_action)\n !! adjustments.promotion.reload.detect do |credit|\n credit.originator_id == promotion_action.id && credit.originator.promotion.id == promotion_action.promotion.id\n end\n end", "def promo_offer?\n promotional_offer_id.present?\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def check_promo_code\n if current_account.promo_code.blank?\n redirect_to waiting_pages_path\n end\n end", "def test_say_if_is_discounted\n setup_new_order_with_items()\n promo = promotions(:percent_rebate)\n \n assert [email protected]_discounted?\n @order.promotion_code = promo.code\n assert @order.is_discounted?\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def promotions\n adjustments.where( promotion: true )\n end", "def promotion_credit_exists?(adjustable)\n self.adjustments.where(:adjustable_id => adjustable.id).exists?\n end", "def check_coupon\n return true if @coupon.blank?\n validate_coupon_referral_code(@coupon, :coupon)\n end", "def promotions\n @promotions ||= order.promotions\n end", "def reject_promotion_if_no_conjunction\n if Promotion.where( id: BasketItem\n .where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion')\n .pluck(:promotion_id),\n conjunction: false).any? ||\n Promotion.find(@basket_item.promotion_id).conjunction == false &&\n BasketItem.where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion').any?\n flash[:danger] = \"Promotion cannot be used in conjunction with already applied promotions!\"\n @reject = true\n end\n end", "def has_an_approved_account_set?\n all_monetary_processor_accounts.was_verified.any?\n end", "def checkout_allowed?\n order_items.count > 0\n end", "def has_options?\n bounty_expiration.present? || upon_expiration.present? || promotion.present?\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def build_promotion_codes\n codes.map do |code|\n promotion.codes.build(value: code)\n end\n end", "def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end", "def has_promotion?\n !offer_percentage.blank?\n end", "def promotional_sale?\n !promotional_sale.nil?\n end", "def test_cleanup_promotion_order_finished\n # Setup - add promotion and complete order\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n @o.order_status_code = order_status_codes(:ordered_paid_to_ship)\n assert @o.save\n \n # Now expire the promo\n assert promo.update_attributes({\n :start => Date.today - 2.weeks,\n :end => Date.today - 1.week\n })\n promo.reload\n @o.reload\n \n # Update something on the order, like an admin would.\n # Maybe we shipped out the order and changed the status code.\n @o.order_status_code = order_status_codes(:sent_to_fulfillment)\n assert [email protected]_promotion_be_applied?(promo)\n assert @o.save\n \n @o.reload\n \n # Check to see if promotion is still applied (it should be!)\n assert_equal promo, @o.promotion\n assert_kind_of OrderLineItem, @o.promotion_line_item\n end", "def maybe_remove_existing_promo_code(shop)\n return if shop.installed?\n\n shop.update!(promo_code: nil)\n end", "def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end", "def pending_financials?\n shop && shop.pending_products.any?\n end", "def has_order_items?\n @cores != nil || @ram != nil || @max_port_speed != nil\n end", "def reject_promotion_if_basket_empty\n if BasketItem.where(basket_id: @basket_item.basket_id).empty?\n flash[:danger] = \"Basket is empty - promotion cannot be applied!\"\n @reject = true\n end\n end", "def eligible?(options = {})\n return unless order = options[:order]\n quantity_ordered = product.variants_including_master.inject(0) do |sum, v|\n sum + order.quantity_of(v)\n end\n quantity_ordered >= preferred_quantity\n end", "def has_code?\n code != nil\n end", "def deactivate!\n return unless storage[:auto_apply_promo_code]\n return unless current_order\n\n time = Time.at(storage[:auto_apply_promo_code_started_at].to_i) + storage[:auto_apply_promo_code_duration].to_i.hours\n return if time >= Time.now # promotion is still active\n\n current_order.adjustments.where(originator_type: 'Spree::PromotionAction').destroy_all\n\n storage.delete(:auto_apply_promo_code)\n storage.delete(:auto_apply_promo_code_duration)\n storage.delete(:auto_apply_promo_code_started_at)\n storage.delete(:auto_apply_promo_code_message)\n storage.delete(:auto_apply_promo_code_title)\n end", "def pending_shop_request?\n !launched_shop? && latest_pending_shop_request\n end", "def eligible?(product)\n @product_codes.include?(product.product_code)\n end", "def apply_promotion( promotion )\n unless has_promotion?\n promotion.adjustment_class.create! adjustable: self, \n basis: promotion.discount_amount, \n message: \"Promotional Code: #{ promotion.promotional_code }\", \n promotion: true\n end\n end", "def purchase_order_required?\n if self.solution.purchase_order_required && self.purchase_order.blank?\n errors.add(:purchase_order_required, \"PROBLEM: A purchase order is required for solution #{self.solution.name}.\")\n end\n end", "def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promotions.\n @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}\n\n # If no promotions have been added to the order, they're all new.\n # Otherwise generate a new collection which is the difference between the\n # existing ones and the new ones.\n if previous_promotion_ids.empty?\n @new_promotions = pending_promotions\n else\n @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}\n @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}\n end\n\n pending_promotions\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def is_pending_confirmation?\n\n self.publishing_state == PublishingState::PENDING_CONFIRMATION\n\n end", "def payments_in_use?\n active_payment_types.present?\n end", "def requires_confirmation?\n cache(:requires_confirmation?) { grouped_required_confirmation_entries.values.flatten.present? }\n end", "def is_pending?\n return self.status == Erp::QuickOrders::Order::STATUS_PENDING\n end", "def pending_swap_manager_approval?\n @is_pending_swap_manager_approval\n end", "def confirmed?\n self.contributions.each do |contribution|\n return false if contribution.isPending?\n end\n return true\n end", "def set_promo_code\n @promo_code = PromoCode.find(params[:id])\n end", "def can_promote?\n current_signatures.all?(&:signed?)\n end", "def claim_code\n\n coupon = Coupon.find_by_code(params[:code])\n\n if (coupon)\n\n # Make sure it's 0) a coupon 1) active 2) in date range 3) not\n # previously used by anyone if it's single-use 4) not being used by\n # an old customer if for first-timers-only and 5) not previously\n # used by this customer\n\n if (!coupon.active? || Date.today < coupon.start_date || Date.today > coupon.end_date)\n # XXXFIX P2: Display coupon errors and successes near coupon? (here and below)\n return redirect_with_message('Error: coupon code is not valid', :action => 'checkout')\n end\n\n if ((coupon.single_use_only? && coupon.uses.size > 0) || (coupon.used_by?(@customer)))\n return redirect_with_message('Error: this coupon code has already been used', :action => 'checkout')\n end\n\n if (coupon.new_customers_only? && @customer.orders.size > 0)\n return redirect_with_message('Error: this coupon can only be used by new customers', :action => 'checkout')\n end\n\n session[:coupon_id] = coupon.id\n\n return redirect_with_message('Your coupon has successfully been applied!', :action => 'checkout')\n\n else\n\n # Not a coupon, see if it's a gift certificate\n gc = GiftCertificate.find_by_code(params[:code])\n\n if (gc)\n\n # Make sure the gift certificate has not been used before\n\n if (gc.used?)\n return redirect_with_message('This gift certificate has already been converted to an account credit, ' +\n 'see your account credits below', :action => 'checkout')\n end\n\n @customer.add_account_credit(gc)\n return redirect_with_message('Your gift certificate is now an account credit that will be used for this order, ' +\n 'see your account credits below', :action => 'checkout')\n\n else\n\n return redirect_with_message('Error: no matching coupon or gift certificate code was found', :action => 'checkout')\n\n end\n\n end\n\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def PO_required?\n # company doesn't, true (acceptable) either way\n return true if !self.quote.project.company.PO_required\n # company requirement and true\n return true if self.quote.project.company.PO_required and self.purchase_order_required\n # company does and we didn't\n errors.add(:PO_required, \"PROBLEM: #{self.quote.project.company.name} requires a purchase order.\")\n end", "def deliver_store_owner_order_notification_email?\n store.new_order_notifications_email.present? && !store_owner_notification_delivered?\n end", "def unredeemable?\n payment_owed? && !(ProductStrategy === self.order.promotion.strategy) \n end", "def needs_prod_set\n\t\treturn false\n\tend", "def delivered?\n check_elements_for_compliance { |e| !e.delivered? }\n end", "def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end", "def promotion\n @promotion ||= Interface::Promotion.new(self)\n end", "def has_pending\n\t\tget_cart_pending_balance > 0\n\tend", "def claimed?\n ! @claim.nil?\n end", "def package_delivered\n self.status = CONSTANT['BOX_DELIVERED']\n self.package.status = CONSTANT['PACKAGE_DELIVERED_DELIVERY']\n if self.package.save\n if self.save\n pin = self.access.generate_pin\n if pin\n self.package.user.send_pick_up_pin pin #TODO\n return true\n end\n end\n end\n return false\n end", "def is_pending?\n generated_at.nil? && !paid_on.nil?\n end", "def approval_requested?\n !([STATE_UNKNOWN, STATE_BLOCK_REQUESTED, STATE_BLOCKED, STATE_UNAVAILABLE, STATE_CANCELLED, STATE_EXPIRED, STATE_AVAILABLE_EXPIRED].include?(self.state))\n end", "def missing_product_code?\n product_code.to_s == ''\n end", "def due_status?(order)\n order.relevant_delivery_date &&\n (order.shippable? || order.collectable?) &&\n !order.shipped_at &&\n order.collection_ready_emails.empty?\n end", "def unappliable_order?\n order.bought? == false\n end", "def available_for_order?(_order)\n true\n end", "def hookup_code\n #break out of this function if we already have a code set\n return true if self.code\n\n #if there is not already a code set then go ahead and set it\n this_code = Code.where(:name => self.name, :coding_type => self.coding_type).first\n if this_code\n self.code = this_code\n else\n return false\n end\n end", "def pact_pending?\n pact_pending\n end", "def set_coupon_code\n\n if(@coupon_code.nil?)\n @coupon_code,@existing_coupon_code_flag = VendorCoupons.generate_coupon_code(@vendor_id,@unique_id,@sub_category_id,@cc_mobile_number,@c_id)\n else\n @coupon_code = \"nocode\"\n end\n \n end", "def ready_to_exchange?\n self.balance >= self.promotion.points_to_exchange\n end", "def coupons?\n coupons.any?\n end", "def uses_pkce?\n self.class.pkce_supported? && code_challenge.present?\n end", "def custom_order?\n order_items.all? { |oi| oi.purchasable_type == 'Effective::Product' }\n end", "def on_order?\n !self.paid?\n end", "def is_required?\n order.suppliers.any? {|supplier| supplier == self.supplier}\n end", "def apply_coupon_code\n if params[:order] && params[:order][:coupon_code]\n @order.coupon_code = params[:order][:coupon_code]\n\n handler = PromotionHandler::Coupon.new(@order).apply\n\n if handler.error.present?\n flash.now[:error] = handler.error\n respond_with(@order) { |format| format.html { render :edit } } && return\n elsif handler.success\n flash[:success] = handler.success\n end\n end\n end", "def promotion_check\n\t\tif @player_play[1][1] == \"8\" && @current_player.color == \"white\"\n\t\t\tpromotion_menu\n\t\telsif @player_play[1][1] == \"1\" && @current_player.color == \"black\"\n\t\t\tpromotion_menu\n end\n\tend", "def punch_out_order_message?\n !punch_out_order_message.nil?\n end", "def is_pending?\n moderation_flag.nil?\n end", "def is_pending?\n moderation_flag.nil?\n end", "def setup_order\n @user = current_user\n country_short = current_user.account.country_short\n total_amount = 0\n promotion_code = false\n @price_plan = false\n\n if params[:promotion_code] && params[:price_plan_id]\n country = Country.where(short: country_short).first\n @price_plan = country.price_plans.find(params[:price_plan_id])\n\n if params[:promotion_code].present?\n code = params[:promotion_code].upcase\n promotion_code = @price_plan.promotion_codes.where(code: code).first\n end\n\n if promotion_code.nil?\n @price_plans = Country.get_paid_plans_for_country(current_user.account.country_short)\n @no_promotion_code = true\n @order = Order.new(\n upgrade: params[:upgrade],\n renewal: params[:renewal]\n )\n\n return render(action: 'upgrade', layout: 'registration') if params[:upgrade] == \"true\"\n return render(action: 'renew', layout: 'registration') if params[:renewal] == \"true\"\n return render(layout: 'registration')\n else\n\n if params[:promotion_code].blank?\n promotion_code = nil\n end\n\n base_price = params[:renewal] == \"true\" ? renew_or_base_price(@user, @price_plan) : @price_plan.base_price\n total_amount = promotion_code ? promotion_code.discounted_price.to_f : base_price\n\n if @price_plan.country.paypal_email.blank?\n express_subject = Rails.application.config.paypal_options[:subject]\n else\n express_subject = @price_plan.country.paypal_email\n end\n\n @order = Order.create!(\n price_plan_id: @price_plan.id,\n currency: @price_plan.country.currency,\n total_amount: total_amount,\n promotion_code: promotion_code.nil? ? nil : promotion_code.code,\n upgrade: params[:upgrade],\n renewal: params[:renewal],\n state: 'started',\n ip_address: request.remote_ip,\n country_short: @user.account.country_short,\n order_number: Order.make_order_number(@price_plan.country.short),\n express_subject: express_subject,\n user_id: @user.id\n )\n\n redirect_to payment_options_url(@order)\n end\n end\n end", "def apply_coupon_code\n if params[:order] && params[:order][:coupon_code]\n @order.coupon_code = params[:order][:coupon_code]\n\n handler = PromotionHandler::Coupon.new(@order).apply\n\n if handler.error.present?\n flash.now[:error] = handler.error\n respond_with(@order) { |format| format.html { render :edit } } and return\n elsif handler.success\n flash[:success] = handler.success\n end\n end\n end", "def delivered?\n (!current_stage.nil? &&\n current_stage.stage.eql?('delivered') &&\n current_stage.status.eql?('passed') &&\n !AutomateSoup.url.nil? &&\n !AutomateSoup.credentials.nil?)\n end", "def applicable?\n adjustment_source && adjustment_source.eligible?(order) && super\n end", "def approved?\n !self.pending\n end", "def pending_manager_approval?\n @is_pending_manager_approval\n end" ]
[ "0.63372177", "0.6250729", "0.6246687", "0.6083889", "0.6052146", "0.60324043", "0.60162807", "0.6010615", "0.59483963", "0.5901427", "0.5697834", "0.56523883", "0.5642045", "0.5545806", "0.54634845", "0.5440411", "0.5435848", "0.54229414", "0.5417677", "0.53852314", "0.5349836", "0.5342884", "0.5230144", "0.52158946", "0.51779443", "0.51666605", "0.5142523", "0.5129475", "0.51147264", "0.50964355", "0.5092444", "0.5086235", "0.50789994", "0.50511193", "0.5046503", "0.5046417", "0.5029783", "0.5029265", "0.49802774", "0.4973535", "0.49668652", "0.49598217", "0.4956443", "0.49480695", "0.49445188", "0.49437687", "0.4911818", "0.4910778", "0.490943", "0.49082634", "0.49052542", "0.48828122", "0.48750138", "0.4861832", "0.4830636", "0.48046052", "0.479677", "0.47935018", "0.47882333", "0.47796628", "0.47762164", "0.47715813", "0.47692645", "0.47674432", "0.4755745", "0.4754757", "0.4754584", "0.47464326", "0.47420472", "0.47324604", "0.47281134", "0.47265163", "0.47242245", "0.47219586", "0.47212037", "0.47137", "0.47056592", "0.46989274", "0.46962026", "0.46894968", "0.46880448", "0.46857294", "0.46812493", "0.4671715", "0.46635023", "0.4661353", "0.46606684", "0.46517774", "0.46501866", "0.46487272", "0.46470344", "0.46458155", "0.46438336", "0.46438336", "0.46430364", "0.46428257", "0.46289304", "0.4628584", "0.46281528", "0.46223983" ]
0.68784934
0
Checks to see if a promotion code has been entered, promotions have been applied and that the order has failed to qualify for any code based promotions.
def code_promotion_failed? !promo_code.blank? and promotion_results.code_based.failed? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normal_and_standalone_promo?\n # Guard clause to ensure promo code is definitely a standalone promo\n return unless promotion.stand_alone_promo(self[:promotion_id])\n if !promotions.empty? && !promotions.map(&:standalone).include?(true)\n return errors.add(:promotion_id, '..other promo exists!')\n end\n end", "def code_promotion_successful?\n promotion_results.code_based.successful?\n end", "def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end", "def code_promotion_unchecked?\n promo_code.blank?\n end", "def can_be_used_jointly?\n ids = order.order_promo_codes.collect(&:promo_code_id).uniq\n singular_promo_codes = PromoCode.where(id: ids).where(combined: false)\n # cant use count since that data isnt saved yet and count would fire an query\n if order.order_promo_codes.size > 1 and singular_promo_codes.count > 0\n self.errors.add(:promo_code_id, 'Cant be used with conjuction with other codes') unless self.promo_code.combined\n end\n end", "def standalone_promo?\n errors.add(:promotion_id, \"#{unique} exists!\") if !promotions.empty? && promotions.map(&:standalone).include?(true)\n end", "def valid_order?\n order.coupon.nil? && coupon.cancelled_at.nil?\n end", "def red_pencil_promotion?\n\t\t if valid_date? && valid_discount_amount? && valid_promotion_length?\n\t\t \treturn true\n\t\t else\n\t\t \treturn false\t\t \t\n\t\t end \n\tend", "def test_cleanup_promotion_order_finished\n # Setup - add promotion and complete order\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n @o.order_status_code = order_status_codes(:ordered_paid_to_ship)\n assert @o.save\n \n # Now expire the promo\n assert promo.update_attributes({\n :start => Date.today - 2.weeks,\n :end => Date.today - 1.week\n })\n promo.reload\n @o.reload\n \n # Update something on the order, like an admin would.\n # Maybe we shipped out the order and changed the status code.\n @o.order_status_code = order_status_codes(:sent_to_fulfillment)\n assert [email protected]_promotion_be_applied?(promo)\n assert @o.save\n \n @o.reload\n \n # Check to see if promotion is still applied (it should be!)\n assert_equal promo, @o.promotion\n assert_kind_of OrderLineItem, @o.promotion_line_item\n end", "def reject_promotion_if_no_conjunction\n if Promotion.where( id: BasketItem\n .where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion')\n .pluck(:promotion_id),\n conjunction: false).any? ||\n Promotion.find(@basket_item.promotion_id).conjunction == false &&\n BasketItem.where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion').any?\n flash[:danger] = \"Promotion cannot be used in conjunction with already applied promotions!\"\n @reject = true\n end\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def reject_promotion_if_not_enough_items\n promotion = Promotion.find(@basket_item.promotion_id)\n if !promotion.item_id.nil?\n items_count = BasketItem.where( basket_id: @basket_item.basket_id,\n item_id: promotion.item_id)\n .count\n # count pieces of the item for which promotions already applied\n item_promotions_count = 0\n Promotion.where(item_id: promotion.item_id).each do | p |\n item_promotions_count += BasketItem.where(basket_id: @basket_item.basket_id,\n promotion_id: p.id)\n .count * promotion.item_quantity\n end\n\n if items_count - item_promotions_count < promotion.item_quantity\n flash[:danger] = \"Not enough items in the basket to apply the promotion!\"\n @reject = true\n end\n end\n end", "def check_coupon\n return true if @coupon.blank?\n validate_coupon_referral_code(@coupon, :coupon)\n end", "def is_conflict?\n from_json\n (@order && @order.paid?).tap do |x|\n @error = true if x\n end\n end", "def validate_can_purchase\n\n return error_with_data(\n 'um_ea_1',\n 'Sale is not active',\n 'Sale is not active',\n GlobalConstant::ErrorAction.default,\n {}\n ) if !@client_token_sale_details.is_token_sale_live?\n\n return error_with_data(\n 'um_ea_2',\n 'Invalid action',\n 'Invalid action',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @client_token_sale_details.ethereum_deposit_address.blank?\n\n return error_with_data(\n 'um_ea_3',\n 'Unauthorized to purchase',\n 'Unauthorized to purchase',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @user_kyc_detail.blank? || !@user_kyc_detail.kyc_approved? ||\n (@client.is_whitelist_setup_done? && !@user_kyc_detail.done_whitelist_status?)\n\n success\n end", "def validate\n !discount_code.nil? && discount.nil? ? raise(InvalidDiscountCode, \"There is no discount with that code\") : true\n end", "def can_be_added?(order)\n eligible?(order) &&\n (can_combine?(order) || order.promotion_credits.empty?) &&\n Credit.count(:conditions => {\n :adjustment_source_id => self.id,\n :adjustment_source_type => self.class.name,\n :order_id => order.id\n }) == 0\n end", "def eligible?(product)\n @product_codes.include?(product.product_code)\n end", "def ready_to_approve?\n status = self.units.map(&:unit_status) & ['condition', 'copyright', 'unapproved']\n return status.empty?\n end", "def imperfect_return_resubmission?\n return false unless previously_transmitted_submission.present?\n \n previously_transmitted_submission.efile_submission_transitions.collect(&:efile_errors).flatten.any? { |error| [\"SEIC-F1040-501-02\", \"R0000-504-02\"].include? error.code }\n end", "def purchase_order_required?\n if self.solution.purchase_order_required && self.purchase_order.blank?\n errors.add(:purchase_order_required, \"PROBLEM: A purchase order is required for solution #{self.solution.name}.\")\n end\n end", "def coupon_code_is_applicable?(code, cart)\n coupon = Coupon.find_by_code(code)\n \n # Check if amount in cart exceed coupon least amount\n if coupon.condition_at_least_amount && cart.price < coupon.condition_at_least_amount.to_f\n @coupon_error = \"Coupon #{code} is allowed on order which has amount $#{coupon.condition_at_least_amount} or higher.\"\n return false\n # TODO: other conditions may applied here\n else\n return true\n end\n end", "def test_say_if_is_discounted\n setup_new_order_with_items()\n promo = promotions(:percent_rebate)\n \n assert [email protected]_discounted?\n @order.promotion_code = promo.code\n assert @order.is_discounted?\n end", "def check_for_coupon\n coupon = self.orders.where(state: \"paused\").first.coupon\n valid_coupon = Coupon.is_valid?(coupon.coupon_code) if coupon.present?\n valid_coupon.present? ? valid_coupon.coupon_code : nil\n end", "def can_be_unconfirmed?\n \n if self.purchase_receival_entries.count != 0\n self.errors.add(:generic_errors, \"Tidak bisa unconfirm karena sudah ada penerimaan barang\")\n return false \n end\n \n if self.purchase_return_entries.count != 0 \n self.errors.add(:generic_errors, \"Tidak bisa unconfirm karena sudah ada pengembalian barang\")\n return false\n end\n\n \n \n reverse_adjustment_quantity = -1*quantity \n \n final_item_quantity = item.pending_receival + reverse_adjustment_quantity\n final_warehouse_item_quantity = warehouse_item.pending_receival + reverse_adjustment_quantity\n \n if final_item_quantity < 0 or final_warehouse_item_quantity < 0 \n msg = \"Tidak bisa unconfirm karena akan menyebabkan jumlah #{item.name} pending receival menjadi #{final_item_quantity} \" + \n \" dan jumlah item gudang menjadi :#{final_warehouse_item_quantity}\"\n self.errors.add(:generic_errors, msg )\n return false \n end\n \n return true \n end", "def PO_required?\n # company doesn't, true (acceptable) either way\n return true if !self.quote.project.company.PO_required\n # company requirement and true\n return true if self.quote.project.company.PO_required and self.purchase_order_required\n # company does and we didn't\n errors.add(:PO_required, \"PROBLEM: #{self.quote.project.company.name} requires a purchase order.\")\n end", "def apply\n return return_with(:error, I18n.t('coupon.cannot_apply_reseller')) if reseller_order?\n unless reached_minimum_order?\n return return_with(:error, I18n.t('coupon.no_minimum_price', minimum: coupon.minimum_order.in_euro.to_yuan(exchange_rate: order.exchange_rate).display))\n end\n return return_with(:error, I18n.t('coupon.cannot_apply_user')) unless valid_user?\n return return_with(:error, I18n.t('coupon.cannot_apply_shop')) unless valid_shop?\n return return_with(:error, I18n.t('coupon.cannot_apply')) unless valid_order?\n return return_with(:error, I18n.t('coupon.not_valid_anymore')) unless valid_coupon?\n return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless update_order! && update_referrer! && update_coupon!\n return_with(:success)\n end", "def validate_coupon_referral_code!(code)\n return false if subscription.blank?\n if code.start_with?(Freemium.referral_code_prefix)\n #lets check referrals\n\n u = eval(\"#{acts_as_subscriber_options[:find_referral_code]} '#{code}'\") rescue nil\n if u.blank?\n raise ReferralNotAppliedException, \"The referral key '#{code}' could not be found.\"\n end\n \n #you cannot apply your own referral code on yourself! nice try....\n if u == self\n raise ReferralNotAppliedException, \"You cannot apply your own referral code for yourself. Try again!\"\n end\n\n if acts_as_subscriber_options[:disable_referral_when_method] && self.send(acts_as_subscriber_options[:disable_referral_when_method])\n raise ReferralNotAppliedException, \"You can no longer add a referral code to your account.\"\n end\n\n #lets make sure they haven't used it already....\n subscription.coupon_referrals.count(:conditions => {:referring_user_id => u.id}) > 0\n if subscription.coupon_referrals.count(:conditions => {:referring_user_id => u.id}) > 0\n raise ReferralNotAppliedException, \"You have already used this referral code.\"\n end\n\n else\n c = FreemiumCoupon.find_by_coupon_code(code)\n if c.blank?\n raise CouponNotAppliedException, \"The coupon code '#{code}' could not be found.\"\n end\n \n #make sure it hasn't been applied before\n if subscription.coupon_referrals.count(:conditions => {:coupon_id => c.id}) > 0\n raise CouponNotAppliedException, \"You have already used this coupon code.\"\n end\n #other checks like usage limit, expired, etc\n end\n end", "def valid_item_code?(item_code)\n @product = Product::PRODUCTS[item_code]\n ([email protected]? && [email protected]?)\n end", "def valid?\n return false if @marketplace_technical_code.nil?\n return false if @account_id.nil?\n return false if @beez_up_order_id.nil?\n return false if @marketplace_business_code.nil?\n return false if @order_marketplace_order_id.nil?\n return false if @order_status_beez_up_order_status.nil?\n return false if @order_purchase_utc_date.nil?\n return false if @order_last_modification_utc_date.nil?\n return false if @order_marketplace_last_modification_utc_date.nil?\n return false if @processing.nil?\n return false if @etag.nil?\n return false if @links.nil?\n return false if @order_items.nil?\n return false if @transition_links.nil?\n return true\n end", "def check_for_promo_payment\n if !self.service_promo_id.nil? && !self.payed_booking_id.nil? && self.payed && self.trx_id != \"\"\n return true\n else\n return false\n end\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def ecommerce_verify_cart_errors(cart)\n errors = []\n # products verification\n cart.product_items.decorate.each do |item|\n unless item.is_valid_qty?\n product = item.product.decorate\n errors << t('plugins.ecommerce.messages.not_enough_product_qty', product: product.the_variation_title(item.variation_id), qty: product.the_qty(item.variation_id), default: 'There is not enough products \"%{product}\" (Available %{qty})')\n end\n end\n\n # coupon verification\n res = cart.discount_for(cart.coupon)\n if res[:error].present?\n errors << commerce_coupon_error_message(res[:error], res[:coupon])\n cart.update_column(:coupon, '')\n end\n\n args = {cart: cart, errors: errors}; hooks_run(\"commerce_on_error_verifications\", args)\n errors\n end", "def eligible?(order)\n return false if expired? || usage_limit_exceeded?(order)\n rules_are_eligible?(order, {})\n end", "def ecommerce_verify_cart_errors(cart)\n errors = []\n # products verification\n cart.product_items.decorate.each do |item|\n unless item.is_valid_qty?\n product = item.product.decorate\n errors << t('plugins.ecommerce.messages.not_enough_product_qty', product: product.the_title, qty: product.the_qty_real, default: 'There is not enough products \"%{product}\" (Available %{qty})')\n end\n end\n\n # coupon verification\n res = cart.discount_for(cart.coupon)\n if res[:error].present?\n errors << commerce_coupon_error_message(res[:error], res[:coupon])\n cart.update_column(:coupon, '')\n end\n\n args = {cart: cart, errors: errors}; hooks_run(\"commerce_on_error_verifications\", args)\n errors\n end", "def test_promo_code_negative_value_bug\n # Setup / preverify\n promo = promotions(:fixed_rebate)\n promo_discount = 5000.00\n assert promo.update_attribute(:discount_amount, promo_discount)\n setup_new_order_with_items()\n assert promo.discount_amount > @o.total\n # Exercise\n @o.promotion_code = promo.code\n assert @o.save\n # Verify\n assert @o.total >= 0, \"Order total was: #{@o.total}\"\n end", "def eligible?(options = {})\n return unless order = options[:order]\n quantity_ordered = product.variants_including_master.inject(0) do |sum, v|\n sum + order.quantity_of(v)\n end\n quantity_ordered >= preferred_quantity\n end", "def check_receipt_state\n\t\tunless account_movement.nil? || account_movement.receipt.nil?\n\t\t\terrors.add(\"Recibo confirmado\", \"Los pagos de un recibo confirmado no pueden ser modificados.\") unless account_movement.receipt.editable?\n\t\tend\n\tend", "def waiting\n code = params[:user] ? params[:user][:promo_code] : nil\n if code and Doers::Config.promo_codes.include?(code)\n current_account.update_attributes(user_params.merge(:confirmed => true))\n notice = _(\"Code worked! Please don't forget to leave your feedback.\")\n redirect_to root_path, :notice => notice\n else\n flash[:alert] =\n _(\"Sorry, but we couldn't validate that promo code.\") if code\n end\n end", "def acro_not_same_as_code\n if acro.present? && code.present?\n errors.add( :acro, I18n.t( 'phase_codes.msg.acro_eq_code' )) \\\n unless acro != code\n end\n end", "def precheck_clearancing_error\n potential_item = Item.find_by(id: @item_id)\n\n if !@item_id.is_a?(Integer) || @item_id == 0\n @errors << \"Item id #{@item_id} is not valid\"\n\n elsif potential_item && potential_item.status == 'clearanced'\n # NOTE: The catch at the end is there just to satisfy a spec condition. Not super happy about that.\n @errors << \"Item id #{@item_id} already clearanced into Batch #{potential_item.clearance_batch.id if potential_item.clearance_batch}\"\n\n elsif !potential_item\n @errors << \"Item id #{@item_id} could not be found\"\n\n elsif Item.sellable.where(id: @item_id).none?\n @errors << \"Item id #{@item_id} could not be clearanced\"\n\n else\n false\n\n end\n\n end", "def reject_promotion_if_basket_empty\n if BasketItem.where(basket_id: @basket_item.basket_id).empty?\n flash[:danger] = \"Basket is empty - promotion cannot be applied!\"\n @reject = true\n end\n end", "def check_promo_code\n if current_account.promo_code.blank?\n redirect_to waiting_pages_path\n end\n end", "def e_validate_related_orders\n errors.add(:base, I18n.t('plugins.ecommerce.message.not_deletable_product')) if Plugins::Ecommerce::ProductItem.where(product_id: id).any?\n end", "def correct_statuses?\n [:order_status, :payment_status].each do |s|\n return false if Commission::INVALID_STATES.include?(self.send(s).gsub(/(.*\\_)/, \"\").to_sym)\n end\n true\n end", "def eligible?(order)\n order.completed? or (!expired? and rules_are_eligible?(order))\n end", "def valid_operation\n if (wallet_origin && wallet_destiny ||\n wallet_origin && card_destiny && card_destiny.debit ||\n card_origin && wallet_destiny).nil?\n errors.add(:amount, 'invalid operation. Missing wallet(s) and/or card(s)')\n end\n end", "def valid_to_submit?\n # Ensure all the results have been assigned/initialized\n if campaign.present?\n valid_results? && validate_modules_ranges\n end\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )\n BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount.to_s ) == order_discount\n end", "def missing_product_code?\n product_code.to_s == ''\n end", "def unredeemable?\n payment_owed? && !(ProductStrategy === self.order.promotion.strategy) \n end", "def promotion_credit_exists?(promotion)\n !! adjustments.promotion.reload.detect { |credit| credit.originator.promotion.id == promotion.id }\n end", "def valid_order?(order)\n valid_orders.include? order.to_s\n end", "def validate_code!\n valid_code? ? confirm! : unconfirm!\n end", "def apply\n assign_order_attributes\n assign_payments_attributes\n\n if order.save\n order.set_shipments_cost if order.shipments.any?\n true\n else\n @errors = order.errors\n false\n end\n end", "def valid?\n return false if @beez_up_order_item_id.nil?\n return false if @order_item_order_item_type.nil?\n return true\n end", "def has_invalid_items?\n unless @offer[:items].empty? || @offer[:items].select { |item_name|\n !Inventory.items_and_values.include?(item_name)}.empty?\n add_error(:offer, :items, \"There is an invalid item in the list\")\n error = true\n end\n unless @for[:items].empty? || @for[:items].select { |item_name|\n !Inventory.items_and_values.include?(item_name)}.empty?\n add_error(:for, :items, \"There is an invalid item in the list\")\n error = true\n end\n\n error ||= false\n end", "def has_promotion?\n adjustments.where( promotion: true ).any?\n end", "def valid_emotion?\n (EMOTIONS - emotion).size != EMOTIONS.size\n # -> any matching pairs\n end", "def products_covered?(dep_prods, man_prods)\n if dep_prods.nil? || man_prods.nil?\n return false\n end\n\n return (dep_prods - man_prods).empty?\n end", "def abort?\n !delivered && !attempts.nil? && (attempts > ATTEMPTS_TOLERANCE)\n end", "def waiting\n code = params[:user] ? user_params[:promo_code] : nil\n if code and Founden::Config.promo_codes.include?(code)\n current_account.update_attributes(user_params)\n notice = _('Code worked! Carry on.')\n redirect_to root_path, :notice => notice\n else\n flash[:alert] = _('Sorry, the code did not work.') if code\n end\n end", "def compute_on_promotion?\n @compute_on_promotion ||= calculable.respond_to?(:promotion)\n end", "def any_damage? \n [@hp_damage, @mp_damage, @tp_damage, @hp_drain, @mp_drain].any? do |result|\n result != 0\n end\n end", "def valid_coupon?\n (coupon.unique == false || available?) && (coupon.expired_at == nil || coupon.expired_at > Time.now)\n end", "def test_set_promo_code_fixed_min_value\n # Setup\n setup_new_order_with_items() \n @promo = promotions(:minimum_rebate)\n assert @totals[:order] >= @promo.minimum_cart_value\n # Exercise\n assert @o.should_promotion_be_applied?(@promo)\n @o.promotion_code = @promo.code\n assert @o.save\n @o.reload\n assert_equal @promo, @o.promotion\n # Verify\n expected_total = @totals[:order] - @promo.discount_amount\n assert_equal(\n expected_total.round(2), \n @o.total, \n \"Fixed rebate with minimum cart value verification error.\"\n )\n end", "def cant_be_claimed_by_other_and_below_income_requirement?\n dependent.cant_be_claimed_by_other_yes? && dependent.below_qualifying_relative_income_requirement_yes?\n end", "def applicable?\n adjustment_source && adjustment_source.eligible?(order) && super\n end", "def has_options?\n bounty_expiration.present? || upon_expiration.present? || promotion.present?\n end", "def has_required_instructions\n unless (REQUIRED_INSTRUCTIONS & instructions.map(&:name)).size == REQUIRED_INSTRUCTIONS.size\n errors.add(:instructions, \"precisa conter pelo menos as seguintes instruções: \" + REQUIRED_INSTRUCTIONS.join(', '))\n end\n end", "def validate_order!\n _validate_order!\n rescue AASM::InvalidTransition => e\n false\n end", "def check_if_approval_is_required\n check_by_families || check_by_supplier || check_by_project ||\n check_by_office || check_by_company || check_by_zone\n end", "def any_eob_processed?\n self.insurance_payment_eobs.length >= 1\n end", "def valid?\n !vendor_no.nil? && !name.nil?\n end", "def promotion_action_credit_exists?(promotion_action)\n !! adjustments.promotion.reload.detect do |credit|\n credit.originator_id == promotion_action.id && credit.originator.promotion.id == promotion_action.promotion.id\n end\n end", "def check_values\n check_numericity\n check_zip_code\n end", "def validate_airdrop_done\n\n client_chain_interactions = CriticalChainInteractionLog.of_activity_type(GlobalConstant::CriticalChainInteractions.\n airdrop_users_activity_type).where(client_id: @client_id).group_by(&:status)\n\n # No requests present\n return success if client_chain_interactions.blank?\n\n # Pending requests present then send error\n return error_with_data(\n 'e_adu_3',\n 'pending_grant_requests',\n GlobalConstant::ErrorAction.default\n ) if (client_chain_interactions.keys & [GlobalConstant::CriticalChainInteractions.queued_status,\n GlobalConstant::CriticalChainInteractions.pending_status]).present?\n\n # TODO: Do we have to apply any other checks\n\n success\n\n end", "def needs_promotion?\n !!@promotion_coords\n end", "def has_reasons\n if !(for_major || for_prof || for_interest || for_distrib || for_easy_a || for_prereq)\n puts \"HAS NO REASONS: incomplete review\"\n errors.add(:incomplete, '. Review must list at least one motivation')\n end\n end", "def must_carry_mens_or_womens_apparel\n errors.add(:base, \"Store must carry either women's or men's apparel.\") if (!mens_apparel && !womens_apparel)\n end", "def can_be_rejected?\n self.applied?\n end", "def can_be_unconfirmed?\n reverse_adjustment_quantity = -1*diff \n \n wh_item = self.warehouse_item\n item = self.item \n \n final_item_ready = item.ready + reverse_adjustment_quantity\n final_wh_item_ready = wh_item.ready + reverse_adjustment_quantity\n \n if final_item_ready < 0 or final_wh_item_ready < 0 \n msg = \"Akan menyebabkan jumlah item ready menjadi : #{final_item_ready}.\"\n self.errors.add(:generic_errors, msg )\n return false\n end\n \n return true \n end", "def claim_code\n\n coupon = Coupon.find_by_code(params[:code])\n\n if (coupon)\n\n # Make sure it's 0) a coupon 1) active 2) in date range 3) not\n # previously used by anyone if it's single-use 4) not being used by\n # an old customer if for first-timers-only and 5) not previously\n # used by this customer\n\n if (!coupon.active? || Date.today < coupon.start_date || Date.today > coupon.end_date)\n # XXXFIX P2: Display coupon errors and successes near coupon? (here and below)\n return redirect_with_message('Error: coupon code is not valid', :action => 'checkout')\n end\n\n if ((coupon.single_use_only? && coupon.uses.size > 0) || (coupon.used_by?(@customer)))\n return redirect_with_message('Error: this coupon code has already been used', :action => 'checkout')\n end\n\n if (coupon.new_customers_only? && @customer.orders.size > 0)\n return redirect_with_message('Error: this coupon can only be used by new customers', :action => 'checkout')\n end\n\n session[:coupon_id] = coupon.id\n\n return redirect_with_message('Your coupon has successfully been applied!', :action => 'checkout')\n\n else\n\n # Not a coupon, see if it's a gift certificate\n gc = GiftCertificate.find_by_code(params[:code])\n\n if (gc)\n\n # Make sure the gift certificate has not been used before\n\n if (gc.used?)\n return redirect_with_message('This gift certificate has already been converted to an account credit, ' +\n 'see your account credits below', :action => 'checkout')\n end\n\n @customer.add_account_credit(gc)\n return redirect_with_message('Your gift certificate is now an account credit that will be used for this order, ' +\n 'see your account credits below', :action => 'checkout')\n\n else\n\n return redirect_with_message('Error: no matching coupon or gift certificate code was found', :action => 'checkout')\n\n end\n\n end\n\n end", "def test_set_promo_code_fixed_rebate\n # Setup\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n # Exercise\n @o.promotion_code = promo.code\n assert @o.save\n assert_equal promo, @o.promotion\n # Verify\n expected_total = @totals[:order] - promo.discount_amount\n assert_equal(\n expected_total.round(2),\n @o.total, \n \"Fixed rebate verification error.\"\n )\n end", "def must_carry_mens_or_womens_apparel\n errors.add(:mens_apparel, 'or womens apparel must be provided') unless mens_apparel || womens_apparel\n end", "def checkout_allowed?\n order_items.count > 0\n end", "def valid?\n return false if @ir.nil?\n return false if @loi.nil?\n return false if @approval_id.nil?\n return false if @calculated_max_price.nil?\n return false if @completes.nil?\n return false if @event_id.nil?\n return false if @id.nil?\n return false if @new_estimated_cost.nil?\n return false if @original_cpi.nil?\n return false if @original_estimated_cost.nil?\n return false if @project_id.nil?\n return false if @quota_group_id.nil?\n return false if @reason.nil?\n return false if @request_new_price.nil?\n return false if @required_completes.nil?\n true\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )\n parsed_discount = discount.nil? ? 0.to_d : discount.to_d\n BigDecimal.new( original_gross ) == order_amount && parsed_discount == order_discount\n end", "def invalid?\n INVALID_CODES.include? @code\n end", "def validate_pricing(promocode, submitted_promocode = nil, cart = nil)\n nil\n end", "def due_status?(order)\n order.relevant_delivery_date &&\n (order.shippable? || order.collectable?) &&\n !order.shipped_at &&\n order.collection_ready_emails.empty?\n end", "def ensure_eligible_for_confirmation\n unless @offering.confirmations_allowed?\n flash[:error] = \"We're sorry, but the confirmation process is currently disabled.\"\n redirect_to apply_url(@offering) and return\n end\n unless @user_application.passed_status?(\"fully_accepted\") || @user_application.passed_status?(\"fully_accepted_vad\")\n flash[:error] = \"You cannot go through the confirmation process until your application has been fully accepted.\"\n redirect_to apply_url(@offering) and return\n end\n end", "def valid?\n VALID_CODES.include? @code\n end", "def did_anyone_buy_this_thing?\n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items Present')\n return false\n\n end\n end", "def order_summary_failed?\n return false unless rejected?\n return true if self.EventLog =~ /Validering av summer feilet/\n false\n end", "def ensure_not_referenced_by_any_product\n if products.empty?\n return true\n else\n errors.add(:base, 'Kann nicht geloescht werden! Es gibt Produkte dieser Marke!')\n return false\n end\n end", "def promotion_credit_exists?(adjustable)\n self.adjustments.where(:adjustable_id => adjustable.id).exists?\n end", "def validate_tags_from_order_confirmation(params)\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n case true\n when params[\"do_optimizely\"]\n check_for_optimizely_function\n when params[\"do_adroll\"]\n check_for_adroll_function\n when params[\"do_ci\"]\n channel_intelligence_script.should_exist\n end\n end" ]
[ "0.66064394", "0.6550816", "0.6235409", "0.6210746", "0.6102948", "0.6055292", "0.6046318", "0.58865774", "0.5851954", "0.5834576", "0.5752221", "0.5730365", "0.57057464", "0.5651144", "0.56200117", "0.56192803", "0.55841076", "0.55555713", "0.5551097", "0.55111104", "0.55062854", "0.548842", "0.54735523", "0.5461112", "0.54552233", "0.5448228", "0.54366213", "0.5425083", "0.54115117", "0.538882", "0.5384902", "0.5376857", "0.53540146", "0.5336522", "0.53350794", "0.5318043", "0.53162783", "0.5308522", "0.5301342", "0.5299313", "0.528704", "0.52746195", "0.5262422", "0.5259577", "0.5225779", "0.5224777", "0.5223082", "0.52192944", "0.5211021", "0.5208626", "0.5206344", "0.52028346", "0.5182798", "0.5175137", "0.51585877", "0.51481354", "0.51377654", "0.51285374", "0.5124862", "0.51241887", "0.51221365", "0.51220506", "0.51219404", "0.511697", "0.51125854", "0.5101522", "0.50963855", "0.50897753", "0.50788003", "0.50720686", "0.5071191", "0.5065675", "0.506396", "0.5061992", "0.5061647", "0.50608975", "0.50486726", "0.50407547", "0.50363904", "0.50354713", "0.5032058", "0.50307435", "0.50295055", "0.5028549", "0.5005695", "0.4998984", "0.4995057", "0.49922287", "0.49921033", "0.49802676", "0.4977056", "0.49735567", "0.49734578", "0.49651197", "0.49614602", "0.49610105", "0.4960042", "0.4959997", "0.49588227", "0.49540713" ]
0.74688196
0
Attempts to apply promotions to this order. It'll return any promotions it successfully applies.
def apply_promotions! raise PromotionApplyError unless pending_promotions.empty? @promotion_results = Promotion.active.apply!(self) apply_adjustments! # Convert all the applied promotions into an array of decorated # promotions. @pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)} # If no promotions have been added to the order, they're all new. # Otherwise generate a new collection which is the difference between the # existing ones and the new ones. if previous_promotion_ids.empty? @new_promotions = pending_promotions else @new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)} @existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)} end pending_promotions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def promotions\n @promotions ||= order.promotions\n end", "def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end", "def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end", "def apply\n assign_order_attributes\n assign_payments_attributes\n\n if order.save\n order.set_shipments_cost if order.shipments.any?\n true\n else\n @errors = order.errors\n false\n end\n end", "def apply_promotion(order)\n items = order.line_items.count\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => order})\n order.reload\n if order.line_items.count == items\n return\n else\n apply_promotion(order)\n end\n end", "def existing_promotions\n @existing_promotions ||= []\n end", "def apply!\n return if @already_applied\n pointcuts.each do |pc| pc.apply! end\n @already_applied = true\n end", "def promotion_for(item)\n @promotions ||= []\n @promotions.sort_by(&:priority).reverse.detect{|pr| pr.can_apply_to?(item)}\\\n || Promotion.new( NoPromote.new )\n end", "def pending_promotions\n @pending_promotions ||= []\n end", "def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end", "def update_order\n # If there is no adjustment for the current gift package, just create one here unless there already is one for the gift package\n if self.gift_package_id && self.gift_package_id > 0 && self.adjustments.gift_packaging.where(:originator_id => self.gift_package_id).count == 0\n self.gift_package.adjust(self) \n end \n # Then update all adjustments\n self.update_adjustments\n # update the order totals, etc.\n order.update!\n end", "def apply\n # TODO: This needs to happen in parallel but can't due to the way running multiple\n # actions on a single node works. Actions work on a node and don't know about other\n # actions which are being run on that node, so in a single node environment the\n # state of a node can get weird when actions stomp all over each other.\n #\n # We should refactor this to APPLY actions to nodes and then allow them to converge\n # together before we run them. This will allow us to execute multiple actions on a node at once\n # without getting weird race conditions.\n @on_procs.each do |on_proc|\n on_proc.call\n end\n\n @on_procs.clear\n end", "def apply_coupon\n if self.behavior == 'coupon'\n item = self.item\n \n # coitem is the OrderItem to which the coupon acts upon\n coitem = self.order.order_items.visible.find_by_sku(item.coupon_applies)\n log_action \"apply_coupon: coitem was not found\" and return if coitem.nil?\n\n unless coitem.coupon_amount.zero? then\n log_action \"apply_coupon: This item is a coupon, but a coupon_amount has already been set\"\n return\n end\n \n log_action \"apply_coupon: Starting to apply coupons. total before is #{ coitem.total_cents }\"\n \n ctype = self.item.coupon_type\n if ctype == 1\n # percent rebate\n factor = self.price_cents / 100.0 / 100.0\n if self.vendor.net_prices\n coitem.coupon_amount_cents = coitem.net.fractional * factor\n else\n coitem.coupon_amount_cents = coitem.gross.fractional * factor\n end\n log_action \"apply_coupon: Applying Percent rebate coupon: price_cents is #{ self.price_cents }, factor is #{ factor }, coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 2\n # fixed amount\n coitem.coupon_amount_cents = self.price_cents\n log_action \"apply_coupon: Applying Fixed amount coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n elsif ctype == 3\n # buy x get y free\n log_action \"apply_coupon: Applying B1G1\"\n x = 2\n y = 1\n if coitem.quantity >= x\n if self.vendor.net_prices\n coitem.coupon_amount_cents = y * coitem.net.fractional / coitem.quantity\n else\n coitem.coupon_amount_cents = y * coitem.gross.fractional / coitem.quantity\n end\n log_action \"apply_coupon: Applying B1G1 coupon: coupon_amount_cents is #{ coitem.coupon_amount_cents }\"\n end\n end\n if self.vendor.net_prices\n coitem.total = coitem.net - coitem.coupon_amount\n else\n # log_action \"XXXXXXXXX #{ coitem.gross.inspect } #{ coitem.coupon_amount.inspect }\"\n coitem.total = coitem.gross - coitem.coupon_amount\n end\n log_action \"apply_coupon: OrderItem Total after coupon applied is: #{coitem.total_cents} and coupon_amount is #{coitem.coupon_amount_cents}\"\n coitem.calculate_tax\n coitem.save!\n else\n self.total -= self.coupon_amount\n end\n end", "def apply\n return return_with(:error, I18n.t('coupon.cannot_apply_reseller')) if reseller_order?\n unless reached_minimum_order?\n return return_with(:error, I18n.t('coupon.no_minimum_price', minimum: coupon.minimum_order.in_euro.to_yuan(exchange_rate: order.exchange_rate).display))\n end\n return return_with(:error, I18n.t('coupon.cannot_apply_user')) unless valid_user?\n return return_with(:error, I18n.t('coupon.cannot_apply_shop')) unless valid_shop?\n return return_with(:error, I18n.t('coupon.cannot_apply')) unless valid_order?\n return return_with(:error, I18n.t('coupon.not_valid_anymore')) unless valid_coupon?\n return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless update_order! && update_referrer! && update_coupon!\n return_with(:success)\n end", "def process_payments!\n ret = payments.each(&:process!)\n end", "def existing_promotions?\n !existing_promotions.empty?\n end", "def apply_result\n return @apply_result\n end", "def apply_promotion( promotion )\n unless has_promotion?\n promotion.adjustment_class.create! adjustable: self, \n basis: promotion.discount_amount, \n message: \"Promotional Code: #{ promotion.promotional_code }\", \n promotion: true\n end\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def execute_promotion\n begin\n self.product.promotions.where(send_post_registration_message: true).find_each do |promo|\n if self.created_at.to_date >= promo.start_on.to_date && self.created_at.to_date <= promo.end_on.to_date\n SiteMailer.delay.promo_post_registration(self, promo)\n end\n end\n rescue\n logger.debug \"problem executing a promotion\"\n end\n end", "def do_apply(msg)\n\n if msg['state'] == 'paused'\n\n return pause_on_apply(msg)\n end\n\n if msg['flavour'].nil? && (aw = attribute(:await))\n\n return await(aw, msg)\n end\n\n unless Condition.apply?(attribute(:if), attribute(:unless))\n\n return do_reply_to_parent(h.applied_workitem)\n end\n\n pi = h.parent_id\n reply_immediately = false\n\n if attribute(:scope).to_s == 'true'\n\n h.variables ||= {}\n end\n\n if attribute(:forget).to_s == 'true'\n\n h.variables = compile_variables\n h.parent_id = nil\n h.forgotten = true\n\n reply_immediately = true\n\n elsif attribute(:lose).to_s == 'true'\n\n h.lost = true\n\n elsif msg['flanking'] or (attribute(:flank).to_s == 'true')\n\n h.flanking = true\n\n reply_immediately = true\n end\n\n if reply_immediately and pi\n\n @context.storage.put_msg(\n 'reply',\n 'fei' => pi,\n 'workitem' => Ruote.fulldup(h.applied_workitem),\n 'flanking' => h.flanking)\n end\n\n filter\n\n consider_tag\n consider_timers\n\n apply\n end", "def new_promotions\n @new_promotions ||= []\n end", "def calculate(order)\n order.participants.lock!\n producers = order.participants.for_calculation\n\n each_point { |point| compute_point(order, point, producers) }\n\n self\n end", "def update\n if @order.completed?\n process_and_add_store_credit(@order)\n end\n\n return orig_update\n end", "def promotions\n Spree::Promotion.find_by_sql(\"#{order.promotions.active.to_sql} UNION #{Spree::Promotion.active.where(code: nil, path: nil).to_sql}\")\n connected_order_promotions | sale_promotions\n end", "def applyNps\r\n currentIdx = 0\r\n \r\n @sentences.each do |sentence|\r\n \r\n #right now we're just going to select the first NP per sentence... this will need to be fixed later\r\n sentence.npModels.each do |npModel|\r\n if npModel.coref\r\n \r\n #just moving on for right now...\r\n npModel.findBestMatch(currentIdx, @sentences)\r\n\r\n #handle if we have a \"they\" in there\r\n\t #TODO: could probably try reordering these rules and see\r\n\t #if we can get greater accuracy\r\n #if(Rules.findItAnt(npModel, currentIdx, @sentences))\r\n #elsif(Rules.findTheyAnt(npModel, currentIdx, @sentences))\r\n #elsif(Rules.matchPlurality(npModel, currentIdx, @sentences))\r\n #elsif(Rules.findSimilarName(npModel, currentIdx, @sentences))\r\n #else\r\n #Rules.findCorrectAnt(npModel, currentIdx, @sentences)\r\n #end\r\n end\r\n end\r\n currentIdx = currentIdx + 1\r\n end\r\n end", "def capture\n begin \n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # go through all order_payments\n order_payments = self.order_payments\n if order_payments.size == 0\n p \"No order_payments to process.\"\n raise PaymentError, \"No order_payments to process.\"\n end\n for order_payment in order_payments\n order_payment.capture!\n end\n self.upgrade_coupons!\n # update order\n self.update_attributes!(:state => Order::PAID, :paid_at => Time.zone.now)\n end\n # send confirmation email\n user = User.find_by_id(self.user_id)\n if user and user.send_confirmation(self.deal_id)\n return true\n else\n logger.error \"Order.capture: Confirmation email failed to send: #{self.inspect}\"\n return false\n end\n rescue PaymentError => pe\n p \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n rescue ActiveRecord::RecordInvalid => invalid\n p \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end", "def unapply\n return return_with(:error, I18n.t('coupon.cannot_remove')) unless unappliable_order?\n return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless reset_order! && reset_coupon!\n return_with(:success)\n end", "def compute(object)\n return 0, [] if self.preferred_buy_number_of_items_x.blank? or \n self.preferred_buy_number_of_items_x == 0 or\n self.preferred_get_number_of_items_y.blank? or \n self.preferred_get_number_of_items_y == 0 or\n self.preferred_at_z_percent_off.blank? or\n self.preferred_at_z_percent_off == 0\n \n #puts \"Buy #{self.preferred_buy_number_of_items_x} Get #{self.preferred_get_number_of_items_y} at #{self.preferred_at_z_percent_off}% Off\"\n \n save_test = lambda do |calculator, options={}|\n #puts \" save test: #{options[:count] % (self.preferred_buy_number_of_items_x + self.preferred_get_number_of_items_y) >= self.preferred_buy_number_of_items_x}\"\n options[:count] % (self.preferred_buy_number_of_items_x + self.preferred_get_number_of_items_y) >= self.preferred_buy_number_of_items_x\n end\n \n save_value = lambda do |calculator, line_item|\n #puts \" save value: #{calculator.preferred_at_z_percent_off / 100.0 * line_item.price}\"\n calculator.preferred_at_z_percent_off / 100.0 * line_item.price\n end\n \n add_false_items_to_current = lambda do |calculator, line_item|\n true\n end\n \n compute_line_items(object, save_value, linked_object: LineItemPromotionCredit, save_test: save_test, add_false_items_to_current: add_false_items_to_current)\n end", "def apply(taxes)\n @order.line_items.each do |item|\n taxed_items = taxes.line_item_taxes.select { |i| i.item_id == item.id }\n update_adjustments(item, taxed_items)\n end\n\n @order.shipments.each do |item|\n taxed_items = taxes.shipment_taxes.select { |i| i.item_id == item.id }\n update_adjustments(item, taxed_items)\n end\n end", "def test_cleanup_promotion_order_finished\n # Setup - add promotion and complete order\n setup_new_order_with_items()\n promo = promotions(:fixed_rebate)\n @o.promotion_code = promo.code\n @o.order_status_code = order_status_codes(:ordered_paid_to_ship)\n assert @o.save\n \n # Now expire the promo\n assert promo.update_attributes({\n :start => Date.today - 2.weeks,\n :end => Date.today - 1.week\n })\n promo.reload\n @o.reload\n \n # Update something on the order, like an admin would.\n # Maybe we shipped out the order and changed the status code.\n @o.order_status_code = order_status_codes(:sent_to_fulfillment)\n assert [email protected]_promotion_be_applied?(promo)\n assert @o.save\n \n @o.reload\n \n # Check to see if promotion is still applied (it should be!)\n assert_equal promo, @o.promotion\n assert_kind_of OrderLineItem, @o.promotion_line_item\n end", "def apply_coupon!(order, coupon)\n CouponHandler.new(nil, order.coupon, order).update_order!\n CouponHandler.new(nil, order.coupon, order).update_coupon!\nend", "def apply_to_order(user, order, session)\n cc = @data_object\n cc.cc_order_id = order.order_id\n pay = gen_payment\n $store.transaction do \n pay.apply_to_order(user, order, cc.cc_amount, session)\n cc.cc_pay_id = pay.pay_id\n save\n end\n end", "def applicable?(promotable)\n promotable.is_a?(Spree::Order)\n end", "def matching_products\n if compute_on_promotion?\n calculable.promotion.rules.map do |rule|\n rule.respond_to?(:products) ? rule.products : []\n end.flatten\n end\n end", "def process_payments!\n if group_buy\n process_payments_with(:authorize!)\n else\n process_payments_with(:purchase!)\n end\n end", "def matching_products\n # Regression check for #1596\n # Calculator::PerItem can be used in two cases.\n # The first is in a typical promotion, providing a discount per item of a particular item\n # The second is a ShippingMethod, where it applies to an entire order\n #\n # Shipping methods do not have promotions attached, but promotions do\n # Therefore we must check for promotions\n if self.calculable.respond_to?(:promotion)\n self.calculable.promotion.rules.map(&:products).flatten\n end\n end", "def maybe_promote\n return unless promote?\n promote!\n end", "def process\n # self.update_attributes(state: 'processing')\n interactor = \"::#{self.handler.class.name}::#{self.action_name.camelcase}\".constantize\n context = interactor.call({\n product_instance: self.product_instance,\n handler: self.handler,\n job: self,\n })\n if context.failure?\n self.error_messages ||= []\n self.error_messages << context.errors if context.errors.present?\n self.save\n end\n context\n end", "def finalize!\n # lock all adjustments (coupon promotions, etc.)\n all_adjustments.each{|a| a.close}\n\n # update payment and shipment(s) states, and save\n #updater.update_payment_state\n shipments.each do |shipment|\n shipment.update!(self)\n shipment.finalize!\n end\n\n updater.update_shipment_state\n save!\n updater.run_hooks\n\n touch :completed_at\n if self.created_by_customer?\n unless self.vendor.try(:auto_approve_orders)\n if !confirmation_delivered?\n self.deliver_vendor_confirmation\n elsif confirmation_delivered? && self.approver_id\n self.deliver_vendor_confirmation(true)\n end\n # changing this so that customer will receive an order confirmation email when order is updated\n # only send if order was created by customer (otherwise will be sent after transition to approve)\n deliver_order_confirmation_email\n end\n end\n\n consider_risk\n end", "def apply(cart)\n coupon = self\n result = {\n :success => true,\n :msg => 'Coupon is applied'\n }\n unless coupon.nil? #check expiration\n if coupon.expired?\n result[:success] = false\n result[:msg] = \"Coupon is expired\"\n end\n if result[:success]\n if coupon.min_price > 0 # check coupon min price\n if coupon.min_price > cart.total_price\n result[:success] = false\n result[:msg] = \"Your order sum is smaller than coupon minimal sum\"\n end\n end\n end\n unless cart.user.nil? # check if coupon was already used\n if UsedCoupon.where(:user_id => cart.user_id, :coupon_id => coupon.id).any?\n result[:success] = false\n result[:msg] = \"You have already used this coupon\"\n end\n end\n if result[:success] # calculate discount if coupon works\n result[:new_sum_display] = ActionController::Base.helpers.number_to_currency(cart.total_price - coupon.value)\n result[:new_sum] = cart.total_price - coupon.value\n unless cart.coupon_id == coupon.id\n cart.update_attribute :coupon_id, coupon.id\n end\n end\n else\n result[:success] = false\n result[:msg] = \"Coupon not found\"\n end\n result\n end", "def compute(order)\n debug = false\n puts order if debug\n \n total_price , total_weight , shipping = 0 , 0 , 0 \n prices = self.preferred_price_table.split.map {|price| price.to_f }\n puts prices.join(\" \") if debug\n \n order.line_items.each do |item| # determine total price and weight\n total_weight += item.quantity * (item.variant.weight || self.preferred_default_weight)\n total_price += item.price * item.quantity\n end\n puts \"Weight \" + total_weight.to_s if debug\n puts \"Price \" + total_price.to_s if debug\n return 0.0 if total_price > self.preferred_max_price \n # determine handling fee\n puts \"Handling max \" + self.preferred_handling_max.to_s if debug\n handling_fee = self.preferred_handling_max < total_price ? 0 : self.preferred_handling_fee\n puts \"Handling \" + handling_fee.to_s if debug\n weights = self.preferred_weight_table.split.map {|weight| weight.to_f} \n puts weights.join(\" \") if debug\n while total_weight > weights.last # in several packages if need be\n total_weight -= weights.last\n shipping += prices.last\n end\n puts \"Shipping \" + shipping.to_s if debug\n index = weights.length - 2\n while index >= 0\n break if total_weight > weights[index] \n index -= 1\n end\n shipping += prices[index + 1] \n puts \"Shipping \" + shipping.to_s if debug\n\n return shipping + handling_fee \n end", "def publish!\n # Transaction ensures we do not create an order without order_items\n begin\n Order.transaction do\n order.save!\n create_order_items(order)\n calculate_total\n\n apply_promotion_to_order(params) if params[:promotion_code]\n end\n order\n rescue ActiveRecord::RecordInvalid => e\n order.tap { |o| o.errors.add(:base, \"This Product does not exist.\") }\n rescue ActiveRecord::RecordNotFound => e\n order.tap { |o| o.errors.add(:base, \"This Product does not exist.\") }\n rescue NoOrderItemsGiven => e\n order.tap { |o| o.errors.add(:base, e.message) }\n rescue InvalidPromoCodeGiven => e\n order.tap { |o| o.errors.add(:base, e.message) }\n rescue ActionController::ParameterMissing => e\n order.tap { |o| o.errors.add(:base, e.message) }\n end\n end", "def apply_coupon_code\n if params[:order] && params[:order][:coupon_code]\n @order.coupon_code = params[:order][:coupon_code]\n\n handler = PromotionHandler::Coupon.new(@order).apply\n\n if handler.error.present?\n flash.now[:error] = handler.error\n respond_with(@order) { |format| format.html { render :edit } } and return\n elsif handler.success\n flash[:success] = handler.success\n end\n end\n end", "def apply\n invoke_deferred_logics\n return if advices.empty?\n\n define_methods_for_advice_blocks\n add_to_instances unless @options[:existing_methods_only]\n apply_to_methods unless @options[:new_methods_only]\n add_method_hooks unless @options[:existing_methods_only]\n # TODO: clear deferred logic results if they are not used in any advice\n self\n end", "def promotions\n adjustments.where( promotion: true )\n end", "def process_order\n @order.process!\n redirect_to root_path\n end", "def new_promotions?\n !new_promotions.empty?\n end", "def process_coupom\n @orders_csv.each do |oc|\n coupom = @coupons[oc.coupom_id]\n @orders_hash[oc.id].compute(coupom) if coupom && coupom.valid?\n end\n end", "def apply_coupon_code\n if params[:order] && params[:order][:coupon_code]\n @order.coupon_code = params[:order][:coupon_code]\n\n handler = PromotionHandler::Coupon.new(@order).apply\n\n if handler.error.present?\n flash.now[:error] = handler.error\n respond_with(@order) { |format| format.html { render :edit } } && return\n elsif handler.success\n flash[:success] = handler.success\n end\n end\n end", "def perform\n candidates.each { |candidate| propose(candidate) }\n @matches\n end", "def distribute_all_answers_if_none_pending\n # only execute if text changed\n if self.changes.keys.include?(\"text\") && self.changes[\"text\"].first.blank?\n answers = self.question.answers\n if answers.pending.count == 0\n AnswerMailer.all_answers(self.question, answers.pluck(:email)).deliver\n end\n end\n end", "def save_and_apply\n self.save\n self.apply\n end", "def applied\n @applied ||= []\n end", "def apply\n started_at = DateTime.now.to_s\n # Check if a Puppetfile is neccesary for use/not use librarian-puppet\n check_puppetfile_content\n # Copy static modules that are not downloaded by librarian-puppet\n copy_static_modules\n # Apply step and if the process is succesful create the checkpoint.\n process_status = apply_step\n create_step_checkpoint(started_at) if process_status.success?\n process_status\n end", "def procesar\n\t\t\tcase @estado\n\n\t\t\t#Estado = Inactiva, la maquina se llena\t\n\t\t\twhen 1\n\t\t\t\tif @maquinaA != nil\n\t\t\t\t\tif @prodAlmacen < @cantPA\t\t\t\n\t\t\t\t\t\t@prodAlmacen += @maquinaA.getProvisiones(@cantPA - @prodAlmacen) \n\t\t\t\t\t\tif @prodAlmacen == @cantPA\n\t\t\t\t\t\t\t@estado = 4\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t@estado = 1\t\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t@estado = 4\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t@estado = 4\n\t\t\t\tend\n\n\t\t\t#Estado = Procesando, la maquina esta procesando su insumo\n\t\t\twhen 2\n\t\t\t\t@cicloActual += 1\n\t\t\t\tif @cicloActual == @cicloMax\n\t\t\t\t\t@estado \t= 3\n\t\t\t\t\t@cantProduc = @cantProduc + (@cantMax * (1 - @desecho))\n\t\t\t\t\t@prodAlmacen = 0\n\t\t\t\t\t@cicloActual = 0\n\t\t\t\tend\n\n\t\t\t#Estado = En espera, la maquina esta esperando a que la \n\t\t\t#proxima maquina este inactiva para podor darle insumos\n\t\t\twhen 3\n\t\t\t\tif @cantProduc == 0\n\t\t\t\t\t@estado = 1\n\t\t\t\tend\n\n\t\t\t#Estado = Lleno, la maquina esta lista para procesar su\n\t\t\twhen 4\n\t\t\t\tif @cicloMax == 0\n\t\t\t\t\t@cantProduc = @cantProduc + @cantMax * (1 - @desecho)\n\t\t\t\t\t@prodAlmacen = 0\n\t\t\t\t\t@estado = 3\n\t\t\t\telse\n\t\t\t\t\t@estado = 2\n\t\t\t\tend\n\t\tend\n\tend", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def perform(_options = {})\n raise 'perform should be implemented in a sub-class of PromotionAction'\n end", "def perform(_options = {})\n raise 'perform should be implemented in a sub-class of PromotionAction'\n end", "def applyPrize(m)\n nLevels = m.getLevelsGained\n self.incrementLevels (nLevels)\n nTreasures = m.getTreasuresGained\n \n if nTreasures > 0\n dealer = CardDealer.instance\n nTreasures.times do\n treasure = dealer.nextTreasure\n @hiddenTreasures << treasure\n end\n end\n \n end", "def process\n actions = []\n changes = { modified: [], added: [], removed: [] }\n\n while pending?\n if (item = @queue.pop).first.is_a?(Symbol)\n actions << item\n else\n item.each { |key, value| changes[key] += value }\n end\n end\n\n _run_actions(actions)\n return if changes.values.all?(&:empty?)\n Runner.new.run_on_changes(*changes.values)\n end", "def update!\n update_totals\n update_payment_state\n # update_adjustments\n # update totals a second time in case updated adjustments have an effect on the total\n update_totals\n \n update_attributes_without_callbacks({\n :state => \"complete\"\n }) \n \n logger.info 'UPDATED ORDER'\n # update_hooks.each { |hook| self.send hook }\n end", "def process\n save_as(:processing)\n perform_checks\n initiate_delivery\n capture_payment\n save_as(:processed)\n end", "def perform\n if user = User.for_receipt(receipt)\n receipt.process! && perform_for_user(user)\n else\n receipt.reject!\n end\n\n true\n end", "def compute results\n @pack.each_with_p do | face, p |\n new_hand = self + face\n new_hand.adjust_prob p\n r = new_hand.result\n if r then\n results[ r ] += new_hand.probability\n else\n new_hand.compute results\n end\n end\n end", "def call\n return broadcast(:has_supports) if @opinion.votes.any?\n\n transaction do\n change_opinion_state_to_withdrawn\n reject_emendations_if_any\n end\n\n broadcast(:ok, @opinion)\n end", "def processOrder\n \n end", "def process\n process_moves\n reassign_team_sets\n reset_quantitative_data\n #notify\n end", "def finalize!\n # lock all adjustments (coupon promotions, etc.)\n all_adjustments.each{|a| a.close}\n\n # update payment and shipment(s) states, and save\n updater.update_payment_state\n shipments.each do |shipment|\n shipment.update!(self)\n shipment.finalize!\n end\n\n updater.update_shipment_state\n save!\n updater.run_hooks\n\n touch :completed_at\n\n # Deshabilitamos el envio de correos estandar de spree para gestionarlo de forma personalizada.\n # deliver_order_confirmation_email unless confirmation_delivered?\n\n consider_risk\n end", "def compute\n @balance = @principal\n @transactions = []\n\n @rates.each do |rate|\n amortize(rate)\n end\n\n # Add any remaining balance due to rounding error to the last payment.\n unless @balance.zero?\n @transactions.find_all(&:payment?)[-1].amount -= @balance\n @balance = 0\n end\n\n if @rates.length == 1\n @payment = self.payments[0]\n else\n @payment = nil\n end\n\n @transactions.freeze\n end", "def process_order_payment\n \n return \"No Order Paid Date not found, order NOT PROCESSED\" if self.paid_date.blank?\n return \"No Order Paid Amount not found, order NOT PROCESSED\" if self.paid_amount.blank?\n return \"No Order Ref Name not found, order NOT PROCESSED\" if self.name.blank? \n return \"No Order Ref Id not found, order NOT PROCESSED\" if self.order_master_id.blank? \n \n return \"Paid Amount #{self.paid_amount} is less than ORDER AMOUNT #{self.order_master.grand_total}\" if self.paid_amount.to_i < self.order_master.grand_total.to_i\n \n order_master = OrderMaster.new\n return order_master.process_order self.order_master_id\n \n end", "def changes_applied\n unless defined?(@attributes)\n mutations_from_database.finalize_changes\n end\n @mutations_before_last_save = mutations_from_database\n forget_attribute_assignments\n @mutations_from_database = nil\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def related_promotions\n @related_promotions ||= Promotions::Relevance.to_category(self)\n end", "def applyPrize(m)\n incrementLevels(m.getLevelsGained)\n \n if(m.getTreasuresGained > 0)\n dealer=CardDealer.instance\n \n i=0\n while(i<m.getTreasuresGained)\n @hiddenTreasures.push(dealer.nextTreasure)\n i = i+1\n end\n \n end\n \n end", "def compute(order)\n rate = self.calculable\n tax = 0\n\n if rate.tax_category.is_default\n order.adjustments.each do | adjust |\n next if adjust.originator_type == \"TaxRate\"\n next if adjust.originator_type == \"ShippingMethod\" and not Spree::Config[:shipment_inc_vat]\n\n tax += (adjust.amount * rate.amount).round(2, BigDecimal::ROUND_HALF_UP)\n end\n end\n\n order.line_items.each do | line_item|\n if line_item.product.tax_category #only apply this calculator to products assigned this rates category\n next unless line_item.product.tax_category == rate.tax_category\n else\n next unless rate.tax_category.is_default # and apply to products with no category, if this is the default rate\n end\n tax += (line_item.price * rate.amount).round(2, BigDecimal::ROUND_HALF_UP) * line_item.quantity\n end\n\n tax\n end", "def settle_payments_if_desired\n @settlement_results = { \"errors\" => [], \"status\" => [] }\n\n op = nil\n\n unless @order.canceled?\n while options[\"ok_capture\"] && @order.outstanding_balance > 0 && op = pick_payment { |opp| opp.pending? && opp.amount > 0 && opp.amount <= @order.outstanding_balance }\n rescue_gateway_error { op.capture! }\n end\n\n while options[\"ok_partial_capture\"] && @order.outstanding_balance > 0 && op = pick_payment { |opp| opp.pending? && opp.amount > 0 && opp.amount > @order.outstanding_balance }\n # Spree 2.2.x allows you to pass an argument to\n # Spree::Payment#capture! but this does not seem to do quite\n # what we want. In particular the payment system treats the\n # remainder of the payment as pending.\n op.amount = @order.outstanding_balance\n rescue_gateway_error { op.capture! }\n end\n\n while options[\"ok_void\"] && @order.outstanding_balance <= 0 && op = pick_payment { |opp| opp.pending? && opp.amount > 0 }\n rescue_gateway_error { op.void_transaction! }\n end\n\n while options[\"ok_refund\"] && @order.outstanding_balance < 0 && op = pick_payment { |opp| opp.completed? && opp.can_credit? }\n rescue_gateway_error { op.credit! } # remarkably, THIS one picks the right amount for us\n end\n end\n\n # collect payment data\n @order.payments.select{|op| op.amount > 0}.each do |op|\n @settlement_results[\"status\"] << { \"id\" => op.id, \"state\" => op.state, \"amount\" => op.amount, \"credit\" => op.offsets_total.abs }\n end\n end", "def compute_on_promotion?\n @compute_on_promotion ||= calculable.respond_to?(:promotion)\n end", "def redo\n return unless pending = self.pending\n\n pending.redo\n\n self.applied = pending\n self.pending = pending.next\n end", "def compute(order)\n options = Order.thread_options\n if options[:skip_tax]\n 0.0\n else\n #@@original_compute.bind(self).call(order)\n # this is a bit of a cheat but we are going with the assumption that\n # all items have the same tax rate - this is a very large win performance\n # wise when you have a large number of line items\n rate = self.calculable\n order.line_items.inject(0) {|sum, line_item|\n sum += line_item.total * rate.amount\n }\n end\n end", "def apply_coupons(cart, coupons)\n counter = 0\n # doesn't break if there is no coupon\n while counter < coupons.length\n # check coupons to see if it matches any of our cart items\n cart_item = find_item_by_name_in_collection(coupons[counter][:item], cart)\n # does the coupon item exist in the cart? change name to add \"W/COUPON\"\n couponed_item_name = \"#{coupons[counter][:item]} W/COUPON\"\n cart_item_with_coupon = find_item_by_name_in_collection(couponed_item_name, cart)\n # checks if the item is in the cart and that the count satisfies the coupon reqs\n # doesn't break if the coupon doesn't apply to any items\n if cart_item && cart_item[:count] >= coupons[counter][:num]\n # can apply multiple coupons\n if cart_item_with_coupon\n cart_item_with_coupon[:count] += coupons[counter][:num]\n cart_item[:count] -= coupons[count][:num]\n else\n # adds the coupon price to the property hash of couponed item\n cart_item_with_coupon = {\n :item => couponed_item_name,\n # adds the coupon price to the property hash of couponed item\n :price => coupons[counter][:cost] / coupons[counter][:num],\n # adds the count number to the property hash of couponed item\n :count => coupons[counter][:num],\n # remembers if the item was on clearance\n :clearance => cart_item[:clearance]\n }\n cart << cart_item_with_coupon\n # removes the number of discounted items from the original item's count\n cart_item[:count] -= coupons[counter][:num]\n end\n end\n counter += 1\n end\n cart\nend", "def compute(object)\n computing_line_items = line_items_for_compute(object)\n return unless object.present? and computing_line_items.present?\n \n item_total = computing_line_items.map(&:amount).sum\n value = item_total * self.preferred_flat_percent / 100.0\n return (value * 100).round.to_f / 100, computing_line_items.collect {|line_item| LineItemPromotionCredit.new(line_item: line_item, quantity: line_item.quantity_available(self))}\n end", "def distribute_production_result\n return nil if self.is_confirmed == false \n \n ok_quantity = self.ok_quantity\n repairable_quantity = self.repairable_quantity\n broken_quantity = self.broken_quantity \n \n sales_item_subcription = self.sales_item_subcription\n \n if sales_item_subcription.pending_production_sales_items.count == 0 \n raise ActiveRecord::Rollback, \"Call tech support!\" \n return\n end\n \n \n total_pending = sales_item_subcription.pending_production ## aggregate over all shite \n \n sales_item_subcription.pending_production_sales_items.each do |sales_item| \n assigned_ok_quantity = 0\n assigned_repairable_quantity = 0 \n assigned_broken_quantity = 0 \n \n # if there is nothing else to distribute, just break. \n # stop the shit. and move on \n if ok_quantity == 0 and repairable_quantity == 0 and broken_quantity == 0 \n break \n end\n \n if sales_item.pending_production >= ok_quantity and ok_quantity != 0 \n assigned_ok_quantity = ok_quantity \n ok_quantity = 0 \n else\n assigned_ok_quantity = sales_item.pending_production \n ok_quantity = ok_quantity - sales_item.pending_production \n end\n \n # the post production order is assigned only once in the beginning\n if repairable_quantity != 0 \n assigned_repairable_quantity = repairable_quantity\n repairable_quantity = 0 \n end\n \n if broken_quantity != 0 \n assigned_broken_quantity = broken_quantity\n broken_quantity = 0 \n end\n \n ProductionHistory.create_history( sales_item_subcription, self, sales_item , {\n :ok_quantity => assigned_ok_quantity, \n :repairable_quantity => assigned_repairable_quantity, \n :broken_quantity => assigned_broken_quantity \n }) \n end\n end", "def collect!\n return nil if collected? || paid_out?\n\n self.class.transaction do\n update_attribute :collected, true\n\n # set ALL OTHER bounty claims from nil to false, and reject\n if issue\n issue.bounty_claims.each { |bounty_claim| bounty_claim.update_attributes!(collected: false, rejected: true) unless bounty_claim == self }\n\n # set issue to paid_out\n issue.update_attribute(:paid_out, true)\n\n if issue.fiat?\n #set bounty_claim.amount to the sum of all the bounties that have been set to paid -- this will not handle paying out claims multiple times..\n payout_amount = issue.bounties.where(status: Bounty::Status::ACTIVE).sum(:amount)\n update_attribute :amount, payout_amount\n\n #update active bounties' status to paid (not refunded)\n issue.bounties.active.update_all(status: Bounty::Status::PAID)\n\n # payout! it raises on its own if something goes wrong\n payout! if payout_amount > 0\n else\n CryptoPayOut.create(issue: issue, person: person, type: 'ETH::Payout')\n end\n\n # update email template, email backers of bounty claim\n issue.backers.find_each { |backer| backer.send_email(:bounty_claim_accepted_backer_notice, bounty_claim: self) }\n\n issue&.update_bounty_total\n elsif pact\n puts \"before loop\"\n\n pact.bounty_claims.each do |bounty_claim| \n puts \"inside loop\"\n puts bounty_claim.id\n puts bounty_claim.inspect\n\n begin\n bounty_claim.update_attributes!(collected: false, rejected: true) unless bounty_claim == self \n puts \"updated\"\n rescue Exception => ex\n puts ex.inspect\n raise ex\n end\n\n end\n\n puts \"after loop\"\n\n pact.update_attribute(:paid_at, Time.now)\n\n #set bounty_claim.amount to the sum of all the bounties that have been set to paid -- this will not handle paying out claims multiple times..\n payout_amount = pact.bounties.where(status: Bounty::Status::ACTIVE).sum(:amount)\n update_attribute :amount, payout_amount\n\n #update active bounties' status to paid (not refunded)\n pact.bounties.active.update_all(status: Bounty::Status::PAID)\n\n # payout! it raises on its own if something goes wrong\n payout! if payout_amount > 0\n\n # update email template, email backers of bounty claim\n pact.backers.find_each { |backer| backer.send_email(:bounty_claim_accepted_backer_notice, bounty_claim: self) }\n\n issue&.update_bounty_total\n end\n\n MixpanelEvent.track(\n person_id: person_id,\n event: 'Awarded Bounty Claim',\n issue_id: issue_id,\n type: unanimously_accepted? ? 'vote' : 'time'\n )\n\n # create event\n BountyClaimEvent::Collected.create!(bounty_claim: self)\n\n # email developer that his/her claim has been collected, with messages from backers\n person.send_email(:bounty_claim_accepted_developer_notice, bounty_claim: self, responses: accepted_responses_with_messages)\n end\n\n self\n end", "def redo\n\t\tself.apply()\n\tend", "def run\n while ( rcs = remaining_candidates ).any?\n rcs.each do | candidate |\n while !candidate.exhausted_preferences? && candidate.free?\n candidate.propose_to_next_preference\n end\n end\n end\n self\n end", "def update_purchasable_attributes\n present_order_items.each { |oi| oi.update_purchasable_attributes }\n end", "def update_status_paid()\n if stock_available?\n # Reduce stock once paid to prevent someone creating lots of unpaid orders which would stop others making purchases.\n # This should really be in a transaction but unlikely to have problems due to race condition.\n update!(status: PAID)\n ScriptLog.info(\"order_id #{id} is now PAID #{btc_address.address}:#{payment_received}\")\n reduce_product_stock()\n ScriptLog.info(\"order_id #{id} product_id #{product.id} stock reduced to #{product.stock}\")\n else\n update!(status: PAID_NO_STOCK)\n ScriptLog.info(\"order_id #{id} is now PAID_NO_STOCK #{btc_address.address}:#{payment_received}\")\n end\n end", "def handle_physical_items(order)\n physical_items = []\n order.line_items.each do |item|\n next unless item.product.physical_product?\n\n physical_items << item\n product = Product.find(item.product.id)\n product.decrement_quantity(item.quantity)\n end\n return unless physical_items.length.positive?\n\n physical_items.each do |item|\n # TODO: Actually do something in here... probably?\n # add to string that gets sent in email\n end\n begin\n OrderMailer.physical_item_purchased(order.user_id, order.id).deliver_later\n rescue StandardError => e\n ExceptionNotifier.notify_exception(ActiveRecord::ActiveRecordError.new(self), env: request.env, data: { message: \"Failed trying to send physical product order email for #{order.to_yaml}: #{e.message}\" })\n end\n end", "def order_success\n begin\n @order = (flash[:order_id] ? Order.find(flash[:order_id]) : @customer.orders.last)\n\n flash.keep(:order_id) # Keep the order ID around in case of a reload\n\n if request.post?\n if params[:customer]\n @order.customer.update_attributes( params[:customer] )\n end\n end\n\n rescue Exception => e\n ExceptionNotifier::Notifier.exception_notification(request.env, e).deliver\n @order = nil\n end\n\n @upsell_products = []\n if ! @order.andand.university_id\n @upsell_products = @customer.andand.postcheckout_upsell_recommend(1, 2, @order)\n end\n end", "def related_promotions?\n !related_promotions.empty?\n end", "def remove_quantity_promotions\n if @basket_item.type == \"PurchasingItem\"\n using_promotions_count = UsingPromotion.where(basket_id: @basket_item.basket_id)\n .group(:promotion_id)\n .count\n using_promotions_count.each do | promotion_id, cnt |\n promotion = Promotion.find(promotion_id)\n item_cnt = BasketItem.where(basket_id: @basket_item.basket_id,\n item_id: @basket_item.item_id)\n .count - 1\n if promotion.item_id == @basket_item.item_id &&\n cnt * promotion.item_quantity > item_cnt\n UsingPromotion.where( basket_id: @basket_item.basket_id,\n promotion_id: promotion.id)\n .first\n .destroy\n end\n end\n end\n end", "def execute_work!\n save_receipts = event_store.with_transaction do\n pending_saves.map(&:call)\n end\n\n @pending_saves = []\n\n save_receipts.each do |reciept|\n message_bus.publish_events(reciept.id, reciept.klass, reciept.events,\n reciept.meta.merge(meta))\n end\n\n self\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def activate_orders(token, coupon,card_id)\n order_with_coupon = self.orders.where(\"state = ? and coupon_id is not ?\", \"paused\", nil).first\n order_with_coupon.assign_attributes(coupon_id: coupon[\"id\"]) if coupon.present? && order_with_coupon.present?\n order_with_coupon.assign_attributes(coupon_id: nil) if order_with_coupon.present? && coupon.blank?\n\n\n if order_with_coupon.present?\n order_with_coupon.save(validate: false)\n order_with_coupon.update_total_and_item_total\n end\n\n paused_orders = self.orders.where(state: 'paused')\n\n paused_orders.each_with_index do |order, index|\n order.assign_attributes(state: \"confirm\",\n delivery_date: FIRST_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 0\n order.assign_attributes(state: \"confirm\",\n delivery_date: SECOND_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 1\n order.assign_attributes(state: \"confirm\",\n delivery_date: THIRD_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 2\n order.assign_attributes(creditcard_id: card_id)\n order.save(validate: false)\n end\n end", "def fulfill_order\n return Order.format_order(process_customer_order)\n end", "def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end", "def apply(invoice)\n invoice.invoice_items.each do |invoice_item|\n if BUY_ONE_GET_ONE_FREE_CODES.include?(invoice_item.product_code)\n invoice_item.charged_count = (invoice_item.count.to_f / 2).ceil\n end\n end\n\n next_rule.apply(invoice)\n end", "def process_pending\n process_nested and process_relations\n pending_nested.clear and pending_relations.clear\n _reset_memoized_descendants!\n end", "def perform!\n run_callbacks(:before_perform, self)\n self.class.upcoming_mailings\n .in_batches(of: self.class.batch_size)\n .each do |batch|\n run_callbacks(:on_perform, self, batch)\n batch.each(&:process!)\n end\n run_callbacks(:after_perform, self)\n nil\n end" ]
[ "0.64268756", "0.61746866", "0.60649604", "0.5835612", "0.55584973", "0.55160064", "0.54326624", "0.53392017", "0.5239044", "0.5236701", "0.51956725", "0.51830184", "0.5129507", "0.51139766", "0.50788236", "0.5071204", "0.5035513", "0.49953207", "0.4930564", "0.49168912", "0.49112818", "0.4905973", "0.49010575", "0.48214543", "0.48133668", "0.48043877", "0.47976354", "0.4783432", "0.47597504", "0.4757763", "0.47555605", "0.47393072", "0.47264272", "0.47250345", "0.47225374", "0.47090563", "0.4684087", "0.46796033", "0.4668448", "0.46570227", "0.46514514", "0.46511653", "0.46493515", "0.4642265", "0.46411648", "0.4623166", "0.46093702", "0.4608156", "0.4603287", "0.4602726", "0.45920163", "0.4584614", "0.45829174", "0.45767877", "0.45741114", "0.45654806", "0.45643204", "0.4561505", "0.4561505", "0.45574468", "0.45393863", "0.45379", "0.45352337", "0.45313102", "0.45285583", "0.4528484", "0.45281747", "0.45265907", "0.4523654", "0.45104524", "0.450864", "0.44937685", "0.4491108", "0.44851714", "0.44802767", "0.44797748", "0.44671524", "0.44655088", "0.44646832", "0.4464181", "0.44606695", "0.44546515", "0.44545305", "0.44516617", "0.44274136", "0.44231588", "0.44160804", "0.4412613", "0.4411926", "0.44100925", "0.44030398", "0.44000873", "0.43980902", "0.43894064", "0.43880066", "0.4387249", "0.43849522", "0.43784562", "0.43664292", "0.43607637" ]
0.8107721
0
Dc(p;q) ==> if p.nullable then Dc(p);q | Dc(q) else Dc(p);q
def Sequence(from) n = from.elements.length alt = @factory.Alt() for i in 0...n first = recurse(from.elements[i]) if first p = @factory.Sequence() p.elements << first unless first.Epsilon? for j in i+1...n p.elements << @copier.copy(from.elements[j]) end alt.alts << p else break end break unless @nullable.recurse(from.elements[i]) end alt.alts.empty? ? nil : alt end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def or_d\n end", "def mark_nullable\n rules.each do |prod|\n if prod.empty?\n prod.nullable = true\n else\n # If all rhs members are all nullable, then rule is nullable\n prod.nullable = prod.rhs.members.all?(&:nullable?)\n end\n end\n end", "def direct_nullable\n nullables = Set.new\n # Direct nullable nonterminals correspond to empty productions\n rules.each do |prod|\n next unless prod.empty?\n\n prod.lhs.nullable = true\n nullables << prod.lhs\n end\n\n nullables\n end", "def new_dsnf_rules_for_conjunction\n end", "def or_c\n end", "def m_ar_or_chain_1\n Rows.where(:x || :y)\n end", "def nil_operand?\n left.nil? || right.nil?\n end", "def and_d\n end", "def or(other)\n if self && !self.nil?\n self\n else\n other\n end\n end", "def nil?\n @x.nil? || @y.nil? || @f.nil?\n end", "def or_d8\n end", "def optional?(field)\n field.type.type_sym == :union &&\n field.type.schemas.first.type_sym == :null\n end", "def cf_or ( a, b )\r\n# Combine for 'A or B'\r\n if a>0 and b>0\r\n a + b - a*b\r\n elsif a<0 and b<0\r\n a + b + a*b\r\n else\r\n (a + b) / ( 1 - [a.abs, b.abs].min )\r\n end\r\nend", "def compute_nullable\n non_terminals.each { |nterm| nterm.nullable = false }\n nullable_sets = [direct_nullable]\n\n # Drop productions with one terminal in rhs or with a nullable lhs\n filtered_rules = rules.reject do |prod|\n prod.lhs.nullable? || prod.rhs.find do |symb|\n symb.kind_of?(Terminal)\n end\n end\n\n (1...non_terminals.size).each do |i|\n new_nullables = Set.new\n filtered_rules.each do |a_prod|\n rhs_nullable = a_prod.rhs.members.all? do |symb|\n nullable_sets[i - 1].include? symb\n end\n if rhs_nullable\n a_prod.lhs.nullable = true\n new_nullables << a_prod.lhs\n end\n end\n break if new_nullables.empty?\n\n filtered_rules.reject! { |prod| prod.lhs.nullable? }\n nullable_sets[i] = nullable_sets[i - 1].merge(new_nullables)\n end\n\n mark_nullable\n end", "def _invert_filter(cond, invert)\n if invert == :or_null\n ~SQL::Function.new(:coalesce, cond, SQL::Constants::SQLFALSE)\n else\n super\n end\n end", "def or_nil\n get_or_else(nil)\n end", "def nullable(entity)\n return entity unless entity[:nullable]\n\n entity.merge(nullable: nil, any_of: [{ type: 'null' }]) do |k, old, new|\n next unless k == :any_of\n\n old + new\n end\n end", "def _reduce_443(val, _values, result)\n result = s(:nil) \n result\nend", "def null?\n car.nil? && cdr.nil?\n end", "def new_simplification_rules_for_conjunction\n end", "def _reduce_444(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_444(val, _values, result)\n result = s(:nil) \n result\nend", "def null?; @null; end", "def default_when_null(sql, default)\n \"COALESCE (#{sql}, #{dispatch(default)})\"\n end", "def null?; false end", "def and_c\n end", "def optionalize\n without_values(nil)\n end", "def concat_null(fields) # :nodoc:\n @concat.gsub(/\\%s/, subs(@nul, fields).join(','))\n end", "def compact\n reject(&:nil?)\n end", "def to_sparql(**options)\n \"COALESCE(#{operands.to_sparql(delimiter: ', ', **options)})\"\n end", "def exclusive_or (p,q)\n p ^ q\nend", "def disjunct_select(arr , *prc_arr)\n arr.select!{ |ele|prc_arr.any?{|prc| prc.call(ele) } }\nend", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def _reduce_507(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_507(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_507(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_507(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_507(val, _values, result)\n result = s(:nil) \n result\nend", "def nil?() end", "def nil?() end", "def detached?; x.nil? && y.nil?; end", "def can_conciliate_or_null?\n !(nuller_id.present? || approver_id.present?)\n end", "def can_conciliate_or_null?\n !(nuller_id.present? || approver_id.present?)\n end", "def f4(x:, x: nil); end", "def is_null\n @value, @operator = nil, :is_null\n self\n end", "def *(other)\n\t\tif other.respond_to?(\"d\")\n return Fraccion.new(@n*other.n, @d*other.d)\n else\n return Fraccion.new(other*@n,@d)\n end\n\tend", "def coalesce exprs, na = \"'NA'\"\n return exprs.map{|expr| coalesce(expr)} if Array === exprs\n return exprs if exprs.is_mandatory\n Expression.new(\"COALESCE(#{exprs}, #{na})\", exprs.type_num, true)\n end", "def option(criteria = T.unsafe(nil)); end", "def not_nil!(*args)\n if args.any?{|arg| arg.nil?}\n coercion_error!\n end\n args\n end", "def reduce_optional(_production, _range, _tokens, _children)\n multiplicity(0, 1)\n end", "def positive(from: T.unsafe(nil), to: T.unsafe(nil)); end", "def _reduce_697(val, _values, result)\n result = :\"**nil\"\n\n result\nend", "def nil?; false; end", "def nil?() true; end", "def _reduce_486(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_none(val, _values, result); end", "def _reduce_none(val, _values, result); end", "def _reduce_508(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_508(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_508(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_508(val, _values, result)\n result = s(:nil) \n result\nend", "def |(p0) end", "def |(p0) end", "def |(p0) end", "def |(p0) end", "def |(p0) end", "def |(p0) end", "def sibling_condition\n self[parent_col_name] ? \"#{prefixed_parent_col_name} = #{self[parent_col_name]}\" : \"(#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\"\n end", "def or_b\n end", "def should_add_two_nil_values()\n # We need to decide what we expect the result of nil + nil is\n expected = 0\n\n calc = Calculator.new\n result = calc.add(nil, nil)\n equal?(result, expected)\n end", "def test_NilClass_InstanceMethods_Or\n\t\tassert_equal(false, nil | false)\n\t\tassert_equal(true, nil | 99)\n\tend", "def and_d8\n end", "def vd(s, a, d)\n r = v(s, a)\n # NOTE: If the potential return is not of the same type,\n # we should return something appropriate (ie, the default)\n # FIXME: Throw error on class inequality?\n if r.nil || r.class != d.class\n return d\n else\n return r\n end\nend", "def _reduce_none( val, _values, result )\r\n result\r\n end", "def first_object(arg1, arg2, arg3)\n arg1 || arg2 || arg3 || nil\nend", "def test_or_implies(stmt)\n l = eval_side(stmt.left)\n r = eval_side(stmt.right)\n if !l.nil? && !l\n set_truth(stmt.right.left) if stmt.right.type == :terminal\n elsif !r.nil? && !r\n set_truth(stmt.left.left) if stmt.left.type == :terminal\n end\n end", "def is_not_null\n @operator = :is_null\n @negated = true\n self\n end", "def _reduce_509(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_509(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_509(val, _values, result)\n result = s(:nil) \n result\nend", "def disjunct_select(arr, *prc_arr)\n arr.select { |el| prc_arr.any? { |prc| prc.call(el) } }\nend", "def _reduce_none( val, _values, result )\n result\n end", "def _reduce_none( val, _values, result )\n result\n end", "def default?; return !explicit?; end", "def orden_nodos(g,d)\r\n return Cola.new(g.grafo[d])\r\n end", "def optional_positionals; end", "def field(criteria = T.unsafe(nil)); end", "def compact\n reject{|key,val| val.nil? }\n end", "def initialize(a = 0, b = 0, c = 0, d = 0)\n @a = a unless a.nil?\n @b = b unless b.nil?\n @c = c unless c.nil?\n @d = d unless d.nil?\n end", "def set_null(params)\n params == \"NA\" ? \"null\" : params\n end", "def fix_subset_operators(dc)\n if (dc.subset_operators)\n dc.subset_operators.each do |subset|\n subset.value.high.instance_variable_set(:@unit, nil) if subset.value.respond_to?(:high) && subset.value.try(:high).try(:unit).try(:strip).try(:empty?)\n subset.value.low.instance_variable_set(:@unit, nil) if subset.value.respond_to?(:low) && subset.value.try(:low).try(:unit).try(:strip).try(:empty?)\n subset.value = nil if subset.type == 'TIMEDIFF' && subset.value.is_a?(HQMF::AnyValue)\n end\n end\n end", "def disjunction_expressions(left_expression, left_expression_joins, right_expression,\n right_expression_joins)\n if left_expression == ALWAYS_TRUE || right_expression == ALWAYS_TRUE\n [ALWAYS_TRUE, []]\n elsif left_expression == ALWAYS_FALSE\n [right_expression, right_expression_joins]\n elsif right_expression == ALWAYS_FALSE\n [left_expression, left_expression_joins]\n else\n [left_expression | right_expression, left_expression_joins + right_expression_joins]\n end\n end" ]
[ "0.6111057", "0.55405974", "0.5517789", "0.54893196", "0.5447858", "0.54364324", "0.5403116", "0.53899294", "0.5335949", "0.52456355", "0.52122486", "0.5193818", "0.513197", "0.51035094", "0.5073621", "0.5058647", "0.5007375", "0.49914598", "0.49744928", "0.49601877", "0.49572363", "0.49572363", "0.49221757", "0.48995563", "0.48971087", "0.4896208", "0.48937786", "0.48886177", "0.48824662", "0.48789483", "0.48771545", "0.48598197", "0.4846803", "0.4846803", "0.4846803", "0.4846803", "0.4846803", "0.4846803", "0.4846803", "0.4846803", "0.4846803", "0.4846803", "0.48149392", "0.48149392", "0.48149392", "0.48149392", "0.48149392", "0.48087743", "0.48087743", "0.48015416", "0.47725874", "0.47725874", "0.4731349", "0.47306493", "0.47253543", "0.47165647", "0.4712669", "0.4686422", "0.4675142", "0.46725795", "0.4645504", "0.46413782", "0.46370345", "0.46245646", "0.45932522", "0.45932522", "0.45910168", "0.45910168", "0.45910168", "0.45910168", "0.45782727", "0.45782727", "0.45782727", "0.45782727", "0.45782727", "0.45782727", "0.45726964", "0.45694852", "0.45582294", "0.45546228", "0.45518917", "0.454382", "0.454314", "0.4542022", "0.45402378", "0.45399088", "0.45337158", "0.45337158", "0.45337158", "0.45314828", "0.45303392", "0.45303392", "0.45248348", "0.45245934", "0.45239118", "0.45221657", "0.45185858", "0.4517199", "0.45164678", "0.45156145", "0.4512695" ]
0.0
-1
Dc(p) ==> if p.nullable then Dc(p) else Dc(p);p
def Regular(from) d = recurse(from.arg) nil if d.nil? if !from.many return d else s = @factory.Sequence() s.elements << d s.elements << @factory.Regular(@copier.copy(from.arg), true, true) return s end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def null?; @null; end", "def nullable\n self['nullable']\n end", "def null?; false end", "def mark_nullable\n rules.each do |prod|\n if prod.empty?\n prod.nullable = true\n else\n # If all rhs members are all nullable, then rule is nullable\n prod.nullable = prod.rhs.members.all?(&:nullable?)\n end\n end\n end", "def cp_d\n end", "def or_d\n end", "def normal(p)\n return nil # FIX ME\n end", "def aggregate_treat_undefined_attributes_as_default_value?; end", "def nullable?\n @nullable\n end", "def nullable?\n @nullable\n end", "def nullable?\n @nullable\n end", "def field(criteria = T.unsafe(nil)); end", "def is_null()\n res = super(context,self)\n return res\n end", "def nullable(entity)\n return entity unless entity[:nullable]\n\n entity.merge(nullable: nil, any_of: [{ type: 'null' }]) do |k, old, new|\n next unless k == :any_of\n\n old + new\n end\n end", "def getValue(value)\n return nil if value==nil \n return value\nend", "def nil?() end", "def nil?() end", "def null?\n true\n end", "def nil?() true; end", "def nil_value\n Validation.new { |d| d.nil? }\n end", "def dp\n @dp ||= dps.first\n end", "def null_record\n @null_record\n end", "def default_when_null(sql, default)\n \"COALESCE (#{sql}, #{dispatch(default)})\"\n end", "def nil?; false; end", "def null?\n false\n end", "def null?\n false\n end", "def set_null(params)\n params == \"NA\" ? \"null\" : params\n end", "def is_pdc?\n false\n end", "def null?(field_info, field)\n field_info[\"notnull\"] == 1 && self.send(field).blank?\n end", "def null\n end", "def null?\n car.nil? && cdr.nil?\n end", "def direct_nullable\n nullables = Set.new\n # Direct nullable nonterminals correspond to empty productions\n rules.each do |prod|\n next unless prod.empty?\n\n prod.lhs.nullable = true\n nullables << prod.lhs\n end\n\n nullables\n end", "def name\n d= Doctor.find_by(email: email)\n if d \n d.d_name\n else\n email\n end\n end", "def vd(s, a, d)\n r = v(s, a)\n # NOTE: If the potential return is not of the same type,\n # we should return something appropriate (ie, the default)\n # FIXME: Throw error on class inequality?\n if r.nil || r.class != d.class\n return d\n else\n return r\n end\nend", "def nullify(bool)\n bool ? bool : nil\n end", "def null?(record)\n type.nullable? && record[:header][:field_nulls][position]\n end", "def test_NilClass_InstanceMethod_to_c\n\t\tassert_equal(Complex(0,0), nil.to_c)\n\tend", "def null \n return @raw.null \n end", "def default?; return !explicit?; end", "def null?\n true\n end", "def or_nil\n get_or_else(nil)\n end", "def value\n virtual? ? content : value_card&.value\nend", "def birth_date\n object.demographics&.birth_date&.to_date&.to_s\n end", "def is_null\n @value, @operator = nil, :is_null\n self\n end", "def definition_for_nil_entry\n reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES)\n ref_id = nil\n unless reference.nil?\n ref_id = \"#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}\"\n end\n reference_criteria = @data_criteria_references[strip_tokens(ref_id)] unless ref_id.nil?\n if reference_criteria\n # we only want to copy the reference criteria definition, status, and code_list_id if this is this is not a grouping criteria (i.e., there are no children)\n if @children_criteria.blank?\n @definition = reference_criteria.definition\n @status = reference_criteria.status\n if @specific_occurrence\n @title = reference_criteria.title\n @description = reference_criteria.description\n @code_list_id = reference_criteria.code_list_id\n end\n else\n # if this is a grouping data criteria (has children) mark it as derived and only pull title and description from the reference criteria\n @definition = 'derived'\n if @specific_occurrence\n @title = reference_criteria.title\n @description = reference_criteria.description\n end\n end\n else\n puts \"MISSING_DC_REF: #{ref_id}\" unless @variable\n @definition = 'variable'\n end\n end", "def must_have_value?()\n return @df_int == nil\n end", "def replace_null(value)\n return 'U' if value.nil?\n\n value\nend", "def option(criteria = T.unsafe(nil)); end", "def nil?\n true\n end", "def nil?\n true\n end", "def nil_value?\n casted_value.nil?\n end", "def is_not_null\n @operator = :is_null\n @negated = true\n self\n end", "def optionalize\n without_values(nil)\n end", "def nullable?\n mode == \"NULLABLE\"\n end", "def optional?(field)\n field.type.type_sym == :union &&\n field.type.schemas.first.type_sym == :null\n end", "def null?\n false\n end", "def _d(*_); end", "def scaffold_null_condition(field)\n [\"#{scaffold_table_name}.#{field} IS NULL\"]\n end", "def direct_dependency(type, result = T.unsafe(nil)); end", "def fields?; @fields; end", "def nil?\n @data.nil?\n end", "def nil?\n @date.nil?\n end", "def optional; end", "def null?\n false\n end", "def field(p,field_name)\n f = p.fields.find {|f| f.name == field_name}\n if f.nil? then\n return nil\n else\n return f.value\n end\nend", "def null?\n false\n end", "def null?\n false\n end", "def detached?; x.nil? && y.nil?; end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def nullables\r\n []\r\n end", "def district_code\n district.try(:code)\n end", "def cdr\n @value2\n end", "def nils_to(nv, *keys) return self if nv.nil? || !value?(nil)\n dup.nils_to!(nv, *keys)\n end", "def nil?\n return true\n end", "def nullable?\n subtype.nullable?\n end", "def f4(x:, x: nil); end", "def set_ps_arg_nil(cps, i)\n cps.setNull(i, JavaSQL::Types::NULL)\n end", "def maybe(f)\n ->(value) { value.nil? ? nil : f.call(value) }\n end", "def maybe_get_noncomplex_default_value(to_dtype) #:nodoc:\n default_value = 0\n unless self.stype == :dense then\n if self.dtype.to_s.start_with?('complex') and not to_dtype.to_s.start_with?('complex') then\n default_value = self.default_value.real\n else\n default_value = self.default_value\n end\n end\n default_value\n end", "def preconditions\n !column.null && column.default.nil? && !primary_field? && !timestamp_field? && !column.default_function\n end", "def nil?\n @x.nil? || @y.nil? || @f.nil?\n end", "def density\n if super.nil? then\n 100\n else\n super\n end\n end", "def density\n if super.nil? then\n 100\n else\n super\n end\n end", "def build_null_object(value)\n Class.new(base_class) {\n @option = value\n @index = 0\n delegate :blank?, :nil?, :to => :option\n }.new\n end", "def tv_side\n get_fields_for(:tv).each do |field|\n if self.send(field).nil?\n return nil\n end\n end\n return true\n end", "def soft?\n column = @reflection.active_record.column_for_attribute(@reflection.foreign_key)\n\n column.null == true || column.default.to_s == '0'\n end", "def nilOrEmpty(data, alt)\n \t\tif data == nil || data.length == 0\n \t\t\talt\n \t\telse\n \t\t\tdata\n \t\tend\n \tend", "def dp\n dps.first\n end", "def build_has_one_child_if_nil(parent, child_name)\n child_obj = parent.send(child_name) # equivalent to calling something like @foster.home\n build_attribute_name_template = \"build_#{child_name}\" # e.g. \"build_personal_preference\"\n\n if child_obj.nil?\n # run the dynamic rails method to build a has_one child of the parent model instance\n # e.g. @foster.build_dog_preference\n child_obj = parent.send(build_attribute_name_template)\n end\n\n return child_obj\n end", "def map_null(ident, &block) ; map_primitive(:null, ident, &block) ; end", "def set_ps_arg_nil(cps, i)\n cps.setNull(i, cps.getParameterMetaData.getParameterType(i))\n end", "def droid; end", "def null_record?\n self == self.class.null_record\n end" ]
[ "0.56643915", "0.54442513", "0.53735656", "0.53655064", "0.5306141", "0.525573", "0.5211456", "0.5209688", "0.5204604", "0.5204604", "0.5204604", "0.51663", "0.51604635", "0.5147444", "0.5140661", "0.5118258", "0.5118258", "0.5064584", "0.502612", "0.5008557", "0.49975446", "0.4991012", "0.49869943", "0.4978524", "0.49743432", "0.49743432", "0.4957867", "0.49418828", "0.49173012", "0.49044663", "0.48910472", "0.48883283", "0.48693258", "0.4858044", "0.4840064", "0.48104587", "0.48068923", "0.47982556", "0.4787169", "0.47827202", "0.4771194", "0.4764451", "0.4754654", "0.47473216", "0.47323164", "0.4717251", "0.4711294", "0.471078", "0.46981877", "0.46981877", "0.46968418", "0.46868435", "0.46827257", "0.4671844", "0.46681163", "0.46675494", "0.466068", "0.46543822", "0.46497765", "0.46215773", "0.4616262", "0.46137983", "0.46088877", "0.4605597", "0.46044186", "0.45905024", "0.45905024", "0.45803848", "0.45789906", "0.45789906", "0.45789906", "0.45789906", "0.45789906", "0.45789906", "0.45789906", "0.45789906", "0.45789906", "0.45789906", "0.45789608", "0.45751846", "0.4573112", "0.457274", "0.45663723", "0.4564378", "0.4561667", "0.45606512", "0.45568794", "0.45469075", "0.45434538", "0.45407817", "0.45407817", "0.45324588", "0.45318246", "0.4530865", "0.45256174", "0.45252693", "0.45249745", "0.4523342", "0.4522607", "0.4515073", "0.4513433" ]
0.0
-1
Dc(p?) ==> if Dc(p) != error then Dc(p)? else empty
def Opt(from) p = recurse(from.arg) p ? @factory.Opt(p) : @factory.Epsilon() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_pdc?\n false\n end", "def debit_factype_null_perdu\n test = init_test('Debit (Facture) avec factype NULL mais sans labour ni pulve associes', LOW)\n Debit.find(:all).each do |facture| \n if facture.factype_id.equal?(Factype.find_by_name('null').id) && facture.pulves.empty? && facture.labours.empty?\n test.num += 1\n error = init_error(facture.name, facture.id, 'factures', '')\n test.errors << error\n end\n end\n test.result = (test.num == 0) \n return test\n end", "def error?()\n #This is a stub, used for indexing\n end", "def error?\n !@data['error'].nil?\n end", "def error?\n !@data['error'].nil?\n end", "def invalid_ndcs *ndc\n Validators::NDC.new invalid: ndc\n end", "def or_d\n end", "def not_errored?\n errors.values.map(&:empty?).reduce(true, &:&) == true\n end", "def pda?(*)\n end", "def cp_d\n end", "def druid_is_valid\n errors.add(:druid, 'is not valid') unless valid_druid?\n end", "def error?\n [email protected]?(NOT_SET)\n end", "def api_error\n dm_data.first.first == \"errors\"\n end", "def error?\n !error.blank?\n end", "def must_have_value?\n return @df_str == nil\n end", "def error?\n self.State == P2::DS_STATE_ERROR\n end", "def check_domain\n dcsize = @dem.params[\"cellsize\"].to_i\n dd = austal_param(\"dd\").to_i\n nx = austal_param(\"nx\").to_i\n ny = austal_param(\"ny\").to_i\n if ((@dem.params[\"ncols\"] * dcsize) < (nx * dd + @x0)) ||\n ((@dem.params[\"nrows\"] * dcsize) < (ny * dd + @y0))\n puts \"WARNING: Calculation area is outside the DEM domain!\"\n puts \"Recommended values:\"\n puts \"dd #{dd}\"\n puts \"ny #{(@dem.params[\"ncols\"] * dcsize - @x0) / dd + 2}\"\n puts \"nx #{(@dem.params[\"nrows\"] * dcsize - @y0) / dd + 2}\"\n end\n end", "def empty?\n @errors.empty? && @children.all?(&:empty?)\n end", "def error?\n attributes['error'] != 0\n end", "def empty?\n cage.nil?\n end", "def error?; end", "def error?; end", "def error?; end", "def valid?\n fetch { errors.empty? }\n end", "def diag_required\n return if self.vis_type == TELE_VISIT # patient-created visits have no diagnosis\n hcp_codes = hcp_proc_codes.split(',') rescue nil\n return unless hcp_codes.any?\n hcp_codes.each do |code|\n proc = Procedure.find_by(code: code) \n if proc.diag_req\n errors.add(:diag_code, \"Diagnosis is required for this visit\") if diag_code.blank?\n return\n end\n end\n end", "def control_sin_items_comprobantes\n if [detalles].any? {|detalle| detalle.any? }\n self.errors[:base] = \"error que queres hacer?\"\n return false\n end \n end", "def error?\n not @error.nil?\n end", "def improper_pair?\n @cdr != NULL\n end", "def sanity_check\n if self[:length] < 10\n raise DRDA::RespError, \"DDM Length is too short.\"\n elsif self[:length2] < 4\n raise DRDA::RespError, \"DDM Length2 is too short.\"\n elsif self[:length]-6 != self[:length2]\n raise DRDA::RespError, \"Codepoint: 0x#{self[:codepoint].to_s(16)} DDM Length2 (0x#{self[:length2].to_s(16)}) isn't six less than Length (0x#{self[:length].to_s(16)})\"\n end\n end", "def missing_dp_lpi_records(cadid=false)\n # FIXME - The CONCAT() functions in this query are to ensure that NULL\n # values get coerced into empty strings. In the import CSV, the value\n # |\"\"| is recorded as \"\", whereas || is recorded as NULL, and sometimes\n # one is present in the LGA import and another in the LPI import.\n connection.query(%{\n SELECT title_reference } + (cadid ? \", cadastre_id\" : \"\") + %{\n FROM land_and_property_information_records AS lpi_records\n LEFT JOIN local_government_area_records AS lga_records\n ON lga_records.local_government_area_id = lpi_records.local_government_area_id\n AND lga_records.dp_plan_number = lpi_records.plan_label\n AND CONCAT('', lga_records.dp_section_number) = CONCAT('', lpi_records.section_number)\n AND CONCAT('', lga_records.dp_lot_number) = CONCAT('', lpi_records.lot_number)\n WHERE lpi_records.plan_label LIKE 'DP%%'\n AND lga_records.dp_plan_number IS NULL\n AND lpi_records.local_government_area_id = %d\n AND lpi_records.retired = FALSE\n } % [id])\n end", "def invalidPatientId\n@patients =Patient.where(\"patient_number =?\",@commands[1])\n\tif @patients.size == 0\n\t\treturn true\t\n\tend \nreturn false\nend", "def invalidPatientId\n@patients =Patient.where(\"patient_number =?\",@commands[1])\n\tif @patients.size == 0\n\t\treturn true\t\n\tend \nreturn false\nend", "def invalidPatientId\n@patients =Patient.where(\"patient_number =?\",@commands[1])\n\tif @patients.size == 0\n\t\treturn true\t\n\tend \nreturn false\nend", "def error?\n !error.nil?\n end", "def db_empty? #TODO: Better version needed (i.e is it child empty? property empty? etc)\n\t\treturn @db.empty? rescue return true\n\tend", "def ok?\n !@error\n end", "def empty?\n @errors.empty?\n end", "def vd(s, a, d)\n r = v(s, a)\n # NOTE: If the potential return is not of the same type,\n # we should return something appropriate (ie, the default)\n # FIXME: Throw error on class inequality?\n if r.nil || r.class != d.class\n return d\n else\n return r\n end\nend", "def invalid_card(card_error: T.unsafe(nil)); end", "def design_data_filled_in?\n !self.description.blank? && \n !self.platform.blank? && \n !self.product_type.blank? && \n !self.project.blank? &&\n !self.design_directory.blank? &&\n !self.incoming_directory.blank?\n end", "def valid?\n data\n end", "def valid?\n data\n end", "def error?\n !! @error\n end", "def donnerErreur()\n return @grilleEnCours.firstDifference(@grilleBase)\n end", "def error?\n return !ok?\n end", "def has_error?\n !(error.nil? || error.empty?)\n end", "def has_error?\n !(error.nil? || error.empty?)\n end", "def error?\n !!@error\n end", "def error?\n !!@error\n end", "def error?\n !error.nil?\n end", "def error?\n !error.nil?\n end", "def invalid; end", "def invalid_data\n {\n :title => \"\",\n :description => nil,\n :parent_id => \"ss\"\n } \n end", "def valid?\n return false if @dd_service.nil?\n true\n end", "def deleted?\n return true if !@data and !@id\n return false\n end", "def test_datapoint_desc(dsobj)\n errors = []\n dshash = get_dshash(dsobj)\n\n # iterate over each datapoint\n dshash['datapoints'] .each { |datapoint|\n dphash = get_dphash(datapoint)\n\n # is the description size less than 10 characters in length?\n if ( dphash['desc'].to_s.size < 10)\n # yes -- record an error\n errors.push(\"datapoint \\\"\" + dphash['name'] + \"\\\" description is empty or sparse\")\n end\n\n }\n\n return(errors)\n end", "def errors?\n @statistics[:error] != 0\n end", "def invalid?\n @ref.invalid?\n end", "def failedG(g, gi, gv)\n not nullG(g, gi, gv) and f(g, gi, gv)\nend", "def test_dsdesc(dsobj)\n error = nil\n dshash = get_dshash(dsobj)\n\n # is the description size less than 10 characters in length?\n if ( dshash['desc'].to_s.size < 10)\n # yes -- record an error\n error = \"datasource description is empty or sparse\"\n end\n\n return(error)\n end", "def and_d\n end", "def error?\n true\n end", "def valid; end", "def error?\n false\n end", "def value?(p0) end", "def valid?\r\n self.error.nil?\r\n end", "def error?\n !!@error\n end", "def has_value?(p0) end", "def derivative(error,dt)\n return @kd*(error - @previous_error)/dt\n end", "def due_date_nameurl_not_empty?(dd)\n dd.deadline_name.present? || dd.description_url.present?\n end", "def error?\n @error\n end", "def error?\n @error\n end", "def check_detalles\n detalles.reload if errors.size > 0\n end", "def dry?\n key?(:d) && true\n end", "def returns_nil_bad\n 3 # error: Returning value that does not conform to method result type\n end", "def error?\n self.error || false\n end", "def errors\n return super unless ldp_object.present?\n ldp_object.errors\n end", "def valid_ddah?(url_token: nil)\n ddah =\n Ddah.includes(:duties, assignment: %i[position applicant])\n .find_by_url_token(url_token)\n\n unless ddah\n render status: 404, inline: \"No ddah found with id='#{url_token}'\"\n return false\n end\n\n @ddah = ddah\n end", "def patient_does_not_have_diagnosis?\n encounter_type = EncounterType.find_by name:OUTPATIENT_DIAGNOSIS\n encounter = Encounter.joins(:type).where(\n 'patient_id = ? AND encounter_type = ? AND DATE(encounter_datetime) = DATE(?)',\n @patient.patient_id, encounter_type.encounter_type_id, @date\n ).order(encounter_datetime: :desc).first\n\n encounter.blank?\n end", "def error?\n error\n end", "def error; state == 'failed' ? @doc['error'] : nil; end", "def empty?() end", "def empty?() end", "def empty?() end", "def presence_of_dob\n\t\tif dob.blank?\n\t\t\terrors.add(:dob, ActiveRecord::Error.new(\n\t\t\t\tself, :base, :blank, { \n\t\t\t\t\t:message => \"Date of birth can't be blank.\" } ) )\n\t\tend\n\tend", "def lac_exist?\n if params[:lac_id]\n @lac = Lac.where(:id => params[:lac_id]).first\n elsif params[:lac_temperature] and params[:lac_temperature][:lac_id]\n @lac = Lac.where(:id => params[:lac_temperature][:lac_id]).first\n params[:lac_temperature].delete(:lac_id)\n end\n redirect_to errors_page_path, :notice => 'Le lac existe pas.' if !@lac\n end", "def patient_does_not_have_dispensation?\n encounter_type = EncounterType.find_by name:DISPENSING\n encounter = Encounter.joins(:type).where(\n 'patient_id = ? AND encounter_type = ? AND DATE(encounter_datetime) = DATE(?)',\n @patient.patient_id, encounter_type.encounter_type_id, @date\n ).order(encounter_datetime: :desc).first\n\n encounter.blank?\n end", "def must_have_value?()\n return @df_int == nil\n end", "def validation_error_check_discrepancies(ar, fields)\n\t\tmsgs = []\n\t\t# get the list of fields that have errors (err_fields)\n\t\terr_fields = []\n\t\tar.errors.each {|k,v| err_fields << k}\n\t\t# identify fields missing from the record’s errors \n\t\tmissing_errors = []\n\t\tfields.each do |field_name|\n\t\t\tmissing_errors << field_name unless err_fields.include?(field_name) #if ar.errors[field_name].blank?\n\t\tend\n\t\tif missing_errors.length > 0\n\t\t\tmsgs << \"missing validation error for fields #{missing_errors.join(', ')}\"\n\t\tend\n\t\t# identify unexpected fields in the record’s errors\n\t\tunexpected_errors = []\n\t\terr_fields.each do |field_name|\n\t\t\tunexpected_errors << field_name unless fields.include?(field_name)\n\t\tend\n\t\tif unexpected_errors.length > 0\n\t\t\tmsgs << \"unexpected errors for fields #{unexpected_errors.join(', ')}\"\n\t\tend\n\t\tif msgs.length > 0\n\t\t\tassert false, msgs.join(\".\\r\")\n\t\tend\n\tend", "def patient_does_not_have_prescription?\n encounter_type = EncounterType.find_by name:TREATMENT\n encounter = Encounter.joins(:type).where(\n 'patient_id = ? AND encounter_type = ? AND DATE(encounter_datetime) = DATE(?)',\n @patient.patient_id, encounter_type.encounter_type_id, @date\n ).order(encounter_datetime: :desc).first\n\n encounter.blank?\n end", "def patient_diagnosis_date_is_after_dob\n\t\tif !patient.nil? && !patient.diagnosis_date.blank? && \n\t\t\t!dob.blank? && patient.diagnosis_date < dob\n#\t\t\t!pii.nil? && !pii.dob.blank? && patient.diagnosis_date < pii.dob\n\t\t\terrors.add('patient:diagnosis_date', \"is before study_subject's dob.\") \n\t\tend\n\tend", "def failed?\n error.present?\n end", "def refute_empty(obj, msg = T.unsafe(nil)); end", "def conn_errors?\n [email protected]?\n end", "def test_necessary_existence_of_deceased\n puts \"*** START OF TEST DECEASED ***\"\n puts \"PERSON DEC FLAG is #{@person.deceased}\"\n @person.deceased = nil\n assert [email protected]\n check_for_error(\"is not included in the list\", @person, :deceased)\n \n \n end", "def empty?\n @errors.empty?\n end", "def empty?\n @errors.empty?\n end", "def invalid\n @invalid\n end", "def check(data)\n\t\tdata.blank? ? 'N/A' : data\n\tend", "def empty?\n @errors.empty?\n end", "def conversion_error?\n ipaper_document && ipaper_document.conversion_status == 'ERROR'\n end" ]
[ "0.55279815", "0.537246", "0.52150273", "0.5210245", "0.5210245", "0.5196373", "0.5165818", "0.5144689", "0.5063147", "0.5058004", "0.5054476", "0.5034367", "0.5015428", "0.5010071", "0.50047207", "0.4997223", "0.49520013", "0.4928947", "0.49130532", "0.48762658", "0.4871541", "0.4871541", "0.4871541", "0.48674265", "0.4846629", "0.48453265", "0.48379028", "0.48317486", "0.4819933", "0.48192608", "0.48180777", "0.48180777", "0.48180777", "0.4812216", "0.4801905", "0.47965723", "0.4792094", "0.47913614", "0.4786763", "0.47863582", "0.47847885", "0.47847885", "0.4781851", "0.4773786", "0.47733784", "0.47731593", "0.47731593", "0.47723493", "0.47723493", "0.47705203", "0.47705203", "0.47635382", "0.47503054", "0.47497422", "0.47478977", "0.4746443", "0.47462246", "0.4743235", "0.47405368", "0.47277397", "0.4724523", "0.47176212", "0.47156593", "0.4706731", "0.4705288", "0.4704674", "0.47040224", "0.46951112", "0.4690852", "0.46835053", "0.4680784", "0.4680784", "0.46805114", "0.46792635", "0.46785772", "0.46734673", "0.4672667", "0.4671502", "0.46700805", "0.4669382", "0.4669114", "0.4667701", "0.4667701", "0.4667701", "0.46540493", "0.4650575", "0.46457002", "0.46445018", "0.46407872", "0.46361163", "0.46338657", "0.4633459", "0.4631742", "0.46233392", "0.4622459", "0.4619773", "0.4619773", "0.46116802", "0.4611207", "0.4606973", "0.46019137" ]
0.0
-1
identifier representing a remote object
def Ref(from) return checkToken(Symbol) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remote_id; end", "def object_id() end", "def __object_unique_id__\n name\n end", "def __object_unique_id__\n name\n end", "def obj_id\n uri.split('/').last\n end", "def obj_id\n uri.split('/').last\n end", "def object_identifier\n [\"#{self.class.name}\", (id.nil? ? nil : \"##{id}\"), \":0x#{self.object_id.to_s(16)}\"].join\n end", "def objname\n id\n end", "def to_id(obj)\n current_server.to_id(obj)\n end", "def __id; @id || @obj.id; end", "def object_id\n object.object_id\n end", "def id\n object_id\n end", "def remote_object(object)\n\t if object.kind_of?(RemoteID)\n\t\tobject\n\t else object.sibling_on(self)\n\t end\n\tend", "def objectFromNetId _args\n \"objectFromNetId _args;\" \n end", "def id\n object.object_id\n end", "def id\n object.external_id\n end", "def id\n object[\"id\"]\n end", "def __object_unique_id__\n return @args[:data][:Key_name]\n end", "def server_object_id\n self.parameters[:server_object_id]\n end", "def id\n object.id\n end", "def id\n object.id\n end", "def id\n @obj['id']\n end", "def getId()\n @obj.getId()\n end", "def oid\n id(get_oid())\n end", "def oid\n self.elements[:object_i_d]\n end", "def id\n object.id.to_s\n end", "def hash\n object_id\n end", "def inspect\n object_identifier\n end", "def remote_id\n @remote_id || Proc.new { @remote_id or raise \"remote-id has not been set yet!\" }\n end", "def inspect\n self.object_id\n end", "def loser_id\n return self.send(\"#{loser}_id\".intern)\n end", "def identify(*args, **kwargs)\n ObjectIdentifier.(self, *args, **kwargs)\n end", "def obj\n @obj ||= master_class.find(remote_id)\n end", "def id\n object.to_param\n end", "def id\n __id\n end", "def local_id; end", "def _fedora_object(id)\n id_segments = id.to_s.split('/')\n connection.find(id_segments[1])\n end", "def get_object_id object\n object.respond_to?(:id) ? object.id : object\n end", "def id() end", "def id\n self[:identifier]\n end", "def get_id(obj)\n\t\[email protected][obj]\n\tend", "def sobject_id\n sobject.id\n end", "def reference\n object.id.to_s\n end", "def register_id(object, type, remote_id, local_id)\n @keymap[type.to_s][remote_id] = local_id\n c = object.class\n while !['Object', 'ActiveRecord::Base'].include?(c.name)\n @keymap[c.name][remote_id] = local_id\n c = c.superclass\n end\n end", "def owner_id\n @delegated_to_object.nsid\n end", "def id\n @id || self.class.name.underscore.split('/').last #gsub('/', '_')\n end", "def urn_id; :id end", "def urn_id; :id end", "def identifier\n send(self.class.identifier)\n end", "def real_id\n @id\n end", "def real_id\n @id\n end", "def id\n object.id.to_i\n end", "def id\n name.gsub(':', '-')\n end", "def id\n raise Errno::ENOENT, \"This object has been deleted.\" if self.deleted?\n raise \"No ID on object.\" if !@id\n return @id\n end", "def identifier\n @info.identifier\n end", "def identifier\n @info.identifier\n end", "def external_id; end", "def __id__() end", "def _id\n @id\n end", "def user_id\n # The user id can't be handled by the method_missing magic from\n # OctocatHerder::Base, since the id method returns the object\n # id.\n @raw['id']\n end", "def ident\n return \"#{self.owner}/#{self.name}\"\n end", "def id\n GitlabSchema.id_from_object(object)\n end", "def identifier; end", "def identifier; end", "def uri_to_object_key(remote_file)\n # `path` is `[5]` in the returned result of URI.split\n URI.split(remote_file)[5][1..-1]\n end", "def id\n \"#{kind}_#{@id}\"\n end", "def id\n \"#{kind}_#{@id}\"\n end", "def target_id\n RssLog.all_types.each do |type|\n obj_id = send(\"#{type}_id\".to_sym)\n return obj_id if obj_id\n end\n nil\n end", "def id_for(_name, _id=nil)\n n = \"#{@object_name}_#{_name}\"\n n += \"_#{_id}\" if _id\n end", "def server_id\n @host.id\n end", "def object_name; end", "def object_name; end", "def object_name; end", "def server_id\n self.delegate\n end", "def make_ref_from_oid(object_type, object_id)\n return \"/#{object_type}/#{object_id}\"\n end", "def id\n Id.new(@head.fetch[2])\n end", "def neo_id\n getId\n end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; 1; end", "def id_for(obj)\n \"#{obj.class.name.underscore}-#{obj.id}\"\n end", "def handle_remote_id\n \"_search_id\"\n end", "def dom_id\n \"#{self.class.name.gsub(/:+/,\"_\")}_#{self.object_id}\"\n end", "def id()\n #This is a stub, used for indexing\n end", "def unique_id\n object_id.abs.to_s(16)\n end", "def id_string\n return \"user_\"+self.username\n end", "def rp_id; end", "def typed_id\n self.class.name + ':' + self.id.to_s\n end", "def neo_id\n getId\n end", "def dom_id(object)\n object.class.to_s.tableize + '_' + object.id.to_s\n end", "def identifier\n fetch_response.display_identifier\n end" ]
[ "0.7822269", "0.76745987", "0.7253405", "0.7253405", "0.7185132", "0.7185132", "0.7117979", "0.7068104", "0.7068056", "0.70438373", "0.69918555", "0.69797593", "0.69503766", "0.6900533", "0.6888203", "0.6877489", "0.68690765", "0.6815677", "0.67677283", "0.67413914", "0.67413914", "0.6715775", "0.67132556", "0.6656021", "0.66175216", "0.65973735", "0.6585362", "0.6569844", "0.6561127", "0.65483135", "0.65441495", "0.65272397", "0.6523631", "0.6514973", "0.65101457", "0.64865285", "0.6483337", "0.64721733", "0.64647216", "0.64602685", "0.6438178", "0.6421637", "0.64147854", "0.63826066", "0.6363636", "0.6334362", "0.6317442", "0.6317442", "0.63013935", "0.6296833", "0.6296833", "0.62658703", "0.6259668", "0.62588793", "0.625442", "0.625442", "0.6235054", "0.62210935", "0.6194859", "0.6187353", "0.6177276", "0.6175309", "0.616153", "0.616153", "0.61548465", "0.615445", "0.615445", "0.6154322", "0.61515725", "0.6148889", "0.613915", "0.613915", "0.613915", "0.61243546", "0.6121532", "0.6118406", "0.6117133", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.6115981", "0.611351", "0.6090532", "0.6085093", "0.6084181", "0.60805255", "0.607817", "0.6076915", "0.6074868", "0.6073933", "0.60684854", "0.6060686", "0.60503614" ]
0.0
-1
create [num] SHF applications in the given state return the list of SHF applications created
def create_shf_apps_in_state(num, state, create_date: Time.current) shf_apps = [] num.times do shf_apps << create(:shf_application, state: state, created_at: create_date, updated_at: create_date) end shf_apps end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_apps_in_states(create_date: Time.current)\n\n NUM_APPS_IN_STATE.each_pair do |state, number|\n create_shf_apps_in_state(number, state, create_date: create_date)\n end\n\n end", "def get_recent_shf_apps(start_date, end_date)\n\n @recent_shf_apps = ShfApplication.updated_in_date_range(start_date, end_date)\n\n unless @recent_shf_apps.empty?\n ShfApplication.all_states.each do |app_state|\n recent_app_state_counts[app_state] = @recent_shf_apps.where(state: app_state).count\n end\n end\n\n @recent_shf_apps # return this to make testing easier\n end", "def initialize_applications\n application_names = (settings['applications'] || '').split(',').flatten.compact.map(&:strip).uniq\n self.applications = []\n application_names.each do |app_name|\n app = Application.find(:name => app_name, :host_id => host.id)\n if app\n self.applications << app\n else\n app = Application.new(:name => app_name, :host_id => host.id)\n if app.save\n self.applications << app\n else\n warn(\"Could not create application '#{app_name}' for host #{host.name}\")\n end\n end\n end\n self.applications\n end", "def request_launch_new_instances(num=1)\n out = []\n num.times {out << launch_new_instance!}\n out\n end", "def create_initial_state(app)\n raise 'Invalid app' unless SUPPORTED_APPS[app]\n SUPPORTED_APPS[app].initial_state\nend", "def find_applications_by_app_name(app_name)\n pids = []\n\n begin\n x = `ps auxw | grep -v grep | awk '{print $2, $11, $12}' | grep #{app_name}`\n if x && x.chomp!\n processes = x.split(/\\n/).compact\n processes = processes.delete_if do |p|\n _pid, name, add = p.split(/\\s/)\n # We want to make sure that the first part of the process name matches\n # so that app_name matches app_name_22\n\n app_name != name[0..(app_name.length - 1)] and not add.include?(app_name)\n end\n pids = processes.map { |p| p.split(/\\s/)[0].to_i }\n end\n rescue ::Exception\n end\n\n pids.map do |f|\n app = Application.new(self, {}, PidMem.existing(f))\n setup_app(app)\n app\n end\n end", "def create\n # Avoid double provisioning: previous url would be \"/provision/new?apps[]=vtiger&organization_id=1\"\n session.delete('previous_url')\n\n @organization = current_user.organizations.to_a.find { |o| o.id && o.id.to_s == params[:organization_id].to_s }\n authorize! :manage_app_instances, @organization\n\n app_instances = []\n params[:apps].each do |product_name|\n app_instance = @organization.app_instances.create(product: product_name)\n app_instances << app_instance\n MnoEnterprise::EventLogger.info('app_add', current_user.id, 'App added', app_instance)\n end\n\n render json: app_instances.map(&:attributes).to_json, status: :created\n end", "def aps_application_names(start = 0, count = 1)\n a = redis.smembers(:aps_applications)\n return a if count == 0\n a[start..(start + count)] || []\n end", "def update_app_list\n # Differentiate between a null app_nids params and no app_nids params\n return unless params[:organization].key?(:app_nids) && (desired_nids = Array(params[:organization][:app_nids]))\n\n existing_apps = @organization.app_instances.active\n\n existing_apps.each do |app_instance|\n desired_nids.delete(app_instance.app.nid) || app_instance.terminate\n end\n\n desired_nids.each do |nid|\n begin\n @organization.app_instances.create(product: nid)\n rescue => e\n Rails.logger.error { \"#{e.message} #{e.backtrace.join(\"\\n\")}\" }\n end\n\n end\n\n # Force reload\n existing_apps.reload\n end", "def ini_programs\n Scent.all[0..3].each do |scent|\n SmellProgram.create!(user: self, scent: scent, status: 1)\n end\n end", "def index\n @program_states = ProgramState.all\n end", "def create_singletons\n count_items\n create_item_sets\n end", "def exec(name)\n create_resource(name, type: 'application', binary_path: name)\n\n e_uid = SecureRandom.uuid\n\n e_name = \"#{self.name}_application_#{name}_created_#{e_uid}\"\n\n resource_group_name = \"#{self.id}_application\"\n\n def_event e_name do |state|\n state.find_all { |v| v[:hrn] == name && v[:membership] && v[:membership].include?(resource_group_name)}.size >= self.members.uniq.size\n end\n\n on_event e_name do\n resources[type: 'application', name: name].state = :running\n end\n end", "def app_list\n host_os_family.app_list( self )\n end", "def darwin_app_list; end", "def steam_apps\n @steam_apps if initted?\n end", "def app_list\n @app_list ||= self.send(\"#{my_os_family}_app_list\")\n end", "def create_appliction_set(application_name, keys)\n results = {}\n code = unlock_vault(keys)\n return code, nil if code > 399\n code = init_application(application_name)\n return code, nil if code > 399\n results[:app_id], code = create_application_id application_name\n return code, results if code > 399\n results[:user_id], code = create_user(application_name, results[:app_id])\n return code, results if code > 399\n results[:user_data], code = create_user_token(results[:user_id], results[:app_id], application_name)\n return code, results if code > 399\n [200, results]\n end", "def create_objects(apps_config, changed_apps = [])\n debug 'create objects'\n apps_config.each do |app_name, app_cfg|\n update_or_create_application(app_name, app_cfg.clone) if changed_apps.include?(app_name)\n end\n\n # sorting applications\n @applications.sort_by!(&:name)\n end", "def applications\n select_application gp_card_manager_aid\n secure_channel\n gp_get_status :apps\n \n # TODO(costan): there should be a way to query the AIDs without asking the\n # SD, which requires admin keys.\n end", "def windows_in_state(state)\n require_relative 'search'\n wfs = Wavefront::Search.new(creds, opts)\n query = { key: 'runningState', value: state, matchingMethod: 'EXACT' }\n wfs.search(:maintenancewindow, query, limit: :all, offset: PAGE_SIZE)\n end", "def index\n @process_states = ProcessState.all\n end", "def startApplications()\n debug(\"Start all applications\")\n @applications.each_key { |name|\n startApplication(name)\n }\n end", "def test_create_all()\n tmp_path = Dir.tmpdir()\n\n input = {\n :ruby => {\n :path => \"#{tmp_path}/ruby\",\n :executables => \"./bin\",\n },\n :python => {\n :path => \"#{tmp_path}/python\",\n },\n :java => {\n :path => \"#{tmp_path}/java\",\n :executables => [\"./obj\", \"./lib\"],\n },\n }\n programs = Factory.create_all(input)\n\n assert_equal(3, programs.size())\n\n program0 = programs[:ruby]\n assert_equal(\"ruby\", program0.name)\n assert_equal(\"#{tmp_path}/ruby\", program0.path)\n assert_equal([\"./bin\"], program0.executables)\n\n program1 = programs[:python]\n assert_equal(\"python\", program1.name)\n assert_equal(\"#{tmp_path}/python\", program1.path)\n assert_equal([\".\"], program1.executables)\n\n program2 = programs[:java]\n assert_equal(\"java\", program2.name)\n assert_equal(\"#{tmp_path}/java\", program2.path)\n assert_equal([\"./obj\", \"./lib\"], program2.executables)\n end", "def build_instances\n filter_instances.map.with_index do |(suite, platform), index|\n new_instance(suite, platform, index)\n end\n end", "def create_many_intents\n intents = []\n @switches.each do |sw|\n rest = @switches - [sw]\n intents = _create_intent sw, rest, intents\nputs intents.size\n post_slice intents\n end\n post_slice intents, true\n end", "def collection(factory, count=3, opts={})\n results = []\n count.times do\n yield opts if block_given?\n results << FactoryBot.create(factory.to_sym, opts)\n end\n results\n end", "def app_state\n @app_state ||= Mash.new(environment: environment)\n end", "def list_spray_programs\n\treturn if authorise_for_web(program_name?,'read_spray_program') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:spray_programs_page] = params['page']\n\n\t\t render_list_spray_programs\n\n\t\t return \n\telse\n\t\tsession[:spray_programs_page] = nil\n\tend\n\n\tlist_query = \"@spray_program_pages = Paginator.new self, SprayProgram.count, @@page_size,@current_page\n\t @spray_programs = SprayProgram.find(:all,\n\t\t\t\t :limit => @spray_program_pages.items_per_page,\n\t\t\t\t :offset => @spray_program_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_spray_programs\nend", "def show\n @job_applications = @job_offer.job_applications.group_by(&:state)\n end", "def create_instances(count)\n fail DTK::Error::Usage, \"Attribute 'admin_state' cannot be set to powered_off if node not created\" if admin_state_powered_off?\n aws_api_operation(:create).create_instances(count)\n end", "def apps_by_family(family)\n apps(:appfamily => family)\n end", "def applications_for(result_type = :in_progress)\n @apps ||= {}\n return @apps[result_type] if @apps[result_type]\n @apps[result_type] = []\n result_type_array = [result_type] unless result_type.is_a?(Array)\n for t in result_type_array || result_type\n for status_type in status_types(t)\n if t.to_s == \"success\" || t.to_s == \"failure\"\n @apps[result_type] << offering.applications_past_status(status_type)\n else\n @apps[result_type] << offering.application_for_offerings.in_status(status_type)\n end\n end\n end\n @apps[result_type] = @apps[result_type].flatten.uniq.compact\n end", "def number_of_applications\n\t\treturn self.appTemplates.size\n\tend", "def startApplications(show_std=true)\n if @app_contexts.empty?\n warn \"No applications defined in group #{@name}. Nothing to start\"\n else\n @applications.each { |app|\n run_application(app[:name], show_std)\n }\n end\n end", "def start_apps\n check_apps\n remove_sockets\n _start_apps(ARGV[1])\nend", "def applications\n list = Array.new\n\n if @db != nil\n is_ok = false\n\n begin\n stm = @db.prepare( 'SELECT qApp FROM qryResults GROUP BY qApp ORDER BY qApp')\n rs = stm.execute\n\n rs.each do |row|\n list.push row['qApp']\n end\n\n stm.close\n is_ok = true\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an SELECT Applications error (#{e.message}).\")\n end\n end\n\n return list\n end", "def create(_state)\n workflow do\n run_apply\n end\n end", "def add_desktops(number_to_add)\n TSApi.tsapi_addDesktopsOnDisplay(number_to_add, 0)\n end", "def generate_subjobs(number_of_jobs_that_we_want_to_create)\n subjob_list = []\n\n render_unit = (job.ending_column - job.starting_column) / number_of_jobs_that_we_want_to_create\n sc = job.starting_column \n\n number_of_jobs_that_we_want_to_create.times do |time|\n new_job = Job::Job.new(@job.id, sc+render_unit*time, sc+render_unit+(render_unit*time))\n subjob_list.push(new_job)\n end \n\n subjob_list.last.ending_column = job.ending_column \n return subjob_list\n end", "def list()\n path = \"/query/apps\"\n conn = multipart_connection(port: 8060)\n response = conn.get path\n\n if response.success?\n regexp = /id=\"([^\"]*)\"\\stype=\"([^\"]*)\"\\sversion=\"([^\"]*)\">([^<]*)</\n apps = response.body.scan(regexp)\n printf(\"%30s | %10s | %10s | %10s\\n\", \"title\", \"id\", \"type\", \"version\")\n printf(\"---------------------------------------------------------------------\\n\")\n apps.each do |app|\n printf(\"%30s | %10s | %10s | %10s\\n\", app[3], app[0], app[1], app[2])\n end\n end\n end", "def fscreates(name, sname)\n if fcreates name, sname\n s = fslistf name\n s.each do |i|\n fcreates i, sname\n end\n return true\n else\n return false\n end\nend", "def applications(params = {}) # rubocop:disable Style/OptionHash\n page_limit = params.delete(:page_limit) { 1 }\n\n applications_array = []\n 1.upto page_limit do |i|\n response = request_applications(params.merge(page: i))\n applications_array += response[\"applications\"]\n break if response[\"paginationComplete\"]\n end\n applications_array\n end", "def applications\n instantiate_models Application, session.get('operations/application')\n end", "def apps_by_status(status)\n apps(:status => status)\n end", "def add_new_instances(count)\n Output.new(current_instances + parent.create_instances(count), []) \n end", "def initialize(num_states)\n @_buffer = FFI::MemoryPointer.new :char,\n FFILib::ReaderStateQuery.size * num_states\n @queries = (0...num_states).map do |i|\n FFILib::ReaderStateQuery.new @_buffer + FFILib::ReaderStateQuery.size * i\n end\n end", "def index\n unless params[:user_id].nil?\n user = User.find_by_user_id(params[:user_id]) \n @applications = Application.where(user: user) unless user.nil?\n @applications ||= []\n @applications.each { |a| a.nursery.count_applications(a.date) }\n else\n @applications = Application.all\n end\n end", "def index\n @q = App.ransack(params[:q])\n @apps = @q.result(distinct: true)\n end", "def windows_app_list\n Launchy.log \"#{self.class.name} : Using 'start' command on windows.\"\n %w[ start ]\n end", "def index\n @app_instances = AppInstance.all\n end", "def generate_list(name, count); end", "def index_hot_checkin(params)\n @programs = TvProgram.all\n @programs.sort!{|x, y| y.checkin_count <=> x.checkin_count}\n if((params[:size] != nil))\n @programs = @programs[0 .. (params[:size].to_i-1)]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @programs.to_xml }\n format.json { render :json => @programs.to_json }\n end\n end", "def Scan_sample_full_bin\n next_state = ScanSampleFullBin.new(self.parent)\n next_state.current_bin_id = self.current_bin_id.to_s\n result_screen_def = next_state.build_default_screen.to_s\n \n #-----------------------------------------------------------------------\n # sets the current pdt_screen_def,which is used in next step the process\n # to determine the current program_fuction(menu_item) to invoke in the \n # next cycle\n #-----------------------------------------------------------------------\n current_screen_def = PdtScreenDefinition.new(result_screen_def,nil,PdtScreenDefinition.const_get(\"ENTERDATA\"),self.pdt_screen_def.user,self.pdt_screen_def.ip)\n \n next_state.pdt_screen_def = current_screen_def\n self.parent.set_active_state(next_state) \n return result_screen_def\n end", "def dump_initial_state(files)\n program_id = ProgramID.new\n files = program_id.resolve_file_list(files)\n program_id.register_files(files)\n\n io = Tempfile.new \"autorespawn_initial_state\"\n initial_info = Marshal.dump([name, program_id])\n io.write([initial_info.size].pack(\"L<\"))\n io.write(initial_info)\n io.flush\n io.rewind\n io\n end", "def create_app()\n app = OpenShift::TestApplication.new(self)\n\n $logger.info(\"Created new application #{app.name} for account #{@name}\")\n\n @apps << app\n app\n end", "def applications_list\n get \"applications\"\n end", "def index\n @applications = Application.all\n end", "def index\n @applications = Application.all\n end", "def index\n @applications = Application.all\n end", "def index\n @applications = Application.all\n end", "def applications\n Application.from session.get 'operations/application', API_V1\n end", "def index\n @apps = @call.app_class.unscoped.all(:order => :id)\n end", "def list_apps\n render :text => app_configs.keys\n end", "def applications=(value)\n @applications = value\n end", "def applications=(value)\n @applications = value\n end", "def boots(state,path,descr=\"\")\n begin\n # get our current position\n curr = path.shift\n case\n when curr.instance_of?(String)\n descr=\"#{descr}.#{curr}\"\n\n # we may have a hash or a mbean from which to get attributes\n # either way, we can \"gettr\" done\n state = (state.respond_to?(:keys) ? state[curr] : state.send(curr))\n if path.empty?\n @results[descr]=state\n else\n boots(state,path,descr)\n end\n when curr.instance_of?(Array)\n curr_state = state\n curr.each do |rabbit|\n hole = path.dup\n my_desc = \"#{descr}.#{rabbit}\"\n my_state = (curr_state.respond_to?(:keys) ? curr_state[rabbit] : curr_state.send(rabbit))\n if hole.empty?\n @results[my_desc]=my_state\n else\n boots(my_state,hole,my_desc)\n end\n end\n end\n rescue Exception => e\n puts \"Exception required processing #{@name}: #{e}\"\n end\n end", "def list_apps\n check_scope!\n\n apps = App.accessible_by(@context).unremoved.includes(:app_series).order(:title)\n apps = apps.where(scope: params[:scopes]) if params[:scopes].present?\n\n # Filter by latest revisions or versions.\n # This is kinda tricky, but we need to handle the apps which revisions were moved to a space\n # before we migrated to the new way how app is published to a space.\n apps = apps.select(&:latest_accessible_in_scope?)\n\n result = apps.map do |app|\n describe_for_api(app, unsafe_params[:describe])\n end\n\n render json: result\n end", "def list\n $stdout.puts \"The following POW applications are available:\\n\\n\"\n Dir[\"#{POWPATH}/*\"].each do |a|\n if File.symlink?(a)\n $stdout.puts \" #{File.basename(a)} -> #{File.readlink(a)}\"\n else\n port = File.open(a) { |f| f.readline.to_i }\n info = _extract_forward_info(port)\n $stdout.puts \" #{File.basename(a)} -> forwarding to :#{port} for\" +\n \" #{info.fetch(:command, 'Unknown')}[#{info.fetch(:pid, '???')}]\"\n end\n end\n $stdout.puts \"\\nRun `powify open [APP_NAME]` to browse an app\"\n end", "def apps\n apps_search = []\n App.all.each do |app|\n apps_search << {\n title: app.name,\n description: app.package_id,\n url: app_path(id: app.id)\n }\n end\n gon.apps = apps_search\n end", "def applist(options:)\n path = \"/query/apps\"\n response = nil\n multipart_connection(port: 8060) do |conn|\n response = conn.get path\n end\n\n if response.success?\n regexp = /id=\"([^\"]*)\"\\stype=\"([^\"]*)\"\\sversion=\"([^\"]*)\">([^<]*)</\n apps = response.body.scan(regexp)\n printf(\"%30s | %10s | %10s | %10s\\n\", \"title\", \"id\", \"type\", \"version\")\n printf(\"---------------------------------------------------------------------\\n\")\n apps.each do |app|\n printf(\"%30s | %10s | %10s | %10s\\n\", app[3], app[0], app[1], app[2])\n end\n end\n end", "def index\n @apps = Application.order(:name).all\n end", "def calendar_week_applications\n puts \"Collecting applications for #{year}, week #{@date.cweek}...\"\n raise \"This week ain't over! It would result in a partial file, so stopping\" if @date.end_of_week >= Date.today\n applications = []\n (@[email protected]_of_week).each do |d|\n applications += applications_on_date(d)\n end\n puts \"Collected #{applications.count} applications.\"\n as_xml applications\n end", "def find_application\n unless self.app_name.blank?\n my_apps = []\n # in the case of an array, the new finder will not work\n Array(self.app_name).each do |individual_name|\n new_apps = App.active.by_short_or_long_name(individual_name)\n logger.info \"new_apps\" + new_apps.inspect\n my_apps += new_apps unless new_apps.blank?\n logger.info \"my_apps\" + my_apps.inspect\n end\n unless my_apps.blank? || my_apps.length != Array(self.app_name).length\n self.apps << my_apps - self.apps\n else\n self.application_lookup_failed = true\n end\n end\n # be sure the call back returns true or else the call will fail with no error message\n # from the validation loop\n return true\n end", "def apps_by_creation_date(createdat)\n t = createdat.is_a?(Time) ? createdat.to_i : createdat\n apps(:createdat => t)\n end", "def all_apps\n json = ENV[\"OOD_APPS\"] || File.read(ENV[\"OOD_CONFIG\"] || File.expand_path(\"../config.json\", __FILE__))\n JSON.parse(json).map { |app| App.new(app.to_h) }\nend", "def num_shelf\n\t\tputs \"Library has #{@shelves.length} shelves\"\n\tend", "def create_program_work_orders(programs)\n if programs.nil? == false and programs.size > 0\n programs.each do |program|\n @queue.push_work_order({:type => Program, :id => DataUtility.get_program_id(program[:id]), :program_type => program[:type], :sponsor => program[:sponsor]})\n end\n end\n end", "def index\n @switterapps = Switterapp.all\n end", "def index_hot_watch(params)\n @programs = TvProgram.all\n @programs.sort!{|x, y| y.watch_count <=> x.watch_count}\n if((params[:size] != nil))\n @programs = @programs[0 .. (params[:size].to_i-1)] \n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @programs.to_xml }\n format.json { render :json => @programs.to_json }\n end\n end", "def ls\n show_fields = options[:l] ? %w[name appid stateflags sizeondisk] : %w[name]\n output = @apps.map do |id, app|\n app.select{ |field| show_fields.include?(field) }\n end\n\n puts output.map{ |o| o.values.join(\"\\t\")}.join(\"\\n\")\n end", "def initialize(num_states: 100, num_actions: 4, alpha: 0.2, gamma: 0.9, rar: 0.5, radr: 0.99, dyna: 0, verbose: false)\n @states = Array.new(num_states)\n @actions = Array.new(num_actions)\n @alpha = alpha\n @gamma = gamma\n @rar = rar\n @radr = radr\n @dyna = dyna\n @verbase = verbose\n @q = (0..99).map{|_| (0..3).map{|_| 0}}\n\n @past = []\n # @q = {}\n # 100.times do |s|\n # @q[s] = {}\n # 4.times {|a| @q[s][a] = 0}\n # end\n end", "def aps_applications_count\n redis.smembers(:aps_applications).size\n end", "def list\n\t\tdoc = xml(get('/apps'))\n\t\tdoc.elements.to_a(\"//apps/app/name\").map { |a| a.text }\n\tend", "def list\n\t\tdoc = xml(get('/apps'))\n\t\tdoc.elements.to_a(\"//apps/app/name\").map { |a| a.text }\n\tend", "def desktops\n @desktops ||= if available?\n Libatspi.get_desktop_count.times.map do |idx|\n Desktop.new(Libatspi.get_desktop(idx))\n end\n else\n []\n end\n end", "def index\n jobs = current_user.hr.jobs\n @applications = Array.new\n jobs.each do |job|\n job_faculties_map = Hash.new\n job_faculties_map[job] = Array.new\n if job.faculties.length > 0\n job.faculties.each do |faculty|\n job_faculties_map[job] << faculty\n end\n @applications << job_faculties_map\n end\n end\n @applications\n end", "def get_shelves\n shelves = [@shelf_ag, @shelf_hp, @shelf_qz]\n return shelves\n end", "def bootstrap_stack(ops, config, input, options_hash)\n puts \"Creating stack #{config['stack']['name']} ...\"\n stack = ops.create_stack(config['stack'])\n\n if config['permissions']\n stack.grant_access(config['permissions'])\n else\n puts \"Warning! No permissions defined in config. Granting full access to everyone.\"\n stack.grant_full_access \n end\n\n layers = []\n config['layers'].each do |l|\n layer_aws_config = l['config']\n layer = stack.create_layer(layer_aws_config)\n\n if not l.has_key?('instances')\n puts \"Warning! no instances key for layer #{layer_aws_config['name']}\"\n else\n l['instances'].each do |i|\n layer.create_instance(i)\n end\n layers.push(layer)\n end\n\n if l['elb']\n stack.create_elb(l['elb']) if options_hash[:create_elbs]\n layer.attach_elb(l['elb']['name']) if options_hash[:attach_elb]\n update_alarms(l['elb']['alarms']) if l['elb']['alarms']\n end\n\n if l['load_based_auto_scaling'] and l['load_based_auto_scaling']['enabled']\n layer.configure_load_based_auto_scaling(config['load_based_auto_scaling'], l, {:enable => options_hash[:enable_auto_scaling]})\n end\n\n if l['time_based_auto_scaling'] and l['time_based_auto_scaling']['enabled']\n layer.configure_time_based_auto_scaling(config['time_based_auto_scaling'], l)\n end\n\n end\n\n config['apps'].each do |a, value|\n stack.create_app(a, config['apps'][a])\n end\n\n if options_hash[:start_instances]\n instances = []\n\n layers.each do |l|\n started = l.send_start\n instances += started\n\n if options_hash[:load_instances_to_start] and options_hash[:load_instances_to_start][l.name] > 0\n started_load_instances = l.start_load_instances(options_hash[:load_instances_to_start][l.name])\n instances += started_load_instances\n end\n end\n\n ops.wait_for_instances_status(instances, \"online\", [\"stopped\", \"requested\", \"pending\", \"booting\", \"running_setup\"])\n end\n\n puts \"\\n\\nStack #{config['stack']['name']} successfully created.\"\n return stack\nend", "def start_app\n response = show_menu\n response = show_menu while response < 1 || response > 7\n\n case response\n when 1\n list_books\n when 2\n list_people\n when 3\n create_person\n when 4\n create_book\n when 5\n create_rental\n when 6\n list_rentals_for_person_id\n when 7\n puts 'Thank you for using this app!'\n end\n\n puts \"\\n\"\n end", "def start_sequence; @start_sequence ||= apps.keys; end", "def apps\n collect\n end", "def apps_single_app_mode_list\n return @apps_single_app_mode_list\n end", "def index\n @rack_installations = RackInstallation.all\n end", "def all\n request_model = @request_model_factory.all_apps_request_model\n response = @network_client.perform_request(request_model)\n JSON.parse(response.body).map do |app_hash|\n Fabricio::Model::App.new(app_hash)\n end\n end", "def start app, &block\n # run available process types\n app[\"ps\"].each do |type,ps|\n ps[\"scale\"].times do |index|\n host = GV::Valley::Runner.random_service \n app[\"ps\"][type][\"containers\"] << host.start(app[\"name\"], type, index, &block)\n end\n end\n end", "def initial_state\n []\n end", "def create_process(workers_count)\n pid = start_threads(workers_count)\n @pids[pid] = {}\n end", "def init(n)\n for s in 1..n do\n\t @stk.push(s)\n\tend\n end", "def plus_state_set\n return []\n end" ]
[ "0.7199402", "0.59144616", "0.5414188", "0.53837156", "0.5303373", "0.52989286", "0.52305746", "0.52006435", "0.519886", "0.5156555", "0.50491333", "0.5034245", "0.499946", "0.49726558", "0.4949552", "0.49459392", "0.49261197", "0.49163422", "0.49084094", "0.48974708", "0.48544404", "0.4847016", "0.48468912", "0.4818747", "0.4814835", "0.47733873", "0.47673407", "0.4765556", "0.4758001", "0.47566292", "0.47473583", "0.4742605", "0.47181854", "0.47056082", "0.47014317", "0.46798158", "0.46720022", "0.46678093", "0.46658516", "0.46649757", "0.4663418", "0.46549192", "0.46395323", "0.46362993", "0.4633181", "0.46292388", "0.46270475", "0.4626438", "0.4623155", "0.46174985", "0.46153796", "0.46135893", "0.45999908", "0.45959887", "0.45951506", "0.45951086", "0.45811915", "0.45799273", "0.45799273", "0.45799273", "0.45799273", "0.45690838", "0.4565987", "0.45630664", "0.45584008", "0.45584008", "0.45548597", "0.4553928", "0.45498595", "0.45463046", "0.45413497", "0.45410207", "0.45398358", "0.4538862", "0.45387498", "0.4529542", "0.45256388", "0.45215872", "0.4520854", "0.45191723", "0.45189774", "0.45177498", "0.45123637", "0.45043766", "0.45043766", "0.45026574", "0.45004413", "0.44993487", "0.4498017", "0.44966638", "0.44964617", "0.44955736", "0.44923788", "0.44887805", "0.44860563", "0.44815737", "0.44781622", "0.44761425", "0.44712332", "0.44710046" ]
0.8624569
0
create applications in all states and set the created_at: and updated_at dates to create_date default create_date = Time.zone.now
def create_apps_in_states(create_date: Time.current) NUM_APPS_IN_STATE.each_pair do |state, number| create_shf_apps_in_state(number, state, create_date: create_date) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_shf_apps_in_state(num, state, create_date: Time.current)\n shf_apps = []\n\n num.times do\n shf_apps << create(:shf_application, state: state, created_at: create_date,\n updated_at: create_date)\n end\n\n shf_apps\n end", "def apps_by_creation_date(createdat)\n t = createdat.is_a?(Time) ? createdat.to_i : createdat\n apps(:createdat => t)\n end", "def create\n @application_date = ApplicationDate.new(application_date_params)\n\n respond_to do |format|\n if @application_date.save\n format.html { redirect_to admin_home_path, notice: '时间阶段创建成功' }\n format.json { render action: 'show', status: :created, location: @application_date }\n else\n format.html { render action: 'new' }\n format.json { render json: @application_date.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_everything\n create_users\n create_user_keys\n create_comments\n create_filters\n create_columns\n create_organizations\n create_approvals\n create_whitelists\n create_user_key_columns\n create_user_key_organizations\n end", "def create\n @application = Application.new(application_params)\n\n if @application.save\n @application.status = Application.where(nursery_id: @application.nursery_id, date: @application.date, status: :appointed).count < @application.nursery.capacity ? :appointed : :waiting\n @application.save\n render :show, status: :created, location: @application\n else\n render json: @application.errors, status: :unprocessable_entity\n end\n end", "def create_database\n DATA[:calendars].each do |calendar|\n CalendarCoordinator::Calendar.create(calendar).save\n end\n\n calendar = CalendarCoordinator::Calendar.first\n DATA[:events].each do |event|\n calendar.add_event(event)\n end\n end", "def create\n @driver_application = DriverApplication.new(driver_application_params)\n \n # Always get the current time to save\n @driver_application.created_at = DateTime.current\n\n respond_to do |format|\n if @driver_application.save\n format.html { redirect_to @driver_application, notice: 'Driver application was successfully created.' }\n format.json { render :show, status: :created, location: @driver_application }\n else\n format.html { render :new }\n format.json { render json: @driver_application.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_database\n DATA[:accounts].each do |account|\n CalendarCoordinator::AccountService.create(data: account).save\n end\n\n account = CalendarCoordinator::Account.first\n DATA[:calendars].each do |calendar|\n account.add_owned_calendar(calendar)\n end\n end", "def before_create; self.created_on = Time.now.utc; end", "def safe_initial_application_dates(status)\n case status\n when :draft, :enrollment_open\n if TimeKeeper.date_of_record.month == 11 && TimeKeeper.date_of_record.day < 16\n current_effective_date TimeKeeper.date_of_record.beginning_of_month\n else\n current_effective_date (TimeKeeper.date_of_record + 2.months).beginning_of_month\n end\n when :enrollment_closed, :enrollment_eligible, :enrollment_extended\n current_effective_date (TimeKeeper.date_of_record + 1.months).beginning_of_month\n when :active, :terminated, :termination_pending, :expired\n current_effective_date (TimeKeeper.date_of_record - 2.months).beginning_of_month\n end\n end", "def set_created_at\n self.created_at ||= Date.today if new_record?\n end", "def create_date\n\t\tcreated_at.to_date\n\tend", "def created\n\t\t\t# Picked a random lender application and temporary set it's status to pending\n\t\tlender_app \t\t\t= LenderApplication.first\n\t\tlender_app.status \t= 'pending'\n\t\tLenderApplicationsMailer.created(lender_app)\n\tend", "def create\n # Avoid double provisioning: previous url would be \"/provision/new?apps[]=vtiger&organization_id=1\"\n session.delete('previous_url')\n\n @organization = current_user.organizations.to_a.find { |o| o.id && o.id.to_s == params[:organization_id].to_s }\n authorize! :manage_app_instances, @organization\n\n app_instances = []\n params[:apps].each do |product_name|\n app_instance = @organization.app_instances.create(product: product_name)\n app_instances << app_instance\n MnoEnterprise::EventLogger.info('app_add', current_user.id, 'App added', app_instance)\n end\n\n render json: app_instances.map(&:attributes).to_json, status: :created\n end", "def create\n date_format = \"#{appointment_params[\"date(1i)\"]}-#{appointment_params[\"date(2i)\"]}-#{appointment_params[\"date(3i)\"]}\"\n @appointment = Appointment.new(type_appointment_id: appointment_params[:type_appointment_id], description: appointment_params[:description], date: date_format,\n user_id: appointment_params[:user_id], estate_id: appointment_params[:estate_id], doctor_id: appointment_params[:doctor_id])\n \n respond_to do |format|\n if @appointment.save\n format.html { redirect_to @appointment, notice: 'Appointment was successfully created.' }\n format.json { render :show, status: :created, location: @appointment }\n else\n format.html { render :new }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_default_values\n self.created_at = DateTime.now unless self.created_at\n end", "def before_create\n self.created_at = Time.now\n self.updated_at = Time.now\n end", "def create_application\n unless self.has_current_application?\n Application.create_for_student self\n end\n end", "def create_contexts\n create_stores\n create_employees\n create_assignments\n end", "def create_and_activate\n create\n activate\n end", "def create\n self[:created] = Time.now.to_s\n save\n end", "def create_initial_state(app)\n raise 'Invalid app' unless SUPPORTED_APPS[app]\n SUPPORTED_APPS[app].initial_state\nend", "def create\n @application = Doorkeeper::Application.new(application_params)\n @application.uid = SecureRandom.hex(4)\n @application.owner = current_user if Doorkeeper.configuration.confirm_application_owner?\n\n if @application.save\n flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications create])\n redirect_to oauth_application_url(@application)\n else\n render :new\n end\n end", "def create_timestamp\n self.created_at = Time.now\n end", "def create_timestamp\n self.created_at = Time.now\n end", "def create\n push_to_db\n end", "def create\n push_to_db\n end", "def create\n @application = Doorkeeper::Application.new(application_params)\n @application.uid = SecureRandom.hex(4)\n @application.owner = current_user if Doorkeeper.configuration.confirm_application_owner?\n\n if @application.save\n flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])\n redirect_to oauth_application_url(@application)\n else\n render :new\n end\n end", "def create\n\n @event = Event.new(event_params)\n\n # if @event.cloudy already exist => duplicate else create from scratch\n @cloudy = @event.cloudy ? @event.cloudy : Cloudy.create\n @save_is_ok = true\n\n # dates is range\n if @event.calendar_range_string.size > 0\n\n @event = Event.new(event_params)\n @event.organizer = ( current_member.has_role?(ROLE_ADMIN) && @event.teacher) ? @event.teacher : current_member\n @event.cloudy = @cloudy\n @event.duration = @event.end_at - @event.begin_at\n # force image to avoid uplaod a new image per event created\n @save_is_ok &&= @event.save\n\n if @save_is_ok\n ContactMailer.new_user_action('Nouvel évènement', @event.url).deliver_now\n @event.reload\n @cloudy.identifier = @event.image.filename\n @cloudy.prefix_cloudinary = 'http://res.cloudinary.com/' + YAML.load_file('config/cloudinary.yml')['production']['cloud_name'] + '/'\n @cloudy.save\n @event.index!\n end\n\n elsif @event.calendar_string.size > 0\n\n # multi_dates_id = Time.new is Id group of all items\n tab_dates = @event.calendar_string.split(',')\n time_stamp = Time.new\n\n @save_is_ok = tab_dates.count > 0\n\n flash[:alert] = \"Il faut choisir une ou plusieurs dates\" unless @save_is_ok\n\n tab_dates.each do |d|\n @event = Event.new(event_params)\n @event.multi_dates_id = time_stamp if tab_dates.count > 1\n @event.organizer = ( current_member.has_role?(ROLE_ADMIN) && @event.teacher) ? @event.teacher : current_member\n\n @event.cloudy = @cloudy\n # if local zone = Paris, the 2 instruction follow add + hours in execution but not in debug\n # so DO NOT CHANGE LOCAL ZONE\n time_at = I18n.l(@event.begin_at, format: '%H:%M')\n @event.begin_at = DateTime.strptime(d+' '+time_at, '%d/%m/%Y %H:%M')\n time_at = I18n.l(@event.end_at, format: '%H:%M')\n @event.end_at = DateTime.strptime(d+' '+time_at, '%d/%m/%Y %H:%M')\n @event.duration = @event.end_at - @event.begin_at\n\n # save once to get cloudinary infos, break if save not ok\n break unless @save_is_ok &&= @event.save\n\n if @save_is_ok\n ContactMailer.new_user_action('Nouvel évènement', @event.url).deliver_now\n if [email protected]\n @event.reload\n @cloudy.identifier = @event.image.filename\n @cloudy.prefix_cloudinary = 'http://res.cloudinary.com/' + YAML.load_file('config/cloudinary.yml')['production']['cloud_name'] + '/'\n @cloudy.save\n params[:event].delete(:image)\n end\n @event.index!\n end\n end\n end\n\n respond_to do |format|\n if @save_is_ok\n format.html { redirect_to @event}\n format.json { render :show, status: :created, location: @event }\n else\n # simple_form doesn t show errors for :begin_at & :end_at because\n flash[:alert] = \"Problème dans la création de l événement\"\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n\t\tbegin\n\t\t\tActiveRecord::Base.transaction do\n\t\t\t\t@application = Application.create!(name: params[:name])\n end\n rescue => e #ActiveRecord::RecordNotUnique\n p e.message\n p e.backtrace\n\t\t\tActiveRecord::Rollback\n\t\t\trender plain: e.message, status: :unprocessable_entity and return\n end\n render json:\" Application created with token = #{@application.token}\", status: :created\n end", "def create\n @job_start_date = Job.find_by(id: params[:id]).job_start_date.to_date\n @job_end_date = Job.find_by(id: params[:id]).job_end_date.to_date\n @seeker_start_date = Jobseeker.find_by(user_id: current_user.id).start_date.to_date\n @seeker_end_date = Jobseeker.find_by(user_id: current_user.id).end_date.to_date\n if @job_start_date < @seeker_start_date\n redirect_to root_path, notice: 'Unable to apply. Job starts before your available period'\n return\n elsif @job_end_date > @seeker_end_date\n redirect_to root_path, notice: 'Unable to apply. Job ends after your availabilty period'\n return\n end\n @application = Application.new(job_id: params[:id], jobseeker_id: Jobseeker.find_by(user_id: current_user.id).id, status: \"Pending\")\n if @application.save\n ApplicationNotificationMailer.notification_email(params[:id]).deliver\n redirect_to @application, notice: 'You application has been sent. Good luck!'\n else\n redirect_to root_path, notice: 'You have already applied for this job'\n end\n end", "def create\n @app = App.new(app_params)\n\n if @app.save\n render json: @app, status: :created, location: @app\n else\n render json: @app.errors, status: :unprocessable_entity\n end\n end", "def create_created\n controller.create_created(resource: resource)\n end", "def create\n @project_states = ProjectState.create!(project_state_params)\n json_response(@project_states, :created)\n end", "def create\n \n end", "def after_create\n\t\tsuper\n\t\t# associate an enrollment queue\n\t\teq = EnrollmentQueue.create(user_id: self.id)\n\t\tself.enrollment_queue = eq\n\t\teq.user = self\n\t\t# associate a state table\n\t\tst = StateTable.create(user_id: self.id)\n\t\tself.state_table = st\n\t\tst.user = self\n\n\n if not ['app', 'android', 'ios'].include? self.platform\n\t\t self.state_table.update(subscribed?: false) unless ENV['RACK_ENV'] == 'test'\n # self.state_table.update(subscribed?: true)\n end\n\n\t\tif not ['fb', 'app', 'android', 'ios'].include? self.platform\n\t\t\tself.code = generate_code\n\t\tend\n\t\t# puts \"start code = #{self.code}\"\n\t\twhile !self.valid?\n\t\t\tself.code = (self.code.to_i + 1).to_s\n\t\t\t# puts \"new code = #{self.code}\"\n\t\tend\n\t\t# set default curriculum version\n\t\tENV[\"CURRICULUM_VERSION\"] ||= '0'\n\t\tself.update(curriculum_version: ENV[\"CURRICULUM_VERSION\"].to_i)\n\n\t\t# we would want to do\n\t\t# self.save_changes\n\t\t# self.state_table.save_changes\n\t\t# but this is already done for us with self.update and self.state_table.update\n\n\trescue => e\n\t\tp e.message + \" could not create and associate a state_table, enrollment_queue, or curriculum_version for this user\"\n\tend", "def enter_created; end", "def create\n\n # physician = Physician.find(physician_id)\n # unless physician.patients.where(email: email).exists?\n # patient = Patient.find_or_create_by(email: email)\n # physician.appointments.create(patient: patient)\n\n unless Appointment.where(doctor_id: appointment_params[:doctor_id], appointment_date_id: appointment_params[:appointment_date_id], time_table_id: appointment_params[:time_table_id]).exists?\n # unless Appointment.where(doctor_id: requested_doctor, appointment_date_id: requested_date, time_table_id: requested_timing).exists?\n @appointment = Appointment.new(appointment_params)\n @patient_id = @current_patient.id\n end\n\n # if @appointment.try(:save)\n # if [email protected]? && @appointment.save\n if @appointment && @appointment.save\n puts \"Im saving!\"\n redirect_to @appointment, notice: 'Appointment was successfully created.'\n else\n puts \"Failed saving!\"\n redirect_to new_appointment_url, notice: 'Appointment was NOT successfully created.'\n end\n end", "def create\n if params[:start_date].present?\n mes_para_consulta = params[:start_date].to_date\n else\n mes_para_consulta = Date.current\n end\n\n beginning_of_month = mes_para_consulta.beginning_of_month\n end_of_month = beginning_of_month.end_of_month\n\n @appointments_todos = Appointment.where(schedule_on: beginning_of_month..end_of_month)\n @appointments_todos = @appointments_todos.para_o_calendar(current_user.calendar_id)\n\n\n\n @appointment = Appointment.new(appointment_params)\n @appointment.calendar_id = current_user.calendar_id\n\n respond_to do |format|\n if @appointment.save\n format.html { redirect_to @appointment, notice: t('create_success') }\n format.json { render :show, status: :created, location: @appointment }\n else\n format.html { render :new }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n create_params = application_params\n if applicant_signed_in?\n create_params[:applicant_id] = current_applicant.id\n end\n @application = Application.new(create_params)\n\n respond_to do |format|\n if @application.save\n format.html { redirect_to @application, notice: \"Application was successfully created.\" }\n format.json { render :show, status: :created, location: @application }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_objects(apps_config, changed_apps = [])\n debug 'create objects'\n apps_config.each do |app_name, app_cfg|\n update_or_create_application(app_name, app_cfg.clone) if changed_apps.include?(app_name)\n end\n\n # sorting applications\n @applications.sort_by!(&:name)\n end", "def create\n @application = Application.new(application_params)\n\n if @application.save\n render json: @application, status: :created, location: api_application_path(@application)\n else\n render json: @application.errors.full_messages.join(', '), status: :unprocessable_entity\n end\n end", "def create_starting_statuses\n new_status_attributes = { :public_title => \"New\",\n :application_status_type => ApplicationStatusType.find_or_create_by_name(\"new\"),\n :disallow_user_edits => 0,\n :disallow_all_edits => 0,\n :allow_application_edits => 1 }\n statuses.create(new_status_attributes)\n in_progress_status_attributes = { :public_title => \"In Progress\",\n :application_status_type => ApplicationStatusType.find_or_create_by_name(\"in_progress\"),\n :disallow_user_edits => 0,\n :disallow_all_edits => 0,\n :allow_application_edits => 1 }\n statuses.create(in_progress_status_attributes)\n submitted_status_attributes = { :public_title => \"Submitted\",\n :application_status_type => ApplicationStatusType.find_or_create_by_name(\"submitted\"),\n :disallow_user_edits => 1,\n :disallow_all_edits => 0,\n :allow_application_edits => 0 }\n statuses.create(submitted_status_attributes)\n end", "def create\n @app = App.new(app_params)\n @app.count = 0\n @app.uid = SecureRandom.uuid\n respond_to do |format|\n if @app.save\n format.html { redirect_to app_path(uid: @app.uid), notice: 'App was successfully created.' }\n format.json { render :show, status: :created, location: @app }\n else\n format.html { render :new }\n format.json { render json: @app.errors, status: :unprocessable_entity }\n end\n end\n end", "def create; end", "def create; end", "def create; end", "def create; end", "def create\n \n end", "def create\n end", "def create_events\n end", "def create\n @application = Oread::Application.new(application_params)\n @application.owner = current_user\n respond_to do |format|\n if @application.save\n format.html { redirect_to settings_admin_oread_applications_path, notice: 'Application was successfully created.' }\n format.json { render :show, status: :created, location: @application }\n else\n format.html { render :new }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize @application, policy_class: Oauth::ApplicationPolicy\n @application = Doorkeeper::Application.new(application_params)\n @application.owner = current_user if T.unsafe(Doorkeeper).configuration.confirm_application_owner?\n if @application.save\n flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])\n redirect_to oauth_application_url(@application)\n else\n render :new\n end\n end", "def create\n @activity_application = @meetup_event.activity_applications.new(activity_application_params_for_create)\n\n respond_to do |format|\n if @activity_application.save\n format.html {redirect_to [@meetup_event, @activity_application], notice: 'Activity application was successfully created.'}\n format.json {render :show, status: :created, location: meetup_event_activity_application_path(@meetup_event, @activity_application)}\n else\n format.html {render :new}\n format.json {render json: @activity_application.errors, status: :unprocessable_entity}\n end\n end\n end", "def timestamps!\n before(:create) do\n self['updated_at'] = self['created_at'] = Time.now\n end \n before(:update) do \n self['updated_at'] = Time.now\n end\n end", "def get_initial_state\n {\n appointments_for_dates: {}\n }\n end", "def initialize\n @created_at = Time.now\n end", "def create_or_update_booking_dates\n if check_in_changed? || check_out_changed?\n # Delete all booking dates if check in or check out changed\n booking_dates.delete_all\n # Adding all the dates of the check_in and check_out range into the reserved dates\n (check_in..check_out).each do |reserved_date| \n # Createing booking dates with specified reserved_date\n booking_dates.create(reserved_date: reserved_date)\n end\n end\n end", "def begin_create\n create_stack.push(true)\n end", "def create\n end", "def create_app()\n app = OpenShift::TestApplication.new(self)\n\n $logger.info(\"Created new application #{app.name} for account #{@name}\")\n\n @apps << app\n app\n end", "def create\n # TODO: implement create\n end", "def new\n puts \"Creating new blank Praxis app under #{app_name}\"\n create_root_files\n create_config\n create_app\n create_design\n create_spec\n create_docs\n end", "def create_reservations\n Time.use_zone(@timezone) do\n @reservations = build_reservations\n return nil unless @reservations.any?\n @reservations = commit_reservations(@reservations)\n return nil unless valid? && @reservations.all?(&:persisted?)\n charge(@reservations) && @reservations.each(&:reload) if @pay\n track(@reservations)\n\n @reservations\n end\n end", "def create(options)\n API::request(:post, 'escrow_service_applications', options)\n end", "def allowed_to_create_apps=(value)\n @allowed_to_create_apps = value\n end", "def create\n @appointment = Appointment.new(appointment_params)\n @appointment.status = 'new'\n @appointment.create_date = Time.now\n respond_to do |format|\n if @appointment.save\n @notice = ('The appointment was succesfuly create, you will recieve an email about your appointment confirmation')\n format.html { render :success, notice: ('The appointment was succesfuly create, you will recieve an email about your appointment confirmation') }\n format.json { render :success, status: :ok, location: @appointment }\n else\n format.html { render :new }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_application \n @user = current_user(session)\n @business = Business.find_by(id: params[:id])\n if [email protected]\n @application = Application.create(business_id: @business.id, user_id: current_user(session).id)\n # binding.pry\n flash[:notice] = \"Your application hass been successfully submitted to #{@business.name} business\"\n else \n flash[:notice] = \"You are an administrator. Please log in without you admin account to apply to '#{@business.name}' business\"\n end\n redirect_to \"/businesses\"\n end", "def before_create\n temp_time = Time.sl_local\n self.created_at = temp_time\n self.modified_at = temp_time\n end", "def create\n appointment_request = current_user.pending_requests.new(\n appointment_request_params\n )\n\n if appointment_request.save\n if appointment_request.initialize_appointment!(appointment_params)\n redirect_to root_path\n else\n render json: {\n status: 500,\n error: 'This expert is not available on the scheduled date'\n }, status: 500\n end\n else\n render json: {\n status: 500, error: appointment_request.errors\n }, status: 500\n end\n end", "def execute(request)\n Doorkeeper::Application.create(params)\n end", "def create_tables\n create_mirrors\n create_users\n create_user_tokens\n create_products\n create_users_products\n create_versions\n create_dependencies\n create_access_keys\n end", "def create\r\n end", "def seed_all\n current_or_create_new_misc\n current_or_create_new_institutions\n current_or_create_new_williams_dining_opps\n current_or_create_new_williams_dining_places\n current_or_create_new_dining_opps\n seed_app_dining_periods\n seed_williams_rss_scraping\nend", "def create\n @application_event=ApplicationsEvent.find(params[:applications_event_id])\n @applications_application = ApplicationsApplication.new(params[:applications_application])\n @applications_application.applications_event_id=@application_event.id\n \n respond_to do |format|\n if @applications_application.save\n format.html { redirect_to @application_event, notice: 'Applications application was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n end", "def create\n end", "def create\n end", "def create\n \t\n end", "def after_created\n super.tap do |val|\n app_state_ruby(self)\n end\n end", "def create\n @application = Application.new()\n @application.name = params[:application][:name].to_s.downcase\n # true - доступ запрещен, false - разрешен\n @application.default = true\n respond_to do |format|\n if @application.save\n format.html { redirect_to applications_path, notice: 'Приложение создано.' }\n format.json { render json: @application, status: :created, location: @application }\n else\n format.html { render action: \"new\" }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @creates = Create.all\n end", "def create\n @application = Application.new(application_params)\n\n respond_to do |format|\n if @application.save\n format.html { redirect_to @application, notice: 'Application was successfully created.' }\n format.json { render :show, status: :created, location: @application }\n else\n format.html { render :new }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create_application_record\n template \"application_record.rb\", application_record_file_name\n end", "def create\n\n begin\n Meeting.transaction do\n @meeting = Meeting.new(meeting_params)\n\n create_agenda\n\n @meeting.save!\n\n create_material\n # create the history of meeting\n create_history(MeetingHistory.operations[:regist])\n # use cybozu api\n use_schedule_coordination_of_cybozu\n\n @meeting.save!\n end\n rescue CybozuApi::Error => e\n logger.info e.message\n @error = t('error.cybozu') << e.message\n rescue => e\n logger.info e.message\n else\n redirect_to @meeting\n end\n\n render :new if @error || @meeting.errors.any?\n\n end", "def create\r\n\r\n\r\n end", "def before_create\n self.created_at ||= Time.now\n super # ($)\n end", "def create_app app_name, dev_name, dev_email\n data[:app_name] = app_name\n data[:dev_name] = dev_name\n data[:dev_email] = dev_email\n end", "def create\n run_callbacks :create do\n true\n end\n end", "def create\n @transaction = Transaction.new(transaction_params)\n @transaction.update(user_id: session[:user_id])\n @transaction.update(status: 'Scheduled')\n\n @timingsList = []\n @datesList = []\n @timings = Timing.find_by_sql(\"SELECT day, hours, minutes, ampm FROM timings\")\n @timings.each do |timing|\n timing.day = date_of_next(timing.day).strftime(\"%d %b %Y\") + \" - \" + timing.hours + \":\" + timing.minutes + \" \" + timing.ampm\n @timingsList.push([timing.day, timing.day])\n end\n for i in 0..9\n @datesList.push([(Date.today+i).strftime(\"%d %b %Y\"), (Date.today+i).strftime(\"%d %b %Y\")])\n end\n\n respond_to do |format|\n if @transaction.save\n format.html { redirect_to transactions_path, notice: 'Transaction was successfully created.' }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_appeal_state_on_task_creation\n update_appeal_state_when_privacy_act_created\n update_appeal_state_when_appeal_docketed\n update_appeal_state_when_ihp_created\n end", "def create\n create_checkpoints\n create_config_base\n generate_deploy_files\n generate_hiera_template\n end", "def set_record_created_at\n self.record_created_at = Time.current.utc.iso8601(3)\n end", "def create\n make_create_request\n end", "def default_values #to set the status as pending and creation date as defaults \n\tif (self.status).nil?\n\t\tself.status ||= \"Pending\"\n\t\tself.application_date = Date.today\n\tend\nend", "def create\n @event = current_user.created_events.build(event_params)\n @upcoming_events = Event.upcoming_events.order('created_at DESC')\n @past_events = Event.past_events.order('created_at DESC')\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to event_path(@event), notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :index, alert: 'Event was not created. Please try again!' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @app = current_user.apps.new(params[:app])\n\n respond_to do |format|\n if @app.save\n format.html { redirect_to @app, :notice => \"The application app was successfully created\" }\n format.xml { render :xml => @app, :status => :created, :location => @app }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @app.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @application = current_user.build_application(application_params)\n\n respond_to do |format|\n if @application.save\n format.html { redirect_to @application, alert: 'Your application was successfully created.' }\n format.json { render action: 'show', status: :created, location: @application }\n else\n format.html { render action: 'new' }\n format.json { render json: @application.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 @app = App.new(app_params)\n\n respond_to do |format|\n if @app.save\n format.html { redirect_to @app, notice: 'App was successfully created.' }\n format.json { render :show, status: :created, location: @app }\n else\n format.html { render :new }\n format.json { render json: @app.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.67802423", "0.6033695", "0.5781957", "0.5771342", "0.57342434", "0.57287693", "0.56911033", "0.56450516", "0.5643362", "0.56431955", "0.5642254", "0.56245863", "0.55921745", "0.5544943", "0.5516274", "0.54866517", "0.5482571", "0.54647434", "0.54512715", "0.54324293", "0.54225755", "0.5398941", "0.53973293", "0.5389928", "0.5389176", "0.53834116", "0.53834116", "0.5379169", "0.5370076", "0.53690886", "0.5368047", "0.536071", "0.5356219", "0.53546196", "0.5343083", "0.528831", "0.5281985", "0.5280762", "0.5271319", "0.52649057", "0.5253676", "0.5252349", "0.5246539", "0.5245228", "0.5236238", "0.5236238", "0.5236238", "0.5236238", "0.5212792", "0.5211392", "0.5205777", "0.5205436", "0.52019846", "0.5200781", "0.5192765", "0.51876", "0.5181069", "0.5178902", "0.517478", "0.51652265", "0.5164175", "0.51600415", "0.51481724", "0.5147468", "0.51378906", "0.5136771", "0.51261145", "0.51259255", "0.5122916", "0.5119769", "0.5115738", "0.511415", "0.5110416", "0.5109506", "0.51086104", "0.5108332", "0.5108332", "0.5108332", "0.51076037", "0.51030135", "0.5102917", "0.5098844", "0.5098457", "0.5095048", "0.5092984", "0.50909567", "0.50853163", "0.50848746", "0.50823337", "0.5082089", "0.50809187", "0.50631756", "0.5060353", "0.5059969", "0.50577015", "0.5057539", "0.505034", "0.5049954", "0.5046557", "0.50453544" ]
0.7496882
0
add an uploaded file to the SHF application
def add_uploaded_file(shf_app) shf_app.uploaded_files << create(:uploaded_file, actual_file: File.open(UPLOAD_PNG_FILE)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_file\n #TODO\n end", "def upload\n self._create params[:upfile], params[:pictitle]\n end", "def upload\r\n \r\n end", "def save_file_entry\n @user.search_files.create!(file_path: uploaded_file_path.result, file_name: @file.original_filename, status: 'initialized')\n end", "def upload\n end", "def upload\n end", "def upload_file\n file = google_session.upload_from_file(file_params[:file].tempfile,\n file_params[:file].original_filename)\n collection.add(file)\n google_session.root_collection.remove(file)\n render json: 'Upload Successful'\n end", "def add_file(filename)\n step('I visit the new file page')\n fill_in(\"file_label\", with: filename)\n attach_file('file_file', filename)\n fill_in('file_description', with: sample_file_description(filename))\n click_link_or_button('Upload File')\n wait_for_ajax_complete\nend", "def add_file(file)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size.to_s\n self.file_uuid = UUID.new.generate\n true\n end", "def addFile(url, local_name)\r\n\t\t\t`bitsadmin /rawreturn /addfile {#{@id}} #{url} #{local_name}`\r\n\t\tend", "def addfile(contents, path, client = nil, clientip = nil)\n contents = Base64.decode64(contents) if client\n bucket = Puppet::FileBucket::File.new(contents)\n Puppet::FileBucket::File.indirection.save(bucket)\n end", "def add_file(file)\n logger.info(\" ########### add file\")\n if (file.nil?)\n logger.error(\"file is nil\")\n self.original_filename = nil\n self.has_attached_file = false\n return false\n elsif (!check_file?(file))\n logger.error(\"error uploading file\")\n self.original_filename = nil\n self.has_attached_file = false\n\n return false\n else\n self.add_file_datastream(file, :label => file.original_filename, :mimeType => file.content_type, :dsid => 'content', :controlGroup => 'M')\n self.original_filename = file.original_filename\n self.mime_type = file.content_type\n self.has_attached_file = true\n end\n return true\n end", "def upload(file, someone)\n end", "def create_uploaded_file\n Hyrax::UploadedFile.create(user: @user, file: local_file)\n end", "def add_file(file, release_id, package_id, processor=nil)\n page = '/frs/admin/editrelease.php'\n\n userfile = open file, 'rb'\n\n type_id = userfile.path[%r|\\.[^\\./]+$|]\n type_id = FILETYPES[type_id]\n processor_id = PROCESSORS[processor.downcase]\n\n form = {\n \"step2\" => '1',\n \"group_id\" => group_id,\n \"package_id\" => package_id,\n \"release_id\" => release_id,\n \"userfile\" => userfile,\n \"type_id\" => type_id,\n \"processor_id\" => processor_id,\n \"submit\" => \"Add This File\"\n }\n\n boundary = Array::new(8){ \"%2.2d\" % rand(42) }.join('__')\n boundary = \"multipart/form-data; boundary=___#{ boundary }___\"\n\n http_post(page, form, 'content-type' => boundary)\n end", "def add_file name, file, mime, content\n @params << \n \"Content-Disposition: form-data; name=\\\"#{name}\\\"; filename=\\\"#{file}\\\"\\n\" +\n \"Content-Transfer-Encoding: binary\\n\" +\n \"Content-Type: #{mime}\\n\" + \n \"\\n\" + \n \"#{content}\"\n end", "def Upload file\n \n APICall(path: \"uploads.json?filename=#{file.split('/').last}\",method: 'POST',payload: File.read(file))\n \n end", "def upload_file(f, body, options={})\n file = init_fog_file(f, body, options)\n if self.config.enabled?\n return directory(options).files.create( file )\n else\n return local_file(f, body, options)\n end\n end", "def swfupload_file=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).to_s\n self.file = data\n end", "def swfupload_file=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).to_s\n self.file = data\n end", "def upload\n secure_silence_logs do\n return bad_request unless params[:file] && params[:title] && current_account\n is_file = params[:file].respond_to?(:path)\n if !is_file && !(URI.parse(params[:file]) rescue nil)\n return bad_request(:error => \"The 'file' parameter must be the contents of a file or a URL.\")\n end\n \n if params[:file_hash] && Document.accessible(current_account, current_organization).exists?(:file_hash=>params[:file_hash])\n return conflict(:error => \"This file is a duplicate of an existing one you have access to.\")\n end\n params[:url] = params[:file] unless is_file\n @response = Document.upload(params, current_account, current_organization).canonical\n render_cross_origin_json\n end\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, dsid, file_name) if dsid == 'content'\n super\n end", "def upload_simple\r\n \r\n end", "def feature_upload(id, file)\r\n dir = \"home_features\"\r\n file.original_filename = id.to_s + (File.extname file.original_filename)\r\n return write(dir, file)\r\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, file_name) if dsid == 'content'\n super\n end", "def add_file (file)\n @files[file.path] = file\n end", "def create_file_to_upload\n file_path = $redis.get(\"tempfile_path_#{self.id}\")\n tempfile = File.open(file_path,'r')\n\n file = ActionDispatch::Http::UploadedFile.new({\n :tempfile => File.new(tempfile)\n })\n file.original_filename = File.basename(file_path).split(\"_\", 2).last\n file.content_type = \"application/#{File.basename(file_path).split('.').last}\" \n file\n end", "def upload(file)\n Item.create(:upload, :file => file)\n end", "def upload_file=(file_name)\n self.file_field(:id=>\"multifile_upload\").set(File.expand_path(File.dirname(__FILE__)) + \"/../../data/sakai-oae/\" + file_name)\n end", "def add_file (file)\n @files[file.path] = file\n end", "def add_file(file, skip_fits)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size\n self.file_uuid = UUID.new.generate\n unless skip_fits\n self.add_fits_metadata_datastream(file)\n end\n true\n end", "def swfupload_file=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).to_s\n self.ufile = data\n end", "def add_files(*files)\n Rails.logger.info \"Adding #{files.map(&:upload_file_name).join(', ')} to bundle #{self.bundle_type}:#{self.id} in #{self.study.name}\"\n files.each do |file|\n file.update!(study_file_bundle_id: self.id)\n end\n additional_files = StudyFileBundle.generate_file_list(*files)\n self.original_file_list += additional_files\n self.save!\n Rails.logger.info \"File addition to bundle #{self.bundle_type}:#{self.id} successful\"\n end", "def add_from_uploaded_file(entry, upload_token_id, type=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'entry', entry);\n\t\t\tclient.add_param(kparams, 'uploadTokenId', upload_token_id);\n\t\t\tclient.add_param(kparams, 'type', type);\n\t\t\tclient.queue_service_action_call('baseentry', 'addFromUploadedFile', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def add_file(file_path)\n @ole.AddFile(file_path)\n end", "def add_file(file_path)\n @ole.AddFile(file_path)\n end", "def file_upload(file)\n file[\"//\"] = \"/\"\n file = ENV['RED5_HOME'] + \"/webapps/encrev1/#{file}\"\n request_url = \"#{@url}/file/demo\"\n request_url += \"?uid=#{@conf.uid}&sid=#{@conf.sid}\"\n $log.info \"Request filename : #{request_url}\"\n response = RestClient.put request_url, \"\"\n $log.info \"--> Got reponse : #{response}\"\n file_name = JSON.parse(response.to_str)['result']\n if file_name\n $log.info \"--> Got filename : #{file_name}\"\n request_url = \"#{@url}/file/demo/\"\n request_url += file_name\n request_url += \"?uid=#{@conf.uid}&sid=#{@conf.sid}\"\n $log.info \"Upload (#{file}) to Encre : #{request_url}\"\n response = RestClient.put request_url, File.read(file), :content_type => 'application/x-shockwave-flash'\n $log.info \"Delete #{file} ...\"\n file = File.delete(file)\n else\n file_name = nil\n end\n rescue\n file_name = nil\n $log.info \"... failed ! (check exception below)\"\n $log.info $!\n end", "def upload_file\n @assignment = Assignment.find(params[:id])\n if ((@assignment.facebook_user.id == @fb_user.id) or (@assignment.is_author? @fb_user))\n @add_file_url = ActionController::Base.asset_host + \"/assignments/add_file/\"\n else\n flash[:alert] = \"You do not have permissions to add a file to that assignment.\"\n redirect_to @assignment\n end\n\n end", "def add_file(values)\n convert_to_multipart unless self.multipart? || self.body.decoded.blank?\n add_multipart_mixed_header\n if values.is_a?(String)\n basename = File.basename(values)\n filedata = File.open(values, 'rb') { |f| f.read }\n else\n basename = values[:filename]\n filedata = values\n unless filedata[:content]\n filedata = values.merge(:content=>File.open(values[:filename], 'rb') { |f| f.read })\n end\n end\n self.attachments[basename] = filedata\n end", "def add_file(uploaded_file, path)\n filename = sanitize_filename(uploaded_file.original_filename)\n\n if (path and path != '')\n FileUtils.mkdir_p(self.path_to_folder + path)\n end\n\n # if it's large enough to be a real file\n return FileUtils.copy(uploaded_file.local_path, self.path_to_folder + path + filename) if uploaded_file.instance_of?(Tempfile)\n # else\n File.open(self.path_to_folder + path + filename, \"w\") { |f| f.write(uploaded_file.read) }\n end", "def save_file\n\t\tif file\n\t\t\tdocuments.create({\n\t\t\t\t:uploaded_file => file,\n\t\t\t\t:user_id => user_id\n\t\t\t})\n\t\tend\n\t\t#`cp \"#{file.path}\" \"#{path}\"` if file\n\tend", "def create\n if params[:local_file].present?\n if ingest_local_file\n redirect_to sufia.batch_edit_path(params[:batch_id])\n else\n flash[:alert] = \"Error creating generic file.\"\n render :new\n end\n else\n # They are uploading files.\n super\n end\n end", "def file_upload\n tmp = params[:configfile]\n file = File.join(\"public\", \"uploads\", params[:configfile].original_filename)\n FileUtils.cp tmp.path, file\n puts \"File uploaded to: public/uploads\"\n # Put up file load success alert?\n redirect_to(\"/dashboard/manage\", :notice => \"File #{params[:configfile].original_filename} uploaded\")\n end", "def addFile(file)\r\n @files << file\r\n end", "def file_up(platform, dir)\r\n # specifying an extension by platform\r\n if platform == Msf::Module::Platform::Windows\r\n filex = \".bat\"\r\n else\r\n if payload.encoded =~ /sh/\r\n filex = \".sh\"\r\n elsif payload.encoded =~ /perl/\r\n filex = \".pl\"\r\n elsif payload.encoded =~ /python/\r\n filex = \".py\"\r\n elsif payload.encoded =~ /ruby/\r\n filex = \".rb\"\r\n else\r\n fail_with(Failure::Unknown, 'Payload type could not be checked!')\r\n end\r\n end\r\n \r\n @fname= rand_text_alpha(9 + rand(3)) + filex\r\n data = Rex::MIME::Message.new\r\n data.add_part('./', nil, nil, 'form-data; name=\"uploadDir\"')\r\n data.add_part(payload.encoded, 'application/octet-stream', nil, \"form-data; name=\\\"theFile\\\"; filename=\\\"#{@fname}\\\"\")\r\n \r\n res = send_request_cgi({\r\n 'method' => 'POST', \r\n 'data' => data.to_s,\r\n 'agent' => 'Mozilla',\r\n 'ctype' => \"multipart/form-data; boundary=#{data.bound}\",\r\n 'cookie' => @cookie,\r\n 'uri' => normalize_uri(target_uri, \"Upload.do\") \r\n })\r\n \r\n if res && res.code == 200 && res.body.include?('icon_message_success') # Success icon control\r\n print_good(\"#{@fname} malicious file has been uploaded.\")\r\n create_exec_prog(dir, @fname) # Great. Let's send them somewhere else o_O\r\n else\r\n fail_with(Failure::Unknown, 'The file could not be uploaded!')\r\n end\r\n end", "def add(file); @actions << Action::AddAction.new(file); end", "def upload_an_odm(file_path)\n if File.exist?(\"#{file_path}\")\n self.odm_file_input.attach_file(file_path) # theoretically it should work but have not tested out yet.\n else\n raise 'File not found or file does not exist'\n end\n end", "def file_answer(file_name)\n frm.file_field(:name=>/deliverFileUpload/).set(File.expand_path(File.dirname(__FILE__)) + \"/../../data/sakai-cle-test-api/\" + file_name)\n frm.button(:value=>\"Upload\").click\n end", "def store_file(*args)\n data, content_type, filename = args.reverse\n if filename\n http.put(204, luwak, escape(filename), data, {\"Content-Type\" => content_type})\n filename\n else\n response = http.post(201, luwak, data, {\"Content-Type\" => content_type})\n response[:headers][\"location\"].first.split(\"/\").last\n end\n end", "def upload(command)\n fname = command[1]\n\n #If the user didn't specify the file name, just use the name of the file on disk\n if command[2]\n new_name = command[2]\n else\n new_name = File.basename(fname)\n end\n\n if fname && !fname.empty? && File.exists?(fname) && (File.ftype(fname) == 'file') && File.stat(fname).readable?\n pp @client.files.upload(new_name, WriteConflictPolicy.overwrite, open(fname))\n else\n puts \"couldn't find the file #{ fname }\"\n end\n end", "def swf_uploaded_data=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).first.to_s\n self.file = data\n end", "def swf_uploaded_data=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).first.to_s\n self.file = data\n end", "def create(work)\n super\n file_upload_initial\n update_work(aasm.current_state)\n @uploaded_file = service.upload_file_content\n @handled_uploaded_files = handle_uploaded_file(@uploaded_file)\n @handled_uploaded_files ? file_upload_succeeded : file_upload_failed\n rescue StandardError => e\n file_upload_failed\n log(\"failed during file upload: #{e.message} : #{e.backtrace}\")\n end", "def upload_to_scribd\n ScribdFu::upload(self, file_path) if scribdable?\n end", "def create_file(file)\n @generic_file = GenericFile.new\n @generic_file.batch_id = object.batch.pid\n @generic_file.add_file(file.read, 'content', file.name)\n @generic_file.apply_depositor_metadata(object.edit_users.first)\n @generic_file.date_uploaded = Time.now.ctime\n @generic_file.date_modified = Time.now.ctime\n @generic_file.save\n end", "def upload\n uploaded_io = params[:file]\n File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|\n file.write(uploaded_io.original_filename) \n end\n end", "def add_from_uploaded_file(document_entry, upload_token_id)\n\t\t\tkparams = {}\n\t\t\t# Document entry metadata\n\t\t\tclient.add_param(kparams, 'documentEntry', document_entry);\n\t\t\t# Upload token id\n\t\t\tclient.add_param(kparams, 'uploadTokenId', upload_token_id);\n\t\t\tclient.queue_service_action_call('document', 'addFromUploadedFile', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def add_file(file)\n uploader_to_add = PostImageUploader.new\n uploader_to_add.cache!(file)\n @uploaders.delete_if { |x| x.filename == file.original_filename }\n @uploaders << uploader_to_add\n end", "def create\n if params[:local_file].present?\n # Ingest files already on disk\n filename = params[:local_file][0]\n file = File.open(File.join(current_user.directory, filename), 'rb')\n create_and_save_generic_file(file, '1', nil, params[:batch_id], filename)\n if @generic_file\n Sufia.queue.push(ContentDepositEventJob.new(@generic_file.pid, current_user.user_key))\n redirect_to sufia.batch_edit_path(params[:batch_id])\n else\n flash[:alert] = \"Error creating generic file.\"\n render :new\n end\n else\n # They are uploading files.\n super\n end\n end", "def upload f, photoset\n return if !is_supported?(f)\n \n id = @flickr.photos.upload.upload_file(f, f, \"\", Array.new,\n false, false, false)\n if photoset_exist? photoset\n set_id = get_photoset_id(photoset)\n @flickr.photosets.addPhoto set_id, id\n else\n @flickr.photosets.create photoset, id\n end\n end", "def upload_file(f)\n # grabs the compiled asset from public_path\n full_file_path = File.join(File.dirname(@manifest.dir), f)\n one_year = 31557600\n mime = Rack::Mime.mime_type(File.extname(f)) \n file = {\n :key => f,\n :public => true,\n :content_type => mime,\n :cache_control => \"public, max-age=#{one_year}\",\n :expires => CGI.rfc1123_date(Time.now + one_year) \n }\n\n gzipped = \"#{full_file_path}.gz\" \n\n if File.exists?(gzipped)\n original_size = File.size(full_file_path)\n gzipped_size = File.size(gzipped)\n\n if gzipped_size < original_size\n file.merge!({\n :body => File.open(gzipped),\n :content_encoding => 'gzip'\n })\n log \"Uploading #{gzipped} in place of #{f}\"\n else\n file.merge!({\n :body => File.open(full_file_path)\n })\n log \"Gzip exists but has larger file size, uploading #{f}\"\n end\n else\n file.merge!({\n :body => File.open(full_file_path)\n })\n log \"Uploading #{f}\"\n end\n # put in reduced redundancy option here later if desired\n\n file = bucket.files.create( file )\n end", "def on_post(path)\n acct = I3.server.remote_account\n local_path = DocumentFile::DOC_FILE_PATH + path\n \n # Sanity checks\n unless File.directory?(local_path)\n send_uploaded_file_response I3::NotFoundException.new(\n :message => \"The path '#{path}' could not be found.\")\n return\n end #unless\n \n if DocumentPlatform.check_permission(:write, acct, local_path).empty?\n send_uploaded_file_response I3::SecurityException.new(\n :message => \"You do not have permission to write to folder '#{path}'\")\n return\n end #if\n \n # We are good to go so far, so let's grab the file\n file = I3.server.cgi[\"fileToUpload\"]\n filename = file.filename\n \n # Internet Explorer will sometimes send the whole path. We only want the filename.\n filename = filename.split(\"\\\\\").last if filename =~ /\\w:\\\\/\n \n begin\n response = UploadedFile.save_as(filename, file, local_path)\n send_uploaded_file_response response\n \n rescue I3::SecurityException\n log.warn \"User #{acct.account_name} tried to upload a file to '#{path}' and was denied.\"\n send_uploaded_file_response $!\n \n rescue FileAlreadyExistsException\n log.warn \"User #{acct.account_name} failed to save file '#{File.join(path, filename)}'\" + \n \" (#{$!.message})\"\n response = $!.to_shared\n response.temp_file = UploadedFile.save_as_temp(file)\n response.path = path\n response.original_filename = filename\n response.overwritable = (not DocumentPlatform.check_permission(\n :write, acct, File.join(local_path, filename)).empty?)\n send_uploaded_file_response response\n rescue\n log.warn \"User #{acct.account_name} failed to save file '#{File.join(path, filename)}'\" + \n \" (#{$!.message})\"\n send_uploaded_file_response I3::ServerException.new(\n :title => \"Could not save file\", \n :message => $!.message )\n end #begin\n \n end", "def on_put(path)\n local_path = DocumentFile::DOC_FILE_PATH + File.dirname(path)\n filename = File.basename(path)\n data = I3.server.receive_object\n \n if data.respond_to? :temp_file\n temp_file_path = File.join(UploadedFile::TEMP_FOLDER, data.temp_file)\n unless File.exists? temp_file_path\n I3.server.send_object I3::NotFoundException.new(:message => \"Could not find temp file.\")\n end #unless\n \n begin\n temp_file = File.new(temp_file_path)\n response = UploadedFile.save_as(filename, temp_file, local_path, true)\n I3.server.send_object response\n\n rescue I3::SecurityException\n log.warn \"User #{acct.account_name} tried to upload a file to '#{path}' and was denied.\"\n I3.server.send_object $!\n\n rescue\n log.warn \"User #{acct.account_name} failed to save file '#{File.join(path, filename)}'\" + \n \" (#{$!.message})\"\n I3.server.send_object I3::ServerException.new(\n :title => \"Could not save file\", \n :message => $!.message )\n end #begin\n \n end #if\n end", "def upload!(file_path)\n raise GitCloud::FileException.new(\"NotFound\") unless File.exists? file_path\n file = File.new(File.expand_path(file_path))\n add(file)\n commit\n push\n end", "def uploadImage\n post = DataFile.save(params[:upload], \"\")\n \n f = Family.where(turn: -1).first\n if f.nil?\n f = Family.new\n f.turn = -1\n f.save\n end\n \n f.name = post.to_s\n f.save\n \n # render :text => \"File has been uploaded successfully\"\n redirect_to :back\n end", "def add_file file, opts={}\n opts[:mime_type] ||= Ddr::Utils.mime_type_for(file)\n opts[:original_name] ||= Ddr::Utils.file_name_for(file)\n\n # @file_to_add is set for callbacks to access the data\n self.file_to_add = file\n\n run_callbacks(:add_file) do\n super\n end\n\n # clear the instance data\n self.file_to_add = nil\n end", "def upload_local(path, **opt)\n File.open(path) do |io|\n file_attacher.attach(io, **opt)\n end\n rescue => error\n __output \"!!! #{__method__}: #{error.class}: #{error.message}\"\n raise error\n end", "def add_file(*args)\n context = args.pop\n file_path_hash_or_string, content, commit_msg = args\n file_path_hash = file_path_hash_form(file_path_hash_or_string)\n get_adapter_repo(context).add_file(file_path_hash, content, commit_msg)\n end", "def uploadFile(key = \"\")\n key = 0 < key.length ? key : self.dispatched.fileName\n self.bucket.put(key, self.string)\n self.clear\n end", "def remote_file(task)\n target_roles = task.delete(:roles)\n override = task.delete(:override)\n\n UploadTask.define_task(task) do |t|\n prerequisite_file = t.prerequisites.first\n file = shared_path.join(t.name).to_s.shellescape\n\n on roles(target_roles) do\n if override || !test(\"[ -f #{file} ]\")\n info \"Uploading #{prerequisite_file} to #{file}\"\n upload! File.open(prerequisite_file), file\n end\n end\n\n end\n end", "def add_file(file_params)\n # append a new file to our the current identity's list of bruse_files\n\n file = BruseFile.new(file_params)\n\n if bruse_files << file\n # return file\n file\n else\n # could not append file!\n file.destroy\n nil\n end\n end", "def upload_entry\n e = Entry.new\n e.image = uploaded_file(\"skanthak.png\", \"image/png\")\n return e\n end", "def upload_entry\n e = Entry.new\n e.image = uploaded_file(\"skanthak.png\", \"image/png\")\n return e\n end", "def store_file(uuid)\n Uploadcare::File.store(uuid)\n end", "def uploaded_file=(file); write_attribute(:uploaded_file, file); end", "def upload_file!(file, description)\n execute!(\n api_method: drive.files.insert,\n body_object: file_description(file, description),\n media: Google::APIClient::UploadIO.new(file, file.content_type),\n parameters: { uploadType: 'multipart', alt: 'json'})\n end", "def local_file(f, body, options={})\n #return !self.config.public?\n file = init_fog_file(f, body, options)\n # If the \"file\" is empty then return nil\n return nil if file.nil? || file.blank? || local_root.nil?\n file = local_root(options).files.create( file )\n end", "def simple_file_upload simple_file_upload_file\n absolut_path_file = Dir.pwd.gsub(/\\.tests/, 'tests/files') + '/' + simple_file_upload_file\n\n self.simple_file = absolut_path_file\n end", "def multipart_upload\n end", "def add_file(file)\n @files << file\n end", "def adm_upload_selected\n if params[:upload].nil?\n flash.now[:error]='Es wäre schon gut, vor dem Upload eine Datei auszuwählen'\n else\n fpath=params[:upload].tempfile\n fbasename=File.basename(params[:upload].original_filename)\n # tempf=File.open(fpath,'r:BOM|UTF-8')\n FileUtils.cp fpath, AMP_DIR+'/'+fbasename # Throws exception if it fails\n # tempf.close\n File.unlink(fpath) # Throws exception if it fails\n # Put information on it into DB.\n # Only adds to DB if not exists yet, otherwise old entry is kept\n added_info=Userpage.new_page_with_default(fbasename)\n if added_info.kind_of?(Array)\n if added_info.length == 0\n flash.now[:info]=\"Neue Version von #{fbasename} gespeichert.\"\n else\n flash.now[:error]=\"Fehler beim Speichern in die Datenbank: \"+added_info.to_sentence\n end\n else\n flash.now[:info]=\"Datei #{fbasename} gespeichert.\"\n end\n end\n prepare_admin_home_data\n render admin_pages_home_path\n end", "def upload\n create_document\n \n render_upload\n end", "def upload(obj, file_path)\n begin\n res = scribd_user.upload(:file => escape(file_path), :access => access_level)\n obj.update_attributes({:ipaper_id => res.doc_id, :ipaper_access_key => res.access_key})\n rescue\n raise ScribdFuUploadError, \"Sorry, but #{obj.class} ##{obj.id} could not be uploaded to Scribd. \"\n end\n end", "def hook_add_files\n @flavor.class.after_add_files do |files, resource_action, type|\n files.each do |file|\n actions_taken << \"#{resource_action} #{type} #{file}\"\n end\n end\n end", "def upload_file(path, format, file)\n delete path\n append_from_file(path, format, file)\n end", "def js_add_new_file(object)\n update_page do |p|\n p.insert_html :bottom, 'files', :partial => 'file', :object => object\n end\n end", "def upload(bucket, file); end", "def upload_file(file_dir, orig_filename, aip_filename, type)\n @log.info 'Uploading file ' + orig_filename\n @log.info \"Renaming #{type} #{aip_filename} -> #{orig_filename}\"\n\n File.rename(file_dir + '/' + aip_filename,\n file_dir + '/' + orig_filename)\n file = File.open(file_dir + '/' + orig_filename)\n\n uploaded_file = Hyrax::UploadedFile.create(file: file)\n uploaded_file.save\n\n file.close\n\n uploaded_file\nend", "def project_file_add(project_id, file)\n put(\"/projects/#{project_id}/files\", nil, file)\n end", "def upload\n file = params[:file].original_filename\n activity = file.sub(/\\..*$/,'')\n path = RAILS_ROOT + \"/public/data/\" + activity\n Dir.mkdir path\n datapath = path + \"/data/\"\n Dir.mkdir datapath\n basename = datapath + activity\n smi = File.open(\"#{basename}.smi\",\"w\")\n cl = File.open(\"#{basename}.class\",\"w\")\n params[:file].read.each do |line|\n items = line.split(/\\s+/)\n smi.puts \"#{items[0]}\\t#{items[1]}\"\n cl.puts \"#{items[0]}\\t#{activity}\\t#{items[2]}\"\n end\n if LazarCategory.find_by_name(\"Uploads\").blank?\n cat = LazarCategory.create(:name => \"Uploads\")\n else\n cat = LazarCategory.find_by_name(\"Uploads\")\n end\n LazarModule.create(:endpoint => activity, :directory => path, :lazar_category => cat)\n redirect_to :action => :search\n end", "def file\n file = params[\"file\"]\n overwrite = (params[\"overwrite\"] == \"yes\")\n\n error_msg = upload_file(file, overwrite)\n if error_msg != nil\n flash[:alert] = error_msg\n redirect_to upload_form_url()\n return\n end\n\n Rails.logger.info(\"Finding aid uploaded: #{file.original_filename}\")\n redirect_to upload_list_url()\n rescue => ex\n render_error(\"file\", ex, current_user)\n end", "def create\n if params['file'] == nil\n return redirect_to :action => :new\n end\n\n temp_file_path = params['file'].tempfile.path\n inferred_type = infer_type(temp_file_path)\n random_name = SecureRandom.uuid\n\n upload_file(random_name, temp_file_path)\n\n @upload = Upload.new(upload_params)\n @upload['uploadDate'] = Time.now\n @upload['file_extension'] = inferred_type\n @upload['s3_name'] = random_name\n @upload['full_text'] = extract_text(temp_file_path, inferred_type)\n\n if @upload.save\n redirect_to :action => :index, notice: 'Upload was successfully created.'\n else\n render :new\n end\n end", "def perform\n check_file # checks if the file uploaded is valid\n save_file_entry # Uploads the file to the server and saves a entry to database\n end", "def upload_file\n filename = request.headers['X-Filename']\n if filename.blank?\n render plain: \"X-Filename header not provided\",\n status: :bad_request and return\n end\n input = request.env['rack.input']\n input.rewind\n input.set_encoding(Encoding::UTF_8)\n @import.save_file(file: input, filename: filename)\n head :no_content\n end", "def add_file(file)\n @files[file.name] = file\n file.parent = self\n end", "def create\n @f = F.new\n original_filename = params['upload'].original_filename \n \n unless File.exists?(software_path)\n Dir.mkdir(software_path)\n end\n \n unless File.exists?(version_path)\n Dir.mkdir(version_path)\n end\n \n filename = version_path + '/' + original_filename\n file_object = File.open(filename, 'wb+') \n file_object.write(params['upload'].read)\n file_object.close\n \n md5sum = Digest::MD5.file(filename).hexdigest\n \n @f.sn = @package.fs.size + 1\n @f.name = original_filename\n @f.content_type = params['upload'].content_type.chomp\n @f.package_id = @package.id\n @f.md5sum = md5sum\n @f.save\n\n redirect_to software_package_fs_path(@software, @package) \n end", "def create(file, destination = \"/\")\n\t\t# change to before filter\n\t\tif @logged_in\n\t\t\thome_page = @agent.get('https://www.dropbox.com/home')\n\t\telse\n\t\t\thome_page = login\n\t\tend\n\t\t\n\t\tupload_form = home_page.forms.detect{ |f| f.action == \"https://dl-web.dropbox.com/upload\" }\n\t\tupload_form.dest = namespace_path(destination)\n\t\tupload_form.file_uploads.first.file_name = file if file\n\t\t\n\t\[email protected](upload_form).code == \"200\"\n\tend", "def put(file, destFolder)\n\t\t\t@a_file = file\t\t\t\t\t\t# Get a copy of attachment \t\t\t\n\t\t\t# Call Dropbox Client\n\t\t\[email protected]_file(destFolder+\"/\"+file, open(file))\n\t\t\tputs \"Uploaded: \"+file\n\tend", "def swfupload_file=(data)\n self.music_attach = data\n end", "def upload(opts = {})\n options = {\n var: \"upload_#{@@upload_counter}\"\n }\n @@upload_counter += 1\n @parts.push(upload: options.merge(opts))\n end" ]
[ "0.7202717", "0.7095032", "0.68771875", "0.6794102", "0.6717206", "0.6717206", "0.6666275", "0.66188914", "0.65814596", "0.6578944", "0.65714294", "0.65434194", "0.6533004", "0.6514539", "0.65074474", "0.6497595", "0.648155", "0.6434443", "0.6428496", "0.6428496", "0.64201474", "0.641852", "0.6417492", "0.6415545", "0.6386415", "0.63699347", "0.6362562", "0.6349379", "0.63422334", "0.6337953", "0.63276386", "0.6320397", "0.63137454", "0.62895477", "0.6279391", "0.6279391", "0.62696034", "0.62630534", "0.6260921", "0.6251968", "0.6246966", "0.62395227", "0.6238887", "0.62365156", "0.62206215", "0.6200421", "0.61991614", "0.619242", "0.6187973", "0.61803764", "0.617923", "0.617923", "0.6177698", "0.6175447", "0.61598516", "0.6158811", "0.6152649", "0.612558", "0.6118115", "0.6115575", "0.61149955", "0.61118287", "0.60941243", "0.6093617", "0.60931885", "0.6089", "0.60875446", "0.60861063", "0.6085993", "0.6084528", "0.60820735", "0.6079687", "0.6079687", "0.60780245", "0.6070909", "0.60648656", "0.60584474", "0.6052654", "0.6047212", "0.6044576", "0.6022342", "0.6021248", "0.6020473", "0.6015436", "0.6014027", "0.6008875", "0.6006277", "0.5999982", "0.5989901", "0.59882206", "0.5988008", "0.598251", "0.5979151", "0.5978776", "0.5971995", "0.59666747", "0.5961701", "0.5961598", "0.5960774", "0.595516" ]
0.8243698
0
create a member with a membership fee payment, branding fee paid return the member
def create_member_with_member_and_branding_payments_expiring(member_pay_expires = Time.zone.today + 1.year, payment_create_date: Time.zone.now, membership_status: :current_member) u = create(:member, last_day: member_pay_expires, membership_status: membership_status) u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date) create(:payment, user: u, payment_type: Payment::PAYMENT_TYPE_BRANDING, status: SUCCESSFUL_PAYMENT, expire_date: member_pay_expires, created_at: payment_create_date, updated_at: payment_create_date) u.payments.each { |payment| payment.update(created_at: payment_create_date, updated_at: payment_create_date) } u end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @member = Member.new(member_params)\n #@member.card_id = SecureRandom.uuid\n @member.magma_coins = 0\n add_abo_types_to_member(@member)\n respond_to do |format|\n if @member.save\n format.html { redirect_to current_user.present? ? @member : members_path, notice: t('flash.notice.creating_member') }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new, alert: t('flash.alert.creating_member') }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n ActiveRecord::Base.transaction do\n @membership = @member.memberships.build(membership_params)\n @plan = Plan.find(params[:membership][:plan_id])\n coupon = params[:membership][:coupon].present? ? params[:membership][:coupon] : nil\n @trial_period_end = params[:membership][:trial_period_days].present? ? set_trial_period_end_date : 'now'\n\n if params[:membership][:payment_type] == 'Stripe'\n stripe_sub = Stripe::Subscription.create(\n customer: @member.stripe_id,\n trial_end: @trial_period_end,\n coupon: coupon,\n :items => [\n {\n :plan => @plan.stripe_id,\n },\n ]\n )\n\n @membership.stripe_sub_id = stripe_sub.id\n @membership.next_invoice_date = Time.at(stripe_sub.current_period_end).to_datetime\n @membership.start_date = set_start_date\n elsif @plan.stripe_id.present?\n @stripe_plan = Stripe::Plan.retrieve(@plan.stripe_id)\n start_date = set_start_date\n plan_interval = @stripe_plan.interval\n plan_interval_count = @stripe_plan.interval_count\n next_date = case plan_interval\n when 'day'\n start_date + plan_interval_count.days\n when 'week'\n start_date + plan_interval_count.weeks\n when 'month'\n start_date + plan_interval_count.months\n when 'year'\n start_date + plan_interval_count.years\n end\n @membership.next_invoice_date = next_date\n end\n\n respond_to do |format|\n if @membership.save!\n format.html { redirect_to @member, notice: 'Membership was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n member_attr = sign_up_params[:member_attributes]\n if validate_email(sign_up_params[:email])\n member_attr[:institution_id] = get_institute(sign_up_params[:email])\n member_attr[:role_id] = Role.find_by(name: 'Pending').id\n member_attr[:account_privacy_id] = 1\n member = Member.new(member_attr)\n user =\n User.new(email: sign_up_params[:email],\n password: sign_up_params[:password],\n password_confirmation: sign_up_params[:password_confirmation],\n last_sign_in_at: Time.now)\n if member.valid? && !member[:name].empty?\n create_transaction(member, user)\n else\n render 'missing_fields'\n return\n end\n else\n render 'invalid_email'\n return\n end\n end", "def create\n @member = Member.new(member_params)\n @member.phone = nil if @member.phone == \"+375\"\n\n if @member.site_user.blank?\n @member.site_user = nil\n end\n\n @member.join_date = Date.today if @member.join_date.blank?\n @member.card_number = Member.last_card_number + 1 if @member.card_number.blank?\n\n respond_to do |format|\n if @member.save\n CrmMailer.with(member: @member).greet_new_member.deliver_later\n\n format.html { redirect_to member_pay_path(@member), notice: 'Участник успешно зарегистрирован' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @membership_fee = MembershipFee.new\n @membership_fee.member_id=(params[:member_id])\n @member = Member.find(@membership_fee.member_id)\n @[email protected]_method\n @[email protected]\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership_fee }\n end\n end", "def create_membership\n member = Member.new(squad: @squad, user: current_user, membership: 'owner')\n member.save(validate: false)\n end", "def create\n\n @user = current_user\n if @user.is_admin? and not session[:express_token]\n # Make a new membership.\n @membership = Membership.new(membership_params)\n @membership.purchase_date = DateTime.now\n payment_complete = true\n else\n # Do the PayPal purchase\n payment_complete = false\n notice_message_for_user = \"Something went wrong, sorry!\"\n @user = current_user\n @membership = @user.memberships.build(:valid_from => (@user.last_membership.try(:expiry_date) or DateTime.now), :duration => session[:express_purchase_membership_duration], :purchase_date => DateTime.now)\n\n if session[:express_autodebit]\n # It's an autodebit, so set that up\n # 1. setup autodebit by requesting payment\n ppr = PayPal::Recurring.new({\n :token => session[:express_token],\n :payer_id => session[:express_payer_id],\n :amount => (session[:express_purchase_price] / 100),\n :ipn_url => \"#{payment_notifications_url}\",\n :currency => 'AUD',\n :description => session[:express_purchase_description]\n })\n response_request = ppr.request_payment\n logger.info \"XXXXXXXXXXXX\"\n logger.info response_request.to_json\n # raise \"Response denied\"\n logger.info \"XXXXXXXXXXXX\"\n\n if response_request.approved?# and response_request.completed?\n # 2. create profile & save recurring profile token\n # Set :period to :daily and :frequency to 1 for testing IPN every minute\n ppr = PayPal::Recurring.new({\n :token => session[:express_token],\n :payer_id => session[:express_payer_id],\n :amount => (session[:express_purchase_price] / 100),\n :currency => 'AUD',\n :description => session[:express_purchase_description],\n :frequency => session[:express_purchase_membership_duration], # 1,\n :period => :monthly, # :daily,\n :reference => \"#{current_user.id}\",\n :ipn_url => \"#{payment_notifications_url}\",\n :start_at => (@membership.valid_from + session[:express_purchase_membership_duration].months), # Time.now\n :failed => 1,\n :outstanding => :next_billing\n })\n\n response_create = ppr.create_recurring_profile\n if not(response_create.profile_id.blank?)\n @membership.paypal_profile_id = response_create.profile_id\n # If successful, update the user's membership date.\n # update_membership_expiry_date\n # Reset refund if they had one in the past\n @membership.refund = nil\n\n # TODO: Background task\n # TODO: Check paypal recurring profile id still valid\n # TODO: Setup future update_membership_expiry_date\n\n # Save the PayPal data to the @membership model for receipts\n save_paypal_data_to_membership_model\n payment_complete = true\n else\n # Why didn't this work? Log it.\n logger.warn \"create_recurring_profile failed: #{response_create.params}\"\n end\n else\n # Why didn't this work? Log it.\n logger.warn \"request_payment failed: #{response_request.params}\"\n notice_message_for_user = response_request.params[:L_LONGMESSAGE0]\n raise \"Request payment failed\"\n end\n else\n # It's a single purchase so make the PayPal purchase\n response = EXPRESS_GATEWAY.purchase(session[:express_purchase_price], express_purchase_options)\n\n if response.success?\n # If successful, update the user's membership date.\n # update_membership_expiry_date\n logger.info \"Paypal is happy!\"\n save_paypal_data_to_membership_model\n payment_complete = true\n else\n # The user probably hit back and refresh or paypal is broken.\n logger.info \"Paypal is sad.\"\n logger.warn response.params\n notice_message_for_user = response.message\n # redirect_to user_path(current_user), notice: response.message\n # return\n end\n end\n\n end\n\n respond_to do |format|\n if payment_complete and @membership.save\n format.html { redirect_to user_path(@user), notice: 'Membership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @membership }\n else\n logger.info \"Uh oh, couldn't save.......\"\n raise \"couldn't save.\"\n format.html { render action: 'index', notice: @membership.errors }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n add_plan_to_user_if_specified!\n \n format.html { redirect_to(@member, :notice => 'Member was successfully created.') }\n format.json { render :json => @member, :status => :created, :location => @member }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @member.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @membership_fee = MembershipFee.new(params[:membership_fee])\n\n respond_to do |format|\n if @membership_fee.save\n format.html { redirect_to @membership_fee, notice: 'Membership fee was successfully created.' }\n format.json { render json: @membership_fee, status: :created, location: @membership_fee }\n else\n format.html { render action: \"new\" }\n format.json { render json: @membership_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(params, membership)\n # Send payload to blip\n data = {\n initials: (params[4].nil? ? params[5][0] : params[4].tr('^a-zA-Z', '')),\n firstname: (params[5].nil? ? params[4][0] : params[5]),\n lastname: [params[6], params[7]].reject{|e| e.nil? or e.empty?}.join(' '),\n email: (params[3].nil? ? '[email protected]' : params[3]),\n gender: params[9] == 'Vrouw' ? 'F' : 'M',\n phone: params[14],\n mobile: params[2],\n phone_parents: params[24],\n address: [params[10], params[11], params[12]].join(' '),\n membership: membership,\n }\n begin\n unless params[15].nil?\n data[:dateofbirth] = Date.strptime(params[15], '%d-%m-%Y').strftime('%Y-%m-%d')\n end\n rescue\n $problems.write \"#{$index}, #{data[:firstname]} #{data[:lastname]}, Birthdate ignored\\n\"\n end\n blip = post('https://people.i.bolkhuis.nl/persons', data)\n\n # Grab uid\n unless blip == nil\n uid = blip['uid']\n\n # Send payload to operculum\n put(\"https://operculum.i.bolkhuis.nl/person/#{uid}\", {\n nickname: params[8],\n study: params[16],\n alive: params[17].nil?,\n inauguration: params[25],\n resignation_letter: params[26],\n resignation: params[27],\n })\n end\nend", "def create\n # Init Member\n @member = Member.new(member_params)\n @member.invited = true\n if @member.save\n flash[:info] = \"Registration successful!\"\n @member.send_activation_email\n render 'activate'\n else\n render 'new'\n end\n end", "def create\n @member_payment = MemberPayment.new(params[:member_payment])\n\n respond_to do |format|\n if @member_payment.save\n format.html { redirect_to member_payments_path, notice: 'Member payment was successfully created.' }\n format.json { render json: @member_payment, status: :created, location: @member_payment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member_payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:date_validate] == \"false\"\n @flash = { status: :none }\n else\n @member = Member.new(as_params(params))\n @member.childrens_attributes = params[:member][:childrens_attributes]\n @member.status = true\n _charge_ids = []\n if [2,3,4,5].include?(params[:member][:membership_type].to_i)\n if params[:default_flat_2000].present? && params[:default_flat_2000] == \"DEFAULT_FLAT_2000\"\n _charge_ids = _charge_ids + Charge.where(\"freq_flag = 'DEFAULT_FLAT_2000'\").collect(&:id)\n end\n Charge.where(freq_flag: [\"MEMBER_3_PER_WEEK\",\"MEMBER_4_PER_WEEK\",\"MEMBER_5_PER_WEEK\"]).each_with_index do |charge, index|\n _charge_ids << params[\"member_#{charge.activity.id}_#{index}\"] if params.has_key?(\"member_#{charge.activity.id}_#{index}\")\n end\n Charge.where(freq_flag: [\"MEMBER_SUMMER_1_PER_WEEK\",\"MEMBER_SUMMER_2_PER_WEEK\",\"MEMBER_SUMMER_3_PER_WEEK\"]).each_with_index do |charge, index|\n _charge_ids << params[\"member_summer_#{charge.activity.id}_#{index}\"] if params.has_key?(\"member_summer_#{charge.activity.id}_#{index}\")\n end\n @member.charge_ids = _charge_ids\n end\n if @member.save\n UserMailer.invitation(@member).deliver\n @flash = { status: :success, message: 'Member is successfully created.' }\n else\n @flash = { status: :warning, message: @member.errors.full_messages.join(',') }\n end\n end\n rescue Exception => e\n @flash = { status: :danger, message: e.message }\n end", "def create\n user = Member.new(user_params)\n if user.save\n code = user.id + 24523009\n user.update(affiliate_code: code)\n MemberupJob.set(wait: 20.seconds).perform_later(user)\n sign_in(user)\n render json: user,serializer: Api::V1::MembersSerializer, :status => 201\n else\n render json: \"errors\", :status => 422\n end \n end", "def create\n @beneficiaire = Beneficiaire.find(params[:beneficiaire_id])\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @beneficiaire, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html {redirect_to @beneficiaire, error: 'Member was not successfully created!' }\n format.json { render json: @beneficiaire.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @payment = Payment.new(params[:payment])\n\n respond_to do |format|\n if @payment.save\n CrmMailer.thank_for_payment(@payment)\n\n format.html { redirect_to @payment, notice: 'Payment was successfully created.' }\n format.json { render json: @payment, status: :created, location: @payment }\n else\n @members = Member.all\n format.html { render action: \"new\" }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def membership_fee\n if business_admin?\n {\"amount\" => 29900, \"id\" => \"business-29900\"}\n elsif church_admin?\n {\"amount\" => 9900, \"id\" => \"church-9900\"}\n elsif alliance_admin?\n {\"amount\" => 9900, \"id\" => \"alliance-9900\"}\n else\n {\"amount\" => 4900, \"id\" => \"individual-4900\"}\n end\n end", "def create\n @member = Member.new(params[:member])\n @member.phone = nil if @member.phone == \"+375\"\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to new_payment_for_url(@member), notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_member(cost, gym)\n Membership.new(cost, self, gym)\n end", "def create_membership_request\n member = Member.new(squad: @squad, user: current_user, membership: 'request')\n member.save(validate: false)\n end", "def create\n @member = Member.new(params[:member]) \n if @member.save\n \n require 'aweber'\n @oauth = AWeber::OAuth.new('Ak8Buwis5Q1j0OwvVZ4eJROe','TjtgHED5PIYPqS85ZgBekIf9jol1PgpUEpETmrV9')\n @oauth.authorize_with_access('Agvk8sGM8K4XFU2axg2d9z2j', 'qcAyJIPah2lBKcqrU85IviuOXjC0gLtYx0koG115')\n @aweber = AWeber::Base.new(@oauth)\n @account = @aweber.account\n\n new_subscriber = {}\n new_subscriber[\"email\"] = params[:member][:email]\n new_subscriber[\"name\"] = params[:member][:username] \n @account.lists.find_by_name(\"cpclist\").subscribers.create(new_subscriber)\n \n \n insert_id = @member.id\n random_string = SecureRandom.hex(5)\n Member.find(insert_id).update_attribute(:random_code, random_string)\n\n flash[:success] = \"Member was successfully created.\"\n session[:user_id] = insert_id\n redirect_to root_url\n #render 'home/index'\n\n flash[:success] = \"\";\n\n #render :partial => 'home/index', :locals => { :success => flash[:success] }\n else\n render 'home/index'\n end\n end", "def create\n $lovedone = nil\n @family_member = User.new(family_member_params)\n @family_member.profile.user_type = Profile.user_types[:family_member]\n respond_to do |format|\n if @family_member.save\n unless family_member_params_for_lovedone[:lovedones].blank?\n follower = Follower.new user_id: @family_member.id, request_status: \"invited\", \n lovedone_id: family_member_params_for_lovedone[:lovedones]\n follower.save\n end\n @family_member.send_on_create_confirmation_instructions_ex\n format.html { redirect_to familymembers_path, notice: 'Family member was successfully created.' }\n #format.json { render :show, status: :created, location: @family_member }\n else\n if current_user.admin?\n @lovedones = Lovedone.all\n else\n @lovedones = current_user.lovedones\n end\n format.html { render :new }\n format.json { render json: @family_member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = GroupMember.new(params[:member])\n if @current_member.group.add_member @member\n render :json=>{success:true, new_id:@member.id}\n UserMailer.invite_email(@member.email).deliver\n else\n render :json=>{success:false, errors:@member.errors}\n end\n end", "def create\n @member = Member.where(email: params[:member][:email]).first\n if @member\n @member.active = true\n @member.update(member_params)\n else\n @member = Member.new(member_params)\n end\n respond_to do |format|\n if @member.save\n Notify.welcome_email(@member).deliver_now\n if current_user.nil?\n log_in @member\n is_admin?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n end\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n\t\t@member = Member.new(params[:member])\n\n\t\trespond_to do |format|\n\t\t\tif @member.save\n\t\t\t\tformat.html { redirect_to(@member.membership, :notice => 'Member was successfully created.') }\n\t\t\t\tformat.xml\t{ render :xml => @member, :status => :created, :location => @member }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml\t{ render :xml => @member.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def generate_membership\n Membership.create(taller_id: id, role_id: Role.propietario.id, usuario_id: owner_id, current: true)\n Role.administrador\n Role.operador\n Role.propietario\n end", "def create\n @member = @organization.members.build(member_params)\n\n respond_to do |format|\n if @member.save\n logger.info(\"User #{current_user.email} created Member '#{@member.first_name} #{@member.last_name}' on #{@member.updated_at}\")\n format.html { redirect_to organization_path(@organization), notice: 'Member was successfully created.' }\n #format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fundation = Fundation.new(params[:fundation])\n respond_to do |format|\n if @fundation.save\n FundationAdmin.create(:member_id =>params[:member_id], :fundation_id => @fundation.id, :active=>true)\n format.html { redirect_to(@fundation, :notice => 'Fundation was successfully created.') }\n format.xml { render :xml => @fundation, :status => :created, :location => @fundation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fundation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @payment = Payment.new(payment_params)\n @user = User.find(params[:user_id])\n @payment.proofreader_id = current_user.id\n @payment.request = current_user.balance \n \n \n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n recipient = Stripe::Recipient.create(\n :name => @payment.legalname,\n :type => \"individual\",\n :bank_account => token\n )\n current_user.recipient = recipient.id\n current_user.save\n \n\n transfer = Stripe::Transfer.create(\n :amount => (@payment.request * 97).floor,\n :currency => \"usd\",\n :recipient => current_user.recipient\n )\n\n current_user.balance = 0\n current_user.save\n\n respond_to do |format|\n if @payment.save\n format.html { redirect_to dashboard_path, notice: 'Payment was successfully made. You should see your money in your account within 7 business days.' }\n format.json { render action: 'show', status: :created, location: @payment }\n else\n format.html { render action: 'new' }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n r = params[:member]\n @member = Member.where(:email => r[:email], :group_name => r[:group_name], :admin_uuid => session[:user_uuid]).first\n r = @member.attributes.merge(r) unless @member.nil?\n @member = Member.new(r) if @member.nil?\n @member.update_attributes(r) unless @member.nil?\n\n unless @member.err\n @member.get_member_uuid\n end\n respond_to do |format|\n unless @member.nil?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_finance_fee(collection, student)\n last_receipt_no = FinanceFee.last.receipt_no if FinanceFee.last\n fee = FinanceFee.new\n fee.finance_fee_collection_id = collection\n fee.student_id = student\n fee.is_paid = false\n if last_receipt_no.nil?\n fee.receipt_no = 001\n else\n fee.receipt_no = last_receipt_no.next\n end\n fee.save\n end", "def create\n @invoice = Invoice.find(params[:invoice_id])\n @payment = Payment.new(payment_params)\n respond_to do |format|\n if @invoice.payments << @payment\n total = @invoice.payments.sum(\"price\")\n if total == @invoice.total || total > @invoice.total\n res = total - @invoice.total if total > @invoice.total\n @invoice.member.update_attributes(payment_add: res)\n @invoice.update_attributes(status: 2)\n end\n format.html { redirect_to @invoice, notice: 'Payment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @payment }\n else\n format.html { render action: 'new' }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n r = params[:member]\n @member = Member.where(:email => r[:email], :group_name => r[:group_name], :admin_uuid => session[:user_uuid]).first\n r = @member.attributes.merge(r) unless @member.nil?\n @member = Member.new(r) if @member.nil?\n @member.update_attributes(r) unless @member.nil?\n unless @member.err\n @member.get_member_uuid\n end\n respond_to do |format|\n unless @member.nil?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_recommend_a_new_member(body)\r\n # Prepare query url.\r\n _path_url = '/v1/airline/members/'\r\n _query_builder = Configuration.get_base_uri\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 'content-type' => 'application/json; charset=utf-8'\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 _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n NewMemberResponse.from_hash(decoded)\r\n end", "def membership_params\n params.require(:membership).permit(:fee)\n end", "def create\n @club=Club.find(session[:current_club])\n @title=\"Sign up\"\n logout_keeping_session!\n @member = @club.members.build(params[:member])\n success = @member && @member.save\n \n \n if success\n session[:current_club]=nil\n # Member dem Club zuordnen\n # @club.members << @member\n flash[:success] = \"Member created for #{@club.name}\"\n redirect_to(login_path)\n else\n flash.now[:error] = \"We couldn't set up that account, sorry. Please try again, or contact an admin. \"\n render :action => 'new'\n end\n \n end", "def create\n\n @pending_membership = PendingMembership.new(club_id: params[:user][:pending_membership][:club_id])\n\n params[:user].delete(\"pending_membership\")\n\n @user = User.new(params[:user])\n @possible_memberships = PendingMembership.where(user_email: @user.email)\n\n if @possible_memberships.length > 0 && @user.save\n new_user = User.last\n @membership = Membership.new\n @membership.user_id = new_user.id\n @membership.club_id = @possible_memberships.first.club_id\n @possible_memberships.first.destroy\n @membership.save\n session[:user_id] = @user.id\n redirect_to @user, notice: 'Account and membership successfuly created.'\n elsif @user.save\n @pending_membership.user_id = @user.id \n @pending_membership.user_first_name = @user.first_name\n @pending_membership.user_last_name = @user.last_name\n @pending_membership.user_email = @user.email\n @pending_membership.save\n UserMailer.admin_verification(@pending_membership).deliver\n UserMailer.welcome(@user).deliver\n session[:user_id] = @user.id\n redirect_to @user, notice: 'Account successfuly created.' \n else\n # needed for render 'new' in case of form errors \n @user.pending_memberships.build\n render action: \"new\"\n end\n end", "def create\n @member = Member.new(member_params)\n @creating_member = true\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'El miembro ha sido creado' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(member_params)\n @member.save\n if @member.save\n redirect_to members_path\n else render :new\n end\n end", "def create_transaction(member, user)\n if !User.exists?(email: sign_up_params[:email])\n User.transaction do\n member.save!\n user[:member_id] = member[:id]\n if user.valid? && user.save!\n sign_in(user)\n flash[:notice] = 'Welcome to the Network, ' + member.title + ' ' +\n member.name\n redirect_to root_path\n else\n render 'error'\n member.destroy\n return\n end\n end\n else\n render 'existing_email'\n end\n end", "def signup_request me,member\n @by_member = member\n @amount = me.amount\n @me = me\n @member_name = member.display_name.nil? ? member.email : member.display_name\n @currency = me.account.currency\n if @me.request_type == \"send_money\"\n subjects = \"You have been sent some money\"\n elsif @me.request_type == \"request_meney\"\n subjects = \"You have been requested some money\"\n end\n mail to: me.sent_on_email, subject: subjects\n end", "def create\n @membership = @member.memberships.build(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership.member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\tif !checkadmin? then return end\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(params[:member])\n @member.warband = current_user.warband if @member.warband.blank?\n respond_to do |format|\n if @member.save\n format.html { redirect_to(@member, :notice => 'Member was successfully created.') }\n format.xml { render :xml => @member, :status => :created, :location => @member }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @member.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_member\n become_member = $browser.element(@selector).link(text: 'Become a Member')\n become_member.click if become_member.exist?\n\n add_new = $browser.element(@selector).link(text: 'Add New')\n add_new.click if add_new.exist?\n end", "def new\n @member = Member.new\n \n end", "def add_member(member)\n Rails.logger.info(\"------------adding #{member} to circle\")\n if !self.circle.users.include?( member )\n member.memberships.create(:circle => self.circle)\n UserMailer.notify_added_to_circle(self,member).deliver\n #send email\n else\n Rails.logger.info(\"--------------already a member!\") \n end\n end", "def create\n @cart = current_cart\n @account_member = AccountMember.new(params[:account_member])\n\n respond_to do |format|\n if @account_member.save\n format.html { redirect_to root_path, notice: 'Daftar member berhasil disimpan' }\n format.json { render json: @account_member, status: :created, location: @account_member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account_member.errors, status: :unprocessable_entity }\n end\n end\n end", "def sign_up(cost,gym)\n Membership.new(self,gym,cost)\n end", "def create_member(data)\n headers = @client.make_request(:post, @client.concat_user_path(\"#{CONFERENCE_PATH}/#{id}/members\"), data)[1]\n id = Client.get_id_from_location_header(headers[:location])\n get_member(id)\n end", "def member_new\n @member = Member.new\n\n #retriving datas\n member = Member.new(email: params[:email], password: params[:password], matricule: SecureRandom.hex(10).upcase, service_id: params[:service_id], phone: params[:phone], region_id: params[:region_id])\n if member.save\n flash[:notice] = \"Membre ajouter avec succes\"\n redirect_to action: member_new\n else\n flash[:notice] = \"Impossible d'enregistrer un partenaire: #{member.errors.messages}\"\n puts \"====== #{member.errors.messages} =======\"\n end\n render layout: 'fylo'\n end", "def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to admin_member_path(@member), notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(params[:member])\n @member.new = false\n\n respond_to do |format|\n if @member.save\n flash[:notice] = 'Member was successfully created.'\n format.html { redirect_to members_url(@member) }\n format.xml { head :created, :location => member_url(@member) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @member.errors.to_xml }\n end\n end\n end", "def create\n @member = @current_enterprise.members.build(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_bepaid_bill\n # Don't touch real web services during of test database initialization\n return if Rails.env.test?\n\n user = self\n\n bp = BePaid::BePaid.new Setting['bePaid_baseURL'], Setting['bePaid_ID'], Setting['bePaid_secret']\n\n amount = user.monthly_payment_amount\n\n #amount is (amoint in BYN)*100\n bill = {\n request: {\n amount: (amount * 100).to_i,\n currency: 'BYN',\n description: 'Членский взнос',\n email: '[email protected]',\n notification_url: 'https://hackerspace.by/admin/erip_transactions/bepaid_notify',\n ip: '127.0.0.1',\n order_id: '4444',\n customer: {\n first_name: 'Cool',\n last_name: 'Hacker',\n },\n payment_method: {\n type: 'erip',\n account_number: 444,\n permanent: 'true',\n editable_amount: 'true',\n service_no: Setting['bePaid_serviceNo'],\n }\n }\n }\n req = bill[:request]\n req[:email] = user.email\n req[:order_id] = user.id\n req[:customer][:first_name] = user.first_name\n req[:customer][:last_name] = user.last_name\n req[:payment_method][:account_number] = user.id\n\n begin\n res = bp.post_bill bill\n logger.debug JSON.pretty_generate res\n rescue => e\n logger.error e.message\n logger.error e.http_body if e.respond_to? :http_body\n user.errors.add :base, \"Не удалось создать счёт в bePaid, проверьте лог\"\n end\n end", "def new\n @member = Member.new\n # set the initial data for member\n @member.role = MemberRole.general_role\n @member.account = current_member.account\n end", "def create\n plan = params[\"payment\"][\"plan\"]\n plan=\"premium_monthly\" if plan.empty?\n stripe_token = params[:payment][:stripe_customer_token]\n cardHolderName = params[\"cardHolderName\"]\n email = params[\"payment\"][\"email\"]\n flag = false\n\n if stripe_token\n begin\n @payment = current_user.payments.new(payment_params)\n customer = current_user.do_transaction(params[:payment_type], stripe_token, plan, cardHolderName, email)\n if customer\n @payment.stripe_customer_token = customer.id\n subcripted_detail = customer.subscriptions[\"data\"][0]\n flash[:notice] = 'Card charged successfully'\n else\n flag = true\n flash[:alert] = 'Some error happened while charging you, please double check your card details'\n end\n rescue Stripe::APIError => e\n flash[:alert] = e\n flag = true\n end\n else\n flag = true\n flash[:alert] = 'You did not submit the form correctly'\n end\n\n if flag\n render new_payment_path({plan: plan, error: e})\n end\n\n respond_to do |format|\n if @payment.save\n plan = Payment.plans[plan]\n current_user.update_attributes(subscription: plan, remaining_days: -1, stripe_customer_id: customer.id, is_paid_user: true)\n NotificationMailer.monthly_subscription_email(current_user, subcripted_detail).deliver_now\n format.html { redirect_to \"/users/edit\", notice: 'Payment made successfully.'}\n format.json { render json: @payment, status: :created, location: @payment }\n end\n end\n\n end", "def sign_up(gym, cost)\n Membership.new(self, gym, cost)\n\n end", "def create_co_and_payment(company_number, payment_exp_date, member_pay_expires: Time.zone.today + 1.year, payment_create_date: Time.zone.now)\n\n u = create(:member_with_membership_app, company_number: company_number)\n u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date)\n\n co = u.shf_application.companies.first\n\n create(:payment,\n user: u,\n payment_type: Payment::PAYMENT_TYPE_MEMBER,\n status: SUCCESSFUL_PAYMENT,\n expire_date: member_pay_expires,\n created_at: payment_create_date,\n updated_at: payment_create_date)\n\n branding_payment = create(:payment,\n user: u,\n payment_type: Payment::PAYMENT_TYPE_BRANDING,\n status: SUCCESSFUL_PAYMENT,\n expire_date: payment_exp_date,\n created_at: payment_create_date,\n updated_at: payment_create_date)\n\n co.payments << branding_payment\n co\n end", "def create\n @fee = Fee.new(fee_params)\n @fee.user_id = current_user.id\n\n respond_to do |format|\n if @fee.save\n format.html { redirect_to @fee, notice: 'Fee was successfully created.' }\n format.json { render :show, status: :created, location: @fee }\n else\n format.html { render :new }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def allowed_to_pay_new_membership_fee?\n return false if admin?\n\n (not_a_member? || former_member?) &&\n RequirementsForMembership.requirements_excluding_payments_met?(self)\n end", "def create\n @member = Member.new(member_params)\n unless @member.set_region_admin == \"1\"\n @member.region_id = current_member.region_id\n end\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n @uplines = Member.order(\"fullname\")\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def addmember\n\t\t@member=User.new\n\t\tend", "def create_first_payment\n make_payment\n end", "def create_payment\n unless self.payment_id\n payment = Payment.new\n payment.paymenttype = 'credit note'\n payment.amount = self.price\n payment.currency = User.current.currency.name\n payment.date_added = Time.now\n payment.shipped_at = Time.now\n payment.completed = 1\n payment.user_id = self.user.id\n payment.owner_id = self.user.owner_id\n payment.tax = tax.count_tax_amount(self.price)\n payment.save\n return payment\n end\n end", "def create\n # type = \"member\"\n\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render action: 'show', status: :created, location: @member }\n else\n format.html { render action: 'new' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @family_member = FamilyMember.new(params[:family_member])\n @family_member.family = @current_family\n\n respond_to do |format|\n if @family_member.save\n format.html { redirect_to(family_family_member_url(@current_family, @family_member), :notice => 'A Family Member was successfully created.') }\n format.xml { render :xml => @family_member, :status => :created, :location => @family_member }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @family_member.errors, :status => :unprocessable_entity }\n end\n end\n end", "def sign_up (gym, cost) \n Membership.new(cost, gym, self)\n end", "def allowed_to_pay_member_fee?\n return false if admin?\n\n if current_member? || in_grace_period?\n allowed_to_pay_renewal_member_fee?\n else\n allowed_to_pay_new_membership_fee?\n end\n end", "def create\n @member = TeamMember.new(team_member_params)\n if @member.save\n flash[:success] = t('create_team_member_success')\n redirect_to team_members_url\n else\n render 'new'\n end\n end", "def create\n super\n resource.update(password: params[:password], password_confirmation: params[:password_confirmation], member_id: SecureRandom.alphanumeric(6))\n post_gmo_with_create_member(resource)\n end", "def create\n brigade = Brigade.find(params[:brigade_id])\n @brigade_membership = brigade.brigade_memberships.create(brigade_membership_params)\n\n respond_to do |format|\n if @brigade_membership.save\n format.html { redirect_to brigade_brigade_memberships_url, notice: 'Brigade membership was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n success = false\n no_success_message = \"\"\n \n # find the epicenter membership that the user wants\n @membership = Membership.find(params[:membership_id])\n membershipcard = current_user.get_membershipcard( @epicenter )\n\n # subscription to \"new circle movement\"\n if @epicenter == @mother\n flash[:warning] = 'This option is no longer active'\n redirect_path = epicenter_path(@epicenter)\n \n # subscription to all other epicenters\n else \n puts \"create non-NCM Epicenter subscription\"\n stripe_customer = false\n \n success = @epicenter.validate_and_pay_new_membership( current_user, @membership )\n unless success\n no_success_message = \"Du har ikke nok beholdning og/eller månedlig tilførsel af #{@epicenter.mother.fruittype.name}\"\n end\n end\n\n if success\n if @epicenter == @mother\n current_user.name = params['stripeBillingName']\n splitted_name = current_user.name.split(' ')\n if splitted_name.length > 2\n current_user.last_name = splitted_name[-1]\n current_user.first_name = current_user.name.strip().gsub(current_user.last_name, '')\n elsif splitted_name == 2\n current_user.first_name = splitted_name[0]\n current_user.last_name = splitted_name[1]\n else\n current_user.first_name = splitted_name[0]\n end\n current_user.save\n end\n\n @epicenter.make_membershipcard( current_user, @membership, stripe_customer )\n @epicenter.make_member( current_user )\n @epicenter.harvest_time_for( current_user )\n\n log_details = { membership: @membership.name }\n EventLog.entry(current_user, @epicenter, NEW_MEMBERSHIP, log_details, LOG_COARSE)\n\n @request = session[:new_ncm_membership]\n if stripe_customer and @request \n @child = Epicenter.find_by_slug(@request['epicenter_id'])\n @child_membership = @child.memberships.find(@request['membership_id'])\n\n session.delete(:new_ncm_membership)\n\n if @child.validate_and_pay_new_membership( current_user, @child_membership )\n @child.make_membershipcard( current_user, @child_membership, false )\n @child.make_member( current_user )\n @child.harvest_time_for( current_user )\n log_details = { membership: @child_membership.name }\n EventLog.entry(current_user, @child, NEW_MEMBERSHIP, log_details, LOG_COARSE)\n end\n end\n\n if @child\n if current_user.has_member_tshirt?(@child)\n flash[:success] = \"Welcome. You are now a member of #{@child.name} and #{@epicenter.name}\"\n redirect_path = epicenter_path(@child)\n else\n flash[:success] = \"Welcome. You are now a member of #{@child.name}. BUT NOT #{@epicenter.name}\"\n redirect_path = epicenter_path(@epicenter)\n end\n else\n flash[:success] = \"Welcome. You are now a member af #{@epicenter.name}\"\n redirect_path = epicenter_path(@epicenter)\n end\n else\n flash[:warning] = no_success_message\n redirect_path = new_epicenter_subscription_path(@epicenter)\n end\n\n\n redirect_to redirect_path\n end", "def new\n @account = Account.new\n @account.memberships.build.build_user\n @plans = Plan.all\n end", "def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save!\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def addmywwmember \n\t\t@vendor=Vendor.find(current_vendor.id)\n\t\t@membership=Vendormember.find_by_user_id_and_vendor_id(params[:user_id], current_vendor.id)\n\n\n\t\tif @membership.nil?\n\n\t\t@member=Vendormember.create(:user_id=>params[:user_id], :vendor_id=>current_vendor.id, :userApproved=>false, :status=>\"waiting\")\n\t\t@user=User.find(params[:user_id])\n\t\trespond_to do |format|\n\t\tif @member.save\n\t\t@[email protected](:notificationTo=>\"User\",:notificationToId=>params[:user_id], :message=> params[:message])\n\t\tBusinessclaimMailer.delay.mywwmembership(@user, @vendor) \n\n\t\tformat.html { render :json => \"Successfully sent a notification to user. Please wait for the approval.\" }\t\t \n\t\tformat.js { render :json => \"Successfully sent a notification to user. Please wait for the approval.\" }\n\t\telse\n\t\tformat.html { render :json => @member.errors.full_messages.first }\t\t \t\t \n\t\tformat.js { render :json => @member.errors.full_messages.first }\n\t\tend\n\t\tend\n\n\t\telse\n\n\t\tif @membership.status==\"waiting\"\n\t\trespond_to do |format|\n\t\tformat.html { render :json => \"Already Waiting approval.\" }\t\t \n\t\tformat.js { render :json => \"Already Waiting approval.\" }\n\t\tend\n\t\tend\n\t\tend\n\t\tend", "def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @membership.save_with_payment!(params[:card_id])\n MembershipNotifier.new(user: @user, membership: @membership).notify_new\n\n redirect_to user_membership_path(@user, @membership), notice: t('.payment_successful')\n rescue => err\n flash.now[:alert] = ErrorNotifier.notify(err)\n\n prepare_new_form\n render action: 'new'\n end", "def create\n #@account_member = AccountMember.new(params[:account_member])\n #@account = Account.find(params[:id])\n #authorize! :admin_team, @account\n if @account.user_count <= @account.account_members.count\n redirect_to account_account_members_path(@account), :notice => \"Unable to add another user. Increase number of account users to add.\"\n else\n email = params[:email]\n user = User.find_by_email(email)\n if user.nil?\n @account.account_members.create( :email => email )\n else\n m = @account.account_members.create( :email => email)\n m.user = user # REVIEW Is this safe?\n m.save\n end\n # respond_to do |format|\n # if @account_member.save\n # format.html { redirect_to @account_member, notice: 'Account member was successfully created.' }\n # format.json { render json: @account_member, status: :created, location: @account_member }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @account_member.errors, status: :unprocessable_entity }\n # end\n # end\n redirect_to account_account_members_path(@account), :notice => \"Team member with email #{email} was successfully created.\"\n \n end\n\n end", "def create\n @member = User.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def sign_up(gym, cost)\n Membership.new(self, gym, cost)\n end", "def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member = Member.new(params[:member])\n @member.house = current_member.house\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to root_url, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def member_registered(member_id)\n @member = Member.find(member_id)\n mail to: @member.email, cc: \"[email protected]\", subject: \"Thank you for registering #{@member.fullname}\"\n end", "def add_creator_as_member\n Membership.add_membership(created_by_id, id)\n end", "def new\n @member = Member.new\n end", "def new\n @member = Member.new\n end", "def new\n @member = Member.new\n end", "def new\n @member = Member.new\n end", "def create\n # You maybe want to log this notification\n notify = Paypal::Notification.new request.raw_post\n \n # Split the item_id\n account_id = notify.item_id\n \n @user = User.find account_id\n\n if notify.acknowledge\n # Make sure you received the expected payment!\n if notify.complete? and 9.99 == Decimal.new( params[:mc_gross] ) and notify.type == \"subscr_payment\"\n # All your bussiness logic goes here\n @user.premium = true\n @user.valid_till = Date.today + 1.month\n @user.save\n render :nothing => true\n end\n end\n end", "def create_invitiation_token\n membership_token = Membership.new_token\n update_attribute(:invitiation_token, membership_token)\n end", "def create\n @membership = Membership.new(params[:membership])\n @membership.member = current_member\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to sub_clubs_path, :notice => 'You requested membership.' }\n format.json { render :json => @membership, :status => :created, :location => @membership }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @membership.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n @user.update_attribute(:token, SecureRandom.hex(6))\n RegistrationMailer.registration_confirmation(@user, new_email_confirmation_url(token: @user.token)).deliver\n if( @user.account == \"premium\")\n redirect_to new_charge_path :user, @user\n else\n redirect_to root_path, notice: \"An email has been sent to your account. Please click the link in the email to verify address and complete your registration.\"\n end\n else\n flash[:error] = \"Error creating new user. Please try again.\"\n render :new\n end\n\n end", "def add_member(user)\n update_membership(user, true)\n end", "def create\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n flash[:notice] = 'Member was successfully created.'\n format.html { redirect_to(@member) }\n format.xml { render :xml => @member, :status => :created, :location => @member }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @member.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @membership = Membership.new(params[:membership])\n @membership.user_id = current_user.id\n if @membership.save\n end\n end", "def create \n logger.info \"Loading MemberUser create action\" \n @member_user = Member.new(params[:member])\n logger.debug \"New member form values - attributes hash: #{@member_user.attributes.inspect}\"\n @member_user.origin = 'web'\n logger.debug \"Origin set to -> #{@member_user.origin.inspect}\"\n @member_user.validation_mode = \"web\"\n logger.debug \"Web validation mode set - #{@member_user.validation_mode.inspect}\"\n if @member_user.valid_with_captcha?\n logger.debug \"Member form values incl captcha valid...proceeding\"\n if @member_user.save\n logger.debug \"New member saved successfully...\"\n #Send welcome e-mail for web profiles\n logger.debug \"Sending delayed welcome email to new member\"\n MemberMailer.delay.welcome_mail_new_member(@member_user.id)\n flash[:success] = t(:member_created, :scope => [:business_validations, :frontend, :member_user])\n redirect_to root_path\n else\n logger.debug \"Error when creating member\"\n logger.fatal \"Error when creating member\"\n flash[:error] = t(:member_create_error, :scope => [:business_validations, :frontend, :member_user])\n redirect_to root_path\n end\n else\n logger.debug \"Member form values not valid. Loading new view with validation errors\"\n render :new\n end\n end" ]
[ "0.69762033", "0.6961654", "0.6950737", "0.6841401", "0.68327266", "0.67581135", "0.6729609", "0.6715025", "0.669848", "0.6658047", "0.66500276", "0.64890933", "0.6476469", "0.6470372", "0.6454703", "0.64526945", "0.6439926", "0.64303267", "0.6428765", "0.6383507", "0.6378504", "0.6377442", "0.6365143", "0.6354198", "0.63047504", "0.63010764", "0.630049", "0.62988895", "0.6297385", "0.62839687", "0.62735033", "0.6272753", "0.6269089", "0.62646747", "0.6241507", "0.6237418", "0.623631", "0.621935", "0.62175167", "0.6214711", "0.6202048", "0.61980873", "0.61900926", "0.618592", "0.6181915", "0.6180852", "0.6175631", "0.6172125", "0.6169649", "0.61630446", "0.6160673", "0.61508816", "0.6147296", "0.61472183", "0.6145393", "0.61440414", "0.61214113", "0.612043", "0.61147267", "0.6113001", "0.6090782", "0.60905194", "0.6089026", "0.6083752", "0.60687906", "0.6066526", "0.6063435", "0.60615313", "0.60611916", "0.6060174", "0.6055622", "0.60482264", "0.60467935", "0.60441613", "0.603759", "0.603552", "0.60324347", "0.60324347", "0.60324347", "0.60324347", "0.6031299", "0.60306627", "0.60203606", "0.6015232", "0.60097474", "0.6006604", "0.6005725", "0.60003936", "0.5999434", "0.5999434", "0.5999434", "0.5999434", "0.5998583", "0.5994266", "0.5993615", "0.599323", "0.59911823", "0.59893286", "0.5986859", "0.59846747" ]
0.7537223
0
create a paid up member with a given company number, make a payment with the expire date.
def create_co_and_payment(company_number, payment_exp_date, member_pay_expires: Time.zone.today + 1.year, payment_create_date: Time.zone.now) u = create(:member_with_membership_app, company_number: company_number) u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date) co = u.shf_application.companies.first create(:payment, user: u, payment_type: Payment::PAYMENT_TYPE_MEMBER, status: SUCCESSFUL_PAYMENT, expire_date: member_pay_expires, created_at: payment_create_date, updated_at: payment_create_date) branding_payment = create(:payment, user: u, payment_type: Payment::PAYMENT_TYPE_BRANDING, status: SUCCESSFUL_PAYMENT, expire_date: payment_exp_date, created_at: payment_create_date, updated_at: payment_create_date) co.payments << branding_payment co end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_member_with_member_and_branding_payments_expiring(member_pay_expires = Time.zone.today + 1.year,\n payment_create_date: Time.zone.now,\n membership_status: :current_member)\n u = create(:member, last_day: member_pay_expires, membership_status: membership_status)\n u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date)\n\n create(:payment,\n user: u,\n payment_type: Payment::PAYMENT_TYPE_BRANDING,\n status: SUCCESSFUL_PAYMENT,\n expire_date: member_pay_expires,\n created_at: payment_create_date,\n updated_at: payment_create_date)\n u.payments.each { |payment| payment.update(created_at: payment_create_date, updated_at: payment_create_date) }\n u\n end", "def create\n\n @user = current_user\n if @user.is_admin? and not session[:express_token]\n # Make a new membership.\n @membership = Membership.new(membership_params)\n @membership.purchase_date = DateTime.now\n payment_complete = true\n else\n # Do the PayPal purchase\n payment_complete = false\n notice_message_for_user = \"Something went wrong, sorry!\"\n @user = current_user\n @membership = @user.memberships.build(:valid_from => (@user.last_membership.try(:expiry_date) or DateTime.now), :duration => session[:express_purchase_membership_duration], :purchase_date => DateTime.now)\n\n if session[:express_autodebit]\n # It's an autodebit, so set that up\n # 1. setup autodebit by requesting payment\n ppr = PayPal::Recurring.new({\n :token => session[:express_token],\n :payer_id => session[:express_payer_id],\n :amount => (session[:express_purchase_price] / 100),\n :ipn_url => \"#{payment_notifications_url}\",\n :currency => 'AUD',\n :description => session[:express_purchase_description]\n })\n response_request = ppr.request_payment\n logger.info \"XXXXXXXXXXXX\"\n logger.info response_request.to_json\n # raise \"Response denied\"\n logger.info \"XXXXXXXXXXXX\"\n\n if response_request.approved?# and response_request.completed?\n # 2. create profile & save recurring profile token\n # Set :period to :daily and :frequency to 1 for testing IPN every minute\n ppr = PayPal::Recurring.new({\n :token => session[:express_token],\n :payer_id => session[:express_payer_id],\n :amount => (session[:express_purchase_price] / 100),\n :currency => 'AUD',\n :description => session[:express_purchase_description],\n :frequency => session[:express_purchase_membership_duration], # 1,\n :period => :monthly, # :daily,\n :reference => \"#{current_user.id}\",\n :ipn_url => \"#{payment_notifications_url}\",\n :start_at => (@membership.valid_from + session[:express_purchase_membership_duration].months), # Time.now\n :failed => 1,\n :outstanding => :next_billing\n })\n\n response_create = ppr.create_recurring_profile\n if not(response_create.profile_id.blank?)\n @membership.paypal_profile_id = response_create.profile_id\n # If successful, update the user's membership date.\n # update_membership_expiry_date\n # Reset refund if they had one in the past\n @membership.refund = nil\n\n # TODO: Background task\n # TODO: Check paypal recurring profile id still valid\n # TODO: Setup future update_membership_expiry_date\n\n # Save the PayPal data to the @membership model for receipts\n save_paypal_data_to_membership_model\n payment_complete = true\n else\n # Why didn't this work? Log it.\n logger.warn \"create_recurring_profile failed: #{response_create.params}\"\n end\n else\n # Why didn't this work? Log it.\n logger.warn \"request_payment failed: #{response_request.params}\"\n notice_message_for_user = response_request.params[:L_LONGMESSAGE0]\n raise \"Request payment failed\"\n end\n else\n # It's a single purchase so make the PayPal purchase\n response = EXPRESS_GATEWAY.purchase(session[:express_purchase_price], express_purchase_options)\n\n if response.success?\n # If successful, update the user's membership date.\n # update_membership_expiry_date\n logger.info \"Paypal is happy!\"\n save_paypal_data_to_membership_model\n payment_complete = true\n else\n # The user probably hit back and refresh or paypal is broken.\n logger.info \"Paypal is sad.\"\n logger.warn response.params\n notice_message_for_user = response.message\n # redirect_to user_path(current_user), notice: response.message\n # return\n end\n end\n\n end\n\n respond_to do |format|\n if payment_complete and @membership.save\n format.html { redirect_to user_path(@user), notice: 'Membership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @membership }\n else\n logger.info \"Uh oh, couldn't save.......\"\n raise \"couldn't save.\"\n format.html { render action: 'index', notice: @membership.errors }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end", "def make_payment! amount, due_at = Time.now\n rack_payment = Rack::Payment.instance.payment\n rack_payment.amount = amount\n rack_payment.credit_card = credit_card # use the encrypted credit card\n rack_payment.purchase :ip => '127.0.0.1'\n\n # TODO add amount_paid (?)\n completed = completed_payments.create :amount => amount, \n :due_at => due_at,\n :success => rack_payment.success?,\n :response => rack_payment.response\n completed\n end", "def create\n @member = Member.new(member_params)\n @member.phone = nil if @member.phone == \"+375\"\n\n if @member.site_user.blank?\n @member.site_user = nil\n end\n\n @member.join_date = Date.today if @member.join_date.blank?\n @member.card_number = Member.last_card_number + 1 if @member.card_number.blank?\n\n respond_to do |format|\n if @member.save\n CrmMailer.with(member: @member).greet_new_member.deliver_later\n\n format.html { redirect_to member_pay_path(@member), notice: 'Участник успешно зарегистрирован' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def make_premium(month_number)\n self.premium_expiry_date = Time.now + month_number.to_i.months\n self.save\n end", "def payment_new(payment, payable, company_phone)\n @payment = payment\n @payable = payable\n @company_phone = company_phone\n @company = Company.find_by!(\n id: company_phone[:company_id]\n )\n emails = company_phone.extensions.admin\n mail(\n to: emails.map(&:email),\n subject: '¡En GurúComm hemos recibido tu pago!'\n )\n end", "def create\n user = Member.new(user_params)\n if user.save\n code = user.id + 24523009\n user.update(affiliate_code: code)\n MemberupJob.set(wait: 20.seconds).perform_later(user)\n sign_in(user)\n render json: user,serializer: Api::V1::MembersSerializer, :status => 201\n else\n render json: \"errors\", :status => 422\n end \n end", "def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end", "def sign_up(gym, cost)\n Membership.new(self, gym, cost)\n\n end", "def sign_up (gym, cost) \n Membership.new(cost, gym, self)\n end", "def make_payement(amount)\n if amount\n @paid_amount = amount\n end\n end", "def create_wepay_account\n if self.has_wepay_access_token? && !self.has_wepay_account?\n params = { :name => self.name, :description => \" User donate \" + self.donate_amount.to_s } \n response = WEPAY.call(\"/account/create\", self.wepay_access_token, params)\n\n if response[\"account_id\"]\n self.wepay_account_id = response[\"account_id\"]\n return self.save\n else\n raise \"Error - \" + response[\"error_description\"]\n end\n\n end \n raise \"Error - cannot create WePay account\"\nend", "def schedule_payment! amount, due_at = Time.now\n scheduled_payments.create :amount => amount, :due_at => due_at\n end", "def do_purchase\n user.purchases.create!(\n amount_in_cents: purchase_amount,\n employee_id: purchase_params.dig(:employee_id),\n qty: purchase_params.dig(:qty).to_i,\n venue_id: purchase_params.dig(:venue_id),\n tap_id: purchase_params.dig(:tap_id),\n description: purchase_params.dig(:description)\n )\n end", "def sign_up(cost,gym)\n Membership.new(self,gym,cost)\n end", "def make_donation\n # try to see if the donor is already in the database\n @user = User.find_by_email(params[:user_email])\n if !@user # if not, then create the user\n @user = User.new({\n name: params[:user_name],\n email: params[:user_email]\n })\n unless @user.valid? && @user.save\n error(@user.errors.full_messages)\n return redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n end\n # create the payment object with the details provided\n @payment = Payment.new({\n campaign_id: @campaign.id,\n payer_id: @user.id,\n wepay_payment_id: params[:payment_method_id],\n wepay_payment_type: params[:payment_method_type],\n amount: params[:amount]\n })\n if [email protected]?\n error(@payment.errors.full_messages)\n return redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n # if the payment is valid, make the /checkout/create call\n # and then save the updated details\n if @payment.valid? && @payment.create_checkout && @payment.save\n @user.add_role(User::ROLE_PAYER)\n @user.save\n @campaign.update_amount_donated\n message(\"Donation Made!\")\n redirect_to(\"/campaign/donation_success/#{@campaign.id}/#{@payment.id}\")\n else\n error(@payment.errors.full_messages)\n redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n end", "def create\n Payjp.api_key = \"sk_test_c62fade9d045b54cd76d7036\"\n @user = user\n\n if customer_id = @user.customer_id\n customer = Payjp::Customer.retrieve(id: customer_id)\n else\n customer = Payjp::Customer.create(card:payjp_token)\n @user.customer_id = customer.id\n @user.save!\n end\n\n plans = customer.subscriptions.data.collect(&:plan).collect(&:id)\n plan_id = \"#{@item.id}_#{@item.interval}\"\n if plans.include?(plan_id)\n plan = Payjp::Plan.retrieve(id: \"#{@item.id}_#{@item.interval}\")\n subscription = customer.subscriptions.data.select{|data| data.plan.id == plan_id}.first\n if subscription\n unless subscription.status == \"active\"\n subscription.resume\n end\n update_role(subscription)\n else\n subscription = Payjp::Subscription.create(customer:customer.id, plan: plan.id)\n update_role(subscription)\n end\n else\n plan = Payjp::Plan.create(id: \"#{@item.id}_#{@item.interval}\", amount: \"#{@item.price}\", interval: \"#{@item.interval}\", currency: \"jpy\")\n subscription = Payjp::Subscription.create(customer:customer.id, plan: plan.id)\n update_role(subscription)\n end\n\n if subscription\n @order = Order.find_or_create_by(subscription: subscription.id)\n @order.item = item\n @order.user = @user\n @order.current_period_end = Time.at(subscription.current_period_end)\n @order.save\n redirect_to @order, notice: 'Order was successfully created.'\n else\n redirect_to new, notice: 'Order was not created.'\n end\n\n end", "def sign_up(gym, cost)\n Membership.new(self, gym, cost)\n end", "def create_first_payment\n make_payment\n end", "def create\n payer_email = params[:payer_email]\n txn_type = params[:txn_type] # subscr_failed, subscr_cancel, subscr_payment, subscr_signup, subscr_eot, subscr_modify\n \n if params[:reason_code] == 'refund'\n # TODO: just notify me that somebody refunded, keep their is_customer flag set to true\n else\n # add/flag customer\n u = User.find_or_create_by_email(payer_email)\n u.first_name = params[:first_name] # overwrite whatever we've got with Paypal's info\n u.last_name = params[:last_name]\n u.password = 'temporary'\n u.is_customer = true\n u.save\n CustomerMailer.deliver_purchase_complete(u) # send them a link\n AdminMailer.deliver_purchase_notification(u) # let me know they were added\n subject = 'Customer added'\n end\n \n render :text => 'OK'\n end", "def credit(postive_amount)\n Credit.create!(team: team,\n room_type: room_type,\n amount: postive_amount)\n end", "def create\n member_attr = sign_up_params[:member_attributes]\n if validate_email(sign_up_params[:email])\n member_attr[:institution_id] = get_institute(sign_up_params[:email])\n member_attr[:role_id] = Role.find_by(name: 'Pending').id\n member_attr[:account_privacy_id] = 1\n member = Member.new(member_attr)\n user =\n User.new(email: sign_up_params[:email],\n password: sign_up_params[:password],\n password_confirmation: sign_up_params[:password_confirmation],\n last_sign_in_at: Time.now)\n if member.valid? && !member[:name].empty?\n create_transaction(member, user)\n else\n render 'missing_fields'\n return\n end\n else\n render 'invalid_email'\n return\n end\n end", "def create_payment\n payment = ShopPayment.new({\n :order => @order,\n :gateway => gateway_name,\n :amount => @order.price,\n :card_type => card_type,\n :card_number=> card_number_secure\n })\n \n @order.update_attribute(:status, 'paid')\n \n @result[:payment] = payment.save\n end", "def paid_signup(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Paid Signup Email')\n @user = user\n mail to: user.email, subject: \"You've Upgraded to our Business Pro plan!\"\n end", "def create\n\n campaign_id = params[:campaign_id]\n credit_card_id = params[:credit_card_id]\n amount = params[:amount]\n\n #testing\n campaign = Campaign.find_by_id(campaign_id)\n user_id = campaign.user_id\n wepay_payment_type = \"credit_card\"\n if(amount>1)\n if(campaign!=nil)\n #create the payment object\n payment = Payment.new({\n campaign_id: campaign_id,\n payer_id: user_id,\n wepay_payment_id: credit_card_id,\n wepay_payment_type: wepay_payment_type,\n amount: amount\n })\n if !payment.valid?\n render json: error(payment.errors.full_messages)\n end\n if payment.valid? && payment.create_checkout && payment.save\n campaign.update_amount_donated\n render json: {\"checkout_id\" => payment[\"wepay_checkout_id\"]}\n else\n render json: payment_invalid_error\n end\n end\n end\n end", "def company_new(company, company_phone)\n @company = company\n @company_phone = company_phone\n @trial_duration = Company::TrialLimits::DURATION\n @play_store = ENV['PLAY_STORE_URL']\n @app_store = ENV['APP_STORE_URL']\n mail(\n to: company_phone.extensions.admin.first.email,\n subject: '¡Bienvenido a GurúComm!'\n )\n end", "def create_payment\n unless self.payment_id\n payment = Payment.new\n payment.paymenttype = 'credit note'\n payment.amount = self.price\n payment.currency = User.current.currency.name\n payment.date_added = Time.now\n payment.shipped_at = Time.now\n payment.completed = 1\n payment.user_id = self.user.id\n payment.owner_id = self.user.owner_id\n payment.tax = tax.count_tax_amount(self.price)\n payment.save\n return payment\n end\n end", "def create\n ActiveRecord::Base.transaction do\n @membership = @member.memberships.build(membership_params)\n @plan = Plan.find(params[:membership][:plan_id])\n coupon = params[:membership][:coupon].present? ? params[:membership][:coupon] : nil\n @trial_period_end = params[:membership][:trial_period_days].present? ? set_trial_period_end_date : 'now'\n\n if params[:membership][:payment_type] == 'Stripe'\n stripe_sub = Stripe::Subscription.create(\n customer: @member.stripe_id,\n trial_end: @trial_period_end,\n coupon: coupon,\n :items => [\n {\n :plan => @plan.stripe_id,\n },\n ]\n )\n\n @membership.stripe_sub_id = stripe_sub.id\n @membership.next_invoice_date = Time.at(stripe_sub.current_period_end).to_datetime\n @membership.start_date = set_start_date\n elsif @plan.stripe_id.present?\n @stripe_plan = Stripe::Plan.retrieve(@plan.stripe_id)\n start_date = set_start_date\n plan_interval = @stripe_plan.interval\n plan_interval_count = @stripe_plan.interval_count\n next_date = case plan_interval\n when 'day'\n start_date + plan_interval_count.days\n when 'week'\n start_date + plan_interval_count.weeks\n when 'month'\n start_date + plan_interval_count.months\n when 'year'\n start_date + plan_interval_count.years\n end\n @membership.next_invoice_date = next_date\n end\n\n respond_to do |format|\n if @membership.save!\n format.html { redirect_to @member, notice: 'Membership was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @Payment = Payment.new\n @Payment.user_id = current_user\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => (25 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for purchasing!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n @Payment.stripe_id = charge.id\n @Payment.amount = charge.amount\n\n if current_user.subscribed != true\n current_user.subscribed = true\n current_user.credit = 25.00\n else\n current_user.credit = current_user.credit + 25.00\n end\n\n current_user.save\n redirect_to caves_path\n end", "def charge\r\n if paypal?\r\n if (@response = paypal.get_profile_details(billing_id)).success?\r\n next_billing_date = Time.parse(@response.params['next_billing_date'])\r\n if next_billing_date > Time.now.utc\r\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\r\n true\r\n else\r\n false\r\n end\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n else\r\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\r\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\r\n true\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n end\r\n end", "def create\n @member = Member.new(params[:member])\n @member.phone = nil if @member.phone == \"+375\"\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to new_payment_for_url(@member), notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(cust_token, data = {})\n pdata = build_payment_info(data)\n data = FiveDL.build_params(data.merge!(transtype: 'updatecustomer', token: cust_token).merge!(pdata))\n FiveDL::Response.new( FiveDL::Gateway.post('/Payments/Services_api.aspx', data) )\n end", "def initialize(owner, expire_date, type)#, dob, phone, vip)\n\t\t@number = rand(10000000)\n\t\t@expire_date = Date.parse(expire_date)\n\t\t@cvv = rand(1000)\n\t\t@name = owner.name\n\t\t# Customer.new(name, dob, phone, vip)\n\tend", "def create_payment(recipient_id, reference, amount)\n post_with_auth 'payment_initiation/payment/create',\n PaymentCreateResponse,\n recipient_id: recipient_id,\n reference: reference,\n amount: amount\n end", "def create\n # You maybe want to log this notification\n notify = Paypal::Notification.new request.raw_post\n \n # Split the item_id\n account_id = notify.item_id\n \n @user = User.find account_id\n\n if notify.acknowledge\n # Make sure you received the expected payment!\n if notify.complete? and 9.99 == Decimal.new( params[:mc_gross] ) and notify.type == \"subscr_payment\"\n # All your bussiness logic goes here\n @user.premium = true\n @user.valid_till = Date.today + 1.month\n @user.save\n render :nothing => true\n end\n end\n end", "def valitation\n # Create a payment and send ID\n end", "def create_wepay_account\n\t\tif self.has_wepay_access_token? && !self.has_wepay_account?\n\t\t\tparams = {:name => self.farm, :description => \"Farm selling \" + self.produce }\n\t\t\tresponse = Wefarm::Application::WEPAY.call(\"/account/create\", self.wepay_access_token, params)\n\t\t\t\n\t\t\tif response[\"account_id\"]\n\t\t\t\tself.wepay_account_id = response[\"account_id\"]\n\t\t\t\treturn self.save\n\t\t\telse\n\t\t\t raise \"Error - \" + response[\"error_description\"]\n\t\t\tend\n\t \n\t\tend\t\t\n\t\traise \"Error - cannot create WePay account\"\n\tend", "def create_merchant email_address, merchant, bank_account_uri=nil, name=nil, meta={}\n account = Account.new(\n :uri => self.accounts_uri,\n :email_address => email_address,\n :merchant => merchant,\n :bank_account_uri => bank_account_uri,\n :name => name,\n :meta => meta,\n )\n account.save\n end", "def new_member(cost, gym)\n Membership.new(cost, self, gym)\n end", "def create\n @purchase = Purchase.new purchase_attributes\n if @purchase.save\n @ok = true\n renewed = Purchase.find_by_id params[:renewed_id]\n if renewed\n renewed.users.each do |u|\n u.purchase_id = @purchase.id\n u.save\n Notification.send_to(\n u.id,\n I18n.t('notifications.account.renewed.title'),\n I18n.t('notifications.account.renewed.message', :expiration_date => TimeConvert.to_string(@purchase.expiration_date)),\n ''\n )\n end\n renewed.expiration_date = Time.zone.now\n renewed.save\n end\n else\n @ok = false\n @errors = @purchase.errors.messages.keys\n @errors << :ssn_code if @errors.include?(:base)\n end\n end", "def create_and_invite\n puts \"MembersController#create_and_invite\"\n # Convert month/year params to date\n params[:joined_at] = \"#{params[:joined_at_y]}-#{params[:joined_at_m]}-1\".to_date\n # Left_at should be the first of next month. A member who's left_at is set to 1st of August will\n # only pay for July.\n params[:left_at] = \"#{params[:left_at_y]}-#{params[:left_at_m]}-1\".to_date.next_month #.end_of_month\n \n # Invite a new member or add an existing to a project\n if params[:invite_or_add] == \"add\"\n # Add to existing project\n @member = Member.find(params[:member][:id])\n # Add member to existing project\n existing_project = Project.find(params[:project_id])\n puts \"Assign project '#{existing_project.name}' (#{params[:project_id]}) with admin #{existing_project.admin_id}, to member '#{@member.name}'.\"\n project_name = existing_project.name\n if existing_project.admin_id == current_member.id\n # Make sure that current member is admin of the project.\n @member.projects << existing_project\n membership = @member.memberships.where(\"project_id = ?\", existing_project.id)\n membership.update(joined_at: params[:joined_at], left_at: params[:left_at])\n @member.save\n \n # Member saved to db. Send invitiation email.\n if params[:send_invitation]\n @member.send_invitation_email sender: current_member, project: existing_project\n flash[:info] = \"Invitation email sent to #{@member.email} from #{current_member.name}. Invited to project #{existing_project.name}.\"\n end\n\n set_current_project_id existing_project.id\n redirect_to root_path and return\n else\n cancel_invite \"NOT PROJECT ADMIN. Member #{current_member.id} is not #{existing_project.admin_id}.\"\n return false\n end\n else\n # Create new and add to existing/newly created project\n # Init Member\n @member = Member.new(member_params)\n if @member.save\n # Saved member (along with project) to database\n puts \"Saved member #{@member.name} to db.\"\n # Choose an existing project or create a new?\n if params[:new_or_existing] == \"new\" && !params[:project][:name].blank?\n # Logged in member wants to create a new project\n project_name = params[:project][:name]\n params[:project][:admin_id] = current_member.id\n if current_member.projects.where(\"admin_id = ? AND name = ?\", current_member.id, project_name).empty?\n # Member is not the admin of a project with this name, create it\n puts \"Will create new Project: '#{project_name}'\"\n # Create project\n puts \"Assign project '#{project_name}' to member '#{@member.name}\"\n puts \"Assign project admin privileges to current member '#{current_member.name}\"\n current_member.projects.build(project_params)\n current_member.save\n else\n flash[:danger] = \"A project named '#{project_name}' already exists. Choose another name.\"\n puts \"A project named '#{project_name}' already exists. Choose another name.\"\n cancel_invite \"PROJECT ALREADY EXISTS\"\n return false\n end\n elsif params[:new_or_existing] == \"existing\" && params[:project_id] != \"0\"\n # Add member to existing project\n existing_project = Project.find(params[:project_id])\n p existing_project\n puts \"Assign project '#{existing_project.name}' (#{params[:project_id]}) with admin #{existing_project.admin_id}, to member '#{@member.name}'.\"\n project_name = existing_project.name\n if existing_project.admin_id == current_member.id\n # Make sure that current member is admin of the project.\n @member.projects << existing_project\n else\n cancel_invite \"NOT PROJECT ADMIN. Member #{current_member.id} is not #{existing_project.admin_id}.\"\n return false\n end\n else\n flash[:danger] = \"Enter a name for a new Project or choose an existing one.\"\n puts \"Enter a name for a new Project or choose an existing one.\"\n cancel_invite \"NO NEW PROJECT NAME or NO PROJECT SELECTED\"\n return false\n end\n @member.current_project_id = params[:project_id]\n @member.save\n\n project = @member.projects.find_by(name: project_name)\n unless project.nil?\n membership = @member.memberships.where(\"project_id = ?\", project.id)\n membership.update(joined_at: params[:joined_at], left_at: params[:left_at])\n @member.save\n\n if project.rents.empty?\n project.rents.create(amount: params[:monthly_rent], due_date: project.start_date.prev_month.change(day: 25))\n end\n end\n\n # Member saved to db. Send invitiation email.\n if params[:send_invitation]\n @member.send_invitation_email sender: current_member, project: project\n flash[:info] = \"Invitation email sent to #{@member.email} from #{current_member.name}. Invited to project #{project_name}.\"\n end\n set_current_project_id project.id\n redirect_to root_path\n else\n flash[:danger] = \"#{@member.name} could not be saved.\"\n p @member.errors.messages\n @projects = current_member.projects.where(admin_id: current_member.id)\n render 'invite'\n end\n end\n\n end", "def create_the_payment_exhibition\n if((params[:invoicing_info][:payment_medium] == \"visa\") or (params[:invoicing_info][:payment_medium] == \"paypal\") or (params[:invoicing_info][:payment_medium] == \"master_card\")) \n credit_card = CreditCard.find_by_user_id(current_user.id)\n if credit_card.blank?\n credit_card = CreditCard.new()\n end\n credit_card.number = params[:credit_card][:number0]+params[:credit_card][:number1]+params[:credit_card][:number2]+params[:credit_card][:number3]+params[:credit_card][:number4]+params[:credit_card][:number5]+params[:credit_card][:number6]+params[:credit_card][:number7]+params[:credit_card][:number8]+params[:credit_card][:number9]+params[:credit_card][:number10]+params[:credit_card][:number11]+params[:credit_card][:number12]+params[:credit_card][:number13]+params[:credit_card][:number14]+params[:credit_card][:number15]\n credit_card.user_id = current_user.id\n credit_card.first_name = params[:credit_card][:first_name]\n credit_card.last_name = params[:credit_card][:last_name]\n credit_card.expiring_date = Date.civil(params[:credit_card][\"expiring_date(1i)\"].to_i,params[:credit_card][\"expiring_date(2i)\"].to_i,params[:credit_card][\"expiring_date(3i)\"].to_i).strftime(\"%y-%m-%d\") \n credit_card.save\n else\n end \n creditcardnumber = params[:credit_card][:number0]+params[:credit_card][:number1]+params[:credit_card][:number2]+params[:credit_card][:number3]+params[:credit_card][:number4]+params[:credit_card][:number5]+params[:credit_card][:number6]+params[:credit_card][:number7]+params[:credit_card][:number8]+params[:credit_card][:number9]+params[:credit_card][:number10]+params[:credit_card][:number11]+params[:credit_card][:number12]+params[:credit_card][:number13]+params[:credit_card][:number14]+params[:credit_card][:number15]\n #######################################this is im copying here is something from payment controller create method\n @order = session[:purchasable] \n if @order.blank?\n render :text =>\"Please Refresh The Page And Try Again\"\n return\n else \n @order.save\n current_user.profile.biography = params[:biography]\n current_user.profile.save\n end\n @current_object = Payment.new(params[:payment])\t\t#@invoice = session[:invoice]\t\t\n \n if @order.instance_of? ExhibitionsUser\n @current_object.amount_in_cents =params[:invoice_amount].to_i*100\n elsif @order.instance_of? CompetitionsUser\n @current_object.amount_in_cents = (@order.find_price(@order.competition.id) ) * 100\n else \n end\n @current_object.user = @current_user\t\t#@current_object.invoice = @invoice\n if @order.instance_of? ExhibitionsUser\n if params[:invoicing_info][:payment_medium] == \"visa\" or params[:invoicing_info][:payment_medium] == \"master_card\" \n @current_object.common_wealth_bank_process((params[:invoice_amount].to_i*100),params,creditcardnumber)\n \n elsif params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n elsif params[:invoicing_info][:payment_medium] == \"paypal\" \n #@current_object.make_paypal_payment((params[:invoice_amount].to_i),params) \n session[:paypal_amount] = params[:invoice_amount].to_i*100\n set_the_token#from here i need to redirect him to paypal after getting the token\n session[:invoice_id] = params[:invoice_id]\n session[:order] = @order\n session[:exhibition_id] = @order.exhibition.id\n session[:current_object_id] = @current_object\n render :update do |page|\n page[\"modal_space_answer\"].hide \n page[\"paypal_form\"].replace_html :partial=>\"paypal_form\",:locals=>{:token =>@token,:amt=>params[:invoice_amount].to_i}\n page.call 'submit_my_form'\n end\n return\n end\n elsif @order.instance_of? CompetitionsUser\n if @order.invoices.last \n total_amount = 0\n @order.invoices.each {|x| total_amount = total_amount + x.final_amount}\n if total_amount < @order.find_price(@order.competition.id) \n more_amount = (@order.find_price(@order.competition.id) ) - total_amount\n @current_object.amount_in_cents = more_amount * 100\n if params[:invoicing_info][:payment_medium] == \"visa\" or params[:invoicing_info][:payment_medium] == \"master card\" \n @current_object.common_wealth_bank_process((more_amount * 100),params)\n elsif params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n elsif params[:invoicing_info][:payment_medium] == \"paypal\" \n @current_object.make_paypal_payment((more_amount * 100),params) \n end\n else\n render :text=>\"You Did not changed the entry field or if you decremented it then send email to admin \"\n return\n end \n else\n if params[:invoicing_info][:payment_medium] == \"visa\" or params[:invoicing_info][:payment_medium] == \"master card\" \n @current_object.common_wealth_bank_process(((@order.find_price(@order.competition.id) ) * 100),params)#payment is done if invoice is not yet created. for competition user\n elsif params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n elsif params[:invoicing_info][:payment_medium] == \"paypal\" \n @current_object.make_paypal_payment(((@order.find_price(@order.competition.id) ) * 100),params) \n end \n end \n else #here it may be come that while working in this method and it fails somewhere and session[:purchasable] = nil. generaly this is not the normal case\n if @order.instance_of? Order\n make_order_payment\n return\n else\n render :text=>\"There Is Internal Error While Making the payment Please Try Go Back And Try Again<a href='/admin/profiles/#{current_user.id}'>Back</a> \"\n end\n return\n end#bank procedure if end\n\t\t#here after the payment is done what message is required to be sent is get decided and the invoice is get generated\n if @current_object.state == 'online_validated'\t # flash[:notice] = 'Your Payment Is Done And Invoice Will Be Sent To You By Email'\n if @order.instance_of? CompetitionsUser \n if @order and @order.invoices.last\n total_amount = 0\n @order.invoices.each {|x| total_amount = total_amount + x.final_amount}\n if total_amount < @order.find_price(@order.competition.id) \n make_the_payment\n render :partial=>\"extra_payment_done\",:locals=>{:competition=>@order.competition,:order=>@order} \n return \n else\n # flash[:error] = \"Your Payment Is Already Done Please Go To Home Page <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n end\n render :text => @template.blank_main_div(:title => 'System error', :hsize => 'sixH', :modal => true), :layout => false\n return\n else \n make_the_payment\n end\n else\n if @order.instance_of? ExhibitionsUser \n make_the_payment_exhibition\n end\n end \n if @order.instance_of? ExhibitionsUser \n \n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. <a href='/admin/exhibitions/#{@order.exhibition.id}'>Select Artwork</a>\"\n else\n invoice = Invoice.find(:last,:conditions=>[\"purchasable_type = ? and client_id = ? and purchasable_id = ?\",\"ExhibitionsUser\" , @order.user,@order.id])\n \n if invoice.state == \"created\"\n alreadypaidamt = @order.price - invoice.final_amount\n note = \"no notes created\"\n note = @order.exhibition.timing.note if @order.exhibition.timing\n create_pdf(invoice.id,invoice.number,@order.exhibition.timing.starting_date.strftime(\"%d %b %Y\"),invoice.client.profile.full_address_for_invoice,invoice.client.profile.full_name_for_invoice,@order.exhibition.title,@order.price.to_i,note,@order.price - alreadypaidamt,alreadypaidamt,true,@order.exhibition.timing.ending_date,\"\")\n QueuedMail.add('UserMailer','send_invoice_exhibition',[@current_object.user.profile.email_address,\"invoice#{invoice.id}\",\"Your Exhibition Payment Is Done And An Invoice Is Sent to Your Email.\",invoice, @current_object.user],0,true,@current_object.user.profile.email_address,\"[email protected]\") \n end \n \n #render :text=>\"Your Payment Is Done Now Upload And Then Select The Artworks <a href='/admin/exhibitions/#{@order.exhibition.id}'>Select Artwork</a>\"\n #render :partial => \"online_response_exhibition_payment\",:locals=>{:exhibition_user_id=>@order.id,:artwork_count=>0}\n add_exhibition_artwork_insamediv\n\t\t\t \n end \n elsif @order.instance_of? CompetitionsUser\n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n #render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. Please Make The Payment Before #{@order.submission_date} <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n render :partial=> \"cash_cheque_response\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order_id=>@order.id,:total_entry=>@order.total_entry}\n else\n #session[:total_entry] = @order.total_entry\n #render :update do |page|\n # session[:store_for_submitting_the_artwork] = @order.id\n #page[\"show_me_the_error\"].replace_html :partial=>\"add_artwork_link\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order_id=>@order.id}\n #end\n render :partial=>\"add_artwork_link\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order_id=>@order.id}\n #render :text=>\"Your Payment Is Done . The Invoice Is Sent To You By Email. <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n end \t \n end\n else\n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n if @order.instance_of? CompetitionsUser\n make_the_payment\n else\n make_the_payment_exhibition\n invoice = Invoice.find(:last,:conditions=>[\"purchasable_type = ? and client_id = ? and purchasable_id = ?\",\"ExhibitionsUser\" , @order.user,@order.id])\n if invoice.state == \"created\"\n note = \"no notes created\"\n note = @order.exhibition.timing.note if @order.exhibition.timing\n senttime \n if invoice.sent_at\n senttime = invoice.sent_at.strftime(\"%d %b %Y\")\n else\n senttime = Time.now.strftime(\"%d %b %Y\")\n end\n \n \n create_pdf(invoice.id,invoice.number,senttime,invoice.client.profile.full_address_for_invoice,invoice.client.profile.full_name_for_invoice,@order.exhibition.title,invoice.final_amount.to_i,note)\n \n QueuedMail.add('UserMailer', 'send_invoice_exhibition', [invoice, @order.user], 0, true)\n end \n end \n if @order.instance_of? CompetitionsUser \n # render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. Please Make The Payment Before #{@order.competition.submission_deadline} <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n render :partial=> \"cash_cheque_response\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order=>@order,:total_entry=>@order.total_entry}\n return \n else\n #exhibition cash_cheque_response\n # render :partial => \"cash_cheque_response_exhibition\",:locals=>{:exhibition_user_id=>@order.id,:artwork_count=>0}\n #instead of this response i need to give the option to add the artwork to user\n \n render :update do |page|\n page[\"add_the_artwork0\"].replace_html :partial=>\"add_the_artwork_exhibition\",:locals=>{:exhibition_user_id => @order.id,:exhibition_id=>@order.exhibition.id,:messageforimageuploaded=>\"After Your Payment Is Done Admin Will Validate You. Please Upload The Artwork\"}\n page[\"description_competition_ex_py\"].hide\n page[\"enterartworkcompetition\"].show\n page[\"add_the_artwork0\"].show\n page[\"iteam_image0\"].show\n page[\"iteam_image_uploaded\"].hide\n \n end\n #render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. <a href='admin/exhibitions/#{@order.exhibition.id}'>Select Artwork</a>\"\n end \t \n return\n end\n\t \n #flash[:error] = 'Error during the payment save '+@current_object.state.to_s\n\t \n #render :partial => 'new', :layout => false\n render :text=>\"Your payment has not been successful. Please check your details and try again\"\n end\n\n end", "def create_wepay_account\n raise 'Error - cannot create WePay account' unless wepay_access_token? && !wepay_account?\n params = { name: farm, description: 'Farm selling ' + produce }\n response = Wefarm::Application::WEPAY.call('/account/create', wepay_access_token, params)\n\n raise 'Error - ' + response['error_description'] unless response['account_id']\n self.wepay_account_id = response['account_id']\n save\n end", "def signup_request me,member\n @by_member = member\n @amount = me.amount\n @me = me\n @member_name = member.display_name.nil? ? member.email : member.display_name\n @currency = me.account.currency\n if @me.request_type == \"send_money\"\n subjects = \"You have been sent some money\"\n elsif @me.request_type == \"request_meney\"\n subjects = \"You have been requested some money\"\n end\n mail to: me.sent_on_email, subject: subjects\n end", "def create\n @user = User.new(params[:user])\n if params[:reservation].nil?\n @company = Company.new(params[:company])\n else\n\t # user has been invited, company already exists\n\t @company = Company.find(params[:company][:id])\n\t @user.company = @company\n\t Reservation.find_by_token(params[:reservation][:token]).delete\n\t end\n\n respond_to do |format|\n if @user.save\n\t if params[:reservation].nil?\n\t\t # set company owner\n\t @company.owner = @user\n\t @company.save\n\t @company.create_default_infos\n\t @user.company = @company\n\t end\n\t @user.save\n format.html { redirect_to :users, notice: 'Registration successful.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def expire!\n successor = BillingPeriod.create! booking: booking,\n start_date: start_of_next_period\n successor.delay.charge!\n end", "def create_checkout(redirect_uri)\n # calculate app_fee as 10% of produce price\n app_fee = self.donate_amount * 0.1\n params = {\n :account_id => self.wepay_account_id,\n :short_description => \"Donate from #{self.name}\",\n :type => 'donation',\n :currency => 'USD',\n :amount => self.donate_amount, \n :fee => { \n :app_fee => app_fee,\n :fee_payer => 'payee'\n },\n :hosted_checkout => {\n :mode => 'iframe',\n :redirect_uri => redirect_uri\n } \n \n }\n response = WEPAY.call('/checkout/create', self.wepay_access_token, params)\n puts response\n if !response\n raise \"Error - no response from WePay\"\n elsif response['error']\n raise \"Error - \" + response[\"error_description\"]\n end\n\n return response\nend", "def create\n # Init Member\n @member = Member.new(member_params)\n @member.invited = true\n if @member.save\n flash[:info] = \"Registration successful!\"\n @member.send_activation_email\n render 'activate'\n else\n render 'new'\n end\n end", "def new_payment(card, taken_amount, auth_amount, auth_code, txn_type)\n payment = creditcard_payments.create(:amount => taken_amount, :creditcard => card)\n # create a transaction to reflect the authorization\n transaction = CreditcardTxn.new( :amount => auth_amount,\n :response_code => auth_code,\n :txn_type => txn_type )\n payment.creditcard_txns << transaction\n transaction\n end", "def new\n @user = User.find(params[:id])\n @order = Order.new\n @order.user = @user\n @order.first_name = @user.profile.firstname\n @order.last_name = @user.profile.lastname\n if params[:companyIdToSell]\n @order.amount = 29 # Basic user to pay $29 when posting a company to sell\n @companyIdToSell = params[:companyIdToSell]\n else\n if params[:upgrade]\n @order.order_type = \"membership_upgrade\"\n if params[:plan_id]\n @order.plan = Plan.find(params[:plan_id])\n else\n @order.plan = Plan.membership_plan(params[:upgrade_plan][:plan_type],@user) #new plan received not the current plan\n if @order.plan.duration==\"1 month\"\n @[email protected]_date.to_date>>(1)\n elsif @order.plan.duration==\"14 month\"\n @[email protected]_date.to_date>>(14)\n end\n @user.save\n end\n if @order.plan.fee<0\n flash[:notice]=\"Please contact Trusted Insight for fee payment.\"\n redirect_to \"/\"\n else\n @order.amount = @order.plan.fee\n end\n else\n @order.order_type = \"sign_up\"\n @order.plan = @user.plan\n if @order.plan.fee<0\n flash[:notice]=\"Please contact Trusted Insight for fee payment.\"\n redirect_to \"/\"\n else\n @order.amount = @user.plan.fee\n end\n end\n end\n end", "def create_bepaid_bill\n # Don't touch real web services during of test database initialization\n return if Rails.env.test?\n\n user = self\n\n bp = BePaid::BePaid.new Setting['bePaid_baseURL'], Setting['bePaid_ID'], Setting['bePaid_secret']\n\n amount = user.monthly_payment_amount\n\n #amount is (amoint in BYN)*100\n bill = {\n request: {\n amount: (amount * 100).to_i,\n currency: 'BYN',\n description: 'Членский взнос',\n email: '[email protected]',\n notification_url: 'https://hackerspace.by/admin/erip_transactions/bepaid_notify',\n ip: '127.0.0.1',\n order_id: '4444',\n customer: {\n first_name: 'Cool',\n last_name: 'Hacker',\n },\n payment_method: {\n type: 'erip',\n account_number: 444,\n permanent: 'true',\n editable_amount: 'true',\n service_no: Setting['bePaid_serviceNo'],\n }\n }\n }\n req = bill[:request]\n req[:email] = user.email\n req[:order_id] = user.id\n req[:customer][:first_name] = user.first_name\n req[:customer][:last_name] = user.last_name\n req[:payment_method][:account_number] = user.id\n\n begin\n res = bp.post_bill bill\n logger.debug JSON.pretty_generate res\n rescue => e\n logger.error e.message\n logger.error e.http_body if e.respond_to? :http_body\n user.errors.add :base, \"Не удалось создать счёт в bePaid, проверьте лог\"\n end\n end", "def create_account_and_subscribe_single_call account_name\n contact = {\n address1: '1051 E Hillsdale Blvd',\n city: 'Foster City',\n country: 'United States',\n firstName: 'John',\n lastName: 'Smith',\n zipCode: '94404',\n state: 'CA'\n }\n #get the rate plans for the product\n product_rate_plan = get_product_rate_plans_for_product 'Medium Monthly Plan'\n myDate = DateTime.now + 10.days;\n #create an account and subscribe to a rate plan at the same time\n subscribe(\n account_name,\n contact,\n DateTime.now.strftime(\"%Y-%m-%d\"),\n myDate.strftime(\"%Y-%m-%d\"),\n product_rate_plan['id']\n )\nend", "def purchase(money, creditcard, options = {})\n post = {}\n add_invoice(post, options)\n add_creditcard(post, creditcard) \n add_address(post, creditcard, options) \n add_customer_data(post, options)\n add_duplicate_window(post)\n \n commit('SALE', money, post)\n end", "def plan_with_balance(company, company_phone)\n @company = company\n @company_phone = company_phone\n mail(\n to: company_phone.extensions.admin.first.email,\n subject: '¡En GurúComm agradecemos tu recarga!'\n )\n end", "def test_a_user_can_create_company_billing_profile_witout_vat_code\n visit new_billing_profile_path\n fill_in_address\n\n fill_in('billing_profile[name]', with: 'ACME corporation')\n\n assert_changes('BillingProfile.count') do\n click_link_or_button('Submit')\n end\n\n assert(@user.billing_profiles\n .where(name: 'ACME corporation')\n .where('vat_code IS NULL'))\n\n assert(page.has_css?('div.notice', text: 'Created successfully.'))\n end", "def create\n plan = params[\"payment\"][\"plan\"]\n plan=\"premium_monthly\" if plan.empty?\n stripe_token = params[:payment][:stripe_customer_token]\n cardHolderName = params[\"cardHolderName\"]\n email = params[\"payment\"][\"email\"]\n flag = false\n\n if stripe_token\n begin\n @payment = current_user.payments.new(payment_params)\n customer = current_user.do_transaction(params[:payment_type], stripe_token, plan, cardHolderName, email)\n if customer\n @payment.stripe_customer_token = customer.id\n subcripted_detail = customer.subscriptions[\"data\"][0]\n flash[:notice] = 'Card charged successfully'\n else\n flag = true\n flash[:alert] = 'Some error happened while charging you, please double check your card details'\n end\n rescue Stripe::APIError => e\n flash[:alert] = e\n flag = true\n end\n else\n flag = true\n flash[:alert] = 'You did not submit the form correctly'\n end\n\n if flag\n render new_payment_path({plan: plan, error: e})\n end\n\n respond_to do |format|\n if @payment.save\n plan = Payment.plans[plan]\n current_user.update_attributes(subscription: plan, remaining_days: -1, stripe_customer_id: customer.id, is_paid_user: true)\n NotificationMailer.monthly_subscription_email(current_user, subcripted_detail).deliver_now\n format.html { redirect_to \"/users/edit\", notice: 'Payment made successfully.'}\n format.json { render json: @payment, status: :created, location: @payment }\n end\n end\n\n end", "def pay\n unless self.payment_id\n payment = create_payment\n self.payment_id = payment.id\n self.status = 'paid'\n self.pay_date = Time.now\n self.save\n add_to_balance\n end\n end", "def create\n @payment = Payment.new(params[:payment])\n\n respond_to do |format|\n if @payment.save\n CrmMailer.thank_for_payment(@payment)\n\n format.html { redirect_to @payment, notice: 'Payment was successfully created.' }\n format.json { render json: @payment, status: :created, location: @payment }\n else\n @members = Member.all\n format.html { render action: \"new\" }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n amount = params[:amount].to_f\n time = params[:time].to_i\n company = Company.find(params[:company_id].to_i)\n Loan.create(company: company,\n investor: current_investor,\n amount: amount,\n time: time)\n redirect_to investor_root_path\n end", "def create_buyer email_address, card_uri, name=nil, meta={}\n account = Account.new(\n :uri => self.accounts_uri,\n :email_address => email_address,\n :card_uri => card_uri,\n :name => name,\n :meta => meta,\n )\n account.save\n end", "def create_buyer email_address, card_uri, name=nil, meta={}\n account = Account.new(\n :uri => self.accounts_uri,\n :email_address => email_address,\n :card_uri => card_uri,\n :name => name,\n :meta => meta,\n )\n account.save\n end", "def create_subscription(credit_card, options = {})\n\n u = self.user\n options[:order_id] = number # currently just loading a date\n options[:email] = u.email\n options[:address] = {\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address1 => u.street_address1,\n :address2 => (u.street_address2 || \"\"),\n :company => (u.company || \"\"),\n :city => u.city,\n :state => u.us_state,\n :zip => u.zip,\n :country => 'United States',\n :phone => u.primary_phone\n }\n\n subscription = OrderTransaction.generate_yearly_subscription(credit_card, options)\n self.save!\n order_transactions << subscription\n\n if subscription.success?\n self.payment_captured!\n else\n self.transaction_declined!\n end\n\n subscription\n end", "def signup(gym, cost, lifter)\n membership = Membership.new(gym, cost)\n self.membership << gym\n end", "def gym_signup(gym, cost)\n Membership.new(gym, cost, self)\n end", "def create_empty_payment_profile(user) \n options = {\n :customer_profile_id => user.authnet_customer_profile_id.to_i, \n :payment_profile => {\n :bill_to => { :first_name => user.first_name, :last_name => user.last_name, :address => '', :city => '', :state => '', :zip => '', :phone_number => '', :email => user.email }, \n :payment => { :credit_card => Caboose::StdClass.new({ :number => '4111111111111111', :month => 1, :year => 2020, :first_name => user.first_name, :last_name => user.last_name }) }\n }\n #, :validation_mode => :live\n } \n resp = self.gateway.create_customer_payment_profile(options) \n if resp.success? \n user.authnet_payment_profile_id = resp.params['customer_payment_profile_id'] \n user.save\n else\n puts \"==================================================================\" \n puts resp.message\n puts \"\"\n puts resp.inspect\n puts \"==================================================================\"\n end\n end", "def register_payout_details(person)\n # nothing to do by default\n end", "def create_organization_and_subscription_plan\n organization = Organization.create(\n name: \"My Organization\",\n subscription_plan_id: self.subscription_plan_id,\n time_zone: self.time_zone\n )\n\n organization_membership = organization.add_user(self)\n organization_membership.role = :owner\n organization_membership.save\n end", "def gen_payment\n cc = @data_object\n pay = Payment.new\n pay.pay_type = Payment::CC\n pay.pay_our_ref = \"CC:\" + sprintf(\"%06d\", cc.cc_id)\n pay.pay_doc_ref = cc.cc_trans_id\n pay.pay_payor = cc.cc_payor[0, 40]\n pay.pay_amount = cc.cc_amount\n pay\n end", "def create\n params[:payment][:amount].gsub!(/[$,]/, \"\")\n params[:payment][:amount] = (params[:payment][:amount].to_f * 100).to_i\n @payment = Payment.new(payment_params)\n\n if params[:booth_id]\n @payable = @booth = Booth.find(params[:booth_id])\n @payer = @booth.vendor\n else\n @payer = Vendor.find(params[:vendor_id])\n end\n\n @payment.payer = @payer\n @payment.payable = @payable\n\n if @payment.save\n if @payment.errors.empty?\n redirect_to(@payment.payable || @payment.payer, notice: \"Payment was successfully created.\")\n else\n redirect_to(@payment.payable || @payment.payer, alert: @payment.errors.full_messages.join(\".\\n\") + \".\")\n end\n else\n @editable = true\n render(:new)\n end\n end", "def create\n billing_record = GatewayTransaction.gateway.start( current_user, request )\n if current_user.power_plan? || billing_record.new_record?\n redirect_to :action => :error, :s => billing_record.plan_id.nil? ? 0 : 1\n else\n redirect_to billing_record.premium_link\n end\n end", "def create\n @payment = @user.payments.build(payment_params)\n if @payment.save\n redirect_to user_payment_url(@user, @payment)\n else\n render :action => \"new\"\n end\n end", "def create\n _user_not_anonymous\n @user = CwaIpaUser.new\n @project = Project.find(Redmine::Cwa.project_id)\n\n if !params[:saa] \n flash[:error] = \"Please indicate that you accept the system access agreement\"\n redirect_to :action => :index\n return\n end\n\n if !params[:tos]\n flash[:error] = \"Please indicate that you accept the terms of service\"\n redirect_to :action => :index\n return\n end\n\n # TODO \n # 1. Call REST to messaging service to notify about account creation\n # 2. Add user to research-computing project\n @user.passwd = params['netid_password']\n\n begin\n @user.create\n rescue Exception => e\n flash[:error] = \"Registration failed: \" + e.to_s\n else\n logger.info \"Account #{@user.uid.first} provisioned in FreeIPA\"\n\n # Add them to the project... allows notifications\n @project.members << Member.new(:user => User.current, :roles => [Role.find_by_name(\"Watcher\")])\n\n CwaMailer.activation(@user).deliver\n\n flash[:notice] = 'You are now successfully registered!'\n end\n redirect_to :action => :index\n end", "def gym_sign_up(gym, membership_cost)\n Membership.new(gym, self, membership_cost)\n end", "def paid(id)\n\t\t@user = User.find(id)\t\n\t\t\tmail(\n\t\t :subject => 'New Sign Up' ,\n\t\t :to => '[email protected]' ,\n\t\t :track_opens => 'true'\n\t\t\t)\n\tend", "def create\n puts \"create*******\"\n puts purchase_params\n user = User.find(session[:user_id])\n email = user.email\n \tpackage_id = params[:purchase][:package]\n \tpurchase_package = Package.find package_id\n \tquantity = purchase_package.quantity.to_s\n \tamount = purchase_package.price.to_i\n \tStripeModel.chargeCreditCard(params[:stripeToken], email, quantity, amount)\n \n \t@purchase = Purchase.new purchase_params\n @purchase.email = email\n \[email protected] = quantity\n \[email protected] = amount\n \[email protected]\t#save method is overridden in the Purchase model\n\n redirect_to user_path(session[:user_id])\n end", "def create_autopay_rent(autopay_params, penalties)\r\n first_pay = MyDate::date_from_date_select(autopay_params, \"first_pay\")\r\n autopay_rent = AutoPay.new({:renter_id => self.id,\r\n :property_id => self.property.id,\r\n :object => autopay_params[\"object\"],\r\n :price => autopay_params[\"price\"],\r\n :category => \"in\",\r\n :groupp => \"najem\",\r\n :last_pay => first_pay,\r\n :repeat => autopay_params[\"repeat\"],\r\n :added => Time.now.to_i})\r\n autopay_rent.save\r\n if autopay_rent.save\r\n autopay_rent.generate_first_bill(autopay_params[:rent_penalty])\r\n end_of_month = Time.utc(Time.now.year,Time.now.month,MyDate::Month[Time.now.month][:days])\r\n autopay_rent.generate_bills(end_of_month)\r\n self.actual_rent.update_attributes({:auto_pay_id => autopay_rent.id,\r\n :penalty_id => autopay_params[:rent_penalty]})\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def create_account_and_create_subscription account_name\n contact = {\n address1: '1051 E Hillsdale Blvd',\n city: 'Foster City',\n country: 'United States',\n firstName: 'John',\n lastName: 'Smith',\n zipCode: '94404',\n state: 'CA'\n }\n\taccount_number = create_account account_name, contact\n\tputs '### Account created in Zuora with number: '+ account_number\n #get the rate plans for the product\n\tproduct_rate_plan = get_product_rate_plans_for_product 'Medium Monthly Plan w Discount'\n #create the subscription\n\tsubscription_number = create_subscription(\n account_number,\n DateTime.now.strftime(\"%Y-%m-%d\"),\n product_rate_plan['id']\n )\n\tputs '### Subscription created in Zuora with number: ' + subscription_number\n return subscription_number\nend", "def purchase\n create_payment(\n user: launched_by,\n organization: organization,\n network_payment_method_id: @network_payment_method.id,\n description: description,\n amount: total_price.to_f,\n quantity: sample_size,\n unit_amount: price_per_response.to_f,\n )\n\n return if payment.persisted?\n\n errors.add(:base, \"Payment failed: #{payment.errors.full_messages.join('. ')}\")\n # throw doesn't work in after_* callbacks, so use this to stop the transaction\n raise ActiveRecord::RecordInvalid, self\n end", "def add_payment_method\n authorize(current_employer)\n @customer = Customer.new\n end", "def create\n @user = User.new(params[:user])\n @user.company = current_company\n create!\n end", "def postContractPaymentSetup( contract_id, payment_provider_id, payment_provider_profile, user_name, user_surname, user_billing_address, user_email_address)\n params = Hash.new\n params['contract_id'] = contract_id\n params['payment_provider_id'] = payment_provider_id\n params['payment_provider_profile'] = payment_provider_profile\n params['user_name'] = user_name\n params['user_surname'] = user_surname\n params['user_billing_address'] = user_billing_address\n params['user_email_address'] = user_email_address\n return doCurl(\"post\",\"/contract/payment/setup\",params)\n end", "def test_11_createaccount_while_donating()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 11 ----------------------\"\n\t\t#~ #---------------- Run HACK URL - Start ------------------------------------#\n\t\tlogin($globaladmin_emailId, $globaladmin_password)\n\t\trunHackURL(\"/admin/reindex\", \"/admin/reindex_all\", \"/admin/memcached_flush\", \"/admin/regenerate_statistics\")\n\t\tlogout()\n\t\t#~ #---------------- Run HACK URL - End ------------------------------------#\n\t\tsleep 120\n\t\tsearchOrg($new_orgname)\n\t\tgotoDonFormClickSignup($donation_amount)\n\t\tcreateRazooAccount($normal2_firstname, $normal2_lastname, $normal2_emailId, $normal2_password)\n\t\tdonateUsingNewCard($donation_amount, $normal2_nameoncard, $street, $state, \n\t\t\t\t\t $city, $pin_code, $mastercard_number, $mastercard_seccode, $normal2don_emailId)\n\t\tpostComments(\"Give and be Blessed!!\")\n\t\tcheckMydonation($donation_amount)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 11 --------------------------\"\n\tend", "def create\n #PaypalCallback object sends the raw post request to paypal and expects to get VERIFIED back\n response = PaypalCallback.new(params, request.raw_post, ENV[\"PAYPAL_POST_URL\"])\n\n #check that the payment says completed & paypal verifies post content\n if response.completed? && response.valid?\n @transaction = Transaction.find(params[:invoice]) #invoice is a pass through variable that gets embedded in the encrpyted paypal form and we get it back here\n Payment.create(:params => params.to_unsafe_h, :transaction_id => @transaction.id, :amount => params['payment_gross'], :confirmed => true)\n else\n #TODO maybe send out some type of alert to an admin\n end\n head :ok\n end", "def create_checkout\n checkout_method = self.campaign.user.checkout_method\n checkout_params = {\n account_id: self.campaign.user.wepay_account_id,\n short_description: \"Donation to #{self.campaign.name}\",\n type: \"DONATION\",\n amount: self.amount.to_s,\n fee_payer: \"payer\",\n callback_uri: self.callback_uri,\n currency: self.currency,\n }\n if(checkout_method == \"iframe\")\n mode = \"iframe\"\n redir = Rails.application.secrets.host + \"/campaign/donation_success/#{self.campaign_id}/#{self.id}\"\n checkout_params[:mode] = mode\n checkout_params[:redirect_uri] = redir\n else\n checkout_params[:payment_method_type] = self.wepay_payment_type\n checkout_params[:payment_method_id] = self.wepay_payment_id\n end\n response = WEPAY.call(\"/checkout/create\", self.campaign.user.wepay_access_token, checkout_params)\n if response[\"error\"]\n throw response[\"error_description\"]\n end\n self.state = response[\"state\"]\n self.wepay_checkout_id = response[\"checkout_id\"]\n self.wepay_fee = response[\"fee\"]\n return response\n end", "def create_wepay_account\n # if we don't have an access_token for this user, then we cannot make this call\n if self.has_wepay_account? then return false end\n # make the /account/create call\n response = WEPAY.call(\"/account/create\", self.wepay_access_token, {\n name: self.campaign.name,\n description: self.campaign.description,\n type: self.campaign.account_type,\n country: self.country,\n currencies: [ self.currency ],\n })\n if response['error'].present?\n raise response['error_description']\n end\n self.wepay_account_id = response['account_id']\n self.save\n end", "def make_donation_iframe\n # try to see if the donor is already in the database\n @user = User.find_by_email(params[:payer_email])\n if !@user # if not, then create the user\n @user = User.new({\n name: params[:payer_email],\n email: params[:payer_email]\n })\n unless @user.valid? && @user.save\n error(@user.errors.full_messages)\n return redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n end\n amount = params[:amount]\n @payment = Payment.new({\n campaign_id: @campaign.id,\n payer_id: @user.id,\n amount: params[:amount]\n })\n if [email protected]?\n error(@payment.errors.full_messages)\n return redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n if @payment.valid? && @payment.save\n @response = @payment.create_checkout\n @checkout_uri = @response[\"checkout_uri\"]\n @payment.state = @response[\"state\"]\n @payment.wepay_checkout_id = @response[\"checkout_id\"]\n if(@response[\"fee\"] == nil)\n @payment.wepay_fee_cents = 0\n end\n @payment.save\n end\n @user.add_role(User::ROLE_PAYER)\n @user.save\n render :action => 'iframe', :user_id => @campaign.id\n end", "def new_credit_card\n # populate new card with some saved values\n ActiveMerchant::Billing::CreditCard.new(\n :first_name => user.first_name,\n :last_name => user.last_name,\n # :address etc too if we have it\n :brand => cc_type\n )\n end", "def create\n @corporate_user, password = User.create_corp_user(corporate_user_params)\n respond_to do |format|\n if @corporate_user.save\n admin_email = User.where(id: @corporate_user.parent_id).first.email\n InviteUser.corporate_user_confirmation(@corporate_user,admin_email,password).deliver\n format.html { redirect_to corporate_users_path, notice: \"#{APP_MSG['corporate_user']['create']}\" }\n format.json { render :show, status: :created, location: corporate_user_path }\n else\n format.html { render :new }\n format.json { render json: @corporate_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def pay_owner(rental)\n # make credit operation on balanced\n balanced.credit(rental)\n\n # account it on subledger\n subledger.credit(rental)\n end", "def singup (gym, cost)\n new_memebership = Membership.new(cost , self, gym)\n end", "def create\n success = false\n no_success_message = \"\"\n \n # find the epicenter membership that the user wants\n @membership = Membership.find(params[:membership_id])\n membershipcard = current_user.get_membershipcard( @epicenter )\n\n # subscription to \"new circle movement\"\n if @epicenter == @mother\n flash[:warning] = 'This option is no longer active'\n redirect_path = epicenter_path(@epicenter)\n \n # subscription to all other epicenters\n else \n puts \"create non-NCM Epicenter subscription\"\n stripe_customer = false\n \n success = @epicenter.validate_and_pay_new_membership( current_user, @membership )\n unless success\n no_success_message = \"Du har ikke nok beholdning og/eller månedlig tilførsel af #{@epicenter.mother.fruittype.name}\"\n end\n end\n\n if success\n if @epicenter == @mother\n current_user.name = params['stripeBillingName']\n splitted_name = current_user.name.split(' ')\n if splitted_name.length > 2\n current_user.last_name = splitted_name[-1]\n current_user.first_name = current_user.name.strip().gsub(current_user.last_name, '')\n elsif splitted_name == 2\n current_user.first_name = splitted_name[0]\n current_user.last_name = splitted_name[1]\n else\n current_user.first_name = splitted_name[0]\n end\n current_user.save\n end\n\n @epicenter.make_membershipcard( current_user, @membership, stripe_customer )\n @epicenter.make_member( current_user )\n @epicenter.harvest_time_for( current_user )\n\n log_details = { membership: @membership.name }\n EventLog.entry(current_user, @epicenter, NEW_MEMBERSHIP, log_details, LOG_COARSE)\n\n @request = session[:new_ncm_membership]\n if stripe_customer and @request \n @child = Epicenter.find_by_slug(@request['epicenter_id'])\n @child_membership = @child.memberships.find(@request['membership_id'])\n\n session.delete(:new_ncm_membership)\n\n if @child.validate_and_pay_new_membership( current_user, @child_membership )\n @child.make_membershipcard( current_user, @child_membership, false )\n @child.make_member( current_user )\n @child.harvest_time_for( current_user )\n log_details = { membership: @child_membership.name }\n EventLog.entry(current_user, @child, NEW_MEMBERSHIP, log_details, LOG_COARSE)\n end\n end\n\n if @child\n if current_user.has_member_tshirt?(@child)\n flash[:success] = \"Welcome. You are now a member of #{@child.name} and #{@epicenter.name}\"\n redirect_path = epicenter_path(@child)\n else\n flash[:success] = \"Welcome. You are now a member of #{@child.name}. BUT NOT #{@epicenter.name}\"\n redirect_path = epicenter_path(@epicenter)\n end\n else\n flash[:success] = \"Welcome. You are now a member af #{@epicenter.name}\"\n redirect_path = epicenter_path(@epicenter)\n end\n else\n flash[:warning] = no_success_message\n redirect_path = new_epicenter_subscription_path(@epicenter)\n end\n\n\n redirect_to redirect_path\n end", "def create_with_payment_profile(customer_code:, amount:, card_id: 1, complete: false)\n create(\n amount: amount,\n payment_method: 'payment_profile',\n payment_profile: {\n customer_code: customer_code,\n card_id: card_id,\n complete: complete,\n },\n )\n end", "def pay_with_current_bank_or_create(price)\n Stripe.api_key = Constants::STRIPE_API_SECRET_KEY\n if self.stripe_customer_id.blank?\n return false\n # customer = Stripe::Customer.create(\n # card: token,\n # description: \"#{self.email}-#{self.display_name}\",\n # email: self.email\n # )\n # customer_id = customer.id\n else\n customer_id = self.stripe_customer_id\n Stripe::Charge.create(\n amount: price+100, #Notice that the price need to be at least 50 cents, or it's gonna raise errors. So I will add 100 cents temprorlay here.\n currency: 'usd',\n customer: customer_id\n )\n # save the customer ID in your database so you can use it later\n self.update_column(\"stripe_customer_id\", customer_id)\n end\n end", "def set_paid\n if unpaid_amount > 0 and not paid\n payment = Payment.create(\n invoice_id: self.id,\n date: Date.today,\n amount: unpaid_amount)\n self.save\n end\n end", "def create\n @member = Member.new(member_params)\n #@member.card_id = SecureRandom.uuid\n @member.magma_coins = 0\n add_abo_types_to_member(@member)\n respond_to do |format|\n if @member.save\n format.html { redirect_to current_user.present? ? @member : members_path, notice: t('flash.notice.creating_member') }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new, alert: t('flash.alert.creating_member') }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_transaction(member, user)\n if !User.exists?(email: sign_up_params[:email])\n User.transaction do\n member.save!\n user[:member_id] = member[:id]\n if user.valid? && user.save!\n sign_in(user)\n flash[:notice] = 'Welcome to the Network, ' + member.title + ' ' +\n member.name\n redirect_to root_path\n else\n render 'error'\n member.destroy\n return\n end\n end\n else\n render 'existing_email'\n end\n end", "def create\n @payout = Payout.new(price: current_user.credit, user_id: current_user.id)\n ti_ids = TaskInstance.where('status = ? AND user_id = ?', :finished, current_user.id).select(:id)\n ti_ids.each do |ti|\n ti.update(status: :paid)\n end\n @payout.task_instances = ti_ids\n\n respond_to do |format|\n if @payout.save\n current_user.update(credit: 0)\n format.html { redirect_to @payout, notice: 'Payout was successfully created.' }\n format.json { render action: 'show', status: :created, location: @payout }\n else\n format.html { render action: 'new' }\n format.json { render json: @payout.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_reactivation_transaction\n\n payment_method = params[:mp]\n company = Company.find(current_user.company_id)\n\n downgradeLog = DowngradeLog.where(company_id: company.id).order('created_at desc').first\n\n new_plan = downgradeLog.plan\n\n #Should have free plan\n previous_plan = company.plan\n\n if new_plan.custom\n price = new_plan.plan_countries.find_by(country_id: company.country.id).price\n else\n price = new_plan.plan_countries.find_by(country_id: company.country.id).price company.computed_multiplier\n end\n\n sales_tax = company.country.sales_tax\n\n day_number = Time.now.day\n month_number = Time.now.month\n month_days = Time.now.days_in_month\n\n plan_month_value = ((month_days - day_number + 1).to_f / month_days.to_f) * price\n due_amount = downgradeLog.debt\n\n\n if company\n mockCompany = Company.find(current_user.company_id)\n mockCompany.plan_id = new_plan.id\n mockCompany.months_active_left = 1.0\n mockCompany.due_amount = 0.0\n mockCompany.due_date = nil\n\n if !mockCompany.valid?\n redirect_to select_plan_path, notice: \"No se pudo completar la operación ya que hubo un error en la solicitud de pago. Por favor escríbenos a [email protected] si el problema persiste. (9)\"\n else\n\n trx_comp = mockCompany.id.to_s + \"0\" + new_plan.id.to_s + \"0\"\n trx_offset = 4\n trx_date = DateTime.now.to_s.gsub(/[-:T]/i, '')\n trx_date = trx_date[0, trx_date.size - trx_offset]\n trx_date = trx_date[trx_date.size - 15 + trx_comp.size, trx_date.size]\n trx_id = trx_comp + trx_date\n\n if trx_id.size > 15\n trx_id = trx_id[0, 15]\n end\n\n due = sprintf('%.2f', ((plan_month_value + due_amount /(1 + sales_tax) )*(1 + sales_tax)).round(0))\n\n crypt = ActiveSupport::MessageEncryptor.new(Agendapro::Application.config.secret_key_base)\n\n encrypted_data = crypt.encrypt_and_sign({reference: trx_id, description: \"Cambio a plan \" + mockCompany.plan.name, amount: due, source_url: select_plan_path})\n\n\n if encrypted_data\n PlanLog.create(trx_id: trx_id, new_plan_id: new_plan.id, prev_plan_id: previous_plan.id, company_id: mockCompany.id, amount: due)\n PayUCreation.create(trx_id: trx_id, payment_method: '', amount: due, details: \"Creación de reactivación de plan empresa id \"+mockCompany.id.to_s+\", nombre \"+mockCompany.name+\". Cambia de plan \"+mockCompany.plan.name+\"(\"+mockCompany.plan.id.to_s+\"), por un costo de \"+due+\". trx_id: \"+trx_id+\" - mp: \"+mockCompany.id.to_s+\". Resultado: Se procesa\")\n redirect_to action: 'generate_transaction', encrypted_task: encrypted_data\n return\n else\n PayUCreation.create(trx_id: trx_id, payment_method: '', amount: due, details: \"Error creación de cambio de plan empresa id \"+mockCompany.id.to_s+\", nombre \"+mockCompany.name+\". Cambia de plan \"+mockCompany.plan.name+\"(\"+mockCompany.plan.id.to_s+\"), por un costo de \"+due+\". trx_id: \"+trx_id+\" - mp: \"+mockCompany.id.to_s+\". Resultado: \"+resp.get_error+\".\")\n redirect_to select_plan_path, notice: \"No se pudo completar la operación ya que hubo un error en la solicitud de pago. Por favor escríbenos a [email protected] si el problema persiste. (3)\"\n end\n end\n end\n end", "def create\n params.permit(:interval, :plan, :stripeEmail, :stripeToken)\n if current_user\n @user = current_user\n begin\n customer = Stripe::Customer.create(\n :email => params[:stripeEmail],\n :source => params[:stripeToken],\n :plan => params[:plan]\n )\n if @user.plan.nil? || @user.plan != params[:plan]\n case params[:interval]\n when \"month\"\n active_date_increment = Time.now + 1.month\n when \"year\"\n active_date_increment = Time.now + 1.year\n when \"week\"\n active_date_increment = Time.now + 1.week\n end\n @user.update_attributes!(\n stripe_customer_id: customer.id,\n active_until: active_date_increment,\n plan: params[:plan],\n stripe_token: params[:stripeToken]\n )\n end\n redirect_to @user\n rescue\n puts \"Unable to register customer with Stripe: #{params[:stripeEmail]}\"\n flash[:alert] = \"There was an error processing the payment. Please try again.\"\n redirect_to plan_path(Stripe::Plan.retrieve(params[:plan]))\n end\n end\n end", "def new_invoice(user_id, payment_id)\n @user = User.find_by_id(user_id)\n @payment = Payment.find_by_id(payment_id)\n\n mail :to => recipient(@user.email), :subject => \"New 25c Invoice!\"\n end" ]
[ "0.69060594", "0.64355946", "0.6358454", "0.63414973", "0.6306214", "0.623397", "0.6134724", "0.6095739", "0.60889095", "0.60676795", "0.6065046", "0.6063734", "0.60517734", "0.602945", "0.6026668", "0.6022899", "0.601373", "0.6005469", "0.59579885", "0.5949564", "0.5937691", "0.59177876", "0.58833", "0.58537716", "0.58443433", "0.58300143", "0.5824252", "0.5818403", "0.5815972", "0.57887286", "0.57880414", "0.5787218", "0.57847935", "0.5778956", "0.5778779", "0.57773167", "0.5775484", "0.5744126", "0.5736729", "0.57349926", "0.5728377", "0.57265425", "0.5720023", "0.5717816", "0.5714622", "0.5707335", "0.57064533", "0.57042444", "0.5702314", "0.56978023", "0.5691797", "0.56900865", "0.56879646", "0.5682784", "0.56771296", "0.5675213", "0.5666721", "0.5665878", "0.56651556", "0.56641686", "0.56641686", "0.5657631", "0.56565255", "0.56551784", "0.5650739", "0.56447446", "0.56429946", "0.56405735", "0.5638742", "0.5635846", "0.56262547", "0.56258655", "0.5617881", "0.5613942", "0.5611534", "0.5611447", "0.5608297", "0.5603048", "0.55993265", "0.5589651", "0.5587804", "0.5585746", "0.5583223", "0.5582022", "0.5581753", "0.55811226", "0.5566595", "0.5564936", "0.5561977", "0.5561767", "0.55608225", "0.5554321", "0.5548564", "0.5545041", "0.5541071", "0.5537308", "0.5535928", "0.55329114", "0.55306464", "0.5530156" ]
0.71493685
0
DELETE /event_registrations/1 DELETE /event_registrations/1.json
def destroy @registration = Registration.find(params[:id]) @event = @registration.event @registration.destroy respond_to do |format| format.html { redirect_to manage_event_path(@event), notice: 'Event registration was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @event_registration.destroy\n respond_to do |format|\n format.html { redirect_to event_registrations_path}\n format.json { head :no_content }\n end\n end", "def destroy\n @event_registration.destroy\n\n respond_to do |format|\n format.html { redirect_to event_url(@event) }\n end\n end", "def destroy\n @registration_table.destroy\n respond_to do |format|\n format.html { redirect_to [@event], notice: 'RSVP was removed from table.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@event_event.destroy\n @event_event.deleted = true\n dest = @event_event.id\n type = 7 #event_notifications_code\n Notification.clear_notifications(type,dest)\n @event_event.save\n @event_event.user.remove_event\n respond_to do |format|\n format.html { redirect_to admin_event_events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attend_event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Request successfully rescinded.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.users.clear\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @user_event.destroy\n respond_to do |format|\n format.html { redirect_to user_events_url, notice: 'User event was successfully unregistered.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n\n sync_destroy @event\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event_event = Event::Event.find(params[:id])\n @event_event.destroy\n\n respond_to do |format|\n format.html { redirect_to event_events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to controller: 'admin/events', action: 'index', conf_id: @event.conference_id }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_event = UserEvent.where(event_id: @event.id)\n @event.destroy\n @user_event.destroy\n render json: { head: :no_content }\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: \"イベントの削除に成功しました。\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event_recurrence.destroy\n respond_to do |format|\n format.html { redirect_to event_recurrences_url, notice: 'Event recurrence was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n \n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def delete_event(event)\n notifications = \"sendNotifications=#{event.send_notifications?}\"\n send_events_request(\"/#{event.id}?#{notifications}\", :delete)\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to scrappers_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, @event, :message => 'Not authorized as an administrator.'\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event_request = EventRequest.find(params[:id])\n @event_request.destroy\n\n respond_to do |format|\n format.html { redirect_to event_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @myevent = Myevent.find(params[:id])\n @myevent.destroy\n\n respond_to do |format|\n format.html { redirect_to myevents_url }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @page_usage_event = PageUsageEvent.find(params[:id])\n @page_usage_event.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_usage_events_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @events = Event.where(event_id: params[:id])\n @events.each.destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @eventtype.events.each do |e|\n e.destroy\n end\n @eventtype.destroy\n respond_to do |format|\n format.html { redirect_to eventtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_event.destroy\n respond_to do |format|\n format.html { redirect_to group_events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'データが削除されました。' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @event.destroy_eventbrite_event\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_event = GroupEvent.find(params[:id])\n @group_event.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @users_event = UsersEvent.find(params[:id])\n @users_event.destroy\n\n respond_to do |format|\n format.html { redirect_to users_events_url }\n format.json { head :no_content }\n end\n end", "def delete_event\n if params[:id]\n @e = Evento.find(params[:id]).destroy\n end\n render :json => msj = { :status => true, :message => 'ok'}\n end", "def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Мероприятие успешно удалено.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_events_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @create_event = CreateEvent.find(params[:id])\n @create_event.destroy\n\n respond_to do |format|\n format.html { redirect_to create_events_url }\n format.json { head :no_content }\n end\n end", "def delete\n # @group_event.destroy\n @group_event = GroupEvent.find params[:id]\n\n @group_event.deleted = true\n @group_event.save!\n\n respond_to do |format|\n format.html { redirect_to group_events_url, notice: 'Group event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.78776497", "0.75545466", "0.72664815", "0.7233993", "0.7121077", "0.71203524", "0.7118392", "0.7118392", "0.7118392", "0.71130234", "0.7070225", "0.7033818", "0.70054746", "0.70037514", "0.6978001", "0.696753", "0.6967277", "0.6949586", "0.6947828", "0.6946387", "0.69450355", "0.69431263", "0.69373727", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.69366544", "0.6930954", "0.693081", "0.69305354", "0.6920081", "0.6919974", "0.69195944", "0.6917667", "0.6916532", "0.6910524", "0.6908909", "0.6906507", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.69064254", "0.6899368", "0.68989986", "0.68971896", "0.6896422", "0.6894178", "0.6893352", "0.6886282", "0.6885446", "0.68830574", "0.6870534", "0.6869379", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819", "0.6867819" ]
0.77075
1
Only allow a trusted parameter "white list" through.
def banner_params params.require(:banner).permit(:name, :title, :description, :image_id, :url, :is_active, :start_date, :expiry_date, page_ids:[]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params\n true\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def user_params\n end", "def permitted_params\n @wfd_edit_parameters\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def user_params\r\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def parameters\n nil\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.71230334", "0.70530915", "0.69479465", "0.6902122", "0.67367256", "0.67172784", "0.6689043", "0.66784793", "0.6660117", "0.6555213", "0.6528485", "0.6458438", "0.6452378", "0.6451654", "0.64478326", "0.6433326", "0.6413599", "0.6413599", "0.63907677", "0.63787645", "0.63787645", "0.6375229", "0.63608277", "0.635366", "0.6283652", "0.62798274", "0.6245606", "0.62283605", "0.6224614", "0.6223649", "0.62118477", "0.6207179", "0.61780804", "0.6173056", "0.61674094", "0.615996", "0.6145132", "0.613597", "0.612235", "0.6108622", "0.6098955", "0.60767287", "0.6055062", "0.60391796", "0.60363555", "0.6030472", "0.6018476", "0.60174584", "0.60163116", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60159874", "0.60052663", "0.6003681", "0.6001089", "0.5996807", "0.5994288", "0.59942675", "0.5984987", "0.59827954", "0.59777087", "0.5975369", "0.59706473", "0.5966046", "0.5965166", "0.5965166", "0.59577847", "0.5952617", "0.59503365", "0.59480196", "0.5943258", "0.5931462", "0.59299", "0.5927073", "0.5924737", "0.5919184", "0.5918459", "0.591457", "0.59142643", "0.59062785", "0.59054136", "0.59047925", "0.5902357", "0.5900476", "0.5898475", "0.5898218", "0.5895328" ]
0.0
-1
why does this method go in the child instead of the parent? self.column_names.each do |col_name| iterate over the column names stored in the column_names class method... attr_accessor col_name.to_sym ...set an attr_accessor for each one, making sure to convert the column name string into a symbol with the to_sym method, since attr_accessors must be named with symbols end
def initialize(options={}) #define method to take in an argument of options, which defaults to an empty hash options.each do |property, value| #iterate over the options hash... self.send("#{property}=", value) #and use our fancy metaprogramming #send method to interpolate the name of each hash key as a method that we set equal to that key's value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def def_column_accessor(*columns)\n clear_setter_methods_cache\n columns, bad_columns = columns.partition{|x| /\\A[A-Za-z_][A-Za-z0-9_]*\\z/.match(x.to_s)}\n bad_columns.each{|x| def_bad_column_accessor(x)}\n im = instance_methods.map(&:to_s)\n columns.each do |column|\n meth = \"#{column}=\"\n overridable_methods_module.module_eval(\"def #{column}; self[:#{column}] end\", __FILE__, __LINE__) unless im.include?(column.to_s)\n overridable_methods_module.module_eval(\"def #{meth}(v); self[:#{column}] = v end\", __FILE__, __LINE__) unless im.include?(meth)\n end\n end", "def def_column_accessor(*columns)\n clear_setter_methods_cache\n columns, bad_columns = columns.partition{|x| /\\A[A-Za-z_][A-Za-z0-9_]*\\z/.match(x.to_s)}\n bad_columns.each{|x| def_bad_column_accessor(x)}\n im = instance_methods\n columns.each do |column|\n meth = \"#{column}=\"\n overridable_methods_module.module_eval(\"def #{column}; self[:#{column}] end\", __FILE__, __LINE__) unless im.include?(column)\n overridable_methods_module.module_eval(\"def #{meth}(v); self[:#{column}] = v end\", __FILE__, __LINE__) unless im.include?(meth)\n end\n end", "def define_accessors\n columns.each do |column|\n underscored_column_name = column.name.underscore\n unless respond_to?(underscored_column_name)\n self.class.send :define_method, underscored_column_name do\n @attributes[column.name.underscore]\n end\n end\n end\n end", "def initialize(options={})\n#In this we def or intitialize with a enpty options hash option={}\n options.each do |property, value|\n# next we interate over everything in our options hash which write this code\n# assuming the the .new method will becaould and data from this .new witll be \n #inserted into the the empty options hash \n self.send(\"#{property}=\", value)\n # finally we use the send method to insert the name of each hash key (from the key value pais created earlier by the column name method)\n # As long as each property has a corresponding attr_accessor, this #initialize method will work.\n end\n end", "def columns\n self.columns = @core.columns._inheritable unless @columns # lazy evaluation\n @columns\n end", "def columns\n self.columns = @core.columns._inheritable unless @columns # lazy evaluation\n @columns\n end", "def initialize(params = {}) # <- ?is params a hash representing a new row object?\n params.each do |key, value|\n attr_name = key.to_sym\n class_name = self.class\n raise \"unknown attribute '#{attr_name}'\" if !class_name.columns.include?(attr_name)\n \n # set the attr_name by calling #send \n # ? what method are we sending? \n # ? we are sending the column name to ?\n self.send(\"#{attr_name}=\", value) \n # self.send \"#{attr_name}=\", value # also works\n end\n end", "def column_methods_hash #:nodoc:\n @dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr|\n attr_name = attr.to_s\n methods[attr.to_sym] = attr_name\n methods[\"#{attr}=\".to_sym] = attr_name\n methods[\"#{attr}?\".to_sym] = attr_name\n methods[\"#{attr}_before_type_cast\".to_sym] = attr_name\n methods\n end\n end", "def attribute_values\n # call Array#map on SQLObject::columns, call send on the instance to \n # get the value\n self.class.columns.map { |attribute| self.send(attribute) }\n end", "def proxy_columns(columns)\n columns.each do |column|\n if (type = column_type(column.type)).present?\n # When setting the default value, note that +main_instance+ might be nil, so we have to use +try+\n attribute column.name, type, default: proc { |f| f.main_instance.try(column.name) }\n end\n end\n end", "def columns; self.class.columns; end", "def attr_columns\n @attr_columns\n end", "def def_bad_column_accessor(column)\n overridable_methods_module.module_eval do\n define_method(column){self[column]}\n define_method(\"#{column}=\"){|v| self[column] = v}\n end\n end", "def def_bad_column_accessor(column)\n overridable_methods_module.module_eval do\n define_method(column){self[column]}\n define_method(\"#{column}=\"){|v| self[column] = v}\n end\n end", "def inspect\n if self == Base\n super\n else\n attr_list = columns.map { |c| \"#{c.name}: #{c.type}\" } * ', '\n \"#{super}(#{attr_list})\"\n end\n end", "def attr_name\n \"#{self.proxy.column_family_name}:#{key}\"\n end", "def initialize(params = {})\n # Your #initialize method should iterate through each of the\n # attr_name, value pairs.\n params.each do | attr_name, value |\n # For each attr_name,\n # it should first convert the name to a symbol\n attr_name = attr_name.to_sym\n # check whether the attr_name is among the columns\n # Hint: we need to call ::columns on a class object\n # not the instance.\n # For example, we can call Dog::columns but not dog.columns.\n if self.class.columns.include?(attr_name)\n # calls appropriate setter method for each item in params\n # Use #send; avoid using @attributes or\n # attributes inside #initialize.\n self.send(\"#{attr_name}=\", value)\n else\n # If it is not, raise an error\n raise \"unknown attribute '#{attr_name}'\"\n end\n end\n end", "def generate_strategy_accessors\n\n attributes = []\n columns.keys.each do |column_name|\n attributes << column_name\n\n self.send(:define_attribute_methods, column_name)\n self.send(:define_method, column_name) { @strategy_hash[column_name] }\n self.send(:define_method, \"#{column_name}=\") do |value|\n send(\"#{column_name}_will_change!\") unless value == instance_variable_get(\"@_#{column_name}\")\n @strategy_hash[column_name] = value\n end\n end\n\n self.send(:define_method, :attributes) do\n Hash[attributes.map { |name, _| [name, send(name)] }]\n end\n end", "def method_missing(name, *args, &block)\n fn = name.to_s\n fnne = fn.gsub('=','')\n if (!self.attributes.keys.include?(fnne)) && self.connection.columns(self.class.table_name).map{|c| c.name}.include?(fnne)\n # for next time\n self.class.reset_column_information\n\n # for this time\n if self.new_record?\n self.attributes[fnne] = nil\n else\n self.attributes[fnne] = self.connection.select_all(\"select #{fnne} from #{self.class.table_name} where id = #{self.id}\")[0][fnne] rescue nil\n end\n\n return self.attributes[fnne]\n else\n super\n end\n end", "def attribute_values\n self.class.columns.map { |col| self.send(col) }\n end", "def column_names\n klass.new.attributes.keys\n end", "def column_names\n klass.attributes\n end", "def attribute_values\n self.class.columns.map { |attr| self.send(attr) }\n end", "def columns\n raise NotImplementedError\n end", "def initialize(params = {})\n params.each do |attr_name, value|\n attr_name_sym = attr_name.to_sym\n if self.class.columns.include?(attr_name_sym)\n self.send(\"#{attr_name_sym}=\", value)\n else\n raise \"unknown attribute '#{attr_name_sym}'\"\n end\n end\n end", "def initialize(params = {})\n params.each do |attr_name, value|\n attr_name_sym = attr_name.to_sym\n\n unless self.class.columns.include?(attr_name_sym)\n raise \"unknown attribute \\'#{attr_name_sym}\\'\"\n end\n attr_setter = (attr_name.to_s + \"=\").to_sym\n send(attr_setter, value)\n end\n end", "def columns; self.class.columns.dup; end", "def columns\n self.class.instance_variable_get(:@columns)\n end", "def _columns\n cache_get(:_columns)\n end", "def column_for_attribute(name)\n if self.class._has_virtual_column?(name)\n return VirtualColumnWrapper.new(singleton_class._virtual_column(name))\n else\n super\n end\n end", "def columns_hash\n unless @all_columns_hash\n # add default hbase columns\n @all_columns_hash =\n if self == base_class\n if @columns_hash\n default_columns.merge(@columns_hash)\n else\n @columns_hash = default_columns\n end\n else\n if @columns_hash\n superclass.columns_hash.merge(@columns_hash)\n else\n superclass.columns_hash\n end\n end\n end\n @all_columns_hash\n end", "def column_methods_hash\n @dynamic_methods_hash ||= columns_hash.keys.inject(Hash.new(false)) do |methods, attr|\n methods[attr.to_sym] = true\n methods[\"#{attr}=\".to_sym] = true\n methods[\"#{attr}?\".to_sym] = true\n methods\n end\n end", "def internal_attr_accessor(*syms)\n internal_attr_reader(*syms)\n internal_attr_writer(*syms)\n end", "def initialize(params = {})\n params.each do |k,v|\n k = k.to_sym\n if self.class.columns.include?(k)\n self.send(k.to_s+'=', v)\n else\n raise \"unknown attribute '#{k}'\"\n end\n end\n end", "def attribute_values \n columns = self.class.columns\n columns.map { |col| self.send(col) } #=> ex. [:id, :name, :owner_id]\n end", "def column_names\n @column_names || owner.column_names\n end", "def attribute_values\n self.class.columns.map { |column| send(column) }\n end", "def column_names\n klass.properties.keys\n end", "def columns\n self.class.columns\n end", "def columns\n self.class.columns\n end", "def columns; @columns; end", "def column_name; end", "def column_names\n self[0].keys\n end", "def all\n __getobj__.column_names\n end", "def columns\n @columns || self.class.columns\n end", "def column=(_); end", "def keys\n @klass.column_names\n end", "def define_accessors\n self.metadata.properties_and_identity.each do |name, _|\n self.model.send :attr_accessor, name.downcase\n end\n end", "def reset_column_information\n generated_methods.each { |name| undef_method(name) }\n @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = nil\n end", "def define_serialized_attribute_accessor(serializer, deserializer, *columns)\n m = self\n include(@serialization_module ||= Module.new) unless @serialization_module\n @serialization_module.class_eval do\n columns.each do |column|\n m.serialization_map[column] = serializer\n m.deserialization_map[column] = deserializer\n define_method(column) do \n if deserialized_values.has_key?(column)\n deserialized_values[column]\n elsif frozen?\n deserialize_value(column, super())\n else\n deserialized_values[column] = deserialize_value(column, super())\n end\n end\n define_method(\"#{column}=\") do |v| \n if !changed_columns.include?(column) && (new? || get_column_value(column) != v)\n changed_columns << column\n\n will_change_column(column) if respond_to?(:will_change_column)\n end\n\n deserialized_values[column] = v\n end\n end\n end\n end", "def real_column; end", "def column_mappings\n raise SolidusImportProducts::AbstractMthodCall\n end", "def table_columns\n klass.column_names\n end", "def cattr_accessor(*syms)\n cattr_reader(*syms)\n cattr_writer(*syms)\n end", "def columns\n unless defined?(@columns) && @columns\n @columns = connection.columns(table_name, \"#{name} Columns\").select do |column| \n column.name =~ Regexp.new(\"^#{self.to_s.underscore}__\") || column.name == primary_key\n end\n @columns.each { |column| column.primary = column.name == primary_key }\n end\n @columns\n end", "def set_to_column_name(value=nil, &block)\n define_attr_method :to_column_name, value, &block\n end", "def cattr_accessor(*syms)\n cattr_reader(*syms) + cattr_writer(*syms)\n end", "def column(name, *args)\n define_method name do\n instance_variable_get(\"@_#{name}\")\n end\n define_method \"#{name}=\" do |val|\n instance_variable_set(\"@_#{name}\", val)\n end\n self.columns = columns.concat([[name].concat(args)])\n end", "def columns\n unless @columns\n self.columns = @core.columns._inheritable \n self.columns.exclude @core.columns.active_record_class.locking_column.to_sym\n end\n @columns\n end", "def sql_for_columns; @sql_for_columns end", "def columns(table_name, name = nil) end", "def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end", "def column_for_attribute(name)\n name = name.to_sym\n return self.faux_columns[name] if self.faux_columns.has_key?(name)\n super\n end", "def define_serialized_attribute_accessor(format, *columns)\n m = self\n include(self.serialization_module ||= Module.new) unless serialization_module\n serialization_module.class_eval do\n columns.each do |column|\n m.serialization_map[column] = format\n define_method(column) do \n if deserialized_values.has_key?(column)\n deserialized_values[column]\n else\n deserialized_values[column] = deserialize_value(column, super())\n end\n end\n define_method(\"#{column}=\") do |v| \n changed_columns << column unless changed_columns.include?(column)\n deserialized_values[column] = v\n end\n end\n end\n end", "def columns\n # we want to delay initializing to the @core.columns set for as long as possible. Too soon and .search_sql will not be available to .searchable?\n unless defined? @columns\n self.columns = @core.columns.collect { |c| c.name if @core.columns._inheritable.include?(c.name) && c.searchable? && c.association.nil? && c.text? }.compact\n end\n @columns\n end", "def initialize(model_name, column_unsplit)\n self.model_name = model_name.singular.underscore\n cols = column_unsplit.split(\":\")\n self.column_name = cols.first#.underscore\n self.column_type = cols.last#.underscore\n end", "def attributes\n super.map { |k, v| [ k.to_s.camelize(:lower).to_sym, v ] }.to_h\n end", "def define_attribute_methods\n return if attribute_methods_generated?\n @attributes.keys.sort.each do |k|\n # ajay Singh --> skip the loop if attribute is null\n next if !k.present?\n self.class.module_eval %Q?\n def #{k}\n read_attribute :#{k}\n end\n def #{k}=(value)\n write_attribute :#{k},value\n end\n def #{k}\\?\n has_attribute\\? :#{k}\n end\n ?\n end\n \n # return the (polymorphic) parent record corresponding to the parent_id and parent_type attributes\n # (an example of parent polymorphism can be found in the Note module)\n if (@attributes.keys.include? 'parent_id') && (@attributes.keys.include? 'parent_type')\n self.class.module_eval %Q?\n def parent\n (self.class.session.namespace_const.const_get @attributes['parent_type'].singularize).find(@attributes['parent_id'])\n end\n ?\n end\n \n self.class.attribute_methods_generated = true\n end", "def columns\n @columns = @clazz.columns_hash.map do |name, column|\n [name, @columns[name] || Column.new(column, @dump)]\n end.to_h.with_indifferent_access\n end", "def set_from_column_name(value = nil, &block)\n define_attr_method :from_column_name, value, &block\n end", "def columns\n @columns\n end", "def state_column(*)\n Log.debug { \"#{__method__}: not defined for #{self_class}\" }\n end", "def freeze\n @typecast_on_load_columns.freeze\n\n super\n end", "def mattr_accessor(*syms)\n mattr_reader(*syms) + mattr_writer(*syms)\n end", "def columns\n collect = []\n recursive_columns(@base, collect)\n end", "def add_child(*)\n\n\n\n super\n\n\n\n calculate_columns!\n\n\n\n end", "def define_read_methods\n self.class.columns_hash.each do |name, column|\n unless respond_to_without_attributes?(name)\n define_read_method(name.to_sym, name, column)\n end\n\n unless respond_to_without_attributes?(\"#{name}?\")\n define_question_method(name)\n end\n end\n end", "def define_indexed_accessors\n return if !const_defined? :IndexedAccessorFieldMappings\n\n self::IndexedAccessorFieldMappings.each do |name, column_name|\n if method_defined? name\n raise \"Accessor #{name} already exists in #{self.name}.\"\n end\n\n index = self.column_names.index column_name\n if index.nil?\n raise \"Cannot find column #{column_name} in #{inspect}.\"\n end\n define_method name do column_at_index(index) end\n end\n end", "def columns(*cs)\n if cs.empty?\n super\n else\n self.columns = cs\n self\n end\n end", "def derived_attribute_names\n Module.nesting.first.public_instance_methods - [:derived_attribute_names]\n end", "def method_missing(method_name, *args, &block)\n return super unless define_attribute_methods\n self.send(method_name, *args, &block)\n end", "def set_columns(new_columns)\n @columns = new_columns\n def_column_accessor(*new_columns) if new_columns\n @columns\n end", "def set_columns(new_columns)\n @columns = new_columns\n def_column_accessor(*new_columns) if new_columns\n @columns\n end", "def define_read_method(symbol, attr_name, column)\n cast_code = column.type_cast_code('v') if column\n access_code = cast_code ? \"(v=@attributes['#{attr_name}']) && #{cast_code}\" : \"@attributes['#{attr_name}']\"\n\n unless attr_name.to_s == self.class.primary_key.to_s\n access_code = access_code.insert(0, \"raise NoMethodError, 'missing attribute: #{attr_name}', caller unless @attributes.has_key?('#{attr_name}'); \")\n self.class.read_methods << attr_name\n end\n\n evaluate_read_method attr_name, \"def #{symbol}; #{access_code}; end\"\n end", "def define_attribute_method(column_name, &block)\n return if method_defined? column_name\n\n define_method(:\"#{column_name}=\") do |value|\n instance_variable_set(:\"@#{column_name}\", value)\n end\n\n define_method(:\"#{column_name}\") do\n instance_variable_get(:\"@#{column_name}\")\n end\n end", "def add_methods_to_flex_column_class!(dynamic_methods_module)\n fn = field_name\n\n dynamic_methods_module.define_method(fn) do\n self[fn]\n end\n\n dynamic_methods_module.define_method(\"#{fn}=\") do |x|\n self[fn] = x\n end\n\n if private?\n dynamic_methods_module.private(fn)\n dynamic_methods_module.private(\"#{fn}=\")\n end\n end", "def columns; end", "def synthetic_columns\n @columns ||= [:id]\n end", "def columns_hash\n self\n end", "def columns\n self.class.const_get(:COLUMNS) rescue []\n end", "def define_attr_method(name, value=nil, &block)\n case self.connection.adapter_name\n\n when 'PostgreSQL'\n sing = class << self; self; end\n self.class.send :alias_method, \"#{name}\", name\n if block_given?\n sing.send :define_method, name, &block\n else\n # use downcased column name\n sing.class_eval \"def #{name}; #{value.to_s.downcase.inspect}; end\"\n end\n\n else\n original_define_attr_method(name, value=nil, &block)\n end\n end", "def initialize\n @col_specs = []\n end", "def column_name\n name.to_sym\n end", "def columns= columns\n columns.each { |c| c.table = self }\n @columns = columns\n end", "def inherited(base)\n base.class_eval do\n @name = nil\n @unknown_inc = 0\n @fields = [ ]\n @fields_by_name = {}\n @field_components_by_name = {}\n @klass = nil\n\n record_name self.name.gsub(\"::\",\"_\") if self.name\n end\n end", "def arel_attribute(column_name, table = arel_table)\n super\n end", "def define_attributes\n @info.attributes.each do |attr|\n rname = underscore(attr.name)\n self.class.__send__(:define_method, rname) { self[attr.name] } if attr.readable?\n self.class.__send__(:define_method, rname + \"=\") {|v| self[attr.name] = v } if attr.writable?\n end\n end", "def define_read_method(symbol, attr_name, column)\n\n cast_code = column.type_cast_code('v') if column\n access_code = cast_code ? \"(v=@attributes['#{attr_name}']) && #{cast_code}\" : \"@attributes['#{attr_name}']\"\n\n unless attr_name.to_s == self.primary_key.to_s\n access_code = access_code.insert(0, \"missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); \")\n end\n\n # This is the Hobo hook - add a type wrapper around the field\n # value if we have a special type defined\n if can_wrap_with_hobo_type?(symbol)\n access_code = \"val = begin; #{access_code}; end; wrapper_type = self.class.attr_type(:#{attr_name}); \" +\n \"if HoboFields.can_wrap?(wrapper_type, val); wrapper_type.new(val); else; val; end\"\n end\n\n if cache_attribute?(attr_name)\n access_code = \"@attributes_cache['#{attr_name}'] ||= begin; #{access_code}; end;\"\n end\n\n generated_attribute_methods.module_eval(\"def #{symbol}; #{access_code}; end\", __FILE__, __LINE__)\n end", "def translated_columns(klass); end", "def columns\n if @column_names\n columns = []\n\n # First match against fully named columns, e.g. 'attribute:name'\n @column_names.each{|cn| columns << owner.columns_hash[cn] if owner.columns_hash.has_key?(cn)}\n\n # Now match against aliases if the number of columns found previously do not\n # match the expected @columns_names size, i.e. there's still some missing.\n if columns.size != @column_names.size\n columns_left = @column_names - columns.map{|column| column.name}\n owner.columns_hash.each { |name,column| columns << column if columns_left.include?(column.alias) }\n end\n\n columns\n else\n owner.columns\n end\n end", "def column_for_attribute(name)\n self.class.columns_hash[name.to_s]\n end" ]
[ "0.7025443", "0.7012534", "0.6787528", "0.6774966", "0.6454685", "0.6454685", "0.64290965", "0.64285654", "0.64096135", "0.63136846", "0.6311516", "0.63050693", "0.62708807", "0.62708807", "0.6192178", "0.61917186", "0.6177599", "0.6170156", "0.61513346", "0.61242086", "0.6114692", "0.60750747", "0.6061804", "0.60381466", "0.6028612", "0.5999855", "0.59728605", "0.59514546", "0.59341305", "0.5932877", "0.5911812", "0.5904405", "0.59002954", "0.5884527", "0.588203", "0.58775765", "0.58728635", "0.586346", "0.58403724", "0.58403724", "0.5838817", "0.582603", "0.5819714", "0.5810101", "0.5804633", "0.57976943", "0.57821584", "0.5768227", "0.57678425", "0.5765571", "0.5763287", "0.57582307", "0.57579905", "0.57563853", "0.57342947", "0.57227325", "0.5711428", "0.5708918", "0.57056904", "0.5702414", "0.56912917", "0.56880474", "0.5685183", "0.5684006", "0.56805384", "0.56457824", "0.56426394", "0.56372315", "0.5634947", "0.56318045", "0.56236964", "0.5618866", "0.5606889", "0.5605299", "0.5605062", "0.56050175", "0.56031847", "0.5601627", "0.55954665", "0.55952287", "0.55919284", "0.55918854", "0.55918854", "0.55904824", "0.55889314", "0.55818063", "0.55795085", "0.5578323", "0.55752105", "0.55716056", "0.55653274", "0.5564509", "0.5546554", "0.5546302", "0.55426335", "0.5537417", "0.5528698", "0.5527695", "0.5526951", "0.5526651", "0.5525045" ]
0.0
-1
conventional ORM methods below:::
def table_name_for_insert self.class.table_name #inside an instance method, self will refer to the instance of the class, not the class itself end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orm; end", "def alchemy\r\n end", "def single_object_db; end", "def prerecord(klass, name); end", "def query; end", "def subscribe_sql_active_record; end", "def find_by()\n\n end", "def query\n super\n end", "def find\n self.db.query(\"\n select * \n from dogs\n \")\n end", "def relation_by_sql_form\n # Nothing to do here\n end", "def orm_patches_applied; end", "def orm\n @orm ||= :none\n end", "def to_query(_model)\n raise 'subclasses should implement this method.'\n end", "def make_and_model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def find(query); end", "def find(query); end", "def entities; end", "def initializeORM()\n\t# nothing to do\nend", "def query\n end", "def method_missing(name, *args, &block)\n fn = name.to_s\n fnne = fn.gsub('=','')\n if (!self.attributes.keys.include?(fnne)) && self.connection.columns(self.class.table_name).map{|c| c.name}.include?(fnne)\n # for next time\n self.class.reset_column_information\n\n # for this time\n if self.new_record?\n self.attributes[fnne] = nil\n else\n self.attributes[fnne] = self.connection.select_all(\"select #{fnne} from #{self.class.table_name} where id = #{self.id}\")[0][fnne] rescue nil\n end\n\n return self.attributes[fnne]\n else\n super\n end\n end", "def db; end", "def db; end", "def get_all_from_database\n model.all\n end", "def find_by_sql(sql)\n raise \"not implemented\"\n end", "def select(db); end", "def select(db); end", "def initial_query; end", "def model_class; end", "def subscribe_sql_active_record=(_arg0); end", "def persisted?; end", "def persisted?; end", "def find_or_create_by\n end", "def find_relationship_by(attribute, value); end", "def mongoize\n self\n end", "def has_many_polymorphic_xdb_records(name, options = {})\n association_name = options[:as] || name.to_s.underscore\n id_field, type_field = \"#{association_name}_id\", \"#{association_name}_type\"\n object_name = options[:class_name] || name.to_s.singularize.camelize\n object_class = object_name.classify.constantize\n\n self.instance_eval do\n define_method(name) do |reload = false|\n reload and self.instance_variable_set(\"@#{name}\", nil)\n if self.instance_variable_get(\"@#{name}\").blank?\n new_value = object_class.where(id_field => self.id, type_field => self.class.name)\n self.instance_variable_set(\"@#{name}\", new_value)\n end\n self.instance_variable_get(\"@#{name}\")\n end\n end\n end", "def real_column; end", "def model_name; end", "def model_name; end", "def with_sql_first(sql)\n obj = super\n obj.allow_lazy_load if obj.is_a?(InstanceMethods)\n obj\n end", "def model_relationships; end", "def to_bson\n #----------\n self\n end", "def to_bson\n #----------\n self\n end", "def to_bson\n #----------\n self\n end", "def model\n __getobj__\n end", "def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end", "def table; end", "def table; end", "def table; end", "def table; end", "def orm_patches_applied=(_arg0); end", "def query\n self\n end", "def query\n self\n end", "def related_fields(method)\n \n end", "def scaffold_get_objects(options)\n optionshash = {}\n data = self.all\n if options[:conditions]\n conditions = options[:conditions]\n if conditions && Array === conditions && conditions.length > 0\n if String === conditions[0]\n data = data.all(:conditions => conditions)\n else\n conditions.each do |cond|\n next if cond.nil?\n data = case cond\n when Hash, String then data.all(:conditions => [cond.gsub(\"NULL\",\"?\"),nil])\n when Array then \n if cond.length==1\n data.all(:conditions => [cond[0].gsub(\"NULL\",\"?\"),nil])\n else\n data.all(:conditions => cond)\n end\n when Proc then data.all(&cond)\n end\n end\n end\n end\n end\n slice = nil\n if options[:limit]\n startpos = options[:offset] || 0\n endpos = options[:limit]\n slice = [startpos,endpos]\n end\n # TODO includes break SQL generation\n # optionshash[:links] = options[:include] if options[:include]\n # optionshash[:links] = [optionshash[:links]] unless optionshash[:links].is_a?(Array)\n if options[:order] then\n optionshash[:order] = get_ordering_options(options[:order])\n end\n if slice then\n q = data.all(optionshash).slice(*slice)\n else\n q = data.all(optionshash)\n end\n #p repository.adapter.send(\"select_statement\",q.query)\n q.to_a\n end", "def find(id); end", "def find(id); end", "def sql_modes; end", "def has_many_composite_xdb_records(name, options = {})\n association_name = options[:as] || name.to_s.underscore\n composite_field = \"#{association_name}_key\".to_sym\n object_name = options[:class_name] || name.to_s.singularize.camelize\n object_class = object_name.classify.constantize\n\n self.instance_eval do\n # Set default reload arg to true since Dynamoid::Criteria::Chain is stateful on the query\n define_method(name) do |reload = true|\n reload and self.instance_variable_set(\"@#{name}\", nil)\n if self.instance_variable_get(\"@#{name}\").blank?\n new_value = object_class.where(composite_field => \"#{self.class.name}#{ActivityNotification.config.composite_key_delimiter}#{self.id}\")\n self.instance_variable_set(\"@#{name}\", new_value)\n end\n self.instance_variable_get(\"@#{name}\")\n end\n end\n end", "def method_missing(method, *args)\n if method =~ /find/\n finder = method.to_s.split('_by_').first\n attributes = method.to_s.split('_by_').last.split('_and_')\n\n chain = Dynamoid::Criteria::Chain.new(self)\n chain.query = Hash.new.tap {|h| attributes.each_with_index {|attr, index| h[attr.to_sym] = args[index]}}\n \n if finder =~ /all/\n return chain.all\n else\n return chain.first\n end\n else\n super\n end\n end", "def transactions_to_db\n\n end", "def method_missing(name, *args)\n begin\n @model.send(name, *args)\n rescue NoMethodError\n @model.db.send(name, *args)\n end\n end", "def mongoize(object)\n object.mongoize\n end", "def relationnal_result(method_name, *arguments)\n self.class.reload_fields_definition(false)\n if self.class.many2one_associations.has_key?(method_name)\n load_m2o_association(method_name, *arguments)\n elsif self.class.polymorphic_m2o_associations.has_key?(method_name)# && @associations[method_name]\n load_polymorphic_m2o_association(method_name, *arguments)\n# values = @associations[method_name].split(',')\n# self.class.const_get(values[0]).find(values[1], arguments.extract_options!)\n else # o2m or m2m\n load_x2m_association(method_name, *arguments)\n end\n end", "def save\n result = nil\n # iterate over each instance variable and insert create row to table\n\t\t\t\t obj = self.inst_strip_braces(self.object)\n self.instance_variables.each do |method|\n method = method.to_s.gsub(/@/,\"\")\n # Don't save objects with braces to database\n val = self.send(method.to_sym)\n # add rows excluding object, source_id and update_type\n unless self.method_name_reserved?(method) or val.nil?\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"attrib\"=>method,\n \"value\"=>val,\n \"update_type\"=>'create'})\n end\n end\n # Create a temporary query record to display in the list\n Rho::RhoConfig::sources[self.class.name.to_s]['attribs'].each do |attrib|\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"attrib\"=>attrib['attrib'],\n \"value\"=>self.send(attrib['attrib'].to_sym),\n \"update_type\"=>'query'})\n end\n result\n end", "def read(id)\n sql = \"SELECT * FROM #{table_name} WHERE \"\n sql += Database.quote_identifier(@primary_key.name)\n sql += \" = \"\n sql += Database.quote_value(id, @primary_key.type)\n sql += \" LIMIT 1\"\n\n result = Database.execute(sql)\n\n if result.cmd_tuples == 0\n return nil\n else\n new_model = self.new({})\n result[0].each do |key, value|\n new_model.send(key + '=', value, true)\n end\n new_model.attributes.each { |attr| attr.reset }\n new_model\n end\n end", "def child_relation; end", "def find_all\n \n end", "def associations; end", "def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n else\n object\n end\n end", "def single_record!\n if use_eager_all?\n obj = clone(:all_called=>true).all.first\n\n if opts[:eager_graph]\n obj = clone(:all_called=>true).where(obj.qualified_pk_hash).unlimited.all.first\n end\n\n obj\n else\n super\n end\n end", "def to_bson\n end", "def sdb_to_ruby(name, value)\n# puts 'sdb_to_ruby arg=' + name.inspect + ' - ' + name.class.name + ' - value=' + value.to_s\n return nil if value.nil?\n att_meta = get_att_meta(name)\n\n if att_meta.options\n if att_meta.options[:encrypted]\n value = Translations.decrypt(value, att_meta.options[:encrypted])\n end\n if att_meta.options[:hashed]\n return PasswordHashed.new(value)\n end\n end\n\n\n if !has_id_on_end(name) && att_meta.type == :belongs_to\n class_name = att_meta.options[:class_name] || name.to_s[0...1].capitalize + name.to_s[1...name.to_s.length]\n # Camelize classnames with underscores (ie my_model.rb --> MyModel)\n class_name = class_name.camelize\n # puts \"attr=\" + @attributes[arg_id].inspect\n # puts 'val=' + @attributes[arg_id][0].inspect unless @attributes[arg_id].nil?\n ret = nil\n arg_id = name.to_s + '_id'\n arg_id_val = send(\"#{arg_id}\")\n if arg_id_val\n if !cache_store.nil?\n# arg_id_val = @attributes[arg_id][0]\n cache_key = self.class.cache_key(class_name, arg_id_val)\n# puts 'cache_key=' + cache_key\n ret = cache_store.read(cache_key)\n# puts 'belongs_to incache=' + ret.inspect\n end\n if ret.nil?\n to_eval = \"#{class_name}.find('#{arg_id_val}')\"\n# puts 'to eval=' + to_eval\n begin\n ret = eval(to_eval) # (defined? #{arg}_id)\n rescue SimpleRecord::ActiveSdb::ActiveSdbError => ex\n if ex.message.include? \"Couldn't find\"\n ret = RemoteNil.new\n else\n raise ex\n end\n end\n\n end\n end\n value = ret\n else\n if value.is_a? Array\n value = value.collect { |x| string_val_to_ruby(att_meta, x) }\n else\n value = string_val_to_ruby(att_meta, value)\n end\n end\n value\n end", "def find_angelina\n #find Angelina Jolie by name in the actors table\n Actor.find_by(name: 'Angelina Jolie')\nend", "def ordering_query; end", "def model\n end", "def persisted? ; false ; end", "def artist #this is a helper method\n sql = \"\n SELECT * FROM artists\n WHERE id = $1\"\n values = [@artist_id]\n\n artist_info = results[0]\n artist = Artist.new(artist_info)\n return artist.name\nend", "def get_base_relation(filter_by_artist, filter_by_text)\n\n # Join tables\n if @play_list\n relation = @play_list\n .play_list_songs\n .includes(:song , { :song => [ :album , :artist ] } )\n else\n # 1st try\n #relation = Song.all\n # .includes( :album , { :album => :artist } )\n\n # 2 try\n #relation = Artist.all.joins( albums: :songs )\n\n # third. Mysql is not smart enought\n # relation = Artist.all\n # .joins('INNER JOIN `albums` FORCE INDEX ( index_albums_on_artist_id_and_name ) ON `albums`.`artist_id` = `artists`.`id`')\n # .joins('INNER JOIN `songs` FORCE INDEX ( index_songs_on_album_id_and_track_and_name_and_path ) ON `songs`.`album_id` = `albums`.`id`')\n\n relation = Artist.all\n .from('artists FORCE INDEX ( index_artists_on_name )')\n .joins('INNER JOIN `songs` FORCE INDEX ( index_songs_on_artist_id_and_album_id_and_track_and_name ) ON `songs`.`artist_id` = `artists`.`id`')\n .joins('INNER JOIN `albums` ON `songs`.`album_id` = `albums`.`id`')\n end\n\n # Filters\n if filter_by_artist && @artist_id && @artist_id != 0\n relation = relation.where( 'artists.id' => @artist_id )\n end\n if @album_name && !@album_name.empty?\n relation = relation.where( 'albums.name = ?' , @album_name )\n end\n\n if @album_id && @album_id != 0\n relation = relation.where( 'albums.id' => @album_id )\n end\n\n # Search by text\n if filter_by_text\n relation = QueryText.apply_composite_query(@text, relation)\n end\n\n if @song_ids\n relation = relation.where( 'songs.id' => @song_ids )\n end\n\n if @play_list && @play_list_song_ids\n relation = relation.where( 'play_list_songs.id' => @play_list_song_ids )\n end\n\n return relation\n end", "def show\n #SQL code below in this method\n #SELECT *\n #FROM people\n #WHERE people.id = 7\n #LIMIT 1\n #from people where people.id = 7, linit 1 the find method sets the limit of 1\n end", "def on_table?; @on_table; end", "def resultset; end", "def collection; end", "def collection; end", "def persisted? ; false ; end", "def associated_records\n raise NotImplementedError\n end", "def relation_objects_perform\n # Build the relation depending on the various options (query methods).\n relation = AllTypesObject.all\n # Extract and apply query methods.\n relation = apply_query_methods(relation, params)\n\n # Perform the query\n case params[:method]\n when \"first\", \"last\", \"take\"\n amount = params[:amount].to_i if params[:amount].present?\n @results = relation.send(params[:method], *amount)\n when \"to_a\", \"all\", \"load\", \"reload\", \"first!\", \"last!\", \"take!\"\n @results = relation.send(params[:method])\n when \"select\"\n @results = relation.send(params[:method]) { true } # Select with a block acts as a finder method. The block simply returns true to not futher limit the results.\n when \"find\"\n case params[:option]\n when \"sub_method\"\n if FIND_SUB_METHODS.include?(params[:sub_method])\n @results = relation.send(params[:method], params[:sub_method].to_sym)\n else\n flash[:alert] = \"Unknown sub method selected\" unless running?\n end\n when \"single_id\"\n @results = relation.send(params[:method], params[:id])\n when \"id_list\"\n @results = relation.send(params[:method], *params[:id])\n when \"id_array\"\n @results = relation.send(params[:method], params[:id])\n end\n when \"find_by\", \"find_by!\"\n conditions = build_conditions('joined', 'list', params[:conditions]).first || [nil]\n @results = relation.send(params[:method], *conditions)\n when \"find_or_initialize_by\", \"find_or_create_by\", \"find_or_create_by!\"\n conditions = build_conditions('joined', 'hash', params[:conditions]).flatten.first || {}\n attributes = params[:attributes].reject { |k,v| v.blank? }\n if attributes.present?\n @results = relation.send(params[:method], conditions) { |object| object.attributes = attributes }\n else\n @results = relation.send(params[:method], conditions)\n end\n when \"dynamic_find_by\", \"dynamic_find_by!\"\n # Check if the attribute name is allowed to prevent errors.\n return redirect_to read_test_relation_objects_form_path(params[:method], params[:option]), :alert => \"Selected attribute is not a valid attribute of AllTypesObject!\" unless AllTypesObject.column_names.include?(params[:attribute])\n method = \"find_by_#{params[:attribute]}\" + (params[:method] == \"dynamic_find_by!\" ? \"!\" : \"\")\n @results = relation.send(method, params[:value])\n when \"find_each\", \"find_in_batches\"\n @results = []\n options = {}\n options[:start] = params[:start].to_i if params[:start].present?\n options[:batch_size] = params[:batch_size].to_i if params[:batch_size].present?\n relation.send(params[:method], options) { |results| @results << results }\n when \"first_or_initialize\", \"first_or_create\", \"first_or_create!\"\n @results = relation.send(params[:method], params[:attributes].presence)\n else\n raise \"Unknown method '#{params[:method]}'\"\n end\n\n # Wrap the result(s) in array and flatten (since the template expects an array of results)\n @all_types_objects = (@results.present? ? [@results].flatten : nil)\n\n @includes = (relation.eager_load_values + relation.includes_values + relation.preload_values).uniq\n\n respond_with(@all_types_objects)\n end", "def find(id)\n\nend", "def generate_active_record(mdm_model, config)\n #do the code to create new classes based on model metadata\n #and load them up in the Ruby VM\n #below NOTE! Need table created first for AR\n #AR provides a #column_names method that returns an array of column names\n useconnection = nil\n mdm_model.mdm_objects.each do |mdm_object|\n klass = Class.new ActiveRecord::Base do\n #establish_connection(config)\n #AR to set the physical tablename\n before_save :diff_row\n self.table_name = mdm_object.name\n \n #below does composite keys!\n \n if mdm_object.mdm_primary_keys.size > 0\n pkeys = mdm_object.mdm_primary_keys.collect{|x| x.mdm_column.name.to_sym }\n self.primary_keys = pkeys\n @@pklist = pkeys\n puts \"-\" * 80\n puts mdm_object.name, pkeys.size\n end\n #note this is FK implementation\n # has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]\n\n def name\n \n end\n \n def diff_row\n #here we send changes out over to the queue\n #we need PK followed by row\n puts self.changes\n pkvals = {}\n changevals = {}\n self.class.primary_keys.each do |k|\n pkvals[k] = self.read_attribute(k)\n end\n changevals['colvals'] = self.changes\n changevals['pkeys'] = pkvals\n redis = Redis.new\n redis.publish(\"mdm:freemdm\", changevals.to_json)\n end\n end\n \n \n #NOTE will need some adjustments to fit legacy tables to AR\n Object.const_set mdm_object.name.capitalize, klass\n puts config.symbolize_keys\n klass.establish_connection(config.symbolize_keys) \n useconnection = klass.connection if !useconnection\n # eval(\"class #{klass.name}; attr_accessible *columns;end\")\n #\n generate_column_meta(klass)\n\n klass.connection.jdbc_connection.close\n end\n \n end", "def all_as_objects\n table_name = self.to_s.pluralize\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n \n results_as_objects << self.new(result_hash)\n \n end\n \n return results_as_objects\n \n end", "def find_angelina\n #find Angelina Jolie by name in the actors table\n\n # find_by\n # Finds the first record matching the specified conditions.\n # There is no implied ordering so if order matters, you should specify it yourself.\n # If no record is found, returns nil.\n\n # Actor.find_by name: 'Angelina Jolie'\n Actor.find_by(name: 'Angelina Jolie')\nend", "def orm\n @orm || self.class.default_orm\n end" ]
[ "0.78273743", "0.6617537", "0.66127664", "0.63570035", "0.62702", "0.6155334", "0.5970101", "0.5968911", "0.5930408", "0.5920892", "0.58345324", "0.58260137", "0.580654", "0.58004534", "0.5797007", "0.5797007", "0.5797007", "0.5797007", "0.5797007", "0.5797007", "0.5797007", "0.5797007", "0.5797007", "0.5797007", "0.5771954", "0.5771954", "0.57539415", "0.5753312", "0.57176554", "0.57060057", "0.56854475", "0.56854475", "0.5682258", "0.56382716", "0.56286097", "0.56286097", "0.56136346", "0.56130195", "0.56126785", "0.5608303", "0.5608303", "0.5556297", "0.5514694", "0.551465", "0.54944474", "0.5480732", "0.54477876", "0.54477876", "0.54368305", "0.5413851", "0.541187", "0.541187", "0.541187", "0.5405381", "0.53865427", "0.53858674", "0.53858674", "0.53858674", "0.53858674", "0.53797764", "0.53594226", "0.53594226", "0.53481704", "0.5340775", "0.53406316", "0.53406316", "0.5338884", "0.5336314", "0.53262717", "0.53249526", "0.5322531", "0.53192276", "0.5314285", "0.53068787", "0.5304652", "0.5304206", "0.53018945", "0.52971685", "0.52965856", "0.52955866", "0.52954036", "0.5293881", "0.52933264", "0.5291524", "0.5289611", "0.5289404", "0.5284029", "0.5283616", "0.52829665", "0.5279685", "0.5269212", "0.52627254", "0.52627254", "0.5258005", "0.52544236", "0.5251348", "0.5244289", "0.52437013", "0.5239836", "0.52277344", "0.5221923" ]
0.0
-1
Instructions when there is missing license information, but the user has specified disableapi preventing remote license sources being used.
def no_remote_instructions(unlicensed) puts <<-INST There is no license defined for #{counter(unlicensed)}. You are running with the `--disable-api` option. If you remove this option, gemterms will attempt to use RubyGems and other sources for license information. INST true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_license()\n return true\n end", "def opted_out?(api_name)\n if @is_opted_out\n @logger.log(\n LogLevelEnum::INFO,\n 'API_NOT_ENABLED',\n {\n '{file}' => FILE,\n '{api}' => api_name\n }\n )\n end\n @is_opted_out\n end", "def api_only; end", "def api_only; end", "def api_only; end", "def intelligent_disable(pks)\n todisable = intelligent_nodeps(pks, :disable, :cant_disable, true)\n logger.info 'COMPONENTS WITHOUT DEPENDENCIES: ' + todisable.to_s\n not_found_vnfds = set_vnfds_status(todisable[:disable][:vnfds], 'inactive')\n not_found_nsds = set_nsds_status(todisable[:disable][:nsds], 'inactive')\n set_pd_status(pks, 'inactive')\n if ( not_found_vnfds.length == 0 ) and ( not_found_nsds.length == 0 )\n logger.debug \"Catalogue: leaving DISABLE /api/v2/packages?#{query_string}\\\" with PD #{pks}\"\n halt 200, JSON.generate(result: todisable)\n else\n logger.debug \"Catalogue: leaving DISABLE /api/v2/packages?#{query_string}\\\" with PD #{pks}\"\n logger.info \"Some descriptors where not found \"\n logger.info \"Vnfds not found: \" + not_found_vnfds.to_s\n logger.info \"Nsds not found: \" + not_found_nsds.to_s\n halt 404, JSON.generate(result: todisable,\n not_found: { vnfds: not_found_vnfds, nsds: not_found_nsds })\n end\n end", "def check_enabled\n User.current = nil\n parse_request\n unless @api_key.present? and @api_key == Setting.mail_handler_api_key\n render :text => 'Access denied. Redmine API is disabled or key is invalid.', :status => 403\n false\n end\n end", "def disable_autogrow\n change_autogrow_status_link.click\n autogrow_status_select.select('No')\n submit_autogrow_status_btn.click\n wait_until{ success_messages == \"Autogrow protection disabled.\" }\n end", "def license_allows_download?(document)\n document[:license_ss] =~ /(Creative Commons|No known restrictions)/\n end", "def invalid_license\n validate_values('license', :valid_licenses)\n end", "def disabled_feature\n\tatm = AtmMachine.new(100, PinValidator)\n\tcard = CreditCard.new(1234, 30)\n\tatm.insert_card(card, 666)\n\tatm.insert_card(card, 1234)\nend", "def has_license?\n !license.nil?\n end", "def invalid_license\n validate_values(:license, :valid_licenses)\n end", "def api_only=(_); end", "def ignore_apdex\n record_api_supportability_metric(:ignore_apdex)\n NewRelic::Agent::Transaction.tl_current&.ignore_apdex!\n end", "def disable_approval!\n send(:remove_const, :DRAFT_PUNK_IS_SETUP) if const_defined? :DRAFT_PUNK_IS_SETUP\n send(:remove_const, :DRAFT_NULLIFY_ATTRIBUTES) if const_defined? :DRAFT_NULLIFY_ATTRIBUTES\n send(:remove_const, :ALLOW_PREVIOUS_VERSIONS_TO_BE_CHANGED) if const_defined? :ALLOW_PREVIOUS_VERSIONS_TO_BE_CHANGED\n fresh_amoeba do\n disable\n end\n end", "def allow_api_key\n @api_key_allowed = true\n end", "def disabled?; end", "def disabled?; end", "def disable\n end", "def licensed?\n end", "def api_only\n @config.instance_variable_set(:@api_only, true)\n end", "def error_on_disabled?\n false\n end", "def disabled; end", "def disabled?\n deprecated? || deleted?\n end", "def northern_irish_driving_licence; end", "def receive_disabled\n\n wrap_reply('disable' => Flor.true?(payload['ret']))\n end", "def uk_driving_licence(*args); end", "def api_request?\n false\n end", "def restrict_access\n # check if the request has an API key as part of it...\n end", "def can_use_api?\n api_enabled\n end", "def hidden_apis; end", "def disable\n {\n method: \"Security.disable\"\n }\n end", "def api_only=(_arg0); end", "def should_remove_librun_and_stc_sources\n !(core_developer? or ENV['RETAIN_STX_AND_LIBRUN_SOURCE'] == 'yespleaseretain!')\nend", "def is_disabled?\n client = RestClient.where(:api_key => @api_key).first\n return true if client.nil?\n client.is_disabled\n end", "def api_mode; end", "def no_download!\n\t\traise_if_error C.glyr_opt_download(to_native, false)\n\tend", "def disable_approval!\n send(:remove_const, :DRAFT_PUNK_IS_SETUP) if const_defined? :DRAFT_PUNK_IS_SETUP\n send(:remove_const, :DRAFT_NULLIFY_ATTRIBUTES) if const_defined? :DRAFT_NULLIFY_ATTRIBUTES\n fresh_amoeba do\n disable\n end\n end", "def validate_license_info\n # First check the project licensing information\n\n # Check existence of licensing information\n if project.license == \"Unspecified\"\n licensing_warning(\"Project '#{project.name}' does not contain licensing information.\")\n end\n\n # Check license file exists\n if project.license != \"Unspecified\" && project.license_file.nil?\n licensing_warning(\"Project '#{project.name}' does not point to a license file.\")\n end\n\n # Check used license is a standard license\n if project.license != \"Unspecified\" && !STANDARD_LICENSES.include?(project.license)\n licensing_info(\"Project '#{project.name}' is using '#{project.license}' which is not one of the standard licenses identified in https://opensource.org/licenses/alphabetical. Consider using one of the standard licenses.\")\n end\n\n # Now let's check the licensing info for software components\n license_map.each do |software_name, license_info|\n # First check if the software specified a license\n if license_info[:license] == \"Unspecified\"\n licensing_warning(\"Software '#{software_name}' does not contain licensing information.\")\n end\n\n # Check if the software specifies any license files\n if license_info[:license] != \"Unspecified\" && license_info[:license_files].empty?\n licensing_warning(\"Software '#{software_name}' does not point to any license files.\")\n end\n\n # Check if the software license is one of the standard licenses\n if license_info[:license] != \"Unspecified\" && !STANDARD_LICENSES.include?(license_info[:license])\n licensing_info(\"Software '#{software_name}' uses license '#{license_info[:license]}' which is not one of the standard licenses identified in https://opensource.org/licenses/alphabetical. Consider using one of the standard licenses.\")\n end\n end\n end", "def disable_cobranding\n change_cobranding_status_link.click\n cobranding_status_select.select('No')\n submit_cobranding_status_btn.click\n wait_until{ !submit_cobranding_status_btn.visible? }\n end", "def partner_unsupported_os_version_blocked\n return @partner_unsupported_os_version_blocked\n end", "def enable_auto_project_license?\n resource_for_controller.try(:new_record?) && logged_in_and_registered? &&\n default_license_for_current_user\n end", "def phase3_basic_command_disabled?\r\n return false\r\n end", "def upload_licenses\n \n end", "def handle_license_error(error)\n ::NewRelic::Agent.logger.error( \\\n error.message, \\\n 'Visit NewRelic.com to obtain a valid license key, or to upgrade your account.'\n )\n disconnect\n end", "def check_if_stolen\n unless license_number != \"1111111\"\n errors.add(:license_number, \"is stolen\")\n end\n end", "def licensing?\n @config[:licensing].present? and licensing.present?\n end", "def appropriate_license?(pool, url)\n return true if pool.serverless?\n\n license = extract_license(pool.get_license(url))\n case license_status(license)\n when 'active'\n true\n when nil\n warn_no_license(url)\n false\n else # 'invalid', 'expired'\n warn_invalid_license(url, license)\n true\n end\n end", "def accepted_agreement?\n return license != DEFAULT_LICENSE\n end", "def download_disabled?\n !is_downloadable?\n end", "def disabled_warnings; end", "def double_corruption_slider!\n warn \"Disabled code #{__method__}. Do not enable in release. #{__FILE__}:#{__LINE__}\"\n\n soft_patch_defines_lua!(\"fun_and_balance_corruption\",\n [\"NCountry.CORRUPTION_COST\", 0.05, 0.10],\n )\n patch_mod_file!(\"common/static_modifiers/00_static_modifiers.txt\") do |node|\n node[\"root_out_corruption\"][\"yearly_corruption\"] = -2.0\n end\n end", "def double_corruption_slider!\n warn \"Disabled code #{__method__}. Do not enable in release. #{__FILE__}:#{__LINE__}\"\n\n soft_patch_defines_lua!(\"fun_and_balance_corruption\",\n [\"NCountry.CORRUPTION_COST\", 0.05, 0.10],\n )\n patch_mod_file!(\"common/static_modifiers/00_static_modifiers.txt\") do |node|\n node[\"root_out_corruption\"][\"yearly_corruption\"] = -2.0\n end\n end", "def disable!\n @disabled = true\n end", "def cannot_access_api?\n !request.env[\"REQUEST_METHOD\"].eql?(\"GET\") &&\n !request.headers['mw-token'].eql?(ENV[\"api_access_token\"])\n end", "def disabled=(_arg0); end", "def is_api?\n false\n end", "def get_license_toggle_with_http_info(feature_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LicenseApi.get_license_toggle ...\"\n end\n \n \n # verify the required parameter 'feature_name' is set\n fail ArgumentError, \"Missing the required parameter 'feature_name' when calling LicenseApi.get_license_toggle\" if feature_name.nil?\n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/license/toggles/{featureName}\".sub('{format}','json').sub('{' + 'featureName' + '}', feature_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\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 => 'LicenseOrgToggle')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LicenseApi#get_license_toggle\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def from_api?; false end", "def file_download_access?\n if license_delivery_contact == 'Yes'\n true\n end\n end", "def valid_es_license?(license)\n license.fetch(\"license\", {}).fetch(\"status\", nil) == \"active\"\n end", "def disable\n @disabled = true\n end", "def a_pi_key_disable_with_http_info(api_key_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: APIKeyApi.a_pi_key_disable ...\"\n end\n # verify the required parameter 'api_key_id' is set\n fail ArgumentError, \"Missing the required parameter 'api_key_id' when calling APIKeyApi.a_pi_key_disable\" if api_key_id.nil?\n # resource path\n local_var_path = \"/apiKey/disable\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n form_params[\"apiKeyID\"] = api_key_id\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'APIKey')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: APIKeyApi#a_pi_key_disable\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def notadmin\n\tprint_error(\"You need admin privs to run this!\")\n\tprint_error(\"Try using 'getsystem' or one of the many escalation scripts and try again.......\")\n\traise Rex::Script::Completed\nend", "def silence_deprecations; end", "def disable\n disable_features :all\n end", "def disable\n {\n method: \"WebAuthn.disable\"\n }\n end", "def conditional_requests=(enabled); end", "def silk_license_tag\n render 'silk_icons/license'\n end", "def cms_voucher_request?\n false\n end", "def enable!; end", "def not_on(*architectures)\n architectures = architectures.map do |name|\n if name.respond_to?(:to_str)\n [name]\n else name\n end\n end\n\n os_names, os_versions = Autoproj.workspace.operating_system\n matching_archs = architectures.find_all { |arch| os_names.include?(arch[0].downcase) }\n if matching_archs.empty?\n return yield\n elsif matching_archs.all? { |arch| arch[1] && !os_versions.include?(arch[1].downcase) }\n return yield\n end\n\n # Simply get the current list of packages, yield the block, and exclude all\n # packages that have been added\n current_packages = Autobuild::Package.each(true).map(&:last).map(&:name).to_set\n yield\n new_packages = Autobuild::Package.each(true).map(&:last).map(&:name).to_set -\n current_packages\n\n new_packages.each do |pkg_name|\n Autoproj.workspace.manifest.add_exclusion(pkg_name, \"#{pkg_name} is disabled on this operating system\")\n end\nend", "def can_disable_affiliate_branding?\n !self.invitation.nil? && \n !self.affiliate.nil? && \n (!self.subscription.trial? || !self.invitation_subscription?)\n end", "def disabled_all?; end", "def api_used!\n update_column(:api_used, true) unless api_used?\n end", "def disableAI _obj, _args\n \"_obj disableAI _args;\" \n end", "def remove_licenses=(value)\n @remove_licenses = value\n end", "def require_product?\n !!!catalog_request?\n end", "def require_product?\n !!!catalog_request?\n end", "def disable\n {\n method: \"HeadlessExperimental.disable\"\n }\n end", "def disable_channel_catalog_product_with_http_info(channel_catalog_id, product_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ChannelCatalogsProductsOptimisationApi.disable_channel_catalog_product ...\"\n end\n # verify the required parameter 'channel_catalog_id' is set\n fail ArgumentError, \"Missing the required parameter 'channel_catalog_id' when calling ChannelCatalogsProductsOptimisationApi.disable_channel_catalog_product\" if channel_catalog_id.nil?\n # verify the required parameter 'product_id' is set\n fail ArgumentError, \"Missing the required parameter 'product_id' when calling ChannelCatalogsProductsOptimisationApi.disable_channel_catalog_product\" if product_id.nil?\n # resource path\n local_var_path = \"/user/channelCatalogs/{channelCatalogId}/products/{productId}/disable\".sub('{format}','json').sub('{' + 'channelCatalogId' + '}', channel_catalog_id.to_s).sub('{' + 'productId' + '}', product_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ChannelCatalogsProductsOptimisationApi#disable_channel_catalog_product\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def log_license_deprecation_warn(url)\n @logger.warn(\"DEPRECATION WARNING: Connecting to an OSS distribution of Elasticsearch using the default distribution of Logstash will stop working in Logstash 8.0.0. Please upgrade to the default distribution of Elasticsearch, or use the OSS distribution of Logstash\", :url => url.sanitized.to_s)\n end", "def appropriate_license?(pool, url)\n return true if oss?\n\n license = pool.get_license(url)\n if valid_es_license?(license)\n true\n else\n # As this version is to be shipped with Logstash 7.x we won't mark the connection as unlicensed\n #\n # @logger.error(\"Cannot connect to the Elasticsearch cluster configured in the Elasticsearch output. Logstash requires the default distribution of Elasticsearch. Please update to the default distribution of Elasticsearch for full access to all free features, or switch to the OSS distribution of Logstash.\", :url => url.sanitized.to_s)\n # meta[:state] = :unlicensed\n #\n # Instead we'll log a deprecation warning and mark it as alive:\n #\n log_license_deprecation_warn(url)\n true\n end\n end", "def security_prevent_install_apps_from_unknown_sources\n return @security_prevent_install_apps_from_unknown_sources\n end", "def remove_licenses\n return @remove_licenses\n end", "def send_unlock_instructions; end", "def post_license_toggle_with_http_info(feature_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LicenseApi.post_license_toggle ...\"\n end\n \n \n # verify the required parameter 'feature_name' is set\n fail ArgumentError, \"Missing the required parameter 'feature_name' when calling LicenseApi.post_license_toggle\" if feature_name.nil?\n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/license/toggles/{featureName}\".sub('{format}','json').sub('{' + 'featureName' + '}', feature_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\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 => 'LicenseOrgToggle')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LicenseApi#post_license_toggle\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def retrieve_license(url)\n (@licenses ||= {})[url] ||= Net::HTTP.get(URI(url))\n end", "def legal_terms_acceptance_on!\n @legal_terms_acceptance = true\n end", "def eligibility\n #Action handles GET Plan/all queries from Eligibleapi.com\n # if @eligiblity[\"error\"] then @message = \"Sorry, there was an error with the information you entered\" end\n # \n # logger.debug \"message: #{@message}\"\n end", "def has_additional_terms_of_use\n false\n end", "def disable!\n @enabled = false\n end", "def enabled?; end", "def enabled?; end", "def disabled?\n false\n end", "def disable_tls; end", "def forbidden!\n render_api_error!('403 Forbidden', 403)\n end", "def disable_channel_catalog_with_http_info(channel_catalog_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: V2UserChannelCatalogsApi.disable_channel_catalog ...\"\n end\n # verify the required parameter 'channel_catalog_id' is set\n fail ArgumentError, \"Missing the required parameter 'channel_catalog_id' when calling V2UserChannelCatalogsApi.disable_channel_catalog\" if channel_catalog_id.nil?\n # resource path\n local_var_path = \"/v2/user/channelCatalogs/{channelCatalogId}/disable\".sub('{format}','json').sub('{' + 'channelCatalogId' + '}', channel_catalog_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: V2UserChannelCatalogsApi#disable_channel_catalog\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def disable(&block)\n @disable_block = block\n end" ]
[ "0.65706086", "0.6272512", "0.609993", "0.609993", "0.609993", "0.59620357", "0.59411335", "0.5854937", "0.58096164", "0.5787622", "0.5754711", "0.5726572", "0.5716209", "0.5688357", "0.5678192", "0.56603557", "0.56530493", "0.565202", "0.565202", "0.56110483", "0.5603035", "0.5599269", "0.55961686", "0.5594521", "0.5590195", "0.5557048", "0.55453163", "0.55252415", "0.5510615", "0.54991573", "0.5489539", "0.5486157", "0.548479", "0.54454577", "0.5427321", "0.5417495", "0.5410439", "0.54038155", "0.5395556", "0.53885806", "0.5372269", "0.5370395", "0.5365485", "0.5362848", "0.5328614", "0.5328132", "0.5313817", "0.53007793", "0.5298976", "0.52949935", "0.5284174", "0.5277121", "0.52712667", "0.52712667", "0.52681965", "0.5257492", "0.52557325", "0.5247346", "0.52465034", "0.52418405", "0.52413994", "0.5238758", "0.5236185", "0.52348983", "0.52340055", "0.52291864", "0.52279556", "0.5222057", "0.5220868", "0.5217598", "0.52125895", "0.5210393", "0.52100074", "0.51999295", "0.5188998", "0.51865", "0.51855296", "0.51834273", "0.51706105", "0.51706105", "0.5167777", "0.51664925", "0.51657605", "0.51657236", "0.5159078", "0.5158858", "0.5146725", "0.5138879", "0.5135463", "0.51327807", "0.5128557", "0.5126556", "0.51216173", "0.5113592", "0.5113592", "0.5106893", "0.50986695", "0.5094221", "0.5083053", "0.50828207" ]
0.81446695
0
POST /birds POST /birds.json Add new bird in data Sanctuary
def create @bird = Bird.new(bird_params) if @bird.save render json: @bird, status: :created else render json: @bird.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_bird\n bird_obj = bird_params\n continent = params['continents']\n unless continent.nil?\n continent = continent.split(',').map { |v| v.strip } if continent.is_a?(String)\n if continent.is_a?(Array) && !continent.blank?\n continent = continent[0].split(',').map { |v| v.strip } if continent.size==1\n end\n else\n continent =[]\n end\n bird_obj['continents'] = continent\n bird = ::Bird.new(bird_obj)\n begin\n bird.save!\n bird_obj = ::Bird.data(bird.id)\n render status: HttpCodes::CREATED, json: bird_obj.extend(BirdRepresenter).to_a.as_json\n rescue Mongoid::Errors::Validations\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"#{bird.errors.full_messages.join(\";\")}\"\n error.validation_errors = bird.errors.to_hash\n render status: HttpCodes::BAD_REQUEST, json: error.as_json\n rescue Exception => e\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"#{e.class} #{e.message}\\n #{e.backtrace}\"\n render status: HttpCodes::BAD_REQUEST, json: error.as_json\n end\n end", "def create\n @bird = Bird.new(bird_params)\n if @bird.save\n render json: @bird, status: :created, location: @bird\n else\n render json: @bird.errors, status: :unprocessable_entity\n end\n end", "def create\n #bird name must be present\n if params[:name].blank?\n render json: {\n status: 400,\n message: \"Fågelns namn måste anges.\" \n }\n end\n \n #latin name must be present\n if params[:latin].blank?\n render json: {\n status: 400,\n message: \"Fågelns latinska namn måste anges.\" \n }\n end\n \n #regularity must be present\n if params[:regularity].blank?\n render json: {\n status: 400,\n message: \"Fågelns regularitet måste anges.\" \n }\n end\n \n #check if bird already exists\n if Api::V1::Bird.exists?(:bird_name => params[:name])\n render json: {\n status: 400,\n message: \"Fågeln finns redan\" \n }\n else\n @bird = Api::V1::Bird.create(:bird_name => params[:name], :latin_name => params[:latin], :regularity => params[:regularity])\n render json: {\n status: 201,\n message: \"Fågeln är registrerad och finns nu i listan.\", \n bird: Api::V1::BirdSerializer.new(@bird) \n }\n end\n end", "def create\n begin\n respond_to do |format|\n if @bird.save(bird_params)\n format.json { render json: {items: @birds, properties: @bird.properties, families: @bird.families, description: \"Add a new bird to the library\",:status => CREATED} }\n else\n format.json { render json: @bird.errors, :status => NOT_FOUND }\n end\n end\n else\n render json:({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def create\n begin\n @bird = Bird.new(bird_params)\n @bird.visible = false if @bird.visible.nil?\n @bird.added = Date.today\n @bird.continents = bird_params[:continents].uniq\n if @bird.save\n render json: @bird, status: :created, location: @bird\n else\n render json: @bird.errors, status: 400\n end\n rescue Exception => e\n render json: \"\", status: 400\n end\n end", "def create\n @bird = Bird.new(bird_params)\n\n respond_to do |format|\n if @bird.save\n format.html { redirect_to @bird, notice: 'Bird was successfully created.' }\n format.json { render :show, status: :created, location: @bird }\n else\n format.html { render :new }\n format.json { render json: @bird.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bird = Bird.new(bird_params)\n\n respond_to do |format|\n if @bird.save\n format.html { redirect_to @bird, notice: \"Bird was successfully created.\" }\n else\n format.html { render :new, status: :unprocessable_entity }\n end\n end\n end", "def bird\n bird = Api::V1::Bird.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n bird: Api::V1::BirdSerializer.new(bird) \n }\n \n end", "def bird_params\n params.require(:bird).permit(:name, :species, :origin)\n end", "def bird_params\n params.require(:bird).permit(:name, :family, :continents, :visible, :uniqueitem)\n end", "def create\n @bunny = Bunny.new(bunny_params)\n\n respond_to do |format|\n if @bunny.save\n format.html { redirect_to @bunny, notice: 'Bunny was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bunny }\n else\n format.html { render action: 'new' }\n format.json { render json: @bunny.errors, status: :unprocessable_entity }\n end\n end\n end", "def bird_list_bird_params\n params.require(:bird_list_bird).permit(:bird_id, :bird_list_id, :rarity_id, :resident, :migrant, :summer_visitor, :winter_visitor, :vagrant)\n end", "def bird_specification\n @bird = Bird.find(params[:id])\n if @bird\n @bird = JSON.parse(@bird.to_json)\n @bird[\"id\"]=params[:id]\n render json: @bird.except(\"_id\"), status: :ok\n else\n render :nothing => true, status: :not_found\n end\n end", "def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def create\n #birdspotter id must be present\n if params[:birdspotter].blank?\n render json: {\n status: 400,\n message: \"Skaparens id saknas.\" \n }\n end\n \n #at least one bird must be present\n if params[:bird].blank?\n render json: {\n status: 400,\n message: \"En birdspot måste innehålla minst en fågel.\" \n }\n end\n \n #latitude and longitude must be present\n if params[:latitude].blank? || params[:longitude].blank?\n render json: {\n status: 400,\n message: \"En birdspot måste innehålla latitud och longitude.\" \n }\n end\n \n #check if birdspotter exists\n if Api::V1::Birdspotter.exists?(params[:birdspotter])\n \n #if exists find birdspotter\n @birdspotter = Api::V1::Birdspotter.find_by_id(params[:birdspotter])\n \n #create a new spot and append to birdspotter\n @spot = Api::V1::Spot.create(:latitude => params[:latitude], :longitude => params[:longitude])\n if @spot.save\n @birdspotter.spots << @spot\n \n #iterate through all birds and append each bird to newly created spot\n params[:bird].tr(' ','').split(',').each do |bird_id|\n if Api::V1::Bird.exists?(bird_id)\n @bird = Api::V1::Bird.find_by_id(bird_id)\n @spot.birds << @bird\n else\n render json: {\n status: 404,\n message: \"En eller flera fåglar med det id:t finns inte.\"\n }\n end\n end\n else\n render json: {\n status: 400,\n message: @spot.errors.full_messages \n }\n end\n else\n render json: {\n status: 404,\n message: \"Skapare med det id:t finns inte.\" \n }\n \n end\n \n render json: { \n status: 201,\n message: \"Din birdspot är registerad. Tack!\", \n spots: Api::V1::SpotSerializer.new(@spot) \n }\n end", "def bird_params\n params.require(:bird).permit(:name, :family, :continents, :visible)\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 create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def create\n @brain = Brain.new(params[:brain])\n\n respond_to do |format|\n if @brain.save\n format.html { redirect_to @brain, notice: 'Brain was successfully created.' }\n format.json { render json: @brain, status: :created, location: @brain }\n else\n format.html { render action: \"new\" }\n format.json { render json: @brain.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @borad = Borad.new(params[:borad])\n\n respond_to do |format|\n if @borad.save\n format.html { redirect_to @borad, :notice => 'Borad was successfully created.' }\n format.json { render :json => @borad, :status => :created, :location => @borad }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @borad.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def create\n @bruschettum = Bruschettum.new(params[:bruschettum])\n params[:ingredient].each{|ingr|\n @bruschettum.ingredients << Ingredient.find_by_name(ingr)\n }\n\n\n respond_to do |format|\n if @bruschettum.save\n format.html { redirect_to @bruschettum, notice: 'Bruschetta è stata creata con successo.' }\n format.json { render json: @bruschettum, status: :created, location: @bruschettum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bruschettum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @brend = Brend.new(params[:brend])\n\n respond_to do |format|\n if @brend.save\n format.html { redirect_to @brend, notice: 'Brend was successfully created.' }\n format.json { render json: @brend, status: :created, location: @brend }\n else\n format.html { render action: \"new\" }\n format.json { render json: @brend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @bird.update(bird_params)\n render json: @bird, status: :ok, location: @bird\n else\n render json: @bird.errors, status: :unprocessable_entity\n end\n end", "def bird_record_params\n params.require(:bird_record).permit(:bird_id, :birding_session_id, :count, :notes)\n end", "def create\n @basin = Basin.new(params[:basin])\n\n respond_to do |format|\n if @basin.save\n format.html { redirect_to @basin, notice: 'Basin was successfully created.' }\n format.json { render json: @basin, status: :created, location: @basin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @basin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bollywood = Bollywood.new(bollywood_params)\n\n respond_to do |format|\n if @bollywood.save\n format.html { redirect_to @bollywood, notice: 'Bollywood was successfully created.' }\n format.json { render :show, status: :created, location: @bollywood }\n else\n format.html { render :new }\n format.json { render json: @bollywood.errors, status: :unprocessabl2e_entity }\n end\n end\n end", "def create\n @brave_burst = BraveBurst.new(brave_burst_params)\n\n respond_to do |format|\n if @brave_burst.save\n format.html { redirect_to @brave_burst, notice: 'Brave burst was successfully created.' }\n format.json { render action: 'show', status: :created, location: @brave_burst }\n else\n format.html { render action: 'new' }\n format.json { render json: @brave_burst.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boat, status: 201\n \tend\n\tend", "def create_breed(breed, price)\n @db.exec(%q[\n INSERT INTO breeds (breed, price)\n VALUES ($1, $2);\n ], [breed, price])\n end", "def create\n @rainbow = Rainbow.new(params[:rainbow])\n\n respond_to do |format|\n if @rainbow.save\n format.html { redirect_to @rainbow, notice: 'Rainbow was successfully created.' }\n format.json { render json: @rainbow, status: :created, location: @rainbow }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rainbow.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @brag = Brag.new(params[:brag])\n\n respond_to do |format|\n if @brag.save\n format.html { redirect_to @brag, notice: 'Brag was successfully created.' }\n format.json { render json: @brag, status: :created, location: @brag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @brag.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(bin_params)\n @rest.post('save', bin_params)\n end", "def create\n @breed = Breed.new(params[:breed])\n\n respond_to do |format|\n if @breed.save\n format.html { redirect_to breeds_path } #notice: 'Breed was successfully created.' }\n format.json { render json: @breed, status: :created, location: @breed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @breed.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @burpy = Burpy.new(burpy_params)\n\n respond_to do |format|\n if @burpy.save\n format.html { redirect_to @burpy, notice: 'Burpy was successfully created.' }\n format.json { render :show, status: :created, location: @burpy }\n else\n format.html { render :new }\n format.json { render json: @burpy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bollywood = Bollywood.new(bollywood_params)\n\n respond_to do |format|\n if @bollywood.save\n format.html { redirect_to @bollywood, notice: 'Bollywood was successfully created.' }\n format.json { render :show, status: :created, location: @bollywood }\n else\n format.html { render :new }\n format.json { render json: @bollywood.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @blurbs = Blurb.find(:all)\n @blurb = Blurb.new(params[:blurb])\n respond_to do |format|\n if @blurb.save\n flash[:notice] = t('blurbs.new.success', :blurb_name => @blurb.name)\n format.html { redirect_to(edit_blurb_url(@blurb)) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def bunny_params\n params.require(:bunny).permit(:name, :age, :color, :breed, :favorite_comic_book)\n end", "def create\n @herb = Herb.new(params[:herb])\n\n respond_to do |format|\n if @herb.save\n format.html { redirect_to @herb, notice: 'Herb was successfully created.' }\n format.json { render json: @herb, status: :created, location: @herb }\n else\n format.html { render action: \"new\" }\n format.json { render json: @herb.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_bird\n @bird = Bird.find(params[:id]) rescue nil\n end", "def create\n @bike_rack = BikeRack.new(bike_rack_params)\n\n respond_to do |format|\n if @bike_rack.save\n flash[:success] = 'Bike rack was successfully created.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :created, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem with creating Bike rack.'\n format.html { render :new }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @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 birdspotter\n birdspotter = Api::V1::Birdspotter.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n birdspotter: Api::V1::BirdspotterSerializer.new(birdspotter) \n }\n end", "def create\n @bowling = Bowling.new(bowling_params)\n\n respond_to do |format|\n if @bowling.save\n format.html { redirect_to @bowling, notice: 'Bowling was successfully created.' }\n format.json { render :show, status: :created, location: @bowling }\n else\n format.html { render :new }\n format.json { render json: @bowling.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @birds = Bird.all\n end", "def index\n @birds = Bird.all\n end", "def create\n @broad = Broad.new(params[:broad])\n\n respond_to do |format|\n if @broad.save\n format.html { redirect_to @broad, notice: 'Broad was successfully created.' }\n format.json { render json: @broad, status: :created, location: @broad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @broad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @animal = Animal.new(params[:animal])\n @species = ['Lion', 'Koala', 'Panda']\n @zoo = Zoo.find(params[:zoo_id])\n @animal.zoo_id = params[:zoo_id];\n \n\n respond_to do |format|\n\n if @animal.save\n format.html { redirect_to zoo_animal_path(params[:zoo_id],@animal.id),\n notice: 'animal was successfully created.' }\n format.json { render json: @animal, status: :created,\n location: @animal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @animal.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def create\n @boy = Boy.new(params[:boy])\n\n respond_to do |format|\n if @boy.save\n format.html { redirect_to @boy, notice: 'Boy was successfully created.' }\n format.json { render json: @boy, status: :created, location: @boy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @boy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boy = Boy.new(params[:boy])\n\n respond_to do |format|\n if @boy.save\n format.html { redirect_to @boy, notice: 'Boy was successfully created.' }\n format.json { render json: @boy, status: :created, location: @boy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @boy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bacon = Bacon.new(bacon_params)\n\n respond_to do |format|\n if @bacon.save\n format.html { redirect_to @bacon, notice: 'Bacon was successfully created.' }\n format.json { render json: { bacon: @bacon }}\n else\n format.html { render action: 'new' }\n format.json { render json: @bacon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bow = Bow.new(bow_params)\n\n respond_to do |format|\n if @bow.save\n format.html { redirect_to @bow, notice: 'Bow was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bow }\n else\n format.html { render action: 'new' }\n format.json { render json: @bow.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @breed = Breed.new(breed_params)\n @user = User.find(params[:user_id])\n @breed.user_id = @user.id\n# puts @breed\nlogger.info(@breed)\n\n if @breed.save!\n render json: @breed, status: :created\n else\n render json: @breed.errors, status: :unprocessable_entity\n end\n # render json: {breed: :breed_params}\n end", "def create\n @bdatabase = Bdatabase.new(params[:bdatabase])\n\n respond_to do |format|\n if @bdatabase.save\n format.html { redirect_to @bdatabase, notice: 'Bdatabase was successfully created.' }\n format.json { render json: @bdatabase, status: :created, location: @bdatabase }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bdatabase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @current_bijou = current_rockhound;\n # @bijou = Bijou.new(bijou_params)\n\n @new_bijou = @current_bijou.bijous.build(bijou_params)\n\n respond_to do |format|\n if @new_bijou.save\n format.html { redirect_to @bijou, notice: 'Bijou was successfully created.' }\n format.json { render :show, status: :created, location: @bijou }\n else\n format.html { render :new }\n format.json { render json: @bijou.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boat = Boat.new(boat_params)\n\n respond_to do |format|\n if @boat.save\n format.html { redirect_to @boat, notice: 'Boat was successfully created.' }\n format.json { render :show, status: :created, location: @boat }\n else\n format.html { render :new }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boat = @harbour.boats.build(boat_params)\n @boat.save\n redirect_to harbour_boats_path(@harbour)\n # respond_to do |format|\n # if @boat.save\n # format.html { redirect_to harbour_boats_path, notice: 'Boat was successfully created.' }\n # format.json { render :show, status: :created, location: @boat }\n # else\n # format.html { render :new }\n # format.json { render json: @boat.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n params[:bubble_tea][:store_id] = params[:id] unless params[:bubble_tea][:store_id].present?\n @bubble_tea = BubbleTea.new(bubble_tea_params)\n\n if @bubble_tea.save\n # successful bubble tea drink creation\n render json: @bubble_tea\n else\n render plain: \"Failed to save drink.\"\n end\n end", "def create\n ass = BowlingAssociation.find(bowler_params[:bowling_association_id])\n \n @bowler = ass.bowlers.create(bowler_params)\n\n \n respond_to do |format|\n if @bowler.save\n\n @bowler.average_entries.create(average: bowler_params[:pbc_average])\n\n @bowler.record :create, current_user, selected_tournament\n\n flash[:create_notice] = \"Bowler #{@bowler.name} has successfully been added.\"\n format.html { redirect_to @bowler }\n format.js { render 'create' }\n else\n format.html { render action: 'new' }\n format.json { render json: @bowler.errors, status: :unprocessable_entity }\n format.js { render 'error' }\n end\n end\n end", "def birds_list\n birds = ::Bird.all\n render status: HttpCodes::OK,json: birds.extend(BirdRepresenter).to_a.as_json unless birds.empty?\n render status: HttpCodes::OK,json: {} if birds.empty?\n end", "def create\n @baggage = Baggage.new(params[:baggage])\n\n respond_to do |format|\n if @baggage.save\n format.html { redirect_to @baggage, notice: 'Baggage was successfully created.' }\n format.json { render json: @baggage, status: :created, location: @baggage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @baggage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @band = Band.new(band_params)\n\n respond_to do |format|\n if @band.save\n format.html { redirect_to @band, notice: 'Band was successfully created.' }\n format.json { render :show, status: :created, location: @band }\n else\n format.html { render :new }\n format.json { render json: @band.errors, status: :unprocessable_entity }\n end\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\n if params[:buzz_tag].present?\n tag = Tag.where(:id => params[:buzz_tag]).first\n @buzz_tag = BuzzTag.add_buzz_tag(@buzz, tag.id)\n end\n end", "def create\n @animal = Animal.new(post_params)\n @animal.breed_id = params[\"animal\"][\"breed\"].to_i\n @animal.user = current_user\n # @animal.breed = Breed.find_by(name: 'Golden Retriever')\n\n respond_to do |format|\n if @animal.save\n format.html { redirect_to '/posts/new', notice: 'Post was successfully created.' }\n format.json { redirect_to '/posts/new', status: :created, location: @animal }\n else\n format.html { render :new }\n format.json { render json: @animal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dog = Dog.new(dog_params)\n\n if @dog.save\n render json: @dog, status: 201\n else\n render json: {\n errors: @dog.errors\n }\n end\n end", "def create\n @sound_bite = SoundBite.new(sound_bite_params)\n\n respond_to do |format|\n if @sound_bite.save\n format.html { redirect_to @sound_bite, notice: 'Sound bite was successfully created.' }\n format.json { render :show, status: :created, location: @sound_bite }\n else\n format.html { render :new }\n format.json { render json: @sound_bite.errors, status: :unprocessable_entity }\n end\n end\n end", "def insertUntappdBlob(data)\n data[\"beers\"][\"items\"].map { |item|\n b = item[\"beer\"]\n @db.execute \"INSERT INTO #{@untappdTable} VALUES (?,?,?,?,?,?,?,?,?,?)\",\n [b[\"bid\"], b[\"beer_name\"], item[\"brewery\"][\"brewery_name\"],\n b[\"beer_label\"], b[\"beer_abv\"],\n b[\"beer_ibu\"], b[\"beer_style\"], b[\"description\"], \n b[\"rating_score\"], b[\"rating_count\"]]\n }\n end", "def create\n @bowl = Bowl.new(params[:bowl])\n\n respond_to do |format|\n if @bowl.save\n format.html { redirect_to(@bowl, :notice => 'Bowl was successfully created.') }\n format.xml { render :xml => @bowl, :status => :created, :location => @bowl }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end", "def remove_bird\n bird = ::Bird.find(params[:id])\n if bird.nil?\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"Bird does not nound\"\n error.validation_errors = \"Invalid Bird Id \"\n render status: HttpCodes::NOT_FOUND, json: error.as_json\n else\n bird.destroy\n render status: HttpCodes::OK ,json: \"OK\".to_json\n end\n end", "def create\n @banda = Banda.new(params[:banda])\n\n respond_to do |format|\n if @banda.save\n format.html { redirect_to @banda, notice: 'Banda was successfully created.' }\n format.json { render json: @banda, status: :created, location: @banda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @banda.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bien = Bien.new(bien_params)\n\n respond_to do |format|\n if @bien.save\n format.html { redirect_to @bien, notice: 'Bien was successfully created.' }\n format.json { render :show, status: :created, location: @bien }\n else\n format.html { render :new }\n format.json { render json: @bien.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if bolt_params.number_of_bolts\n #not what we want\n else\n @bolt = Bolt.new(bolt_params)\n end\n respond_to do |format|\n if @bolt.save\n format.html { redirect_to @bolt, notice: 'Bolt was successfully created.' }\n format.json { render :show, status: :created, location: @bolt }\n else\n format.html { render :new }\n format.json { render json: @bolt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n megam_rest.post_billedhistories(to_hash)\n end", "def create\n @bio_signal = BioSignal.new(params[:bio_signal])\n\n respond_to do |format|\n if @bio_signal.save\n format.html { redirect_to @bio_signal, notice: 'Bio signal was successfully created.' }\n format.json { render json: @bio_signal, status: :created, location: @bio_signal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bio_signal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @brewhouse = Brewhouse.new(params[:brewhouse])\n\n respond_to do |format|\n if @brewhouse.save\n format.html { redirect_to @brewhouse, notice: 'Brewhouse was successfully created.' }\n format.json { render json: @brewhouse, status: :created, location: @brewhouse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @brewhouse.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @new_boat = Boat.create(\n name: params[:boat][:name],\n maxcontainers: params[:boat][:maxcontainers],\n company_id: params[:boat][:company_id],\n location: params[:boat][:location],\n image: params[:boat][:image]\n )\n\n\n\n if @new_boat\n redirect_to url_for(:controller => :boats, :action => :index)\n else\n redirect_to url_for(:controller => :boats, :action => :new)\n end\n end", "def create\n @drug = Drug.new(params[:drug])\n\n respond_to do |format|\n if @drug.save\n format.html { redirect_to @drug, notice: 'Drug was successfully created.' }\n format.json { render json: @drug, status: :created, location: @drug }\n else\n format.html { render action: \"new\" }\n format.json { render json: @drug.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_dog(name)\n @db.get_first_value('INSERT INTO dogs VALUES (null, :name)', \n ':name' => name)\n end", "def create\n @ribbit = Ribbit.new(ribbit_params)\n @ribbit.frog_id = current_frog.id\n\n respond_to do |format|\n if @ribbit.save\n format.html { redirect_to @ribbit, notice: 'Ribbit was successfully created.' }\n format.json { render :show, status: :created, location: @ribbit }\n else\n format.html { render :new }\n format.json { render json: @ribbit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet_breed = PetBreed.new(pet_breed_params)\n\n respond_to do |format|\n if @pet_breed.save\n format.html { redirect_to @pet_breed, notice: 'Pet breed was successfully created.' }\n format.json { render :show, status: :created, location: @pet_breed }\n else\n format.html { render :new }\n format.json { render json: @pet_breed.errors, status: :unprocessable_entity }\n end\n end\n end", "def birds\n @birds = Api::V1::Bird.all\n @serializer = ActiveModel::ArraySerializer\n\n #if regularity is not defined get all birds\n if params[:regularity].blank?\n render json: {\n status: 200,\n message: \"OK\",\n totalCount: @birds.count,\n birds: @serializer.new(@birds, each_serializer: Api::V1::BirdSerializer) \n }\n \n \n #if regularity is defined get birds based on regularity\n else\n @regularity = params[:regularity].split(\",\")\n @birds = @birds.where(regularity: @regularity)\n render json: \n { \n status: 200,\n message: \"OK\",\n totalCount: @birds.count,\n birds: @serializer.new(@birds, each_serializer: Api::V1::BirdSerializer) \n }\n end\n end", "def create\n @blog = Blog.create(blog_params)\n params[:tags][:tag_id].each do |p|\n @tagging = Tagging.create(tag_id: p.to_i, blog_id: @blog.id)\n end\n respond_to do |format|\n\n format.html { redirect_to @blog, notice: 'Blog was successfully created.' }\n format.json { render :show, status: :created, location: @blog }\n\n end\nend", "def create\n @borc = Borc.new(params[:borc])\n\n respond_to do |format|\n if @borc.save\n format.html { redirect_to @borc, notice: 'Borc was successfully created.' }\n format.json { render json: @borc, status: :created, location: @borc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @borc.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @form_bir = FormBir.new(form_bir_params)\n\n respond_to do |format|\n if @form_bir.save\n format.html { redirect_to @form_bir, notice: 'Form bir was successfully created.' }\n format.json { render :show, status: :created, location: @form_bir }\n else\n format.html { render :new }\n format.json { render json: @form_bir.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @barrack = Barrack.new(params[:barrack])\n\n respond_to do |format|\n if @barrack.save\n format.html { redirect_to @barrack, notice: 'Barrack was successfully created.' }\n format.json { render json: @barrack, status: :created, location: @barrack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end", "def bird_params\n params.fetch(:bird, {}).permit(:common_name, :latin_name)\n end", "def create\n @bond = Bond.new(bond_params)\n\n respond_to do |format|\n if @bond.save\n format.html { redirect_to bonds_path, notice: I18n.t('messages.created_with', item: @bond.company) }\n format.json { render :show, status: :created, location: @bond }\n else\n format.html { render :new }\n format.json { render json: @bond.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @animals = Animal.all\n @animal = Animal.create(animal_params)\n\n end", "def create\n @bike_type = BikeType.new(bike_type_params)\n\n if @bike_type.save\n audit(@bike_type, current_user)\n render json: @bike_type, status: :created\n else\n render json: @bike_type.errors, status: :unprocessable_entity\n end\n end", "def create\n @bin = Bin.new(bin_params)\n\n respond_to do |format|\n if save_bin(@bin)\n format.html { redirect_to @bin, notice: 'Bin was successfully created.' }\n format.json { render json: { ok: true, bin: @bin } }\n else\n format.html { render :new }\n format.json {\n bin = Bin.find_by(id: @bin.id) || {}\n render json:\n { ok: false, errors: @bin.errors.full_messages, bin: bin }\n }\n end\n end\n end", "def create\n @bagtype = Bagtype.new(params[:bagtype])\n\n respond_to do |format|\n if @bagtype.save\n format.html { redirect_to @bagtype, notice: 'Bagtype was successfully created.' }\n format.json { render json: @bagtype, status: :created, location: @bagtype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bagtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bl = Bl.new(params[:bl])\n\n respond_to do |format|\n if @bl.save\n format.html { redirect_to @bl, notice: 'Bl was successfully created.' }\n format.json { render json: @bl, status: :created, location: @bl }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bl.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n AuditedOperationsService.add_birth_record_to_user(\n user: current_user,\n birth_record: BirthRecord.find_by(params.permit(:id))\n )\n\n redirect_to user_birth_records_path\n end", "def create\n @britt = Britt.new(britt_params)\n\n respond_to do |format|\n if @britt.save\n format.html { redirect_to @britt, notice: 'Britt was successfully created.' }\n format.json { render :show, status: :created, location: @britt }\n else\n format.html { render :new }\n format.json { render json: @britt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dog = Dog::Dog.new(params[:dog_dog])\n\n respond_to do |format|\n if @dog.save\n format.html { redirect_to @dog, notice: 'Dog was successfully created.' }\n format.json { render json: @dog, status: :created, location: @dog }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dog.errors, status: :unprocessable_entity }\n end\n end\n end", "def insertCrawlerBlob(data)\n data.each do |beer|\n beer['price'] = beer['price'].gsub(/[^\\d\\.]/, '').to_f\n beer['style'] = JSON.generate(beer['style'])\n @db.execute \"INSERT INTO #{@crawlerTable} VALUES (?,?,?,?,?,?)\", beer.values\n end\n end" ]
[ "0.7714612", "0.75363326", "0.7342247", "0.73273396", "0.7292651", "0.7231101", "0.7071595", "0.6567158", "0.6535382", "0.632883", "0.62607706", "0.6230511", "0.62067455", "0.61623937", "0.6154507", "0.6017123", "0.5993737", "0.5970231", "0.5929623", "0.5923371", "0.5912476", "0.5911365", "0.5911365", "0.5911365", "0.59034437", "0.58963937", "0.58936805", "0.5888483", "0.5888119", "0.58337593", "0.5814864", "0.5794639", "0.5788719", "0.5780758", "0.57624316", "0.57599986", "0.57186097", "0.57137257", "0.571205", "0.5699957", "0.5689045", "0.56882", "0.5688107", "0.5678301", "0.56532353", "0.5651408", "0.5647098", "0.5641359", "0.5641359", "0.5632392", "0.5625437", "0.5623218", "0.5623218", "0.5619666", "0.5610744", "0.5608342", "0.56067926", "0.5601653", "0.5578821", "0.55761755", "0.5569392", "0.55667174", "0.5566706", "0.5565304", "0.55604315", "0.55580264", "0.5549105", "0.554483", "0.55375487", "0.55347174", "0.55302745", "0.55239815", "0.5523075", "0.5522168", "0.5521095", "0.5520406", "0.5509552", "0.5493282", "0.54923606", "0.5491166", "0.5491033", "0.5486367", "0.5478529", "0.547149", "0.5462866", "0.5456837", "0.54567796", "0.54530495", "0.5449533", "0.5448802", "0.5439493", "0.5432823", "0.5420473", "0.54203707", "0.5416821", "0.54113656", "0.5409536", "0.5403959", "0.5401197", "0.54008514" ]
0.7564016
1
GET /birds GET /birds.json Returns all the available birds in sanctuary
def total_visible_birds @birds = Bird.all(visible: true) render json: @birds, status: :ok end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def birds_list\n birds = ::Bird.all\n render status: HttpCodes::OK,json: birds.extend(BirdRepresenter).to_a.as_json unless birds.empty?\n render status: HttpCodes::OK,json: {} if birds.empty?\n end", "def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def index\n @birds = Bird.where(visible: true)\n render json: @birds, status: 200\n end", "def birds\n @birds = Api::V1::Bird.all\n @serializer = ActiveModel::ArraySerializer\n\n #if regularity is not defined get all birds\n if params[:regularity].blank?\n render json: {\n status: 200,\n message: \"OK\",\n totalCount: @birds.count,\n birds: @serializer.new(@birds, each_serializer: Api::V1::BirdSerializer) \n }\n \n \n #if regularity is defined get birds based on regularity\n else\n @regularity = params[:regularity].split(\",\")\n @birds = @birds.where(regularity: @regularity)\n render json: \n { \n status: 200,\n message: \"OK\",\n totalCount: @birds.count,\n birds: @serializer.new(@birds, each_serializer: Api::V1::BirdSerializer) \n }\n end\n end", "def index\n @birds = Bird.all\n end", "def index\n @birds = Bird.all\n end", "def index\n birds = Bird.all\n render json: birds.to_json(except: [:created_at, :updated_at])\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 getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end", "def index\n @bunnies = Bunny.all\n end", "def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend", "def db_list\n beername = params[:name]\n @beer_info = BREWERY.search.beers(q: beername, withBreweries: 'Y').first(10)\n @beers_with_breweries = []\n @beerlist = @beer_info.map do |drink|\n drink_object(drink)\n end\n render json: @beerlist\n end", "def get_brandings\n request :get, \"/v3/brandings.json\"\n end", "def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end", "def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end", "def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end", "def index\n @britts = Britt.all\n end", "def my_bets\n @bets = Bet.where('owner = ? AND status != ? AND status != ?', params[:id], \"won\", \"lost\").to_a\n @bets.sort! {|x,y| x.id <=> y.id }\n render 'my-bets.json.jbuilder'\n end", "def index\n @brave_bursts = BraveBurst.all\n end", "def index\n @breeds = Breed.all\n\n render json: @breeds\n end", "def index\n @boks = Bok.all\n end", "def get_banks\n HTTParty.get(BASE_URI + 'bank?country=ghana',\n headers: HEADERS).parsed_response\n end", "def index\n @lightbulbs = Lightbulb.all\n end", "def index\n @bronies = Brony.all\n end", "def index\n @bills = @dwelling.bills\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bills }\n end\n end", "def index\n pet_type = PetType.find(params[:pet_type_id])\n @pet_breeds = pet_type.pet_breeds.select { | match | match.published }\n\n respond_to do | format |\n format.html #index.html.erb\n format.json { render json: @pet_breeds }\n end\n end", "def index\n @bids = Bid.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bids }\n end\n end", "def show\n @bird = Bird.joins(:sightings).find(params[:id])\n if @bird\n render json: {\n \"bird\": @bird,\n \"sightings\": [@bird.sightings]\n }, status: :ok\n else\n render json: @bird.errors, status: :unprocessable_entity\n end\n end", "def index\n @breeds = Breed.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @breeds }\n end\n end", "def index\n @buisnesses = Buisness.all\n\n render json: @buisnesses \n end", "def index\n @bounties = Bounty.all\n end", "def init_brands\n response = @conn.get do |req|\n req.url \"/api/v1/brands\"\n req.headers = rest_headers\n end\n\n @brands = json(response.body)[:brands]\n end", "def all_bathing_waters(options = {})\n if bws_by_uri.empty?\n api_options = { _pageSize: 600 }.merge(options)\n\n bws = api_get_resources(BathingWater.endpoint_all, ALL_PAGES, BathingWater, api_options)\n bws.each do |bw|\n bws_by_uri[bw.uri] = bw\n bws_by_id[bw.id] = bw\n end\n end\n\n bws_by_uri.values\n end", "def index\n @stationary_batteries_battery_banks = StationaryBatteriesBatteryBank.all\n end", "def index\n @bowlings = Bowling.all\n end", "def index\n @blues = Blue.all\n end", "def index\n @wears = Wear.all.order(brand: :asc)\n render json: @wears\n end", "def index\n @banks = Bank.all\n render json: @banks\n end", "def index\n @active_breweries = Brewery.active\n\t\t@retired_breweries = Brewery.retired\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @breweries }\n end\n end", "def index\n @bets = Bet.all\n end", "def index\n @bowlers = Bowler.all\n respond_with(@bowlers)\n end", "def index\n @blars = Blar.all\n end", "def index\n @bilges = Bilge.all\n end", "def index\n @bolts = Bolt.all\n end", "def show\n if @bird\n respond_to do |format|\n format.json { render json: {required: @bird, properties: @bird.properties, families: @bird.families, title: \"POST /birds [request]\", description: \"Get bird by id\",:status => OK }}\n end\n else\n respond_to do |format|\n format.json { render json: {:status => NOT_FOUND} }\n end\n end\n end", "def index\n @bobs = Bob.paginate(:page => params[:page], :order => 'created_at DESC',:per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bobs }\n end\n end", "def index\n @bustours = Bustour.all\n end", "def index\n @kind_of_boats = KindOfBoat.all\n end", "def index\n @boredoms = Boredom.all\n end", "def index\n @brochures = Brochure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brochures }\n end\n end", "def index\n @biddings = Bidding.all\n end", "def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end", "def index\n if params[:title]\n @boats = Boat.where title: params[:title]\n else\n if params[:open_seats]\n @boats = Boat.where open_seats: params[:open_seats]\n else\n @boats = Boat.all\n end\n end\n render json: @boats\n end", "def index\n @bhistories = Bhistory.all\n end", "def index\n @bikestands = Bikestand.all\n end", "def index\n @blivots = Blivot.all\n end", "def index\n @biens = Bien.all\n end", "def index\n @bike_hires = BikeHire.all\n end", "def bird\n bird = Api::V1::Bird.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n bird: Api::V1::BirdSerializer.new(bird) \n }\n \n end", "def find_bikes\n user_id = params[\"user_id\"]\n bike_ids = get_bike_ids(user_id)\n bikes = []\n bike_ids.each {|bike_id|\n bikes.push(get_bike(bike_id, user_id))\n }\n update_bike_database(bikes, user_id)\n render json: { new_bikes: bikes }\n end", "def get_bs_companies(vendors)\r\n response = make_API_request(\"https://api.bitsighttech.com/ratings/v1/companies\",'get','',false,{type: 'basic', username: $BS_TOKEN, password: ''})\r\n\tcompanies = JSON.parse(response.body)['companies']\r\n\r\n\tputs \"BitSight API code: #{response.code}, #{companies.length} companies sent\"\r\n\tif response.code != \"200\"\r\n\t\tputs \"BitSight API response:\"\r\n\t\tpp JSON.parse(response.body)\r\n\tend\r\n\r\n\tcreates = updates = Array.new\r\n\tcompanies.each do |company|\r\n\t\tcurrent_vendor = vendors[company['guid']]\r\n\t\tif(current_vendor != nil)\r\n\t\t\tif(current_vendor['attributes']['bitsight_rating_date']==company['rating_date']) then next end\r\n\t\t\tprofile = build_profile_hash(company, current_vendor['id'])\r\n\t\t\tupdates << profile\r\n\t\telse\r\n\t\t\tprofile = build_profile_hash(company)\r\n\t\t\tcreates << profile\r\n\t\tend\r\n\tend\r\n\tlists = {\r\n\t\tcreates: creates,\r\n\t\tupdates: updates,\r\n\t}\r\nend", "def index\n @bagels = Bagel.all\n end", "def index\n @bloodstocks = Bloodstock.all\n end", "def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end", "def index\n @boats = Boat.all\n end", "def index\n @boats = Boat.all\n end", "def index\n @weddings = Wedding.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weddings }\n end\n end", "def index\n @buddies = Buddy.all\n end", "def index\n @buisinesses = Buisiness.all\n end", "def index\n @businesses = Business.all.offset(offset).limit(limit)\n render json: @businesses\n end", "def all_star_ballot(league_id, season = nil, **options)\n options[:season] = season || Time.now.year\n\n get \"/league/#{league_id}/allStarBallot\", **options\n end", "def index\n @balloons = Balloon.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded balloons', data:@balloons},status: :ok\n end", "def state_breweries\n render json: BreweryDb::ShowBreweries.new('state', params[:state]).results\n end", "def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end", "def index\n response = RestClient.get 'http://api.bitvalor.com/v1/order_book.json'\n data = JSON.parse(response.body)[\"bids\"]\n @fox = data.select {|element| element[0] == \"FOX\"}\n @b2u = data.select {|element| element[0] == \"B2U\"}\n @mbt = data.select {|element| element[0] == \"MBT\"}\n end", "def index\n weathers = Weather.all\n render json: weathers, status: 200\n end", "def index\n @bands = Band.all \n\t@tags = Store.find_by_sql(\"select DISTINCT tag from stores\")\n\t@stores = Store.find(:all, :order => \"created_at desc\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stores }\n end\n end", "def index\n @blood_pressures = BloodPressure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @blood_pressures }\n end\n end", "def index\n @hoods = Hood.all\n end", "def index\n @bands = Band.all\n end", "def index\n @belts = Belt.all\n end", "def index\n @bettings = Betting.all\n end", "def index\n @bids = Bid.all\n end", "def index\n @bids = Bid.all\n end", "def index\n @bids = Bid.all\n end", "def index\n @bids = Bid.all\n end", "def index\n @buoys = Buoy.all\n end", "def index\n @braiders = Braider.find(:all)\n end", "def get_non_bajaj_vehicles\n @bikes = Bike.where(non_bajaj: true).order(\"display_order\")\n \n render json: @bikes\n end", "def index\n @shop_section = ShopSection.find_by_short_url(\"brands\")\n @brands = Brand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brands }\n end\n end", "def index\n @lobbies = Lobby.all\n end", "def drinks\n top_drinks = Drink.top.limit(5)\n exclude_drink_ids = top_drinks.map(&:id)\n top_gin_drinks = Drink.top(Ingredient.gin_canonical_id, exclude_drink_ids).limit(5)\n exclude_drink_ids += top_gin_drinks.map(&:id)\n top_vodka_drinks = Drink.top(Ingredient.vodka_canonical_id, exclude_drink_ids).limit(5)\n exclude_drink_ids += top_vodka_drinks.map(&:id)\n top_margarita_drinks = Drink.top([Ingredient.triple_sec_canonical_id, Ingredient.tequila_canonical_id], exclude_drink_ids).limit(5)\n render json: {\n general: top_drinks,\n gin_drinks: top_gin_drinks,\n vodka_drinks: top_vodka_drinks,\n margaritas: top_margarita_drinks,\n }\n end", "def index\n @bocconis = Bocconi.all\n end", "def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @baskets }\n end\n end", "def index\n @beasts = Beast.all\n end", "def index\n @banks = Bank.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @banks }\n end\n end", "def index\n @barns = Barn.all\n end", "def index\n @boooks = Boook.page(params[:page]).per(5)\n end", "def index\n @bandtogethers = Bandtogether.all\n end", "def bridges_list\n get \"bridges\"\n end" ]
[ "0.76453465", "0.7624405", "0.73643875", "0.6947235", "0.6882653", "0.6882653", "0.6737538", "0.6672589", "0.66622317", "0.66176736", "0.6583566", "0.651511", "0.64983344", "0.6469395", "0.6394985", "0.63911265", "0.63898486", "0.6365461", "0.6365438", "0.63297385", "0.6329194", "0.6316951", "0.6287099", "0.62563974", "0.623251", "0.622866", "0.62165254", "0.62149376", "0.6195438", "0.61819607", "0.6180232", "0.616993", "0.61662114", "0.61357915", "0.613383", "0.61127603", "0.6080499", "0.60651445", "0.6061244", "0.6028919", "0.6014268", "0.6003245", "0.59993464", "0.59986436", "0.59974205", "0.59912443", "0.59826595", "0.5982588", "0.59723", "0.5963161", "0.59559214", "0.5955113", "0.5947672", "0.59168255", "0.59098995", "0.5906435", "0.5894727", "0.58770674", "0.5875932", "0.58726937", "0.58615935", "0.58564353", "0.5853199", "0.58480436", "0.58444256", "0.58444256", "0.5837085", "0.58312464", "0.582908", "0.581481", "0.58111554", "0.5799761", "0.5788609", "0.5784486", "0.57835174", "0.57818496", "0.57797444", "0.57792985", "0.5777007", "0.57740086", "0.57727844", "0.57700443", "0.5768116", "0.5768116", "0.5768116", "0.5768116", "0.5765095", "0.57644504", "0.576249", "0.57560784", "0.5752682", "0.5750253", "0.5745586", "0.57453895", "0.57439023", "0.57438874", "0.5731847", "0.57314575", "0.5723862", "0.57211477" ]
0.6563176
11
GET /birds/1 GET /birds/1.json Return specific bird provided by bird id
def bird_specification @bird = Bird.find(params[:id]) if @bird @bird = JSON.parse(@bird.to_json) @bird["id"]=params[:id] render json: @bird.except("_id"), status: :ok else render :nothing => true, status: :not_found end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bird\n bird = Api::V1::Bird.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n bird: Api::V1::BirdSerializer.new(bird) \n }\n \n end", "def show\n @bird = Bird.find(params[:id])\n end", "def show \n bird = Bird.find_by(id: params[:id])\n if bird \n render bird.json: {id: bird.id, name: bird.name, species: bird.species}\n else \n render {\"Bird not found\"}\n end\nend", "def show\n if @bird\n respond_to do |format|\n format.json { render json: {required: @bird, properties: @bird.properties, families: @bird.families, title: \"POST /birds [request]\", description: \"Get bird by id\",:status => OK }}\n end\n else\n respond_to do |format|\n format.json { render json: {:status => NOT_FOUND} }\n end\n end\n end", "def show\n @bird = Bird.joins(:sightings).find(params[:id])\n if @bird\n render json: {\n \"bird\": @bird,\n \"sightings\": [@bird.sightings]\n }, status: :ok\n else\n render json: @bird.errors, status: :unprocessable_entity\n end\n end", "def show \n bird = Bird.find(params[:id])\n if bird \n render json: bird.slice(:id, :name, :species)\n else \n render json: {message: \"Bird not found\"}\n end\n # {id: bird.id, name: bird.name, species: bird.species}\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def set_bird\n @bird = Bird.find(params[:id])\n end", "def birdspotter\n birdspotter = Api::V1::Birdspotter.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n birdspotter: Api::V1::BirdspotterSerializer.new(birdspotter) \n }\n end", "def set_bird\n @bird = Bird.find(params[:id]) rescue nil\n end", "def display_bird\n bird = ::Bird.data(params[:id])\n if bird.nil?\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"Bird does not Exists\"\n error.validation_errors = \"Invalid Document Id \"\n render status: HttpCodes::NOT_FOUND, json: error.as_json\n else\n render status: HttpCodes::OK, json: bird.extend(BirdRepresenter).to_a.as_json\n end\n end", "def index\n @birds = Bird.all\n end", "def index\n @birds = Bird.all\n end", "def index\n @birds = Bird.where(visible: true)\n render json: @birds, status: 200\n end", "def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def show\n bird = Bird.find_by(id: params[:id]) #if the bird is not found bird is assigned nil value this is falsey \n if bird\n render json: bird, except: [:created_at, :updated_at] \n else\n render json: { message: 'Bird not found' }\n end\nend", "def birds\n @birds = Api::V1::Bird.all\n @serializer = ActiveModel::ArraySerializer\n\n #if regularity is not defined get all birds\n if params[:regularity].blank?\n render json: {\n status: 200,\n message: \"OK\",\n totalCount: @birds.count,\n birds: @serializer.new(@birds, each_serializer: Api::V1::BirdSerializer) \n }\n \n \n #if regularity is defined get birds based on regularity\n else\n @regularity = params[:regularity].split(\",\")\n @birds = @birds.where(regularity: @regularity)\n render json: \n { \n status: 200,\n message: \"OK\",\n totalCount: @birds.count,\n birds: @serializer.new(@birds, each_serializer: Api::V1::BirdSerializer) \n }\n end\n end", "def show\n if [email protected]?\n render json: @bird\n else\n render json: \"\", status: 404\n end\n end", "def birds_list\n birds = ::Bird.all\n render status: HttpCodes::OK,json: birds.extend(BirdRepresenter).to_a.as_json unless birds.empty?\n render status: HttpCodes::OK,json: {} if birds.empty?\n end", "def show \n bird = Bird.find_by(id: params[:id])\n # render json: {id: bird.id, name: bird.name, species: bird.species} \n #* could also use slice\n # render json: bird.slice(:id,:name:species)\n #* better option to be specific\n # render json: bird, only: [:id,:name,:species]\n #* alternatively can choose to exluse\n render json: bird, except: [:created_at, :updated_at] \n # this is how it looked behind the scenes: render json: birds.to_json(except: [:created_at, :updated_at])\nend", "def get_bike(bikeID, userID)\n user = User.find_by(id: userID)\n authorize_time_check(user)\n response = RestClient.get('https://www.strava.com/api/v3/gear/'+bikeID, {Authorization: 'Bearer ' + user.access_token})\n bike = JSON.parse(response)\n end", "def remove\n @bird = Bird.find(params[:id])\n if @bird\n @bird.destroy\n render :nothing => true, status: :ok\n else\n render :nothing => true, status: :not_found\n end\n end", "def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end", "def get_beer\n beer_id = params['id'];\n response = HTTP.get('http://api.brewerydb.com/v2/beer/' + beer_id,\n :params=> {\n :key => ENV[\"BREWERYDB_BEERRATER_KEY\"],\n :withBreweries => \"y\"\n }\n )\n\n body = response.parse\n\n # check for success\n if body[\"status\"] == \"success\"\n data = body[\"data\"]\n unless data.nil?\n render json: {\n status: 200,\n message: \"#{params['id']} found\",\n data: data}\n else\n render json: {\n status: 200,\n message: \"#{params['id']} not found\",\n data: []\n }\n end\n else\n render json: { status: 401, message: body[\"errorMessage\"]}\n end\n end", "def get_blast(blast_id)\n self.api_get(:blast, {:blast_id => blast_id.to_s})\n end", "def show\n @breed = Breed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @breed }\n end\n end", "def show\n @bike = Bike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bike }\n end\n end", "def test_show_success\n get \"api/v1/birds/#{@bird.id.to_s}\"\n assert_equal true, json.present?\n assert_equal \"blue\", json[\"title\"]\n assert_equal \"String\", json[\"type\"]\n assert_equal \"testing description\", json[\"description\"]\n end", "def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end", "def add_bird\n bird_obj = bird_params\n continent = params['continents']\n unless continent.nil?\n continent = continent.split(',').map { |v| v.strip } if continent.is_a?(String)\n if continent.is_a?(Array) && !continent.blank?\n continent = continent[0].split(',').map { |v| v.strip } if continent.size==1\n end\n else\n continent =[]\n end\n bird_obj['continents'] = continent\n bird = ::Bird.new(bird_obj)\n begin\n bird.save!\n bird_obj = ::Bird.data(bird.id)\n render status: HttpCodes::CREATED, json: bird_obj.extend(BirdRepresenter).to_a.as_json\n rescue Mongoid::Errors::Validations\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"#{bird.errors.full_messages.join(\";\")}\"\n error.validation_errors = bird.errors.to_hash\n render status: HttpCodes::BAD_REQUEST, json: error.as_json\n rescue Exception => e\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"#{e.class} #{e.message}\\n #{e.backtrace}\"\n render status: HttpCodes::BAD_REQUEST, json: error.as_json\n end\n end", "def remove_bird\n bird = ::Bird.find(params[:id])\n if bird.nil?\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"Bird does not nound\"\n error.validation_errors = \"Invalid Bird Id \"\n render status: HttpCodes::NOT_FOUND, json: error.as_json\n else\n bird.destroy\n render status: HttpCodes::OK ,json: \"OK\".to_json\n end\n end", "def create\n @bird = Bird.new(bird_params)\n if @bird.save\n render json: @bird, status: :created, location: @bird\n else\n render json: @bird.errors, status: :unprocessable_entity\n end\n end", "def create\n @bird = Bird.new(bird_params)\n if @bird.save\n render json: @bird, status: :created\n else\n render json: @bird.errors, status: :unprocessable_entity\n end\n end", "def set_bunny\n @bunny = Bunny.find(params[:id])\n end", "def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end", "def update\n if @bird.update(bird_params)\n render json: @bird, status: :ok, location: @bird\n else\n render json: @bird.errors, status: :unprocessable_entity\n end\n end", "def create\n @bird = Bird.new(bird_params)\n\n respond_to do |format|\n if @bird.save\n format.html { redirect_to @bird, notice: 'Bird was successfully created.' }\n format.json { render :show, status: :created, location: @bird }\n else\n format.html { render :new }\n format.json { render json: @bird.errors, status: :unprocessable_entity }\n end\n end\n end", "def by_id\n get_brewery\n end", "def search_breed\n name = params[:name]\n render :json => Breed.find_breed_by_substr(name)\n end", "def create\n begin\n respond_to do |format|\n if @bird.save(bird_params)\n format.json { render json: {items: @birds, properties: @bird.properties, families: @bird.families, description: \"Add a new bird to the library\",:status => CREATED} }\n else\n format.json { render json: @bird.errors, :status => NOT_FOUND }\n end\n end\n else\n render json:({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def show\n #@item = Bid.find(params[:auction_uniq_id])\n\n @bid = Bid.all\n @item = Item.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bid }\n end\n end", "def show\n @boat = Boat.find(params[:id])\n @dockyard_spot = DockyardSpot.find_by_boat_id(@boat.id)\n @dockyard = Dockyard.find(@dockyard_spot.dockyard_id) unless @dockyard_spot.nil?\n @berth = Berth.where(:boat_id => @boat.id).first\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boat }\n end\n end", "def show\n @breeding_pair = BreedingPair.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @breeding_pair }\n end\n end", "def show\n @blast = Blast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blast }\n end\n end", "def show\n @baby_pic = BabyPic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baby_pic }\n end\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\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 @boy = Boy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boy }\n end\n end", "def show\n @boy = Boy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boy }\n end\n end", "def show\n dog = Dog.find(params[:id])\n render json: dog\n end", "def get_artist(id)\n @connection.get \"artists/#{id}\"\n end", "def update\n respond_to do |format|\n if @bird.update(bird_params)\n format.html { redirect_to @bird, notice: 'Bird was successfully updated.' }\n format.json { render :show, status: :ok, location: @bird }\n else\n format.html { render :edit }\n format.json { render json: @bird.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bird.update(bird_params)\n format.html { redirect_to @bird, notice: 'Bird was successfully updated.' }\n format.json { render :show, status: :ok, location: @bird }\n else\n format.html { render :edit }\n format.json { render json: @bird.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n birds = Bird.all\n render json: birds.to_json(except: [:created_at, :updated_at])\n end", "def find id\n DynamicModel.new perform_request api_url \"summoners/#{id}\"\n end", "def index\n @breeds = Breed.all\n\n render json: @breeds\n end", "def create\n begin\n @bird = Bird.new(bird_params)\n @bird.visible = false if @bird.visible.nil?\n @bird.added = Date.today\n @bird.continents = bird_params[:continents].uniq\n if @bird.save\n render json: @bird, status: :created, location: @bird\n else\n render json: @bird.errors, status: 400\n end\n rescue Exception => e\n render json: \"\", status: 400\n end\n end", "def show\n @bike = Bike.find(params[:id])\n end", "def index\n @breeds = Breed.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @breeds }\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 show\n @bdatabase = Bdatabase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bdatabase }\n end\n end", "def create\n #bird name must be present\n if params[:name].blank?\n render json: {\n status: 400,\n message: \"Fågelns namn måste anges.\" \n }\n end\n \n #latin name must be present\n if params[:latin].blank?\n render json: {\n status: 400,\n message: \"Fågelns latinska namn måste anges.\" \n }\n end\n \n #regularity must be present\n if params[:regularity].blank?\n render json: {\n status: 400,\n message: \"Fågelns regularitet måste anges.\" \n }\n end\n \n #check if bird already exists\n if Api::V1::Bird.exists?(:bird_name => params[:name])\n render json: {\n status: 400,\n message: \"Fågeln finns redan\" \n }\n else\n @bird = Api::V1::Bird.create(:bird_name => params[:name], :latin_name => params[:latin], :regularity => params[:regularity])\n render json: {\n status: 201,\n message: \"Fågeln är registrerad och finns nu i listan.\", \n bird: Api::V1::BirdSerializer.new(@bird) \n }\n end\n end", "def show\n @brain = Brain.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brain }\n end\n end", "def show(id:)\n raise 'must provide the id of the railgun' if id.nil?\n cf_get(path: \"/railguns/#{id}\")\n end", "def set_pet_breed\n @pet_breed = PetBreed.find(params[:id])\n end", "def set_pet_breed\n @pet_breed = PetBreed.find(params[:id])\n end", "def show\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rainbow }\n end\n end", "def set_bid\n @bid = @pet.bids.find_by!(number: params[:id])\n end", "def by_id\n get_beer\n end", "def show\n respond_to do | format |\n format.html #show.html.erb\n format.json { render json: @pet_breed }\n end\n end", "def bird_params\n params.require(:bird).permit(:name, :species, :origin)\n end", "def show\n @photo = @allbum.photos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end", "def show\n animal_id = params[:id]\n # Find that animal (by id) in the database\n @animal = Animal.find(animal_id)\n \n #Give back JSON details of that animal\n render json: @animal\n end", "def index\n @bids = Bid.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bids }\n end\n end", "def show\n mix = BreedMix.find(params[:id])\n render json: mix\n end", "def get_book( book_id )\n response = if book_id.to_s.length >= 10\n Amazon::Ecs.item_lookup( book_id, :id_type => 'ISBN', :search_index => 'Books', \n :response_group => 'Large,Reviews,Similarities,AlternateVersions' )\n else\n Amazon::Ecs.item_lookup( book_id, :response_group => 'Large,Reviews,Similarities' )\n end\n response.items.each do |item|\n binding = item.get('ItemAttributes/Binding')\n next if binding.match(/Kindle/i)\n return Book.new( item )\n end\n return nil\n end", "def show\n @broad = Broad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @broad }\n end\n end", "def show\n bike = Bike.find(params[:id]);\n render json: {status: 'SUCCESS', message:'Loaded bike', data:bike}, status: :ok\n end", "def show\n @album = Album.where(id: params[:id]).first\n if @album\n render json: @album, status: 200\n else\n return_not_found \n end\n end", "def show\n @baggage = Baggage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baggage }\n end\n end", "def show\n params.require(%i[id])\n render json: Beverage.find_by!(id: params[:id])\n end", "def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end", "def show\n @borad = Borad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @borad }\n end\n end", "def show\n @photo_booth = PhotoBooth.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo_booth }\n end\n end", "def birds\n nests.map do |nest|\n nest.bird.species\n end\n end", "def find_bikes\n user_id = params[\"user_id\"]\n bike_ids = get_bike_ids(user_id)\n bikes = []\n bike_ids.each {|bike_id|\n bikes.push(get_bike(bike_id, user_id))\n }\n update_bike_database(bikes, user_id)\n render json: { new_bikes: bikes }\n end", "def show\n @brewery = Brewery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brewery }\n end\n end", "def show\n render(:json => Burn.find(params[:id]).as_json)\n rescue ActiveRecord::RecordNotFound\n render(:json => {error: \"no burn with that id found}\"}, :status => 404)\n end", "def get_book( book_id )\n response = if book_id.to_s.length >= 10\n Amazon::Ecs.item_lookup( book_id, :id_type => 'ISBN', :search_index => 'Books', :response_group => 'Large,Reviews,Similarities' )\n else\n Amazon::Ecs.item_lookup( book_id, :response_group => 'Large,Reviews,Similarities' )\n end\n response.items.each do |item|\n binding = item.get('ItemAttributes/Binding')\n next if binding.match(/Kindle/i)\n return parse_item( item )\n end\n end", "def get_batterie_by_building\n @battery = Battery.where(building_id: params[:building_id])\n respond_to do |format| \n format.json { render :json => @battery }\n end\n \n end", "def battery_select\n p params[\"building_id\"]\n @batteries = Battery.where(building_id: params[\"building_id\"])\n respond_to do |format |\n format.json {\n render json: {\n batteries: @batteries\n }\n }\n end\n end", "def show\n @bob = Bob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bob }\n end\n end", "def show\n @herb = Herb.find_by_permalink(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @herb }\n end\n end", "def find_album_by_id(client, album_id)\n client.api(:album, :show, album_id)\nend", "def show\n @brewhouse = Brewhouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brewhouse }\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 bird_params\n params.require(:bird).permit(:name, :family, :continents, :visible, :uniqueitem)\n end" ]
[ "0.7842902", "0.75328666", "0.7532793", "0.73402125", "0.72267026", "0.71068805", "0.70877093", "0.69594675", "0.69594675", "0.69594675", "0.6863208", "0.6838396", "0.67940015", "0.6771479", "0.6771479", "0.6751278", "0.6612028", "0.6603761", "0.64625204", "0.64274997", "0.63626057", "0.6324306", "0.6136274", "0.6134033", "0.6133538", "0.61333466", "0.6081602", "0.6065798", "0.60050076", "0.6000911", "0.5991538", "0.5986212", "0.5971978", "0.5950107", "0.5923976", "0.5909381", "0.58978856", "0.5879679", "0.5860887", "0.583369", "0.58255833", "0.5820556", "0.581362", "0.5810724", "0.5804362", "0.57968545", "0.5758828", "0.57457674", "0.573867", "0.5727775", "0.57228625", "0.57228625", "0.5717982", "0.5702187", "0.56952906", "0.5695143", "0.5686848", "0.5681519", "0.56776935", "0.56699854", "0.5658434", "0.56565654", "0.5647287", "0.5634084", "0.5633089", "0.56328714", "0.5607046", "0.5591632", "0.5591632", "0.5589246", "0.5588269", "0.557173", "0.5570707", "0.55624837", "0.55603725", "0.5557659", "0.5556275", "0.5555791", "0.55552244", "0.5552832", "0.5550964", "0.55456215", "0.5541971", "0.55324435", "0.5531728", "0.55297744", "0.552066", "0.5506897", "0.5506636", "0.5504945", "0.5501306", "0.5492537", "0.54887426", "0.5479775", "0.5478045", "0.54761934", "0.5469952", "0.5467669", "0.54644996", "0.5461228" ]
0.7864114
0
DELETE /birds/1 DELETE /birds/1.json
def remove @bird = Bird.find(params[:id]) if @bird @bird.destroy render :nothing => true, status: :ok else render :nothing => true, status: :not_found end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @bird.destroy\n respond_to do |format|\n format.html { redirect_to birds_url, notice: 'Bird was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bird.destroy\n \n begin\n respond_to do |format|\n format.json { render json:({:status => NO_CONTENT}) }\n end\n else\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def remove_bird\n bird = ::Bird.find(params[:id])\n if bird.nil?\n error = Error.new.extend(ErrorRepresenter)\n error.message = \"Bird does not nound\"\n error.validation_errors = \"Invalid Bird Id \"\n render status: HttpCodes::NOT_FOUND, json: error.as_json\n else\n bird.destroy\n render status: HttpCodes::OK ,json: \"OK\".to_json\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @bird.destroy\n head :no_content\n end", "def destroy\n if [email protected]?\n @bird.destroy\n render json: \"\", status: 200\n else\n render json: \"\", status: 404\n end\n end", "def delete_one()\n #connect to db\n db = PG.connect({ dbname: \"bounty_hunters\", host: \"localhost\" })\n #write SQL statement string\n sql = \"DELETE FROM bounties WHERE id = $1\"\n #make values array - in this case it only needs one value\n values = [@id]\n #prepare statemnt\n db.prepare(\"delete_one\", sql)\n #run prepared statement\n db.exec_prepared(\"delete_one\", values)\n #close db link\n db.close()\n end", "def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bunny.destroy\n respond_to do |format|\n format.html { redirect_to bunnies_url }\n format.json { head :no_content }\n end\n end", "def delete()\n sql = \"DELETE FROM albums\n WHERE id = $1;\"\n values = [@id]\n SqlRunner.run( sql, values )\n end", "def delete\n sql = \"DELETE FROM albums WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend", "def destroy\n @brag = Brag.find(params[:id])\n @brag.destroy\n\n respond_to do |format|\n format.html { redirect_to brags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bird.destroy\n respond_to do |format|\n format.html { redirect_to birds_url, notice: \"Bird was successfully destroyed.\" }\n end\n end", "def destroy\n @bdatabase = Bdatabase.find(params[:id])\n @bdatabase.destroy\n\n respond_to do |format|\n format.html { redirect_to bdatabases_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 @bowl = Bowl.find(params[:id])\n @bowl.destroy\n\n respond_to do |format|\n format.html { redirect_to bowls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @boy = Boy.find(params[:id])\n @boy.destroy\n\n respond_to do |format|\n format.html { redirect_to boys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @boy = Boy.find(params[:id])\n @boy.destroy\n\n respond_to do |format|\n format.html { redirect_to boys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bread.destroy\n respond_to do |format|\n format.html { redirect_to breads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @brave_burst.destroy\n respond_to do |format|\n format.html { redirect_to brave_bursts_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()\n db = PG connect( {dbname: 'bounty_hunter',\n host: 'localhost'\n })\n sql = 'DELETE from bounty_hunter'\n db.prepare('delete_one', sql)\n db.exec_prepared('delete_one', value)\n db.close()\nend", "def destroy\n @bob = Bob.find(params[:id])\n @bob.destroy\n\n respond_to do |format|\n format.html { redirect_to bobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to bounties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @blast = Blast.find(params[:id])\n @blast.destroy\n\n respond_to do |format|\n format.html { redirect_to blasts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @barrack = Barrack.find(params[:id])\n @barrack.destroy\n\n respond_to do |format|\n format.html { redirect_to barracks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @boat = Boat.find(params[:id])\n remove_reknro_from_berth\n @boat.destroy\n\n respond_to do |format|\n format.html { redirect_to boats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bid = Bid.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to bids_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bid = Bid.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to bids_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @basin = Basin.find(params[:id])\n @basin.destroy\n\n respond_to do |format|\n format.html { redirect_to basins_url }\n format.json { head :no_content }\n end\n end", "def delete() #DELETE film1.delete (removes 1 film)\n sql = \"DELETE FROM films WHERE id = $1;\"\n values = [@id]\n SqlRunner.run(sql, values)\n end", "def destroy\n @breed = Breed.find(params[:id])\n @breed.destroy\n\n respond_to do |format|\n format.html { redirect_to breeds_url }\n format.json { head :ok }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @bl = Bl.find(params[:id])\n @bl.destroy\n\n respond_to do |format|\n format.html { redirect_to bls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bike = Bike.find(params[:id])\n @bike.destroy\n\n respond_to do |format|\n format.html { redirect_to bikes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bowl = Bowl.find(params[:id])\n @bowl.destroy\n\n respond_to do |format|\n format.html { redirect_to(bowls_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @broad = Broad.find(params[:id])\n @broad.destroy\n\n respond_to do |format|\n format.html { redirect_to broads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @blar.destroy\n respond_to do |format|\n format.html { redirect_to blars_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bloom = Bloom.find(params[:id])\n @bloom.destroy\n\n respond_to do |format|\n format.html { redirect_to blooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @brain = Brain.find(params[:id])\n @brain.destroy\n\n respond_to do |format|\n format.html { redirect_to brains_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @borad = Borad.find(params[:id])\n @borad.destroy\n\n respond_to do |format|\n format.html { redirect_to borads_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def pet_delete(pet)\n @db.delete(\"pets\", pet[\"id\"])\n end", "def delete\n render json: Like.delete(params[\"id\"])\n end", "def destroy\n set_boat\n @boat.destroy\n respond_to do |format|\n format.html { redirect_to harbour_boats_path}\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @burpy.destroy\n respond_to do |format|\n format.html { redirect_to burpies_url, notice: 'Burpy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bb = Bb.find(params[:id])\n @bb.destroy\n\n respond_to do |format|\n format.html { redirect_to bbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @brewhouse = Brewhouse.find(params[:id])\n @brewhouse.destroy\n\n respond_to do |format|\n format.html { redirect_to brewhouses_url }\n format.json { head :no_content }\n end\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def destroy\n @bacon.destroy\n respond_to do |format|\n format.html { redirect_to bacons_url }\n format.json { head :no_content }\n end\n end", "def bucket_delete_object(key)\n http.delete(\"/#{key}\", bucket: bucket, key: key)\n end", "def destroy\n @brew.destroy\n respond_to do |format|\n format.html { redirect_to brews_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @brony.destroy\n respond_to do |format|\n format.html { redirect_to bronies_url, notice: 'Brony was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @boat.destroy\n\n head :no_content\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\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 destroy\n @blivot.destroy\n respond_to do |format|\n format.html { redirect_to blivots_url, notice: 'Blivot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sugar_bag = SugarBag.find(params[:id])\n @sugar_bag.destroy\n\n respond_to do |format|\n format.html { redirect_to sugar_bags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n\n respond_to do |format|\n format.html {redirect_to boats_url}\n format.json {head :no_content}\n end\n end", "def destroy\n @bath.destroy\n respond_to do |format|\n format.html { redirect_to baths_url, notice: 'Bath was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @borc = Borc.find(params[:id])\n @borc.destroy\n\n respond_to do |format|\n format.html { redirect_to borcs_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 delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n @sound_bite.destroy\n respond_to do |format|\n format.html { redirect_to sound_bites_url, notice: 'Sound bite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rainbow = Rainbow.find(params[:id])\n @rainbow.destroy\n\n respond_to do |format|\n format.html { redirect_to rainbows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n BuzzTag.where(:buzz_id => params[:buzz_id], :tag_id => params[:tag_id]).first.destroy\n end", "def destroy\n @baggage = Baggage.find(params[:id])\n @baggage.destroy\n\n respond_to do |format|\n format.html { redirect_to baggages_url }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to auction_bids_url(@auction) }\n format.json { head :no_content }\n end\n end", "def destroy\n @baby_pic = BabyPic.find(params[:id])\n @baby_pic.destroy\n\n respond_to do |format|\n format.html { redirect_to baby_pics_url }\n format.json { head :no_content }\n end\n end", "def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end", "def delete() # EXTENSION\n sql = \"DELETE FROM films WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend", "def destroy\n @boredom.destroy\n respond_to do |format|\n format.html { redirect_to boredoms_url, notice: 'Boredom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dog = Dog::Dog.find(params[:id])\n @dog.destroy\n\n respond_to do |format|\n format.html { redirect_to dog_dogs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @Bouquets = Bouquet.find(params[:id])\n @Bouquets.destroy\n\n respond_to do |format|\n format.html { redirect_to bouquets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @go_slim = GoSlim.find(params[:id])\n @go_slim.destroy\n\n respond_to do |format|\n format.html { redirect_to go_slims_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bet = Bet.find(params[:id])\n @bet.destroy\n\n respond_to do |format|\n format.html { redirect_to bets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bet = Bet.find(params[:id])\n @bet.destroy\n\n respond_to do |format|\n format.html { redirect_to bets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @b = B.find(params[:id])\n @b.destroy\n\n respond_to do |format|\n format.html { redirect_to bs_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 @boat.destroy\n respond_to do |format|\n format.html { redirect_to boats_url, notice: 'Boat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.6887387", "0.68635166", "0.6820788", "0.6808459", "0.680432", "0.6740291", "0.6725452", "0.66929066", "0.6681796", "0.6652052", "0.66318506", "0.66247386", "0.6568351", "0.6554738", "0.6544394", "0.6531139", "0.6516086", "0.6516086", "0.6512393", "0.6499316", "0.64837694", "0.6455121", "0.6451036", "0.645037", "0.6436925", "0.6436209", "0.64355266", "0.6427148", "0.6418446", "0.641058", "0.6407651", "0.6399479", "0.6399479", "0.63987875", "0.6389951", "0.6386636", "0.637891", "0.63701975", "0.6354277", "0.6352192", "0.63476896", "0.633217", "0.6329217", "0.6328396", "0.63191193", "0.63164425", "0.63094443", "0.63056284", "0.63056284", "0.63056284", "0.63056284", "0.63043237", "0.6301992", "0.6294836", "0.6288913", "0.62870413", "0.6283201", "0.6283006", "0.62792486", "0.6276354", "0.62718207", "0.6270324", "0.6262577", "0.625819", "0.62555647", "0.6254003", "0.62426096", "0.62313384", "0.6227539", "0.6226539", "0.62264454", "0.6224918", "0.6224316", "0.62235516", "0.6222712", "0.6222322", "0.6222322", "0.6219168", "0.62152416", "0.6214701", "0.62129647", "0.6204477", "0.6201713", "0.61890274", "0.61852324", "0.61850834", "0.61788183", "0.6177727", "0.6177534", "0.61766875", "0.617077", "0.6167462", "0.6165288", "0.6163368", "0.6162834", "0.61592674", "0.61592674", "0.6158614", "0.61549443", "0.6153975" ]
0.67570484
5
Never trust parameters from the scary internet, only allow the white list through.
def bird_params params.require(:name) params.require(:family) params.require(:continents) params.permit(:name, :family , :added, :visible, :continents => []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def valid_params_request?; end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def backend_user_params\n params.permit!\n end", "def url_params\n params[:url].permit(:full)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6981273", "0.6783789", "0.67460483", "0.6742222", "0.67354137", "0.65934366", "0.65028495", "0.6497783", "0.64826745", "0.6479415", "0.6456823", "0.6440081", "0.63800216", "0.6376521", "0.636652", "0.6319898", "0.6300256", "0.62994003", "0.6293621", "0.6292629", "0.6291586", "0.629103", "0.6282451", "0.6243152", "0.62413", "0.6219024", "0.6213724", "0.62103724", "0.61945", "0.61786324", "0.61755824", "0.6173267", "0.6163613", "0.6153058", "0.61521065", "0.6147508", "0.61234015", "0.61168665", "0.6107466", "0.6106177", "0.6091159", "0.60817343", "0.6071238", "0.6062299", "0.6021663", "0.60182893", "0.6014239", "0.6011563", "0.60080767", "0.60080767", "0.60028875", "0.60005623", "0.59964156", "0.5993086", "0.5992319", "0.5992299", "0.59801805", "0.59676576", "0.59606016", "0.595966", "0.59591126", "0.59589803", "0.5954058", "0.5953234", "0.5944434", "0.5940526", "0.59376484", "0.59376484", "0.5935253", "0.5930846", "0.5926387", "0.59256274", "0.5917907", "0.5910841", "0.590886", "0.59086543", "0.59060425", "0.58981544", "0.5898102", "0.5896809", "0.5895416", "0.58947027", "0.58923644", "0.5887903", "0.58830196", "0.5880581", "0.5873854", "0.58697754", "0.5869004", "0.58669055", "0.5866886", "0.58664906", "0.5864619", "0.58630043", "0.5862495", "0.5861368", "0.5859712", "0.5855544", "0.58551925", "0.5851284", "0.5850602" ]
0.0
-1
If a chunk represents an integer such as the sum of the cubes of its digits is divisible by 2, reverse that chunk; otherwise rotate it to the left by one position. Put together these modified chunks and return the result as a string. If sz is ) than the length of str it is impossible to take a chunk of size sz hence return "". Examples: revrot("123456987654", 6) > "234561876549" revrot("123456987653", 6) > "234561356789" revrot("66443875", 4) > "44668753" revrot("66443875", 8) > "64438756" revrot("664438769", 8) > "67834466" revrot("123456779", 8) > "23456771" revrot("", 8) > "" revrot("123456779", 0) > "" revrot("563000655734469485", 4) > "0365065073456944"
def divisible_by_two?(num_str) num_str.split("").reduce(0) {|sum, num| sum += num.to_i * num.to_i } % 2 == 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def revrot(str, sz)\r\n\r\n if str.empty? || sz <= 0 || sz > str.length\r\n \"\"\r\n else\r\n\r\n chunk_array = str.scan(/.{#{sz}}/)\r\n\r\n chunk_array.map do |chunk|\r\n split_chunk = chunk.split('')\r\n chunk_cubed = split_chunk.map { |d| (d.to_i)**3 }\r\n chunk_sum = chunk_cubed.reduce(:+)\r\n\r\n if chunk_sum % 2 == 0\r\n chunk.reverse\r\n else\r\n split_chunk.rotate\r\n end\r\n\r\n end.join('')\r\n end\r\nend", "def revrot(str, sz)\n return \"\" if sz > str.length || sz <= 0 || str.length < 1\n\n chunk_arr = []\n transformed_chunks = []\n\n input_str_arr = str.chars\n\n until input_str_arr.length < sz\n chunk_arr << input_str_arr.shift(sz)\n end\n \n chunk_arr.each do |subarray|\n cube_arr = []\n subarray.each do |digit|\n cube_arr << digit.to_i ** 3\n end\n \n if cube_arr.sum % 2 == 0\n transformed_chunks << subarray.reverse\n else\n subarray.push(subarray.shift)\n transformed_chunks << subarray\n end\n \n end\n transformed_chunks.flatten.join('')\nend", "def revrot(str, sz)\n return '' if sz <= 0\n chunks = str.scan(/.{#{sz}}/)\n chunks.map do |chunk|\n digits = chunk.chars\n sum = digits.map { |x| x.to_i ** 3 }.inject(:+)\n sum.even? ? digits.reverse : digits.rotate\n end.join\nend", "def revrot(str, sz)\n return \"\" if sz == 0 || sz > str.length\n out = \"\"\n str.split(\"\").each_slice(sz).to_a.each do |i|\n return out if i.length < sz\n if i.reduce(0){ |sum,e| sum + (e.to_i)**3 } % 2 == 0 \n out += i.reverse!.join\n else\n out += i.rotate!.join\n end\n end\n out\nend", "def revrot(str, sz)\n return '' if sz <= 0\n # 文字数を指定して、文字列を分割する\n chunks = str.scan(/.{#{sz}}/)\n # 分割した文字列ごとに各数値の3乗の合計を計算し、偶数か奇数を判定する\n chunks.map do |chunk|\n digits = chunk.chars\n sum = digits.map {|x| x.to_i ** 3 }.inject(:+)\n sum.even? ? digits.reverse : digits.rotate\n end.join\nend", "def max_rotation int\n final_string = ''\n string_digits = int.to_s.chars\n loop do\n string_digits = rotate_arr(string_digits)\n final_string << string_digits.shift\n break if string_digits.size < 1\n end\n final_string.to_i\nend", "def rotate_str(str)\n str[1..-1] << str[0]\nend", "def max_rotation(int)\n arr = int.to_s.chars\n\n arr.length.times do |i|\n arr << arr[i]\n arr.delete_at(i)\n end\n arr.join(\"\").to_i\nend", "def max_rot(n)\n result = n\n n = n.to_s.chars\n len = n.length - 1\n n.each.with_index do |_value, i|\n n.push(n[i])\n n.delete_at(i)\n temp = n.join('').to_i\n if temp > result\n result = temp\n elsif i == len\n puts result\n return result\n end\n end\nend", "def BinaryReversal(str)\n binary = str.to_i.to_s(2)\n pad_size = binary.size % 8 == 0 ? binary.size : (8 - binary.size % 8) + binary.size\n format(\"%0#{pad_size}d\", binary).reverse.to_i(2).to_s\nend", "def rotate_rightmost_digits(number, slice)\n digits = number.to_s.chars\n digits[-slice..-1] = rotate_array(digits[-slice..-1])\n digits.join.to_i\nend", "def max_rotation(int)\n arr_size = int.digits.size\n max_rotations = arr_size - 1\n counter = 0\n while counter < max_rotations\n position = arr_size - counter\n int = rotate_rightmost_digits(int, position)\n counter += 1\n end\n int\nend", "def rotations(num)\n output = [num]\n digits = num.to_s.chars\n x = digits.count - 1\n x.times do\n first = digits.shift\n rotation = digits.push(first).join(\"\").to_i\n output << rotation\n end\n output\nend", "def rotate_string(str)\n rotate_array(str.chars).join\nend", "def rotate_string(str)\n rotate_array(str.chars).join\nend", "def rotate_string(str)\n rotate_array(str.chars).join\nend", "def rotate_string(string)\n if string.size > 1\n rotate_array(string.chars).join\n else\n string\n end\nend", "def rotate_string(str)\n arr = str.chars\n rotate_array(arr).join\nend", "def max_rot(n)\n count = n.to_s.chars.count\n i = 0\n arr = []\n arr.push(n)\n \n until i == count - 1\n n = n.to_s.chars\n n = (n[0...i] + n[i..-1].rotate).join.to_i\n arr.push(n)\n i += 1\n end\n \n arr.max\nend", "def max_rotation(num)\n arr = num.to_s.split(\"\")\n first_rotation = arr[1..-1] + [arr[0]]\n result = first_rotation\n if arr.size == 1\n return num\n elsif arr.size == 2\n return first_rotation.join.to_i\n else\n rotation_times = first_rotation.size - 2\n\n 1.upto(rotation_times) do |i|\n rotating_digit = result.delete_at(i)\n result.push(rotating_digit)\n end\n end\n return result.join.to_i\nend", "def rotate_rightmost_digits(num, n)\n num = num.digits.reverse\n rotators = num.pop(n)\n result = num + rotate_array(rotators)\n result.join.to_i\nend", "def rotate_rightmost_digits(num, n)\n arr = num.to_s.chars\n arr[-n..-1] = arr[-n..-1].rotate\n arr.join.to_i\nend", "def max_rotation(number)\n number_digits = number.to_s.length\n number = number.to_s.chars\n\n number_digits.times do |n|\n number[n-1..number_digits] = rotate_array(number[n-1..number_digits])\n end\n\n number.join('').to_i\nend", "def rotate_integer(integer)\n integer.to_s.chars.rotate.join.to_i\nend", "def rotate_string(string)\n string[1..-1] + string[0]\nend", "def rotate_string(string)\n string[1..-1] + string[0]\nend", "def rotate_rightmost_digits(number, n)\n number_array = number.to_s.chars\n number_array[-n..-1] = rotate_array(number_array[-n..-1])\n number_array.join.to_i\nend", "def rotate_rightmost_digits(int, position)\n int_arr = int.digits.reverse\n shifting = int_arr.pop(position)\n int_arr.concat(rotate_array(shifting)).join.to_i\nend", "def rotate_rightmost_digits(int, r)\n arr = int.to_s.chars\n remove = arr.delete_at(-r)\n arr << remove\n arr.join.to_i\nend", "def rotate_integer(integer)\n string = integer.to_s\n integer = rotate_string(string)\n integer.join.to_i # 'join' to join integers and to_i to convert string to int.\nend", "def max_rotation(number)\n num_length = number.to_s.length\n\n while num_length > 0\n number = rotate_rightmost_digits(number, num_length)\n num_length -= 1\n end\n\n number\nend", "def max_rotation(num)\n digits = num.to_s.chars\n\n (digits.length - 1).times do |idx|\n digits << digits.delete_at(idx)\n end\n\n digits.join.to_i\nend", "def rotate_rightmost_digits(number, position)\n num_array = number.to_s.chars\n remainder_digits = num_array.delete_at(-position) # delete_at is a mutating method - original object changes\n num_array << remainder_digits\n num_array.join.to_i\nend", "def max_rotation(num)\n arr_num = num.digits.reverse\n arr_size = arr_num.size\n counter = 0\n while counter < arr_size - 1\n curr = arr_num[counter]\n arr_num.delete_at(counter)\n arr_num << curr\n counter += 1\n end\n arr_num.join.to_i\nend", "def rotate_rightmost_digits(number, n)\nall_digits = number.to_s.chars\nall_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nall_digits.join.to_i\nend", "def rotate_string(string)\n arr = string.chars\n str = rotate_array(arr).join\nend", "def reverse_string_3(string)\n string = string.to_s\n result = ''\n string.length.times { |i| result << string[(i + 1) * -1] }\n result\nend", "def rotate_rightmost_digits(number, n)\np all_digits = number.to_s.chars\n# all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nend", "def max_rotation(int)\n int_digits = int.to_s.length\n rotation_iterations = int_digits - 1\n rotated_number = int\n rotation_iterations.times { |iteration| rotated_number = rotate_rightmost_digits(rotated_number, int_digits - iteration) }\n rotated_number\nend", "def rotate_integer(int)\r\n ans = int.to_s[1..-1] << int.to_s[0]\r\n ans.to_i\r\nend", "def max_rotation(num)\n number_string = num.to_s\n\n number_string.size.downto(2) do |i|\n num = rotate_rightmost_digits(num, i)\n end\n num\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_rightmost_digits(integer, n)\n ary = integer.digits.reverse\n new_ary = Array.new(ary) # avoid mutating the original argument\n new_ary << new_ary.delete_at(-n)\n new_ary.join('').to_i\nend", "def rotate_rightmost_digits(number, times)\n rotated_number = number.to_s.split('')\n rotated_number[(times * -1)..-1] = rotate_array(rotated_number[times*-1..-1])\n\n rotated_number.join('').to_i\nend", "def to_s\n require 'stringio'\n\n sb = StringIO.new\n each { |block3|\n sb << block3.map { |block4|\n format(\"%0#{1 << BLOCK4}b\", (block4 || 0)).reverse }.join\n }\n\n # At max there will be just 1 block of extra bits\n # So we are cutting at exactly @size\n sb.string[0...@size]\n end", "def rotate_rightmost_digits(number, n)\n all_digits = number.to_s.chars\n all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\n all_digits.join.to_i\nend", "def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n rotate_arr = rotate_array(arr.pop(n))\n (arr + rotate_arr).join.to_i\nend", "def rotate_rightmost_digits(integer, n)\n num_arr = integer.digits.reverse\n new_arr = num_arr[0...-n] << rotate_array(num_arr[-n..-1])\n new_arr.flatten.join.to_i\nend", "def max_rotation(int)\n arr = int.digits.reverse\n arrdup = arr.dup # this code works without reduces whats deleted/pushed in.\n result = []\n arrdup.each.with_index do |_,idx|\n arr << arr[idx]\n arr.delete_at(idx)\n result = arr\n end\n result.join.to_i\nend", "def reverse_str(s, k)\n new_str = \"\"\n current_start_idx = 0\n \n s.each_char.with_index do |char, idx|\n if ((idx + 1) % (2 * k)) == 0\n new_str << s[current_start_idx..current_start_idx + k - 1].reverse\n new_str << s[current_start_idx + k..idx]\n current_start_idx = idx + 1\n end\n end\n new_str << s[current_start_idx..current_start_idx + k - 1].reverse\n remaining_chars = s[current_start_idx + k ..-1]\n new_str << remaining_chars if remaining_chars\n new_str\nend", "def rotate_rightmost_digits(number, num)\n digits = number.to_s.chars.map(&:to_i)\n index_to_rotate = digits.size - num\n digits << digits.delete_at(index_to_rotate)\n p digits.join.to_i\nend", "def rotate_string(word)\n new_word = ''\n new_word << word[1..-1] << word[0]\n new_word\nend", "def rotate3(num)\n length = num.inspect.length\n max_rotate = rotate2(num, length)\n loop do \n length -= 1\n max_rotate = rotate2(max_rotate, length)\n break if length == 0\n end\n max_rotate\nend", "def rotate_string(string)\n arr = string.split(\"\")\n rotate_array(arr).join(\"\")\nend", "def rotate_rightmost_digits(num, n)\n digits = num.to_s.chars\n digits << digits.delete_at(-n)\n digits.join.to_i\nend", "def max_rotation(num)\n arr = num.digits.reverse\n 0.upto(arr.size - 1) do |i|\n sub_arr = arr[i..-1]\n rot_arr = sub_arr[1..-1] + [sub_arr[0]]\n arr[i..-1] = rot_arr\n end\n arr.join.to_i\nend", "def rotate_rightmost_digits(number, rotation_digit)\n new_number = [] # hold new digit order; join; to_i\n counter = 0 # loop through digits as array of strings\n loop do\n # loop through number add all but string at rotation_digit (as number from end)\n unless number.to_s.chars[-rotation_digit].to_i == number.to_s.chars[counter].to_i\n new_number << number.to_s.chars[counter].to_i\n end\n counter += 1\n break if new_number.size == number.to_s.chars.size - 1\n end\n number.to_s.chars.select { |n| new_number << n.to_i if n == number.to_s.chars[-rotation_digit] }\n new_number.join.to_i\nend", "def rotate_rightmost_digits(long_number, n)\n return long_number if n == 1\n arr = long_number.to_s\n (arr[0...-n] + arr[-n+1..-1] + arr[-n]).to_i\nend", "def rotate_rightmost_digits(number, digit)\n string_number = number.to_s\n sliced_num = string_number[-digit]\n string_number.delete!(sliced_num)\n (string_number << sliced_num).to_i\nend", "def rotate_rightmost_digits(num, n)\n [num.to_s[0..-(n+1)],rotate_array(num.to_s[-n..-1])].flatten.join('').to_i\nend", "def rotate_string(string)\n array = string.split('')\n rotate_array(array).join\nend", "def max_rot(n)\n answer = Array.new\n rotation = 1\n index = 0\n answer << n\n loop do\n n = (n.to_s[0, index] + (n.to_s.split(\"\").pop(n.to_s.length - rotation).join) + n.to_s[index]).to_i\n answer << n\n rotation += 1\n index += 1\n if rotation >= n.to_s.length\n break\n end\n end\n return answer.max\nend", "def max_rotation(nums)\n digits = nums.digits.reverse\n n = 0\n digits.size.times do\n rotated_num = digits[n..-1].shift\n digits.delete_at(n)\n digits = digits.push(rotated_num)\n n += 1\n end\n digits.join.to_i\nend", "def max_rotation(num)\n num.to_s.size.downto(2) do |rotators|\n num = rotate_rightmost_digits(num, rotators)\n end\n num\nend", "def reverse(string)\n output = \"\"\n array = string.chars\n string.length.times { output << array.pop } \n output\nend", "def max_rotation(num)\n arr = num.digits.reverse\n arrdup = arr.dup # this code works without reduces whats deleted/pushed in.\n arrdup.each_with_index do |_, idx|\n arr << arr.delete_at(idx) \n end\n arr.join.to_i\nend", "def rotate_string(string)\n return \"\" if string.empty?\n string.chars.rotate # using chars instead of split.\nend", "def rotate_rightmost_digits(num, rotate)\n rotate = rotate * -1\n num_array = num.to_s.split(//)\n rotated_arr = []\n if num_array.length > 1\n num_array.each_index do |index|\n next if num_array[index] == num_array[rotate]\n rotated_arr.push(num_array[index])\n end\n end\n rotated_arr.push(num_array[rotate])\n rotated_arr.join.to_i\nend", "def unrotate(string, positions = 12)\r\n alphabet = Array('A'..'Z')\r\n decrypted = ''\r\n string.split('').each do |char|\r\n i = alphabet.find_index(char)\r\n decrypted += alphabet[(i-positions)%alphabet.size]\r\n end\r\n return decrypted\r\nend", "def rot13(string) #puts (ascii % 90)+64+13 #T-G 84-71\n # binding.pry\n rot = \"\"\n string.length.times do |i|\n ascii = string[i].ord\n if ascii >= 65 && ascii <= 90 then\n if (ascii + 13) > 90\n rot.concat((((ascii+13) % 90)+64).chr)\n else\n rot.concat((ascii+13).chr)\n end\n elsif ascii >= 97 && ascii <= 122\n if (ascii + 13) > 122\n rot.concat((((ascii+13) % 122)+96).chr)\n else\n rot.concat((ascii+13).chr)\n end\n else\n rot << \" \"\n end\n end\n return rot\nend", "def max_rotation(original_num)\ncount = original_num.to_s.size\ncount.downto(2) do |num|\noriginal_num = rotate_rightmost_digits(original_num, num)\nend\noriginal_num\nend", "def rotate_rightmost_digits_alt(number, n)\n digits = number.digits.reverse\n digits[-n..-1] = rotate_array_alt(digits[-n..-1])\n digits.join.to_i\nend", "def max_rot(n)\n count = 1\n n_array = [n]\n n_chars = n.to_s.chars\n while count <= (n_chars.length - 1)\n n_chars.each_with_index do |char, index|\n n_chars.push(n_chars[index])\n n_chars.delete_at(index)\n n_array << n_chars.join.to_i\n count += 1\n end\n end\n return n_array.uniq.max\nend", "def rotations(string)\n #array = string.split(//)\n #array2 = array.map {|element| }\n\n return (0...string.length).map { |i| (string * 2)[i, string.length] }\n\nend", "def max_rotation(int)\n rotated = int\n count = int.digits.size\n\n until count < 2\n rotated = rotate_rightmost_digits(rotated, count)\n count -= 1\n end\n rotated\nend", "def max_rotation(num)\n arr = num.digits.reverse\n 0.upto(num.digits.size - 1) do |idx|\n arr << arr.delete_at(idx)\n end\n arr.join.to_i\nend", "def rev(str, i)\n # str = \"75\", i = -1\n if i < 0 then\n return \"\";\n else\n # return \"5\" + \"7\" + \"\"\n return str[i, 1] + rev(str, i-1);\n end;\nend", "def rotate_string(string)\n return nil if string.empty?\n array = string.split('')\n result = array[1..-1] + [array[0]]\n result.join # to convert array back to 'string'\nend", "def circular_rotations(number)\n rotations = []\n if number.to_s.size == 1\n return rotations\n end\n digits = number.to_s.split(\"\").map { |x| x.to_i }\n (number.to_s.size-1).times {\n digits << digits.shift\n rotations << digits.to_s.to_i\n }\n return rotations\nend", "def rotate_rightmost_digits(num, digits)\n left, right = num.divmod(10**digits)\n [[left], rotate_array(right.to_s.chars)].join.to_i\nend", "def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n number = arr.delete_at(-n)\n arr.append(number).join.to_i\nend", "def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n number = arr.delete_at(-n)\n arr.append(number).join.to_i\nend", "def perm_recur(ans=\"\",s)\n if s.length == 0\n return\n end\n\n if s.length == 1\n puts ans + s\n return\n end\n \n if s.length == 2\n puts ans + s[0] + s[1] \n puts ans + s[1] + s[0]\n return\n end\n\n (0..s.size-1).each do |l|\n new = s.chars.rotate(l).join('')\n element = new[0] \n rest = new[1..new.size-1]\n perm_recur(ans + element, rest)\n end\nend", "def rotate_rightmost_digits(number, n)\n arr = number.digits.reverse\n e = arr.delete_at(-n)\n arr << e\n arr.join.to_i\nend", "def rotate_rightmost_digits(array, n)\n input_array = array.to_s.chars\n start_index = input_array.length - n\n sub_array = input_array[start_index..-1]\n sub_array_rotated = rotate_array(sub_array)\n output = input_array[0...start_index] + sub_array_rotated\n output.join(\"\").to_i\nend", "def encrypt(str)\n result = []\n i = 0\n while str.size > 0\n chunk = counter(str)\n index = chunk[1]\n result << chunk\n str = str[index..-1]\n end\n result\nend", "def max_rotation(number)\n number_digits = number.to_s.size\n number_digits.downto(2) do |n|\n number = rotate_rightmost_digits(number, n)\n end\n number\nend", "def max_rotation(number)\n number_digits = number.to_s.size\n number_digits.downto(2) do |n|\n number = rotate_rightmost_digits(number, n)\n end\n number\nend", "def max_rotation(num)\n arr_size = num.digits.size\n arr_size.times do |idx|\n sign_idx = arr_size.odd? ? idx : -idx\n num = rotate_rightmost_digits(num, sign_idx)\n end\n num\nend", "def max_rotation(number)\n starting_num = number.to_s.length\n starting_num.downto(2) do |digits|\n number = rotate_rightmost_digits(number, digits)\n end\n number\nend", "def reverse_string_4(string)\n string = string.to_s\n result = ''\n index = 0\n while index < string.length\n result = string[index] + result\n index += 1\n end\n result\nend", "def str_perm_efficient(string, k, n)\n if k == n\n puts string\n else\n for i in k..n\n string[i], string[k] = string[k], string[i] # fixing one element\n str_perm_efficient(string, k+1, n) # calling perm on remaining string\n string[k], string[i] = string[i], string[k] # Swap back the previously swapped elements\n end\n end\nend", "def reverse_str(str)\n # puts str.reverse\n w = ''\n chrs = str.each_char.to_a\n chrs.size.times {\n w << chrs.pop\n }\n puts \"Reverse of String: #{w}\"\nend", "def rotate_rightmost_digits(number, n)\n array = number.to_s.split(//)\n removed_element = array[-n]\n array.slice!(-n)\n [array, removed_element].flatten.join.to_i\nend", "def rot_n(string, n)\n lowercase = (\"a\"..\"z\").to_a\n uppercase = (\"A\"..\"Z\").to_a\n string_encrypt = string.tr(\"a-zA-Z\", \"#{lowercase[n]}-za-#{lowercase[n-1]}#{uppercase[n]}-ZA-#{uppercase[n-1]}\")\nend", "def reverse(x)\n int_str = x.to_s\n res_str = String.new\n if int_str[0] == '-'\n res_str << int_str[0]\n int_str.slice!(0)\n end\n i = int_str.size - 1\n int_str.size.times do\n res_str << int_str[i]\n i -= 1\n end\n res = res_str.to_i\n res.between?(-2**31, 2**31 - 1) ? res : 0\nend", "def reverse_string(string)\n rev_string = \"\"\n string.length.times do |i|\n rev_string = string[i] + rev_string\n end\n\n puts rev_string\nend" ]
[ "0.85434216", "0.84711236", "0.82055515", "0.80406415", "0.7997467", "0.6016435", "0.59622145", "0.5934973", "0.5916981", "0.5877696", "0.5857657", "0.57538456", "0.5753773", "0.5729776", "0.5729776", "0.5729776", "0.5711763", "0.56774753", "0.56655705", "0.5657272", "0.56495094", "0.5611132", "0.56062675", "0.5598155", "0.5592893", "0.5592893", "0.5590077", "0.55800766", "0.5570193", "0.55651647", "0.5564902", "0.5551177", "0.55476415", "0.55427605", "0.5538701", "0.5533333", "0.5533141", "0.55276656", "0.5517427", "0.5514487", "0.55119747", "0.5504056", "0.5504056", "0.5504056", "0.5504056", "0.5504056", "0.5490975", "0.5482043", "0.5478899", "0.5469622", "0.5468627", "0.5457418", "0.54393345", "0.5438531", "0.5428907", "0.5421738", "0.54157346", "0.5414404", "0.54126304", "0.54017514", "0.53888166", "0.5387494", "0.5377387", "0.5372038", "0.53701055", "0.53537226", "0.5350591", "0.5346952", "0.53414834", "0.5334313", "0.53328115", "0.5329812", "0.53273785", "0.5325412", "0.5325315", "0.53198373", "0.53150994", "0.53144705", "0.53115416", "0.5302846", "0.5298935", "0.52921486", "0.5290771", "0.52878165", "0.5275841", "0.5275841", "0.5267025", "0.52599096", "0.5254998", "0.525131", "0.52192676", "0.52192676", "0.5215882", "0.5189776", "0.5189024", "0.5173207", "0.51688653", "0.5153313", "0.5140219", "0.51234514", "0.51186275" ]
0.0
-1
end ======================================================================================== Problem 2: Golden Ratio Golden Ratio is ratio between consecutive Fibonacci numbers calculate the golden ratio up to specified precision validate using MiniTest unit tests module Assignment08
def golden_ratio(precision) x = fib(99)/fib(98).to_f x.round(precision) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 df1()\n\tdig = []\n\tsum = 0;\n\t145.upto(260000) do |x|\n\t\tdig = splitNumber(x)\n\t\ttemp = dig.map {|d| factorial(d)}.reduce(:+)\n\t\t#p temp\n\t\tif(x == temp ) then\n\t\t\tprintf \"x = %d\\n\",x\n\t\t\tsum = sum + x\n\t\t\tnext\n\t\tend\n\t\tif(x > temp - 5 and x < temp + 5) then\n\t\t\tprintf \"close but not x = %d\\n\",x\n\t\tend\n\tend\n\tsum\nend", "def zrdo\n\n # we seed a good b and keep estimating up\n b = 120\n prevb = 21\n\n calcb = 0\n while prevb < 10 ** 12 do\n\n # this part will find us the next good b\n calcb = Math.sqrt(1 + 2 * b ** 2 - 2 * b)\n while calcb.round != calcb do\n b += 1\n calcb = Math.sqrt(1 + 2 * b ** 2 - 2 * b)\n end\n\n c = b\n # this is our estimation phase... since b / prevb\n # approaches a limit, i think it is quite accurate\n b = (b**2 / prevb.to_f).floor\n prevb = c\n # prevb directly correlates to calcb at this point,\n # that is why we have while prevb < 10**12\n end\n 1/2.0 + calcb / 2.0\nend", "def test_positive_big_bigdecimal\n\n @values_positive_big_bigdecimal.each { |x|\n # funktioniert, dauert aber fuer 2 Werte 10 Sekunden, fuer 3 Werte 18 Sekunden\n assert_in_delta(Math::log(x), ln(x))\n }\n\n end", "def fibs(n) ; PHI**n - PHA**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 solve112(target_proportion)\n bouncy_proportion = 0\n total_bouncy = 0\n num = 0\n while bouncy_proportion < target_proportion\n num += 1\n if bouncy?(num)\n total_bouncy += 1\n bouncy_proportion = 1.0*total_bouncy/num\n end\n end\n puts target_proportion, num\nend", "def calculate_probability(useful_results, reroll_count)\n return 100.0 * useful_results / ( 6 ** reroll_count )\n end", "def getFibbo\n prev_num = 1\n cur_num = 2\n running_total = 0\n sum_total = 0\n while (prev_num < 4E6)\n if (prev_num % 2 == 0)\n sum_total += prev_num\n end\n running_total = cur_num + prev_num\n prev_num = cur_num\n cur_num = running_total\n puts \"Current total is #{running_total}\"\n end\n return sum_total\nend", "def test_equiprobability\n winners_1, winners_2 = nil, nil\n\n @unique_advertises_count.times do\n winners_1 = Auctioneer.auction(\n creatives: @creatives,\n number_of_winners: @unique_advertises_count\n )\n winners_2 = Auctioneer.auction(\n creatives: @creatives,\n number_of_winners: @unique_advertises_count\n )\n\n break if winners_1 != winners_2\n end\n\n assert { winners_1 != winners_2 }\n end", "def test_calculate\n \tassert_equal '508.16', @gold_rush.calculate(23, 25)\n end", "def test_positive_bigdecimal\n\n @values_positive_bigdecimal.each { |x|\n assert_in_delta(Math::log(x), ln(x))\n }\n\n end", "def test_groebner_basis_coeff_01\n x, y, z = @P.vars('xyz')\n\n f1 = x**2 + y**2 + z**2 - 1\n f2 = x**2 + z**2 - y\n f3 = x - z\n\n g = x**3 + y**3 + z**3\n q, r = g.divmod_s(f1, f2, f3)\n # p q\n # p r\n assert_equal(g, q.inner_product([f1, f2, f3]) + r)\n # if g == q.inner_product([f1, f2, f3]) + r\n # puts \"Success!\"\n # else\n # puts \"Fail.\"\n # end\n end", "def test_Arithmetic_Sample03\n assert_equal(4, 2**2)\n assert_equal(0.5, 2.0**-1)\n assert_equal(0.5, 2**-1.0)\n assert_equal(3.0, 27**(1.0/3.0))\n assert_equal(1, 2**0)\n assert_equal(1, 2**(1/4))\n assert_equal(2.0, 16**(1.0/4.0))\n end", "def test_suma\n assert_equal 12,@a.suma(@b).num\n assert_equal 7, @a.suma(@b).denom\n end", "def fibonacci(n)\n # raise NotImplementedError\n\n if n == 0\n return 0\n end\n\n if n == nil || n < 0\n raise ArgumentError\n else\n a = 0\n b = 1\n for i in (1...n)\n temp = b\n b += a\n a = temp\n end\n # Golden Ratio\n # f = ((1.618034 ** n) - ((-0.618034) ** n)) / Math.sqrt(5)\n end\n\n return b\n # return f.round(0)\nend", "def rand_test p\n 20.downto(0) do |i|\n a = 1+rand(p-1)\n x = fastexp_mod(a,(p-1),p)\n# puts \"a=#{a} x=#{x}\"\n if (x != 1)\n return false\n end\n end\n return true\nend", "def fib(n)\r\n gRatio = 1.61803398875\r\n\r\n if n == 0\r\n return 0\r\n elsif n == 1\r\n return 1\r\n else\r\n num = (((gRatio)**n) - ((1 - gRatio) ** n)) / Math.sqrt(5)\r\n return num.to_i\r\n end\r\nend", "def test_fibonacci\n serie = @solucion.fibonacci(89)\n esperada = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n assert_equal(esperada, serie, \"No ha funcionado la serie fibonacci\")\n end", "def test_standard_credit_results\n @standard_credit_Value.each { |key, value| assert_in_delta @calc_standard[@row_number][key], value, 0.03 }\n check_count @calc_standard\n end", "def t_test r, n\n r * Math.sqrt( (n-2) / (1-r**2).to_f)\nend", "def fib(n)\n n += 2\n n.times do |num|\n if num == 0\n next\n elsif num == 1\n next\n else\n print \"#{(1.618034 ** num - (1 - 1.618034) ** num) * 1 / Math.sqrt(5)}\".to_i\n print \", \"\n end\n end\n puts \"*****\"\nend", "def p206\n re = /1.2.3.4.5.6.7.8.9.0/\n max = Math.sqrt(1929394959697989990).floor\n\n # Round since only squares of multiples of 30 and 70 end with 9_0 (e.g. 900)\n i = round_up Math.sqrt(1020304050607080900).floor, 100\n while i < max\n p30 = (i+30) ** 2\n p70 = (i+70) ** 2\n\n if re === \"#{p30}\"\n return \"#{i+30}^2 = #{p30}\"\n elsif re === \"#{p70}\"\n return \"#{i+70}^2 = #{p70}\"\n end\n\n i += 100\n end\nend", "def add_frac(a,b)\nlcm = a[1].lcm(b[1])\nputs a.inspect\nputs b.inspect\nputs lcm\nif lcm == a[1] and b[1] then\n sum2 = a[0] + b[0]\n puts \"Your fraction is #{sum2}/#{lcm}\"\nelse\n sum1 = (a[0]*b[1]) + (b[0]*a[1])\n puts sum1\nputs \"Your fraction is #{sum1}/#{lcm}\"\nend\nend", "def problem_57a\n root2 = lambda do |depth|\n if depth == 0\n Rational(1,2) \n else\n Rational(1,(root2.call(depth - 1) + 2))\n end\n end\n ret = 0\n 1000.times do |n|\n r = root2.call(n) + 1\n ret += 1 if r.numerator.to_s.length > r.denominator.to_s.length\n end\n ret\nend", "def test_exercise_1127\n @rec_calls = 0\n binomial(10, 4, 0.25)\n predicate = Proc.new { |actual|\n Math.log10(actual).truncate == Math.log10(@rec_calls).truncate\n }\n\n params = [10, 4]\n verify_method :exercise_1127,\n :with => [{params: params, predicate: predicate}]\n end", "def test_convert_cash_g\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n\n gold = 2\n silver = 0\n actual = pros.convert_metals_to_cash gold, silver\n expected = 41.34\n assert_equal expected, actual\n end", "def test_split\n assert_equal((46 / 3.0).round(2), @check_test.split.to_f)\n end", "def is_fibonacci?(num)\n num_plus_4 = ((5.0 * (num**2.0)) + 4.0)\n num_min_4 = ((5.0 * (num**2.0)) - 4.0)\n puts Math.sqrt(num)\n if Math.sqrt(num_plus_4) == Math.sqrt(num_plus_4).to_i|| Math.sqrt(num_min_4) == Math.sqrt(num_min_4).to_i\n return true\n else\n return false\n end\nend", "def problem_80b(size = 100)\n total = 0\n (2..100).each do |n|\n r = n.sqrt_digits(size+1)\n next if r.length == 1\n r = r[0,size].reduce(&:+)\n total += r\n# puts \"#{n} #{r.inspect}\"\n end\n total\nend", "def pzoe\n sum = 0\n (0..9).each do |a|\n (0..9).each do |b|\n (0..9).each do |c|\n (0..9).each do |e|\n (0..9).each do |f|\n (0..9).each do |g|\n sum += a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g if a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g == a ** 5 + b ** 5 + c ** 5 + e ** 5 + f ** 5 + g ** 5\n end\n end\n end\n end\n end\n end\n sum - 1\nend", "def test_convert_cash_g_s\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n gold = 2\n silver = 2\n actual = pros.convert_metals_to_cash gold, silver\n expected = 43.96\n assert_equal expected, actual\n end", "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 test_promedio_edades\n n=5\n print validate(23.2, promedio_edades(n)) \nend", "def euler008\n big_num = <<-eos\n 73167176531330624919225119674426574742355349194934\n 96983520312774506326239578318016984801869478851843\n 85861560789112949495459501737958331952853208805511\n 12540698747158523863050715693290963295227443043557\n 66896648950445244523161731856403098711121722383113\n 62229893423380308135336276614282806444486645238749\n 30358907296290491560440772390713810515859307960866\n 70172427121883998797908792274921901699720888093776\n 65727333001053367881220235421809751254540594752243\n 52584907711670556013604839586446706324415722155397\n 53697817977846174064955149290862569321978468622482\n 83972241375657056057490261407972968652414535100474\n 82166370484403199890008895243450658541227588666881\n 16427171479924442928230863465674813919123162824586\n 17866458359124566529476545682848912883142607690042\n 24219022671055626321111109370544217506941658960408\n 07198403850962455444362981230987879927244284909188\n 84580156166097919133875499200524063689912560717606\n 05886116467109405077541002256983155200055935729725\n 71636269561882670428252483600823257530420752963450\n eos\n\n current_max = 0\n\n until big_num.length == 5 do\n current_prod = big_num[0..4].split('').map { |i| i.to_i }.reduce(:*)\n current_max = current_prod if current_prod > current_max\n big_num = big_num[1..-1]\n end\n\n current_max\nend", "def expected_score(r_A, r_B)\n 1 / (1 + 10**((r_B - r_A) / 400.0))\n end", "def is_fibonacci?(num)\n p x = (5*(num*num) + 4)\n p x_2 = Math.sqrt(x).to_i\n p (x_2*x_2)\n p y = (5*(num*num) - 4)\n p y_2 = Math.sqrt(y).to_i\n p (y_2*y_2)\n if (x_2*x_2) == x || (y_2*y_2) == y\n p true\n else\n p false\n end\nend", "def test_total_cost\n assert_equal(46.0, @check_test.total_cost)\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 test_Arithmetic_Sample04\n assert_equal(16, 2**2**2)\n assert_equal(81, 3**2**2)\n end", "def euler002\n sum = 0\n fib = [1, 1]\n while fib[1] < 4e6\n sum += fib[1] if fib[1].even?\n fib = [fib[1], fib[0] + fib[1]]\n end\n sum\nend", "def puppy_golden_age_brute_forced(gains)\n \n # brute force solution\n \n if gains.empty?\n return nil\n end\n \n golden_age_so_far= [0, 0]\n value_so_far= sum(gains[0..0])\n \n 0.upto (gains.length-1) do |i|\n i.upto (gains.length-1) do |j|\n if sum(gains[i..j]) > value_so_far\n value_so_far= sum(gains[i..j])\n golden_age_so_far= [i, j]\n end\n end\n end\n \n golden_age_so_far\nend", "def fibevensum xmax\n a, b = 1, 2\n sum = 0\n while a < xmax\n sum += a if a.even?\n a, b = b, a + b\n end\n sum\nend", "def main\n sum, ssq = 0, 0\n 100.downto(1) { |x| sum+=x; ssq += (x*x) }\n res = sum**2 - ssq\n puts \"#{res}\"\nend", "def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend", "def missing_number_gauss_formula(nums)\n expected_sum = (nums.length * (nums.length + 1))/2\n actual_sum = nums.reduce(:+) # or nums.inject{ |sum, x| sum + x} / nums.inject(:+)\n return expected_sum - actual_sum\nend", "def fibGetSingle2 (n)\n (1.61803398875 ** n - -0.61803398875 ** n) / 2.2360679775\nend", "def test_Arithmetic_Sample05\n assert(3.0 < Float::MAX)\n assert(Float::MAX == Float::MAX)\n end", "def test_69_cents #tests the coins that should be returned to total 69 cents\n \t\n\tassert_equal(2, $quarters)\n\tassert_equal(1, $dimes)\n\tassert_equal(1, $nickels)\n\tassert_equal(4, $pennies)\nend", "def test_positive_float\n\n @values_positive_float.each { |x|\n assert_in_delta(Math::log(x), ln(x))\n }\n\n end", "def find_best_ratio(samples, n, step_sz)\n spam = samples.select { |s| s.kind == :spam }.shuffle\n ham = samples.select { |s| s.kind == :ham }.shuffle\n\n # bests = {\n # :accuracy => {:step => 0, :value => 0.0, :ratio => nil, :mat => nil},\n # :precision => {:step => 0, :value => 0.0, :ratio => nil, :mat => nil},\n # :recall => {:step => 0, :value => 0.0, :ratio => nil, :mat => nil},\n # }\n\n steps = {}\n\n (step_sz).step(0.99, step_sz).each do |i|\n ratio = {:spam => (n * i).round, :ham => (n * (1 - i)).round}\n limited_samples = spam.take(ratio[:spam]) + ham.take(ratio[:ham])\n\n STDERR.puts \"Step %0.2f, #{ratio.inspect}, n=#{ratio.values.reduce(:+)}\" % i\n\n mat = CrossValidate.run(limited_samples, Classifier.fetch(0, :unigram))\n\n steps[i] = {:ratio => ratio, :mat => mat}\n # if mat[:accuracy] > bests[:accuracy][:value]\n # bests[:accuracy] = {:step => i, :value => mat[:accuracy], :ratio => ratio, :mat => mat}\n # end\n\n # if mat[:precision] > bests[:precision][:value]\n # bests[:precision] = {:step => i, :value => mat[:precision], :ratio => ratio, :mat => mat}\n # end\n\n # if mat[:recall] > bests[:recall][:value]\n # bests[:recall] = {:step => i, :value => mat[:recall], :ratio => ratio, :mat => mat}\n # end\n end\n\n steps\n # bests\nend", "def poisson_calc(expected, prng) #expected number of occurences\n\t\tl = Math.exp(-expected) #(P|X = 0) \n\t\tk = 0.0 #(number of occurences)\n\t\tp = 1.0 #The product of the urandoms\n\t\tk = 1.0 unless p > l # need because 1.0 !> 1.0\n\t\twhile p > l \n\t\t\tu = prng.rand\n\t\t\tp *= u\n\t\t\tk += 1 \n\t\tend\n\t (k - 1)\n\tend", "def calculatePhi(num)\n a=1\n b=1\n c=a+b\n num.times do\n a=b\n b=c\n c=a+b\n end\n print \"The value of PHI after #{num} iterations is #{c/b.to_f}\"\n print \"\\n\"\nend", "def f_iter(x)\n cur_prob = 1.0\n for i in 2..$x do\n cur_prob += ($n - cur_prob)/$n\n end\n return cur_prob\nend", "def NR(exp,num,prec)\r\n\tres = Float(num)\r\n\twhile((res**exp - num) > prec)\r\n\t\tres = res - (((res**exp) - num)/(exp*(res**(exp-1))))\r\n\t\t#puts res\r\n\tend\r\n\treturn res\r\nend", "def p003(total_remaining = 600_851_475_143)\n divisor = 2\n until divisor >= total_remaining\n if (total_remaining % divisor).zero?\n total_remaining /= divisor\n else\n divisor += 1\n end\n end\n divisor\nend", "def calculate_gain(change_ratio, previous_gains, new_investment)\n return (previous_gains + new_investment) * change_ratio\nend", "def fibonacci_numbers\n fibonacci_snapshot = [1,2]\n fibonacci_results = []\n loop do\n return fibonacci_results if fibonacci_snapshot[1] > 4_000_000\n fibonacci_snapshot << fibonacci_snapshot.reduce(:+)\n fibonacci_results << fibonacci_snapshot[0]\n fibonacci_snapshot.shift\n end\nend", "def probability_of_success\n experience / 5.0\n end", "def test_annuity_credit_results\n @annuity_credit_Value.each { |key, value| assert_in_delta @calc_annuity[@row_number][key], value, 0.03 }\n check_count @calc_annuity\n end", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def test_negative_float\n\n @values_positive_float.each { |x|\n assert_in_delta(Math::log(x), ln(x))\n }\n\n end", "def test_example_3\n result = @project_calc.calculate_project_cost(base_price: 12456.95, num_workers: 4, product_categories: ['books'])\n assert_equal 13707.63, result\n end", "def reciprocal\n dividend = 1\n answer = max = remainder = count = 0\n 999.downto(7) do |divisor|\n next if divisor % 2 == 0 || divisor % 5 == 0\n count = 0\n until count > 2 && remainder == 1\n remainder = dividend % divisor\n dividend = remainder * 10\n count += 1\n end\n if count > max\n max = count\n answer = divisor\n end\n end\n answer\nend", "def test_operaciones\n\t\t#Con la Suma\n\t\tassert_equal(\"6\", Fraccion.new(25,5).suma(3,3).to_s)\n\t\tassert_equal(\"8/3\", Fraccion.new(2,3).suma(4,2).to_s) \n\t\t#Con la Resta\n\t\tassert_equal(\"-4/3\", Fraccion.new(2,3).resta(4,2).to_s)\n\t\tassert_equal(\"-3\", Fraccion.new(-4,2).resta(2,2).to_s)\n\t\t#Con la Multiplicacion\n\t\t#Se comprueban todas las posibilidades\n\t\tassert_equal(\"4/15\", Fraccion.new(2,3).mult(2,5).to_s)\n\t\tassert_equal(\"-2/5\", Fraccion.new(1,1).mult(-2,5).to_s)\n\t\tassert_equal(\"1\", Fraccion.new(5,5).mult(1,1).to_s)\n\t\tassert_equal(\"-1\", Fraccion.new(-5,5).mult(1,1).to_s)\n\t\tassert_equal(\"-1\", Fraccion.new(5,-5).mult(1,1).to_s)\n\t\tassert_equal(\"1\", Fraccion.new(-5,-5).mult(1,1).to_s)\n\t\tassert_equal(\"1/2\", Fraccion.new(5,5).mult(1,2).to_s)\n\t\tassert_equal(\"-1/2\", Fraccion.new(-5,5).mult(1,2).to_s)\n\t\tassert_equal(\"-1/2\", Fraccion.new(5,-5).mult(1,2).to_s)\n\t\tassert_equal(\"1/2\", Fraccion.new(-5,-5).mult(1,2).to_s)\n\t\tassert_equal(\"0\", Fraccion.new(0,5).mult(1,2).to_s)\n\t\tassert_equal(\"0\", Fraccion.new(0,-5).mult(1,2).to_s)\n\t\tassert_equal(\"0\", Fraccion.new(5,-5).mult(0,2).to_s)\n\t\tassert_equal(\"0\", Fraccion.new(-5,-5).mult(0,2).to_s)\n\t\t#Con la Division\n\t\tassert_equal(\"5/3\", Fraccion.new(2,3).div(2,5).to_s)\n\t\tassert_equal(\"-1\", Fraccion.new(25,5).div(-10,2).to_s)\n\t\tassert_equal(\"-1\", Fraccion.new(-25,5).div(10,2).to_s)\n\tend", "def pmt(rate,n,amount)\n\n\ttop = 0.0\n\ttop = rate*(1+rate)**n\n\tbot = 0.0\n\tbot = (1+rate)**n-1\n\tresult = 0.0\n\tresult =amount*top/bot\n\treturn result \n\nend", "def euler020\n def fact(x)\n ans = x.downto(1).reduce(:*)\n end\n fact(100).to_s.split('').map { |x| x.to_i}.reduce(:+)\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def is_fibonacci?(num)\n return true if num == 1 or num == 0\n fib = (5*num*num) + 4\n nac = (5*num*num) - 4\n \n if num == Math.sqrt((fib-4)/ 5) || num == Math.sqrt((nac+4)/ 5)\n return true\n else\n return false\n end\n \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 problem_80(size = 100)\n total = 0\n (2..100).each do |n|\n n,d = n.sqrt_frac(2*size)\n next unless n\n r = n * (10 ** (size * 1.1).to_i) / d\n r = r.to_s[0,size].split(//).map(&:to_i).reduce(&:+)\n total += r\n# puts r.inspect\n end\n total\nend", "def sqrt_convergents()\r\n\tthe_div = [1, 2]\t\t# Numerator and Denominator\r\n\titerations = 1000\r\n\treturner = 0\r\n\r\n\twhile iterations > 0\r\n\t\t# Every next fraction has previouse one in the denominator.\r\n\t\tthe_div = [the_div[1], 2*the_div[1] + the_div[0]]\t\t# Simplify the fraction.\r\n\t\tto_test = the_div[0] + the_div[1]\t\t\t\t\t\t# 1 + fraction\r\n\t\treturner += 1 if to_test.to_s.size > the_div[1].to_s.size\r\n\t\titerations -= 1\r\n\tend\r\n\treturn returner\r\nend", "def calculate_kn_probability next_ngram: nil, ngram_model: 0, discount: 0.25, ngram_counts: @ngram_counts, good_turing_bins: @good_turing_bins, separator: \" \"\n local_ngram_model = ngram_model==0 ? next_ngram.split(separator).count : ngram_model\n \n return calculate_mle_probability(next_ngram: next_ngram, separator: separator) if local_ngram_model==1 # Recursion stops at the unigram model\n\n prefix_regex = /^#{next_ngram.split(separator)[0..-2].join(separator)}\\b/\n prefix = next_ngram.split(separator)[0..-2].join(separator)\n suffix = next_ngram.split(separator).last\n similar_ngrams = ngram_counts[local_ngram_model].select{|ngram, _| puts \"Found #{prefix.green} #{ngram.split[1..-1].join(\" \").brown}\" if (@verbose and ngram.match(prefix_regex)); ngram.match(prefix_regex)}.count # Number of words which complete the current n-1 gram, e.g. for the n-gram \"your house looks nice\" we count \"yhl ugly\", \"yhl fine\" etc. Notice - we don't counts the number of occurences for \"yhl ugly\" etc but only the number of lower-order ngrams which complete the current ngram.\n puts \"#{'Total of '.red + similar_ngrams.to_s.red + ' found.'.red} Now calculating counts.\" if @verbose\n similar_ngrams_total_counts = ngram_counts[local_ngram_model].reduce(0){|acc, (ngram, counts)| puts \"Found #{prefix.green} #{ngram.split[1..-1].join(\" \").brown} with raw count of #{counts}\" if (@verbose and ngram.match?(prefix_regex)); if ngram.match(prefix_regex) then acc += counts; else acc; end} # It's here that we actually sum up the counts\n puts \"#{'Total count is '.red + similar_ngrams_total_counts.to_s.red}\"\n ngrams_with_fixed_suffix = ngram_counts[local_ngram_model].reduce(0){|acc, (ngram, counts)| puts \"Found #{ngram.brown} / #{suffix.green} with raw count of #{counts}\" if (@verbose and ngram.match?(/^#{suffix}\\b/)); acc += counts if ngram.match?(/^#{suffix}\\b/); acc}\n\n first_term = [get_raw_counts(next_ngram).to_f - discount, 0].max / similar_ngrams_total_counts.to_f\n second_term = discount * (similar_ngrams.to_f/ngrams_with_fixed_suffix.to_f)\n \n return first_term + (second_term * calculate_kn_probability(next_ngram: next_ngram.split(separator)[1..-1].join(separator)))\n end", "def euler006\n square_of_sum = (1..100).reduce(:+) ** 2\n sum_of_squares = (1..100).inject { |sum, n| sum + n*n }\n\n return square_of_sum - sum_of_squares\nend", "def btc_profit\n break_even.abs\n end", "def factor(n)\n count = 0\n n_sqrt = Math.sqrt(n)\n a = n_sqrt.ceil.to_i\n b = Math.sqrt((a**2 - n))\n while true\n a += 1\n b = Math.sqrt(a**2 - n)\n if b - b.floor == 0\n factor_one = (a - b)\n factor_two = (a + b)\n end\n if count > 100000\n break\n end\n count += 1\n end\nputs \"The factors of #{n} are #{factor_one} and #{factor_two}.\"\n$factor_one = factor_one\n$factor_two = factor_two\nend", "def generateAccuracy()\n return (rand 0.6..0.8)\nend", "def test_addition_of_two_number\n # assert_raises \"Invalid values.\" do\n magic_ball = MagicBall.new\n puts \"--------------\"\n puts magic_ball.addition(5, 5)\n puts \"--------------\"\n assert magic_ball.addition(5, 5), 10\n # assert addition == 10\n # end\n end", "def float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 34 )\n\n \n # - - - - main rule block - - - -\n # at line 344:5: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? | '.' ( '0' .. '9' )+ ( EXPONENT )? | ( '0' .. '9' )+ EXPONENT )\n alt_12 = 3\n alt_12 = @dfa12.predict( @input )\n case alt_12\n when 1\n # at line 344:9: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )?\n # at file 344:9: ( '0' .. '9' )+\n match_count_6 = 0\n while true\n alt_6 = 2\n look_6_0 = @input.peek( 1 )\n\n if ( look_6_0.between?( 0x30, 0x39 ) )\n alt_6 = 1\n\n end\n case alt_6\n when 1\n # at line 344:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_6 > 0 and break\n eee = EarlyExit(6)\n\n\n raise eee\n end\n match_count_6 += 1\n end\n\n match( 0x2e )\n # at line 344:25: ( '0' .. '9' )*\n while true # decision 7\n alt_7 = 2\n look_7_0 = @input.peek( 1 )\n\n if ( look_7_0.between?( 0x30, 0x39 ) )\n alt_7 = 1\n\n end\n case alt_7\n when 1\n # at line 344:26: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n break # out of loop for decision 7\n end\n end # loop for decision 7\n # at line 344:37: ( EXPONENT )?\n alt_8 = 2\n look_8_0 = @input.peek( 1 )\n\n if ( look_8_0 == 0x45 || look_8_0 == 0x65 )\n alt_8 = 1\n end\n case alt_8\n when 1\n # at line 344:37: EXPONENT\n exponent!\n\n end\n\n when 2\n # at line 345:9: '.' ( '0' .. '9' )+ ( EXPONENT )?\n match( 0x2e )\n # at file 345:13: ( '0' .. '9' )+\n match_count_9 = 0\n while true\n alt_9 = 2\n look_9_0 = @input.peek( 1 )\n\n if ( look_9_0.between?( 0x30, 0x39 ) )\n alt_9 = 1\n\n end\n case alt_9\n when 1\n # at line 345:14: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_9 > 0 and break\n eee = EarlyExit(9)\n\n\n raise eee\n end\n match_count_9 += 1\n end\n\n # at line 345:25: ( EXPONENT )?\n alt_10 = 2\n look_10_0 = @input.peek( 1 )\n\n if ( look_10_0 == 0x45 || look_10_0 == 0x65 )\n alt_10 = 1\n end\n case alt_10\n when 1\n # at line 345:25: EXPONENT\n exponent!\n\n end\n\n when 3\n # at line 346:9: ( '0' .. '9' )+ EXPONENT\n # at file 346:9: ( '0' .. '9' )+\n match_count_11 = 0\n while true\n alt_11 = 2\n look_11_0 = @input.peek( 1 )\n\n if ( look_11_0.between?( 0x30, 0x39 ) )\n alt_11 = 1\n\n end\n case alt_11\n when 1\n # at line 346:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_11 > 0 and break\n eee = EarlyExit(11)\n\n\n raise eee\n end\n match_count_11 += 1\n end\n\n exponent!\n\n end\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 34 )\n\n end", "def p6\n\trange = (1..100).to_a\n\tsquare_of_sum = range.reduce(:+) ** 2\n\tsum_of_square = (range.map{|x| x ** 2}).reduce(:+)\n\tsquare_of_sum - sum_of_square\nend", "def f(num)\n (1.upto(num).inject { |m,n| m + n**2 } - 1.upto(num).sum ** 2).abs\nend", "def fib(n)\n\t((PHI ** n - (-1/PHI) ** n) / Math.sqrt(5)).round\nend", "def rms\n sum = 0\n @test.each do |value|\n sum += (value[2] - value[3]) ** 2\n end\n Math.sqrt(sum/@test.length.to_f)\n end", "def calculate_win_broke_fire_rate\n all_cycles_result = []\n win_rate = []\n fire_rate = []\n broke_rate = []\n # todo we can tune this number\n (@number_of_years-100+@fire_age).times do |i|\n all_cycles_result << calculate_one_cycle(i*12)\n end\n number_of_cycles = all_cycles_result.count\n number_of_months = all_cycles_result[0].count\n\n\n (number_of_months/12).times do |year|\n total_win = 0\n total_fire = 0\n total_broke = 0\n number_of_cycles.times do |cycle|\n year_start_month = year*12\n year_end_month = year*12+11\n\n total_win += all_cycles_result[cycle].slice(year_start_month, year_end_month-year_start_month).count{|i| i == WIN}\n total_fire += all_cycles_result[cycle].slice(year_start_month, year_end_month-year_start_month).count{|i| i == FIRE}\n total_broke += all_cycles_result[cycle].slice(year_start_month, year_end_month-year_start_month).count{|i| i == BROKE}\n end\n total_count = total_win + total_fire + total_broke\n win_rate << total_win/total_count.to_f\n fire_rate << total_fire/total_count.to_f\n broke_rate << total_broke/total_count.to_f\n end\n return [win_rate, fire_rate, broke_rate]\n end", "def sum_dig_pow(a,b)\n eureka_numbers = [] # Where we store the array\n a.upto(b) do |number|\n number_length = number.to_s.length\n digits = number.to_s.split(\"\") # This will return an array of the numbers\n index = 0\n sum = 0\n while index < number_length\n sum += digits[index].to_i ** (index + 1) # Multiplying by the power\n index += 1\n end\n if number == sum\n eureka_numbers << number\n end\n end\n eureka_numbers # Our implicit return\nend", "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 divide(a,b,num_of_sig_figs=10)\n #output will be our answer\n output = 0\n #we loop until our dividend is smaller than our divisor\n while a >= b\n # we subtract the divisor from the dividend and the difference is our new dividend\n a -= b\n #we increase the output by 1\n output += 1\n end\n if a == 0\n #if there is no remainder we return the output\n output\n else\n #if there is a remainder we need to change the output to a string\n output = output.to_s\n #sig_figs keeps track of the significant figures we've made\n sig_figs = output.length\n #remainder_args takes an array of three arguments - the dividend, divisor and the final answer string which ends with a . as we will be adding decimals\n remainder_args = [a,b,output + '.']\n #the default number of significant figures is 10. The loop runs until we hit the number of significant figures or if there is no remainder left\n while sig_figs < num_of_sig_figs && remainder_args[0] != 0\n #we have to create a new function which we will call recursively to add any new digits after the decimal point. We must call it on an array because otherwise we cannot change the variables due to Ruby's scope\n def remainder_divide(arr)\n #we multiply the dividend by 10 to make it a non decimal number\n arr[0] = multiply(arr[0], 10)\n #this loop is the same as our original division\n output = 0\n while arr[0] >= arr[1]\n arr[0] -= arr[1]\n output += 1\n end\n #here we change the output to a string and attach it to our original answer.\n output = output.to_s\n arr[2] += output\n #We change the remainder_args to our new array\n remainder_args = [arr[0],arr[1],arr[2]]\n end\n #now that we've defined our function, we will call it on our array of arguments until we hit the desired amount of significant figures or we have the answer\n remainder_divide(remainder_args)\n #we add one to our significant figures so that we don't loop infinitely\n sig_figs += 1\n end\n #we return our answer converted back to a number\n remainder_args[2].to_f\n end\nend", "def bench_factorial\n assert_performance_linear do |n| # n is a range value\n Math.factorial(n)\n end\n end", "def checkDef?(num1, num2, num3)\n if(num1**2 + num2**2 == num3**2 && num1+num2+num3==$sum)\n return true\n end\nend", "def test_powers_of_two\n 100.times do |p|\n n = 2 << p\n\n assert_equal n, n.to_ber.read_ber\n end\n end", "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 expected\n\t\t\tBigDecimal(@count) * ((@sides + 1.0) / 2.0)\n\t\tend", "def solve(meal_cost, tip_percent, tax_percent)\n\n result = meal_cost * (1 + tip_percent.to_f / 100 + tax_percent.to_f / 100)\n puts result.round()\n \nend", "def percent_passes; end", "def percent_passes; end", "def problem_six\n (1.upto(100).reduce(:+)) ** 2 - (1.upto(100).map { |n| n ** 2 }).reduce { |sum, n| sum + n }\n end" ]
[ "0.6329578", "0.6120972", "0.604802", "0.60390025", "0.6032825", "0.6017206", "0.60041684", "0.5998652", "0.5917522", "0.591311", "0.59097296", "0.5905226", "0.5897867", "0.5875491", "0.58643633", "0.5861391", "0.5860039", "0.58598614", "0.5812934", "0.5812185", "0.5807329", "0.5805687", "0.5780547", "0.5776623", "0.57595587", "0.5751984", "0.5751438", "0.5725108", "0.5712376", "0.56760556", "0.56686723", "0.5668626", "0.5660329", "0.5649973", "0.56375366", "0.5635457", "0.56203914", "0.56145185", "0.5602745", "0.56009555", "0.5598567", "0.5598166", "0.5597293", "0.5593755", "0.5588681", "0.55805117", "0.55756223", "0.55676055", "0.5567338", "0.5564706", "0.5558056", "0.5557343", "0.5554726", "0.5542852", "0.5541776", "0.55407315", "0.5538216", "0.5534825", "0.55347216", "0.55329", "0.55300653", "0.55291003", "0.5511572", "0.55073094", "0.5506604", "0.5506356", "0.54976004", "0.5495377", "0.5495377", "0.5495377", "0.5495377", "0.5495377", "0.5487845", "0.5482337", "0.54773134", "0.547526", "0.5471775", "0.54678184", "0.5465904", "0.54639834", "0.5444095", "0.5444094", "0.54423296", "0.543931", "0.5432213", "0.5430508", "0.5427638", "0.5426326", "0.5425071", "0.5420611", "0.5420512", "0.5416826", "0.54159623", "0.5410099", "0.54096955", "0.54067594", "0.54049313", "0.5404128", "0.5404128", "0.53998464" ]
0.7249214
0
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_mailer.new_price_quote.subject
def send_price_quote(price_quote) @price_quote = price_quote mail to: @price_quote.request.user.email, subject: 'New price quote on Stabstr' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message_subject=(value)\n @message_subject = value\n end", "def subject=(subject); @message_impl.setSubject subject; end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end", "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end", "def new_quote_notice(quote)\n @quote = quote\n mail(subject: \"[team] New Enquiry Received\")\n end", "def subject\n self['subject'] || msg['subject']\n end", "def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end", "def subject\n @mail.subject\n end", "def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end", "def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end", "def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end", "def subject=(string)\n set('Subject', string)\n end", "def set_subject(subject)\n\t\tend", "def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end", "def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end", "def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def subject\n @subject=EzCrypto::Name.new(@cert.subject) unless @subject\n @subject\n end", "def subject_name=(value)\n @subject_name = value\n end", "def set_subject_and_message(form, subject, message)\n raise Impostor::MissingTemplateMethodError.new(\"set_subject_and_message must be implemented\")\n end", "def subject\n message.subject\n end", "def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end", "def subject\n @options.fetch(:subject) { \"Invitation\" }\n end", "def konsalt_mail params\n build_params params\n send_email t('emails.konsalta_mail.subject')\n end", "def subject; @message_impl.getSubject; end", "def subject\n self['subject']\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def subject\n title \n end", "def message_subject\n return @message_subject\n end", "def subject_name\n return @subject_name\n end", "def get_subject\n\t\tend", "def subject_name\n subject_full_name\n end", "def build_email_kase(options={})\n EmailKase.new({\n :kase => self,\n :subject => \"%{name} wants to know what you think\".t % {:name => self.person.casualize_name}\n }.merge(options))\n end", "def SetSubject(subject)\n\t\t#Subject of document\n\t\t@subject = subject\n\tend", "def email_subject(&blk)\n @email_subject_block = blk if blk\n @email_subject_block\n end", "def custom_mail( user, subject, title, contents )\n @user = user\n @host = GogglesCore::AppConstants::WEB_MAIN_DOMAIN_NAME\n @contents = contents\n @title = title\n #subject: \"[#{ GogglesCore::AppConstants::WEB_APP_NAME }@#{ @host }] #{ subject }\",\n mail(\n subject: \"#{ subject } [#{GogglesCore::AppConstants::WEB_APP_NAME}]\",\n to: user.email,\n date: Time.now\n )\n end", "def newcompany_email(company)\n @company = company\n @message = t('mailers.company.created')\n \n emails = AdminUser.all.collect(&:email).join(\",\")\n\n mail(:to => emails, :subject => \"#{t('site_title')}: #{@message}\")\n \n end", "def user_added_email(user)\n ActsAsTenant.without_tenant do\n @course = user.course\n end\n @recipient = user.user\n\n I18n.with_locale(@recipient.locale) do\n mail(to: @recipient.email, subject: t('.subject', course: @course.title))\n end\n end", "def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end", "def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end", "def send_message_to_company(recipientEmail, fromEmail, subjectEmail, bodyMessage)\n @subject = subjectEmail\n @body[\"body_message\"] = bodyMessage\n @body[\"sent_to\"] = recipientEmail\n @recipients = recipientEmail\n @from = fromEmail\n @content_type = \"text/html\"\n @headers = {}\n end", "def quote_request(quote)\n @quote = quote\n mail( to: TO, subject: \"Quote Request by #{@quote.name.camelcase} #{Time.current.strftime('%b %d, %Y %H:%M %p')}\")\n end", "def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <[email protected]>\",\n from: \"BaseRails <[email protected]>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end", "def default_i18n_subject(interpolations = {})\n ''\n end", "def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end", "def set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end", "def headers\n { subject: \"#{I18n.t('cms.contact_form.subject_prefix')}: #{reason}: #{subject}\",\n to: Account.current.preferred_support_email,\n from: Account.current.preferred_support_email,\n reply_to: %(\"#{name}\" <#{email}>) }\n end", "def send_subscribe_email(subscriptor)\n @subscriptor = subscriptor\n @subject = \"Thanks for subscribe for our amazing app\"\n mail(to: @subscriptor.email, subject: @subject)\n # mail(to: , from: , subject:)\n end", "def headers\n {\n :subject => \"澄清:對於#{candidate_name}的#{record_type}\",\n # :to => \"[email protected]\",\n :to => Setting.email.clarify,\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def newsletter(user, subject, text)\n @user = user\n @text = text\n\n mail(to: user.email, subject: subject)\n end", "def deliver\n I18n.switch_locale self.language || Utility.language_code do \n EmailMailer.deliver_share_kase(self, self.kase) if self.valid?\n end\n end", "def data_subject=(value)\n @data_subject = value\n end", "def subscriber_notice_subscription_paid\n BrandMailer.subscriber_notice(\n brand: Brand.find_by(company_name: 'Brand Nine'),\n stage: 'subscription_paid'\n )\n end", "def adhoc_test_subj_call\n ->(candidate) { I18n.t('email.test_adhoc_subject_initial_input', candidate_account_name: candidate.account_name) }\n end", "def subject\n @subject\n end", "def subject\n @subject\n end", "def send_message(subject:, text:, from: nil)\n super(to: get_attribute(:name), subject: subject, text: text, from: from)\n end", "def send_message(subject:, text:, from: nil)\n super(to: get_attribute(:name), subject: subject, text: text, from: from)\n end", "def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end", "def course_notification_item_details(course)\n t('notifications.subscribe_course')\n end", "def subject(*extra)\n subject = \"\"\n subject << \"#{@project.name} | \" if @project\n subject << extra.join(' | ') if extra.present?\n subject\n end", "def devalert(subject, body='', extra_to=[])\n recipients = CONTACT_EMAIL_ACCOUNTS\n if RAILS_ENV == 'production'\n extra_to = [extra_to] if extra_to.is_a?(String)\n recipients = [recipients].concat(extra_to).join(',')\n end\n @subject = subject\n @body = {:msg => body}\n @recipients = recipients\n @from = ALERT_EMAIL_DEV\n @sent_on = Time.now\n @headers = {}\n end", "def subject\n @subject\n end", "def email_us(subject, body)\n unless ENV['RACK_ENV'] == 'development'\n recipient = \"The Awesome Team <[email protected]>\"\n\n # First, instantiate the Mailgun Client with your API key\n mg_client = Mailgun::Client.new ENV['MAILGUN_PRIVATE']\n\n # Define your message parameters\n message_params = { from: '[email protected]',\n to: recipient,\n subject: subject,\n html: body,\n text: Nokogiri::HTML(body).text\n }\n\n # Send your message through the client\n mg_client.send_message 'sandboxa148f93a5c5f4813a81365d1b873ee8f.mailgun.org', message_params\n end # unless ENV['RACK_ENV'] == 'development'\n end", "def subject\n raise \"Override #subject in the service class\"\n end", "def translate(key, options = {})\n I18n.t(key, options.merge(locale: @answer.questionnaire.language))\n end", "def getEmailDefaults(subject, toEmail, ccEmail = nil)\n if Rails.env.eql? 'development'\n subject = \"[BASL-DEV] #{subject}\"\n toEmail = '[email protected]'\n ccEmail = toEmail\n else\n subject = \"[BASL] #{subject}\"\n end\n mailInfo = {\n :to => toEmail,\n :subject => subject,\n :cc => ccEmail\n }\n mailInfo\n end", "def send_message(subject:, text:, from: nil)\n super(to: read_attribute(:name), subject: subject, text: text, from: from)\n end", "def new_motification_email(motification, receiver)\n @motification = motification\n @receiver = receiver\n set_subject(motification)\n mail :to => receiver.send(Mailboxer.email_method, motification),\n :subject => t('mailboxer.motification_mailer.subject', :subject => @subject),\n :template_name => 'new_motification_email'\n end", "def as_eloqua_email\n subject = \"#{self.title}: #{self.abstracts.first.headline}\"\n\n {\n :html_body => view.render_view(\n :template => \"/editions/email/template\",\n :formats => [:html],\n :locals => { edition: self }).to_s,\n\n :plain_text_body => view.render_view(\n :template => \"/editions/email/template\",\n :formats => [:text],\n :locals => { edition: self }).to_s,\n\n :name => \"[scpr-edition] #{self.title[0..30]}\",\n :description => \"SCPR Short List\\n\" \\\n \"Sent: #{Time.now}\\nSubject: #{subject}\",\n :subject => subject,\n :email => \"[email protected]\"\n }\n end", "def subject_titles\n @subject_titles ||= sw_subject_titles\n end", "def new_message_email(message,receiver)\n @message = message\n @receiver = receiver\n set_subject(message)\n mail :to => receiver.send(Mailboxer.email_method, message),\n :from => \"Panel KW Kraków <reply+#{message.conversation.code}@panel.kw.krakow.pl>\",\n :subject => @subject,\n :template_name => 'new_message_email'\n end", "def title_for_user_applied_to_travel\n I18n.t(\"notification.user_applied_to_travel.title\")\n end", "def subject=(text)\n current_div.text_field(:id=>\"comp-subject\").set text\n end", "def get_subject_name\n subject_name = subject_header.text.sub! 'Subject:', ''\n subject_name = subject_name.strip!\n subject_name\n end", "def send_notice(type:,adjustment:,previous_data: nil, subject:,title:,email: '[email protected]')\n @type = type\n @adjustment = adjustment\n @previous_data = previous_data\n @title = title\n @link = inventory_adjustments_url\n mail :to => email, :subject => subject\n end", "def quote_received(quote)\n @quote = quote\n\n mail to: quote.email, :subject => \"Your Quote Received\"\n end" ]
[ "0.6757123", "0.66477495", "0.6615914", "0.6599148", "0.65804195", "0.655499", "0.6492605", "0.645177", "0.6394896", "0.63842005", "0.63827956", "0.6353556", "0.6348274", "0.63079405", "0.6298014", "0.62972003", "0.62779576", "0.626582", "0.6253665", "0.62525433", "0.6207085", "0.61606365", "0.61606365", "0.61606365", "0.61606365", "0.61606365", "0.61606365", "0.6151047", "0.6140982", "0.6100455", "0.6100455", "0.6100455", "0.6100455", "0.6099764", "0.6095081", "0.60943675", "0.6088228", "0.6075944", "0.6069094", "0.6058459", "0.60576767", "0.60289466", "0.6005497", "0.6005497", "0.6005497", "0.6005497", "0.6005497", "0.6005497", "0.6005497", "0.6005497", "0.59977496", "0.59954345", "0.59625876", "0.5933827", "0.59214073", "0.5914313", "0.5908493", "0.59046257", "0.58757764", "0.5867584", "0.58642995", "0.585784", "0.5789057", "0.5766324", "0.57578355", "0.5728633", "0.57071394", "0.5680136", "0.5662142", "0.5651984", "0.563018", "0.56216675", "0.5611324", "0.5609805", "0.55975944", "0.55917126", "0.55791646", "0.55609494", "0.55609494", "0.55605036", "0.55605036", "0.5559071", "0.5556257", "0.5555711", "0.55540776", "0.5547433", "0.5529178", "0.55267686", "0.55247825", "0.5521753", "0.5514957", "0.550529", "0.54876935", "0.54741657", "0.54733324", "0.54725695", "0.5463446", "0.54606485", "0.545852", "0.54564077" ]
0.61353564
29
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 Abe and Brian. 0. total Pseudocode make sure all pseudocode is commented out! Input: an array of numbers Output: sum of all numbers within the array Steps to solve the problem. define variable result=0 add each number to the result 1. total initial solution each or while loop
def total(my_array) result=0 my_array.each { |a| result= result + a } return result 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(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 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(a)\n ans = 0\n for i in 1 .. (a.length - 1)\n ans += a[i]\n end \n ans\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 solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes 0!=1 class Quiz\n # find even values\n def solution1(input)\n # Final solution\n input.flatten.select do |value|\n value.even?\n end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.select do |value|\n # value.even?\n # end\n # end.flatten\n end\n\n # find value sum\n def solution2(input)\n # Final Solution\n input.flatten.inject(:+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.flatten.inject do |sum, value|\n # sum += value\n # end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.inject do |sum, value|\n # sum += value\n # end\n # end.inject do |sum, value|\n # sum += value\n # end\n end\n\n # find max value\n def solution3(input)\n # Final solution\n input.flatten.max\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.max\n # end.max\n end\n\n # sum the array lengths\n def solution4(input)\n # Final solution\n input.map(&:length).inject(0, :+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.map(&:length).inject{|sum, value| sum += value}\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.length\n # end.inject {|sum, value| sum += value}\n end\n\n # transform to factorials\n # Factorial is defined as the product of all the whole numbers from 1 to n\n # Examples:\n # 4! = 4*3*2*1\n # 1! = 1\n # 0! = 1\n def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end\nend", "def solution(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 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 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 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 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 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 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 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 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 solution(a)\n cars_going_east = [0]\n\n a.each do |direction|\n next_counter = direction.zero? ? cars_going_east.last + 1 : cars_going_east.last\n cars_going_east << next_counter\n end\n\n passings = 0\n a.each_with_index do |direction, index|\n passings += cars_going_east[index] if direction == 1\n end\n\n return -1 if passings > 1000000000\n passings\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 total(array)\n\tanswer=array.inject(0){\n\t\t|sum,i| sum+i\n\t}\n\treturn answer\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(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 compute(array)\n\n index = 0\n while index < array.length\n code = array[index]\n instruction = code % 100\n case instruction\n when 1\n add(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 2\n multiply(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 3\n # Input\n consume_input(code, array, array[index + 1])\n index += 2\n when 4\n # Output\n write_to_output(code, array, array[index + 1])\n index += 2\n when 5\n bool, new_index = jump_if_true(code, array, array[index + 1], array[index + 2])\n\n index = bool ? new_index : index + 3\n when 6\n bool, new_index = jump_if_false(code, array, array[index + 1], array[index + 2])\n\n index = bool ? new_index : index + 3\n when 7\n less_than(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 8\n equals(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 9\n add_to_relative_base(code, array, array[index + 1])\n index += 2\n when 99\n break\n else\n break\n end\n end\nend", "def total(array)\n\tx = array.length\n\tsum = 0\n\t\twhile x > 0\n\t\t\tsum += array[x-1]\n\t\t\tx -= 1\n\t\tend\n\n\treturn sum\n\nend", "def total(array)\n sum = 0\n array.each do |n|\n sum += n\n end\n sum\nend", "def total(array)\n sum = 0\n array.each do |number|\n sum = sum += number\n end\n sum\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 check_array_for_sum(arr, goal)\n arr.product(arr).reject{|pair| pair.first == pair.last}.map{ |pair| pair.reduce(0, :+)}.include?(goal)\nend", "def stepPerms(n)\n # dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]\n \n dp = Array.new(n + 1, 0)\n dp[0] = 1 # when number of steps are 0 there is only 1 way\n \n (1..n).each do |i|\n dp[i] += dp[i - 1] if i - 1 >= 0\n dp[i] += dp[i - 2] if i - 2 >= 0\n dp[i] += dp[i - 3] if i - 3 >= 0\n end\n\n dp[n]\nend", "def 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 reduce_to_total(source_array, starting_point=0)\n i = 0\n total = starting_point\n while i < source_array.length do\n total = total + source_array[i]\n i += 1\n end\n total\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 total(array)\n sum = 0\n array.each do |x|\n sum = sum + x\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 reduce_to_total(source_array, starting_point=0)\n\n i = 0\n\n while i < source_array.length do\n starting_point += source_array[i]\n i += 1\n end\n\n starting_point\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 total(input_array)\n\tn = 0\n\tinput_array.each do |x|\n\t\tn += x\n\tend\n\treturn n\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 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 problem18(r) \n h = r.length\n sum = 0\n for i in 0..h-1 \n \n end\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 total(array)\n array.inject { |sum, n| sum + n}\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 running_total3(array)\n sum = 0\n array.map do |num|\n sum = [sum, num].inject(:+)\n end\nend", "def reduce_to_total(array)\n total = 0 \n count = 0 \n while count < array.length do\n total = total + array[count]\n count += 1\n end\n total\nend", "def total array\n array.inject(0){|sum,x| sum + x }\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 solution(number)\n ans = 0\n (3...number).step(3) {|n| ans += n}\n (5...number).step(5) {|n| n % 3 == 0 ? next : ans += n}\n return ans\nend", "def total(array)\n array.inject(0) {|sum, i| sum + i }\nend", "def total(array) \n number = 0\n array.each do |i|\n number += i\n end\n number\nend", "def run_total(array)\n sum = 0\n array.map { |num| sum += num }\nend", "def total (array)\n\tarray.inject { |sum, n| sum + n }\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 total(array)\n sum = 0\n array.each do |x|\n sum += x\nend\nsum\nend", "def total(array)\nsum = 0 \n\tarray.each do |num|\n\tsum += num \n\tend \n\treturn sum\nend", "def sum(array)\n sum = 0\n array.each { |n| sum += n } \n sum\nend", "def reduce_to_total(array,starting_point=0)\n total = starting_point\n counter = 0 \n while counter < array.size do \n total += array[counter]\n counter += 1\n end\n total\nend", "def sum(array)\n sum = 0\n\n array.each { |number|\n sum += number\n }\n\n return sum\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 total (array)\n sum = 0\n array.each do |i|\n sum + i\n end\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 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(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\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 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_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 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 total(array)\n a = 0\n for i in 0...array.length\n a = a + array[i]\n end\n return a\nend", "def total(array)\n\tarray.inject {|sum,n| sum + n}\n\tend", "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 total(array)\n y = 0\n array.each {|x| y = x + y}\n return y\nend", "def total(array)\n sum = 0\n array.each { |i| sum += i}\n return sum\nend", "def running_total(array)\n result = []\n\n array.inject(0) do |sum, num|\n result << sum += num\n sum # have to return sum\n end\n result\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 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 reduce_to_total(source_array, starting_point = 0 )\n \n new_total = starting_point\n i = 0\n while i < source_array.length do\n new_total += source_array[i]\n i += 1\n end\n return new_total\n \n end", "def running_total1(array)\n r_total = 0\n array.map { |n| r_total += n }\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 problem_106a\n combin = lambda { |m,h| m.factorial / (h.factorial * (m - h).factorial) }\n max = 20\n\n sum = Array.new(max+1,-1)\n 1.upto(max) do |n|\n 0.upto(n/2) do |k|\n sum[n] += combin.call(n,2*k) * combin.call(2*k - 1, k + 1)\n end\n puts \"#{n} #{sum[n]}\"\n end\n sum[12]\nend", "def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend", "def total (array)\n x = 0 \n sum = 0\n while x <= array.length-1\n sum += array[x]\n x += 1\n end\n return sum \nend", "def total (array)\n x = 0 \n sum = 0\n while x <= array.length-1\n sum += array[x]\n x += 1\n end\n return sum \nend", "def total(array)\n index = 0\n sum = 0\n until index == array.length\n sum += array[index]\n index += 1\n end\nreturn sum\nend", "def given(array = [])\n i = cur_val = 0\n until array[i].nil?\n cur_val += array[i] * VALS[i]\n i += 1 \n end\n return [array] if cur_val == GOAL_VAL\n combos = []\n if VALS[i] > 1\n (0..((GOAL_VAL - cur_val) / VALS[i])).each do |num_coins|\n combos += given( array + [num_coins] )\n end\n return combos\n else\n return [array + [GOAL_VAL - cur_val] ]\n end\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 solution(number)\n(0...number).map{|x| x % 3 == 0 || x % 5 == 0 ? x : 0}.inject{|sum, x| sum + x}\nend", "def sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend", "def sum(array)\n array.reduce(0) {|sum, num| sum += num}\nend", "def sum_of_multiples(target, factors)\n\n# 1. Create an empty array called multiples\n\nmultiples = []\n\n# 2. Check where the list of factors is empty, and if it is, set the list to [3, 5]\n\nif factors.empty?\n factors = [3, 5]\nend\n\n# 3. For every factor in the factors list\n# 1. Set the current_multiple to factor to keep track of the multiples of factor\n# 2. While current_multiple < targe\n# 1. Append the current_multiple to multiples\n# 2. Add factor to current_multiple\n\nfactors.each do |factor|\n current_multiple = factor\n \n while current_multiple < target\n multiples.push(current_multiple)\n current_multiple += factor\n end\nend\n\n# 4. Filter duplicate numebrs from multiples\n\nmultiples.uniq!\n\n# 5. Compute and return the sum of the numbers in multiples\n\np multiples.sum\n\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 y = 0\n array.each do |x|\n y += x\n end\n y\nend", "def solution(num)\n sum_of_squares = 0\n\n (1..num).each do |number|\n sum_of_squares += number**2\n end\n\n square_of_sums = (1..num).inject(:+) ** 2\n\n p (square_of_sums - sum_of_squares).abs\nend", "def total(array)\n\tarray.inject do |sum, i| sum + i\n\tend\nend", "def total(arr)\nnumber = 0\narr.each { |x| number += x}\n return number\nend", "def sum(arr)\n output = 0\n arr.each do |num|\n output += num\n end\n return output\nend", "def total(array)\n sum = 0\n array.inject(0) {|sum, i|\n sum + i}\n end", "def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend", "def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend", "def reduce_to_total(source_array, starting_point = 0)\n return source_array.reduce() {|sum,n| sum + n}\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 i = 0\n array.each { |a| i += a.to_i }\n return i\nend" ]
[ "0.6719396", "0.66952485", "0.66764003", "0.66593844", "0.65953165", "0.6582857", "0.65276414", "0.65183413", "0.6490501", "0.6457219", "0.6447671", "0.6379239", "0.6360184", "0.63583905", "0.6345708", "0.6326957", "0.6326957", "0.63077205", "0.6297719", "0.6270918", "0.6266461", "0.6247721", "0.62092435", "0.6207803", "0.6204505", "0.61964566", "0.61878717", "0.6187788", "0.6185299", "0.61725485", "0.6164311", "0.61595625", "0.61581546", "0.61580956", "0.61533886", "0.6148258", "0.61462", "0.6138358", "0.61378556", "0.6133336", "0.61327064", "0.6130602", "0.61295056", "0.6129104", "0.6124553", "0.6118754", "0.6117958", "0.61146134", "0.6114478", "0.6110344", "0.6106452", "0.6103729", "0.6100629", "0.61002624", "0.60983676", "0.6094508", "0.6091711", "0.60910547", "0.60905945", "0.60895306", "0.6084227", "0.60807407", "0.6078159", "0.6076592", "0.60716313", "0.6066163", "0.6063154", "0.60628974", "0.6060826", "0.60601133", "0.6059824", "0.6055057", "0.60542864", "0.6053798", "0.60480535", "0.60473144", "0.60459846", "0.6043572", "0.6042661", "0.6042637", "0.60407585", "0.60407585", "0.6040491", "0.604045", "0.60395384", "0.60367614", "0.6029026", "0.6027872", "0.6027663", "0.6027077", "0.60267454", "0.6026341", "0.6014934", "0.60137945", "0.6012394", "0.6008258", "0.60076904", "0.60054505", "0.60003245", "0.59986216", "0.5997983" ]
0.0
-1
3. total refactored solution Works in Ruby on Rails
def total(my_array) my_array.sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def appraisals; end", "def appraisals; end", "def formation; end", "def suivre; end", "def intensifier; end", "def schubert; end", "def romeo_and_juliet; end", "def probers; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def strategy; end", "def apply\n\t\t\t\t\n\t\t\tend", "def anchored; end", "def transformations; end", "def relatorios\n end", "def villian; end", "def refutal()\n end", "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "def helpers; end", "def helpers; end", "def helpers; end", "def make_and_model; end", "def celebration; end", "def transforms; end", "def scientist; end", "def extract_code_to_gists(request)\n\n end", "def who_we_are\r\n end", "def weber; end", "def implementation; end", "def implementation; end", "def stderrs; end", "def production_curtailment; end", "def operations; end", "def operations; end", "def create\n @question = Question.new(params[:question])\n @question.if_soft_deleted(params[:question][:soft_deleted],current_user) if params[:question][:soft_deleted].present?\n\n #params[:question][:identity_list].collect!{|i| Identity.find(i) if Identity.exists? i}.compact! if params[:question][:identity_list].present?\n #params[:question][:timeline_list].collect!{|t| Timeline.find(t) if Timeline.exists? t}.compact! if params[:question][:timeline_list].present?\n #params[:question][:category_list].collect!{|c| Category.find(c) if Category.exists? c}.compact! if params[:question][:category_list].present?\n params[:question][:identity_list] = Identity.find(params[:question][:identity_list]) if Identity.exists? params[:question][:identity_list] if params[:question][:identity_list].present?\n params[:question][:timeline_list] = Timeline.find(params[:question][:timeline_list]) if Timeline.exists? params[:question][:timeline_list] if params[:question][:timeline_list].present?\n params[:question][:category_list] = Category.find(params[:question][:category_list]) if Category.exists? params[:question][:category_list] if params[:question][:category_list].present?\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render json: @question, status: :created, location: @question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def processor; end", "def transform; end", "def silly_adjective; end", "def parts; end", "def parts; end", "def parts; end", "def calculated; end", "def generate_comprehensive\n\n end", "def winter_paralympics_sport; end", "def offences_by; end", "def lookup_new_swimmer\n \n end", "def common\n \n end", "def custom; end", "def custom; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def index\n @sponsor = @project.program\n if has_read_all?(@sponsor) then\n @submissions = Submission.all(:include=>[:key_personnel, :applicant, :submitter, :reviewers], :conditions=>[\"project_id = :project_id\",{:project_id => @project.id}])\n \n @applicants = @submissions.collect{|s| s.applicant }.compact.uniq.sort{ |a,b| a.last_name.downcase+' '+a.first_name.downcase <=> b.last_name.downcase+' '+b.first_name.downcase }\n @key_personnel = (@submissions.collect{|s| s.key_personnel.collect{ |k| k } }.flatten).compact.uniq.sort{ |a,b| a.last_name.downcase+' '+a.first_name.downcase <=> b.last_name.downcase+' '+b.first_name.downcase }\n @core_managers = @submissions.collect{|t| t.core_manager}.flatten.compact.uniq.sort{ |a,b| a.last_name.downcase+' '+a.first_name.downcase <=> b.last_name.downcase+' '+b.first_name.downcase }\n @submitters = @submissions.collect{|s| s.submitter }.compact.uniq.sort{ |a,b| a.last_name.downcase+' '+a.first_name.downcase <=> b.last_name.downcase+' '+b.first_name.downcase }\n @approvers = @submissions.collect{|e| e.effort_approver }.compact.uniq.sort{ |a,b| a.last_name.downcase+' '+a.first_name.downcase <=> b.last_name.downcase+' '+b.first_name.downcase }\n @business_admins = @submissions.collect{|e| e.department_administrator }.compact.uniq.sort{ |a,b| a.last_name.downcase+' '+a.first_name.downcase <=> b.last_name.downcase+' '+b.first_name.downcase }\n @reviewers = @submissions.collect{|e| e.reviewers.collect{|r| r} }.flatten.compact.uniq.sort{ |a,b| a.last_name.downcase+' '+a.first_name.downcase <=> b.last_name.downcase+' '+b.first_name.downcase }\n# @users = (@applicants+@key_personnel.collect{|e| e.user}.flatten+@core_managers+@submitters+@approvers+@business_admins+@reviewers).compact.uniq\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n else\n redirect_to projects_path\n end\n end", "def find_all\n \n end", "def view_flow; end", "def unsolved_params\n \n end", "def king_richard_iii; end", "def greibach_normal_form\n raise NotImplementedError\n end", "def validate_resident_survey model\n\n # What ID do we use to mark ambiguous users?\n err_res_id = P4Resident.find_by_p4_program_id('#999')['id']\n # Get list of all surveys, and look for duplicate survey entries\n if not model.column_names.index('abfm_last_four2').nil?\n # In rails 2.3 the select method is private\n # So either use rails 3.2 or use the find method\n # model.find( :all,\n # :select=>'count(*) as xcount, p4_program_id, contclin, abfm_last_four, abfm_last_four2',\n # :group:=>'p4_program_id,contclin,abfm_last_four,abfm_last_four2,p4_resident_id'\n # )\n surveys = model.select('count(*) as xcount, p4_program_id, contclin, abfm_last_four, abfm_last_four2').group('p4_program_id,contclin,abfm_last_four,abfm_last_four2,p4_resident_id')\n else\n surveys = model.select('count(*) as xcount, p4_program_id, contclin, abfm_last_four').group('p4_program_id,contclin,abfm_last_four,p4_resident_id')\n end\n\n surveys.each do |survey|\n abfm_last_four = survey.abfm_last_four.to_s.rjust(4,'0')\n if survey.attributes.has_key? 'abfm_last_four2'\n abfm_last_four_old = survey.abfm_last_four2.to_s.rjust(4,'0')\n else\n abfm_last_four_old = abfm_last_four\n end\n\n # look for matching resident \n residents = P4Resident.joins(:p4_resident_clinics).\n where([\"(abfm_last_four = ? OR abfm_last_four_old = ?) AND p4_resident_clinics.p4_clinic_id = ?\",abfm_last_four,abfm_last_four_old,survey.contclin])\n\n log_msgs = []\n # Multiple surveys have the same identifying information\n if survey.xcount.to_i != 1\n resident = P4Resident.find(err_res_id)\n log_msgs += [[\"Duplicate Surveys found\",survey]]\n end\n \n if residents.count == 0\n # No matching resident\n resident = P4Resident.find(err_res_id)\n log_msgs += [['No matching user', survey]]\n elsif residents.count > 1\n # This survey can me matched to more than one resident\n resident = P4Resident.find(err_res_id)\n log_msgs += [['Matched multiple users', survey]]\n else\n resident = residents[0]\n end\n \n # Update survey records to point to the correct resident\n if abfm_last_four == abfm_last_four_old\n conditions= ['p4_program_id= ? AND (abfm_last_four = ?) AND contclin=?', \n survey.p4_program_id,abfm_last_four,survey.contclin ]\n else\n conditions= ['p4_program_id= ? AND (abfm_last_four=? OR abfm_last_four2 = ?) AND contclin=?', \n survey.p4_program_id,abfm_last_four,abfm_last_four_old,survey.contclin ]\n end\n\n responses = model.where(conditions) \n \n responses.each do |response|\n if not response.p4_resident_id.nil? and response.p4_resident_id != err_res_id\n log_msgs = []\n log \"Manually Matched: #{response.p4_resident_id}\", response\n next\n end\n response.p4_resident_id = resident[:id]\n response.save!\n end\n \n log_msgs.each do |arr|\n log arr[0],arr[1]\n end\n\n end\nend", "def invention; end", "def summer_paralympics_sport; end", "def manufacture; end", "def apply\n end", "def resolver; end", "def jaeger_quest; end", "def zuruecksetzen()\n end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def isolated; end", "def isolated; end", "def schumann; end", "def my\n open_season_ids = Season.is_not_ended.select(:id).map{|s| s.id }\n\n # Why refine? If user tags a meeting out form his affikliation it should be shown\n browsable_season_ids = open_season_ids\n # Refine the list of open seasons:\n #browsable_season_ids = open_season_ids.select{ |season_id|\n # ! current_user.find_team_affiliation_id_from_badges_for( season_id ).nil?\n #} + open_season_ids.select{ |season_id|\n # ! current_user.find_team_affiliation_id_from_team_managers_for( season_id ).nil?\n #}\n #browsable_season_ids.uniq!\n\n # Extract the user-tagged browsable meetings:\n meeting_id_list = Meeting\n .where( \"meetings.season_id IN (?)\", browsable_season_ids )\n .tagged_with( \"u#{ current_user.id }\", on: :tags_by_users )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n\n # If user has an associated swimmer look for team tagged and attended meetings too\n if current_user.has_associated_swimmer?\n # Add also the team-tagged browsable meetings.\n # Find the current, browsable team affiliations that may have tagged the meetings,\n # and, for each, add any tagged meeting found to the list:\n browsable_season_ids\n .map{ |season_id| current_user.find_team_affiliation_id_from_badges_for(season_id) }\n .compact.each do |tagger_team_affiliation_id|\n meeting_id_list += Meeting\n .where( [\"meetings.season_id IN (?)\", browsable_season_ids] )\n .tagged_with( \"ta#{ tagger_team_affiliation_id }\", on: :tags_by_teams )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n end\n\n # .where( [\"meetings.id not in (?) and meetings.season_id IN (?)\", meeting_id_list, browsable_season_ids] )\n\n # Add also any already attended and closed meeting belonging to the browsable\n # seasons: (the relationship w/ swimmer is through MIRs, so the inner join is enough)\n meeting_id_list += current_user.swimmer.meetings\n .where( [\"meetings.season_id IN (?)\", browsable_season_ids] )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n end\n\n# .where( [\"meetings.id not in (?) and meetings.season_id IN (?)\", meeting_id_list, browsable_season_ids] )\n\n @calendarMeetingPicker = CalendarMeetingPicker.new( nil, nil, nil, meeting_id_list.uniq! )\n @calendarDAO = @calendarMeetingPicker.pick_meetings( 'DESC', false, current_user )\n @meetings = @calendarDAO.get_meetings\n\n end", "def show\n \n rec_id = params[:id].to_i\n recipe = Recipe.find(rec_id)\n # find user name for recipe\n \n username = recipe.user.username;\n\n # get all ingredients from step ingredients ?\n ingredients = []\n\n recipe_steps = recipe.recipe_steps\n # one to one step ingredients to ingredients when coming from recipe-steps\n \n # recipe ingredients\n \n \n \n step_ingredients = recipe_steps.map{ |rs| \n { \n step_num: rs.step_num,\n step_image: rs.image,\n instruction: rs.instruction,\n step_ingredients: rs.step_ingredients.map{ |si| \n {amount: si.amount, ingredient: {name: si.ingredient.name} }\n } \n \n }\n \n }\n\n \n step_ingredients.each do |si|\n # byebug \n ings = si[:step_ingredients]\n ings.each do |ing|\n if ing[:amount] \n ing_total = ing[:amount] + \" \" + ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n else\n ing_total = ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n end\n end\n end\n \n # fix time to string\n \n render json: {username: username, recipe: recipe, ingredients: ingredients, recipe_steps: step_ingredients }, status: :accepted\n end", "def cobasysprog\n end", "def terpene; end", "def singular_siegler; end", "def post_process; end", "def verdi; end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def compilereturn\n\n end", "def transformation\n end", "def retire\n\n end", "def collegiate_rivals\n end", "def show\n\n @all_annotation_string = ''\n Annotation.where(passage_id: @passage.id).each do |annot|\n @all_annotation_string = @all_annotation_string + \"#{annot.element}@-@#{annot.original_spanish}@-@#{annot.annotation_content}$-$\"\n end\n @all_annotation_string = @all_annotation_string.gsub(/\\R+/, ' ')\n\n\n #==================================================================\n #DO NOT ALLOW TO READ IF NOT GRANTED PRIVILEGE\n #DO NOT LINK TO EDIT IF NOT GRANTED PRIVILEGE\n privilege = PassageShare.find_by(recieving_user_id: @current_user.id, passage_id: @passage.id)\n\n\n if (@passage.user_id == @current_user.id)\n author = true\n else\n author = false\n end\n\n if author || privilege\n else \n redirect_back fallback_location: '/'\n end\n\n if author || privilege.edit_privilege\n @has_editing_privilege = true\n else \n @has_editing_privilege = false\n end\n #==================================================================\n\n #==================================================================\n #RETRIEVE AUTHOR OF CURRENT PASSAGE\n if author\n @author = @current_user\n else\n @author = User.find(@passage.user_id)\n end\n #==================================================================\n\n #==================================================================\n #RETRIEVE HISTORY OF UPDATES FOR CURRENT PASSAGE AND USERS THAT MADE THEM\n @update_history = UpdateTrack.where(passage_id: @passage.id).order(\"created_at DESC\")\n @participating_users = {}\n @time_since = {}\n @update_history.each do |update|\n @time_since[update.id] = update_elapse_count(update[:created_at])\n @participating_users[update.id] = User.find(update.last_user_id)\n end \n #==================================================================\n end", "def point_attribution_all\n \tnewrating = Array.new\n \tnewpartial = Array.new\n \texistpartial = Array.new\n \texercise_value = Array.new\n \texercise_section = Array.new\n \tqcm_value = Array.new\n \tqcm_section = Array.new\n \tproblem_value = Array.new\n \tproblem_section = Array.new\n \tsectionid = Array.new\n \tn_section = Section.count\n \t\n \t(1..n_section).each do |i|\n \t\tnewpartial[i] = Array.new\n \t\texistpartial[i] = Array.new\n \tend\n \t\n \tUser.all.each do |u|\n \t\tnewrating[u.id] = 0\n \t\t(1..n_section).each do |i|\n \t\t\tnewpartial[i][u.id] = 0\n \t\t\texistpartial[i][u.id] = false\n \t\tend\n \tend\n \t\n \tPointspersection.all.each do |p|\n \t\texistpartial[p.section_id][p.user_id] = true\n \tend\n \t\n \tUser.all.each do |u|\n \t\t(1..n_section).each do |i|\n \t\t\tif !existpartial[i][u.id]\n \t\t\t\tnewpoint = Pointspersection.new\n \t \tnewpoint.points = 0\n \tnewpoint.section_id = i\n \tuser.pointspersections << newpoint\n \t\t\tend\n \t\tend\n \tend\n \t\n \tChapter.all.each do |c|\n \tsectionid[c.id] = c.section_id\n end\n \n \tExercise.all.each do |e|\n \t\texercise_value[e.id] = e.value\n \t\texercise_section[e.id] = sectionid[e.chapter_id]\n \tend\n \t\n \tQcm.all.each do |q|\n \t\tqcm_value[q.id] = q.value\n \t\tqcm_section[q.id] = sectionid[q.chapter_id]\n \tend\n \t\n \tProblem.all.each do |p|\n \t\tproblem_value[p.id] = p.value\n \t\tproblem_section[p.id] = p.section_id\n \tend\n \t\n \tSolvedexercise.all.each do |e|\n \t\tif e.correct\n pt = exercise_value[e.exercise_id]\n u = e.user_id\n s = exercise_section[e.exercise_id]\n newrating[u] = newrating[u] + pt\n newpartial[s][u] = newpartial[s][u] + pt\n \t\tend\n \tend\n \t\n \tSolvedqcm.all.each do |q|\n \t\tif q.correct\n pt = qcm_value[q.qcm_id]\n u = q.user_id\n s = qcm_section[q.qcm_id]\n newrating[u] = newrating[u] + pt\n newpartial[s][u] = newpartial[s][u] + pt\n \t\tend\n \tend\n \t\n \tSolvedproblem.all.each do |p|\n \t\tpt = problem_value[p.problem_id]\n \t\tu = p.user_id\n \t\ts = problem_section[p.problem_id]\n \t\tnewrating[u] = newrating[u] + pt\n newpartial[s][u] = newpartial[s][u] + pt\n \tend\n \t\n \twarning = \"\"\n \t\n \tPointspersection.all.each do |p|\n \t\tif newpartial[p.section_id][p.user_id] != p.points\n \t\t\tp.points = newpartial[p.section_id][p.user_id]\n \t\t\tp.save\n \t\tend\n \tend\n \t\n \tUser.all.each do |u|\n \t\tif newrating[u.id] != u.rating\n \t\t\twarning = warning + \"Le rating de #{u.name} a changé... \"\n \t\t\tu.rating = newrating[u.id]\n \t\t\tu.save\n \t\tend\n \tend\n \t\n \tif(warning.size > 0)\n \t\tflash[:danger] = warning\n \tend\n end", "def adjust_params \n #if request is like this:\n # GET /relations\n # GET /entities/relations\n # GET /databases/entities/relations\n if params[:action] == 'index'\n \n # If it is \n # GET /relations\n # Then we cannot sevice this request, must specify the entity.\n# if !params[:database_id] and !params[:entity_id]\n# render :text => 'GET /relations is not available', :status => 400\n# return false;\n# end\n\n # But in the remaining two cases:\n # * /entities/relations\n # * /databases/entities/relations\n # Allow the class\n return true;\n end\n \n # if it is:\n # GET /relations\n # GET /entities/relations\n # GET /databases/entities/relations/\n # Becasue show needs to have an ID, therefore\n # any of the above URL will do and no context is needed.\n #FIXME: What other possibility the show action might face?\n if params[:action] == 'show'\n return true;\n end\n \n #If its like this:\n # POST /relations\n # POST /entities/relations\n # POST /databases/entities/relations\n # NOTE: For now, the relation resource should be totally complete\n # even if the call is being as a nested resource.\n #\n if params[:action] == 'create'\n \n #if it is like this:\n # POST /relations\n # Then the relations resource should be complete in\n # every respect.\n if !params[:database_id] and !params[:entity_id]\n #return true if valid_relation_resource?\n # Otherwise, the resource is not vaild and we need to tell the user\n #render :json => report_errors(nil, 'The provided realtion resource is incomplete')[0], \n # :status => 400 and return false;\n end\n \n # But if its something like this:\n # POST /entities/:entity_id/relations\n # POST /databases/entities/:entity_id/relations\n #\n if params[:database_id] or params[:entity_id]\n # Then if the relation resource is valid, \n # the entity_id parameter is altogather ignored.\n #return true if valid_relation_resource? \n end\n return true\n end\n \n # if its either of these:\n # PUT /relations\n # PUT /entities/relations\n # PUT /databases/entities/relations\n #\n if params[:action] == 'update'\n # Set the params[:relation_id] because\n # the underlying Admin::EntitiesController#add_link function\n # expects it\n params[:relation_id] = params[:id] and return true;\n end\n \n # If it is either of these:\n # DELETE /relations\n # DELETE /entities/relations\n # DELETE /databases/entities/relations\n #\n if params[:action] == 'destroy'\n \n # For now, you can only make a nested call.\n #PENDING: This would change when the rest call would include the user\n # authenticiy information which would help to determine whether the \n # relation being deleted belongs to the user or not.\n if !params[:entity_id]\n render :json => report_errors(nil, 'DELETE /relations call is not available for now. Call DELETE /entities/relations instead')[0],\n :status => 400 and return false\n end\n \n params[:source_id] = params[:entity_id]\n return true;\n \n end\n \n # In all cases, the request is not handled by this controller!\n render :json => report_errors(nil, \"The requested action is \\\"#{params[:action]}\\\" \" + \n \" on controller \\\"#{params[:controller]}\\\" while I am\" + \n \" \\\"#{self.class.name}\\\" and cannot handle your request.\")[0],:status => 400 and return false;\n \n end", "def query_1\n document_ids = Perpetuity[Document].all.to_a.map(&:id)\n index_num = [ 42, 76, 44, 90, 8, 12, 4, 77, 43, 99]\n all_ids = []\n index_num.each do |num|\n all_ids << document_ids[num]\n end\n\n processed_number = 0\n all_ids.each do |id|\n Perpetuity[Document].find(id)\n processed_number+=1\n end\n return processed_number\nend", "def build_lookup_belongs(blank = nil)\n # TODO: Remove rescue statement\n @sms_templates = SmsTemplate.find_all_for_select_option('')\n @message_signature = \"\\n--\\n#{self.current_user.display_name.truncate(24)}\"\n @sms_recipients = AddressbookContact.find(:all, :order => 'name ASC')\n \n end", "def index\n @sponsor = @project.program\n if has_read_all?(@sponsor)\n @submissions = Submission.includes([:key_personnel, :applicant, :submitter, :reviewers])\n .where('project_id = :project_id', { :project_id => @project.id })\n .all\n\n @applicants = @submissions.map { |s| s.applicant }.compact.uniq.sort { |a, b| a.sort_name.downcase <=> b.sort_name.downcase }\n @key_personnel = (@submissions.map { |s| s.key_personnel.map { |k| k } }.flatten).compact.uniq.sort { |a, b| a.sort_name.downcase <=> b.sort_name.downcase }\n @core_managers = @submissions.map { |t| t.core_manager }.flatten.compact.uniq.sort { |a, b| a.sort_name.downcase <=> b.sort_name.downcase }\n @submitters = @submissions.map { |s| s.submitter }.compact.uniq.sort { |a, b| a.sort_name.downcase <=> b.sort_name.downcase }\n @approvers = @submissions.map { |e| e.effort_approver }.compact.uniq.sort { |a, b| a.sort_name.downcase <=> b.sort_name.downcase }\n @business_admins = @submissions.map { |e| e.department_administrator }.compact.uniq.sort { |a, b| a.sort_name.downcase <=> b.sort_name.downcase }\n @reviewers = @submissions.map { |e| e.reviewers.map { |r| r } }.flatten.compact.uniq.sort { |a, b| a.sort_name.downcase <=> b.sort_name.downcase }\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n else\n redirect_to projects_path\n end\n end", "def jack_handey; end", "def offenses_to_check; end", "def rest_positionals; end", "def index\n\n # @sql = \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n @sql = params[:name].present? ? \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" : \"Projects.name ILIKE '%' \"\n @sql += \"OR Projects.description ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n\n @sql += \"and Projects.category ILIKE '#{'%'+params[:categorysdigital]+'%'}' \" if params[:categorysdigital].present?\n if params[:categorysdigital].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n end\n\n if params[:categorysdigital].present? || params[:categorysmarketing].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n end\n\n @sql += \"and Projects.progress = #{params[:progresspropose].to_i} \" if params[:progresspropose].present?\n if params[:progresspropose].present?\n @sql += \"or Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n else\n @sql += \"and Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n end\n\n if params[:progressselected].present?\n @sql += \"or Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n else\n @sql += \"and Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n end\n\n # @sql += \"ORDER progress\"\n @projects = Project.where(@sql).order(:progress)\n @count = @projects.count\n @count_tt = Project.count\n end", "def sitemaps; end", "def checks; end", "def index\n #p \"params\",params\n params.delete_if{|k,v| v=='' || v=='0' } \n @providers = Provider.order(:name)\n @projects = Project.order(:address)\n @executors = User.actual.where(id: Project.pluck(:executor_id)) #undefined method `uniq' for #<Class\n @param_provider = params[:receipts_provider]\n @param_provider = @param_provider.to_i if !@param_provider.nil?\n @only_actual = params[:only_actual].nil? ? true : params[:only_actual]=='true'\n all_ids = Receipt.all.ids\n p_ids = s_ids = pt_ids = prj_ids = u_ids = a_ids = all_ids \n\n @receipts = Receipt.select(\"receipts.*, date_trunc('month', date) AS month\" )\n \n if @param_provider == -1\n p_ids = @receipts.where(provider_id: 0).ids\n elsif !params[:receipts_provider].nil? \n p_ids = Provider.find(params[:receipts_provider]).receipts.ids\n end\n\n\n if @only_actual\n a_ids = Receipt.where(payment_id: nil).ids\n end\n\n if !params[:search].nil?\n _prj_ids = Project.where('LOWER(address) like LOWER(?)', '%'+params[:search]+'%').ids\n s_ids = @receipts.where(project_id: _prj_ids).ids\n end\n\n \n prj_ids = @receipts.where(project_id: params[:receipts_project_id]).ids if !params[:receipts_project_id].nil? \n pt_ids = PaymentType.find(params[:receipts_payment_type]).receipts.ids if !params[:receipts_payment_type].nil?\n\n if !params[:receipts_executor_id].nil?\n _prj_ids = User.find(params[:receipts_executor_id]).projects.ids\n u_ids = @receipts.where(project_id: _prj_ids).ids\n end\n\n ids = p_ids & s_ids & pt_ids & prj_ids & u_ids & a_ids\n \n @receipts = @receipts.where(id: ids).order(:date)\n #@sum = @receipts.sum(:sum)\n end", "def point_attribution(user)\n user.rating = 0\n partials = user.pointspersections\n partial = Array.new\n sectionid = Array.new\n\n Section.all.each do |s|\n partial[s.id] = partials.where(:section_id => s.id).first\n if partial[s.id].nil?\n newpoint = Pointspersection.new\n newpoint.points = 0\n newpoint.section_id = s.id\n user.pointspersections << newpoint\n partial[s.id] = user.pointspersections.where(:section_id => s.id).first\n end\n partial[s.id].points = 0\n end\n \n Chapter.all.each do |c|\n \tsectionid[c.id] = c.section_id\n end\n\n user.solvedexercises.includes(:exercise).each do |e|\n if e.correct\n exo = e.exercise\n pt = exo.value\n user.rating = user.rating + pt\n partial[sectionid[exo.chapter_id]].points = partial[sectionid[exo.chapter_id]].points + pt\n end\n end\n\n user.solvedqcms.includes(:qcm).each do |q|\n if q.correct\n qcm = q.qcm\n pt = qcm.value\n user.rating = user.rating + pt\n partial[sectionid[qcm.chapter_id]].points = partial[sectionid[qcm.chapter_id]].points + pt\n end\n end\n\n user.solvedproblems.includes(:problem).each do |p|\n problem = p.problem\n pt = problem.value\n user.rating = user.rating + pt;\n partial[problem.section_id].points = partial[problem.section_id].points + pt\n end\n\n user.save\n Section.all.each do |s|\n partial[s.id].save\n end\n end" ]
[ "0.588194", "0.55688155", "0.55688155", "0.55438113", "0.55015033", "0.54975283", "0.5438975", "0.5419278", "0.5357542", "0.5338416", "0.5338416", "0.5334146", "0.5320993", "0.53050125", "0.5247769", "0.51455414", "0.51272094", "0.50639933", "0.50485283", "0.50030184", "0.50030184", "0.50030184", "0.49835163", "0.4928538", "0.49088293", "0.4902798", "0.4871484", "0.48611978", "0.4851609", "0.48438132", "0.48438132", "0.4840008", "0.48255298", "0.48228794", "0.48228794", "0.48222327", "0.48093978", "0.48079315", "0.4807042", "0.48020202", "0.48020202", "0.48020202", "0.47896895", "0.4786668", "0.47848147", "0.47834378", "0.47806895", "0.4778455", "0.47630575", "0.47630575", "0.4761997", "0.4761997", "0.4761997", "0.4761997", "0.4758012", "0.4755852", "0.4751134", "0.47505116", "0.474483", "0.47433284", "0.47386366", "0.47294316", "0.47284058", "0.47162506", "0.4709676", "0.46985933", "0.4694323", "0.46934795", "0.4688633", "0.4688633", "0.4688633", "0.4688633", "0.46801412", "0.46801412", "0.46673167", "0.46549422", "0.4653106", "0.46529785", "0.46510085", "0.46422777", "0.46371907", "0.46371305", "0.46365097", "0.46353546", "0.4629546", "0.4621284", "0.4620298", "0.46173912", "0.46079636", "0.46035057", "0.4602994", "0.46029866", "0.46024078", "0.45983306", "0.45962217", "0.45954707", "0.4593128", "0.4591176", "0.45856053", "0.45849138", "0.45838335" ]
0.0
-1
Make use of .reduce:
def total(my_array) my_array.reduce( :+ ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_375(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_1(val, _values, result); end", "def _reduce_378(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def reduce\n _reduce = ->(acc, f, xs){\n xs == [] ? acc : _reduce.(f.(acc, xs[0]), f, xs[1..-1])\n }\n\n curry.(->(f, xs) {\n _reduce.(xs[0], f, xs[1..-1])\n })\n end", "def _reduce_120(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_120(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_120(val, _values, result)\n result = [ val[0] ]\n\n result\nend", "def _reduce_1(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_122(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_122(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_122(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_217(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_1(val, _values, result)\n result = val[0]\n\n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_119(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_125(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_586(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_21(val, _values, result); end", "def _reduce_122(val, _values, result)\n result = [ val[0] ]\n\n result\nend", "def _reduce_115(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_115(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_1(val, _values, result)\n result = val[0] \n result\nend", "def _reduce_23(val, _values, result); end", "def _reduce_2(val, _values, result)\n result.append val[1]\n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_379(val, _values, result)\n result = [ val[0], val[1] ]\n\n result\nend", "def _reduce_115(val, _values, result)\n result = [ val[0] ]\n\n result\nend", "def _reduce_28(val, _values, result)\n result = val.join \n result\nend", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_509(val, _values, result)\n result = [val[0]]\n \n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_557(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_531(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_102(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_533(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_1(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_536(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_637(val, _values, result); end", "def _reduce_18(val, _values, result); end", "def _reduce_18(val, _values, result); end", "def _reduce_725(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_37(val, _values, result)\n result = val.join \n result\nend", "def _reduce_433(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_667(val, _values, result); end", "def _reduce_435(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_435(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_102(val, _values, result)\n result = [ val[0] ]\n\n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_248(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_248(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_387(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_1(val, _values, result)\n result = [val[0], val[2]].flatten\n\n result\nend", "def _reduce_669(val, _values, result); end", "def _reduce_109(val, _values, result)\n result << val[1]\n result\nend", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_417(val, _values, result)\n result = [ val[0], val[1] ]\n\n result\nend", "def _reduce_544(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_344(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_17(val, _values, result); end", "def _reduce_434(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_706(val, _values, result); end", "def _reduce_464(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_464(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_464(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_464(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_464(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_547(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_379(val, _values, result); end", "def _reduce_332(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_546(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_595(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_444(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_444(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_444(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_444(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_462(val, _values, result); end" ]
[ "0.75614583", "0.74612826", "0.7459427", "0.7388131", "0.7363048", "0.7363048", "0.73142934", "0.7293636", "0.7264736", "0.7264736", "0.7263576", "0.72578144", "0.72475827", "0.7245283", "0.72423506", "0.7241427", "0.7230415", "0.72184974", "0.7216164", "0.7215201", "0.7215201", "0.7208042", "0.72068065", "0.7206148", "0.7197505", "0.71895194", "0.716098", "0.71584916", "0.71523905", "0.71451956", "0.71451956", "0.7139608", "0.7138519", "0.7138519", "0.71347964", "0.71347964", "0.71126413", "0.71126413", "0.71126413", "0.71126413", "0.71126413", "0.71126413", "0.71126413", "0.71126413", "0.71126413", "0.71099913", "0.71078444", "0.71065754", "0.71022123", "0.7096225", "0.70947796", "0.70947796", "0.709209", "0.7075192", "0.70708936", "0.7068721", "0.7068721", "0.70662385", "0.706513", "0.706513", "0.7048899", "0.70481443", "0.70467764", "0.7045458", "0.70443004", "0.70442694", "0.70442694", "0.7043299", "0.7043078", "0.70414376", "0.7040118", "0.7040118", "0.70391446", "0.70362276", "0.7033011", "0.7032883", "0.7031526", "0.7031526", "0.7028805", "0.7028164", "0.7027173", "0.7024447", "0.7022032", "0.70186013", "0.701505", "0.701325", "0.701325", "0.701325", "0.701325", "0.701325", "0.7011449", "0.70109004", "0.7010549", "0.7008975", "0.70073485", "0.70033187", "0.70033187", "0.70033187", "0.70033187", "0.7002962", "0.7002013" ]
0.0
-1
4. sentence_maker pseudocode make sure all pseudocode is commented out! Input: an array of strings Output: a sentence with all of the words from the array. Steps to solve the problem. define variable result=empty string add space after each element, add next word. 5. sentence_maker initial solution
def sentence_maker(my_sentence) result=my_sentence.shift my_sentence.each { |x| result= result + " " + x.to_s } result=result + "." result.capitalize! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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(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(word_array)\n sentence = word_array.inject(\" \"){|words,element| words += element.to_s + \" \"}\n sentence.strip!.capitalize!\n 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_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 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(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(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(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\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 ( strArray )\r\n\r\n\tanswer = ''\r\n\r\n\tstrArray.each do |thisStr|\r\n\t\tanswer += thisStr.to_s + ' '\r\n\tend\r\n\r\n\tanswer.slice!(answer.length-1)\r\n\r\n\tanswer += '.'\r\n\r\n\treturn answer.capitalize!\r\n\r\nend", "def sentence_maker(array)\n 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(array)\n\tx = 0\n\tsum = \"\"\n\twhile x <= array.length-1\n\t\tif x == array.length-1\n\t\t\tsum += array[x].to_s\n\t\t\tx += 1\n\t\telse \n\t\t\tsum += array[x].to_s + \" \"\n\t\t\tx += 1\n\t\tend\t\n\tend\n\tsum += \".\"\n\tsum.capitalize!\n\treturn sum\nend", "def sentence_maker(array_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(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(array)\n combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\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 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(arr)\n string = \"\"\n i = 1\n while i < arr.length-1\n string += arr[i].to_s + ' '\n i+=1\n end\n sentence = arr[0].capitalize! + \" \" + string + arr[-1] + \".\"\n return sentence\nend", "def sentence_maker(array_of_strings)\n\n sentence = array_of_strings[0].capitalize\n \n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n p sentence + \".\"\n \nend", "def 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(word_array)\n\tsentence = word_array.join(\" \")\n\treturn sentence.capitalize + \".\"\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\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\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(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 (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 solution(sentence)\n sentence_arr = []\n sentence_arr = sentence.split(\" \")\n #puts \"#{sentence_arr}\"\n sentence_str = \"\"\n sentence_arr.reverse_each { |word| sentence_str += \"#{word} \" }\n #puts \"#{sentence_str}\"\n return sentence_str\nend", "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "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 to_sentence(ary)\n # your implementation here\n words = ary\n result = \"\"\n \n while words.length > 0 do\n result << words.shift.to_s\n if words.length > 1\n result << \", \"\n elsif words.length == 1\n result << \" and \" \n end \n end\n puts result\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\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\tsentence += \".\"\n\treturn sentence\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(array)\n\tarray[0].capitalize!\n\tfinalString = array.join(' ')\n\tfinalString = finalString + '.'\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_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(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(array)\n array[0].capitalize!\n array.join(\" \") << \".\"\nend", "def sentence_maker(arr)\n string = \"\"\n arr.each do |i|\n string += i.to_s + ' '\n end\n string[-1] = \".\"\n return string = string.capitalize\nend", "def sentence_maker(array)\n result = array.join(' ')\n result = result.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(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_refactored(words)\n words.first.capitalize!\n words.join(\" \") + \".\"\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 create_sentence(words)\n\n\tstr=\"\"\n\tfor i in 0..words.size-1 do\n\t\tstr+=words[i]\n\t\tstr+=\" \"\n\n\tend\n\nputs str\n\t\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(array)\n array.join(\" \")\n array(0,1).capitalize + array(1..-1) + \".\"\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 sentence_maker(array)\n sentence = array.join(\" \")\n sentence = sentence.capitalize + \".\"\nend", "def sentence_maker (array)\n array[0].capitalize!\n return array.join(\" \") + \".\"\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 sentence = array.join(\" \")\n sentence << \".\"\n sentence.capitalize!\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(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(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 alternate_words(sentence)\n #creates an array with all these symbols as elements\n #iterates throuch each element and makes new sentence\n #equal to the substitution of each of the element\n #which is being iterated in the array\n '!@$#%^&*()-=_+[]:;,./<>?\\\\|'.split(//).each do |char|\n sentence = sentence.gsub(char, ' ')\n end\n #new array called words, made out of splitting\n #string at every \" \" instance\n words = sentence.split\n #new empty array\n #pushes even indexed words into new array\n solution = []\n words.each_with_index do |word, index|\n solution << word if index.even?\n end\n solution\nend", "def sentence_maker(array_of_strings)\n return array_of_strings.join(\" \").capitalize + '.'\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(array_of_strings)\n\n p array_of_strings.join(' ').capitalize + \".\"\n\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 sentence_maker(x)\n\tx.join(\" \")\nend", "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 words(my_sentence)\n length = my_sentence.length\n words_array = []\n i = 0\n word = \"\"\n\n until i == length\n l = my_sentence[i]\n j = my_sentence[i + 1]\n \n if l != \" \" && j != \" \"\n word += l\n elsif l != \" \" && j == \" \"\n word += l\n words_array << word\n word = \"\"\n elsif l == \" \" && j == \" \"\n word += l\n elsif l == \" \" && j != \" \"\n word += l\n words_array << word\n word = \"\"\n end\n \n if i == length - 1\n words_array << word\n end\n\n i += 1\n end\n\n return words_array\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(array)\n string = array.join(' ').capitalize! + '.'\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 solution(sentence)\n return sentence.split.reverse.join(\" \")\nend", "def sentence_maker(array_of_strings)\n array_of_strings.join(' ').capitalize + \".\"\nend", "def alternate_words(sentence) #Not clear why failing test because exact same output\n\tarray = sentence.split(' ')\n\t\n\tnew_array = []\n\tarray.length.times {|index| new_array << array[index] if index.even?}\n\tnew_array.map! {|element| element.gsub(/\\p{P}(?<!')/, \"\")}\n\treturn new_array\nend", "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 typoglycemiaSentence(input)\n words = input.split(' ')\n words.map! { |x| typoglycemiaWord(x) }\n words.join(\" \")\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 array\n array = array.join(' ').capitalize\n return \"#{array}.\"\nend", "def make_a_sentence(words)\n words.join(' ') + \"!\"\nend", "def translate(word)\r\n vowels = \"aeio\".split('').to_a\r\n consonant = \"bcdfghjklmnpqrstuvwxyz\".split('').to_a \r\n answer = []\r\n \r\n while word.split(' ').length == 1 \r\n words = word.split('')\r\n until vowels.include?(words[0])\r\n words = words.rotate(1)\r\n end\r\n words << \"ay\"\r\n return words.join('')\r\n end # one word ^^\r\n \r\n if word.split(' ').length > 1 \r\n words = word.split(' ')\r\n end \r\n words.each do |i|\r\n if vowels.include?(i[0])\r\n i << \"ay\"\r\n answer << i\r\n #return answer\r\n end\r\n end\r\n \r\n words.each do |j|\r\n if consonant.include?(j[0])\r\n j = j.split('').rotate(1).join('') until vowels.include?(j[0])\r\n j = j + \"ay\"\r\n #return j\r\n #j << j #correct format for 1 consonant but it doesnt add to array\r\n answer << j\r\n end\r\n end\r\n \r\n return answer.join(' ')\r\n end", "def translate(sentence)\n\twordsArray = sentence.split(' ')\n\treturnArray = []\n\n\twordsArray.each do |e| \n\t\twhile true\n\t\t\tif e[0].match(/[aeiou]/)\n\t\t\t\te = e + 'ay'\n\t\t\t\treturnArray.push(e)\n\t\t\t\tbreak\n\t\t\telse\n\t\t\t\tif e[0..1].match(/qu/)\n\t\t\t\t\te = e + e[0..1]\n\t\t\t\t\te[0..1] = ''\n\t\t\t\telse\n\t\t\t\t\te = e + e[0]\n\t\t\t\t\te[0] = ''\n\t\t\t\tend\n\t\t\t\t#if e[0..2].match(/sch/)\n\t\t\t\t#puts e\n\t\t\tend\n\t\tend\n\tend\n\n\n\t#puts returnArray\n\treturn returnArray.join(' ')\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(array)\n\tarray.join(\" \").capitalize << \".\"\nend", "def sentence_maker(array)\n\tarray.join(\" \").capitalize << \".\"\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(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.join(\" \").capitalize + \".\"\nend", "def solution(sentence)\n sentence.split.reverse.join(\" \")\nend", "def sentence_maker(words)\n return words.join(\" \").capitalize << \".\"\nend", "def to_sentence(ary)\n\n\tif ary.count > 1\n\t\tlast_word=ary.pop\n\t\tfirst_words=ary.join \", \"\n\t\tnew_sentence=first_words + \" and \" + last_word\n\telse\n\t\tnew_sentence=ary.join\n\tend\n\nend", "def sentence_maker(arr)\n arr[0] = arr[0].capitalize\n return arr.join(\" \") + \".\"\nend", "def array_translate(array)\n repeatedWords = \"\"\n i = 0\n while i < array.length-1\n word = array[i]\n num = array[i+1]\n num.times { repeatedWords += word }\n i += 2\n end\n return repeatedWords\nend", "def spinWords(string)\r\n \r\n var= string.split(' ') #[\"Hey\", \"fellow\", \"warriors\"]\r\n finalarry=[]\r\n var.each do |x|\r\n arry= x.split('') \r\n if arry.count >= 5\r\n finalarry << arry.reverse\r\n else\r\n finalarry<< arry\r\n end\r\n\r\n \r\n end\r\n \r\n lastarry=[]\r\n finalarry.each do |y|\r\n lastarry << y.join(\"\")\r\n \r\n end\r\n \r\n result= lastarry\r\n p result.join(' ')\r\n\r\n\r\n \r\n \r\nend", "def sentence(string)\n string.split.map { |word| single_word(word) }.join(' ')\nend", "def alternate_words(sentence) #Define the method\n '!@$#%^&*()-=_+[]:;,./<>?\\\\|'.split(//).each { |char| sentence = sentence.gsub(char, ' ') } #Substitutes any punctuation in string with a space\n words = sentence.split #Splits the sentence string into an array called words\n answer = [] #Creates a new array for the answer\n words.each_with_index do |word, index| #Loops on each word with an index\n answer << word if index.even? #Appends to the array if the index value is even\n end #Ends the loop\n answer #Returns the answer array\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" ]
[ "0.7697035", "0.7641277", "0.7627471", "0.7609692", "0.7601866", "0.75048286", "0.75048286", "0.75048286", "0.74929297", "0.7455897", "0.74304205", "0.74223495", "0.7393547", "0.7369137", "0.7360743", "0.73604906", "0.73482585", "0.7324801", "0.73005855", "0.7293622", "0.72776836", "0.72472197", "0.72433704", "0.7228587", "0.72168285", "0.72132576", "0.7208861", "0.71912986", "0.71728235", "0.7166663", "0.7165441", "0.71557903", "0.71522295", "0.7147533", "0.71321887", "0.7129684", "0.7125984", "0.71170014", "0.70919794", "0.7087946", "0.70759356", "0.70419246", "0.703779", "0.70270705", "0.7011278", "0.7011278", "0.7009923", "0.7003506", "0.69781595", "0.6974654", "0.69735646", "0.6970769", "0.6966434", "0.6963042", "0.6963014", "0.69547594", "0.69540554", "0.69477695", "0.6942735", "0.6928821", "0.69206476", "0.69191796", "0.6909629", "0.68954176", "0.6885431", "0.6873549", "0.68593585", "0.685708", "0.68342483", "0.6826904", "0.6813819", "0.68047583", "0.68023103", "0.6798904", "0.6795898", "0.6788963", "0.6774924", "0.67697066", "0.6755357", "0.6746045", "0.67391086", "0.67386955", "0.67329377", "0.67314917", "0.6726068", "0.6726068", "0.6709568", "0.6709498", "0.670888", "0.66878814", "0.668745", "0.6684352", "0.6683749", "0.66754335", "0.6659634", "0.6645609", "0.6641423", "0.663652", "0.66348207", "0.66342425" ]
0.688388
65
6. sentence_maker refactored solution
def sentence_maker(my_sentence) result=my_sentence.join(" ") result=result.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\[email protected]_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(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(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_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(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 ([email protected]).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 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(words)\n return words.join(\" \").capitalize << \".\"\nend", "def sentence_maker(strings)\n return strings.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 sentence_maker(words)\n words = words.join(' ').capitalize + \".\"\nend", "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(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 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(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 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 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 sentences(total)\n (1..interpret_value(total)).map do\n words(5..20).capitalize\n end.join('. ')\n end", "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 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 combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\nend", "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 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 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 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.8855467", "0.7072183", "0.7007714", "0.7006025", "0.69965297", "0.6969853", "0.68722224", "0.68363017", "0.6817278", "0.68010527", "0.6796742", "0.67929393", "0.67922384", "0.67889005", "0.67810446", "0.67709756", "0.6766261", "0.6727445", "0.66979486", "0.6686248", "0.66606086", "0.6638643", "0.6637014", "0.66337794", "0.66222805", "0.65922797", "0.658729", "0.6549272", "0.6548174", "0.65399283", "0.6525441", "0.65221035", "0.6521562", "0.65165716", "0.64802164", "0.6467466", "0.6467466", "0.6467466", "0.6462705", "0.6456898", "0.64401495", "0.6434835", "0.6432043", "0.64131993", "0.64110476", "0.6399056", "0.6390183", "0.6378818", "0.63731194", "0.6359801", "0.6356304", "0.63338095", "0.63076544", "0.6306873", "0.6296538", "0.6284758", "0.62836725", "0.6276678", "0.6275537", "0.6273086", "0.62712675", "0.62700385", "0.62659913", "0.62477773", "0.6243484", "0.6232906", "0.622537", "0.6221286", "0.6219013", "0.62175745", "0.6217362", "0.6213411", "0.6208717", "0.6199351", "0.61981803", "0.61854017", "0.6184038", "0.61782426", "0.6177084", "0.61729944", "0.61728716", "0.6167097", "0.6164619", "0.6158581", "0.6157904", "0.6149027", "0.6144488", "0.61406726", "0.6138679", "0.6130376", "0.61276054", "0.61269116", "0.61187065", "0.6118538", "0.61165863", "0.61068106", "0.61028457", "0.6101225", "0.60985917", "0.60912734" ]
0.65363246
30
before_action :set_resource, only: %i[show update destroy] GET /contacts
def index authorize @model, :index? # @collection = @model.all render json: Oj.dump( collection: @model.all ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_contact\n @category = \"Contact\"\n @contact = resource_owner.contacts.find(params[:id])\n end", "def show\n @contact_action = ContactAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact_action }\n end\n end", "def resources\n end", "def show\n @contactaction = Contactaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @contactaction }\n end\n end", "def show\n if not current_user.nil?\n @contacts = Contact.all\n else\n redirect_to contactp_path\n end\n end", "def show\n @contact = contacts.find(params[:id])\n end", "def contacts\r\n\r\n end", "def contacts\r\n @contact = @customer.contact_people.find_by_id params[:id]\r\n \r\n # Delete contact\r\n if @contact && params[:method] == \"delete\"\r\n @store_user.my_account_log(@contact,\"Delete Contact #{@contact.name}\")\r\n @contact.destroy\r\n @customer.update_ax( :contacts => [@contact] )\r\n redirect_to :id => nil\r\n end\r\n \r\n # Add or update contact\r\n if request.post? && params[:contact]\r\n @contact ||= @customer.contact_people.build\r\n @contact.attributes = params[:contact]\r\n if @contact.save\r\n redirect_to :id => nil\r\n else\r\n @customer.contact_people.delete @contact\r\n render\r\n end\r\n \r\n # Synchronize customer\r\n @customer.update_ax( :contacts => [@contact] ) if @contact.errors.empty?\r\n @store_user.my_account_log(@contact,\"Add or Update Contact #{@contact.name}\")\r\n end\r\n end", "def index\n if not current_user.nil?\n @contacts = Contact.all\n else\n redirect_to create_contant\n end\n\n end", "def show\n @contact = current_user.contacts.find(params[:id])\n\n end", "def show\r\n\t\t@contact = current_user.contacts.find(params[:id])\r\n\tend", "def set_contact\n if params[:action] == \"update\"\n @contact = Contact.find(params[:format]) \n else\n @contact = Contact.find(params[:id])\n end\n end", "def show\n @contact = Contact.find(params[:id])\n @company = @contact.company\n @company = Company.new if !@company\n @company_path_ = @company.id ? company_path(@company) : \" \"\n restrict_access(\"contacts\") if @contact.firm_id != @firm.id\n end", "def set_contact\n @contact = current_user.contacts.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n\n end", "def set_contact\n @contact = Contact.find(params[:contact_id])\n end", "def set_contact\n @contact = Contact.find(params[:contact_id])\n\nend", "def show\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render \"show.html.erb\", :layout => false }\n end\n end", "def index\n @contacts = current_company.contacts\n respond_to do |format|\n format.xml { render :xml => @contacts }\n format.json { render :json => @contacts }\n end\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def show\r\n if verif_admin\r\n\t @contact = Contact.find(params[:id])\r\n\t \r\n\t respond_to do |format|\r\n\t\t format.html # show.html.erb\r\n\t\t format.xml { render :xml => @contact }\r\n\t end\r\n else\r\n\t redirect_to :controller => 'admins', :action => 'index'\r\n end \r\n end", "def set_resource\n @resource = Company.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:contact_id])\n end", "def show\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find_by_id(params[:id])\n if(@contact == nil)\n redirect_to(contacts_path,notice: 'Ingen kontakt hittades.')\n end\n end", "def index\n ignore = contact_emails_rejected\n @contacts = resource_owner.contacts.reject do |c|\n ignore.include?(c.emailaddress.downcase)\n end.each{ |c| authorize c }\n session[:ret_url] = contacts_path\n end", "def show\n @users = User.all\n @followups = Followup.all\n @followup = Followup.new\n if params[:controller] == \"contacts\" && params[:action]==\"show\"\n @edit_contact = Contact.find(params[:id])\n session[:contact_id] = @edit_contact.id\n else\n @edit_contact = Contact.find(params[:format])\n render 'contacts/edit'\n end\n end", "def show\n #@contact = Contact.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact }\n end\n end", "def show\n @contact_list = ContactList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contact_list }\n end\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def set_contact\n @contact = Contact.friendly.find(params[:id])\n end", "def set_contact\n @contact = Contact.find(params[:id])\n end", "def show\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cust_contact }\n end\n end", "def show\n instance_exec(&resource.before_actions[:show]) if resource.before_actions[:show]\n end", "def resources; end", "def resources; end", "def set_contact\n\t\t\t@contact = Contact.find(params[:id])\n\t\tend", "def edit\r\n\t\t@contact = current_user.contacts.find(params[:id])\r\n\tend", "def show\n @contact = Contact.find(params[:id])\n render :json => { :success => true, :message => \"Show Contacts\", :contact => @contact }\n # respond_to do |format|\n # format.html # show.html.erb\n # format.xml { render :xml => @contact }\n # end\n end", "def set_contact\n\t @contact = Contact.find(params[:id])\n\t end", "def show\n @contact = Contact.find(params[:contact_id])\n @property = Property.find(params[:id])\n authorize @property\n end" ]
[ "0.7048773", "0.64073664", "0.63425845", "0.63355905", "0.6326527", "0.63066614", "0.62955564", "0.6271615", "0.62338173", "0.6223006", "0.61480844", "0.6124371", "0.6107699", "0.6092012", "0.6057428", "0.60533947", "0.6043033", "0.60406184", "0.6031699", "0.6028119", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.6024871", "0.60215867", "0.599873", "0.59944683", "0.5988857", "0.5971052", "0.59710443", "0.59668034", "0.5946759", "0.5940652", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934661", "0.5934267", "0.59337115", "0.5916302", "0.5896803", "0.5893714", "0.5893714", "0.5891703", "0.5886588", "0.5877394", "0.58767796", "0.5872659" ]
0.0
-1
Row explanation: [ "language", prs ] Output: [ ["Ruby", 3], ... ["CSS", 1] ]
def language_prs languages.map do |language| [language.fetch("language").name, language.fetch("prs")] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row\n [\n \"Theme\",\n \"Question\",\n { value: \"Average Score\", alignment: :right },\n { value: \"No. Scores Submitted\", alignment: :right }\n ]\n end", "def reformat_languages(languages)\n new_hash = {}\n java_style_array = Array.new\n\n languages.each do |style, language_data| # :oo , :ruby\n language_data.each do |language_name, language_name_value| # :ruby , {type =>}\n if language_name == :javascript\n java_style_array << style\n end\n language_name_value.each do |attribute, value|\n if language_name == :javascript\n new_hash[language_name] = {type: value, style: java_style_array}\n else\n new_hash[language_name] = {type: value, style: [style]}\n end\n\n end\n end\n end\n puts new_hash\n return new_hash\nend", "def alt_ranks\n { Division: \"Phylum\" }\n end", "def languages\n h2 :languages\n p (langs = @record.languages).empty? ? '-' : langs.map(&:to_s).join(', ')\n gap\n end", "def row(question)\n [\n question.theme,\n Utilities.word_wrap(question.text, CHARACTER_LIMIT),\n average_score(question),\n { value: question.scores.size, alignment: :right }\n ]\n end", "def number_of_programming_languages(text_array)\n resume_as_array = resume_to_array(text_array)\n result = 0\n @programming_languages.each do |p|\n if resume_as_array.include?(p)\n result += 1\n end\n end\n return result\nend", "def row_cells_to_text_columns(table_row)\n table_row.cells.map do |cell|\n # Join paragraphs into a String using a space delimiter.\n cell_paragraphs(cell).join(' ')\n end\n end", "def highlight_by_language(text, language)\n ::CodeRay.scan(text, language).html(:line_numbers => :inline, :wrap => :span)\n end", "def column_styles\n # [\n # {:name => 'general', :column => 0},\n # {:name => 'general', :column => 1},\n # {:name => 'general', :column => 2}\n #]\n []\n end", "def get_numpr_prop_from_ast(ast, key)\n values = []\n ast.grep(Sablon::HTMLConverter::Paragraph).each do |para|\n numpr = para.instance_variable_get('@properties')['numPr']\n numpr.each { |val| values.push(val[key]) if val[key] }\n end\n values\n end", "def all\n @raw.map { |l| l['language'] }\n end", "def context_type_result_row\n ContextTypeDef.new(\n :result_row,\n [\n /:\\s+(?<rank>(\\d{1,3}|FG|\\s*))\\s*:\\s+(?<swimmer>.{4,27})\\s*:\\s+(?<year>\\d{2})\\s*:(?<team>.{4,26})\\s*:\\s+(?<timing>((\\d{1,2}.)?\\d{2}.\\d{2})|ritirato|squalif.)\\s*:/i\n ],\n :category_header # parent context\n )\n end", "def row\n [\n {\n value: \"Single Select Question Values (submitted surveys only)\",\n colspan: COLUMN_SPAN,\n alignment: :center\n }\n ]\n end", "def get_row_style(row)\n if @row_styles[(row+1).to_s].nil?\n @row_styles[(row+1).to_s] = {}\n @row_styles[(row+1).to_s][:style] = '0'\n @workbook.fonts['0'][:count] += 1\n end\n return @row_styles[(row+1).to_s][:style]\n end", "def context_type_result_row\n ContextTypeDef.new(\n :result_row,\n [\n /(\\s{3,20}NP|\\s{3,20}SQ|\\s{3,20}RIT|(\\d{1,2}')?\\d\\d.\\d\\d\\s*\\d{3,4}[\\,|\\.]\\d{1,2}\\s*(RI|RE|RM)?)(\\r\\n|\\n|$|\\Z)/i\n ],\n :individual_category_header # parent context\n )\n end", "def languages\n documents.collect(&:sections).flatten.collect(&:examples).flatten.map(&:language).compact.uniq\n end", "def to_a(newlines: false, phrases: true)\n grid[:rows]\n .reverse\n .map { |row|\n grid[:columns].map do |column|\n render(\n phrases ? words_inside(column, row) : chars_inside(column, row),\n newlines: newlines\n )\n end\n }\n end", "def to_a(newlines: false, phrases: true)\n grid[:rows]\n .reverse\n .map { |row|\n grid[:columns].map do |column|\n render(\n phrases ? words_inside(column, row) : chars_inside(column, row),\n newlines: newlines\n )\n end\n }\n end", "def inline_translations_for(language)\n translations_for(language, -50).sort_by{|t| t.precedence}\n end", "def progress_tex(type, article)\n load_return = YAML.load_file(\"./config/format/#{type}.yml\")\n return_fields = load_return['return']\n res_arr = []\n return_fields.each do |field|\n elemenent_arr = []\n elemenent_arr << field['text']\n elemenent_arr << article.index(field['text']) + field['text'].length\n res = field['end_text'] ? article.index(field['end_text']) - 1 : -1\n elemenent_arr << res\n res_arr << elemenent_arr\n end\n res_arr\n end", "def reformat_languages(languages)\n new_hash = {}\n arraystyles = []\n languages.each do |styles, all_info|\n\n all_info.each do |programming_language, info|\n puts info\n new_hash[programming_language] = info\n new_hash[programming_language][:style] = [styles]\n end\n end\n puts new_hash\nend", "def rows\n @columns.each do |column|\n @rows << Array.new(@columns.size) do |i|\n \"#{column}#{i + 1}\"\n end\n end\n @rows\n end", "def languages\n array = []\n details.css(\"div.txt-block a[href^='/language/']\").each do |node|\n array << {:code => node['href'].clean_href, :name => node.text.strip}\n end\n\n array\n end", "def handle_language(langcode)\n df('041', '0', ' ').with_sfs(['a', langcode])\n end", "def languages\n grouped_language_files.map do |language, stats|\n additions = summarize(stats, :additions)\n deletions = summarize(stats, :deletions)\n net = summarize(stats, :net)\n LanguageSummary.new(language, additions, deletions, net, added_files, deleted_files, modified_files)\n end\n end", "def reformat_languages(languages)\n\tnewHash = {}\n\n\tlanguages.each do |style, languageHash|\t\n\t\t#style = :oo, :functional\n\t\tlanguageHash.each do |language, type|\n\t\t\tnewHash[language] = type\n\t\t\t#stop here, add :style in another enumerator\t\t\t\n\t\tend\n\tend\n\n\t#create new hash element for each language\n\tnewHash.collect do |language, info|\n\t\tinfo[:style] = []\n\tend\n\n\t#populate each :style array\n\tlanguages.each do |style, languageHash|\n\t\tlanguageHash.each do |name, type|\n\t\t\tnewHash.each do |language, info|\n\t\t\t\tif language == name\n\t\t\t\t\tinfo[:style] << style\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn newHash\nend", "def reformat_languages(languages)\nnew_hash = Hash.new\n# another_hash = Hash.new\nlanguages.each do |hash_key, hash_data|\n hash_data.each do |language_name, types|\n new_hash[language_name] = types\n new_hash[language_name][:style] = [hash_key]\n end\n new_hash[:javascript][:style] << :oo\n end\n new_hash\nend", "def languages\n ['HTML', 'Javascript', 'CSS', 'PHP', 'ERB', 'Ruby', 'Objective-C']\n end", "def render_row row\n if row == :separator\n separator\n else\n Y + row.map_with_index do |cell, i|\n render_cell(cell, row_to_index(row, i))\n end.join(Y) + Y\n end\n end", "def paragraph_style_mappings\n {\n 'header-1' => 'header1',\n 'header-2' => 'header2',\n 'header-3' => 'header3',\n 'hr' => 'horizontalRule',\n 'p.normal' => 'normal',\n 'p.test' => 'paraTest',\n }\n end", "def _parse_set_rarity row\n ret_ary = []\n sets_ary = row./('td[2]').children.first.to_s.strip.split(', ')\n sets_ary.each do |set_str|\n if set_str.include? 'Mythic Rare'\n set_str.sub! ' Mythic Rare', ''\n ret_ary << [set_str, 'Mythic Rare']\n next\n end\n\n tmp = set_str.split(' ')\n ret_ary << [tmp.pop, tmp.join(' ')].reverse\n end\n\n ret_ary\n end", "def context_type_result_row\n ContextTypeDef.new(\n :result_row,\n [\n /(Ritir.*|Squal.*|\\d{1,2}'\\d\\d\"\\d\\d)( {1,6})+\\d{1,4}[\\,|\\.]\\d\\d(\\r\\n|\\n|$|\\Z)/i\n ],\n :category_header # parent context\n )\n end", "def pascal_row(row)\n ([0] + row).zip(row + [0]).collect { |a, b| a + b }\nend", "def alternative_titles\n array = []\n release_info.css('#akas').css('tr').map do |row|\n cells = row.css('td')\n array << { :title => cells.last.text.strip, :comment => cells.first.text.strip }\n end\n\n array\n end", "def eval_lecture_head\n b = \"\"\n b << \"\\\\kurskopf{#{title.escape_for_tex}}\"\n b << \"{#{profs.map { |p| p.fullname.escape_for_tex }.join(' / ')}}\"\n b << \"{#{returned_sheets}}\"\n b << \"{#{id}}\"\n b << \"{#{t(:by)}}\\n\\n\"\n unless note.nil? || note.strip.empty?\n b << RT.small_header(I18n.t(:note))\n b << note.strip\n b << \"\\n\\n\"\n end\n b\n end", "def row_options(question)\n question.question_cells.select { |cell| cell.type =~ /Rating|TextBox|Comment/ }.collect do |cell|\n [cell.row, cell.row]\n end\n end", "def pariculars\n\t\t[\"Concentration\", \"Concept\", \"Participation\", \"Completion of Task\"]\n\tend", "def languages_by_day(days=30)\n joins(:code_cell, :notebook)\n .where('executions.updated_at > ?', days.days.ago)\n .select([\n 'count(distinct(notebooks.id)) AS count',\n 'notebooks.lang AS lang',\n 'DATE(executions.updated_at) AS day'\n ].join(','))\n .group('lang, day')\n .order('day, lang')\n .group_by(&:lang)\n .map {|lang, entries| [lang, entries.map {|e| [e.day, e.count]}.to_h]}\n .to_h\n end", "def get_issue_numbers_and_titles(section) \n issues_titles = []\n section.split(/\\n/).each do |line|\n issue = line[/\\* \\[#(.*?)\\]\\(/m, 1]\n title = line[/\\)\\: (.*?) - \\[@/m, 1].gsub(/\\\"/, \"\") # strip double quotations from pr titles\n issues_titles.push( { \"issue\" => issue, \"title\" => title } ) if issue && !issue.empty? && title && !title.empty?\n end \n return issues_titles\nend", "def row(percentage)\n [\n { value: \"Participation Percentage\", colspan: COLUMN_SPAN },\n {\n value: formatted_percentage(percentage),\n alignment: :right,\n colspan: COLUMN_SPAN\n }\n ]\n end", "def column_headings\n {\n :line_count => \"Lines\",\n :loc_count => \"LOC\",\n :file_count => \"Classes\",\n :method_count => \"Methods\",\n :average_methods => \"M/C\",\n :method_length => \"LOC/M\",\n :class_length => \"LOC/C\"\n }\n end", "def marc_languages(spec = \"008[35-37]:041a:041d\")\n translation_map = Traject::TranslationMap.new(\"marc_languages\")\n\n extractor = MarcExtractor.new(spec, :separator => nil)\n\n lambda do |record, accumulator|\n codes = extractor.collect_matching_lines(record) do |field, spec, extractor|\n if extractor.control_field?(field)\n (spec.bytes ? field.value.byteslice(spec.bytes) : field.value)\n else\n extractor.collect_subfields(field, spec).collect do |value|\n # sometimes multiple language codes are jammed together in one subfield, and\n # we need to separate ourselves. sigh.\n unless value.length == 3\n # split into an array of 3-length substrs; JRuby has problems with regexes\n # across threads, which is why we don't use String#scan here.\n value = value.chars.each_slice(3).map(&:join)\n end\n value\n end.flatten\n end\n end\n codes = codes.uniq\n\n translation_map.translate_array!(codes)\n\n accumulator.concat codes\n end\n end", "def extract_code_language!(attr); end", "def inspect\n [self,(\"(#{pretty_score})\" if @score),(\"(language:#{language})\" if language)].compact.join(\" \")\n end", "def language_interpreter\n # Do not show this block in CYA if the user didn't yet reach this step\n # (we know because the array will be `nil` in that case).\n return [] if arrangement.language_options.nil?\n\n AnswersGroup.new(\n :language_interpreter,\n [\n Answer.new(\n :language_interpreter,\n arrangement.language_options.include?(LanguageHelp::LANGUAGE_INTERPRETER.to_s).to_s\n ),\n FreeTextAnswer.new(:language_interpreter_details, arrangement.language_interpreter_details),\n Answer.new(\n :sign_language_interpreter,\n arrangement.language_options.include?(LanguageHelp::SIGN_LANGUAGE_INTERPRETER.to_s).to_s\n ),\n FreeTextAnswer.new(:sign_language_interpreter_details, arrangement.sign_language_interpreter_details),\n Answer.new(\n :welsh_language,\n arrangement.language_options.include?(LanguageHelp::WELSH_LANGUAGE.to_s).to_s\n ),\n FreeTextAnswer.new(:welsh_language_details, arrangement.welsh_language_details),\n ],\n change_path: edit_steps_attending_court_language_path\n )\n end", "def row_name_columns\n [:appendix, :taxon, :term, :unit, :country]\n end", "def sparkline_data\n @p = live_problems\n data = @p.where(:difficulty => ['V0', 'V0+', 'V0-']).count.to_s\n (1..16).each do |n|\n data << \",\" << @p.where(:difficulty => [\"V#{n}\", \"V#{n}+\", \"V#{n}-\"]).count.to_s\n end\n return data\n end", "def _parse_rules_text row\n text = ''\n row./('td[2]').children.each do |block|\n if block.name == 'br'\n text << \"\\n\"\n next\n end\n\n text << block.to_s.strip \n end\n\n text\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\nSQL\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"SELECT pr.title, SUM(pl.amount)\n FROM projects pr\n JOIN pledges pl\n ON pr.id = pl.project_id\n GROUP BY(pr.title);\"\nend", "def build_dialog_from_csv_rows(rows, lang_index)\n return Array.new(rows.size - 1) do |i|\n rows[i + 1][lang_index].to_s.gsub('\\nl', \"\\n\")\n end\n end", "def language\n values = super\n values = MetadataHelper.ordered( ordered_values: self.language_ordered, values: values )\n return values\n end", "def language\n values = super\n values = MetadataHelper.ordered( ordered_values: self.language_ordered, values: values )\n return values\n end", "def matrix(text)\n row1, row2, row3 = rows_as_char_arrays(text)\n row1.zip(row2, row3)\n end", "def content (data)\n string = ''\n data.each_index do |i|\n row = data[i]\n row.each_index do |j|\n column = row[j]\n column ||= {:value => nil, :color => nil}\n width = max_width data, j\n alignment = (@align[j] or @default_align)\n value = Aligner.align alignment, column[:value].to_s, width\n value = Yummi.colorize value, column[:color] unless @no_colors\n string << value\n string << (' ' * @colspan)\n end\n string.strip! << $/\n end\n string\n end", "def languages(candidate)\n candidate[:languages].include?('Python') ||\n candidate[:languages].include?('Ruby')\nend", "def resolve_implicit_levels par\n par['characters'].each {|char|\n embedding_level=char['level']\n bidiType=char['bidiType']\n case bidiType\n when 'L'\n char['level']=embedding_level + 1 if embedding_level.odd?\n when 'R'\n char['level']=embedding_level + 1 if embedding_level.even?\n when 'AN','EN'\n char['level']=embedding_level + (embedding_level.odd? ? 1 : 2)\n end\n char['level']=0 if char['value']==0x0A or char['value']==0x0D\n }\n end", "def locales_from_xlsx_sheet_row row\n locales = []\n row.each_with_index do |cell, i|\n if i > 0\n locales.push(cell.downcase)\n end\n end\n locales\n end", "def assemble_preferences_rows\n PostingPosition.joins(:position).where(posting: @posting).order(\n :'positions.position_code'\n ).pluck('positions.position_code', 'positions.position_title')\n .map do |(code, title)|\n { text: (title.blank? ? code : \"#{code} - #{title}\"), value: code }\n end\n end", "def ui_columns\n text = name\n text += \"\\n\" + notes if notes\n\n res = [id.to_s.blue, quantity.to_s.light_blue, text]\n if quantity > 1\n # we need to print unit weight and total weight\n value = \"$#{price}\\n$#{price*quantity}\"\n burden = \"#{weight}lbs\\n#{weight*quantity}lbs\"\n else\n value = \"$#{price}\"\n burden = \"#{weight}lbs\"\n end\n res << value\n res << burden\n \n status = []\n status.push('Purchased'.red) if was_bought\n status.push('Magical'.on_blue) if is_magic\n status.push('Was Dropped'.white.on_red) if ! is_had\n res << status.join(\"\\n\")\n res\n end", "def each_row_as_native\n @rows.each { |row| yield(Array.new(row.size) { |i| @columns[i].type.translate(row[i]) }) }\n self\n end", "def format_paragraph(misc, rmgroup)\n reading_type = Array[\"Pinyin\", \"Korean\", \"Onyomi\", \"Kunyomi\"]\n pinyin_readings = Array[]\n korean_readings = Array[]\n korean_roman_readings = Array[]\n onyomi_readings = Array[]\n kunyomi_readings = Array[]\n reading_lookup = { \"pinyin\" => pinyin_readings, \"korean_r\" => korean_roman_readings, \"korean_h\" => korean_readings, \"ja_on\" => onyomi_readings, \"ja_kun\" => kunyomi_readings }\n output = \"<pre><code>\"\n \n output << \"Stroke count: \" + misc.at_xpath('stroke_count').content + \"\\\\n\"\n \n # Nicely format and handle potential non-existence and duplicates\n # of readings in pinyin, hangul, Japanese onyomi and kunyomi\n readings = rmgroup.xpath(\"reading\")\n if readings != nil\n for i in 0 ... readings.size \n reading_lookup[readings[i].attributes[\"r_type\"].value].push(readings[i].content)\n end\n \n # writing done here to avoid writing blank entries\n if pinyin_readings.size > 0\n output << \"Pinyin: \" + pinyin_readings.join(',') + \"\\\\n\"\n end\n if korean_readings.size > 0\n output << \"Korean: \" + korean_readings.join(',') + \"\\\\n\"\n end\n if onyomi_readings.size > 0\n output << \"Onyomi: \" + onyomi_readings.join(',') + \"\\\\n\"\n end\n if kunyomi_readings.size > 0\n output << \"Kunyomi: \" + kunyomi_readings.join(',') + \"\\\\n\"\n end\n end\n \n # Nicely format and handle potential non-existence and duplicates\n # of meanings in English\n meanings = rmgroup.xpath(\"meaning\")\n if not meanings.nil? \n meanings_output = Array[]\n for meaning in meanings\n if meaning.attributes[\"m_lang\"].nil? # ignore French, Spanish, and Portugese for now\n meanings_output.push(meaning.content)\n end\n end\n \n # writing done here to avoid having \"Meanings: \" and no meanings\n if meanings_output.size > 0\n output << \"Meanings: \" + meanings_output.join(\", \")\n end\n end\n \n \n output << \"</code></pre>\"\n return output\nend", "def names\n \n # COMBINE split names into composite names for these rows\n composites = [\n {:row => :sa, :version => /^[6-8]/, :field => [:contributor, :donor_candidate]},\n {:row => :sb, :version => /^[6-8]/, :field => [:payee, :beneficiary_candidate]},\n {:row => :sc, :version => /^[6-8]/, :field => [:lender, :lender_candidate]},\n {:row => :sc1, :version => /^[6-8]/, :field => [:treasurer, :authorized]},\n {:row => :sc2, :version => /^[6-8]/, :field => :guarantor},\n {:row => :sd, :version => /^[6-8]/, :field => :creditor},\n {:row => :se, :version => /^[6-8]/, :field => [:payee, :candidate]},\n {:row => :sf, :version => /^[6-8]/, :field => [:payee, :payee_candidate]},\n {:row => :f3p, :version => /^[6-8]/, :field => :treasurer},\n {:row => :f3p31, :version => /^[6-8]/, :field => :contributor},\n ]\n # SPLIT composite names into component parts for these rows\n components = [\n {:row => :sa, :version => /^3|(5.0)/, :field => :contributor},\n {:row => :sa, :version => /^[3-5]/, :field => :donor_candidate},\n {:row => :sb, :version => /^3|(5.0)/, :field => :payee},\n {:row => :sb, :version => /^[3-5]/, :field => :beneficiary_candidate},\n {:row => :sc, :version => /^[3-5]/, :field => [:lender, :lender_candidate]},\n {:row => :sc1, :version => /^[3-5]/, :field => [:treasurer, :authorized]},\n {:row => :sc2, :version => /^[3-5]/, :field => :guarantor},\n {:row => :sd, :version => /^[3-5]/, :field => :creditor},\n {:row => :se, :version => /^[3-5]/, :field => [:payee, :candidate]},\n {:row => :sf, :version => /^[3-5]/, :field => [:payee, :payee_candidate]},\n {:row => :f3p, :version => /^[3-5]/, :field => :treasurer},\n {:row => :f3p31, :version => /^[3-5]/, :field => :contributor},\n ]\n \n composites.each { |c| combine_components_into_name(c) }\n components.each { |c| split_name_into_components(c) }\n \n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"SELECT pr.title, sum(pl.amount) FROM projects pr join pledges pl ON pr.id = pl.project_id GROUP BY pr.title ORDER BY pr.title;\"\nend", "def extract_code_language(attr); end", "def questionary_row_template\n result= []\n @items.each do |item|\n data= Caracal::Core::Models::TableCellModel.new margins: { top: 100, bottom: 0, left: 10, right: 10 } do\n unless item.nil?\n p \"Questionary: #{item[0]}\", bold: true\n p \"Full name: #{item[1]}\"\n p \"E-mail: #{item[12]}\"\n p\n p \"Phone: #{item[17]} #{item[18]}\"\n p\n\n addr_empty= item[16].nil? and item[13].nil? and item[14].nil? and item[15].nil?\n p \"Address: #{item[16]} #{item[13]}, #{item[14]} #{item[15]}\" unless addr_empty\n p \"Address:\" if addr_empty\n p\n p\n end\n end\n result << data\n end\n result\n end", "def published_assessment_titles\n titles =[]\n published_table = frm.div(:class=>\"tier2\", :index=>2).table(:class=>\"listHier\", :index=>0)\n 1.upto(published_table.rows.size-1) do |x|\n titles << published_table[x][1].span(:id=>/publishedAssessmentTitle/).text\n end\n return titles\n end", "def context_type_ranking_row\n ContextTypeDef.new(\n :ranking_row,\n [\n /\n (?<=\\s)\n (?<decimal_score>\n (?<thousand>\\d{1,3}\\.)*\\d{1,3}\n (?<decimals>[\\,|\\.]\\d\\d)\n (?<endline>\\s+|\\r\\n|\\n|$|\\Z)\n (?!\\D+)\n )|\n (?<score_comma>\n \\s+\\d+[\\,|\\.]\\d\\d\n (?!\\s\\s\\d\\d\\s\\s)\n )|\n (?<score_stats>\n \\s+\\d+[\\,|\\.]\\d\\d\n (?=\\s\\s\\d\\d\\s\\s)\n )|\n (?<=\\s\\s\\s\\s)(?<integer_score>\n \\s+\\d+(?=\\r|\\n|$|\\Z)\n )\n /iux\n # This one looks for a siplyfied version of the ranking score:\n# /\\s+(((\\d{1,3}\\.)*\\d{1,3}|\\d{1,})([\\,|\\.]\\d\\d)?)(\\s+|\\r\\n|\\n|$|\\Z)/i\n ],\n :team_ranking\n )\n end", "def context_type_ranking_row\n ContextTypeDef.new(\n :ranking_row,\n [\n /\n (?<=\\s)\n (?<decimal_score>\n (?<thousand>\\d{1,3}\\.)*\\d{1,3}\n (?<decimals>[\\,|\\.]\\d\\d)\n (?<endline>\\s+|\\r\\n|\\n|$|\\Z)\n (?!\\D+)\n )|\n (?<score_comma>\n \\s+\\d+[\\,|\\.]\\d\\d\n (?!\\s\\s\\d\\d\\s\\s)\n )|\n (?<score_stats>\n \\s+\\d+[\\,|\\.]\\d\\d\n (?=\\s\\s\\d\\d\\s\\s)\n )|\n (?<=\\s\\s\\s\\s)(?<integer_score>\n \\s+\\d+(?=\\r|\\n|$|\\Z)\n )\n /iux\n # This one looks for a siplyfied version of the ranking score:\n# /\\s+(((\\d{1,3}\\.)*\\d{1,3}|\\d{1,})([\\,|\\.]\\d\\d)?)(\\s+|\\r\\n|\\n|$|\\Z)/i\n ],\n :team_ranking\n )\n end", "def reformat_languages(languages)\n new_hash = {}\n\n languages.each do |oo_or_functional, language_hash|\n language_hash.each do |language, attribute_hash|\n attribute_hash.each do |attribute, str_val|\n if new_hash[language].nil?\n new_hash[language] = {}\n end\n\n new_hash[language][:style] ||= []\n new_hash[language][:style] << oo_or_functional\n if new_hash[language][attribute].nil?\n new_hash[language][attribute] = str_val\n end\n end\n end\n end\n\n new_hash\n end", "def rows(parts, fields = [\n [\n \"Sub Assembly\",\n \"sub_assembly\" \n ],\n [ \n \"Part Name\", \n \"part_name\"\n ],\n [ \n \"Quantity\", \n \"quantity\"\n ],\n [ \n \"Width\",\n \"width\"\n ],\n [ \n \"Length\",\n \"length\"\n ],\n [ \n \"Thickness\", \n \"thickness\"\n ],\n [ \n \"Material\",\n \"material\"\n ]\n ])\n \n # TODO: Get the order of items in a list to be configurable somehow...\n \n html = <<-EOS\n \n <table>\n <thead>\n <tr>\n \n EOS\n \n # List each heading for the coumns based on the `fields` parameter.\n fields.each { |f|\n \n html += \"<th>#{f[0].to_s}</th>\"\n \n }\n\n \n html += <<-EOS\n \n </tr>\n </thead>\n <tbody>\n \n EOS\n \n if parts != nil\n \n all_rows = ''\n \n parts.each { |p| \n \n all_rows += row(p, fields)\n \n }\n \n puts \"[HTMLRenderer.rows] all_rows: #{all_rows}\" if $cutlister_debug\n \n html += all_rows.to_s\n \n else\n \n UI.messagebox \"Sorry, there are no parts to cutlist...\", MB_OK\n \n end\n \n html += <<-EOS\n \n </tbody>\n </table>\n \n EOS\n \n html += section_footer(parts)\n \n html\n \n end", "def experimental_layout(string, matrix)\n matrix.each_with_index do |row, idx|\n if row.include? string\n matrix = matrix[idx..(idx + 8)] \n # Removing rows and columns from 96 well format\n arr = matrix[1..matrix.length].map do |row|\n if string == 'sample_id_mat'\n row[1..row.length].map {|i| i.to_i}\n else\n row[1..row.length].map {|i| i}\n end\n end\n return arr\n end\n end\n end", "def context_type_ranking_row\n ContextTypeDef.new(\n :ranking_row,\n [\n /(?<rank>\\s*(\\d{1,3}\\))?)\\s+(?<team_code>\\d{3})\\s+(?<team>.{4,26})\\s+(?<score>(\\d{1,6}|\\s+))\\s*(?<medals>(\\d{1,3}|-)\\s+(\\d{1,3}|-)\\s+(\\d{1,3}|-))/i\n ],\n :team_ranking\n )\n end", "def assemble_preferences_rows\n PostingPosition.joins(:position).where(posting: @posting).pluck(\n 'positions.position_code',\n 'positions.position_title'\n ).map do |(code, title)|\n { text: (title.blank? ? code : \"#{code} - #{title}\"), value: code }\n end\n end", "def reformat_languages(languages)\r\n new_languages_hash = {}\r\n \r\n languages.each do |style_key, language_val|\r\n language_val.each do |language_key, type_val|\r\n type_val.each do |type_key, string_val|\r\n \t#new_languages_hash[language_key] ||= {}\r\n \tif new_languages_hash[language_key].nil?\r\n \t\tnew_languages_hash[language_key] = {}\r\n \tend\r\n \tnew_languages_hash[language_key][:style] ||= []\r\n \tnew_languages_hash[language_key][:style] << style_key\r\n \tif new_languages_hash[language_key][type_key].nil?\r\n \t\tnew_languages_hash[language_key][type_key] = string_val\r\n \tend \r\n end\r\n end\r\n end\r\n new_languages_hash\r\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n %q(\n SELECT pr.title, \n SUM(pl.amount) AS pledge_amount\n FROM projects pr\n JOIN pledges pl ON pr.id = pl.project_id\n GROUP BY 1\n ORDER BY 1;\n )\nend", "def coderay(text = \"\")\n text.gsub(/\\<code( lang=\"(.+?)\")?\\>\\s*(.+?)\\<\\/code\\>/m) do \n CodeRay.scan($3, $2).div( :css => :class,\n :line_numbers => :inline,\n :tab_width => 2\n ) \n end\n end", "def docbook_pba( text_in, element = \"\" )\n \n return '' unless text_in\n\n style = []\n text = text_in.dup\n if element == 'td'\n colspan = $1 if text =~ /\\\\(\\d+)/\n rowspan = $1 if text =~ /\\/(\\d+)/\n end\n\n style << \"#{ $1 };\" if not filter_styles and\n text.sub!( /\\{([^}]*)\\}/, '' )\n\n lang = $1 if\n text.sub!( /\\[([^)]+?)\\]/, '' )\n\n cls = $1 if\n text.sub!( /\\(([^()]+?)\\)/, '' )\n \n cls, id = $1, $2 if cls =~ /^(.*?)#(.*)$/\n \n atts = ''\n atts << \" role=\\\"#{ cls }\\\"\" unless cls.to_s.empty?\n atts << \" id=\\\"#{ id }\\\"\" if id\n atts << \" colspan=\\\"#{ colspan }\\\"\" if colspan\n atts << \" rowspan=\\\"#{ rowspan }\\\"\" if rowspan\n \n atts\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"select\nprojects.title,\nsum(pledges.amount) as sum_all_pledges\nfrom projects\ninner join pledges\non projects.id = pledges.project_id\ngroup by projects.title\norder by projects.title;\n\"\nend", "def format_row(row)\n \" #{row[:guess].join(' | ')} || #{row[:accuracy].join(' | ')} \"\n end", "def row_search \n horizontal_words = []\n search = @@boards_templates[1].to_s.scan(/...../).each_slice(1).to_a\n rows = search.join \n @@boards_templates[0].each { |x| rows.include?(x) ? horizontal_words << x : rows.reverse.include?(x) ? horizontal_words << x : \"No hay palabras en dirección horizontal\" }\n horizontal_words\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n <<-SQL\n SELECT\n title, sum(amount)\n FROM\n projects\n JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY\n title\n ORDER BY\n title\n SQL\nend", "def select_translations(args = {})\n hash = grouped_translated_text(args[:locale])\n hash.each { |key, value| hash[key] = value.count }.sort_by { |_key, value| value }.reverse.to_h\n end", "def extract_raw_ruby_lines(haml_processed_ruby_code, first_line_index)\n haml_processed_ruby_code = haml_processed_ruby_code.strip\n first_line = @original_haml_lines[first_line_index]\n\n char_index = first_line.index(haml_processed_ruby_code)\n\n if char_index\n return [char_index, [haml_processed_ruby_code]]\n end\n\n cur_line_index = first_line_index\n cur_line = first_line.rstrip\n lines = []\n\n # The pipes must also be on the last line of the multi-line section\n while cur_line && process_multiline!(cur_line)\n lines << cur_line\n cur_line_index += 1\n cur_line = @original_haml_lines[cur_line_index].rstrip\n end\n\n if lines.empty?\n lines << cur_line\n else\n # The pipes must also be on the last line of the multi-line section. So cur_line is not the next line.\n # We want to go back to check for commas\n cur_line_index -= 1\n cur_line = lines.last\n end\n\n while HAML_PARSER_INSTANCE.send(:is_ruby_multiline?, cur_line)\n cur_line_index += 1\n cur_line = @original_haml_lines[cur_line_index].rstrip\n lines << cur_line\n end\n\n joined_lines = lines.join(\"\\n\")\n\n if haml_processed_ruby_code.include?(\"\\n\")\n haml_processed_ruby_code = haml_processed_ruby_code.gsub(\"\\n\", ' ')\n end\n\n haml_processed_ruby_code.split(/[, ]/)\n\n regexp = HamlLint::Utils.regexp_for_parts(haml_processed_ruby_code.split(/,\\s*|\\s+/), '(?:,\\\\s*|\\\\s+)')\n\n match = joined_lines.match(regexp)\n # This can happen when pipes are used as marker for multiline parts, and when tag attributes change lines\n # without ending by a comma. This is quite a can of worm and is probably not too frequent, so for now,\n # these cases are not supported.\n return if match.nil?\n\n raw_ruby = match[0]\n ruby_lines = raw_ruby.split(\"\\n\")\n first_line_offset = match.begin(0)\n\n [first_line_offset, ruby_lines]\n end", "def get_row(column_label)\n row = []\n\n (0..8).each do |row_label|\n row << get_value( column_label + row_label.to_s )\n end\n return row\n end", "def build_row(row, i)\n row.map.with_index do |piece, j|\n color_options = colors_for(i,j)\n piece.to_s.colorize(color_options)\n end\n end", "def languages\n @xml.xpath('//language').map do |lang|\n lang.text.to_s.gsub(/\\.|\\,/,'').strip.capitalize.gsub(\"Finding aid written in english\", \"English\")\n end.uniq\n end", "def format_rows descriptions\n formatted = descriptions.map do |description|\n @column_descriptions.map do |field, _, format,|\n format % description[field]\n end\n end\n\n [@headers].concat formatted\n end", "def rows(parts=@parts)\n \n @renderer.rows(parts)\n \n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"SELECT prj.title, sum(plg.amount) FROM pledges plg\n INNER JOIN projects prj ON plg.project_id = prj.id\n GROUP BY prj.title\n ORDER BY prj.title\"\nend", "def modified_sample_layout\n lyt = []\n make_modified_start_array(@group_size).each do |j|\n cols = Array.new(@columns) { |c| c }\n cols.each { |c| @group_size.times { |i| lyt << [i + j, c] } }\n end\n lyt\n end", "def existing_kases_list_header_in_words(kind)\n case kind\n when :idea then \"Existing Ideas in the Community\".t\n when :question then \"Existing Questions in the Community\".t\n when :problem then \"Existing Problems in the Community\".t\n when :praise then \"Existing Praise in the Community\".t\n else \"Existing Cases in the Community\".t\n end\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\nSELECT projects.title, SUM(pledges.amount) \nFROM projects \nINNER JOIN pledges on projects.id = pledges.project_id\nGROUP BY (pledges.project_id)\nORDER BY projects.title;\nSQL\nend", "def hash\n [text, row_span, col_span, margin_top, margin_right, margin_left, margin_bottom, text_anchor_type, text_vertical_type, fill_format, border_top, border_right, border_left, border_bottom, border_diagonal_up, border_diagonal_down, column_index, row_index, text_frame_format, paragraphs].hash\n end", "def row(part, fields)\n \n # TODO: Add in notes, grain direction.\n html = \"<tr>\"\n\n fields.each { |f|\n \n # val = eval f[1] # Eval can be dangerous if passing something wrong into it...\n val = part[f[1]]\n \n # Check if the val is a float, so we can perform fraction conversion.\n if val.class == Float\n val = val.to_html_fraction(@round_dimensions)\n end\n\n puts \"[HTMLRenderer.row] row values: #{f[0]}, #{val}\\n\\n\" if $cutlister_debug\n \n html += \"<td>#{val.to_s}</td>\"\n \n }\n \n html += \"</tr>\"\n \n puts \"[HTMLRenderer.row] row html: #{html}\" if $cutlister_debug\n \n html\n \n end", "def rates(table_rows)\n table_rows.map do |e|\n e.css('.content').map(&:text).map(&:strip).map do |txt|\n txt.split(\"\\n\").map(&:strip)\n end\n end\n end", "def row_cells\n rowdata = []\n print_layout.each do |section|\n rowdata += row_cell_items(section[:row_cells])\n end\n rowdata\n end", "def headings_with_rows\n [headings] + rows\n end", "def show_series_language_description(mvf, language)\n notes = []\n mvf.each_with_index do |note, index|\n notes << note if (index.even? && language == :it) || (index.odd? && language == :en)\n end\n notes.join('<br /><br />')\n end", "def assignments_titles\n titles = []\n a_table = frm.table(:class=>\"listHier lines nolines\")\n 1.upto(a_table.rows.size-1) do |x|\n titles << a_table[x][1].h4(:index=>0).text\n end\n return titles\n end" ]
[ "0.559313", "0.5516747", "0.5369649", "0.53510374", "0.5305311", "0.52974373", "0.5261206", "0.5224807", "0.51573884", "0.5136142", "0.51236105", "0.5122372", "0.51097256", "0.508731", "0.5048546", "0.50386214", "0.5018835", "0.5017918", "0.5006626", "0.4990945", "0.49556917", "0.49385238", "0.4933849", "0.49330753", "0.49251693", "0.49150538", "0.4907261", "0.48968074", "0.48898724", "0.48542562", "0.4852642", "0.48365384", "0.483287", "0.48255995", "0.4811086", "0.48073545", "0.47921312", "0.47904727", "0.4780228", "0.47795582", "0.47781032", "0.4753745", "0.47451052", "0.47407776", "0.4727313", "0.47247747", "0.47084814", "0.47062796", "0.47030768", "0.4698704", "0.46982023", "0.4698069", "0.4698069", "0.469503", "0.46803036", "0.46769056", "0.46672982", "0.4660567", "0.4658156", "0.46580812", "0.4657144", "0.46564308", "0.46527576", "0.46500626", "0.4649831", "0.4648573", "0.46442124", "0.46433082", "0.46433082", "0.46431357", "0.4641109", "0.4639692", "0.46327552", "0.46310595", "0.46288884", "0.46283332", "0.4625349", "0.4624374", "0.4621001", "0.46202445", "0.46181992", "0.46163505", "0.46146682", "0.461391", "0.46054378", "0.4603415", "0.4591191", "0.45884985", "0.45879304", "0.45842713", "0.45778954", "0.45756415", "0.4570278", "0.45678356", "0.4566489", "0.4564646", "0.45646337", "0.45636484", "0.45589608", "0.45535126" ]
0.6034796
0
LOADS ONLY RECENT TWEETS FOR A USER
def load_tweets_for_user(user_id) authenticate max_id = Tweet.get_max_tweet_id(user_id) || @@max_id response = [] puts max_id result = @@client.user_timeline(user_id.to_i, :since_id => max_id) result.each do |tweet| begin newTweet = Tweet.new newTweet = newTweet.init(tweet) unless newTweet.is_retweet_or_mention newTweet.save! else puts "Found Retweet #{newTweet.text}" end rescue puts "COULD NOT SAVE" else t = TweetViewModel.new response << t.initFromActiveRecord(newTweet) end end response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_tweets!\n Twitter.user_timeline(username).each do |tweet|\n unless Tweet.where(twitter_user_id: self.id).find_by_content(tweet.text) \n self.tweets << Tweet.create(content: tweet.text)\n end\n end\n end", "def load\n params.permit!\n @user = current_user\n @users = []\n @lat, @lng = params[:lat].to_f, params[:lng].to_f\n location = [@lat, @lng].join(',')\n if $REDIS.lrange(CoffeeShop.trim_location(location), 0, -1).length < 10\n Thread.new do \n CoffeeShop.preload_local_coffee_shops(@lat, @lng)\n end\n end\n @nearby_hangouts = Hangout.find_by_location(\n 0.07, :lat => @lat, :lng => @lng\n )\n @nearby_hangouts.each do |hangout|\n @users.concat(hangout.attending_users)\n end\n render \"api/users/load\"\n end", "def index\n\t\t@tweets = current_user.tweets\n\tend", "def index\n authenticate\n @tweets = Tweet.where(\n user_id: current_user.id,\n stat: nil\n ).order(:id)\n end", "def get_users\n @get_users = Rails.cache.fetch(\"get_aside_users\", :expires_in => 1.hours) do\n if @current_user.present?\n Core::User.active.where(\"verified = 1 AND id != #{@current_user.id}\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n else\n Core::User.active.where(\"verified = 1\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n end\n end\n end", "def load_twitter_data\n create_twitter_client\n twitter_feeds = current_user.feeds.where(provider: \"twitter\")\n\n twitter_feeds.each do |feed|\n @client.user_timeline(feed.uid.to_i).each do |tweet|\n feed.posts.find_or_create_by(\n author_name: tweet.user.name,\n author_handle: tweet.user.handle,\n author_profile_pic: tweet.user.profile_image_uri.to_s,\n content: tweet.text,\n uid: tweet.id.to_s,\n posted_time: tweet.created_at\n )\n end\n end\n end", "def index\n # specific_assigned_version_process(__callee__, params)\n @twitter_users = current_user.twitter_users.all\n end", "def get_all_user_data\n load_user_data(nil)\n end", "def index\n @userpolls = eager_userpoll.where(user_id: current_user.id)\n end", "def index\n # show overview of users (both walkers and non-walkers)\n # allow user to filter on (non-)walkers\n # position of these people should be shown on a map (aprox. not exact)\n\n # start with 10 users\n # radius = 10km\n LoadNearbyUsers(10, false, current_user.id);\n end", "def show_tweets\n @user = get_user_or_current_user(params[:id])\n @tweets = Tweet.where(:user_id => @user.id).order(created_at: :desc)\n end", "def refresh_all\n User.find(:all, :conditions => [\"tokendopplr != NULL\"]).each do |u|\n call :action => getdata, :id => user.id\n end\n render :nothing => true \n end", "def index\n @users = policy_scope(User)\n .includes(:avatar, :main, :rank)\n .order(created_at: :desc)\n .page(params[:page])\n\n @users = @users.where(hidden: false) unless params[:hidden]\n\n authorize @users\n end", "def index\n # binding.pry\n @tweet = Tweet.new\n if current_user\n friend_ids = Friend.where(user_id: current_user).pluck(:friends_id) \n @tweets = Tweet.where(user_id: friend_ids)\n else\n @tweets = Tweet.includes([:user]).all\n end\n\n @tweets = @tweets.order(updated_at: :desc).page(params[:page]).per(10)\n end", "def index\n @retweets = Retweet.all.order(created_at: :DESC)\n @tweet = Retweet.new\n @users = User.all_except(current_user)\n end", "def index\n redirect_to(root_url) unless current_user\n\n @user = current_user\n @places = Place.where(user_id: @user).order(\"created_at DESC\")\n end", "def index\n @user = User.find(params[:user_id])\n @picks = @user.picks.order(\"created_at DESC\").page(params[:page]).per(20)\n end", "def get_tweets(list)\n if list.authorized?(@user)\n list.tweets\n else\n []\n end\nend", "def index\n @users = User.all\n\n set_up_twitter\n\n @users.each do |user|\n tweets = @client.user_timeline(user.twitter_id, count: 5)\n user.last_tweet = tweets.first.full_text\n end\n end", "def index\n if current_user.admin?\n @tips = Tip.joins(:race).where('races.year' => @year).order('races.race_number ASC')\n @users = User.all\n else\n @user = current_user\n @tips = Tip.joins(:race).where(\"races.year = ? AND races.ical_dtstart < ? AND user_id != ?\", @year, Time.current, @user.id)\n @tips = @tips + Tip.joins(:race).where(\"races.year = ? AND user_id = ?\", @year, @user.id)\n\n end\n end", "def index\n @tweets = Tweet.select { |tweet| tweet.user_id == current_user.id }\n end", "def fetch_users!(track)\n log(\"Fetching users for track #{track.id}\")\n\n user_ids = track.user_ids.members\n\n user_ids.each do |user_id|\n next if user_id == @user.id.to_s\n\n user = Smoothie::User.new(user_id)\n\n next unless user.synced? && user.favorites_synced?\n\n add_user!(user, track)\n end\n end", "def set_users\n @users = []\n \n if user_signed_in\n @users << current_user.tweets(:sort){:time_stamp}\n else\n User.all.each do |user|\n @users << user.tweets(:sort){:time_stamp}\n end\n end\n end", "def get_tweets(list)\n unless list.authorized(@user)\n raise AuthorizationException.new\n end\n list.tweets\nend", "def get_user_tweets\n @tweets = COLL.find(\n selector = {\"user.id\" => @user[:id]},\n opts={ :sort=>[\"created_at\", Mongo::ASCENDING],\n :fields=>[\"coordinates\",\"user\",\"text\",\"created_at\", \"entities\", \"place\"]\n })\n\n @user[:tweet_count] = @tweets.count\n @tweets.count > 1\n end", "def fetch_local_trends(user)\n @woeid = user.woeid.to_i\n local_trends = $redis.get(\"local_trends_#{@woeid}\")\n if local_trends.nil?\n response = twitter.trends(id = @woeid)\n local_trends = JSON.generate(response.attrs[:trends])\n $redis.set(\"local_trends_#{@woeid}\", local_trends)\n $redis.expire(\"local_trends_#{@woeid}\", 15.minutes.to_i)\n end\n @local_trends = JSON.load(local_trends)\n end", "def show\n set_up_twitter\n\n get_last_tweet\n get_five_last_tweets\n end", "def show\n @user = User.find_by!(username: params[:username])\n #This saves user tweets in desc order.\n @tweets = @user.tweets.order(created_at: :desc)\n end", "def load_bulk_tweets(user_id)\n\t\t\tauthenticate\n\n\t\t\tresponse = []\n\t\t\tresult = @@client.user_timeline(user_id.to_i)\n\t\t\tresult.each do |tweet|\n\t\t\t\tbegin\n\t\t\t\t\tnewTweet = Tweet.new\n\t\t\t\t\tnewTweet = newTweet.init(tweet)\n\t\t\t\t\tnewTweet.save!\n\t\t\t\trescue\n\t\t\t\t\tputs \"COULD NOT SAVE\"\n\t\t\t\telse\n\t\t\t\t\tt = TweetViewModel.new\n\t\t\t\t\tresponse << t.initFromActiveRecord(newTweet)\n\t\t\t\tend\n\t\t\tend\n\t\t\tresponse\n\t\tend", "def userfilter\n @tweets = Tweet.where(\"user_vote < 0 or user_vote > 0\").includes(:company).page params[:page]\n @count = Tweet.where(\"user_vote < 0 or user_vote > 0\").count\n end", "def topusers\n\t\t@topusers = User.find(:all, :order => \"points DESC\", :limit => \"10\")\n\tend", "def index\n @favorite_tweets = FavoriteTweet.where(:user => session[:user_id])\n end", "def index\n @politically_exposed_people = current_user.politically_exposed_people.all\n \n # Set progress bar\n @progress = 0.55\n if !@politically_exposed_people.empty?\n @progress += 0.20\n end\n end", "def index\n if current_user.role == 'ADMIN'\n @users = User.includes(:jobs).all\n else\n #@user = User.eager_load(jobs: {taks_jobs: :task}, users_teams: {team: :users_teams}).find(current_user)\n @user = User.includes(:jobs).find(current_user.id)\n end\n end", "def load_objects\r\n @guests, @users = @resource.can_be_modified_by?(current_user) ? [@resource.guests, @resource.invited_users] : \r\n [\r\n @resource.guests([\"invitor_id = '#{current_user.id}'\"]), \r\n @resource.invited_users.all(:conditions => ['invitor_id = ?', current_user])\r\n ]\r\n end", "def import_user_data\n @page_title = _('Import_user_data')\n @page_icon = 'excel.png'\n @users = User.find(:all, :conditions => \"temporary_id >= 0\")\n @devices = Device.find(:all, :conditions => \"temporary_id >= 0 AND name not like 'mor_server_%'\")\n end", "def index_lawfirm_users\n if current_user.id == current_user.lawfirm.user_id\n @users = User.where(lawfirm_id: current_user.lawfirm.id).load\n else\n flash[:danger] = \"You must have administrative privileges to view this page.\"\n redirect_to user_cases_path\n end\n end", "def load_tailors\n\t\t@shop_name=params[:shop_name]\n\t\t@title=params[:title]\n\t\tuser = User.where(:user_type => \"tailor\", :shop_name => @shop_name, :title => @title).select(\"id\",\"username\",\"email\")\n\t\tif user.nil?\n\t\t\trender json: {message: \"No any tailor in this group\"}\n\t\telse\t\t\t\n\t\t \tdetails = []\n\t\t\tuser.each do |chat|\n\t\t\t\tdetails << { :id => chat.id, :type => chat.username, :email => chat.email}\n\t\t\tend\n\t\t\trender :json => details.to_json\t\n\t\tend\n\tend", "def index\n @user_things = current_user.user_things\n end", "def index\n @tweets = Tweet.all\n @user = current_user\n @recent_tweets = Tweet.order(created_at: :desc).limit(10)\n @pop_tweets = Tweet.order(likes_count: :desc).limit(10)\n @tweet = Tweet.new\n #@users # 基於測試規格,必須講定變數名稱,請用此變數中存放關注人數 Top 10 的使用者資料\n end", "def index\n @userlitts = Userlitt.all\n end", "def get_user_curated_articles\n\n @curated_articles = User.find(params[:id]).imports.article.limit(10).offset(10*params[:curated_article_spline].to_i)\n if params[:ajax] == \"true\"\n render partial: \"curated_articles_list\", layout: false\n end\n end", "def index\n @author_site_storages = SiteStorage.fetch_data(current_user)\n end", "def index\n @teachers = current_user.branch.users.teachers\n end", "def indexbyuser\n @user = User.find_by_id params[:id]\n unless @user.nil?\n @treks = Trek.find_by_user params[:id]\n else\n redirect_to root_url, :alert => \"User not found\"\n end\n end", "def all_people_scheduled\n Entry.users_for_client(self.id)\n end", "def show\n @tweet = Tweet.find(params[:id])\n @user=User.all\n end", "def index\n redirect_to root_path unless session_logged_in?\n @tours = Tour.accessible_by(current_ability, :update)\n end", "def book\n @trips = current_user.driver.trips\n @trips.each do |trip|\n @books = trip.books\n end\n @books.each do |book|\n @user = book.user\n end\n end", "def tweets\n #Looked at all tweets\n #select only the tweets that match the User\n Tweet.all.select{|tweet| tweet.user == self }\n end", "def my_external\n @user = User.includes(:savings, :groups).find(session[:user_id])\n @savings = @user.savings.includes(:groups, :author).stand_alone_savings.ordered_by_most_recent\n render 'index'\n end", "def index\n @page_title = \"CBCL - Liste af Brugere\"\n @sort = params[:sort] || 'users.created_at'\n @order = params[:order] || \"asc\"\n\n @users = current_user.get_users(:page => params[:page], :per_page => Journal.per_page, :sort => params[:sort], :order => params[:order])\n\n if !params[:partial]\n render\n else\n render :partial => 'users/users', :layout => false\n end\n end", "def index\n @t_users = TUser.all\n end", "def index\n @tours = Tour.all\n @cities = City.all\n @places = Place.all\n @user = User.first\n end", "def index_users\n load_alert\n return if (@alert.blank?)\n\n # Preload the users\n @users = User.where(:_id.in => @alert.user_ids)\n\n respond_to do |format|\n format.html\n end\n end", "def index\n @user = current_user\n if (@user.populated == false) \n populate_database\n @user.populated = true\n @user.save!\n elsif @user.current_login - @user.last_login > 30\n populate_database\n end\n @tasks = @user.tasks.where(start: params[:start]..params[:end])\n end", "def init_tweets(tweeter)\n all_tweets = Twitter.user_timeline(tweeter.user, :trim_user => true, :count => 200, :include_rts => true)\n tweeter.latest_tweet = all_tweets.first.id\n tweeter.twit_id = all_tweets.first.user.id\n page = 2\n\n until all_tweets.empty?\n for item in all_tweets do\n Tweet.new(:data => item, :city_id => self.id, :user => tweeter.id, ).save\n end\n all_tweets = Twitter.user_timeline(tweeter.user, :trim_user => true, :count => 200, :include_rts => true, :page => page)\n page += 1\n end\n\n end", "def index\n\n @tweets = Tweet.tweets_for_me(list_friends()).order(created_at: :DESC).page params[:page]\n \n if params[:q] #REEMPLAZA A RANSACK PARA BUSCAR\n @tweets = Tweet.where('content LIKE ?', \"%#{params[:q]}%\").order(created_at: :DESC).page params[:page]\n\n end\n \n #SOLO APARECERÁN LOS TWEETS A LOS QUE SIGUE EL CURREN USER\n #@tweets = Tweet.tweets_for_me(list_friends()).order(created_at: :DESC).page params[:page]\n #@tweets = Tweet.order(created_at: :DESC).page params[:page]\n \n \n @tweet = Tweet.new\n \n end", "def get_all_tweets(user)\n collect_with_max_id do |max_id|\n options = {count: @limit, include_rts: true}\n options[:max_id] = max_id unless max_id.nil?\n $client.user_timeline(user, options)\n end\n end", "def fetch_user_timeline\n statuses = client.user_timeline(user_timeline_options)\n tweets = TweetMaker.many_from_twitter(statuses, project: project, twitter_account: self, state: :posted)\n update_max_user_timeline_twitter_id(tweets.map(&:twitter_id).max)\n tweets\n # If there's an error, just skip execution\n rescue Twitter::Error\n false\n end", "def index\n @templates = current_user.templates\n @events = Event.by_user_limit current_user\n end", "def index\n @verfugbarkeits = Verfugbarkeit.all\n @alle_user = User.where(typ: :Mitarbeiter).order(:username)\n end", "def index\n @stories = (Story.where(access: \"PUBLIC\")).recent.page(params[:page])\n @PVT = (Story.where(user_id: current_user.id))\n @private_stories = (@PVT.where(access: \"PRIVATE\")).recent.page(params[:page])\n @tweets = SocialTool.twitter_search\n @topics = Topic.all\n end", "def index\n @user_feeds = UserFeed.find_all_by_user_id(current_user.id)\n end", "def index\n @trips = current_user.trips\n end", "def index\n @trips = current_user.trips\n end", "def index\n if current_user.teacher?\n @tutorings = current_user.tutorings\n else\n if current_user.homeworks.any? \n @tutorings = Tutoring.where(homework_id: current_user.homeworks.pluck(:id))\n else\n @tutorings = []\n end \n end\n end", "def show\n @user_entries = Entry.find( :all, \n :conditions => [\"created_by = ?\", params[:user_name]],\n :order => \"created_at DESC\")\n @user_comments = Comment.find ( :all,\n :conditions => [\"created_by =?\", params[:user_name]],\n :order => \"created_at DESC\",\n :include => :entry)\n @user_favorites = @user.favorites.find (:all, :order => \"created_at DESC\")\n @user_favcoms = @user.favcoms.find (:all, :order => \"created_at DESC\")\n end", "def index\n #anyone\n # @wikis = policy_scope(Wiki)\n @wikis = Wiki.all\n @wikis = Wiki.visible_to(current_user)\n\n @wiki = policy_scope(Wiki)\n end", "def loadUsers()\n @@userid_count+=1\n user1 = User.new(@@userid_count, \"Shweta\", \"Dublin 1\", 1, Array.new)\n @@userid_count+=1\n user2 = User.new(@@userid_count, \"Chirag\", \"Dublin 2\", 5, Array.new)\n @@userid_count+=1\n user3 = User.new(@@userid_count, \"Karishma\", \"Galway\", 5, Array.new)\n\n @users += [user1, user2, user3]\n end", "def index\n @tweets = current_user.feed_tweets.order(id: :desc).page(params[:page])\n @tweet = current_user.tweets.build\n end", "def index\n @shots = Shot.where(published: true, user: !nil).limit(10)\n end", "def fetch_latest_everything\n\t\t@user_info = @client.execute(api_method: @info.userinfo.get).data\n\t\t@task_lists = @client.execute(api_method: @gtasks.tasklists.list).data.items\n\t\t@tasks = Hash.new\n\t\t@task_lists.each do |list|\n\t\t\t@tasks[list] = @client.execute(api_method: @gtasks.tasks.list, parameters: { 'tasklist' => list.id }).data.items\n\t\tend\n\t\treturn @user_info, @task_lists, @tasks\n\tend", "def index\n @gatherings = current_user.gatherings\n @own_gatherings = (current_user.own_gatherings).sort_by{|g| g.created_at}\n @invited_gatherings = (@gatherings - @own_gatherings).sort_by{|g| g.created_at}\n session[:return_to] ||= request.referer\n end", "def crawl users_to_crawl = @seed, infinity: false\n user = users_to_crawl.to_a.sample\n twitter_catcher_main_block do\n crawl_user( user )\n users_to_crawl = @sn.users_to_crawl if infinity\n crawl( users_to_crawl.delete( user ) ) if users_to_crawl.size > 0\n end\n end", "def index\n unless params[:user_id].nil?\n @user = User.find(params[:user_id])\n @trips = @user.trips\n else\n @trips = Trip.all\n end\n end", "def index\n #Busqueda Parcial del contenido\n if params[:q]\n @tweets = Tweet.where('content LIKE ?', \"%#{params[:q]}%\").order(created_at: :desc).page params[:page]\n elsif user_signed_in?\n @tweets = Tweet.tweets_for_me(current_user).or(current_user.tweets).order(created_at: :desc).page params[:page]\n else\n @tweets = Tweet.all.order(created_at: :desc).page params[:page]\n #@tweets = Tweet.eager_load(:likes).order(created_at: :desc).page params[:page] #Ordenando la vista dejando el ultimo creado en primera posicion\n end\n @tweet = Tweet.new #Accion para crear un tweet\n @user_likes = Like.where(user: current_user).pluck(:tweet_id)\n @users = User.where.not(id: current_user.id).last(5) if user_signed_in?\n #@user_likes = Like.eager_load(:user, :tweet).where(user: current_user).pluck(:tweet_id)\n #@users = User.where('id IS NOT ?', current_user.id).last(5) if user_signed_in?\n end", "def index\n user = current_user\n\n @giftees = Giftee.where(:user_id => user.id)\n \n \n end", "def show\n # Do not use costly eager load to get all meets/chatters/friends. We only need\n # to get a top listed few.\n @user = find_user(params[:id])\n assert_internal_error(@user)\n respond_to do |format|\n format.html {\n #@meets = @user.top_meets(15) # Get a bit more to make sure we have enough top friends\n #@friends = @user.top_friends(@meets, 15)\n #@chatters = @user.top_chatters(10)\n #@meets = @meets.slice(0..4)\n #attach_meet_infos(current_user, @meets)\n @title = @user.name_or_email\n redirect_to meets_user_path(@user)\n }\n format.json { # Only return user profile\n if (!current_user?(@user) && !admin_user?)\n render :json => @user.to_json(JSON_USER_BRIEF_API)\n else\n render :json => @user.to_json(JSON_USER_DETAIL_API)\n end\n }\n end\n end", "def index\n @favos = Favo\n .where(user_id: current_user.id)\n @tweets = Tweet.all\n end", "def index\n if params[:user_id].present?\n load_new_task\n @tasks = Task.where(user_id: params[:user_id])\n \n else\n @tasks = Task.all\n end\n end", "def get_tweets(list)\n if list.authorized?(@user)\n list.tweets\n else\n [] # \"magic\" return value\n end\nend", "def show\n if @user\n #fresh_when last_modified: @user.updated_at\n #expires_in 2.minutes\n #response.headers[\"Expires\"] = 1.minutes.from_now.httpdate\n puts \"\\e[31minside action\\e[0m\"\n @microposts = @user.microposts.newest.paginate page: params[:page],\n per_page: Settings.app.models.micropost.microposts_per_page\n else\n flash[:danger] = t \"controllers.users_controller.user_not_found\"\n redirect_to :root\n end\n end", "def index\n @user = User.find(current_user.id)\n @userpop = @user.userpop3s.all\n @usermails = @user.usermails.all\n end", "def index\n @in_play_stories = current_user.in_play_stories\n @friends_stories = current_user.finished_friends_stories\n @top_stories = current_user.top_stories\n @your_stories = current_user.finished_own_stories\n end", "def index\n @bunches = current_user.bunches.all\n end", "def userPublicKitesIndex\n check_and_handle_kites_per_page_update(current_user, params)\n\n @user = User.where(:username => params[:username]).first\n @function = \"#{@user.KosherUsername}'s Kites\"\n\n @kites = []\n if current_user\n @kites = Kite.joins(:user).where(\"users.username\" => params[:username]).kites_visible_to_me(current_user.id).paginate(:page => params[:page], :per_page => @kitesPerPage)\n else\n @kites = Kite.public_kites.joins(:user).where(\"users.username\" => params[:username]).paginate(:page => params[:page], :per_page => @kitesPerPage)\n end\n\n get_common_stats\n\n respond_to do |format|\n format.html { render :template => 'kites/index' }# indexPublic.html.erb\n format.xml { render :xml => @kites }\n format.js { render :template => 'kites/index' }\n end\n\n end", "def my_tweets\n \t@my_tweets = Tweet.find_by_sql(\"select tweets.* from tweets where user_id = #{current_user.id} UNION select tweets.* from tweets INNER JOIN tweets_users ON tweets.id = tweets_users.tweet_id where tweets_users.user_id = #{current_user.id}\")\n end", "def index\n @tweet = Tweet.new\n @comment = Comment.new\n @tweets = Tweet.all.order('created_at DESC')\n @friends = current_user.get_friends\n end", "def index\n @beehives = Beehive.where(user_id: current_user.id)\n end", "def index\n #byebug\n @parent_user = current_user; \n @user = PeerTeacherLogin.find( current_user.meta_id );\n \n @office_hours = OfficeHour.all\n @peer_teachers = PeerTeacher.all\n @updates = Update.all\n @time = Time.new\n @today = (@time.month.to_s + \"/\" + @time.day.to_s + \"/\" + @time.year.to_s)\n puts \"********#{request.remote_ip}: logged into peer teacher hub using email: #{@user.first_name} \"\n end", "def user_list\n @snippets = Snippet\n .where(user: current_user)\n .paginate(page: params[:page], per_page: 30)\n .order(created_at: :desc)\n render 'user_list'\n end", "def user_tweets(user, count=10, since_id=nil, max_id=nil)\n print \"Getting Last %d Statuses for User %s\" % [count, user.to_s]\n print \" since %s\" % since_id if since_id\n print \" until %s\" % max_id if max_id\n print \"\\n\"\n options = {:count => count, :trim_user => true, :include_rts => true, :include_entities => true}\n options[:since_id] = since_id if since_id\n options[:max_id] = max_id if max_id\n begin\n statuses = @MT.user_timeline(user, options)\n if statuses.size > 0\n status_data = statuses.map do |s|\n {\n :user_id => s.user.id,\n :created_at => s.created_at,\n :id => s.id,\n :text => s.text,\n :source => s.source,\n :truncated => s[\"truncated\"],\n :in_reply_to_user_id => s[\"in_reply_to_user_id\"],\n :in_reply_to_screen_name => s[\"in_reply_to_screen_name\"],\n :geo => s[\"geo\"],\n :coordinates => s[\"coordinates\"],\n :place => parse_place(s[\"place\"]),\n :contributors => s[\"contributors\"],\n :retweet_count => s[\"retweet_count\"],\n :entities => parse_entities(s.attrs[\"entities\"]),\n :retweeted_status => parse_retweeted_status(s[\"retweeted_status\"])\n }\n end\n status_data\n else\n []\n end\n rescue Twitter::Error::Unauthorized, Twitter::Error::Forbidden\n puts \"Failed for %s (Protected)\" % user.to_s\n []\n end\n end", "def show\n @user_picture = @user.profile_image.expiring_url(3600, :square)\n @bookmarks = @user.bookmarks\n @enrollments = @user.courses\n @enrollments_visible = @user.course_enrollments_visible_for_user(current_user)\n @completions_visible = @user.course_results_visible_for_user(current_user)\n end", "def read_all_about_it user\n \n collection.find(who_id: user.id,\n who_class: user.class.to_s\n ).collect{|args| Extra.new args }\n \n end", "def load_users\n\n $test_logger.log(\"Loading users...\")\n\n #Delete all users from terminal DB\n @@cmd_proc.delete_all_uers\n\n #Fetch finger images from resource\n finger1 = Resource.get_content(\"N1.pklite\", true)\n finger2 = Resource.get_content(\"N2.pklite\", true)\n\n #Create required user records on terminal DB\n user_map = {\n USER1_ID => User_DB_record.new({:name_UTF8 => \"Test MFU User 1\", :PIN_code_UTF8 => \"4455\",\n :first_finger_nb => 1,\n :templates => [User_templates.new(:template_type => Biofinger_template_type::Pklite,\n :template_data => finger1)]}),\n USER2_ID => User_DB_record.new({:name_UTF8 => \"Test MFU User 2\", :PIN_code_UTF8 => \"6677\",\n :first_finger_nb => 1,\n :templates => [User_templates.new(:template_type => Biofinger_template_type::Pklite,\n :template_data => finger2)]})\n }\n\n # USER_BAD_ID => User_DB_record.new({:name_UTF8 => \"Test bad quality id\",\n # :templates => [User_templates.new(:template_type => Biofinger_template_type::Pklite,\n # :template_data => bad_qual_finger)]})\n\n @@cmd_proc.call_thrift{user_DB_set_users(user_map, false)}\n \n end", "def index\n if params[:user_id].present?\n @items = current_user.items.page params[:page]\n else\n @items = Item.available.page params[:page]\n end\n end", "def show\n return if invalid_id params[:id]\n @current_user = get_current_user\n return if not_friend_or_user( @current_user, params[:id] )\n\n @user = User.find(params[:id])\n\n ordering = handle_sort params\n if @current_user == @user\n @torrents = @user.my_torrents\n else\n @torrents = paginated_torrents @user\n end\n\n @torrents.sort! { |a,b| a.created_at <=> b.created_at }\n @torrents = @torrents.reverse[0..5]\n\n @seeders = Swarm.get_all_seeders @current_user.id\n @leechers = Swarm.get_all_leechers @current_user.id \n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end", "def index\n add_breadcrumb 'Trouble Ticket'\n\n if current_user.admin == true\n @troubletickets = Troubleticket.all\n @pagy, @troubletickets = pagy(Troubleticket.all.order(:created_at))\n else\n @troubletickets =\n Troubleticket.where('user_id =?', current_user.id).order(\n 'created_at DESC'\n )\n @pagy, @troubletickets =\n pagy(\n Troubleticket.where('user_id =?', current_user.id).order(\n 'created_at DESC'\n )\n )\n end\n end", "def index\n setup_stats\n setup_superuser_facets\n @users = User.all\n add_institution_filter! # if they chose a facet or are only an admin\n @sort_column = user_sort_column\n @users = @users.order(@sort_column.order).page(@page).per(@page_size)\n end" ]
[ "0.6006903", "0.5871958", "0.5849025", "0.58081084", "0.5807453", "0.5796438", "0.5772522", "0.57509166", "0.5738463", "0.57040185", "0.5701107", "0.5685649", "0.5683876", "0.5667632", "0.56216335", "0.5615163", "0.5575764", "0.55688995", "0.556537", "0.5555986", "0.55252117", "0.55221945", "0.55107826", "0.5488787", "0.5482525", "0.5464489", "0.54635286", "0.54623675", "0.54521674", "0.54491836", "0.5448764", "0.5443045", "0.5426708", "0.5423338", "0.54095274", "0.5406897", "0.5404206", "0.53961056", "0.53838766", "0.53664035", "0.5363177", "0.5361972", "0.53524363", "0.5329031", "0.5328826", "0.5328087", "0.53271157", "0.5323183", "0.5313844", "0.53088564", "0.53051466", "0.53015095", "0.5298049", "0.5296647", "0.5293236", "0.5293227", "0.5280364", "0.52749556", "0.52728647", "0.52683", "0.52678007", "0.5263325", "0.52590746", "0.52570444", "0.5254083", "0.5254083", "0.5249432", "0.5248696", "0.5242493", "0.524095", "0.5239116", "0.52373534", "0.5235743", "0.523225", "0.52310914", "0.5228321", "0.5221669", "0.52215606", "0.52214795", "0.52203375", "0.5218887", "0.52188283", "0.52051383", "0.5201363", "0.51943135", "0.519396", "0.5193043", "0.51913804", "0.5189777", "0.51869994", "0.5186599", "0.5185387", "0.5184076", "0.51840115", "0.5182973", "0.5181285", "0.51802284", "0.5172535", "0.5163285", "0.51596016" ]
0.5619067
15
LOAD ALL TWEETS FOR A USER
def load_bulk_tweets(user_id) authenticate response = [] result = @@client.user_timeline(user_id.to_i) result.each do |tweet| begin newTweet = Tweet.new newTweet = newTweet.init(tweet) newTweet.save! rescue puts "COULD NOT SAVE" else t = TweetViewModel.new response << t.initFromActiveRecord(newTweet) end end response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_users\n\n $test_logger.log(\"Loading users...\")\n\n #Delete all users from terminal DB\n @@cmd_proc.delete_all_uers\n\n #Fetch finger images from resource\n finger1 = Resource.get_content(\"N1.pklite\", true)\n finger2 = Resource.get_content(\"N2.pklite\", true)\n\n #Create required user records on terminal DB\n user_map = {\n USER1_ID => User_DB_record.new({:name_UTF8 => \"Test MFU User 1\", :PIN_code_UTF8 => \"4455\",\n :first_finger_nb => 1,\n :templates => [User_templates.new(:template_type => Biofinger_template_type::Pklite,\n :template_data => finger1)]}),\n USER2_ID => User_DB_record.new({:name_UTF8 => \"Test MFU User 2\", :PIN_code_UTF8 => \"6677\",\n :first_finger_nb => 1,\n :templates => [User_templates.new(:template_type => Biofinger_template_type::Pklite,\n :template_data => finger2)]})\n }\n\n # USER_BAD_ID => User_DB_record.new({:name_UTF8 => \"Test bad quality id\",\n # :templates => [User_templates.new(:template_type => Biofinger_template_type::Pklite,\n # :template_data => bad_qual_finger)]})\n\n @@cmd_proc.call_thrift{user_DB_set_users(user_map, false)}\n \n end", "def loadUsers()\n @@userid_count+=1\n user1 = User.new(@@userid_count, \"Shweta\", \"Dublin 1\", 1, Array.new)\n @@userid_count+=1\n user2 = User.new(@@userid_count, \"Chirag\", \"Dublin 2\", 5, Array.new)\n @@userid_count+=1\n user3 = User.new(@@userid_count, \"Karishma\", \"Galway\", 5, Array.new)\n\n @users += [user1, user2, user3]\n end", "def get_all_user_data\n load_user_data(nil)\n end", "def load_users\n user_set = Set[]\n @users_config.each_key do |provider|\n @users_config[provider].each do |a|\n add_user(a, user_set, provider)\n end\n end\n add_users_to_group(user_set)\n end", "def import_user_data\n @page_title = _('Import_user_data')\n @page_icon = 'excel.png'\n @users = User.find(:all, :conditions => \"temporary_id >= 0\")\n @devices = Device.find(:all, :conditions => \"temporary_id >= 0 AND name not like 'mor_server_%'\")\n end", "def set_users\n @users = []\n \n if user_signed_in\n @users << current_user.tweets(:sort){:time_stamp}\n else\n User.all.each do |user|\n @users << user.tweets(:sort){:time_stamp}\n end\n end\n end", "def process_row(username)\n logger.debug \"Started processing teacher timetable slots for #{username}.\"\n timetable_slots = fetch_teacher_timetable_slots(username)\n @timetable_slots = timetable_slots.each\n @username = username\n logger.debug \"Finished processing teacher timetable slots for #{username}.\"\n end", "def trophy_files\n trophies.map do |t|\n begin\n ::GenericFile.load_instance_from_solr(t.generic_file_id)\n rescue ActiveFedora::ObjectNotFoundError\n logger.error(\"Invalid trophy for user #{user_key} (generic file id: #{t.generic_file_id})\")\n nil\n end\n end.compact\n end", "def fetch_tweets!\n Twitter.user_timeline(username).each do |tweet|\n unless Tweet.where(twitter_user_id: self.id).find_by_content(tweet.text) \n self.tweets << Tweet.create(content: tweet.text)\n end\n end\n end", "def populate_user_pool(user, type)\n case type\n when 'iso'\n @iso_users << user\n when 'agent'\n @agent_users << user\n end\n end", "def load_twitter_data\n create_twitter_client\n twitter_feeds = current_user.feeds.where(provider: \"twitter\")\n\n twitter_feeds.each do |feed|\n @client.user_timeline(feed.uid.to_i).each do |tweet|\n feed.posts.find_or_create_by(\n author_name: tweet.user.name,\n author_handle: tweet.user.handle,\n author_profile_pic: tweet.user.profile_image_uri.to_s,\n content: tweet.text,\n uid: tweet.id.to_s,\n posted_time: tweet.created_at\n )\n end\n end\n end", "def load_tweets_for_user(user_id)\n\t\t\tauthenticate\n\t\t\tmax_id = Tweet.get_max_tweet_id(user_id) || @@max_id\n\n\t\t\tresponse = []\n\t\t\tputs max_id\n\t\t\tresult = @@client.user_timeline(user_id.to_i, :since_id => max_id)\n\t\t\tresult.each do |tweet|\n\t\t\t\tbegin\n\t\t\t\t\tnewTweet = Tweet.new\n\t\t\t\t\tnewTweet = newTweet.init(tweet)\n\t\t\t\t\tunless newTweet.is_retweet_or_mention\n\t\t\t\t\t\tnewTweet.save!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"Found Retweet #{newTweet.text}\"\n\t\t\t\t\tend\n\t\t\t\trescue\n\t\t\t\t\tputs \"COULD NOT SAVE\"\n\t\t\t\telse\n\t\t\t\t\tt = TweetViewModel.new\n\t\t\t\t\tresponse << t.initFromActiveRecord(newTweet)\n\t\t\t\tend\n\t\t\tend\n\t\t\tresponse\n\t\tend", "def tables\n @users = [{:name => 'Yorick Peterse', :age => 18}, {:name => 'Chuck Norris', :age => 9000}, {:name => 'Bob Ross', :age => 53}]\n end", "def scan_user_templates\n if @@user_template_dir\n @@template_names = {greedy: [], nongreedy: [], independent: []}\n Dir.glob(File.join @@user_template_dir, \"*.haml\") do |filename|\n name = File.basename filename, \".haml\"\n params, template = load name, true\n greediness = params[\"greedy\"] ? :greedy : :nongreedy\n @@template_names[greediness] << name\n @@template_names[:independent] << name if params[\"independent\"]\n end\n end\n end", "def load_users\n CSV.foreach(\"bank_users.csv\",:headers, true) do |row|\n users = User.new\n user.name = row['name']\n user.pin = row['pin'].to_i\n user.balance = row['balance'].to_i\n user.push(users)\n\n end\n end", "def index\n @t_users = TUser.all\n end", "def load_data(ctx, **)\n ctx[:users] = User.all\n ctx[:welcome] = 'Welcome to TRB training'\n end", "def load_data()\n @trainSet.each do |line|\n subline = line.split\n user_id = subline[0].to_i\n movie_id = subline[1].to_i\n rating = subline[2].to_i\n\n if !(@usermap.has_key?(user_id))\n @usermap[user_id] = Hash.new\n end\n #first we fill up usermap\n @usermap[user_id][movie_id] = rating\n\n if !(@moviemap.has_key?(movie_id))\n @moviemap[movie_id] = Hash.new\n end\n #then we fill up moviemap\n @moviemap[movie_id][user_id] = rating\n end\n end", "def load_users\n @users = Array.new\n str = @fh.read_obj_no_par\n if str!=nil && str.size>0 then\n u_arr = YAML::load(str)\n set_users(u_arr)\n i = @users.size\n print \"Successfully loaded #{i} \"\n if i>1 \n puts \"users!\"\n return 1\n end\n if i==1\n puts \"user!\" \n end\n return 1\n end\n puts \"No users were found!\"\n return -1\n end", "def generate_all_teachers(site)\n # puts \"222222222222222222222222222222222222222222222222222222222222 \" + Dir.pwd\n if Dir.exists?('_teachers')\n # puts \"3333333333\"\n Dir.chdir('_teachers')\n\n Dir[\"*.yml\"].each do |path|\n # puts \"444444444 \" + path\n name = File.basename(path, '.yml')\n self.generate_teacher_index(site, site.source, \"/pages/teachers/\" + name, name)\n end\n\n Dir.chdir(site.source)\n self.generate_all_teachers_index(site)\n end\n end", "def load\n params.permit!\n @user = current_user\n @users = []\n @lat, @lng = params[:lat].to_f, params[:lng].to_f\n location = [@lat, @lng].join(',')\n if $REDIS.lrange(CoffeeShop.trim_location(location), 0, -1).length < 10\n Thread.new do \n CoffeeShop.preload_local_coffee_shops(@lat, @lng)\n end\n end\n @nearby_hangouts = Hangout.find_by_location(\n 0.07, :lat => @lat, :lng => @lng\n )\n @nearby_hangouts.each do |hangout|\n @users.concat(hangout.attending_users)\n end\n render \"api/users/load\"\n end", "def extra_users_data_look_up\n return if @results.empty?\n\n tickets = DataStore.instance.tickets\n @results.each do |user|\n ticket_names = tickets.select { |t| t['assignee_id'] == user['_id'] }.map { |t| t['subject'] }\n user['tickets'] = ticket_names\n end\n end", "def gym_user_instances\n user_names = []\n self.exercise_instances.each do |user|\n user_names << User.all.find {|user_instance| user_instance.id == user.user_id}\n end\n user_names\n \n end", "def itemized_stash_data(users)\n user = users.first\n # enable stash for the user?\n end", "def get_all_tweets(user)\n collect_with_max_id do |max_id|\n options = {count: @limit, include_rts: true}\n options[:max_id] = max_id unless max_id.nil?\n $client.user_timeline(user, options)\n end\n end", "def read_all_about_it user\n \n collection.find(who_id: user.id,\n who_class: user.class.to_s\n ).collect{|args| Extra.new args }\n \n end", "def load_data\n @roles = Role.find(:all, :order => \"name\")\n @users = User.find(:all, :order => \"login\")\n end", "def all(instance)\n data = service.list_users(instance).to_h[:items] || []\n load(data)\n end", "def sync_all_active_users\n prepare_sis_user_import\n get_canvas_user_report_file\n load_active_users\n process_updated_users\n process_new_users\n Canvas::MaintainUsers.handle_changed_sis_user_ids(@sis_user_id_updates)\n import_sis_user_csv\n end", "def refresh_all\n User.find(:all, :conditions => [\"tokendopplr != NULL\"]).each do |u|\n call :action => getdata, :id => user.id\n end\n render :nothing => true \n end", "def for_all_cpanel_users(&block)\n\t\t\t\tDir.foreach(user_data_dir) do |filename|\n\t\t\t\t\tnext if filename == '.' or filename == '..'\n\t\t\t\t\tblock.call(filename)\n\t\t\t\tend\n\t\t\tend", "def get_all_users\n @users = []\n User.all.each do |user|\n @users << user.to_hash\n end\n end", "def get_all_users\n @users = []\n results = User.all\n results.each do |user|\n @users << user.to_hash\n end\n end", "def init_tweets(tweeter)\n all_tweets = Twitter.user_timeline(tweeter.user, :trim_user => true, :count => 200, :include_rts => true)\n tweeter.latest_tweet = all_tweets.first.id\n tweeter.twit_id = all_tweets.first.user.id\n page = 2\n\n until all_tweets.empty?\n for item in all_tweets do\n Tweet.new(:data => item, :city_id => self.id, :user => tweeter.id, ).save\n end\n all_tweets = Twitter.user_timeline(tweeter.user, :trim_user => true, :count => 200, :include_rts => true, :page => page)\n page += 1\n end\n\n end", "def get_all_users\n @users = []\n\n User.all.each do|user|\n @users << user.to_hash\n end\n end", "def parse_tweets\n @tweets.each do |tweet|\n @user[:handle] << tweet[\"user\"][\"screen_name\"]\n unless tweet[\"place\"].nil?\n place = tweet[\"place\"][\"full_name\"]\n else\n place = nil\n end\n\n @user[:features]<<{:type =>\"Feature\",\n :geometry =>{:type=>\"Point\",\n :coordinates =>tweet[\"coordinates\"][\"coordinates\"]},\n :properties =>{:created_at=>tweet[\"created_at\"],\n :text=>tweet[\"text\"],\n :place=>place}}\n end\n end", "def list_users(workspace)\n puts \"\\nUser List\\n\\n\"\n tp workspace.users, \"id\", \"name\", \"real_name\", \"status_text\", \"status_emoji\"\nend", "def index\n # specific_assigned_version_process(__callee__, params)\n @twitter_users = current_user.twitter_users.all\n end", "def setup\n load_users\n end", "def index\n @users = User.all\n\n set_up_twitter\n\n @users.each do |user|\n tweets = @client.user_timeline(user.twitter_id, count: 5)\n user.last_tweet = tweets.first.full_text\n end\n end", "def find_all\n execute_sql(:read, :user) { table.map {|u| inflate_model(u) } }\n end", "def load_tsbs\n ($data_skills + $data_items + $data_states + $data_classes + \n $data_weapons + $data_actors + $data_enemies).compact.each do |item|\n item.load_tsbs\n end\n end", "def load_tsbs\n ($data_skills + $data_items + $data_states + $data_classes + \n $data_weapons + $data_actors + $data_enemies).compact.each do |item|\n item.load_tsbs\n end\n end", "def lists\n load_user_lists\n end", "def find_user_data\n if @guardian.current_user && @all_topics.present?\n topic_lookup = TopicUser.lookup_for(@guardian.current_user, @all_topics)\n @all_topics.each { |ft| ft.user_data = topic_lookup[ft.id] }\n end\n end", "def persistUserContentToFile(dataDir)\n threadForEachUser do |account|\n #account.contentMap.keys.each do |tag|\n #userFile = @dataDir+\"other/#{account.user}.yml\"\n # if tag.match(/programming/)\n # userFile = @dataDir+\"programming/#{account.user}.yml\"\n # elsif tag.match(/travel/)\n # userFile = @dataDir+\"travel/#{account.user}.yml\"\n # end\n userFile = dataDir+\"/#{account.user}.yml\"\n # Remove user file if already present.\n File.delete(userFile) if File.exists?(userFile)\n File.open(userFile,\"a\") do |outputFile|\n puts \"Persisting content for '#{account.user}'\"\n #outputFile.puts account.contentMap[tag].to_yaml \n outputFile.puts account.contentArr.to_yaml\n end\n #end\n end\n end", "def load_data\n\t\tFile.open(\"u.data\", \"r\").each_line do |line|\n\t\t\ta = line.split\n\t\t\t@movies[a[1].to_i] = @movies[a[1].to_i] + a[2].to_i\n\n\t\t\t@users[a[0].to_i] = @users[a[0].to_i].push(a[1].to_i)\n\t\t\t\n\t\tend\n\tend", "def load_users \n\tFile.readlines(file_input).each do |line|\n\t\tusernames = line.split(\",\")\n\t\t# the return value of this method needs to be an array, not the file\n\t\t# so there's an explicit return\n\t\treturn usernames\n\tend\nend", "def scrape_all\n\t\tpage = fetch_page(@base_url)\n\t\turl_list = get_url_list(page)\n\t\turl_list.each do |url|\n\t\t\t#scrape the page\n\t\t\tuser = User.new(url,@user_agent)\n\t\t\tuser.scrape\n\t\tend\n\tend", "def list\n @trips = Trips.my_trips(cookies[ :user_id ] )\n end", "def book\n @trips = current_user.driver.trips\n @trips.each do |trip|\n @books = trip.books\n end\n @books.each do |book|\n @user = book.user\n end\n end", "def load_hashes(data_set)\n\t\tFile.open(data_set, \"r\") do |f|\n\t\t\tf.each_line do |line|\n\t\t\t\t@@line_array = line.split(' ')\n\t\t\t\tload_user_info\n\t\t\t\tload_movie_viewers\n\t\t\t\tload_movie_ratings\t\n\t\t\tend\n\t\tend\n\tend", "def user\n t = []\n ville = nom_ville\n\t\tville.each do |i|\n\t\t\tCLIENT.search(i).take(1).collect do |tweet|\n\t\t\t\tt.push(\"#{tweet.user.screen_name}\") \n\n\t\t\tend\n\t\t end\n\treturn t\nend", "def block_users\n request('/block/users', {body: {}})\n end", "def init_user(tag, count=5)\n @users = {}\n @delicious.get_popular(tag)[0,count].each do |bookmark|\n @delicious.get_url(bookmark[\"u\"]).each do |url|\n @users[url[\"user\"]] = {}\n end\n end\n @users\n end", "def user_trips(user_id=self.username)\n connection.get(\"/users/#{user_id}/trips\").body.trips\n end", "def find_all_by_username(usernames)\n finder = table.where(:username => usernames)\n execute_sql(:read, :user) { finder.map {|u| inflate_model(u) } }\n end", "def index\n @userlitts = Userlitt.all\n end", "def preload_data\n DataStore.instance.insert_data('users', 'data/users.json')\n DataStore.instance.insert_data('tickets', 'data/tickets.json')\n end", "def user_items(user_id=self.username, context='pack')\n response = connection.get do |req|\n req.url \"/users/#{user_id}/items\", :context => context\n end\n response.body.items\n end", "def bootstrap_users\n @@bootstrap_users ||= []\n return @@bootstrap_users unless @@bootstrap_users.length == 0\n 12.times do\n u = User.gen\n @@bootstrap_users << u\n u.build_watch_collection\n end\n return @@bootstrap_users\nend", "def users\n @users ||= rows.map { |r| UserImport::User.new(r) }\n end", "def load_training_data\n\t\tCSV.foreach(@data_file_path+'/'+@training_file_name, {col_sep: \"\\t\", encoding: 'windows-1251:utf-8'}) do |row|\n\t\t\tuser_id, movie_id, rating, timestamp = row\n\t\t\trating = rating.to_f\n\t\t\tuser = get_obj(User, @all_users, user_id)\n\t\t\tuser.ratings[movie_id] = rating\n\n\t\t\tmovie = get_obj(Movie, @all_movies, movie_id)\n\t\t\tmovie.ratings[user_id] = rating\n\t\tend\n\tend", "def load_bulk_jobs(druid)\n directory_list = []\n bulk_info = []\n bulk_load_dir = File.join(Settings.bulk_metadata.directory, druid)\n\n # The metadata bulk upload processing stores its logs and other information in a very simple directory structure\n directory_list = Dir.glob(\"#{bulk_load_dir}/*\") if File.directory?(bulk_load_dir)\n\n directory_list.each do |directory|\n time = directory.sub(\"#{bulk_load_dir}/\", \"\")\n log = UserLog.new(druid, time)\n bulk_info.push(log.bulk_job_metadata)\n end\n\n # Sort by start time (newest first)\n sorted_info = bulk_info.sort_by { |b| b[\"argo.bulk_metadata.bulk_log_job_start\"].to_s }\n sorted_info.reverse!\n end", "def users\n reload!\n @users\n end", "def load_bulk_jobs(druid)\n directory_list = []\n bulk_info = []\n bulk_load_dir = File.join(Settings.BULK_METADATA.DIRECTORY, druid)\n\n # The metadata bulk upload processing stores its logs and other information in a very simple directory structure\n directory_list = Dir.glob(\"#{bulk_load_dir}/*\") if File.directory?(bulk_load_dir)\n\n directory_list.each do |directory|\n time = directory.sub(\"#{bulk_load_dir}/\", '')\n log = UserLog.new(druid, time)\n bulk_info.push(log.bulk_job_metadata)\n end\n\n # Sort by start time (newest first)\n sorted_info = bulk_info.sort_by { |b| b['argo.bulk_metadata.bulk_log_job_start'].to_s }\n sorted_info.reverse!\n end", "def each\n if is_partial?\n yield user\n else\n yield user\n yield user_profile\n yield user_style\n end\n yield tweet if tweet\n end", "def index\n unless params[:user_id].nil?\n @user = User.find(params[:user_id])\n @trips = @user.trips\n else\n @trips = Trip.all\n end\n end", "def find_tweets(current_user)\n @screen_name = current_user.authentications[2].to_s\n @another_tweet = self.twitter.user_timeline(@screen_name)\n @tweet = Tweets.new\n @another_tweet.each do |t|\n @tweet.screenname = t.screen_name\n @tweet.text = t.text\n @tweet.created_at = t.created_at\n end\n @tweet.save\n end", "def cache_users(stuff)\r\n query_result = stuff.slm.find_all(:user)\r\n query_result.each {|user| add_user(user)}\r\n puts \"\\n\"\r\nend", "def index\n\t\t@tweets = current_user.tweets\n\tend", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def user=(user)\n @user = user\n @twitter_user = nil\n load_words\n end", "def load_user_data(id = nil)\n if id\n @user_id = id.to_i\n users = [User.find(id)]\n else\n @user_id = nil\n users = User.all\n end\n\n # Prime @user_data structure.\n @user_data = {}\n users.each do |user|\n @user_data[user.id] = {\n id: user.id,\n name: user.unique_text_name,\n bonuses: user.sum_bonuses\n }\n add_language_contributions(user)\n end\n\n # Load record counts for each category of individual user data.\n (ALL_FIELDS - SITE_WIDE_FIELDS).each { |field| load_field_counts(field) }\n\n # Calculate full contribution for each user. This will also correct some\n # double-counting of versioned records.\n users.each do |user|\n contribution = calc_metric(@user_data[user.id])\n # Make sure contribution caches are correct.\n if user.contribution != contribution\n user.contribution = contribution\n user.save\n end\n end\n end", "def load_user_hive\n debug \"Loading NTUSER.DAT for '#{@resource[:user]}'\"\n\n home_path = nil\n begin\n Win32::Registry::HKEY_LOCAL_MACHINE.open(\"SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\ProfileList\\\\#{@user_sid}\") do |key|\n home_path = key['ProfileImagePath']\n end\n rescue Win32::Registry::Error => error\n self.fail \"Cannot find registry hive for user '#{@resource[:user]}'\"\n end\n\n ntuser_path = File.join(home_path, 'NTUSER.DAT')\n\n Puppet::Util::Windows::Security.with_privilege(Puppet::Util::Windows::Security::SE_RESTORE_NAME) do\n result = self.class::WinAPI.RegLoadKey(Win32::Registry::HKEY_USERS.hkey, @user_sid, ntuser_path)\n unless result == 0\n raise Puppet::Util::Windows::Error.new(\"Could not load registry hive for user '#{@resource[:user]}'\", result)\n end\n end\n\n self.class.loaded_hives << { :user_sid => @user_sid, :username => @resource[:user] }\n end", "def fetch_data(user)\n array = read_from_file(\"userdata/#{user}.txt\")\n array[0]\nend", "def create_cached_personal_tweet_list(name, user_id)\n\t\tif REDIS.exists(name+\"_personal\") == false\n\t\t\t#Queries the database for the 100 latest tweets by the given user\n\t\t\ttweets = Tweet.search_latest_tweets_by_users([user_id])\n\n\t\t\t#Constructs a REDIS object containing the text and timestamps of all the tweets by the given user\n\t\t\ttweets.each do |tweet|\n\t\t\t\thash = Hash.new\n\t\t\t\thash[:text] = tweet.text\n\t\t\t\thash[:created_at] = Time.at(tweet.created_at).to_s\n\t\t\t\tREDIS.lpush(name + \"_personal\", hash.to_json)\n\t\t\tend\n\n\t\t\tREDIS.expire(name + \"_personal\", 120)\n\t\tend\n\tend", "def user_data(filename)\n user_data = CSV.read Dir.pwd + filename\n descriptor = user_data.shift\n descriptor = descriptor.map { |key| key.to_sym }\n user_data.map { |user| Hash[ descriptor.zip(user) ] }\n end", "def user_tweets(user_hash, opts = {})\n client = self.client(user_hash)\n user_name = user_hash['name']\n\n opts = @default_user_tweets_options.merge(opts)\n\n expected_count = opts['count'] || 20\n max_id = nil\n\n Enumerator.new do |yielder|\n # make API request & return results in an enumerator\n loop do\n query_opts = opts\n if max_id\n query_opts = opts.clone\n query_opts['max_id'] = max_id\n end\n\n results = client.user_timeline(user_name, query_opts)\n results.each do |tweet|\n id = tweet['id']\n max_id = id if (max_id.nil? || id < max_id) # max_id should descend\n yielder << tweet\n end\n\n # TODO catch RateLimitExceeded exception\n\n break if results.size < expected_count # this can happen if optional params are passed in...\n\n max_id -= 1 # subtract 1 from max_id to avoid redundant messages\n end\n end\n end", "def list_all_users\n\n end", "def crawl users_to_crawl = @seed, infinity: false\n user = users_to_crawl.to_a.sample\n twitter_catcher_main_block do\n crawl_user( user )\n users_to_crawl = @sn.users_to_crawl if infinity\n crawl( users_to_crawl.delete( user ) ) if users_to_crawl.size > 0\n end\n end", "def create_entries_for_user(_user)\n entries = []\n (0..30).each do |_number|\n entries << EntryBuilder.new(number).entry\n end\n end", "def my_tweets\n \t@my_tweets = Tweet.find_by_sql(\"select tweets.* from tweets where user_id = #{current_user.id} UNION select tweets.* from tweets INNER JOIN tweets_users ON tweets.id = tweets_users.tweet_id where tweets_users.user_id = #{current_user.id}\")\n end", "def get_user_tweets\n @tweets = COLL.find(\n selector = {\"user.id\" => @user[:id]},\n opts={ :sort=>[\"created_at\", Mongo::ASCENDING],\n :fields=>[\"coordinates\",\"user\",\"text\",\"created_at\", \"entities\", \"place\"]\n })\n\n @user[:tweet_count] = @tweets.count\n @tweets.count > 1\n end", "def fetch_user_data\n @username = params[:username]\n @configured_sources = params[:source_ids] || []\n @result_set = Hash.new\n @configured_sources.each do |source|\n feed_result = fetch_feed(source,@username)\n @result_set[source] = feed_result\n end\n \n end", "def import_guest_users\n private_data = site.data['private'] || {}\n hub_data = private_data['hub'] || {}\n if hub_data.member? 'guest_users'\n site.data['guest_users'] = site.data['private']['hub']['guest_users']\n site.data['private']['hub'].delete 'guest_users'\n end\n end", "def load_users_fixture\n unless @users_fixture_loaded\n self.method(:fixtures).call(user_symbol.to_s.pluralize.to_sym)\n @users_fixture_loaded = true\n end\n end", "def set_users\n @users = User.all.where(user_type: \"chw\")\n end", "def find_all_gym_users\n self.gym_user_instances.map{|user| user.name } \n end", "def getUserPosts\n threadForEachUser do |account|\n begin\n #puts \"'#{account.user}' Started.\"\n posts = DeliciousConnector::get_posts(account.user,account.pwd) \n account.post_doc = Hpricot(posts) # Parse XML\n puts \"'#{account.user}' Post List Loaded.\"\n rescue => e\n puts \"[Warning]: Failed to retrieve posts for '#{account.user}' : [#{e}]\" \n end\n end \n end", "def find_all_for_authz_map(usernames)\n return usernames if usernames.empty?\n finder = table.select(:id,:authz_id,:username).where(:username => usernames)\n execute_sql(:read, :user) { finder.map {|u| inflate_model(u)}}\n end", "def load_tailors\n\t\t@shop_name=params[:shop_name]\n\t\t@title=params[:title]\n\t\tuser = User.where(:user_type => \"tailor\", :shop_name => @shop_name, :title => @title).select(\"id\",\"username\",\"email\")\n\t\tif user.nil?\n\t\t\trender json: {message: \"No any tailor in this group\"}\n\t\telse\t\t\t\n\t\t \tdetails = []\n\t\t\tuser.each do |chat|\n\t\t\t\tdetails << { :id => chat.id, :type => chat.username, :email => chat.email}\n\t\t\tend\n\t\t\trender :json => details.to_json\t\n\t\tend\n\tend", "def generate_all_teachers_index(site)\n # puts \"55555555555555555555555555555555555555555555555555555555\"\n allTeachers = AllTeachersIndex.new(site, site.source, \"/pages/teachers\")\n allTeachers.render(site.layouts, site.site_payload)\n allTeachers.write(site.dest)\n\n site.pages << allTeachers\n site.static_files << allTeachers\n end", "def index\n @userpolls = eager_userpoll.where(user_id: current_user.id)\n end", "def load_objects\r\n @guests, @users = @resource.can_be_modified_by?(current_user) ? [@resource.guests, @resource.invited_users] : \r\n [\r\n @resource.guests([\"invitor_id = '#{current_user.id}'\"]), \r\n @resource.invited_users.all(:conditions => ['invitor_id = ?', current_user])\r\n ]\r\n end", "def add_user_to_import(canvas_user)\n @sis_user_import << canvas_user\n end", "def load_all\n @leagues = @loader.load unless @loader.nil?\n end", "def nodes(tweets)\n tweets.inject({}) do |nodes, tweet|\n node = nodes[tweet.user_name]\n nodes[tweet.user_name] = User.new(tweet.user_name) unless node\n nodes\n end\n end", "def users\n return @canonical_user_pool if @canonical_user_pool\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Retrieving all users\"\n check_retval @user_pool.info!\n\n @canonical_user_pool = []\n @user_pool.each { |user| @canonical_user_pool << canonical_user(user) }\n @canonical_user_pool\n end" ]
[ "0.6613841", "0.66098845", "0.6590403", "0.624021", "0.5994971", "0.5949833", "0.57905906", "0.5728993", "0.56339604", "0.56163824", "0.55906844", "0.5581066", "0.5577806", "0.5559744", "0.5550515", "0.552597", "0.54965323", "0.54870754", "0.54638827", "0.5461878", "0.54578716", "0.5455025", "0.54520124", "0.54198354", "0.5391511", "0.53844213", "0.5379695", "0.5374632", "0.5354058", "0.5347297", "0.53431886", "0.5326513", "0.53251076", "0.532275", "0.5320849", "0.5311854", "0.53086007", "0.5303556", "0.5299852", "0.5294657", "0.5277499", "0.52654696", "0.52654696", "0.5262381", "0.52617365", "0.5259472", "0.52554333", "0.524855", "0.52469426", "0.52460945", "0.5243522", "0.5239054", "0.52316797", "0.52166", "0.52128994", "0.5201531", "0.52010185", "0.51968575", "0.5182596", "0.5181675", "0.51659477", "0.516", "0.5158687", "0.51564044", "0.51541805", "0.51459813", "0.5143467", "0.51365983", "0.51335716", "0.5119653", "0.5106864", "0.51061404", "0.51061404", "0.51023406", "0.5095436", "0.50925756", "0.50886816", "0.50838184", "0.5082979", "0.50792027", "0.5076583", "0.5075782", "0.5061394", "0.50532335", "0.5053039", "0.50514466", "0.50492054", "0.5048885", "0.5035525", "0.5032765", "0.5027703", "0.5018622", "0.501047", "0.5010402", "0.50098807", "0.5003071", "0.49996924", "0.4995088", "0.49938086", "0.49929413" ]
0.63790214
3
Transforms a SQLiX embedded XML Document. Takes a valid XML document as either a string or url, including local filename, or REXML::Document. Use the seeds hash to feed the references of the initial row element. Returns the resulting XML Document as a string, or as an REXML::Document if that was given. sqlix:query elements are in this format:
def transform(xml_source, seeds={}) if xml_source.is_a?(REXML::Document) xml_document = xml_source else src = fetch_xml(xml_source) xml_document = REXML::Document.new(src) end queries = REXML::XPath.match(xml_document.root,'//x:query', {'x' => 'http://www.transami.net/namespace/sqlix'}) queries.each do |element| listener = SQLiX_Listener.new(@dbi, seeds) el_str = '' element.write(el_str) REXML::Document.parse_stream(el_str, listener) new_element = listener.build_document new_element.elements.each do |el| element.parent.add_element(el) end element.remove end # return output if xml_source.is_a?(REXML::Document) return xml_document else xml_string = "" xml_document.write(xml_string) xml.gsub!(/>\s+</,'><') # clean poor rexml whitespace handling return xml_string end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform_solr\n puts \"transforming #{self.filename}\"\n solr_doc = Nokogiri::XML(\"<add></add>\")\n @csv.each do |row|\n if !row.header_row?\n doc = Nokogiri::XML::Node.new(\"doc\", solr_doc)\n # row_to_solr should return an XML::Node object with children\n doc = row_to_solr(doc, @csv.headers, row)\n solr_doc.at_css(\"add\").add_child(doc)\n end\n end\n # Uncomment to debug\n # puts solr_doc.root.to_xml\n if @options[\"output\"]\n filepath = \"#{@out_solr}/#{self.filename(false)}.xml\"\n # puts \"output #{@out_solr}\"\n File.open(filepath, \"w\") { |f| f.write(solr_doc.root.to_xml) }\n end\n return { \"docs\" => solr_doc.root.to_xml }\n end", "def solr_document_xml( docs )\n solr_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => solr_xml, :indent => 2 )\n \n xml.add {\n docs.each do |doc|\n xml.doc {\n doc.each do |field,field_terms|\n field_terms.each do |term|\n xml.field( term, :name => field )\n end\n end\n }\n end\n }\n \n return solr_xml\n end", "def xml_to_solr( text, solr_doc=Solr::Document.new )\n doc = REXML::Document.new( text )\n doc.root.elements.each do |element|\n solr_doc << Solr::Field.new( :\"#{element.name}_t\" => \"#{element.text}\" )\n end\n\n return solr_doc\n end", "def query\n {:xml => xml}\n end", "def q!(query, db)\n # build bindings from references\n bindings = []\n if query.references\n query.references.each do |reference|\n bindings << @row[reference]\n end\n end\n # query\n qry = query.query.gsub('&apos;',\"'\").gsub('&quot;','\"') # replace single and double quotes that rexml substituted out.\n if bindings.empty?\n rows = db.connection.select_all(qry)\n else\n rows = db.connection.select_all(qry, *bindings)\n end\n result_rows = []\n rows.each do |row|\n result_rows << Row.new(query.name, row, query.attributes)\n end\n result_rows.each do |row|\n self << row\n end\n return result_rows\n end", "def from_qbxml(xml, opts = {})\n hash = Qbxml::Hash.from_xml(xml, underscore: true, schema: @doc)\n hash = opts[:no_namespace] ? hash : namespace_qbxml_hash(hash)\n hash.extend(DeepFind)\n end", "def row_to_solr(doc, headers, row)\n headers.each do |column|\n doc.add_child(\"<field name='#{column}'>#{row[column]}</field>\") if row[column]\n end\n return doc\n end", "def import_xml xml_data\n ###\n [table, id]\n end", "def transform(xsl, xml)\n Rexslt.new(xsl, xml).to_s\n end", "def xml( filters_to_use, attributes_to_use, query )\n biomart_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => biomart_xml, :indent => 2 )\n\n xml.instruct!\n xml.declare!( :DOCTYPE, :Query )\n xml.Query( :virtualSchemaName => \"default\", :formatter => \"TSV\", :header => \"0\", :uniqueRows => \"1\", :count => \"\", :datasetConfigVersion => \"0.6\" ) {\n xml.Dataset( :name => self.dataset, :interface => \"default\" ) {\n\n if filters_to_use\n filters_to_use.each do |f|\n xml.Filter( :name => f, :value => query )\n end\n end\n\n if attributes_to_use\n attributes_to_use.each do |a|\n xml.Attribute( :name => a )\n end\n else\n self.attributes.each do |a|\n xml.Attribute( :name => a )\n end\n end\n\n }\n }\n\n return biomart_xml\n end", "def sanitize_id_format_raw_xml(original_input)\n return nil if original_input.nil? || original_input.raw_content.blank?\n format_sanitizer = Stix::Stix111::SanitizerValidFormat.new(Setting.XML_PARSING_LIBRARY.to_s.to_sym)\n format_sanitizer.sanitize_xml(original_input.raw_content)\n @warnings = format_sanitizer.warnings\n if format_sanitizer.valid?\n original_input.raw_content = format_sanitizer.xml\n else\n @errors = format_sanitizer.errors\n nil\n end\n end", "def initialize(xml_data)\n initialize_data(Sequel.postgres('roadworks'), xml_data)\n end", "def from_qbxml(xml, opts = {})\n hash = Qbxml::Hash.from_xml(xml, underscore: true, schema: @doc)\n\n opts[:no_namespace] ? hash : namespace_qbxml_hash(hash)\n end", "def create_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.resource(\"xmlns\" => \"http://datacite.org/schema/kernel-2.2\", \"xmlns:xsi\" =>\"http://www.w3.org/2001/XMLSchema-instance\", \"xsi:schemaLocation\" => \"http://datacite.org/schema/kernel-2.2 http://schema.datacite.org/meta/kernel-2.2/metadata.xsd\") {\n xml.identifier(:identifierType => \"DOI\"){ xml.text doi.sub(\"doi:\", \"\") }\n xml.creators{\n xml.creator{\n xml.creatorName creator\n xml.nameIdentifier(:nameIdentifierScheme => \"ISNI\") { xml.text name_id }\n }\n }\n xml.titles{\n xml.title title\n xml.title(:titleType => \"Subtitle\") { xml.text subtitle}\n }\n xml.publisher publisher\n xml.publicationYear publicationyear\n xml.subjects{\n xml.subject subject\n }\n xml.contributors{\n xml.contributor(:contributorType => \"DataManager\"){\n xml.contributorName contributor\n }\n }\n xml.dates{\n xml.date(:dateType => \"Valid\"){ xml.text created_date }\n xml.date(:dateType => \"Accepted\"){ xml.text accepted_date }\n }\n xml.language lang\n xml.resourceType(:resourceTypeGeneral => \"Image\"){ xml.text resource_type }\n xml.sizes{\n xml.size data_size\n }\n xml.formats{\n xml.format format\n }\n xml.version version\n xml.rights rights\n xml.descriptions{\n xml.description(:descriptionType => \"Other\") { xml.text description }\n }\n }\n end\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def z3950query (isbn, host, port, db)\n begin\n ZOOM::Connection.open(host, port) do |conn|\n conn.database_name = db\n conn.preferred_record_syntax = 'MARC21'\n rset = conn.search(\"@attr 1=7 #{isbn}\")\n return rset[0].xml\n end\n rescue Exception => e\n STDERR.puts \"\\nERROR Z39.50 query: '#{e}'\" if /failed/.match(e)\n return nil\n end\nend", "def setup\n xml_results = <<BEGIN\n <search:response total=\"2\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"1\" uri=\"/documents/discoverBook.xml\" path=\"fn:doc('/documents/discoverBook.xml')\" score=\"243\" confidence=\"0.97047\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:bookinfo/*:title\">Discoverers <search:highlight>and</search:highlight> Explorers</search:match>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:chapter[1]/*:chapterinfo/*:biblioentry/*:title\">Discoverers <search:highlight>and</search:highlight> Explorers</search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"2\" uri=\"/documents/a_and_c.xml\" path=\"fn:doc('/documents/a_and_c.xml')\" score=\"234\" confidence=\"0.952329\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/a_and_c.xml')/PLAY/PERSONAE/PERSONA[10]\">Officers, Soldiers, Messengers, <search:highlight>and</search:highlight> other Attendants.</search:match>\n </search:snippet>\n </search:result>\n <search:qtext>and</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.009197S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.000083S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.019534S</search:snippet-resolution-time>\n <search:total-time>PT0.029033S</search:total-time>\n </search:metrics>\n</search:response>\nBEGIN\n\n xml_results_noh = <<BEGIN\n <search:response total=\"2\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"1\" uri=\"/documents/discoverBook.xml\" path=\"fn:doc('/documents/discoverBook.xml')\" score=\"243\" confidence=\"0.97047\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:bookinfo/*:title\">Discoverers and Explorers</search:match>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:chapter[1]/*:chapterinfo/*:biblioentry/*:title\">Discoverers and Explorers</search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"2\" uri=\"/documents/a_and_c.xml\" path=\"fn:doc('/documents/a_and_c.xml')\" score=\"234\" confidence=\"0.952329\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/a_and_c.xml')/PLAY/PERSONAE/PERSONA[10]\">Officers, Soldiers, Messengers, and other Attendants.</search:match>\n </search:snippet>\n </search:result>\n <search:qtext>and</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.009197S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.000083S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.019534S</search:snippet-resolution-time>\n <search:total-time>PT0.029033S</search:total-time>\n </search:metrics>\n</search:response>\nBEGIN\n\n results_with_facets = <<-BEGIN\n<search:response total=\"21973\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"9\" uri=\"/Users/clarkrichey/Downloads/wits/wits21402.xml\" path=\"fn:doc(&quot;/Users/clarkrichey/Downloads/wits/wits21402.xml&quot;)\" score=\"196\" confidence=\"0.338805\" fitness=\"0.890659\">\n <search:snippet>\n <search:match path=\"fn:doc(&quot;/Users/clarkrichey/Downloads/wits/wits21402.xml&quot;)/*:Incident/*:Subject\">1 newspaper editor injured in letter <search:highlight>bomb</search:highlight> attack by Informal Anarchist Federation in Turin, Piemonte, Italy</search:match>\n <search:match path=\"fn:doc(&quot;/Users/clarkrichey/Downloads/wits/wits21402.xml&quot;)/*:Incident/*:EventTypeList\">\n<search:highlight>Bombing</search:highlight>\n</search:match>\n <search:match path=\"fn:doc(&quot;/Users/clarkrichey/Downloads/wits/wits21402.xml&quot;)/*:Incident/*:WeaponTypeList/*:WeaponType\">Letter <search:highlight>Bomb</search:highlight></search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"10\" uri=\"/Users/clarkrichey/Downloads/wits/wits23118.xml\" path=\"fn:doc(&quot;/Users/clarkrichey/Downloads/wits/wits23118.xml&quot;)\" score=\"196\" confidence=\"0.338805\" fitness=\"0.890659\">\n <search:snippet>\n <search:match path=\"fn:doc(&quot;/Users/clarkrichey/Downloads/wits/wits23118.xml&quot;)/*:Incident/*:Subject\">1 government employee killed in <search:highlight>bombing</search:highlight> in Ghazni, Afghanistan</search:match>\n <search:match path=\"fn:doc(&quot;/Users/clarkrichey/Downloads/wits/wits23118.xml&quot;)/*:Incident/*:EventTypeList\">\n<search:highlight>Bombing</search:highlight>\n</search:match>\n </search:snippet>\n </search:result>\n <search:facet name=\"Region\">\n <search:facet-value name=\"Africa\" count=\"622\">Africa</search:facet-value>\n <search:facet-value name=\"Central and South America\" count=\"1012\">Central and South America</search:facet-value>\n <search:facet-value name=\"East Asia-Pacific\" count=\"1198\">East Asia-Pacific</search:facet-value>\n <search:facet-value name=\"Eurasia\" count=\"761\">Eurasia</search:facet-value>\n <search:facet-value name=\"Europe\" count=\"1057\">Europe</search:facet-value>\n <search:facet-value name=\"Middle East and Persian Gulf\" count=\"10374\">Middle East and Persian Gulf</search:facet-value>\n <search:facet-value name=\"North America and Caribbean\" count=\"16\">North America and Caribbean</search:facet-value>\n <search:facet-value name=\"South Asia\" count=\"6933\">South Asia</search:facet-value>\n </search:facet>\n <search:facet name=\"Country\">\n <search:facet-value name=\"England\" count=\"200\">England</search:facet-value>\n <search:facet-value name=\"Ireland\" count=\"422\">Ireland</search:facet-value>\n <search:facet-value name=\"Brazil\" count=\"10\">Brazil</search:facet-value>\n </search:facet>\n <search:qtext>bomb</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.420016S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.002873S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.039998S</search:snippet-resolution-time>\n <search:total-time>PT0.463759S</search:total-time>\n </search:metrics>\n</search:response>\n BEGIN\n @search_results = ActiveDocument::SearchResults.new(xml_results)\n @search_results_noh = ActiveDocument::SearchResults.new(xml_results_noh)\n @faceted_results = ActiveDocument::SearchResults.new(results_with_facets)\n end", "def build_results(solr_docs)\n results = Nokogiri::XML::Builder.new do |xml|\n xml.documents( :total => solr_docs[\"response\"][\"numFound\"], :\"page-size\" => solr_docs[\"page_size\"], :\"page-number\" => solr_docs[\"page\"] ) { \n solr_docs[\"response\"][\"docs\"].each do |doc| \n xml.document(:created => check_solr_field(doc[\"fgs_createdDate_date\"]), :\"last-modified\" => check_solr_field(doc[\"fgs_lastModifiedDate_date\"]), :name => doc[\"id\"] ) {\n xml.details {\n solr_docs[\"queries\"].each do |q| \n xml.detail_ check_solr_field(doc[q])\n end\n }\n }\n end\n }\n end\n return results.to_xml\n end", "def to_solr(_solr_doc = {}, _opts = {})\n indexing_service.generate_solr_document\n end", "def transform doc, collection_id, institution\n\n uniqName = createName collection_id\n\n errorStore(uniqName,\"Owning Institution left blank.\") if institution.nil?\n \n tmpdir = Dir.mktmpdir nil, \"#{data_path}/\"\n \n #convert excel into xml\n exceldoc = convertExcel(doc, uniqName, tmpdir)\n \n if exceldoc\n \n xmldoc = Nokogiri::XML::Document.parse(exceldoc) unless @errors.key?(uniqName)\n \n exceldoc.close\n remove exceldoc.path\n \n xmldoc.xpath(\"//Row\").each do |node|\n next if node.child.nil? #empty row\n #get tags from xml\n array = getTags node\n \n #translate these tags into mods equivalent\n hashArray = translate array, uniqName\n\n next unless hashArray\n #break if @errors.key?(uniqName)\n \n #make xml - transformation\n xml = makeXML hashArray, institution\n\n #validate xml against mods\n if validate xml, uniqName\n #puts \"passes mods validation\"\n else\n #puts \"failed mods validation\"\n end\n \n #retrieve filename for mods xml file\n fname = hashArray[0]\n fname = fname.values[0]\n \n #save\n saveXML xml, fname, tmpdir unless fname.nil?\n\n end\n #check if any rows were found\n errorStore(uniqName,(\"ERROR :: No rows found.\")) if xmldoc.xpath(\"//Row\").length == 0\n end\n \n \n #create package\n package tmpdir, uniqName, data_path unless @errors.key?(uniqName)\n FileUtils.rm_r tmpdir\n\n if @errors.key?(uniqName)\n return 500\n else\n return File.join(data_path, \"#{uniqName}.zip\")\n end\n end", "def prepare_update_xml(options = {})\n r = [\"<add#{options.to_xml_attribute_string}>\\n\"]\n # copy and clear pending docs\n working_docs, @pending_documents = @pending_documents, nil\n working_docs.each { |doc| r << doc.xml }\n r << \"\\n</add>\\n\"\n r.join # not sure, but I think Array#join is faster then String#<< for large buffers\n end", "def to_xml\n ret = \"<document documenttype=\\\"\" + @documenttype +\n \"\\\" documentid=\\\"\" + xmlQuote(@documentid, true) + \"\\\">\\n\"\n\n fields.sort.each { | key,value |\n if value.class == Array\n ret << \" <\" + key + \">\\n\"\n if value[0].class == Array\n\t value.sort.each { | v |\n ret << \" <item weight=\\\"\" + v[1].to_s + \"\\\">\" + xmlQuote(v[0].to_s) + \"</item>\\n\"\n }\n else\n\t value.each { | v |\n ret << \" <item>\" + xmlQuote(v.to_s) + \"</item>\\n\"\n }\n end\n ret << \" </\" + key + \">\\n\"\n elsif value.class == Hash\n ret << \" <\" + key + \">\\n\"\n value.sort.each { | k, v |\n ret << \" <item><key>#{k}</key><value>#{v}</value></item>\\n\"\n }\n ret << \" </\" + key + \">\\n\"\n elsif value.class == String or value.is_a? Numeric\n ret << \" <\" + key + \">\" + xmlQuote(value.to_s) + \"</\" + key + \">\\n\"\n elsif value # Struct\n ret << \" <\" + key + \">\\n\"\n value.each_pair { | name, val |\n ret << \" <#{name}>#{xmlQuote(val)}</#{name}>\\n\"\n }\n ret << \" </\" + key + \">\\n\"\n else # nil value, eg. <foo/>\n ret << \" <\" + key + \"/>\\n\"\n end\n }\n ret << \"</document>\"\n ret\n end", "def transform(xml)\n xml = xml.root if xml.is_a? Nokogiri::XML::Document\n xml = Nokogiri::XML(xml, nil, nil, Nokogiri::XML::ParseOptions.new).root unless xml.is_a? Nokogiri::XML::Node\n @document = xml.document\n generate_element(xml)\n end", "def payload(document,payload)\n\t# insert the payload, TODO this should be refactored\n\tdocument = document.gsub('<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\"\"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\"?>#{payload.gsub('IP',@options[\"ip\"]).gsub('FILE',@options[\"exfiltrate\"])}\"\"\")\n\tdocument = document.gsub('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>',\"\"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\"?>#{payload.gsub('IP',@options[\"ip\"]).gsub('FILE',@options[\"exfiltrate\"])}\"\"\")\n\treturn document\nend", "def to_qbxml(hash, opts = {})\n hash = Qbxml::Hash.from_hash(hash, camelize: true)\n hash = namespace_qbxml_hash(hash) unless opts[:no_namespace] \n validate_qbxml_hash(hash) if opts[:validate]\n\n Qbxml::Hash.to_xml(hash, schema: XML_DIRECTIVES[@schema], version: @version)\n end", "def to_solr(solr_doc=Hash.new, *args)\n doc = self.ng_xml\n if doc.root['type']\n shelved_file_count=0\n content_file_count=0\n resource_type_counts={}\n resource_count=0\n preserved_size=0\n first_shelved_image=nil\n add_solr_value(solr_doc, \"content_type\", doc.root['type'], :string, [:facetable])\n doc.xpath('contentMetadata/resource').sort { |a,b| a['sequence'].to_i <=> b['sequence'].to_i }.each do |resource|\n resource_count+=1\n if(resource['type'])\n if resource_type_counts[resource['type']]\n resource_type_counts[resource['type']]+=1 \t\n else\n resource_type_counts[resource['type']]=1\n end\n end\n resource.xpath('file').each do |file|\n content_file_count+=1\n if file['shelve'] == 'yes'\n shelved_file_count+=1\n if first_shelved_image.nil? and file['id'].match(/jp2$/)\n first_shelved_image=file['id']\n end\n end\n if file['preserve'] == 'yes'\n preserved_size += file['size'].to_i\n end\n end\n end\n add_solr_value(solr_doc, \"content_file_count\", content_file_count.to_s, :string, [:searchable, :displayable])\n add_solr_value(solr_doc, \"shelved_content_file_count\", shelved_file_count.to_s, :string, [:searchable, :displayable])\n add_solr_value(solr_doc, \"resource_count\", resource_count.to_s, :string, [:searchable, :displayable])\n add_solr_value(solr_doc, \"preserved_size\", preserved_size.to_s, :string, [:searchable, :displayable])\n resource_type_counts.each do |key, count|\n add_solr_value(solr_doc, key+\"_resource_count\", count.to_s, :string, [:searchable, :displayable])\n end\n if not first_shelved_image.nil?\n add_solr_value(solr_doc, \"first_shelved_image\", first_shelved_image, :string, [:displayable])\n end\n end\n solr_doc\n end", "def to_xml(opts=OPTS)\n vals = values\n types = opts[:types]\n inc = opts[:include]\n\n cols = if only = opts[:only]\n Array(only)\n else\n vals.keys - Array(opts[:except])\n end\n\n name_proc = model.xml_serialize_name_proc(opts)\n x = model.xml_builder(opts)\n x.send(name_proc[opts.fetch(:root_name, model.send(:underscore, model.name).gsub('/', '__')).to_s]) do |x1|\n cols.each do |c|\n attrs = {}\n if types\n attrs[:type] = db_schema.fetch(c, OPTS)[:type]\n end\n v = vals[c]\n if v.nil?\n attrs[:nil] = ''\n end\n x1.send(name_proc[c.to_s], v, attrs)\n end\n if inc.is_a?(Hash)\n inc.each{|k, v| to_xml_include(x1, k, v)}\n else\n Array(inc).each{|i| to_xml_include(x1, i)}\n end\n yield x1 if block_given?\n end\n x.to_xml\n end", "def load_document_proofsheets(xml_url)\n xml_document = REXML::Document.new(fetch_xml(xml_url))\n xml_document.schema_instructions.each do |si|\n uri = si.attributes['uri'].downcase\n url = si.attributes['url']\n # be sure we only get relavent schema types\n if uri.downcase == \"http://www.transami.net/namespace/xmlproof\"\n if is_relative?(url)\n relative_to_xml_url = File.dirname(xml_url) + '/' + url\n else\n relative_to_xml_url = url\n end\n self << Proofsheet.new(relative_to_xml_url)\n end\n end\n return xml_document\n end", "def solr_schema_xml\n template = File.open( \"#{File.dirname(__FILE__)}/../templates/solr_schema.xml.erb\", \"r\" )\n erb = ERB.new( template.read, nil, \"-\" )\n schema = erb.result( binding )\n return schema\n end", "def to_xcql( xml=nil, prefixes=nil, sortkeys=nil )\r\n nil\r\n end", "def as_xml_document(remove_stylesheets = false) \n # pulling this in instead of calling fro it from the file store everytime we need it\n data = current_data\n data = data.gsub(/\\<\\?xml\\-stylesheet.*\\?\\>/,'') if remove_stylesheets\n data ? REXML::Document.new(data) : nil\n end", "def to_solr(doc = {} )\n super(doc)\n\n exemplary_check = Bplmodels::OAIObject.find_with_conditions({\"is_exemplary_image_of_ssim\"=>\"info:fedora/#{self.pid}\"}, rows: '1', fl: 'id' )\n if exemplary_check.present?\n doc['exemplary_image_ssi'] = exemplary_check.first[\"id\"]\n end\n\n doc\n\n end", "def xml\n base = REXML::Element.new(@name)\n if @row.class == DBI::Row # only if we have a row otherwise return an empty xml node\n # prime\n context = nil\n rowcontext = base\n # loop through each column\n @row.each_with_name do |val, colpath|\n context = rowcontext # start at the top of the row for each column\n parents = colpath.split('/') # split on any path dividers, i.e. parent/parent/child\n child = parents.pop # get the child off the parents\n # loop through all the parents\n parents.each.each do |p|\n found = REXML::XPath.first(context, p) # does the element already exist?\n if not found # if not...\n el = p.gsub(/[[].*[]]$/,'') # remove index if there is one\n found = context.add_element(el) # add the element\n end\n context = found # this parent is now our new context\n end\n # do the child (the end of the tree branch)\n if child =~ /^@(.*)/ # is it labeled an attribute with @?\n context.add_attribute($1, val.to_s) # add attribute\n elsif @attributes.include?(child) # or is it in the attributes list?\n context.add_attribute(child, val.to_s) # add attribute\n else\n found = REXML::XPath.first(context, child) # does it already exist?\n if not found # if not...\n el = child.gsub(/[[].*[]]$/,'') # remove index if there is one\n found = context.add_element(el) # add the element\n end\n context = found # the child is now our new context\n context.add_text(val.to_s) # insert the text node as val\n end\n end\n end\n return base\n end", "def to_qbxml(hash, opts = {})\n hash = Qbxml::Hash.from_hash(hash, camelize: true)\n hash = namespace_qbxml_hash(hash) unless opts[:no_namespace] \n validate_qbxml_hash(hash) if opts[:validate]\n Qbxml::Hash.to_xml(hash, { xml_directive: XML_DIRECTIVES[@schema] }.merge(opts[:to_xml_opts] || {}))\n end", "def xml_escape(input)\n return input.to_s.to_xs\n end", "def to_xml(data, columns = nil, buffer = \"\", options = {})\n require 'builder'\n options = DEFAULT_OPTIONS.merge(options)\n ten, ren, cen = options[:table_element_name], \n options[:row_element_name],\n options[:column_element_name]\n buffer << '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' << \"\\n\"\n buffer << \"<#{ten}>\"<< \"\\n\"\n data.each{|row|\n buffer << \" \" << \"<#{ren}>\" << \"\\n\"\n columns.each{|column|\n buffer << \" \" << \"<#{column}>#{row[column].to_s.to_xs}</#{column}>\" << \"\\n\"\n }\n buffer << \" \" << \"</#{ren}>\" << \"\\n\"\n }\n buffer << \"</#{ten}>\"<< \"\\n\"\n buffer\n end", "def normalize!\n doc = xmldoc\n nodes doc.xpath(ITEMS_XPATH) do |node|\n content_node = node.xpath(ITEM_FILE_XPATH).first\n src = content_node.attributes['src'].to_s\n\n src = URI(src)\n item = get_item(src.to_s)\n\n filepath = URI(item.normalized_hashed_path(:relative_to => self))\n if src.fragment\n filepath.fragment = src.fragment\n end\n\n content_node['src'] = filepath.to_s\n end\n\n\n root = read_xml\n\n # Replace the node, bit messy\n node = root.xpath(ROOT_XPATH).first\n doc_partial = Nokogiri::XML(doc.to_s)\n node.replace(doc_partial.root)\n\n # Write it back\n data = root.to_s\n write(data)\n end", "def query(query)\n raw_query(query).map do |row|\n row = row.map do |item| \n # If the row entry is a String, it is the result already, and not, as \n # Neo4j.build would expect, the URL of a Neo4j node or relationship. The\n # same is true for all non-hashes.\n next item unless item.is_a?(Hash)\n build_from_hash(item)\n end\n \n row = row.first if row.length == 1\n row\n end\n end", "def import\n @uploaded_io = params[:q].read()\n Hash.from_xml(@uploaded_io).each do |key, value|\n value.each do |column|\n column.delete(\"id\")\n puts column\n @quote_db = QuoteDb.new(column)\n \n @quote_db.save \n \n \n #puts params[:column][:quote] \n end\n \n end\n \n end", "def rexmlify(data)\n\t\tdoc = data.kind_of?(REXML::Document) ? data : REXML::Document.new(data)\n\tend", "def html_content_to_solr( ds, solr_doc=Solr::Document.new )\n \n text = CGI.unescapeHTML(ds.content)\n doc = Nokogiri::HTML(text)\n \n # html to story_display\n stories = doc.xpath('//story')\n \n stories.each do |story|\n solr_doc << Solr::Field.new(:story_display => story.children.to_xml)\n end\n \n #strip out text and put in story_t\n text_nodes = doc.xpath(\"//text()\")\n text = String.new\n \n text_nodes.each do |text_node|\n text << text_node.content\n end\n \n solr_doc << Solr::Field.new(:story_t => text)\n \n return solr_doc\n end", "def fake_data_generator(query, output_document)\n ############\n # Removed this, as it is not necessary\n ############\n #uris_hash = Hash.new\n #uris_hash.default_proc = proc {|k| k}\n #File.foreach(query_document_location) {|line|\n # case line\n # when /^PREFIX (\\w+:) (<.+)>/i #if the line starts with PREFIX, find the prefix and its full URI and store them in a hash\n # uris_hash[$1] = $2\n # \n # when /^SELECT|CONSTRUCT|ASK|DESCRIBE/i #This line corresponds to the first line of the final query\n # query = line\n # when /(^\\n|})/\n # query << line\n # else \n # uris_hash.each { |k, v| \n # line[k] &&= v } #changes all occurances of a prefix with the full URI\n # line.match(/(<\\S+)/)\n # line[$1] &&= $1.concat(\">\")\n # line.gsub!(/\\ba\\b/, \"<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\") #changes \"a\" with the whole URI of rdf:type\n # query << line\n # end\n #}\n \n $stderr.puts query\n parsed = SPARQL.parse(query) # this is a nightmare method, that returns a wide variety of things! LOL!\n \n rdf_query=''\n if parsed.is_a?(RDF::Query) # we need to get the RDF:Query object out of the list of things returned from the parse\n rdf_query = parsed\n else\n parsed.each {|c| rdf_query = c if c.is_a?(RDF::Query) }\n end\n\n patterns = rdf_query.patterns # returns the triple patterns in the query\n\n variables = Hash.new # we're going to create a random string for every variable in the query\n patterns.each do |p| \n vars = p.unbound_variables # vars contains e.g. [:s, #<RDF::Query::Variable:0x6a400(?s)>] \n vars.each {|var| variables[var[0]] = RDF::URI(\"http://fakedata.org/\" + (0...10).map { ('a'..'z').to_a[rand(26)] }.join)}\n # now variables[:s] = <http://fakedata.org/adjdsihfrke>\n end\n\n File.open(output_document, \"w\") {|file|\n #now iterate over the patterns again, and bind them to their new value\n patterns.each do |triple| # we're going to create a random string for every variable\n if triple.subject.variable?\n var_symbol = triple.subject.to_sym # covert the variable into a symbol, since that is our hash key\n triple.subject = variables[var_symbol] # assign the random string for that symbol\n end\n\n if triple.predicate.variable?\n var_symbol = triple.predicate.to_sym # covert the variable into a symbol, since that is our hash key\n triple.predicate = variables[var_symbol] # assign the random string for that symbol\n end\n \n # special case for objects, since they can be literals\n if triple.object.variable?\n var_symbol = triple.object.to_sym # covert the variable into a symbol, since that is our hash key\n triple.object = variables[var_symbol] # assign the random string for that symbol\n file.write triple.to_rdf\n file.write \"\\n\"\n ########\n # What will you do with triples that have a literal as their value, rather than a <URI>?\n ########\n else # this ensures that it is written even if the object is not a variable\n file.write triple.to_rdf\n file.write \"\\n\"\n end\n end\n }\n\nend", "def parse_xml(xml)\n hash = XmlSimple.xml_in(xml)\n hash['query']#return just the results of the query\nend", "def to_sparql(**options)\n to_sxp(**options)\n end", "def to_sparql(**options)\n to_sxp(**options)\n end", "def converted_doc\n # In the future, change to point to reference material within Tutor\n return @converted_doc unless @converted_doc.nil?\n\n @converted_doc = doc.dup\n\n @converted_doc.css(\"[src]\").each do |link|\n src = link.attributes[\"src\"]\n uri = Addressable::URI.parse(src.value)\n\n if uri.absolute?\n # Since this is embedded content, make sure it is https\n uri.scheme = \"https\"\n src.value = uri.to_s\n else\n next if uri.path.blank?\n\n # Relative link: make secure and absolute\n src.value = OpenStax::Cnx::V1.url_for(uri, secure: true)\n end\n end\n\n @converted_doc.css(\"[href]\").each do |link|\n href = link.attributes[\"href\"]\n uri = Addressable::URI.parse(href.value)\n\n # Anchors don't need to be https\n next if uri.absolute? || uri.path.blank?\n\n # Relative link: make secure and absolute\n href.value = OpenStax::Cnx::V1.url_for(uri, secure: true)\n end\n\n @converted_doc\n end", "def sanitize_data\n data + \"datacite: #{create_xml.to_xml.gsub(\"%\", \"%25\").gsub(\":\", \"%3A\").gsub(\"\\n\", \"%0D%0A\").gsub(\"\\r\", \"\")}\\n\"\n end", "def whereise query_str\n <<-SPARQL.strip_heredoc\n WHERE {\n #{query_str}\n }\n SPARQL\n end", "def escape_xml(value)\n value.to_s.gsub(/[&<>\"']/) { |s| ESCAPE_TABLE[s] } # or /[&<>\"']/\n end", "def to_rexml\n REXML::Document.new(to_s)\n end", "def to_solr\n @datastreams.each do |key, value|\n if self.respond_to?(\"#{key}_to_solr\")\n self.send(\"#{key}_to_solr\")\n end #if\n end\n \n fulltext_to_solr\n \n return @solr_document\n end", "def build_query(payload)\n if payload[:file]\n payload\n else\n Rack::Utils.build_nested_query(payload)\n end\n end", "def resultsToXML(result)\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct! :xml, :encoding => \"UTF-8\"\n xml.declare! :DOCTYPE, :Resultado, :SYSTEM, \"Resultados.dtd\"\n xml.tag! 'xml-stylesheet', :type => \"text/xsl\", :href => \"Resultados.xsl\"\n xml.resultado do |r|\n xml.pregunta do |p|\n @question.each{ |q| p.item q }\n end\n result.each { \n |r| xml.documento(:id => r[@INDEX_ID]) do |d| \n d.titulo r[@INDEX_TITLE];\n perc = (r[1]*100).round(2).to_s;\n d.relevancia perc + \"%\"; d.texto r[@INDEX_PATH]\n end \n }\n end\n #UGLY CODE (removing extra <to_s/> from the xml builder)\n f = File.open(\"Results.xml\", 'w')\n f.write(xml)\n f.close\n f = File.open(\"Results.xml\", 'r')\n data = f.read\n data = data.gsub!(\"<to_s/>\", \"\")\n f.close\n f = File.open(\"Results.xml\", 'w')\n f.write(data)\n f.close\n return data\n end", "def voting_record_xml_to_table(voting_record_xml)\n src = Nokogiri::XML(voting_record_xml)\n xslt = stylesheet\n xslt.transform(src).inner_html.to_s.html_safe\n end", "def ParseQuery(n)\n\trequire \"rexml/document\"\n\tinclude REXML\n\tquery_file = REXML::Document.new(File.open($options[:i], \"r\"))\n\tif !Dir.exist?(\"#{$dir_queryfile}/queries_converted\") # \"./model-files/inverted-index_converted/0_dictionary\"\n\t\tDir.mkdir(\"#{$dir_queryfile}/queries_converted\")\n\tend\n\n\tp query_number = 1 #to name file_name\n\tquery_file.elements.each(\"xml/topic\") do |topic|\n\t\t# parse query\n\t\tfile_name = \"query#{query_number}\"\n\t\tputs \"Parse #{file_name}...\"\n\t\tquery_f = File.open(\"#{$dir_queryfile}/queries_converted/#{file_name}.xml\", 'w')\n\t\tquery_f.write(topic)\n\t\tquery_f.close()\n\n\t\t# create ngram\n\t\tcase n\n\t\twhen 1 # unigram only\n\t\t\t%x( src/bin/create-ngram -vocab src/data/vocab.all -o #{$dir_queryfile}/queries_converted/#{file_name}_ngram.all -n 1 -encoding utf8 #{$dir_queryfile}/queries_converted/#{file_name}.xml )\n\t\twhen 2 # bigram only\n\t\t\t%x( src/bin/create-ngram -vocab src/data/vocab.all -o #{$dir_queryfile}/queries_converted/#{file_name}_ngram.all -n 2 -encoding utf8 #{$dir_queryfile}/queries_converted/#{file_name}.xml )\n\t\twhen 3 # unigram + bigram merge\n\t\t\t%x( src/bin/create-ngram -vocab src/data/vocab.all -o #{$dir_queryfile}/queries_converted/unigram.temp -n 1 -encoding utf8 #{$dir_queryfile}/queries_converted/#{file_name}.xml )\n\t\t\t%x( src/bin/create-ngram -vocab src/data/vocab.all -o #{$dir_queryfile}/queries_converted/bigram.temp -n 2 -encoding utf8 #{$dir_queryfile}/queries_converted/#{file_name}.xml )\n\t\t\t%x( src/bin/merge-ngram -o #{$dir_queryfile}/queries_converted/#{file_name}_ngram.all #{$dir_queryfile}/queries_converted/unigram.temp #{$dir_queryfile}/queries_converted/bigram.temp )\n\t\tend\n\t\tquery_number += 1\n\tend\nend", "def to_solr(solr_doc=Hash.new, opts={})\n solr_doc = super(solr_doc, opts)\n solr_doc.merge!(ActiveFedora::SolrService.solr_name(:event_date_time, :date) => event_date_time,\n ActiveFedora::SolrService.solr_name(:event_type, :symbol) => event_type,\n ActiveFedora::SolrService.solr_name(:event_outcome, :symbol) => event_outcome,\n ActiveFedora::SolrService.solr_name(:event_id_type, :symbol) => event_id_type,\n ActiveFedora::SolrService.solr_name(:event_id_value, :symbol) => event_id_value, \n ActiveFedora::SolrService.solr_name(:linking_object_id_type, :symbol) => linking_object_id_type,\n ActiveFedora::SolrService.solr_name(:linking_object_id_value, :symbol) => linking_object_id_value)\n return solr_doc\n end", "def cmd_db_import_qualys_xml(*args)\n\t\t\treturn unless active?\n\t\t\tif not (args and args.length == 1)\n\t\t\t\tprint_status(\"Usage: db_import_qualys_xml <result.xml>\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tif not File.readable?(args[0])\n\t\t\t\tprint_status(\"Could not read the Qualys file\")\n\t\t\t\treturn\n\t\t\tend\n\t\t\tframework.db.import_qualys_xml_file(:filename => args[0])\n\t\tend", "def xml_escape(input); end", "def exec(query_hash)\n outputs[:exercises] = []\n OpenStax::Exercises::V1.exercises(query_hash)['items'].each do |wrapper|\n exercise = Content::Models::Exercise.find_or_initialize_by(url: wrapper.url)\n uid = wrapper.uid\n number_version = uid.split('@')\n exercise.number = number_version.first\n exercise.version = number_version.last\n exercise.title = wrapper.title\n exercise.content = wrapper.content\n exercise.save\n transfer_errors_from(exercise, {type: :verbatim}, true)\n\n lo_tags = wrapper.los\n non_lo_tags = wrapper.tags - lo_tags\n run(:tag, exercise, lo_tags, tag_type: :lo)\n run(:tag, exercise, non_lo_tags)\n\n outputs[:exercises] << exercise\n end\n end", "def to_sparql(**options)\n str = to_triple.map {|term| term.to_sparql(**options)}.join(\" \")\n quoted? ? ('<<' + str + '>>') : str\n end", "def xsl_html\n Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), '/xslt/fgdc2html.xsl')))\n end", "def wrap_in_version(xml_rq)\n if QBWC.api == :qbpos\n %Q( <?qbposxml version=\"#{QBWC.min_version}\"?> ) + xml_rq\n else\n %Q( <?qbxml version=\"#{QBWC.min_version}\"?> ) + xml_rq\n end\n end", "def create_new_xml_document( options = nil)\n p \"new xml doc created!\"\n \n blog_doc = <<-eos\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->\n<!-- It contains information about your blog's posts, comments, and categories. -->\n<!-- You may use this file to transfer that content from one site to another. -->\n<!-- This file is not intended to serve as a complete backup of your blog. -->\n\n<!-- To import this information into a WordPress blog follow these steps. -->\n<!-- 1. Log into that blog as an administrator. -->\n<!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). -->\n<!-- 3. Choose \"WordPress\" from the list. -->\n<!-- 4. Upload this file using the form provided on that page. -->\n<!-- 5. You will first be asked to map the authors in this export file to users -->\n<!-- on the blog. For each author, you may choose to map to an -->\n<!-- existing user on the blog or to create a new user -->\n<!-- 6. WordPress will then import each of the posts, comments, and categories -->\n<!-- contained in this file into your blog -->\n\n<!-- generator=\"WordPress/MU\" created=\"2009-03-10 00:13\"-->\n<rss version=\"2.0\"\n\txmlns:excerpt=\"http://wordpress.org/export/1.0/excerpt/\"\n\txmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n\txmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"\n\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n\txmlns:wp=\"http://wordpress.org/export/1.0/\"\n>\n\n<channel>\n\t<title>xxx</title>\n\t<link>xxx</link>\n\t<description>xxx</description>\n\t<pubDate>xxx</pubDate>\n\t<generator>http://wordpress.org/?v=MU</generator>\n\t<language>en</language>\n\t<wp:wxr_version>1.0</wp:wxr_version>\n\t<wp:base_site_url>http://wordpress.com/</wp:base_site_url>\n\t<wp:base_blog_url>xxx</wp:base_blog_url>\n\t<wp:category><wp:category_nicename>uncategorized</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Uncategorized]]></wp:cat_name></wp:category>\n\t<image>\n\t\t<url>http://www.gravatar.com/blavatar/bc8a29036e9d9925e702dcf90996d0cd?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>\n\t\t<title>xxx</title>\n\t\t<link>xxx</link>\n\t</image>\n \n</channel>\n</rss>\n eos\n \n doc = Hpricot.XML(blog_doc)\n \n #change created date to be right-now\n #element at fixed-offset 30\n #<!-- generator=\"WordPress/MU\" created=\"2009-03-10 00:13\"-->\n doc.search(\"*\")[30].swap(\n \"<!-- generator=\\\"WordPress/MU\\\" created=\\\"#{Time.now.strftime(\"%Y-%m-%d %H:%M\")}\\\"-->\"\n )\n \n #replace default_title, default_link, the name of the blog and link to blog (wordpress), respectively\n doc.search(\"title\")[0].inner_html = @options[:default_title]\n doc.search(\"title\")[1].inner_html = @options[:default_title]\n doc.search(\"link\")[0].inner_html = @options[:default_link]\n doc.search(\"link\")[1].inner_html = @options[:default_link]\n\n #replace default_description, pub_date\n doc.search(\"description\").inner_html = @options[:default_description]\n doc.search(\"pubDate\").inner_html = @options[:pub_date]\n doc.search(\"wp:base_blog_url\").inner_html = @options[:base_blog_url]\n\n @doc = doc\n end", "def set_content_as_sax()\n # We can't use this handler to create database content because XMLDB:API specifies\n # that the only way how to store content into databse is via store_resource method\n # so we hav to create DOM in memory\n return XML::SaxDomCreator.new(self)\n end", "def XQuery(model, &block)\n XQuery::Generic.with(model, &block)\nend", "def crossref_query\n CrossrefQuery.generate_query_from_text( ref_apa_6 )\n end", "def doc_transformed(root)\n\n end", "def xslt_transform(document, xsl_file)\n xslt = XML::XSLT.new()\n # get xml document\n xslt.xml = document\n # get xslt document\n xslt.xsl = xsl_file\n\n # return transformation output\n return xslt.serve() \n end", "def to_nokogiri(doc) # :nodoc:\n row = doc.create_element('row'); doc.add_child(row)\n each { |key,value|\n element = doc.create_element(key.to_s)\n element.add_child(doc.create_text_node(value.to_s))\n row.add_child(element)\n }\n row\n end", "def render_bylaw(doc, base_url='')\n params = { 'base_url' => base_url }\n\n @@xslt[:bylaw].transform(doc, Nokogiri::XSLT.quote_params(params)).to_s\n end", "def build_sru_query(input)\n if input[0..4] == 'lccn:'\n \"bath.lccn=#{input[5..-1]}\"\n else\n \"bath.isbn=#{input}\"\n end\nend", "def cmd_db_import_nessus_xml(*args)\n\t\t\treturn unless active?\n\t\t\tif (not (args and args.length == 1))\n\t\t\t\tprint_status(\"Usage: db_import_nessus_xml <nessus.nessus>\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tif (not File.readable?(args[0]))\n\t\t\t\tprint_status(\"Could not read the NESSUS file\")\n\t\t\t\treturn\n\t\t\tend\n\t\t\tframework.db.import_nessus_xml_file(:filename => args[0])\n\t\tend", "def build_hash_documents( dif_xml=nil )\n difs = []\n self.document = load_xml( dif_xml ) unless dif_xml.nil?\n \n unless document.nil?\n difs = document_to_object\n else\n raise ArgumentError, \"No XML provided!\"\n end\n\n difs\n end", "def xsl_html\n Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), '../xslt/iso2html.xsl')))\n end", "def to_xml(opts = {})\n to_raw.to_xml({ :root => 'document', :dasherize => true }.merge(opts))\n end", "def sdmx_doc(cache, url=ECB_ALL_RATES_URL)\n rates_source = !!cache ? cache : url\n Nokogiri::XML(open(rates_source))\n end", "def call\n refs = replace_refs\n replace_references(refs)\n\n doc\n end", "def xslt(stylesheet_file_path, document, params={})\n require 'nokogiri'\n document = Nokogiri::XML(document) if document.is_a?(String)\n stylesheet = Nokogiri::XSLT.parse(render(stylesheet_file_path))\n stylesheet.apply_to(Nokogiri::XML(document.to_xml), params)\n end", "def make_document(xml)\n xml.is_a?(Atom::XML::Document) ? xml : Atom::XML::Document.string(xml)\n end", "def solr_doc_data\n doc = {}\n\n\n # To support indexing of records of different classes, create a unique id by concatenating\n # class name (downcased and underscored) and record id (see solr_id below)...\n doc[:id] = solr_id\n\n\n # ... then record class name and record id as record_type, record_id\n doc[:record_type] = self.class.to_s.underscore\n doc[:record_id] = self.id\n\n\n # This will add all attributes that correspond to database columns (make sure these are all in the schema, or modify)\n attrs = self.class.column_names.map { |n| n.to_sym }\n attrs.each do |a|\n if a != :id\n doc[a] = self[a]\n end\n end\n\n\n ######################################################\n # Here you can add other elements to the doc as needed\n #\n # If you are indexing records from multiple models, it's a good idea to use a case statement here\n # to specify which fields to index for which model, e.g.:\n #\n # case self\n # when Foo\n # doc['foo_attribute'] = self.foo_attribute\n # when Boo\n # doc['boo_attribute'] = self.boo_attribute\n # end\n #\n ######################################################\n\n\n # remove nil/empty values\n doc.delete_if { |k,v| nil_or_empty?(v) }\n\n\n doc\n end", "def existing_solr_doc_hash(id)\n document_model.new(unique_key => id).to_solr if document_model && id.present?\n end", "def initialize(rows = [])\n raise ArgumentError, 'Missing class names' if rows.nil?\n\n xml = '<?xml version=\"1.0\" encoding=\"utf-8\"?>'\n\n xml << '<sphinx:docset><sphinx:schema>'\n\n @xml_docs = []\n classes = []\n\n rows.each do |row|\n object = nil\n\n if row.kind_of? CouchRest::Document\n object = row\n elsif row.kind_of? Hash\n row = row['value'] if row['couchrest-type'].nil?\n\n if row and (class_name = row['couchrest-type'])\n object = eval(class_name.to_s).new(row) rescue nil\n end\n end\n\n if object and object.sphinx_id\n classes << object.class if not classes.include? object.class\n @xml_docs << XMLDoc.from_object(object)\n end\n end\n\n field_names = classes.collect { |clas| clas.fulltext_keys rescue []\n }.flatten.uniq\n\n field_names.each do |key, value|\n xml << \"<sphinx:field name=\\\"#{key}\\\"/>\"\n end\n\n xml << '<sphinx:field name=\"couchrest-type\"/>'\n xml << '<sphinx:attr name=\"csphinx-class\" type=\"multi\"/>'\n\n xml << '</sphinx:schema>'\n\n @xml_header = xml\n @xml_footer = '</sphinx:docset>'\n end", "def process(parsedXMLdocument)\n raise \"XInclude::process expects an REXML::Document\" unless parsedXMLdocument.is_a?(REXML::Document)\n newDoc = REXML::Document.new(nil,parsedXMLdocument.context.clone)\n copyElementWithReplacements(parsedXMLdocument, newDoc)\n return newDoc\n end", "def moddify_document(path)\n doc = nil\n File.open(path,'r+') do | file|\n xml_string = file.read\n doc = process_xml(xml_string) if valid_xml?(xml_string)\n end\n doc\nend", "def index_document( url_string = 'http://localhost:8983/solr/update' )\n index_doc = create_base_add_doc\n root = index_doc.root\n begin\n doc = to_solr_index_doc\n root << doc\n #set up basic connection\n @url = URI.parse( url_string )\n @http = Net::HTTP.new( @url.host, @url.port )\n \n response, body = @http.post( @url.path, index_doc.to_s, { 'Content-type'=>'text/xml; charset=utf-8' } )\n \n response, body = @http.post( @url.path, \"<commit/>\", { 'Content-type'=>'text/xml; charset=utf-8' } )\n\n rescue Exception => ex\n #puts \"Something went wrong with item: #{item.id}: #{item.title}\"\n puts ex.inspect\n puts ex.backtrace\n end\n end", "def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end", "def to_solr(solr_doc=Hash.new, opts={})\n\n active_fedora_model_s = solr_doc[\"active_fedora_model_s\"] if solr_doc[\"active_fedora_model_s\"]\n actual_class = active_fedora_model_s.constantize if active_fedora_model_s\n if actual_class && actual_class != self.class && actual_class.superclass == ::FileAsset\n solr_doc\n else\n super(solr_doc,opts)\n end\n end", "def query_normalization\n uri = Addressable::URI.parse(@url)\n tmp_q = (uri.query_values || {}).merge(@query)\n\n return tmp_q if tmp_q.empty? && tmp_q.values.all? { |v| v.encode == @encoding }\n tmp_q.each_key { |k| tmp_q[k].encode! @encoding }\n tmp_q\n end", "def convert_doc_attributes(hash)\n converted_hash = hash.inject({}) do |ret, (key, value)|\n if key == \"id\"\n ret[\"id\"] = value.to_s.split(\"/\").last\n else\n ret[reverse_lookup_solr_field(key).to_s] = value\n end\n ret\n end\n self.select_fields.each do |select_field|\n converted_hash[select_field.to_s] = nil if !converted_hash.has_key?(select_field.to_s)\n end\n converted_hash\n end", "def new_synset(sax, author_id, offset = 0)\n RawSynset.new.tap do |synset|\n synset.id = offset + sax.id[/\\d+/].to_i\n synset.author_id = author_id\n synset.words_ids = sax.words.map(&:id)\n synset.definitions_ids = sax.definitions.map(&:id)\n end\nend", "def solr_document\n config = Configuration.instance\n\n # add fields required by activemedusa\n doc = {\n config.solr_id_field => self.id,\n config.solr_class_field => self.class.entity_class_uri,\n config.solr_parent_uri_field =>\n self.rdf_graph.any_object('http://fedora.info/definitions/v4/repository#hasParent').to_s,\n }\n\n # add fields corresponding to property statements\n self.class.properties.select{ |p| p.class == self.class }.each do |prop|\n doc[prop.solr_field] = self.send(prop.name)\n end\n\n # add fields corresponding to associations\n self.class.associations.\n select{ |a| a.source_class == self.class and\n a.type == Association::Type::BELONGS_TO }.each do |assoc|\n obj = self.send(assoc.name)\n doc[assoc.solr_field] = obj.repository_url if\n obj.respond_to?(:repository_url)\n end\n\n doc\n end", "def generate_xml_from_hash(hash, base_type, collection_key)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.send(base_type) { process_simple_array(collection_key, hash, xml) }\n end\n\n builder.to_xml\n end", "def main\n if (argnum = $*.size) != 2\n errmsg = 'wrong number of arguments'\\\n \"(given #{argnum}, expected 2).\"\n raise ArgumentError, errmsg\n return 1\n end\n x = XPathToSQL.new(*$*)\n conv_sql = x.xpath_to_sql\n res_ids = x.lookup(conv_sql[:sql], conv_sql[:labels])\n res_ids.each{\n puts \"=== #{_1} ===\"\n x.printexe(_1)\n }\n return 0\nend", "def strInsertEntry(xmlNode)\n name = xmlNode.name ;\n scanSchemaFromDB(name) ;\n element = @xsd.findElement(name) ;\n sqlRow = element.expandedStructure.xml2sqlRow(xmlNode) ;\n return element.sqlTable.strSimpleInsert(sqlRow) ;\n end", "def create_classic_query(options)\n raise ArgumentError, \"Query name is not present\" unless options[:query_name]\n raise ArgumentError, \"Parent list id is not present\" unless options[:parent_list_id]\n raise ArgumentError, \"Criteria is required\" unless options[:criteria]\n\n options[:visibility] ||= 0\n\n request_body = ''\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n xml.instruct!\n\n xml.Envelope do\n xml.Body do\n xml.CreateQuery do\n xml.QUERY_NAME options[:query_name]\n xml.PARENT_LIST_ID options[:parent_list_id]\n xml.VISIBILITY options[:visibility]\n\n xml.PARENT_FOLDER_ID options[:parent_folder_id] if options.has_key?(:parent_folder_id)\n xml.SELECT_COLUMNS options[:select_columns] if options.has_key?(:select_columns)\n xml.ALLOW_FIELD_CHANGE options[:allow_field_change] if options.has_key?(:allow_field_change)\n\n xml.CRITERIA do\n xml.TYPE options[:criteria][:type] if options[:criteria].has_key?(:type)\n\n options[:criteria][:expressions].each do |exp|\n xml.EXPRESSION do\n xml.TYPE exp[:type] if exp.has_key?(:type)\n xml.COLUMN_NAME exp[:column_name] if exp.has_key?(:column_name)\n xml.OPERATORS exp[:operators] if exp.has_key?(:operators)\n xml.VALUES exp[:values] if exp.has_key?(:values)\n xml.TABLE_ID exp[:table_id] if exp.has_key?(:table_id)\n xml.LEFT_PARENS exp[:left_parens] if exp.has_key?(:left_parens)\n xml.RIGHT_PARENS exp[:right_parens] if exp.has_key?(:right_parens)\n xml.AND_OR exp[:and_or] if exp.has_key?(:and_or)\n if exp[:rt_expressions]\n exp[:rt_expressions].each do |rt_exp|\n xml.RT_EXPRESSION do\n xml.TYPE rt_exp[:type] if rt_exp.has_key?(:type)\n xml.COLUMN_NAME rt_exp[:column_name] if rt_exp.has_key?(:column_name)\n xml.OPERATORS rt_exp[:operators] if rt_exp.has_key?(:operators)\n xml.VALUES rt_exp[:values] if rt_exp.has_key?(:values)\n xml.LEFT_PARENS rt_exp[:left_parens] if rt_exp.has_key?(:left_parens)\n xml.RIGHT_PARENS rt_exp[:right_parens] if rt_exp.has_key?(:right_parens)\n xml.AND_OR rt_exp[:and_or] if rt_exp.has_key?(:and_or)\n end\n end\n end\n end\n end\n end\n\n if options[:behavior]\n xml.BEHAVIOR do\n xml.OPTION_OPERATOR options[:behavior] if options.has_key?(:behavior)\n xml.TYPE_OPERATOR options[:type_operator] if options.has_key?(:type_operator)\n xml.MAILING_ID options[:mailing_id] if options.has_key?(:mailing_id)\n xml.REPORT_ID options[:report_id] if options.has_key?(:report_id)\n xml.LINK_NAME options[:link_name] if options.has_key?(:link_name)\n xml.WHERE_OPERATOR options[:where_operator] if options.has_key?(:where_operator)\n xml.CRITERIA_OPERATOR options[:criteria_operator] if options.has_key?(:criteria_operator)\n xml.VALUES options[:values] if options.has_key?(:values)\n end\n end\n end\n end\n end\n\n doc = send_xml_api_request(request_body)\n result_dom(doc)['ListId']\n end", "def load_xml(source)\n #begin\n if source.is_a? Nokogiri::XML::Document\n @document = source\n else\n #source =~ /\\<DIF\\>/\n if source.size < 255 and File.exists? source\n source = File.read source\n end\n @document = Nokogiri::XML::Document.parse( source, nil, nil ) #, Nokogiri::XML::ParseOptions::NOBLANKS\n end\n # Sets all properties like Entry_ID for this instance\n load_hash(document_to_hash)\n \n #rescue => e\n #puts e.backtrace\n #raise ArgumentError, \"Cannot load DIF XML: \" + e.message[0..255]\n #end\n end", "def to_xml\n find_correct_build.to_xml\n end", "def affiliations_xml\n <<-NODE\n<iq type='result'\n from='pubsub.shakespeare.lit'\n to='[email protected]'\n id='affil1'>\n <pubsub xmlns='http://jabber.org/protocol/pubsub'>\n <affiliations>\n <affiliation node='node1' affiliation='owner'/>\n <affiliation node='node2' affiliation='owner'/>\n <affiliation node='node3' affiliation='publisher'/>\n <affiliation node='node4' affiliation='outcast'/>\n <affiliation node='node5' affiliation='member'/>\n <affiliation node='node6' affiliation='none'/>\n </affiliations>\n </pubsub>\n</iq>\n NODE\nend", "def to_opml\n\t\tdoc = Nokogiri::XML::DocumentFragment.parse \"\"\n\t\tNokogiri::XML::Builder.with(doc) { |xml|\n\t\t\txml.outline(:title => self.title, :text => self.title) {\n\t\t\t\tself.feeds.each do |feed|\n\t\t\t\t\txml.__send__ :insert, feed.to_opml\n\t\t\t\tend\n\t\t\t}\n\t\t}\n\t\treturn doc\n\tend", "def from_trusted_xml(xml)\n from_xml xml, []\n end" ]
[ "0.5513982", "0.51492333", "0.5118726", "0.50949293", "0.48850235", "0.48745278", "0.48360753", "0.46812204", "0.46770287", "0.46688595", "0.46593094", "0.46211913", "0.4581038", "0.4566015", "0.4557557", "0.45343542", "0.45343143", "0.45018125", "0.449809", "0.44949844", "0.4494175", "0.44861102", "0.44695875", "0.4462858", "0.4443993", "0.44388244", "0.44353768", "0.4428245", "0.44091296", "0.44069687", "0.44065127", "0.43790135", "0.43772244", "0.43609008", "0.43597692", "0.43589565", "0.43573433", "0.43571472", "0.43510458", "0.4348428", "0.43453404", "0.43328342", "0.4330255", "0.43271652", "0.43271652", "0.43080217", "0.428484", "0.4283205", "0.42772758", "0.42698437", "0.42629716", "0.42544279", "0.4248735", "0.42338634", "0.42325437", "0.42219204", "0.42189348", "0.4214762", "0.4210239", "0.4209569", "0.42083573", "0.42070073", "0.41938013", "0.4181912", "0.41776943", "0.41608998", "0.415061", "0.41429296", "0.41417912", "0.41341996", "0.41249174", "0.4124796", "0.40892133", "0.40870416", "0.40854037", "0.40820867", "0.4076005", "0.40748328", "0.4067031", "0.40557083", "0.40510306", "0.40503573", "0.40470025", "0.40415055", "0.403802", "0.403802", "0.40319124", "0.40261412", "0.40247047", "0.402393", "0.40234962", "0.40228027", "0.4019982", "0.40190718", "0.40188894", "0.40164784", "0.40125373", "0.4011356", "0.401103", "0.40090698" ]
0.7102761
0
q! method, she's an odd one, takes a query and returns an array of Row objects produced but also inserts those Row objects into this Row's (self) children it is also neccessary to pass the DBConnection object the query will be run against this actually pisses me off in that the whole point of having this class
def q!(query, db) # build bindings from references bindings = [] if query.references query.references.each do |reference| bindings << @row[reference] end end # query qry = query.query.gsub('&apos;',"'").gsub('&quot;','"') # replace single and double quotes that rexml substituted out. if bindings.empty? rows = db.connection.select_all(qry) else rows = db.connection.select_all(qry, *bindings) end result_rows = [] rows.each do |row| result_rows << Row.new(query.name, row, query.attributes) end result_rows.each do |row| self << row end return result_rows end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drillthrough(query)\n RowSet.new @connection.create_statement.execute_query(query.to_s)\n end", "def insert_in_database\n Fetch.new(insertion_query).array\n end", "def node_query_mapping_insert\n # binding.pry\n branches.each do |br|\n br.nodes.each do |nd|\n nodeName = nd.name\n\n # columnsArray=nd.columns.map{|c| \"'\"+(c.relalias.nil? ? '' : c.relalias+'.')+c.colname+\"'\"}.join(',')\n columnsArray = nd.columns.map { |c| \"'\" + c.relname + '.' + c.colname + \"'\" }.join(',')\n query = \"INSERT INTO #{@nqTblName} values (#{@test_id} ,'#{br.name}','#{nd.name}', '#{nd.query.gsub(/'/, '\\'\\'')}',#{nd.location}, ARRAY[#{columnsArray}], #{nd.suspicious_score} , '#{@type}' )\"\n # pp query\n DBConn.exec(query)\n end\n end\n end", "def reaktor_insert(row)\n insert_id = 0\n unless row.idstore.nil?\n Log.write_log($import_log, \"reaktor_insert: Table: #{row.table_name} args: #{row.idstore.args * ', '}\")\n else\n Log.write_log($import_log, \"reaktor_insert: Table: #{row.table_name} No IdStore object\")\n end\n query = \"INSERT INTO #{row.table_name} (#{row.get_column_name_string})\\n VALUES (#{(['?']*row.size).join(', ')})\"\n sth = $dbh_ms.prepare(query)\n begin\n sth.execute(*row.get_column_values)\n rescue\n $stderr.puts \"### Error in #{__FILE__} on line #{__LINE__}. See errorlog\"\n Log.write_log('error', \"Could not insert data. Message: #{$!}. query: \\\"#{get_query_string(sth)}\\\"\")\n raise\n exit\n end\n begin\n insert_id = $dbh_ms.func(:insert_id) unless row.idstore.nil?\n rescue\n $stderr.puts \"### Error in #{__FILE__} on line #{__LINE__}. See errorlog\"\n Log.write_log('error', \"Could not get insert id. Message: #{$!}.\")\n raise\n exit\n end\n if insert_id > 0\n row.store_id(insert_id)\n Log.write_log($import_log, \"Insert id store to table: #{row.table_name} id_store parameters: (#{row.idstore.args * ', '}) id: #{insert_id}\")\n else\n unless row.idstore.nil?\n Log.write_log($import_log, \"No id stored for table: #{row.table_name} id_store parameters: (#{row.idstore.args * ', '})\")\n else\n Log.write_log($import_log, \"No id stored for table: #{row.table_name} No IdStore object\")\n end\n \n end\nend", "def row\n new_row = RowBuilder.new\n\n yield new_row\n\n @rows << new_row\n end", "def initialize(query:, columns:, table:, size:, serializer:, model:, &transaction)\n @query = query\n @serializer = serializer\n @table = table\n qutex = Mutex.new\n\n queue = case\n when activerecord?\n @query.pluck(*@columns)\n when arel?\n ActiveRecord::Base.connection.execute(@query.to_sql).map(&:values)\n when tuple?\n @query.map { |result| result.slice(*columns).values }\n when twodimensional?\n @query\n else\n raise ArgumentError, 'query wasn\\'t recognizable, please use some that looks like a: ActiveRecord::Base, Arel::SelectManager, Array[Hash], Array[Array]'\n end\n\n puts \"Migrating #{queue.count} #{table} records\"\n\n # Spin up a number of threads based on the `maximum` given\n 1.upto(size).map do\n Thread.new do\n loop do\n # Try to get a new queue item\n item = qutex.synchronize { queue.shift }\n\n if item.nil?\n # There is no more work\n break\n else\n # Wait for a free connection\n model.connection_pool.with_connection do\n model.transaction do\n # Execute each statement coming back\n Array[instance_exec(*item, &transaction)].each do |instruction|\n next if instruction.nil?\n model.connection.execute(instruction.to_sql)\n end\n end\n end\n end\n end\n end\n end.map(&:join)\n end", "def push(*rows)\n rows.each { |row| self << row }\n self\n end", "def run\n if @prepared_type == :insert\n fetch_rows(prepared_sql){|r| return r.values.first}\n else\n super\n end\n end", "def exec_query(query, conn = ActiveRecord::Base.connection)\n res = conn.exec_query(query)\n puts res.rows.map { |r| r.map(&:inspect).join(\",\") }.join('\\n')\n res.to_a\nend", "def query(&block)\n items = assert_connected(table).query(&block)\n results = []\n items.each { |i| results << new(i) }\n results\n end", "def <<(sql); execute((Array === sql) ? sql.to_sql : sql); end", "def execute_all( sql ) # :yields: row\n loop do\n stmt = prepare( sql )\n stmt.execute do |result|\n result.each { |row| yield row if block_given? }\n end\n sql = stmt.remainder\n if sql.length > 0\n yield nil if block_given? # notify of new query starting\n else\n break\n end\n end\n end", "def perform_query\n Rails.logger.info queries.to_sql\n queries\n end", "def run\n _escaped_sql = escaped_sql\n @query_logger << _escaped_sql if @query_logger\n result = @conn.exec_query _escaped_sql\n row_class = OccamsRecord::Results.klass(result.columns, result.column_types, @eager_loaders.names, model: @eager_loaders.model, modules: @use)\n rows = result.rows.map { |row| row_class.new row }\n @eager_loaders.run!(rows, query_logger: @query_logger)\n rows\n end", "def execute_insert(query)\n @connection.nil? and raise \"Attempting to query a connection that isn't open.\"\n\n if (@type == \"db2\")\n Models::Databases::SiteDatabase::Base.connection.execute(query)\n elsif (@type == \"bops\")\n Models::Databases::Bops::Base.connection.execute(query)\n else\n Models::Databases::Dyces::Base.connection.execute(query)\n end\n\n end", "def append_row!(*args)\r\n insert_row!(*args)\r\n end", "def execute_sql(my_sql)\n pg_result = ActiveRecord::Base.connection.execute(my_sql)\n\n # In this example we are just calling #to_a to convert the PG::Result to an\n # Array. PG::Result has a nice API for slicing and dicing itself so you may\n # want to to something clever instead. See\n # https://www.rubydoc.info/gems/pg/PG/Result for details.\n #\n # The important bit here is that we are copying all the data we care about\n # out of the PG::Result in preparation for later clearing the PG::Result\n results = pg_result.to_a\n\n # Calling #clear on the PG::Result is the important bit of cleanup and the\n # whole reason this method exists. See\n # https://www.rubydoc.info/gems/pg/PG/Result#clear-instance_method\n pg_result.clear\n\n yield results if block_given?\n\n results\nend", "def add_values_rec(schema, table, t, query)\n if t.parent == nil\n t.data['values'] = exec(query)\n else\n t.parent.data['values'].each_with_index { |v, i|\n where = \"WHERE\"\n unless t.parent.foreign_keys.size == 0\n t.parent.foreign_keys.each { |x|\n if x['foreign_table_name'] == t.table_name\n foreign_col = x['foreign_column_name']\n col = x['column_name']\n parent_val = t.parent.data['values'][i][col]\n where = \"#{where} #{foreign_col} = '#{parent_val}'\"\n end\n }\n end\n query = \"SELECT * FROM #{schema}.#{table} #{where} LIMIT 1\";\n if t.data['values'].nil?\n t.data['values'] = Array.new\n end\n t.data['values'] << exec(query)[0]\n }\n end\n\n t.depends.each { |n|\n add_values_rec(schema, n.table_name, n, query)\n }\nend", "def pg_gem_batch__from psql_db, db_queries\n psql_db = array__from psql_db\n db_queries = array__from db_queries\n pg_gem_conn = pg_gem_conn__from psql_db\n pg_connection = pg_gem_conn[5]\n batch = [pg_connection].product db_queries\n end", "def insert\n array = [[@name, @tagline, @github, @twitter, @blog_url, @image_url, @biography]]\n ins = DB[:conn].prepare(\"INSERT INTO students (name, tagline, github, twitter, blog_url, image_url, biography) VALUES (?, ?, ?, ?, ?, ?, ?);\")\n array.each { |s| ins.execute(s)}\n self.id = DB[:conn].execute(\"SELECT last_insert_rowid() FROM students;\")[0][0]\n #ask steven re. index figures\n #inserting data into an instance\n end", "def fetch_rows(sql, opts=OPTS, &block)\n db.execute(sql){|result| process_result_set(result, opts, &block)}\n self\n end", "def execute_query(sql, args)\n\t\t\t\t\[email protected]_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend", "def insert_rows(rows, field, table_struct, dest_table_name = NEW_TABLE_NAME)\n fields = get_fields(table_struct)\n insert_tmplt = row_sql_insert(dest_table_name, table_struct)\n primary_keys = get_pkey_fields(table_struct) \n errs = []\n row_action_data = []\n del_keys = []\n \n if (rows) then\n rows.each_hash do | row |\n row_action_data << {\n :sql_insert => make_sql_insert_row(fields, insert_tmplt, row), \n :key => make_key_hash_for_row(primary_keys, row)\n }\n end\n end\n\n row_action_data.each { |row|\n begin\n dbres = do_sql_command(row[:sql_insert])\n if dbres.nil?\n del_keys << row[:key]\n end\n rescue Mysql::Error\n if !($! =~ /^Duplicate entry .* for key/).nil?\n # i'll consider a duplicate entry okay for a delete\n LOGGER.warn \"Database error! Duplicate key found on insert, marking for deletion anyway, moving on: #{$!}\"\n del_keys << row[:key]\n else\n #errs << \"Database error, moving on: #{$!}\"\n LOGGER.error \"Database error, not sure what, moving on: #{$!}\"\n end\n end\n }\n\n del_keys\nend", "def query_thredis(prepare_only)\n if prepare_only\n @rows = @connection.redis.sqlprepare(@sql)\n else\n @rows = @connection.redis.sql(@sql, *@params)\n @prepare_only = false\n end\n if @rows.is_a? Integer\n @rows, @columns, @connection.changes = [], [], @rows\n else\n @columns = @rows.shift\n## @rows = convert_type(@rows, @columns)\n end\n end", "def each_row(the_query, &block)\n begin\n query(the_query)\n unless @result.nil?\n @affected_rows = @result.num_rows # This is non-zero is we do a select, and get results.\n if block_given?\n @result.each(&block)\n else\n result = []\n @result.each { |row| result << row }\n return result\n end\n end\n rescue Mysql::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end", "def q_buffer(&block)\r\n Knj::Db::Query_buffer.new(:db => self, &block)\r\n end", "def process_row(connection, row)\n Array(task.execute_sql(connection, row)).each do |sql|\n connection.execute(sql)\n end\n end", "def insert_sql_each\n return enum_for(__method__) unless block_given?\n each_row do |row|\n yield table_dataset.insert_sql( row )\n end\n end", "def rows\n @rows ||= if ActiveRecord::Base.connection.adapter_name == \"PostgreSQL\"\n result.entries\n else\n [].tap do |row_hashes|\n result.entries.map do |row|\n hash = {}\n result.fields.each do |field|\n hash[field] = row[result.fields.index(field)]\n end\n row_hashes << hash\n end\n end\n end\n end", "def insert!(*rows)\n Mao.sql(with_options(:insert => rows.flatten).sql) do |pg_result|\n if @options[:returning]\n pg_result.map {|result| Mao.normalize_result(result, @col_types)}\n else\n pg_result.cmd_tuples\n end\n end\n end", "def all\n\t\tquery.execute\n end", "def insert(values)\n primary_key_value = nil\n\n if primary_key && Hash === values\n primary_key_value = values[values.keys.find { |k|\n k.name == primary_key\n }]\n\n if !primary_key_value && connection.prefetch_primary_key?(klass.table_name)\n primary_key_value = connection.next_sequence_value(klass.sequence_name)\n values[klass.arel_table[klass.primary_key]] = primary_key_value\n end\n end\n\n im = arel.create_insert\n\n # ****** BEGIN PARTITIONED PATCH ******\n actual_arel_table = @klass.dynamic_arel_table(Hash[*values.map{|k,v| [k.name,v]}.flatten]) if @klass.respond_to?(:dynamic_arel_table)\n actual_arel_table = @table unless actual_arel_table\n # Original line:\n # im.into @table\n im.into actual_arel_table\n # ****** END PARTITIONED PATCH ******\n\n conn = @klass.connection\n\n substitutes = values.sort_by { |arel_attr,_| arel_attr.name }\n binds = substitutes.map do |arel_attr, value|\n [@klass.columns_hash[arel_attr.name], value]\n end\n\n substitutes.each_with_index do |tuple, i|\n tuple[1] = conn.substitute_at(binds[i][0], i)\n end\n\n if values.empty? # empty insert\n im.values = Arel.sql(connection.empty_insert_statement_value)\n else\n im.insert substitutes\n end\n\n conn.insert(\n im,\n 'SQL',\n primary_key,\n primary_key_value,\n nil,\n binds)\n end", "def query(query)\n raw_query(query).map do |row|\n row = row.map do |item| \n # If the row entry is a String, it is the result already, and not, as \n # Neo4j.build would expect, the URL of a Neo4j node or relationship. The\n # same is true for all non-hashes.\n next item unless item.is_a?(Hash)\n build_from_hash(item)\n end\n \n row = row.first if row.length == 1\n row\n end\n end", "def execute_query(query)\n ActiveRecord::Base.connection.select_all(query)\n end", "def flush\n conn.transaction do\n buffer.flatten.each do |row|\n # check to see if this row's compound key constraint already exists\n # note that the compound key constraint may not utilize virtual fields\n next unless row_allowed?(row)\n\n # add any virtual fields\n add_virtuals!(row)\n \n names = []\n values = []\n order.each do |name|\n names << \"`#{name}`\"\n values << conn.quote(row[name]) # TODO: this is probably not database agnostic\n end\n q = \"INSERT INTO `#{table_name}` (#{names.join(',')}) VALUES (#{values.join(',')})\"\n ETL::Engine.logger.debug(\"Executing insert: #{q}\")\n conn.insert(q, \"Insert row #{current_row}\")\n @current_row += 1\n end\n buffer.clear\n end\n end", "def <<(row)\n @rows << row\n self\n end", "def query(sql)\n @dataset = @database[sql] #Take SQL string and connect it to a DB\n #puts(\"Datset\", dataset)\n @fields = Array.new #Create blank array of field/column names\n @fields = @dataset.columns #Gets table field/column names\n #print(\"Fields\", @fields, \"\\n\") #debug \n @fieldCount = @fields.length\n\n begin\n @data = @dataset.all #Executes SQL\n rescue\n @data = Array.new\n end\n end", "def <<(sql)\n execute((Array === sql) ? sql.to_sql : sql)\n end", "def query(q=\"\")\n\t\tif @connection != nil\n\t\t\t@data = MonetDBData.new(@connection)\n\t\t\[email protected](q)\n\t\tend\n\t\treturn @data\n\tend", "def multi_insert(tuples)\n pks = relation.multi_insert(tuples, return: :primary_key)\n relation.where(relation.primary_key => pks).to_a\n end", "def insert(tuples)\n pks = tuples.map { |tuple| relation.insert(tuple) }\n relation.where(relation.primary_key => pks).to_a\n end", "def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n # TODO put these lines back in and create another method to turn results_as_objects array of \n # objects in to array of hashes!!!!!!!\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end", "def run\r\n ridFieldName = @qbc.lookupFieldNameFromID( \"3\")\r\n records = Records.new\r\n @qbc.iterateRecords(@dbid,@qbc.getFieldNames(@dbid),nil,@id,nil,qyclst()){|qb_record|\r\n record = Record.new\r\n record.build(@qbc,ridFieldName, qb_record)\r\n records << record\r\n }\r\n records\r\n end", "def run_query()\n return nil unless @query\n \n gres = @query.execute()\n if @filterClass \n fres = @filterClass.filter(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n elsif @filterBlock \n fres = @filterBlock.call(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n else\n res = fres.result_s\n end\n res\n end", "def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = QUIZ.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end", "def build_daos_for_row(row)\n dao_class.new parent: dao_node, row: row\n end", "def process_row(table, row)\n Log.write_log(table.name, \"Processing row: #{row.pretty_inspect}\")\n row.each do |v|\n row.to_h.each do |k,v|\n row[k] = Utf8_Converter::convert(v) if v.kind_of?(String)\n end\n end\n pk_string = ''\n table.primary_key.each do |pk|\n pk_string << row[pk].to_s\n end\n if pk_string.empty?\n row.each {|c| pk_string << c.to_s}\n end\n if (table.__id_store__)\n default_table_row = InsertRow.new(table.__default_table__, IdStore.new(table.name, pk_string))\n else\n default_table_row = InsertRow.new(table.__default_table__)\n end\n default_table_row.prototype_table_map = table\n default_table_row.prototype_result_set = row\n table_rows = []\n\n table.each_column do |attr_name, maps_to|\n next if maps_to == IGNORE\n\n if maps_to.kind_of?(ReaktorColumn)\n #\n # ReaktorColumn\n #\n default_table_row.add(*process_reaktor_column(maps_to, attr_name, row))\n elsif maps_to.kind_of?(ReaktorRow)\n #\n # ReaktorRow\n #\n table_rows << process_reaktor_row(maps_to, attr_name, row)\n elsif maps_to.kind_of?(Class)\n #\n # Plugin\n #\n plugin = process_plugin(maps_to, attr_name, row)\n list = plugin.each\n if list.kind_of?(Array)\n list.each do |reaktor_object|\n if reaktor_object.kind_of?(ReaktorColumn)\n default_table_row.add(*process_reaktor_column(reaktor_object, attr_name, row))\n elsif reaktor_object.kind_of?(ReaktorRow)\n table_rows << process_reaktor_row(reaktor_object, attr_name, row)\n else\n STDERR.puts \"reaktor_object was a #{reaktor_object.class} class\"\n exit\n end\n end\n end\n else\n STDERR.puts \"maps_to was of class: #{maps_to.class} and not processed\"\n exit\n end\n end\n \n table.__set__.each do |set|\n t = set.value\n if set.value.kind_of?(Query)\n tsth = $dbh_pg.prepare(set.value.sql)\n begin\n tsth.execute(row[:id])\n rescue\n $stderr.puts \"### Error in #{__FILE__} on line #{__LINE__}. See errorlog\"\n Log.write_log('error', \"Could not process query. Message: #{$!} query: #{get_query_string(tsth)}.\")\n raise\n exit\n end\n r = tsth.fetch\n t = r.nil? ? r : r[0]\n else\n t = set.parse_value(nil, row)\n end\n t = Filter.apply_filters(t, row, set.filters)\n default_table_row.add(set.name, t)\n end\n table_rows.insert(0, default_table_row) unless table.__default_table__.nil?\n return table_rows\nend", "def query(q=\"\")\n if @connection != nil \n @data = MonetDBData.new(@connection)\n @data.execute(q)\n end\n return @data\n end", "def InsertPubmedRecords(publications)\n row_iterator(publications) { |publication|\n abstract = InsertPublication(publication)\n }\nend", "def multi_query_builder\n\n query = \"\n SELECT\n #{select_arr.join(\",\\n\\t\")}\n FROM \\t#{groups.first.parent_table}\n #{pk_join_arr.join(\"\\n\")}\n #{fk_join_arr.join(\"\\n\")};\"\n\n return query\n end", "def dump_insert_multi(io, table_obj, rows)\n print \"Inserting #{rows.length} into #{table_obj.name}.\\n\" if @debug\n sqls = @args[:db].insert_multi(table_obj.name, rows, :return_sql => true, :keys => @keys)\n sqls.each do |sql|\n io.write(\"#{sql};\\n\")\n end\n \n rows.clear\n \n #Ensure garbage collection or we might start using A LOT of memory.\n GC.start\n end", "def fast_insert(rows, base_cmd, end_cmd = '')\n RawDB.fast_insert(db, rows, base_cmd, end_cmd)\n end", "def query(sql)\n database.execute2(sql)\n end", "def each_row(the_query, &block)\n begin\n query(the_query, { as: :array, cache_rows: false })\n unless @result.nil?\n if block_given?\n @affected_rows = @result.count # This is non-zero is we do a select, and get results.\n @result.each(&block)\n else\n result = []\n @result.each { |row| result << row }\n return result\n end\n end\n rescue Mysql2::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end", "def sql_literal_append(ds, sql)\n sql << 'ROW'\n ds.literal_append(sql, to_a)\n if db_type\n sql << '::'\n ds.quote_schema_table_append(sql, db_type)\n end\n end", "def insert\n # the array of ::columns of the class joined with commas, drop id\n col_names = self.class.columns[1..-1].join(\", \") \n # an array of question marks\n question_marks = ([\"?\"] * col_names.split.size).join(\", \")\n\n DBConnection.execute(<<-SQL, *attribute_values[1..-1])\n INSERT INTO\n #{self.class.table_name} (#{col_names})\n VALUES\n (#{question_marks})\n SQL\n\n self.id = DBConnection.last_insert_row_id\n end", "def db_query sql\n\n db = SQLite3::Database.new 'database.db'\n db.results_as_hash = true\n # debugging output in the terminal:\n puts '================='\n puts sql\n puts '================='\n results db.execute sql\n db.close might\n\n results # return results as query\nend", "def psql_db_batch__db_queries_method psql_db, db_queries_method\n psql_db = array__from(psql_db)\n db_queries = array__from(db_queries_method)\n batch = psql_db_batch__cli_or_queries psql_db, db_queries\n end", "def query(the_query)\n raise Mysql::Error, 'Not Connected' if @my.nil?\n\n begin\n if @result != nil\n @result.free # Free any result we had left over from previous use.\n @result = nil\n end\n @affected_rows = 0 # incase this query crashes and burns, this will have a value.\n @result = @my.query(the_query)\n @affected_rows = @my.affected_rows # This is non-zero for insert/delete/update of rows\n if block_given?\n yield @result\n else\n return @result\n end\n rescue Mysql::Error => e\n if @result != nil\n @result.free # Free any result we had left over from previous use.\n @result = nil\n end\n raise e\n end\n end", "def perform_query(query, operand)\n# STDERR.puts \"perform_query(q '#{query}', op '#{operand}')\"\n records = []\n\t\t \n if operand.is_a?(DataMapper::Query::Conditions::NotOperation)\n#\tSTDERR.puts \"operand is a NOT operation\"\n\tsubject = operand.first.subject\n\tvalue = operand.first.value\n elsif operand.subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)\n#\tSTDERR.puts \"operand subject is a many-to-one relation: '#{operand.subject.inspect}'\"\n\tif operand.subject.parent_model == NamedQuery && operand.subject.child_model == Bug\n\t name = operand.value[operand.subject.parent_key.first.name]\n\t bugs = named_query(name)\n\t bugs.each do |bug|\n\t records << bug_to_record(query.model, bug)\n\t end\n\t return records\n\telse\n\t raise \"Unknown parent (#{operand.subject.parent_model}) child (#{operand.subject.child_model}) relation\"\n\tend\n else\n#\tSTDERR.puts \"operand is normal\"\n\tsubject = operand.subject\n\tvalue = operand.value\n end\n \n if subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)\n#\tSTDERR.puts \"subject is a many-to-one relation\"\n\tsubject = subject.child_key.first\n end\n \n # typical queries\n #\n \n# STDERR.puts \"perform_query(subject '#{subject.inspect}', value '#{value.inspect}')\"\n case query.model.name\n when \"Bug\"\n\tif query.model.key.include?(subject)\n\t # get single <bug>\n\t bugs = get_bugs(value)\n\t records << bug_to_record(query.model, bugs.first)\n\telse\n\t raise \"Unknown query for bug\"\n\tend\n when \"NamedQuery\"\n\trecords << { subject.name.to_s => value }\n\t# be lazy: do the actual named query when NamedQuery#bugs gets accessed\n else\n\traise \"Unsupported model '#{query.model.name}'\"\n end\n \n records\n end", "def prepare(base, settings)\n super\n\n prepare_sub_query(base, settings)\n end", "def next_row\n row = []\n case rc = @stmt_api.step\n when ResultCode::ROW\n result_meta.each_with_index do |col, idx|\n value = nil\n column_type = @stmt_api.column_type( idx )\n case column_type\n when DataType::TEXT\n value = @stmt_api.column_text( idx )\n when DataType::FLOAT\n value = @stmt_api.column_double( idx )\n when DataType::INTEGER\n value = @stmt_api.column_int64( idx )\n when DataType::NULL\n value = nil\n when DataType::BLOB\n # if the rowid column is encountered, then we can use an incremental\n # blob api, otherwise we have to use the all at once version.\n if using_rowid_column? then\n value = Amalgalite::Blob.new( :db_blob => SQLite3::Blob.new( db.api,\n col.schema.db,\n col.schema.table,\n col.schema.name,\n @stmt_api.column_int64( @rowid_index ),\n \"r\"),\n :column => col.schema)\n else\n value = Amalgalite::Blob.new( :string => @stmt_api.column_blob( idx ), :column => col.schema )\n end\n else\n raise ::Amalgalite::Error, \"BUG! : Unknown SQLite column type of #{column_type}\"\n end\n\n row << db.type_map.result_value_of( col.schema.declared_data_type, value )\n end\n row.fields = result_fields\n when ResultCode::DONE\n row = nil\n write_blobs\n else\n self.close # must close so that the error message is guaranteed to be pushed into the database handler\n # and we can can call last_error_message on it\n msg = \"SQLITE ERROR #{rc} (#{Amalgalite::SQLite3::Constants::ResultCode.name_from_value( rc )}) : #{@db.api.last_error_message}\"\n raise Amalgalite::SQLite3::Error, msg\n end\n return row\n end", "def read_children(child_class) # :nodoc:\n if new_record? \n nil\n else\n result = Array.new\n _late_connect?\n child_class.in_batches :query, condition_options(child_class) do |attrs|\n result << child_class.new._setup_from_dynamo(attrs)\n end\n result\n end\n end", "def query(tql)\n rid = tql[:rid]\n where = nil\n filter = nil\n if tql.has_key?(:where)\n w = tql[:where]\n where = w.is_a?(Array) ? ExprParser.parse(w) : w\n end\n filter = ExprParser.parse(tql[:filter]) if tql.has_key?(:filter)\n\n if tql.has_key?(:insert)\n insert(tql[:insert], rid, where, filter)\n elsif tql.has_key?(:update)\n update(tql[:update], rid, where, filter)\n elsif tql.has_key?(:delete)\n delete(tql[:delete], rid, where, filter)\n else\n select(tql[:select], rid, where, filter)\n end\n end", "def each\n # Need to close the connection, teh result_set, AND the result_set.getStatement when\n # we're done.\n connection = open_connection!\n\n # We're going to need to ask for item/copy info while in the\n # middle of streaming our results. JDBC is happier and more performant\n # if we use a seperate connection for this.\n extra_connection = open_connection! if include_some_holdings?\n\n # We're going to make our marc records in batches, and only yield\n # them to caller in batches, so we can fetch copy/item info in batches\n # for efficiency.\n batch_size = settings[\"horizon.batch_size\"].to_i\n record_batch = []\n\n exclude_tags = (settings[\"horizon.exclude_tags\"] || \"\").split(\",\")\n\n\n rs = self.fetch_result_set!(connection)\n\n current_bib_id = nil\n record = nil\n record_count = 0\n\n error_handler = org.marc4j.ErrorHandler.new\n\n while(rs.next)\n bib_id = rs.getInt(\"bib#\");\n\n if bib_id != current_bib_id\n record_count += 1\n\n if settings[\"debug_ascii_progress\"] && (record_count % settings[\"solrj_writer.batch_size\"] == 0)\n $stderr.write \",\"\n end\n\n # new record! Put old one on batch queue.\n record_batch << record if record\n\n # prepare and yield batch?\n if (record_count % batch_size == 0)\n enhance_batch!(extra_connection, record_batch)\n record_batch.each do |r|\n # set current_bib_id for error logging\n current_bib_id = r['001'].value\n yield r\n end\n record_batch.clear\n end\n\n # And start new record we've encountered.\n error_handler = org.marc4j.ErrorHandler.new\n current_bib_id = bib_id\n record = MARC::Record.new\n record.append MARC::ControlField.new(\"001\", bib_id.to_s)\n end\n\n tagord = rs.getInt(\"tagord\");\n tag = rs.getString(\"tag\")\n\n # just silently skip it, some weird row in the horizon db, it happens.\n # plus any of our exclude_tags.\n next if tag.nil? || tag == \"\" || exclude_tags.include?(tag)\n\n indicators = rs.getString(\"indicators\")\n\n # a packed byte array could be in various columns, in order of preference...\n # the xref stuff is joined in from the auth table\n # Have to get it as bytes and then convert it to String to avoid JDBC messing\n # up the encoding marc8 grr\n authtext = rs.getBytes(\"xref_longtext\") || rs.getBytes(\"xref_text\")\n text = rs.getBytes(\"longtext\") || rs.getBytes(\"text\")\n\n\n if tag == \"000\"\n # Horizon puts a \\x1E marc field terminator on the end of hte\n # leader in the db too, but that's not really part of it.\n record.leader = String.from_java_bytes(text).chomp(\"\\x1E\")\n\n fix_leader!(record.leader)\n elsif tag != \"001\"\n # we add an 001 ourselves with bib id in another part of code.\n field = build_marc_field!(error_handler, tag, indicators, text, authtext)\n record.append field unless field.nil?\n end\n end\n\n # last one\n record_batch << record if record\n\n # yield last batch\n enhance_batch!(extra_connection, record_batch)\n\n record_batch.each do |r|\n yield r\n end\n record_batch.clear\n\n rescue Exception => e\n logger.fatal \"HorizonReader, unexpected exception at bib id:#{current_bib_id}: #{e}\" \n raise e\n ensure\n logger.info(\"HorizonReader: Closing all JDBC objects...\")\n\n # have to cancel the statement to keep us from waiting on entire\n # result set when exception is raised in the middle of stream.\n statement = rs && rs.getStatement\n if statement\n statement.cancel\n statement.close\n end\n\n rs.close if rs\n\n # shouldn't actually need to close the resultset and statement if we cancel, I think.\n connection.close if connection\n\n extra_connection.close if extra_connection\n\n logger.info(\"HorizonReader: Closed JDBC objects\")\n end", "def commit(q)\n\t\tdbh=Mysql.init\n\t\tdbh.real_connect(@host, @user, @password, @db,@port,nil,Mysql::CLIENT_MULTI_RESULTS)\n\t\tdbh.query_with_result=false\n\t\tdbh.query(q)\n\t\t\tbegin\n\t\t\t rs = dbh.use_result\n\t\t\trescue Mysql::Error => e \n\t\t\t no_more_results=true\n\t\t\tend \n\t\tif rs.fetch_row == nil\n\t\t\treturn nil\n\t\telse\n\t\t\treturn rs\n\t\tend\n\tend", "def all_as_objects\n table_name = self.to_s.pluralize\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n \n results_as_objects << self.new(result_hash)\n \n end\n \n return results_as_objects\n \n end", "def <<(row)\n @rows << row\n end", "def push(*args)\n @tables.push *args\n return self\n end", "def copy(query)\n queries << query\n end", "def getDBArray(connection, query, id1, *id2)\r\n dbi_query = connection.prepare(query)\r\n dbi_query.execute(id1, *id2)\r\n #fetch the result\r\n return dbi_query.fetch_all\r\nend", "def insert_as_embedded\n raise Errors::NoParent.new(self.class.name) unless _parent\n if _parent.new_record?\n _parent.insert\n else\n selector = _parent.atomic_selector\n _root.collection.find(selector).update_one(\n positionally(selector, atomic_inserts),\n session: _session)\n end\n end", "def execute(query)\n # use exec_params instead of exec for security\n #\n # Unlike PQexec, PQexecParams allows at most one SQL command in the given string.\n # (There can be semicolons in it, but not more than one nonempty command.)\n # This is a limitation of the underlying protocol, but has some usefulness\n # as an extra defense against SQL-injection attacks.\n # https://www.postgresql.org/docs/current/static/libpq-exec.html\n query = squish(query)\n log \"SQL: #{query}\" if @log_sql\n conn.exec_params(query, []).to_a\n end", "def insert\n # Preparing for the query...\n cols = self.class.columns\n col_names = cols.map(&:to_s).join(\", \")\n question_marks = ([\"?\"] * cols.count).join(\", \")\n \n # The actual query\n DBConnection.execute(<<-SQL, *attribute_values)\n INSERT INTO\n #{ self.class.table_name } (#{ col_names })\n VALUES\n (#{ question_marks })\n SQL\n \n # Add an id number for the record\n self.id = DBConnection.last_insert_row_id\n end", "def execute( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n result.each { |row| yield row }\n else\n return result.inject( [] ) { |arr,row| arr << row; arr }\n end\n end\n end", "def run_query(q)\n return sky_table.query(q)\n end", "def db_custom_query(query)\n db = open_create_db\n\n if db\n result = db.execute(query)\n end\n db.close\n return result\n end", "def execute_query(sql, args)\n @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}\n end", "def runQuery(query, &block)\n raise \"Trying to run a query when not connected to inventory DB\" if not @connected\n begin\n debug \"SQL Query: '#{query}'\"\n [email protected](query)\n # Check if the SQL result contains anything at all...\n # If so, then call the block of commands to process it\n if (reply.num_rows() > 0)\n reply.each() { |result|\n debug \"SQL Reply: '#{result.to_s}'\"\n yield(result)\n }\n else\n debug \"SQL Reply is EMPTY!\"\n end\n rescue MysqlError => e\n debug \"ERROR - SQL Error: '#{e}'\"\n end\n end", "def each_query(options = {})\n options = { sort: false, subject_regex: nil }.merge(options)\n \n # Set the state variables\n current_rows = []\n current_query = nil\n\n # Read through rows until the query changes.\n each(subject_regex: options[:subject_regex]) do |hit|\n if hit.query == current_query\n current_rows << hit\n else\n if current_query\n current_rows.sort! if options[:sort]\n yield current_query, current_rows \n end\n\n current_query, current_rows = hit.query, [hit]\n end\n end\n \n # Yield the last query if any were found\n yield current_query, current_rows if current_query\n end", "def dump_insert_multi(io, table_obj, rows)\n debug \"Inserting #{rows.length} into #{table_obj.name}.\"\n sqls = @export_db.insert_multi(\n table_obj.name,\n rows,\n replace_line_breaks: true,\n return_sql: true,\n keys: @keys\n )\n sqls.each do |sql|\n io.write(\"#{sql};\\n\")\n end\n\n rows.clear\n\n # Ensure garbage collection or we might start using A LOT of memory.\n GC.start\n end", "def insert(*values)\n if @opts[:sql] || @opts[:returning]\n super\n else\n returning(insert_pk).insert(*values){|r| return r.values.first}\n end\n end", "def generate_pg_insert_query(table_name, keys, rows)\n \"INSERT INTO #{table_name}(#{keys.map { |i| \"\\\"#{i}\\\"\" }.join(',')}) VALUES(#{keys.map { |i| rows[i] == nil ? 'NULL' : \"'\" + pg_conn.escape_string(rows[i]) + \"'\" }.join(',')});\\n\"\n end", "def execute_insert(sql, opts=OPTS)\n _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}; conn.last_insert_rowid}\n end", "def recipe_with_comments\n db_connection do |conn|\n conn.exec(\"SELECT recipes.id, comments.comment FROM recipes INNER JOIN comments ON comments.recipe_id=recipes.id\").to_a\n end\nend", "def create_child_skeleton_rows\n ActiveRecord::Base.transaction do\n\n AssignmentDefinition.all.each do |a|\n assignment = assignments.find_by_assignment_definition_id(a.id)\n if assignment.nil?\n assignment = Assignment.create(\n assignment_definition_id: a.id,\n state: 'new'\n )\n assignments << assignment\n end\n\n a.task_definitions.each do |td|\n task = tasks.find_by_task_definition_id(td.id)\n if task.nil?\n task = Task.create(\n task_definition_id: td.id,\n assignment_id: assignment.id,\n state: 'new'\n )\n tasks << task\n end\n end\n end\n end\n end", "def db_query( sql )\n db = SQLite3::Database.new 'database.db'\n db.results_as_hash = true\n puts '==============================='\n puts sql # for debugging our SQL\n puts '==============================='\n result = db.execute sql\n db.close\n result # return the result of the query\nend", "def _execute(conn, sql, opts)\n r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif defined?(yield)\n yield conn\n end\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n if r\n r.free\n r = nil\n end\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n yield r if opts[:type] == :select\n end\n end\n rescue Mysql::Error => e\n raise_error(e)\n ensure\n r.free if r\n # Use up all results to avoid a commands out of sync message.\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n r.free if r\n end\n end\n end", "def Okdoki_Sql_Ladder o\n tag = \"#{o.class.to_s.downcase} ladder tag\"\n\n # === Get parents array:\n sqls = o.parent_sql\n i_dig_sql = I_Dig_Sql.new\n\n # === Turn parent array into sql array:\n About_Pos.Back(sqls) { |v, i, meta|\n cte_table_name = meta[:cte_table_name] = \"#{o.class.to_s.downcase}_ladder_#{i}\" \n\n with_sql = case v\n\n when Proc\n v\n .call(Okdoki_Sql_Ladder::Curr.new(cte_table_name), Okdoki_Sql_Ladder::Prev.new(meta.prev? ? meta.prev[:cte_table_name] : nil))\n .AS(cte_table_name)\n\n when Array\n klass = if meta.bottom?\n v.first.class\n else\n v.first\n end\n fkey = v[1] || 'parent_id'\n\n if meta.top? # TOP\n I_Dig_Sql.new(\"SELECT ? as class_id, id, NULL as parent_id\n FROM #{klass.table_name}\n WHERE id in ( SELECT parent_id FROM #{meta.prev[:cte_table_name]} )\", klass.class_id)\n .AS(cte_table_name)\n\n elsif meta.middle? # MIDDLE\n I_Dig_Sql.new(\"SELECT ? AS class_id, id, ? AS parent_id\n FROM #{klass.table_name}\n WHERE id IN ( SELECT parent_id FROM #{meta.prev[:cte_table_name]} )\", klass.class_id, fkey)\n .AS(cte_table_name)\n\n else meta.bottom? # BOTTOM\n I_Dig_Sql.new(\"SELECT ? AS class_id, id, ? AS parent_id\n FROM #{klass.table_name}\n WHERE id = ?\", klass.class_id, fkey, o.id)\n .AS(cte_table_name)\n end\n else\n raise \"Unknown type for sql: #{v.inspect}\"\n end\n\n i_dig_sql.WITH(with_sql).tag_as(tag)\n }\n # ---------------------------------------------------\n\n i_dig_sql.WITH(\n I_Dig_Sql.new(\n i_dig_sql\n .find_tagged(tag)\n .map { |s| \"SELECT * FROM #{s.AS}\" }\n .join(\"\\nUNION\\n\")\n )\n .AS(\"#{o.class.to_s.downcase}_ladder_sql\")\n )\n\n i_dig_sql\nend", "def make_query(query)\n puppetdb_client = Puppet.lookup(:bolt_pdb_client)\n # Bolt executor not expected when invoked from apply block\n executor = Puppet.lookup(:bolt_executor) { nil }\n executor&.report_function_call(self.class.name)\n\n puppetdb_client.make_query(query)\n end", "def copy_to(db, args = {})\r\n data[\"tables\"].each do |table|\r\n table_args = nil\r\n table_args = args[\"tables\"][table[\"name\"].to_s] if args and args[\"tables\"] and args[\"tables\"][table[\"name\"].to_s]\r\n next if table_args and table_args[\"skip\"]\r\n table.delete(\"indexes\") if table.key?(\"indexes\") and args[\"skip_indexes\"]\r\n db.tables.create(table[\"name\"], table)\r\n \r\n limit_from = 0\r\n limit_incr = 1000\r\n \r\n loop do\r\n ins_arr = []\r\n q_rows = self.select(table[\"name\"], {}, {\"limit_from\" => limit_from, \"limit_to\" => limit_incr})\r\n while d_rows = q_rows.fetch\r\n col_args = nil\r\n \r\n if table_args and table_args[\"columns\"]\r\n d_rows.each do |col_name, col_data|\r\n col_args = table_args[\"columns\"][col_name.to_s] if table_args and table_args[\"columns\"]\r\n d_rows[col_name] = \"\" if col_args and col_args[\"empty\"]\r\n end\r\n end\r\n \r\n ins_arr << d_rows\r\n end\r\n \r\n break if ins_arr.empty?\r\n \r\n db.insert_multi(table[\"name\"], ins_arr)\r\n limit_from += limit_incr\r\n end\r\n end\r\n end", "def prepare(query)\n sth = nil\n mutex.synchronize do\n self.last_query = query\n sth = new_statement(query)\n yield sth if block_given?\n sth.finish if block_given?\n end\n\n return self.last_statement = sth\n end", "def sql_query(sql)\n db = PG.connect(:dbname => 'todo_book', :host => 'localhost')\n query_result = db.exec(sql)\n db.close\n\n return query_result\nend", "def build_records(amount, per_query, &block)\n amount.times do\n record = Record.new(@model_class, last_id_in_database + @records.size + 1)\n @records << record\n block.call(record) if block\n save_records if @records.size >= per_query\n end\n end", "def comments\n db_connection do |conn|\n conn.exec(\"SELECT * FROM comments\").to_a\n end\nend", "def exec_insert(sql, name, binds)\n exec_query(sql, name, binds)\n end", "def row(row)\n Row.new(@data, row)\n end", "def insert_sequenced(row)\n sql = row.type.insert_sql_minus_key\n vals = row.field_values_minus_key\n#$stderr.puts sql\n#$stderr.puts vals.inspect\n\n db.do(sql, *vals)\n insert_id = db.select_one(row.type.get_insert_id_sql)[0]\n row.send(row.type.primary_key.setter_name, insert_id)\n row.reset_changed\n end", "def each_row_for_next_chunk\n return nil if finished?\n raise \"#{self.class}: instance not prepared before running the iteration\" unless @prepared\n\n select_sql = @select_sql.present? ? @select_sql : '*'\n sql = \"SELECT #{select_sql} FROM #{data_table_name} WHERE #{data_where_scope} ORDER BY id ASC LIMIT #{Import::CHUNK_ROWS_COUNT} OFFSET #{@iteration_number * Import::CHUNK_ROWS_COUNT}\"\n pg_result = postgres.copy(\"COPY (#{sql}) TO STDOUT WITH CSV DELIMITER ','\") do |row|\n yield row\n end\n\n @iteration_number += 1\n check_if_finished\n end", "def prepare(*args)\n ps = super\n ps.extend(::Sequel::Postgres::DatasetMethods::PreparedStatementMethods)\n ps\n end" ]
[ "0.63389015", "0.6150857", "0.56682765", "0.5638703", "0.5631739", "0.5565175", "0.554424", "0.55289435", "0.55239236", "0.5510129", "0.54968923", "0.54849654", "0.54802024", "0.5435421", "0.5407851", "0.53947794", "0.5382071", "0.53806543", "0.5377896", "0.5330029", "0.5320639", "0.53194565", "0.5308432", "0.52994543", "0.52825695", "0.5278363", "0.52700776", "0.52639747", "0.525961", "0.52407956", "0.5233736", "0.52314085", "0.5225316", "0.5224003", "0.52194554", "0.52150816", "0.521317", "0.5200904", "0.5200896", "0.5180896", "0.51787925", "0.5173525", "0.5166651", "0.5163598", "0.5158341", "0.5157137", "0.51554215", "0.5143598", "0.5138968", "0.5137085", "0.5121721", "0.51146686", "0.5113563", "0.51127136", "0.51112354", "0.5103805", "0.51008576", "0.50954276", "0.5094215", "0.5086317", "0.5081714", "0.5078849", "0.5073252", "0.50731367", "0.5072414", "0.5062032", "0.5061931", "0.5061237", "0.5060749", "0.5036122", "0.50252223", "0.50218225", "0.50125754", "0.50120616", "0.5006753", "0.50046045", "0.50033873", "0.50018585", "0.50011146", "0.49917534", "0.49881473", "0.49841022", "0.4983929", "0.49814114", "0.49805355", "0.4979222", "0.49791282", "0.49619284", "0.4960663", "0.4955237", "0.49544394", "0.49495962", "0.49490622", "0.4947453", "0.49425545", "0.4941987", "0.49401146", "0.4938222", "0.49365926", "0.49330577" ]
0.70666033
0
this is a mesh builder which returns this Row (self) as xml
def xml base = REXML::Element.new(@name) if @row.class == DBI::Row # only if we have a row otherwise return an empty xml node # prime context = nil rowcontext = base # loop through each column @row.each_with_name do |val, colpath| context = rowcontext # start at the top of the row for each column parents = colpath.split('/') # split on any path dividers, i.e. parent/parent/child child = parents.pop # get the child off the parents # loop through all the parents parents.each.each do |p| found = REXML::XPath.first(context, p) # does the element already exist? if not found # if not... el = p.gsub(/[[].*[]]$/,'') # remove index if there is one found = context.add_element(el) # add the element end context = found # this parent is now our new context end # do the child (the end of the tree branch) if child =~ /^@(.*)/ # is it labeled an attribute with @? context.add_attribute($1, val.to_s) # add attribute elsif @attributes.include?(child) # or is it in the attributes list? context.add_attribute(child, val.to_s) # add attribute else found = REXML::XPath.first(context, child) # does it already exist? if not found # if not... el = child.gsub(/[[].*[]]$/,'') # remove index if there is one found = context.add_element(el) # add the element end context = found # the child is now our new context context.add_text(val.to_s) # insert the text node as val end end end return base end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_xml(builder, include_dims=true)\n builder.grid do |xml|\n xml.cube\n dims_to_xml(xml) if include_dims\n xml.slices do |xml|\n xml.slice :rows => @row_count, :cols => @col_count do |xml|\n xml.data do |xml|\n xml.range :start => 0, :end => @row_count * @col_count - 1 do\n xml.vals @vals.join('|')\n xml.types @types.join('|')\n end\n end\n end\n end\n end\n end", "def create_row(xml)\n row = self.rowclass.new\n self.columns.each { |colname|\n row.send(colname +\"=\", xml[colname]) # row content ignored so far (needs to be added!!!)\n }\n if xml.children && xml.containers.length > 0\n xml.containers.each { |child|\n el = EAAL::Result::ResultElement.parse_element(self.rowclass.name, child)\n row.add_element(el.name, el)\n }\n end\n row\n end", "def to_xml\n builder.target!\n end", "def row\n new_row = RowBuilder.new\n\n yield new_row\n\n @rows << new_row\n end", "def toxml\n\t\tend", "def to_xml(xml)\n #build it for now, break it down later!\n xml[:xdr].twoCellAnchor {\n xml.from {\n from.to_xml(xml)\n }\n xml.to {\n to.to_xml(xml)\n }\n @object.to_xml(xml)\n xml.clientData\n }\n end", "def to_xml(*args)\n super\n end", "def render_matrix\n Matrix.rows render_rows\n end", "def to_xml(options={})\n options[:root] ||= 'cell'\n options[:indent] ||= 2\n options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])\n\n cell_name = self.to_s.gsub('Cell', '').underscore\n\n options[:builder].tag!(options[:root]) do |cell_node|\n cell_node.id cell_name\n cell_node.name I18n.translate(:\"adva.cells.#{cell_name}.name\", :default => cell_name.humanize)\n cell_node.states do |states_node|\n self.states.uniq.each do |state|\n states_node.state do |state_node|\n state = state.to_s\n\n # render the form ... if it's empty ... well, then it's empty ;-)\n # view = Cell::View.new\n # template = self.find_class_view_for_state(state + '_form').each do |path|\n # puts path\n # if template = view.try_picking_template_for_path(path)\n # puts template\n # return template\n # end\n # end\n # form = template ? ERB.new(view.render(:template => template)).result : ''\n\n # FIXME: this implementation is brittle at best and needs to be refactored/corrected ASAP!!!\n possible_templates = Dir[RAILS_ROOT + \"/app/cells/#{cell_name}/#{state}_form.html.erb\"] + Dir[File.join(RAILS_ROOT, 'vendor', 'adva', 'engines') + \"/*/app/cells/#{cell_name}/#{state}_form.html.erb\"]\n template = possible_templates.first\n form = template ? ERB.new(File.read(template)).result : ''\n\n state_node.id state\n state_node.name I18n.translate(:\"adva.cells.#{cell_name}.states.#{state}.name\", :default => state.humanize)\n state_node.description I18n.translate(:\"adva.cells.#{cell_name}.states.#{state}.description\", :default => '')\n state_node.form form\n end\n end\n end\n end\n end", "def to_xml(options={})\n options[:root] ||= 'cell'\n options[:indent] ||= 2\n options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])\n\n cell_name = self.to_s.gsub('Cell', '').underscore\n\n options[:builder].tag!(options[:root]) do |cell_node|\n cell_node.id cell_name\n cell_node.name I18n.translate(:\"adva.cells.#{cell_name}.name\", :default => cell_name.humanize)\n cell_node.states do |states_node|\n self.states.uniq.each do |state|\n states_node.state do |state_node|\n state = state.to_s\n\n # render the form ... if it's empty ... well, then it's empty ;-)\n # view = Cell::View.new\n # template = self.find_class_view_for_state(state + '_form').each do |path|\n # puts path\n # if template = view.try_picking_template_for_path(path)\n # puts template\n # return template\n # end\n # end\n # form = template ? ERB.new(view.render(:template => template)).result : ''\n\n # FIXME: this implementation is brittle at best and needs to be refactored/corrected ASAP!!!\n possible_templates = Dir[RAILS_ROOT + \"/app/cells/#{cell_name}/#{state}_form.html.erb\"] + Dir[File.join(RAILS_ROOT, 'vendor', 'adva', 'engines') + \"/*/app/cells/#{cell_name}/#{state}_form.html.erb\"]\n template = possible_templates.first\n form = template ? ERB.new(File.read(template)).result : ''\n\n state_node.id state\n state_node.name I18n.translate(:\"adva.cells.#{cell_name}.states.#{state}.name\", :default => state.humanize)\n state_node.description I18n.translate(:\"adva.cells.#{cell_name}.states.#{state}.description\", :default => '')\n state_node.form form\n end\n end\n end\n end\n end", "def to_xml(options={})\n options[:root] ||= 'cell'\n options[:indent] ||= 2\n options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])\n\n cell_name = self.to_s.gsub('Cell', '').underscore\n\n options[:builder].tag!(options[:root]) do |cell_node|\n cell_node.id cell_name\n cell_node.name I18n.translate(:\"adva.cells.#{cell_name}.name\", :default => cell_name.humanize)\n cell_node.states do |states_node|\n self.states.uniq.each do |state|\n states_node.state do |state_node|\n state = state.to_s\n\n # render the form ... if it's empty ... well, then it's empty ;-)\n # view = Cell::View.new\n # template = self.find_class_view_for_state(state + '_form').each do |path|\n # puts path\n # if template = view.try_picking_template_for_path(path)\n # puts template\n # return template\n # end\n # end\n # form = template ? ERB.new(view.render(:template => template)).result : ''\n\n # FIXME: this implementation is brittle at best and needs to be refactored/corrected ASAP!!!\n possible_templates = Dir[RAILS_ROOT + \"/app/cells/#{cell_name}/#{state}_form.html.erb\"] + Dir[File.join(RAILS_ROOT, 'vendor', 'adva', 'engines') + \"/*/app/cells/#{cell_name}/#{state}_form.html.erb\"]\n template = possible_templates.first\n form = template ? ERB.new(File.read(template)).result : ''\n\n state_node.id state\n state_node.name I18n.translate(:\"adva.cells.#{cell_name}.states.#{state}.name\", :default => state.humanize)\n state_node.description I18n.translate(:\"adva.cells.#{cell_name}.states.#{state}.description\", :default => '')\n state_node.form form\n end\n end\n end\n end\n end", "def to_xml\n\t\tend", "def to_xml\n\t\tend", "def row; end", "def to_xml\n render_xml\n end", "def render_xml\n @xml = Builder::XmlMarkup.new\n @xml.gauge do\n @xml.license( @license ) unless @license.nil?\n render_extra_components \n render_components\n end\n @xml.to_s.gsub( /<to_s\\/>/, '' ) \n end", "def to_xml\n Builder.new(self).to_s\n end", "def build_xml(builder)\n super(builder)\n builder.Value { |b| b.Text self.data }\n builder.UnitType { |b| eng_unit_type.build_xml(b) } unless eng_unit_type.blank?\n end", "def to_xml(*)\n self\n end", "def to_xml(data, columns = nil, buffer = \"\", options = {})\n require 'builder'\n options = DEFAULT_OPTIONS.merge(options)\n ten, ren, cen = options[:table_element_name], \n options[:row_element_name],\n options[:column_element_name]\n buffer << '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' << \"\\n\"\n buffer << \"<#{ten}>\"<< \"\\n\"\n data.each{|row|\n buffer << \" \" << \"<#{ren}>\" << \"\\n\"\n columns.each{|column|\n buffer << \" \" << \"<#{column}>#{row[column].to_s.to_xs}</#{column}>\" << \"\\n\"\n }\n buffer << \" \" << \"</#{ren}>\" << \"\\n\"\n }\n buffer << \"</#{ten}>\"<< \"\\n\"\n buffer\n end", "def to_xml(b = Builder::XmlMarkup.new(:indent => 2))\n optional_root_tag(parent.class.optional_xml_root_name, b) do |c|\n c.tag!(model.class.xml_node_name || model.model_name) {\n attributes.each do | key, value |\n field = self.class.fields[key]\n value = self.send(key) if field[:calculated]\n xml_value_from_field(b, field, value) unless value.nil?\n end\n }\n end\n end", "def build_element(row)\n # Unlike the meal, there are no customer specific\n # convertions to be done on Row\n Customer.new(row) # returns a Customer instance\n end", "def build_element(row)\n # Unlike the meal, there are no customer specific\n # convertions to be done on Row\n Customer.new(row) # returns a Customer instance\n end", "def generate_xml(row)\n xml = Builder::XmlMarkup.new\n xml.PAP_INTVSCH_RECORD do |d|\n d.appLseNumber(row[\"appNumber\"])\n d.enabled(\"Y\")\n (0..@config[\"lease_terms\"].to_i).each do |i|\n\n duedate = row[\"dueDate_#{i}\"].nil? ? '' : row[\"dueDate_#{i}\"]\n amount = row[\"amount_#{i}\"].nil? ? '' : row[\"amount_#{i}\"]\n\n d.__send__(\"dueDate_#{i}\") do\n d << duedate\n end\n d.__send__(\"amount_#{i}\") do\n d << amount\n end\n end\n end\n end", "def to_xml\n @builder.to_xml\n end", "def dbrow_serialization\n dbrow = super[\"dbrow\"]\n dbrow[:xml] = self.xml\n dbrow.delete(:_xml_entity_created_by)\n dbrow.delete(:_xml_entity_created_at)\n dbrow.delete(:_xml_entity_modified_by)\n dbrow.delete(:_xml_entity_modified_at)\n\n {\n \"dbrow\" => dbrow\n }\n end", "def to_xml\n builder = Builder::XmlMarkup.new(:indent=>2)\n builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'\n xml = builder.items{ self.each{|x| builder.item(x) } }\n xml\n end", "def build_xml\n raise NotImplementedError, \"Override build_xml in subclass\"\n end", "def xml_builder\n return Builder::XmlMarkup.new(:indent=>2, :margin=>4)\n end", "def to_xml_fragment\n Exporters::XML::DDI::Fragment.export_3_2 Exporters::XML::DDI::QuestionGrid, self\n end", "def render_xml\n end", "def to_s\r\n assert_exists\r\n r = super({\"rows\" => \"rows.length\",\"columns\" => \"columnLength\", \"cellspacing\" => \"cellspacing\", \"cellpadding\" => \"cellpadding\", \"border\" => \"border\"})\r\n # r += self.column_count.to_s\r\n end", "def to_xml\n before_validate\n validate\n render File.expand_path('../../haml/block.haml', __FILE__), self\n end", "def row\n @vgroup.add(@vertical);\n alignments_reset ; widths_reset ; heights_reset\n end", "def serialize\n\n\t\t{\n\t\t\twidth: @width, height: @height, mines: @mines, \n\t\t\tcell_size: @cell_size,\n\t\t}\n\n\tend", "def xml; end", "def serialize()\n { x: @x, y: @y, w: @w, h: @h, path: @path, x_offset: @x_offset,\n y_offset: @y_offset, w_offset: @w_offset, h_offset: @h_offset,\n source_x: @source_x, source_y: @source_y, source_w: @source_w,\n source_h: @source_h, col: @col, row: @row }\n end", "def content\n\t\treturn GridCreator.fromArray(self.contents, :horizontal => true)\n\tend", "def to_xml(xml)\n xml[:c].title {\n unless @text.empty?\n xml[:c].tx {\n xml[:c].strRef {\n xml[:c].f Axlsx::cell_range([@cell])\n xml[:c].strCache {\n xml[:c].ptCount :val=>1\n xml[:c].pt(:idx=>0) {\n xml[:c].v @text\n }\n }\n }\n }\n end\n xml[:c].layout\n xml[:c].overlay :val=>0\n } \n end", "def to_xml\n\t\t\t\"<#{@name} #{attributes_string} />\"\n\t\tend", "def to_xml\n builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|\n xml.send('c:chartSpace', :'xmlns:c' => XML_NS_C, :'xmlns:a' => XML_NS_A) {\n xml[:c].date1904 :val => Axlsx::Workbook.date1904\n xml[:c].style :val=>style\n xml[:c].chart {\n @title.to_xml(xml)\n xml.autoTitleDeleted :val=>0\n @view3D.to_xml(xml) unless @view3D.nil?\n \n xml.floor { xml.thickness(:val=>0) }\n xml.sideWall { xml.thickness(:val=>0) }\n xml.backWall { xml.thickness(:val=>0) }\n xml.plotArea {\n xml.layout\n yield xml if block_given?\n }\n if @show_legend\n xml.legend {\n xml.legendPos :val => \"r\"\n xml.layout\n xml.overlay :val => 0 \n }\n end\n xml.plotVisOnly :val => 1\n xml.dispBlanksAs :val => :zero\n xml.showDLblsOverMax :val => 1\n }\n \n }\n end\n builder.to_xml(:save_with => 0)\n end", "def marshal( options={} )\n xml = options[:builder]\n\n @table.each_pair do |key, value|\n if value.is_a?( Array )\n if value.empty?\n do_xml!( xml, key, nil )\n else\n value.each { |each_value| do_xml!( xml, key, each_value ) }\n end\n elsif value.is_a?(REXML::Element)\n xml << value.to_s\n else\n do_xml!( xml, key, value )\n end\n end\n end", "def build_xml(p_item)\r\n xml = \"<#{ELE_ITEM}>\\n\"\r\n unless p_item.id.nil?\r\n xml += \"\\t<#{ELE_ID}>#{p_item.id}</#{ELE_ID}>\\n\"\r\n end\r\n xml += \"\\t<#{ELE_TITLE}>#{p_item.title}</#{ELE_TITLE}>\\n\"\r\n xml += \"\\t<#{ELE_CREATED_ON}><![CDATA[#{format_date(p_item.created_on)}]]></#{ELE_CREATED_ON}>\\n\"\r\n xml += \"\\t<#{ELE_LAST_UPDATED_ON}><![CDATA[#{format_date(p_item.last_updated_on)}]]></#{ELE_LAST_UPDATED_ON}>\\n\"\r\n xml += \"\\t<#{ELE_FIELDS}>\\n\"\r\n p_item.get_fields.each do |name, value|\r\n xml += \"\\t\\t<#{ELE_FIELD} #{ATTR_NAME}='#{name}'><![CDATA[#{value}]]></#{ELE_FIELD}>\\n\"\r\n end\r\n xml += \"\\t</#{ELE_FIELDS}>\\n\"\r\n\r\n # add related items\r\n related_items = p_item.get_related_items\r\n unless related_items.nil? and related_items.empty?\r\n xml += \"<#{ELE_RELATED_ITEMS}>\\n\"\r\n related_items.each do |key, item_ids|\r\n xml += \"<#{key}>\\n\"\r\n item_ids.each do |item_id|\r\n xml += \"<#{ELE_ITEM}>\"\r\n xml += item_id.to_s\r\n xml += \"</#{ELE_ITEM}>\\n\"\r\n end\r\n xml += \"</#{key.to_s.downcase}>\\n\"\r\n end\r\n xml += \"</#{ELE_RELATED_ITEMS}>\\n\"\r\n end\r\n\r\n # set target class\r\n unless p_item.target_class.nil?\r\n xml += \"<#{ELE_TARGET_CLASS}>\"\r\n xml += p_item.target_class\r\n xml += \"</#{ELE_TARGET_CLASS}>\"\r\n end\r\n\r\n xml += \"</#{ELE_ITEM}>\\n\"\r\n end", "def to_xml\n output=\"\"\n self.to_rexml.write output\n end", "def to_xml\n to_xml_builder.to_xml\n end", "def to_xml\n to_xml_builder.to_xml\n end", "def draw_property_row(name, value)\n html = HtmlOutputHelper.new(\n @server.base_uri,\n @server.xml.namespace_map\n )\n\n \"<tr><th>#{html.xml_name(name)}</th><td>#{draw_property_value(html, value)}</td></tr>\"\n end", "def build_xml(builder)\n super(builder)\n object_data.each do |d|\n builder.Attribute do |b|\n d.build_xml(b)\n end\n end\n builder.DefaultUnitType { |b| default_eng_unit_type.build_xml(b) }\n end", "def build_cell(cell)\n # implement in row class\n nil\n end", "def to_s\n \"Row #{@line}\"\n end", "def row(row)\n Row.new(@data, row)\n end", "def xml_builder_template(extra_opts = {})\n extra_attributes = extra_opts.fetch(:attributes, {})\n\n node_options = []\n node_child_template = \"\"\n if !self.default_content_path.nil?\n node_child_options = [\"\\':::builder_new_value:::\\'\"]\n node_child_template = \" { xml.#{self.default_content_path}( #{OM::XML.delimited_list(node_child_options)} ) }\"\n else\n node_options = [\"\\':::builder_new_value:::\\'\"]\n end\n if !self.attributes.nil?\n self.attributes.merge(extra_attributes).each_pair do |k,v|\n node_options << \"\\'#{k}\\'=>\\'#{v}\\'\" unless v == :none\n end\n end\n\n builder_ref = if self.path.include?(\":\")\n \"xml['#{self.path[0..path.index(\":\")-1]}']\"\n elsif !self.namespace_prefix.nil? and self.namespace_prefix != 'oxns'\n \"xml['#{self.namespace_prefix}']\"\n else\n \"xml\"\n end\n\n attribute = OM::XML.delimited_list(node_options)\n\n builder_method = if self.path.include?(\":\")\n \"#{self.path[path.index(\":\")+1..-1]}( #{attribute} )\"\n elsif self.path.include?(\".\")\n \"send(:\\\\\\\"#{self.path}\\\\\\\", #{attribute} )\"\n elsif self.path.kind_of?(Hash) && self.path[:attribute]\n \"@#{self.path[:attribute]}( #{OM::XML.delimited_list(node_options)} )\"\n elsif Nokogiri::XML::Builder.method_defined? self.path.to_sym\n \"#{self.path}_( #{OM::XML.delimited_list(node_options)} )\"\n else\n \"#{self.path}( #{OM::XML.delimited_list(node_options)} )\"\n end\n template = \"#{builder_ref}.#{builder_method}#{node_child_template}\"\n return template.gsub( /:::(.*?):::/ ) { '#{'+$1+'}' }\n end", "def builder\n @builder ||= Builder::XmlMarkup.new(:indent => 2)\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def build_xml(builder)\n super(builder)\n builder.ValidNetwork { |b| valid_network.build_xml(b) } if valid_network\n builder.Model { |b| model.build_xml(b) } if model\n builder.Manufacturer { |b| manufacturer.build_xml(b) } if manufacturer\n end", "def generate_xml( args={} )\n biomart_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => biomart_xml, :indent => 2 )\n \n xml.instruct!\n xml.declare!( :DOCTYPE, :Query )\n xml.Query( :virtualSchemaName => \"default\", :formatter => \"TSV\", :header => \"0\", :uniqueRows => \"1\", :count => args[:count], :datasetConfigVersion => \"0.6\" ) {\n xml.Dataset( :name => @name, :interface => \"default\" ) {\n \n if args[:filters]\n args[:filters].each do |name,value|\n if value.is_a? Array\n value = value.join(\",\")\n end\n xml.Filter( :name => name, :value => value )\n end\n else\n self.filters.each do |name,filter|\n if filter.default\n xml.Filter( :name => name, :value => filter.default_value )\n end\n end\n end\n \n unless args[:count]\n if args[:attributes]\n args[:attributes].each do |name|\n xml.Attribute( :name => name )\n end\n else\n self.attributes.each do |name,attribute|\n if attribute.default\n xml.Attribute( :name => name )\n end\n end\n end\n end\n \n }\n }\n \n return biomart_xml\n end", "def build_xml(builder)\n super(builder)\n builder.Type { |b| self.object_type.build_xml(b) } if object_type\n end", "def xmlAttr()\r\n a = super()\r\n a << ['width', @width]\r\n a << ['height', @height]\r\n a << ['depth', @depth]\r\n @fillColor.xmlAttr.each { |ac|\r\n a << ac\r\n }\r\n a\r\n end", "def build_row(data = self.data)\n values = data.to_a\n keys = self.data.column_names.to_a\n hash = {}\n values.each_with_index do |val, i|\n key = (keys[i] || i).to_s\n hash[key] = val\n end\n line = hash.to_json.to_s\n output << \" #{line}\"\n end", "def render_sections_xml(sectionslist)\n builder do |xml|\n xml.instruct!\n xml.sections do\n sectionslist.each do |section|\n xml.section do\n xml.userId section.userId\n xml.title section.title\n xml.shows section.shows\n xml.actors section.actors\n end\n end\n end\n end\nend", "def to_xml\n \n text = \"<node id=\\\"#{self.id}\\\" label=\\\"#{self.label}\\\">\\n\"\n \n unless self.attributes.nil?\n text << \"\\t<attvalues>\\n\"\n self.attributes.each do |key, value|\n text << \"\\t\\t<attvalue for=\\\"#{key}\\\" value=\\\"#{value}\\\"></attvalue>\\n\"\n end\n text << \"\\t</attvalues>\\n\"\n end\n \n unless self.viz_size.nil?\n text << \"\\t<viz:size value=\\\"#{self.viz_size}\\\"/>\\n\"\n end\n \n unless self.viz_color.nil?\n text << \"\\t<viz:color b=\\\"#{self.viz_color[:b]}\\\" g=\\\"#{self.viz_color[:g]}\\\" r=\\\"#{self.viz_color[:r]}\\\"/>\\n\"\n end\n \n unless self.viz_position.nil?\n text << \"\\t<viz:position x=\\\"#{self.viz_position[:x]}\\\" y=\\\"#{self.viz_position[:z]}\\\"/>\\n\"\n end\n \n text << \"</node>\\n\"\n text \n end", "def to_xml(builder)\n builder.series type: type do\n builder.title { title.to_xml builder } if title\n builder.place place if place\n builder.organization organization if organization\n builder.abbreviation { abbreviation.to_xml builder } if abbreviation\n builder.from from if from\n builder.to to if to\n builder.number number if number\n builder.part_number part_number if part_number\n end\n end", "def content\n @row.html\n end", "def result_to_attributes_xml(result, options = {}, &block)\n inner_recursion = options.delete(:inner_recursion)\n result_set = inner_recursion ? result : result.dup\n \n parent_id = (options.delete(:parent_id) || result_set.first[result_set.first.parent_col_name]) rescue nil\n level = options[:level] || 0 \n options[:methods] ||= []\n options[:nested] = true unless options.key?(:nested)\n options[:dasherize] = true unless options.key?(:dasherize)\n \n if options[:only].blank? && options[:except].blank?\n options[:except] = [:left_column, :right_column, :parent_column].inject([]) do |ex, opt|\n column = acts_as_nested_set_options[opt].to_sym\n ex << column unless ex.include?(column)\n ex\n end\n end\n \n options[:indent] ||= 2\n options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])\n options[:builder].instruct! unless options.delete(:skip_instruct)\n \n parent_attrs = {}\n parent_attrs[:xmlns] = options[:namespace] if options[:namespace]\n \n siblings = options[:nested] ? result_set.select { |s| s.parent_id == parent_id } : result_set \n siblings.each do |sibling|\n result_set.delete(sibling)\n node_tag = (options[:record] || sibling[sibling.class.inheritance_column] || 'node').underscore\n node_tag = node_tag.dasherize unless options[:dasherize]\n attrs = block_given? ? block.call(sibling, level) : sibling.attributes(:only => options[:only], :except => options[:except])\n options[:methods].inject(attrs) { |enum, m| enum[m.to_s] = sibling.send(m) if sibling.respond_to?(m); enum }\n if options[:nested] && sibling.children?\n opts = options.merge(:parent_id => sibling.id, :level => level + 1, :inner_recursion => true, :skip_instruct => true) \n options[:builder].tag!(node_tag, attrs) { result_to_attributes_xml(result_set, opts, &block) }\n else\n options[:builder].tag!(node_tag, attrs)\n end\n end\n unless inner_recursion\n result_set.each do |orphan|\n node_tag = (options[:record] || orphan[orphan.class.inheritance_column] || 'node').underscore\n node_tag = node_tag.dasherize unless options[:dasherize] \n attrs = block_given? ? block.call(orphan, level) : orphan.attributes(:only => options[:only], :except => options[:except])\n options[:methods].inject(attrs) { |enum, m| enum[m.to_s] = orphan.send(m) if orphan.respond_to?(m); enum }\n options[:builder].tag!(node_tag, attrs)\n end\n end\n options[:builder].target!\n end", "def generatexml()\n merge(gadrgeneratexml: 'true')\n end", "def xml_builder_template(extra_opts = {})\n extra_attributes = extra_opts.fetch(:attributes, {})\n\n node_options = []\n node_child_template = \"\"\n if !self.default_content_path.nil?\n node_child_options = [\"\\':::builder_new_value:::\\'\"]\n node_child_template = \" { xml.#{self.default_content_path}( #{OM::XML.delimited_list(node_child_options)} ) }\"\n else\n node_options = [\"\\':::builder_new_value:::\\'\"]\n end\n if !self.attributes.nil?\n self.attributes.merge(extra_attributes).each_pair do |k,v|\n node_options << \"\\'#{k}\\'=>\\'#{v}\\'\" unless v == :none\n end\n end\n builder_ref = \"xml\"\n builder_method = self.path\n if builder_method.include?(\":\")\n builder_ref = \"xml['#{self.path[0..path.index(\":\")-1]}']\"\n builder_method = self.path[path.index(\":\")+1..-1]\n elsif !self.namespace_prefix.nil? and self.namespace_prefix != 'oxns'\n builder_ref = \"xml['#{self.namespace_prefix}']\"\n elsif self.path.kind_of?(Hash) && self.path[:attribute]\n builder_method = \"@#{self.path[:attribute]}\"\n end\n if Nokogiri::XML::Builder.method_defined? builder_method.to_sym\n builder_method += \"_\"\n end\n template = \"#{builder_ref}.#{builder_method}( #{OM::XML.delimited_list(node_options)} )\" + node_child_template\n return template.gsub( /:::(.*?):::/ ) { '#{'+$1+'}' }\n end", "def rows(parts=@parts)\n \n @renderer.rows(parts)\n \n end", "def prepare_final_xml\n @base_xml.elements[\"#{@ns}:OccupancyLevels/#{@ns}:OccupancyLevel/#{@ns}:OccupantQuantity\"].text = @occupant_quantity if !@occupant_quantity.nil?\n @base_xml.elements[\"#{@ns}:SpatialUnits/#{@ns}:SpatialUnit/#{@ns}:NumberOfUnits\"].text = @number_of_units if !@number_of_units.nil?\n\n # Add new element in the XML file\n add_user_defined_field_to_xml_file('OpenStudioModelName', @name)\n add_user_defined_field_to_xml_file('StandardTemplateYearOfConstruction', @built_year)\n add_user_defined_field_to_xml_file('StandardTemplate', @standard_template)\n add_user_defined_field_to_xml_file('BuildingRotation', @building_rotation)\n add_user_defined_field_to_xml_file('FloorHeight', @floor_height)\n add_user_defined_field_to_xml_file('WindowWallRatio', @wwr)\n add_user_defined_field_to_xml_file('PartyWallStoriesNorth', @party_wall_stories_north)\n add_user_defined_field_to_xml_file('PartyWallStoriesSouth', @party_wall_stories_south)\n add_user_defined_field_to_xml_file('PartyWallStoriesEast', @party_wall_stories_east)\n add_user_defined_field_to_xml_file('PartyWallStoriesWest', @party_wall_stories_west)\n add_user_defined_field_to_xml_file('Width', @width)\n add_user_defined_field_to_xml_file('Length', @length)\n add_user_defined_field_to_xml_file('PartyWallFraction', @party_wall_fraction)\n add_user_defined_field_to_xml_file('ModelNumberThermalZones', @model.getThermalZones.size)\n add_user_defined_field_to_xml_file('ModelNumberSpaces', @model.getSpaces.size)\n add_user_defined_field_to_xml_file('ModelNumberStories', @model.getBuildingStorys.size)\n add_user_defined_field_to_xml_file('ModelNumberPeople', @model.getBuilding.numberOfPeople)\n add_user_defined_field_to_xml_file('ModelFloorArea(m2)', @model.getBuilding.floorArea)\n\n wf = @model.weatherFile.get\n add_user_defined_field_to_xml_file('ModelWeatherFileName', wf.nameString)\n add_user_defined_field_to_xml_file('ModelWeatherFileDataSource', wf.dataSource)\n add_user_defined_field_to_xml_file('ModelWeatherFileCity', wf.city)\n add_user_defined_field_to_xml_file('ModelWeatherFileStateProvinceRegion', wf.stateProvinceRegion)\n add_user_defined_field_to_xml_file('ModelWeatherFileLatitude', wf.latitude)\n add_user_defined_field_to_xml_file('ModelWeatherFileLongitude', wf.longitude)\n prepare_final_xml_for_spatial_element\n end", "def generatexml()\n merge(rvgeneratexml: 'true')\n end", "def result\n render_xml\n end", "def to_xml_string(str = +'')\n return if empty?\n\n str << \"<tableParts count='#{size}'>\"\n each { |table| str << \"<tablePart r:id='#{table.rId}'/>\" }\n str << '</tableParts>'\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def to_xml\n IO::XMLExporter.new.to_xml(self)\n end", "def markup\r\n return @markup if @markup \r\n @markup = Builder::XmlMarkup.new(:target => self.output, :indent => 1)\r\n end", "def to_xml(options={}, &block)\n super(options.reverse_merge(:include => :parts), &block)\n end", "def to_nokogiri(doc) # :nodoc:\n row = doc.create_element('row'); doc.add_child(row)\n each { |key,value|\n element = doc.create_element(key.to_s)\n element.add_child(doc.create_text_node(value.to_s))\n row.add_child(element)\n }\n row\n end", "def to_xml\n return self.to_s\n end", "def to_s\n \"#{self.class} <#{@rows} x #{@cols}>: #{@fm.each_slice(@cols).to_a}\"\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_collection_of_object_values(\"borders\", @borders)\n writer.write_object_value(\"columnWidth\", @column_width)\n writer.write_object_value(\"fill\", @fill)\n writer.write_object_value(\"font\", @font)\n writer.write_string_value(\"horizontalAlignment\", @horizontal_alignment)\n writer.write_object_value(\"protection\", @protection)\n writer.write_object_value(\"rowHeight\", @row_height)\n writer.write_string_value(\"verticalAlignment\", @vertical_alignment)\n writer.write_boolean_value(\"wrapText\", @wrap_text)\n end", "def build\r\n builder = Builder::XmlMarkup.new\r\n builder.instruct!(:xml, encoding: 'UTF-8')\r\n builder.tag! :env, :Envelope, namespaces do |env|\r\n env.tag!(:env, :Header) do |env_header|\r\n create_header(env_header)\r\n end\r\n env.tag!(:env, :Body) do |env_body|\r\n create_body(env_body)\r\n end\r\n end\r\n end", "def rows\n render 'rows.html'\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_collection_of_object_values(\"columns\", @columns)\n writer.write_boolean_value(\"highlightFirstColumn\", @highlight_first_column)\n writer.write_boolean_value(\"highlightLastColumn\", @highlight_last_column)\n writer.write_string_value(\"legacyId\", @legacy_id)\n writer.write_string_value(\"name\", @name)\n writer.write_collection_of_object_values(\"rows\", @rows)\n writer.write_boolean_value(\"showBandedColumns\", @show_banded_columns)\n writer.write_boolean_value(\"showBandedRows\", @show_banded_rows)\n writer.write_boolean_value(\"showFilterButton\", @show_filter_button)\n writer.write_boolean_value(\"showHeaders\", @show_headers)\n writer.write_boolean_value(\"showTotals\", @show_totals)\n writer.write_object_value(\"sort\", @sort)\n writer.write_string_value(\"style\", @style)\n writer.write_object_value(\"worksheet\", @worksheet)\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def to_xml(elem_name = nil)\n # The root element is the class name, downcased\n elem_name ||= self.class.to_s.split('::').last.downcase\n root = Element.new elem_name\n\n # Add each BaseObject member to the root elem\n self.members.each do |field_name|\n next if self.class::MUTABILITY[field_name.to_sym] == :read_only\n\n value = self.send(field_name)\n\n if value.is_a?(Array)\n node = root.add_element(field_name)\n value.each { |array_elem|\n array_elem_name = 'line' if field_name == 'lines'\n node.add_element(array_elem.to_xml(array_elem_name))\n }\n elsif !value.nil?\n root.add_element(field_name).text = value\n end\n end\n root\n end", "def to_xml\n self.to_s\n end", "def to_xml\n self.to_s\n end", "def to_xml(builder=nil)\n builder = ::Builder::XmlMarkup.new if builder.nil?\n builder.sitemap do\n builder.loc self[:loc]\n builder.lastmod w3c_date(self[:lastmod]) if self[:lastmod]\n end\n builder << '' # force to string\n end", "def to_xml\r\n x = Builder::XmlMarkup.new(:target => (reply = ''))\r\n x.instruct!\r\n x.comment! \"#{@collection.size} entries\" \r\n x.strings(:each => @each) {\r\n @collection.each do |each|\r\n x.s(each)\r\n end\r\n }\r\n reply\r\n end", "def write_content(file_out)\n @array.each do |row|\n file_out.puts(' <Row>')\n row.each do |e|\n t = float?(e) ? 'Number' : 'String'\n file_out.puts(\n \" <Cell><Data ss:Type=\\\"#{t}\\\">#{e}</Data></Cell>\"\n )\n end\n file_out.puts(' </Row>')\n end\n end", "def build_element(row)\n # Price MUST be an integer\n # binding.pry\n row[:price] = row[:price].to_i\n # binding.pry\n Meal.new(row) # returns a Meal instance\n end", "def to_xml(opts=OPTS)\n vals = values\n types = opts[:types]\n inc = opts[:include]\n\n cols = if only = opts[:only]\n Array(only)\n else\n vals.keys - Array(opts[:except])\n end\n\n name_proc = model.xml_serialize_name_proc(opts)\n x = model.xml_builder(opts)\n x.send(name_proc[opts.fetch(:root_name, model.send(:underscore, model.name).gsub('/', '__')).to_s]) do |x1|\n cols.each do |c|\n attrs = {}\n if types\n attrs[:type] = db_schema.fetch(c, OPTS)[:type]\n end\n v = vals[c]\n if v.nil?\n attrs[:nil] = ''\n end\n x1.send(name_proc[c.to_s], v, attrs)\n end\n if inc.is_a?(Hash)\n inc.each{|k, v| to_xml_include(x1, k, v)}\n else\n Array(inc).each{|i| to_xml_include(x1, i)}\n end\n yield x1 if block_given?\n end\n x.to_xml\n end", "def to_xml_string(str = '')\n str << '<sheetViews>'\n str << '<sheetView '\n str << instance_values.map { |key, value| (Axlsx::camel(key.to_s, false) << '=\"' << value.to_s << '\"') unless CHILD_ELEMENTS.include?(key.to_sym) || value == nil }.join(' ')\n str << '>'\n @pane.to_xml_string(str) if @pane\n @selections.each do |key, selection|\n selection.to_xml_string(str)\n end\n str << '</sheetView>'\n str << '</sheetViews>'\n end", "def render\n puts \"-------------------------------------\"\n @grid.each do |row| \n puts \"| \" + row.map(&:to_s).join(\" | \") + \" |\"\n puts \"-------------------------------------\"\n end\n end", "def hc(row,col)\n build :cell, row: row, col: col\n end", "def to_xml_string(str = +'')\n return if empty?\n\n str << '<cols>'\n each { |item| item.to_xml_string(str) }\n str << '</cols>'\n end", "def generate_row(row)\n '|' + \"#{(row.map {|x| generate_item(x)}).join('|')}\\n\"\n end", "def encode(model, record)\n if record.respond_to?(\"to_#{prefix}\")\n record.send(\"to_#{prefix}\")\n else\n xml = Builder::XmlMarkup.new\n map = model.respond_to?(\"map_#{prefix}\") ? model.send(\"map_#{prefix}\") : {}\n xml.tag!(\"#{prefix}:#{element_namespace}\", header_specification) do\n fields.each do |field|\n values = value_for(field, record, map)\n next if values.nil?\n if values.respond_to?(:each)\n values.each do |value|\n xml.tag! \"#{element_namespace}:#{field}\", value\n end\n else\n xml.tag! \"#{element_namespace}:#{field}\", values\n end\n end\n end\n xml.target!\n end\n end", "def xml \n obj = {}\n expOb = Experiment.where('experimentName' => params[:experimentName]).to_a[0]\n obj['gameName'] = expOb['gameName']\n obj['sequences'] = expOb['sequences']\n obj['experimentName'] = expOb['experimentName']\n render :xml => \"<hash>\"+create_xml(obj, '')+\"</hash>\\n\"\n end", "def build\r\n\t \tbuffer = \"\"\r\n\t\t xml = Builder::XmlMarkup.new(buffer)\r\n\t\t xml.instruct! :xml, :version=>\"1.0\", :encoding=>\"UTF-8\" \r\n\t\t xml.Workbook({\r\n\t\t 'xmlns' => \"urn:schemas-microsoft-com:office:spreadsheet\", \r\n\t\t 'xmlns:o' => \"urn:schemas-microsoft-com:office:office\",\r\n\t\t 'xmlns:x' => \"urn:schemas-microsoft-com:office:excel\", \r\n\t\t 'xmlns:html' => \"http://www.w3.org/TR/REC-html40\",\r\n\t\t 'xmlns:ss' => \"urn:schemas-microsoft-com:office:spreadsheet\" \r\n\t\t }) do\r\n\t \r\n\t\t\t xml.Styles do\r\n\t\t\t xml.Style 'ss:ID' => 'Default', 'ss:Name' => 'Normal' do\r\n\t\t\t xml.Alignment 'ss:Vertical' => 'Bottom'\r\n\t\t\t xml.Borders\r\n\t\t\t xml.Font 'ss:FontName' => 'Arial'\r\n\t\t\t xml.Interior\r\n\t\t\t xml.NumberFormat\r\n\t\t\t xml.Protection\r\n\t\t\t end\r\n\t\t\t \r\n\t\t\t xml.Style 'ss:ID' => 'DefaultBold' do\r\n\t\t\t xml.Font 'ss:Bold' => '1'\r\n\t\t end\r\n\t\t\t \r\n\t\t\t xml.Style 'ss:ID' => 'Date' do\r\n\t\t\t xml.NumberFormat 'ss:Format' => 'mm/dd/yy'\r\n\t\t\t end\r\n\r\n\t\t\t xml.Style 'ss:ID' => 'DateBold' do\r\n\t\t\t xml.NumberFormat 'ss:Format' => 'mm/dd/yy'\r\n\t\t\t xml.Font 'ss:Bold' => '1'\r\n\t\t\t end\r\n\t\t\t \r\n\t\t\t xml.Style 'ss:ID' => 'Currency' do\r\n\t\t\t xml.NumberFormat 'ss:Format' => '\"$\"#,##0.00'\r\n\t\t\t end\t\t\t \r\n\r\n\t\t\t xml.Style 'ss:ID' => 'CurrencyBold' do\r\n\t\t\t xml.NumberFormat 'ss:Format' => '\"$\"#,##0.00'\r\n\t\t\t xml.Font 'ss:Bold' => '1'\r\n\t\t\t end\t\t\t \r\n\t\t\t end\r\n\t\t\t \r\n\t\t\t for object in @worksheets\r\n\t\t \t\t# use the << operator to prevent the < > and & characters from being converted.\r\n\t\t \t\t# this will concat them together.\r\n\t\t \t\tif object[1] =='array'\r\n\t\t \t\t xml << worksheetFromArray(object[0], object[2])\r\n\t elsif object[1]=='table'\r\n\t xml << worksheetFromTable(object[0], object[2])\r\n\t else\r\n\t xml << worksheet(object[0], object[1], object[2])\r\n\t end\r\n\t\t\t end # for records\r\n\t\t\t end\r\n\t\t\t \r\n\t return xml.target! \r\n\t end", "def to_xml(builder)\n encoded_length = \n if @external\n 0\n else\n base64 = to_binary\n base64.bytesize\n end\n\n builder.binaryDataArray(encodedLength: encoded_length) do |bda_n|\n super(bda_n)\n bda_n.binary(base64) unless self.external\n end\n end" ]
[ "0.67881894", "0.64383596", "0.6252738", "0.6088256", "0.60743666", "0.6060757", "0.59958315", "0.5992822", "0.59912175", "0.59912175", "0.59912175", "0.5930447", "0.5930447", "0.59286547", "0.5905474", "0.58934057", "0.5868874", "0.58656883", "0.5779803", "0.5759905", "0.57500505", "0.5715927", "0.5714694", "0.57131165", "0.57056", "0.5696521", "0.56928533", "0.56925565", "0.56508994", "0.56240624", "0.5595986", "0.55792135", "0.55768794", "0.55737996", "0.5565709", "0.5549701", "0.5547702", "0.55434996", "0.5543496", "0.5540886", "0.5524173", "0.552242", "0.55114454", "0.54843", "0.5477888", "0.5477888", "0.54563874", "0.54536736", "0.5452145", "0.5445585", "0.5443576", "0.54341686", "0.54134804", "0.5402782", "0.5395621", "0.5389437", "0.53824586", "0.5375221", "0.53682494", "0.5364755", "0.53565377", "0.5354643", "0.53488094", "0.5348344", "0.53375703", "0.53334606", "0.53280735", "0.532581", "0.5323915", "0.53197974", "0.5315534", "0.5304008", "0.53007776", "0.5298652", "0.5296164", "0.5292029", "0.5289717", "0.52855414", "0.52829987", "0.52729577", "0.52706665", "0.52665776", "0.5265193", "0.52601594", "0.52566904", "0.52566904", "0.52559614", "0.5246824", "0.5245299", "0.523692", "0.52282804", "0.5220476", "0.52160156", "0.5214101", "0.5206277", "0.52054065", "0.5198126", "0.51845884", "0.51759934", "0.517524" ]
0.6755729
1
build query tree, listener required methods
def xmldecl ver, enc, stand # ignore xml declaration end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_classic_query(options)\n raise ArgumentError, \"Query name is not present\" unless options[:query_name]\n raise ArgumentError, \"Parent list id is not present\" unless options[:parent_list_id]\n raise ArgumentError, \"Criteria is required\" unless options[:criteria]\n\n options[:visibility] ||= 0\n\n request_body = ''\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n xml.instruct!\n\n xml.Envelope do\n xml.Body do\n xml.CreateQuery do\n xml.QUERY_NAME options[:query_name]\n xml.PARENT_LIST_ID options[:parent_list_id]\n xml.VISIBILITY options[:visibility]\n\n xml.PARENT_FOLDER_ID options[:parent_folder_id] if options.has_key?(:parent_folder_id)\n xml.SELECT_COLUMNS options[:select_columns] if options.has_key?(:select_columns)\n xml.ALLOW_FIELD_CHANGE options[:allow_field_change] if options.has_key?(:allow_field_change)\n\n xml.CRITERIA do\n xml.TYPE options[:criteria][:type] if options[:criteria].has_key?(:type)\n\n options[:criteria][:expressions].each do |exp|\n xml.EXPRESSION do\n xml.TYPE exp[:type] if exp.has_key?(:type)\n xml.COLUMN_NAME exp[:column_name] if exp.has_key?(:column_name)\n xml.OPERATORS exp[:operators] if exp.has_key?(:operators)\n xml.VALUES exp[:values] if exp.has_key?(:values)\n xml.TABLE_ID exp[:table_id] if exp.has_key?(:table_id)\n xml.LEFT_PARENS exp[:left_parens] if exp.has_key?(:left_parens)\n xml.RIGHT_PARENS exp[:right_parens] if exp.has_key?(:right_parens)\n xml.AND_OR exp[:and_or] if exp.has_key?(:and_or)\n if exp[:rt_expressions]\n exp[:rt_expressions].each do |rt_exp|\n xml.RT_EXPRESSION do\n xml.TYPE rt_exp[:type] if rt_exp.has_key?(:type)\n xml.COLUMN_NAME rt_exp[:column_name] if rt_exp.has_key?(:column_name)\n xml.OPERATORS rt_exp[:operators] if rt_exp.has_key?(:operators)\n xml.VALUES rt_exp[:values] if rt_exp.has_key?(:values)\n xml.LEFT_PARENS rt_exp[:left_parens] if rt_exp.has_key?(:left_parens)\n xml.RIGHT_PARENS rt_exp[:right_parens] if rt_exp.has_key?(:right_parens)\n xml.AND_OR rt_exp[:and_or] if rt_exp.has_key?(:and_or)\n end\n end\n end\n end\n end\n end\n\n if options[:behavior]\n xml.BEHAVIOR do\n xml.OPTION_OPERATOR options[:behavior] if options.has_key?(:behavior)\n xml.TYPE_OPERATOR options[:type_operator] if options.has_key?(:type_operator)\n xml.MAILING_ID options[:mailing_id] if options.has_key?(:mailing_id)\n xml.REPORT_ID options[:report_id] if options.has_key?(:report_id)\n xml.LINK_NAME options[:link_name] if options.has_key?(:link_name)\n xml.WHERE_OPERATOR options[:where_operator] if options.has_key?(:where_operator)\n xml.CRITERIA_OPERATOR options[:criteria_operator] if options.has_key?(:criteria_operator)\n xml.VALUES options[:values] if options.has_key?(:values)\n end\n end\n end\n end\n end\n\n doc = send_xml_api_request(request_body)\n result_dom(doc)['ListId']\n end", "def build(attrs = {})\n @parent.new(@query_attrs.merge(attrs))\n end", "def make_query\n run_callbacks :make_query do\n self.scope.search(get_query_params)\n end\n end", "def build_query\n GraphQL.parse(BASE_QUERY).tap do |d_ast|\n selections = d_ast.definitions.first.selections.first.selections\n\n node_types.each do |type|\n selections << inline_fragment_ast(type) if include?(type)\n end\n\n selections.compact!\n end\n end", "def build_query(buttons = T.unsafe(nil)); end", "def initial_query; end", "def query\n q = @root.clone\n\n # Navigation paths come first in the query\n q << \"/#{@navigation_paths.join(\"/\")}\" unless @navigation_paths.empty?\n\n # Handle links queries, this isn't just a standard query option\n q << \"/$links/#{@links_navigation_property}\" if @links_navigation_property\n\n # Handle count queries, this isn't just a standard query option\n q << \"/$count\" if @count\n query_options = generate_query_options\n\n q << \"?#{query_options.join('&')}\" if !query_options.empty?\n q\n end", "def build_queries(text, build_opts, norm_opts)\n\t\ttrier = TEXT_TO_TRIE.new( build_opts[:min_tokens],\n\t\t\t\t\t\t\t\t build_opts[:max_tokens],\n\t\t\t\t\t\t\t\t )\n\t\t\n\t\t# Queries are normalized.\n\t\tqueries = trier.to_trie( text, \n\t\t \t\t\t\t norm_opts[:lowercased], \n\t\t \t norm_opts[:hyphen_replaced], \n\t\t \t norm_opts[:stemmed], \n\t\t \t)\n\t\t# queries - A hash of key (the normalized query string) and value (the array of \n\t\t# offsets (range values)) pairs.\n\t\tqueries\n\tend", "def compile_query\n #puts \"DATASET COMPILE self #{self}\"\n #puts \"DATASET COMPILE queries #{queries}\"\n \n # Old way: works but doesn't handle fmp compound queries.\n #query.each_with_object([{},{}]){|x,o| o[0].merge!(x[0] || {}); o[1].merge!(x[1] || {})}\n \n # New way: handles compound queries. Reqires ginjo-rfm 3.0.11.\n return unless queries # This should help introspecting dataset that results from record deletion. TODO: test this.\n queries.inject {|new_query,scope| apply_scope(new_query, scope)} ##puts \"SCOPE INJECTION scope:#{scope} new_query:#{new_query}\"; \n end", "def multi_query_builder\n\n query = \"\n SELECT\n #{select_arr.join(\",\\n\\t\")}\n FROM \\t#{groups.first.parent_table}\n #{pk_join_arr.join(\"\\n\")}\n #{fk_join_arr.join(\"\\n\")};\"\n\n return query\n end", "def prepare_query\n if @taxon_concept && TaxonData.is_clade_searchable?(@taxon_concept)\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query_with_taxon_filter(@taxon_concept.id, inner_select_clause, where_clause, order_clause)\n else\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query(inner_select_clause, where_clause, order_clause, nil)\n end\n # this is strange, but in order to properly do sorts, limits, and offsets there should be a subquery\n # see http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtTipsAndTricksHowToHandleBandwidthLimitExceed\n EOL::Sparql::SearchQueryBuilder.build_query(outer_select_clause, inner_query, nil, limit_clause)\n end", "def build_query(query)\n project, _, configuration, node_type, node_name = query.split(\":\")\n\n # Any empty/nil value is defaulted to nodes value\n # e.g/ :::service:main is a reference to the service main in the same project/env/config.\n project = @project if project.to_s == \"\"\n # can ONLY query within the same environment\n\n configuration = @configuration if configuration.to_s == \"\"\n node_type = @node_type if node_type.to_s == \"\"\n node_name = @node_name if node_name.to_s == \"\"\n\n \"#{project}:#{@environment}:#{configuration}:#{node_type}:#{node_name}\"\n end", "def prepare_query\n if @taxon_concept\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query_with_taxon_filter(@taxon_concept.id, inner_select_clause, where_clause, inner_order_clause)\n else\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query(inner_select_clause, where_clause, inner_order_clause, nil)\n end\n # this is strange, but in order to properly do sorts, limits, and offsets there should be a subquery\n # see http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtTipsAndTricksHowToHandleBandwidthLimitExceed\n EOL::Sparql::SearchQueryBuilder.build_query(outer_select_clause, inner_query, outer_order_clause, limit_clause)\n end", "def initialize(query:, model: )\n @query = query\n @root = model.table_name\n end", "def initialize(directory, &block)\n # Set root object\n @data = directory\n\n # Populate configurables from DSL block\n instance_eval(&block)\n\n\n raise(ArgumentError, \"A query must specify a 'select' clause\") unless @what\n raise(ArgumentError, \"A query must specify a 'from' clause\") unless @from\n\n warn(\"Multiple selections made without using an 'as' clause\") unless @name_transforms || (@what.count == @what.uniq.count)\n\n # Gather relevant objects from root object and filters\n @data = CQL::MapReduce.gather_objects(@data, @from, @filters)\n\n # Extract properties from gathered objects\n @data = format_output(@data)\n end", "def query; end", "def build_base_select\n id_node = base_table[primary_key]\n\n base_table.where(\n ids.apply_to(id_node)\n ).project(\n id_node,\n base_table[parent_key],\n Arel.sql('0').as(depth_column.to_s)\n )\n end", "def add_queries\n add_general_query\n add_title_query\n add_creators_query\n add_series_query\n add_collected_query\n add_tag_name_query\n end", "def build_path_query\n @path = '/' + @dn\n\n query = []\n [@extensions, @filter, @scope, @attributes].each do |x|\n next if !x && query.size == 0\n query.unshift(x)\n end\n @query = query.join('?')\n end", "def json_query\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n handler = nil\n newer = params[:newer]\n handler = params[:handler]\n offset = 0\n limit = 100\n offset = params[:offset] if params[:offset]\n limit = params[:limit] if params[:limit]\n begin\n newer = newer.to_i\n #newer = 0 if !newer || newer.to_i < 1\n rescue\n end\n #puts \"note::json_query asking for #{params[:path]}\" if @@debug\n parent = Note.find_by_path(@user,params[:path])\n return nil if !parent\n # handle different queries... ideally a more intelligent query system later xxx\n if params[:table] && params[:table] == \"visitors\"\n parent.activity_remember(@user.id) if @user\n users = parent.activity_get\n #puts \"got users len n=#{users.length} p=#{parent.id} u=#{@user.id}\"\n #write_json_array users\n else\n results = parent.find_children(offset,limit,newer,handler)\n # also tack on the parent; it could be used to store general global state\n # (note most of apps in appwiki use a special 'state' node however instead)\n results << parent;\n #puts \"note::json_query got results #{results}\" if @@debug\n write_json_array results\n end\n end", "def method_missing(name, *args, &block)\n super unless respond_to? name\n @builder = Builder.new(builder.tree) do\n __send__(name, *args, &block)\n end\n end", "def initialize\n super(\"query\")\n end", "def query_builder\n QueryBuilder.new(self)\n end", "def construct_query(ids)\n # Some descendants of ActiveFedora::Base are anonymous classes. They don't have names. Filter them out.\n candidate_classes = klass.descendants.select(&:name)\n candidate_classes += [klass] unless klass == ActiveFedora::Base\n model_pairs = candidate_classes.each_with_object([]) { |klass, arr| arr << [:has_model, klass.to_class_uri] }\n '(' + ActiveFedora::SolrQueryBuilder.construct_query_for_ids(ids) + ') AND (' +\n ActiveFedora::SolrQueryBuilder.construct_query_for_rel(model_pairs, 'OR') + ')'\n end", "def initial_query=(_arg0); end", "def parse_expr_tree(expr_tree, opts = {})\n instruction = {\n selects: {},\n joins: [],\n where: \"\"\n }\n\n # If expr_tree is blank\n if expr_tree.blank?\n instruction[:where] = TRUE_WHERE_QUERY\n return instruction\n end\n\n # If expr_tree is not blank\n tree_operator = nil\n where_stack = []\n\n expr_tree.each_with_index do |expr, idx|\n if (idx == 0) && (%w(AND OR).include? expr)\n tree_operator = expr\n else\n if expr.is_a? Array\n result = parse_expr_tree(expr, opts)\n instruction[:joins] |= result[:joins].flatten\n instruction[:selects].merge! result[:selects]\n where = \"(#{result[:where]})\"\n else\n\n # =====================================================================================\n # TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n expr_stack = expr.scan(/(?:\"(?:\\\\.|[^\"])*\"|[^\" ])+/)\n if (expr_stack.size != 3) && (!%w(= IN).include? expr_stack[1])\n raise \"Syntax error #{expr}\"\n else\n operator = expr_stack[1]\n\n #\n # Evaluate lhs\n #\n lhs_expr = expr_stack.first\n if lhs_expr.start_with?(\"object\")\n result = parse_lhs(lhs_expr, opts[:object], operator)\n lhs_join = result[:join]\n lhs_select = result[:select]\n lhs_where = result[:where]\n else\n raise \"Syntax error: #{lhs_expr} at left-hand side\"\n end\n\n #\n # Evaluate rhs\n #\n rhs_expr = expr_stack.last\n if rhs_expr.start_with?(\"subject\")\n rhs_where = parse_rhs(rhs_expr, opts[:subject], operator)\n else\n rhs_where = rhs_expr\n end\n\n #\n # Formulaize instructions\n #\n instruction[:joins] |= [lhs_join] if lhs_join.present?\n instruction[:selects].merge! lhs_select if lhs_select.present?\n if rhs_where.present?\n where = \"#{lhs_where} #{operator} #{rhs_where}\"\n else\n where = FALSE_WHERE_QUERY\n end\n end\n\n # =====================================================================================\n # END TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n end\n\n where_stack.push where\n end\n end\n\n if tree_operator\n instruction[:where] = where_stack.join(\" #{tree_operator} \")\n else\n instruction[:where] = where_stack.shift\n end\n\n return instruction\n end", "def build_tree\n t = RDTree.new\n t.add_node(0, DummyRoot)\n root = root_node_of\n t.add_edge(0, root.attributes[\"ID\"])\n do_build_tree(root, 1, t) \n t\n end", "def query(&block)\n @query = GraphQuery.new(block) \n end", "def query(&block)\n raise(ArgumentError, 'Query cannot be run. No query root has been set.') unless @query_root\n\n Query.new(@query_root, &block).data\n end", "def gen_tree\n new_tree = {}\n node_list = {}\n @json_tree.each do |k, v|\n if v['child_of'].nil?\n # top\n new_tree[k] = v\n node_list[k] = new_tree[k]\n else\n parent = v['child_of']\n if v['condition'] == 'and'\n node_list[parent]['and'] ||= {}\n node_list[parent]['and'][k] = v\n node_list[k] = node_list[parent]['and'][k]\n elsif v['condition'] == 'or'\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n else\n # TODO: sink?\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n end\n end\n end\n\n @json_tree_type = 'tree'\n @json_tree = new_tree\n end", "def build(squeel, model_class, comparator, conditions)\n build_expression_node(squeel, model_class, comparator, conditions, true)\n end", "def build_query_parts\n # Always include the following columns:\n select_clause = ['DISTINCT(Person.' + _(:id, :person) + ') as person_id'] # person id\n select_clause += ['Person.' + _(:first_name, :person) + ' as First_Name'] # first name\n select_clause += ['Person.' + _(:last_name, :person) + ' as Last_Name'] # last name\n \n # Always include the person table\n tables = ['Person']\n tables_clause = Person.table_name + ' as Person'\n # Always include the campus involvements table\n tables << 'CampusInvolvement'\n tables_clause += \" LEFT JOIN #{CampusInvolvement.table_name} as CampusInvolvement on Person.#{_(:id, :person)} = CampusInvolvement.#{_(:person_id, :campus_involvement)} AND CampusInvolvement.end_date IS NULL\"\n # Always include the ministry involvements table\n tables << 'MinistryInvolvement'\n tables_clause += \" LEFT JOIN #{MinistryInvolvement.table_name} as MinistryInvolvement on Person.#{_(:id, :person)} = MinistryInvolvement.#{_(:person_id, :ministry_involvement)} AND MinistryInvolvement.end_date IS NULL\"\n # Always include the current address\n tables << 'CurrentAddress'\n tables_clause += \" LEFT JOIN #{CurrentAddress.table_name} as CurrentAddress on Person.#{_(:id, :person)} = CurrentAddress.#{_(:person_id, :address)} AND #{_(:address_type, :address)} = 'current'\"\n # Hooks to support different schemas\n tables += build_query_parts_custom_tables if self.respond_to?(:build_query_parts_custom_tables)\n tables_clause += build_query_parts_custom_tables_clause if self.respond_to?(:build_query_parts_custom_tables_clause)\n\n columns.each do |column|\n raise inspect if column.nil? # If something goes wrong, we want good information\n # Add table to table clause\n table_name = column.from_clause.constantize.table_name if column.from_clause.present?\n unless !column.from_clause.present? || tables.include?(column.from_clause)\n tables << column.from_clause\n source_model = (column.source_model.to_s.empty? ? 'Person' : column.source_model).constantize\n source_column = column.source_column.to_s.empty? ? 'id' : column.source_column\n foreign_key = column.foreign_key.to_s.empty? ? 'person_id' : column.foreign_key\n source_table_name = source_model.table_name\n join_on_left = \"#{source_model}.#{_(source_column.to_sym, source_model.name.downcase.to_sym)}\"\n join_on_right = \"#{column.from_clause}.#{_(foreign_key.to_sym, column.from_clause.underscore.to_sym)}\"\n tables_clause += \" LEFT JOIN #{table_name} as #{column.from_clause} on #{join_on_left} = #{join_on_right}\"\n tables_clause += \" AND \" + column.join_clause unless column.join_clause.blank?\n end\n \n # Don't add id, first name or last name here because we added them earlier\n unless ['id','first_name','last_name'].include?(column.select_clause)\n # Add column to select clause\n unless column.select_clause.first == '('\n select_clause << \"#{column.from_clause}.#{_(column.select_clause, column.from_clause.underscore)} as #{column.safe_name}\"\n else\n select_clause << \"#{column.select_clause} as #{column.safe_name}\"\n end\n end\n end\n self.select_clause = select_clause.join(', ')\n self.tables_clause = tables_clause\n return tables\n end", "def query(query)\n runner = QueryRunner.new(query: query)\n\n scripts.each do |path, node|\n runner.run(node) do |node, parents|\n yield path, node, parents\n end\n end\n end", "def as_query(opts={})\n Tripod.logger.debug(\"TRIPOD: building select query for criteria...\")\n\n return_graph = opts.has_key?(:return_graph) ? opts[:return_graph] : true\n\n Tripod.logger.debug(\"TRIPOD: with return_graph: #{return_graph.inspect}\")\n\n select_query = \"SELECT DISTINCT ?uri \"\n\n if graph_lambdas.empty?\n\n if return_graph\n # if we are returning the graph, select it as a variable, and include either the <graph> or ?graph in the where clause\n if graph_uri\n select_query += \"(<#{graph_uri}> as ?graph) WHERE { GRAPH <#{graph_uri}> { \"\n else\n select_query += \"?graph WHERE { GRAPH ?graph { \"\n end\n else\n select_query += \"WHERE { \"\n # if we're not returning the graph, only restrict by the <graph> if there's one set at class level\n select_query += \"GRAPH <#{graph_uri}> { \" if graph_uri\n end\n\n select_query += self.query_where_clauses.join(\" . \")\n select_query += \" } \"\n select_query += \"} \" if return_graph || graph_uri # close the graph clause\n\n else\n # whip through the graph lambdas and add into the query\n # we have multiple graphs so the above does not apply\n select_query += \"WHERE { \"\n\n graph_lambdas.each do |lambda_item|\n select_query += \"GRAPH ?g { \"\n select_query += lambda_item.call\n select_query += \" } \"\n end\n\n select_query += self.query_where_clauses.join(\" . \")\n select_query += \" } \"\n end\n\n select_query += self.extra_clauses.join(\" \")\n\n select_query += [order_clause, limit_clause, offset_clause].join(\" \")\n\n select_query.strip\n end", "def to_sql\n @sql ||= case @kind\n when :target, :comp_op, :bin_bool_op, :term\n child(0).to_sql\n when :target_set\n # array of fragments, one per target\n [child(0).to_sql] + (child(1) ? child(2).to_sql : [])\n when :qual_term\n # child(2) will be an array (target_set)\n \"(\" + child(2).to_sql.collect{|sql| comparison(child(0), child(1).child(0), sql)}.join(\" OR \") + \")\"\n when :unqual_term\n \"(\" + default_quals.collect{|q| comparison(q, EQUAL_TOKEN, child(0).to_sql)}.join(\" OR \") + \")\"\n when :query\n # first form\n if child(0).is?(:lparen)\n @children.collect{|c| c.to_sql}.join\n # second form\n elsif child(1) && child(1).is?(:bin_bool_op)\n @children.collect{|c| c.to_sql}.join(\" \")\n # third form\n elsif child(1) && child(1).is?(:query)\n child(0).to_sql + \" AND \" + child(1).to_sql\n # fourth form\n else\n child(0).to_sql\n end\n end\n end", "def build_query(base)\n # Expose columns and get the list of the ones for select\n columns = expose_columns(base, @query.try(:arel_table))\n sub_columns = columns.dup\n type = @union_all.present? ? 'all' : ''\n\n # Build any extra columns that are dynamic and from the recursion\n extra_columns(base, columns, sub_columns)\n\n # Prepare the query depending on its type\n if @query.is_a?(String) && @sub_query.is_a?(String)\n args = @args.each_with_object({}) { |h, (k, v)| h[k] = base.connection.quote(v) }\n ::Arel.sql(\"(#{@query} UNION #{type.upcase} #{@sub_query})\" % args)\n elsif relation_query?(@query)\n @query = @query.where(@where) if @where.present?\n @bound_attributes.concat(@query.send(:bound_attributes))\n\n if relation_query?(@sub_query)\n @bound_attributes.concat(@sub_query.send(:bound_attributes))\n\n sub_query = @sub_query.select(*sub_columns).arel\n sub_query.from([@sub_query.arel_table, table])\n else\n sub_query = ::Arel.sql(@sub_query)\n end\n\n @query.select(*columns).arel.union(type, sub_query)\n else\n raise ArgumentError, <<-MSG.squish\n Only String and ActiveRecord::Base objects are accepted as query and sub query\n objects, #{@query.class.name} given for #{self.class.name}.\n MSG\n end\n end", "def create_query( relation )\n Query.new(relation)\n end", "def build_arel(*)\n arel = super\n subqueries = build_auxiliary_statements(arel)\n subqueries.nil? ? arel : arel.with(subqueries)\n end", "def startMethods()\n @orderMethods = OrderTree.new(@root) ##Metodos de recorridos\n @addMethods = AddTree.new(@root,@compare) ##Metodos de agregado\n @searchMethods = SearchTree.new(@root,@compare) ## Metodos de busqueda en arbol\n @removeMethods = RemoveTree.new(@root,@compare) ##Metodos para remover elementos\n @drawMethods = DrawTree.new(@root,@compare)\n end", "def init_simple_tree\n @root_org = Org.create(name: 'root')\n @lv1_child_org = Org.create(name: 'lv1')\n @lv1_child_org2 = Org.create(name: 'lv1-2')\n @lv2_child_org = Org.create(name: 'lv2')\n @lv2_child_org2 = Org.create(name: 'lv2-2')\n @lv2_child_org3 = Org.create(name: 'lv2-3')\n @lv2_child_org4 = Org.create(name: 'lv2-4')\n @lv3_child_org = Org.create(name: 'lv3')\n @lv3_child_org2 = Org.create(name: 'lv3-2')\n @lv4_child_org = Org.create(name: 'lv4')\n @lv4_child_org2 = Org.create(name: 'lv4-2')\n @lv5_child_org = Org.create(name: 'lv5')\n @lv5_child_org2 = Org.create(name: 'lv5-2')\n\n current_time = Time.now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @root_org.id,\n distance: 0,\n start_time: 10.minutes.ago(current_time),\n end_time: 1000.years.from_now,\n scope_name: 'default'\n )\n\n # 10 minutes ago\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 2,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n # now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org3.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org3.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org4.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org4.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv3_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org2.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\nend", "def build_associations_for_searches\n # Advanced search fields\n @master.pro_infos.build\n @master.player_infos.build\n @master.addresses.build\n @master.player_contacts.build\n @master.trackers.build\n @master.tracker_histories.build\n @master.scantrons.build if @master.respond_to? :scantrons\n\n # NOT conditions\n @master.not_trackers.build\n @master.not_tracker_histories.build\n\n # Simple search fields\n @master.general_infos.build\n end", "def build_tree(arr)\n\tend", "def rebuild!\n # Don't rebuild a valid tree.\n return true if valid?\n \n scope = lambda{ |node| {} }\n if acts_as_nested_set_options[:scope]\n scope = lambda { |node|\n scope_column_names.inject({}) { |hash, column_name|\n hash[column_name] = node.send(column_name.to_sym)\n hash\n }\n }\n end\n indices = {}\n \n set_left_and_rights = lambda do |node|\n # set left\n node.send(:\"#{left_column_name}=\", (indices[scope.call(node)] += 1))\n # find\n all(scope.call(node).merge(parent_column_name => node.id)).each { |n| set_left_and_rights.call(n) }\n # set right\n node.send(:\"#{right_column_name}=\", (indices[scope.call(node)] += 1))\n node.save! \n end\n \n # Find root node(s)\n root_nodes = all(parent_column_name => nil, :order => \"#{left_column_name}, #{right_column_name}, id\").each do |root_node|\n # setup index for this scope\n indices[scope.call(root_node)] ||= 0\n set_left_and_rights.call(root_node)\n end\n end", "def get_query_options(&block)\n ActsAsRecursiveTree::Options::QueryOptions.from(&block)\n end", "def query\n end", "def all(query); end", "def build\n\t\t\tfifo_q = Array.new\n\t\n\t\t\t# Set the failures for the nodes coming out of the root node.\n\t\t\[email protected]_pair do |item, node|\n\t\t\t\tnode.failure = @root\n\t\t\t\tfifo_q.push node\n\t\t\tend\n\n\t\t\t# Set the failures in breadth-first search order\n\t\t\t# using a FIFO queue. A failure identifies the deepest node\n\t\t\t# that is a proper suffix of the current node. \n\t\t\twhile !fifo_q.empty?\n\t\t\t\tp_node = fifo_q.shift\n\t\t\t\tif p_node.get\n\t\t\t\t\tp_node.get.each_pair do |item, node|\n\t\t\t\t\t\t# Push the current node onto the queue, so any child\n\t\t\t\t\t\t# nodes can be processed later.\n\t\t\t\t\t\tfifo_q.push node \n\t\t\t\t\t\n\t\t\t\t\t\tf_node = p_node.failure\n\t\t\t\t\t\t\n\t\t\t\t\t\t# Follow the failures until we find a goto transition\n\t\t\t\t\t\t# or arrive back at the root node\n\t\t\t\t\t\twhile f_node.goto(item) == nil and !f_node.eql? @root\n\t\t\t\t\t\t\tf_node = f_node.failure\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif f_node.eql? @root and f_node.goto(item) == nil\n\t\t\t\t\t\t\tnode.failure = @root\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnode.failure = f_node.goto(item)\n\t\t\t\t\t\t\tif block_given?\n\t\t\t\t\t\t\t\tnode.output = yield node.output, (node.failure).output\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif node.output && (node.failure).output\n\t\t\t\t\t\t\t\t\tnode.output = node.output + (node.failure).output\n\t\t\t\t\t\t\t\telsif (node.failure).output\n\t\t\t\t\t\t\t\t\tnode.output = (node.failure).output\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\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tbuild_dfa if @type == :DFA\n\n\t\tend", "def initialize(parameters, query, model, filter_settings)\n # might need this at some point: Rack::Utils.parse_nested_query\n @key_prefix = 'filter_'\n key_partial_match = :filter_partial_match\n\n @default_page = 1\n @default_items = 25\n @max_items = 500\n @table = relation_table(model)\n\n # `.all' adds 'id' to the select!!\n @initial_query = !query.nil? && query.is_a?(ActiveRecord::Relation) ? query : relation_all(model)\n # the check for an active record relation above can lead to some subtle\n # bugs when you pass some non-nil query like thing.\n # temporarily throwing here to see what breaks. All tests pass so\n # we'll make the check below a validation that always runs\n unless query.is_a?(ActiveRecord::Relation)\n raise ArgumentError, \"query was not an ActiveRecord::Relation. Query: #{query}\"\n end\n\n validate_filter_settings(filter_settings)\n @valid_fields = filter_settings[:valid_fields].map(&:to_sym)\n @text_fields = filter_settings.include?(:text_fields) ? filter_settings[:text_fields].map(&:to_sym) : []\n @render_fields = filter_settings[:render_fields].map(&:to_sym)\n @filter_settings = filter_settings\n @default_sort_order = filter_settings[:defaults][:order_by]\n @default_sort_direction = filter_settings[:defaults][:direction]\n @custom_fields2 = filter_settings[:custom_fields2] || {}\n @capabilities = filter_settings[:capabilities] || {}\n\n @build = Build.new(@table, filter_settings)\n\n @parameters = CleanParams.perform(parameters)\n validate_hash(@parameters)\n\n @parameters = decode_payload(@parameters)\n\n @filter = @parameters.include?(:filter) && !@parameters[:filter].blank? ? @parameters[:filter] : {}\n @projection = parse_projection(@parameters)\n\n # remove key_partial_match key from parameters hash\n parameters_for_generic = @parameters.dup\n parameters_for_generic.delete(key_partial_match) if parameters_for_generic.include?(key_partial_match)\n\n # merge filters from qsp partial text match into POST body filter\n partial_match_filters = parse_qsp_partial_match_text(@parameters, key_partial_match, @text_fields)\n @filter = add_qsp_to_filter(@filter, partial_match_filters, :or)\n\n # merge filters from qsp generic equality match into POST body filter\n qsp_generic_filters = parse_qsp(nil, parameters_for_generic, key_prefix)\n @filter = add_qsp_to_filter(@filter, qsp_generic_filters, :and)\n\n # populate properties with qsp filter spec\n @qsp_text_filter = @parameters[key_partial_match]\n @qsp_generic_filters = {}\n qsp_generic_filters.each do |key, value|\n @qsp_generic_filters[key] = value[:eq]\n end\n\n @paging = parse_paging(@parameters, @default_page, @default_items, @max_items)\n @sorting = parse_sorting(@parameters, @default_sort_order, @default_sort_direction)\n end", "def _build(scope, opts, locale, invert)\n return yield if (mods = translation_modules(scope)).empty?\n\n keys, predicates = opts.keys.map(&:to_s), []\n\n used_keys = []\n\n query_map = mods.inject(IDENTITY) do |qm, mod|\n i18n_keys = mod.names & keys - used_keys\n next qm if i18n_keys.empty?\n\n used_keys += i18n_keys\n mod_predicates = i18n_keys.map do |key|\n build_predicate(scope.backend_node(key.to_sym, locale), opts.delete(key))\n end\n invert_predicates!(mod_predicates) if invert\n predicates += mod_predicates\n\n ->(r) { mod.backend_class.apply_scope(qm[r], mod_predicates, locale, invert: invert) }\n end\n\n return yield if query_map == IDENTITY\n\n relation = opts.empty? ? scope : yield(opts)\n query_map[relation.where(predicates.inject(:and))]\n end", "def run_query()\n return nil unless @query\n \n gres = @query.execute()\n if @filterClass \n fres = @filterClass.filter(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n elsif @filterBlock \n fres = @filterBlock.call(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n else\n res = fres.result_s\n end\n res\n end", "def retrieve_query\r\n if !params[:query_id].blank?\r\n cond = \"project_id IS NULL\"\r\n cond << \" OR project_id = #{@project.id}\" if @project\r\n @query = Query.find(params[:query_id], :conditions => cond)\r\n @query.project = @project\r\n session[:query] = {:id => @query.id, :project_id => @query.project_id}\r\n else\r\n if params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)\r\n # Give it a name, required to be valid\r\n @query = Query.new(:name => \"_\")\r\n @query.project = @project\r\n if params[:fields] and params[:fields].is_a? Array\r\n params[:fields].each do |field|\r\n @query.add_filter(field, params[:operators][field], params[:values][field])\r\n end\r\n else\r\n @query.available_filters.keys.each do |field|\r\n @query.add_short_filter(field, params[field]) if params[field]\r\n end\r\n end\r\n session[:query] = {:project_id => @query.project_id, :filters => @query.filters}\r\n else\r\n @query = Query.find_by_id(session[:query][:id]) if session[:query][:id]\r\n @query ||= Query.new(:name => \"_\", :project => @project, :filters => session[:query][:filters])\r\n @query.project = @project\r\n end\r\n end\r\n end", "def perform_query(query, operand)\n# STDERR.puts \"perform_query(q '#{query}', op '#{operand}')\"\n records = []\n\t\t \n if operand.is_a?(DataMapper::Query::Conditions::NotOperation)\n#\tSTDERR.puts \"operand is a NOT operation\"\n\tsubject = operand.first.subject\n\tvalue = operand.first.value\n elsif operand.subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)\n#\tSTDERR.puts \"operand subject is a many-to-one relation: '#{operand.subject.inspect}'\"\n\tif operand.subject.parent_model == NamedQuery && operand.subject.child_model == Bug\n\t name = operand.value[operand.subject.parent_key.first.name]\n\t bugs = named_query(name)\n\t bugs.each do |bug|\n\t records << bug_to_record(query.model, bug)\n\t end\n\t return records\n\telse\n\t raise \"Unknown parent (#{operand.subject.parent_model}) child (#{operand.subject.child_model}) relation\"\n\tend\n else\n#\tSTDERR.puts \"operand is normal\"\n\tsubject = operand.subject\n\tvalue = operand.value\n end\n \n if subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)\n#\tSTDERR.puts \"subject is a many-to-one relation\"\n\tsubject = subject.child_key.first\n end\n \n # typical queries\n #\n \n# STDERR.puts \"perform_query(subject '#{subject.inspect}', value '#{value.inspect}')\"\n case query.model.name\n when \"Bug\"\n\tif query.model.key.include?(subject)\n\t # get single <bug>\n\t bugs = get_bugs(value)\n\t records << bug_to_record(query.model, bugs.first)\n\telse\n\t raise \"Unknown query for bug\"\n\tend\n when \"NamedQuery\"\n\trecords << { subject.name.to_s => value }\n\t# be lazy: do the actual named query when NamedQuery#bugs gets accessed\n else\n\traise \"Unsupported model '#{query.model.name}'\"\n end\n \n records\n end", "def query(tql)\n rid = tql[:rid]\n where = nil\n filter = nil\n if tql.has_key?(:where)\n w = tql[:where]\n where = w.is_a?(Array) ? ExprParser.parse(w) : w\n end\n filter = ExprParser.parse(tql[:filter]) if tql.has_key?(:filter)\n\n if tql.has_key?(:insert)\n insert(tql[:insert], rid, where, filter)\n elsif tql.has_key?(:update)\n update(tql[:update], rid, where, filter)\n elsif tql.has_key?(:delete)\n delete(tql[:delete], rid, where, filter)\n else\n select(tql[:select], rid, where, filter)\n end\n end", "def retrieve_query\n if params[:set_filter] or !session[:query] or session[:query].project_id\n # Give it a name, required to be valid\n @query = Query.new(:name => \"_\", :executed_by => logged_in_user)\n if params[:fields] and params[:fields].is_a? Array\n params[:fields].each do |field|\n @query.add_filter(field, params[:operators][field], params[:values][field])\n end\n else\n @query.available_filters.keys.each do |field|\n @query.add_short_filter(field, params[field]) if params[field]\n end\n end\n session[:query] = @query\n else\n @query = session[:query]\n end\n end", "def initialize(query)\n @query = query \n end", "def build_db_tree( parent_id, zone ) \n sub_root = nil\n connect_for( zone ) do |con|\n root = Node.make_node( \"home\" )\n sub_root = Node.new( parent_id, zone )\n \n root << sub_root\n \n count = 0\n data = { :dyna => true }\n database_names( con ).each do |db_name|\n db = con.db( db_name, :strict => true )\n cltns = collection_names( db ).size \n node = Node.new( \"#{zone}_#{count}\", \"#{db_name}(#{cltns})\", data.clone )\n sub_root << node\n count += 1\n end\n end\n sub_root\n end", "def query\n @operation = :query\n self\n end", "def query_full\n query = @initial_query.dup\n\n # restrict to select columns\n query = query_projection(query)\n\n #filter\n query = query_filter(query)\n\n # sorting\n query = query_sort(query)\n\n # paging\n query_paging(query)\n end", "def build_sub_tree( parent_id, path_names )\n path_name_tokens = path_names.split( \"|\" )\n zone = path_name_tokens[1] \n \n if db_request?( path_name_tokens ) \n sub_tree = build_db_tree( parent_id, zone )\n else\n db_name = path_name_tokens.last \n sub_tree = build_cltn_tree( parent_id, zone, db_name )\n end\n sub_tree\n end", "def cs_starter\n # make_batched_queries\n make_standard_queries\n end", "def build_query(builder)\n builder.OPTION {\n @option.each do |k, v|\n builder.PARAMETER k.to_s.upcase\n value = case v\n when Array then v.join(',')\n when Hash then v.map { |a| a.join(':') }.join(',')\n else\n v.to_s\n end\n\n # I don't know this is correct or not, but I think we should not\n # touch third party ID.\n value.upcase! unless k == :prefer_xid\n\n builder.VALUE value\n end\n }\n end", "def build\n reset\n visit(root, @root)\n end", "def query_root=(value)\n @query_root = value\n end", "def rebuild!\n\n scope = lambda{}\n # TODO: add scope stuff\n \n # Don't rebuild a valid tree.\n return true if valid?\n indices = {}\n \n move_to_child_of_lambda = lambda do |parent_node|\n # Set left\n parent_node[nested_set_options[:left_column]] = indices[scope.call(parent_node)] += 1\n # Gather child noodes of parend_node and iterate by children\n parent_node.children.order(:id).all.each do |child_node|\n move_to_child_of_lambda.call(child_node)\n end\n # Set right\n parent_node[nested_set_options[:right_column]] = indices[scope.call(parent_node)] += 1\n parent_node.save\n end\n\n # Gatcher root nodes and iterate by them\n self.roots.all.each do |root_node|\n # setup index for this scope\n indices[scope.call(root_node)] ||= 0\n move_to_child_of_lambda.call(root_node)\n end\n end", "def build_server_tree(parent)\n @server_tree = if @sb[:diag_tree_type] == \"roles\"\n TreeBuilderRolesByServer.new(:roles_by_server_tree, @sb, true, :root => parent)\n else\n TreeBuilderServersByRole.new(:servers_by_role_tree, @sb, true, :root => parent)\n end\n if @sb[:diag_selected_id]\n @record = @sb[:diag_selected_model].constantize.find(@sb[:diag_selected_id]) # Set the current record\n @rec_status = @record.assigned_server_roles.find_by(:active => true) ? \"active\" : \"stopped\" if @record.class == ServerRole\n end\n end", "def discover\n choria.pql_query(@query, true)\n end", "def to_gql\n result = ' ' * __depth + __name\n result += __params_to_s(__params, true) unless __params.empty?\n unless __nodes.empty?\n result += \" {\\n\"\n result += __nodes.map(&:to_gql).join(\"\\n\")\n result += \"\\n#{' ' * __depth}}\"\n end\n\n result\n end", "def query\n case query_type_str\n when 'empty'\n return\n when 'iso'\n return iso_query_builder\n when 'multi'\n return multi_query_builder\n end\n end", "def query_root\n return @query_root\n end", "def construct_sql\n if @reflection.options[:finder_sql]\n @finder_sql = interpolate_sql(@reflection.options[:finder_sql])\n else\n @finder_sql = conditions\n end\n \n if @reflection.options[:counter_sql]\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n elsif @reflection.options[:finder_sql]\n # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */\n @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\\/\\*.*?\\*\\/ )?(.*)\\bFROM\\b/im) { \"SELECT #{$1}COUNT(*) FROM\" }\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n else\n @counter_sql = @finder_sql\n end\n end", "def retrieve_query\r\n if params[:query_id]\r\n @query = @project.queries.find(params[:query_id])\r\n @query.executed_by = logged_in_user\r\n session[:query] = @query\r\n else\r\n if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id\r\n # Give it a name, required to be valid\r\n @query = Query.new(:name => \"_\", :executed_by => logged_in_user)\r\n @query.project = @project\r\n if params[:fields] and params[:fields].is_a? Array\r\n params[:fields].each do |field|\r\n @query.add_filter(field, params[:operators][field], params[:values][field])\r\n end\r\n else\r\n @query.available_filters.keys.each do |field|\r\n @query.add_short_filter(field, params[field]) if params[field]\r\n end\r\n end\r\n session[:query] = @query\r\n else\r\n @query = session[:query]\r\n end\r\n end\r\n end", "def query(query_definition)\n return\n end", "def build_json_query(node_type, phenotype)\r\n phenotype_params = {}\r\n phenotype.each{|component, id| phenotype_params[component] = {:id => id} }\r\n query = {:phenotype => [phenotype_params]}\r\n query[node_type] = [{:id => params[:node_id]}]\r\n query[:include_inferred] = (params[:include_inferred] == 'true')\r\n query[:publication] = []\r\n params[:publications].each{|index, id| query[:publication] << {:id => id} } if params[:publications]\r\n return URI.encode(JSON.generate(query))\r\n end", "def getAllChildren\n children = Tree.where(\"tree_type_id = ? AND version_id = ? AND subject_id = ? AND grade_band_id = ? AND code like ?\", tree_type_id, version_id, subject_id, grade_band_id, code+'.%')\n Rails.logger.debug(\"*** tree children: #{children.inspect}\")\n return children\n end", "def query\n super\n end", "def db_queries_operate__samples_recursive\n non_rec = db_queries_operate__samples_non_recursive\n sample_1 = [ non_rec, \"AND\", :recursive ]\n sample_2 = [ [\"E\", sample_1], \"OR\", :recursive ]\n r = [\n sample_1,\n sample_2,\n ]\n\n end", "def AddQuery(query, index = '*', comment = '')\n # build request\n \n # mode and limits\n request = Request.new\n request.put_int @offset, @limit, @mode, @ranker\n # process the 'expr' ranker\n if @ranker == SPH_RANK_EXPR\n request.put_string @rankexpr\n end\n\n request.put_int @sort\n\n request.put_string @sortby\n # query itself\n request.put_string query\n # weights\n request.put_int_array @weights\n # indexes\n request.put_string index\n # id64 range marker\n request.put_int 1\n # id64 range\n request.put_int64 @min_id.to_i, @max_id.to_i \n \n # filters\n request.put_int @filters.length\n @filters.each do |filter|\n request.put_string filter['attr']\n request.put_int filter['type']\n\n case filter['type']\n when SPH_FILTER_VALUES\n request.put_int64_array filter['values']\n when SPH_FILTER_RANGE\n request.put_int64 filter['min'], filter['max']\n when SPH_FILTER_FLOATRANGE\n request.put_float filter['min'], filter['max']\n else\n raise SphinxInternalError, 'Internal error: unhandled filter type'\n end\n request.put_int filter['exclude'] ? 1 : 0\n end\n \n # group-by clause, max-matches count, group-sort clause, cutoff count\n request.put_int @groupfunc\n request.put_string @groupby\n request.put_int @maxmatches\n request.put_string @groupsort\n request.put_int @cutoff, @retrycount, @retrydelay\n request.put_string @groupdistinct\n \n # anchor point\n if @anchor.empty?\n request.put_int 0\n else\n request.put_int 1\n request.put_string @anchor['attrlat'], @anchor['attrlong']\n request.put_float @anchor['lat'], @anchor['long']\n end\n \n # per-index weights\n request.put_int @indexweights.length\n @indexweights.each do |idx, weight|\n request.put_string idx\n request.put_int weight\n end\n \n # max query time\n request.put_int @maxquerytime\n \n # per-field weights\n request.put_int @fieldweights.length\n @fieldweights.each do |field, weight|\n request.put_string field\n request.put_int weight\n end\n \n # comment\n request.put_string comment\n \n # attribute overrides\n request.put_int @overrides.length\n for entry in @overrides do\n request.put_string entry['attr']\n request.put_int entry['type'], entry['values'].size\n entry['values'].each do |id, val|\n assert { id.instance_of?(Fixnum) || id.instance_of?(Bignum) }\n assert { val.instance_of?(Fixnum) || val.instance_of?(Bignum) || val.instance_of?(Float) }\n \n request.put_int64 id\n case entry['type']\n when SPH_ATTR_FLOAT\n request.put_float val\n when SPH_ATTR_BIGINT\n request.put_int64 val\n else\n request.put_int val\n end\n end\n end\n \n # select-list\n request.put_string @select\n \n # store request to requests array\n @reqs << request.to_s;\n return @reqs.length - 1\n end", "def expand_queries(queries, threshold, ssr, pgr)\n\t\text_queries = []\n\t\tqueries.each do |q, offsets|\n\t\t\text_queries += expand_query(q, offsets, threshold, ssr, pgr)\n\t\tend\n\t\n\t\t# @return [ {:requested_query => string, :original_query => string, \n\t\t# :range => (begin...end), :sim => float}, ... ]\n\t\text_queries\n\tend", "def index\n @query = params[:q] || '*:*'\n query = Jbuilder.encode do |json|\n json.filter do\n json.missing do\n json.field \"parent_id\"\n end\n end\n json.query do\n json.query_string do\n json.query @query\n end\n end\n json.sort do\n json.node \"asc\"\n end\n end\n @themata = Thema.__elasticsearch__.search(query).page(params[:page]).records\n end", "def query\n return if @item[:query].present? # when :query excplicitly defined then no need to resolve matchers\n @item[:query] = cleanup(Query::Builder.for(item: @item))\n end", "def build_query(payload)\n if payload[:file]\n payload\n else\n Rack::Utils.build_nested_query(payload)\n end\n end", "def build_move_tree\n self.root_node = PolyTreeNode.new(start_pos) #instance variable\n \n queue = [root_node]\n until queue.empty?\n #pop,queue\n cur_node = queue.shift\n move_list = new_move_positions(cur_node.value)\n move_list.each do |pos|\n child_node = PolyTreeNode.new(pos)\n cur_node.add_child(child_node)\n queue << child_node\n end\n end\n end", "def node_query_mapping_insert\n # binding.pry\n branches.each do |br|\n br.nodes.each do |nd|\n nodeName = nd.name\n\n # columnsArray=nd.columns.map{|c| \"'\"+(c.relalias.nil? ? '' : c.relalias+'.')+c.colname+\"'\"}.join(',')\n columnsArray = nd.columns.map { |c| \"'\" + c.relname + '.' + c.colname + \"'\" }.join(',')\n query = \"INSERT INTO #{@nqTblName} values (#{@test_id} ,'#{br.name}','#{nd.name}', '#{nd.query.gsub(/'/, '\\'\\'')}',#{nd.location}, ARRAY[#{columnsArray}], #{nd.suspicious_score} , '#{@type}' )\"\n # pp query\n DBConn.exec(query)\n end\n end\n end", "def build_fields_with_ns(query, ns)\n build_select_fields(@fields.keys - get_excludes(query),ns)\n end", "def prepare_search query\n receive!(filter: event_filter(query))\n self\n end", "def query_base\n @query_base ||= lambda do\n el = '?'\n [Func::UNACCENT].each do |func|\n el = \"#{func}(#{el})\"\n end\n el\n end.call\n end", "def subtree_conditions\n column = \"#{self.base_class.table_name}.#{self.base_class.structure_column}\"\n lookup = if has_parent? then\n \"%/#{id}\"\n else\n \"#{id}\"\n end\n [\"#{column} like ?\n or #{column} like ?\n or #{column} like ?\n or #{column} like ?\n or #{column} = ?\n or #{self.base_class.table_name}.#{self.base_class.primary_key} = ?\", \"#{lookup}\", \"#{lookup}/%\", \"#{lookup},%\", \",#{id}\", \"#{id}\", \"#{id}\"]\n end", "def query(_tql)\n raise NotImplementedError.new\n end", "def construct_filter_query(queries)\n query_string = '?'\n query_list = Array[]\n\n # Format the include_* queries similarly to other queries for easier\n # processing\n if queries.key?('include_deleted')\n queries['include_deleted'] = if queries['include_deleted']\n ['true']\n else\n ['false']\n end\n end\n\n if queries.key?('include_revisions')\n queries['include_revisions'] = if queries['include_revisions']\n ['true']\n else\n ['false']\n end\n end\n\n # If uuid is included, the only other accepted queries are the\n # include_*s\n if queries.key?('uuid')\n query_string = format('/%s?', queries['uuid'])\n if queries.key?('include_deleted')\n query_string += format('include_deleted=%s&',\n queries['include_deleted'][0])\n end\n\n if queries.key?('include_revisions')\n query_string += format('include_revisions=%s&',\n queries['include_revisions'][0])\n end\n\n # Everthing is a list now, so iterate through and push\n else\n # Sort them into an alphabetized list for easier testing\n # sorted_qs = sorted(queries.to_a, key = operator.itemgetter(0))\n sorted_qs = queries.to_a.sort\n sorted_qs.each do |query, param|\n param.each do |slug|\n # Format each query in the list\n # query_list.push('%s=%s' % Array[query, slug])\n query_list.push(format('%s=%s', query, slug))\n end\n end\n\n # Construct the query_string using the list.\n # Last character will be an & so we can push the token\n query_list.each do |string|\n query_string += format('%s&', string)\n end\n end\n query_string\n end", "def immediate_subqueries\n my_nodes_tagged(:subquery)\n end", "def immediate_subqueries\n my_nodes_tagged(:subquery)\n end", "def build(params); end", "def build_query\n case query = build_query_values.inject{|q,v| query_coder.decode(q).deep_merge(query_coder.decode(v)) }\n when Hash\n query_coder.encode(query)\n when String, NilClass\n query\n else\n raise InvalidRepresentationError, 'expected Hash, String, or NilClass but got: '+query.class.name\n end\n end", "def generate_xpath_queries!\n self.xpath = OM::XML::TermXpathGenerator.generate_absolute_xpath(self)\n self.xpath_constrained = OM::XML::TermXpathGenerator.generate_constrained_xpath(self)\n self.xpath_relative = OM::XML::TermXpathGenerator.generate_relative_xpath(self)\n self.children.each_value {|child| child.generate_xpath_queries! }\n return self\n end", "def build_query(params)\n query = UserInteraction.includes(:user, :interaction, :answer)\n fields = get_fields()\n params.each do |filter|\n field_id = filter['field'].to_sym\n operator = filter['operand']\n operand = filter['value']\n if operator == FILTER_OPERATOR_CONTAINS\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), \"%\"+operand.to_s+\"%\" )\n else\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), operand )\n end\n end\n return query \n end", "def to_query\n return nil if config.nil? # not a whitelisted attr\n klass = JsonApiServer.filter_builder(builder_key) || raise(\"Query builder '#{builder_key}' doesn't exist.\")\n builder = klass.new(attr, casted_value, operator, config)\n builder.to_query(@model)\n end", "def get_query_options(proc)\n opts = ActsAsRecursiveTree::Options::QueryOptions.new\n\n proc.call(opts) if proc\n\n opts\n end", "def subtree_conditions\n column = \"#{self.base_class.table_name}.#{self.base_class.ancestry_column}\"\n lookup = if has_parent? then\n \"%/#{id}\"\n else\n \"#{id}\"\n end\n [\"#{column} like ?\n or #{column} like ?\n or #{column} like ?\n or #{column} like ?\n or #{column} = ?\n or #{self.base_class.table_name}.#{self.base_class.primary_key} = ?\", \"#{lookup}\", \"#{lookup}/%\", \"#{lookup},%\", \",#{id}\", \"#{id}\", \"#{id}\"]\n end", "def subtree\n model_base_class.where(subtree_conditions)\n end", "def initialize_from_builder(&block)\n builder = Class.new(Builder)\n builder.setup\n \n builder.instance_eval &block\n \n unless @model.descends_from_active_record?\n stored_class = @model.store_full_sti_class ? @model.name : @model.name.demodulize\n builder.where(\"#{@model.quoted_table_name}.#{quote_column(@model.inheritance_column)} = '#{stored_class}'\")\n end\n\n @fields = builder.fields\n @attributes = builder.attributes\n @conditions = builder.conditions\n @groupings = builder.groupings\n @delta_object = ThinkingSphinx::Deltas.parse self, builder.properties\n @options = builder.properties\n \n # We want to make sure that if the database doesn't exist, then Thinking\n # Sphinx doesn't mind when running non-TS tasks (like db:create, db:drop\n # and db:migrate). It's a bit hacky, but I can't think of a better way.\n rescue StandardError => err\n case err.class.name\n when \"Mysql::Error\", \"ActiveRecord::StatementInvalid\"\n return\n else\n raise err\n end\n end", "def generate_xpath_queries!\n self.xpath = OM::XML::TermXpathGenerator.generate_absolute_xpath(self)\n self.xpath_constrained = OM::XML::TermXpathGenerator.generate_constrained_xpath(self)\n self.xpath_relative = OM::XML::TermXpathGenerator.generate_relative_xpath(self)\n self.children.each_value {|child| child.generate_xpath_queries! }\n return self\n end" ]
[ "0.61193997", "0.6111638", "0.6072295", "0.59630275", "0.59165335", "0.58392924", "0.5824635", "0.58225507", "0.57200986", "0.57007927", "0.56901294", "0.5676976", "0.56269515", "0.55952084", "0.5530375", "0.55196667", "0.54879797", "0.54466045", "0.53911716", "0.5385983", "0.5377659", "0.53732646", "0.5369518", "0.5367912", "0.53486764", "0.53404135", "0.533904", "0.5329101", "0.52760845", "0.5275923", "0.52686393", "0.5263607", "0.52533877", "0.52520907", "0.52345765", "0.5233896", "0.52262104", "0.5224184", "0.52065414", "0.5202347", "0.52003175", "0.5198104", "0.517479", "0.5166543", "0.51600105", "0.51540387", "0.51411545", "0.5132976", "0.5131198", "0.5128659", "0.5128402", "0.51244944", "0.51243347", "0.5112609", "0.51125944", "0.5104763", "0.5101881", "0.5087482", "0.5075317", "0.50671923", "0.50646824", "0.50638443", "0.5055913", "0.5053147", "0.503897", "0.503754", "0.5027412", "0.4997025", "0.49926892", "0.49903834", "0.49885485", "0.49837974", "0.49788532", "0.49599507", "0.49585", "0.4953901", "0.49533546", "0.49504048", "0.49501377", "0.49420553", "0.49355814", "0.4931047", "0.49293295", "0.49287668", "0.49201223", "0.4917758", "0.49144986", "0.49127206", "0.4905304", "0.49041474", "0.49041474", "0.49038798", "0.49010682", "0.48907688", "0.48870674", "0.48865277", "0.4876184", "0.48753092", "0.48719037", "0.4869148", "0.48672402" ]
0.0
-1
Perform HTTP GET request
def get(path, params={}) RestClient.get request_base+path, {params: params} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end", "def do_get\n Net::HTTP.get(URI.parse(api_url))\n end", "def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend", "def http( *args )\n p http_get( *args )\n end", "def get\n start { |connection| connection.request http :Get }\n end", "def get(url, headers = {})\n do_request Net::HTTP::Get, url, headers\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n check_response( @httpcli.get(@endpoint) )\n end", "def get\n @response = Net::HTTP.get_response(URI(@url))\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get(url, headers={})\n do_request(\"get\", url, nil, headers)\n end", "def get()\n return @http.request(@req)\n end", "def get(url='/', vars={})\n send_request url, vars, 'GET'\n end", "def _get\n http_method(:get)\n end", "def perform_get(path, options = {})\n perform_request(:get, path, options)\n end", "def send_get(uri)\n _send_request('GET', uri, nil)\n end", "def get(request)\n do_request(request) { |client| client.http_get }\n end", "def get(path)\n req = Net::HTTP::Get.new(@base_url + path)\n response = handle_request(req)\n response.each {|k,v| puts \"#{k}: #{v}\"}\n response\n end", "def get(uri)\r\n request(Net::HTTP::Get.new(uri)) \r\n end", "def get(url, args = {})\r\n make_request(:get, url, args)\r\n end", "def get endpoint\n do_request :get, endpoint\n end", "def get_request\n# Use our @http_object object's request method to call the\n# Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end", "def get(url); end", "def get(path, params, connection = CONNECTION)\n request = Net::HTTP::Get.new(to_url(path, params))\n process_request(request, connection)\nend", "def get_request\n # Use our @http_object object's request method to call the\n # Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end", "def make_get_request url, headers = []\n make_request url, headers: headers\n end", "def get path, header={}, body_string_or_hash=\"\"\n env.http 'GET', path, header, body_string_or_hash\n end", "def get\n execute_request { faraday_connection.get(href || '') }\n end", "def get(path)\n request 'GET', path\n end", "def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end", "def get(options = {}, all = true)\n uri = URI.parse(request_path(options, all))\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n puts \"Request URL (GET) is #{uri.request_uri}\" \n\n response = http.request(Net::HTTP::Get.new(uri.request_uri))\n response.body\n end", "def get(url, headers = {})\n request(:get, url, headers)\n end", "def get(url, headers = {})\n request(:get, url, headers)\n end", "def get(url)\n request(:get, url, {}, nil)\n end", "def get(path, options={})\n send_request 'get', path, options\n end", "def get\n\t\t\tself.make_request!({uri: self.to_uri, method: :get})\n\t\tend", "def get(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Add parameters to URL query string\n get_params = {\n :method => \"get\", \n :verbose => DEBUG\n }\n get_params[:params] = data unless data.empty?\n # Create GET request\n get = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", get_params)\n # Send request\n do_request(get, format, :cache => true)\n end", "def get(path, options = {})\n request = Net::HTTP::Get.new(request_uri(path))\n make_request(request, options.merge(no_callbacks: true))\n end", "def get(uri, params = {})\n send_request(uri, :get, params)\n end", "def get(uri, request_headers)\n request('get', uri, request_headers)\n end", "def http_get(path, query, format = :json)\n uri = URI.parse(\"http://#{Jamendo::API_SERVER}/v#{Jamendo::API_VERSION}/#{path}#{query}\")\n puts uri.request_uri\n http = Net::HTTP.new(uri.host, uri.port) \n request = Net::HTTP::Get.new(uri.request_uri)\n begin\n response = http.request(request)\n result = parse_response(response)\n assert_response(result[:headers])\n return result[:results]\n rescue JamendoError => e\n e.inspect\n end\n end", "def get(url)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n\n response = http.get(\"#{uri.path}?auto\")\n\n unless response.code == \"200\"\n puts \"Failed to retrieve #{url}: #{response.code}\"\n exit 3\n end\n\n response.body\nend", "def get(resource, **params)\n\n execute(Net::HTTP::Get, 'GET', resource, **params)\n\n end", "def _http_get resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Get.new(path)\n _build_request resource, request\nend", "def _http_get resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Get.new(path)\n _build_request resource, request\nend", "def get path = \"\", payload = {}\n make_request(path, \"get\", payload)\n end", "def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end", "def get query = nil\n\t\tif (query = make_query query)\n\t\t\[email protected] = @uri.query ? @uri.query+\"&\"+query : query\n\t\tend\n\t\tfull_path = @uri.path + (@uri.query ? \"?#{@uri.query}\" : \"\")\n\t\t\t\n\t\treq = Net::HTTP::Get.new(full_path)\n\t\t# puts Net::HTTP::Proxy(@proxy_host, @proxy_port, @proxy_user, @proxy_pwd).get(@uri)\n\t\tdo_http req\n\tend", "def request_get(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"GET\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Get.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend", "def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end", "def get url\n RestClient::Request.execute(:method => :get, :url => url, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def http_get(path, headers = { })\n clear_response\n path = process_path(path)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end", "def get(path, data=nil)\n request(:get, path, data)\n end", "def get(url, headers: {}, params: {}, options: {}, &block)\n url = encode_query(url, params)\n\n request = Net::HTTP::Get.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options, &block)\n end", "def get!\n self.https.request self.http_request # Net::HTTPResponse object\n end", "def get_request(path, params={}, options={})\n request(:get, path, params, options)\n end", "def http_get(url, headers = nil)\r\n if @debug\r\n puts \"Url:\"\r\n puts url\r\n puts \"Headers:\"\r\n puts headers\r\n puts \"Method: get\"\r\n end\r\n return headers ? HTTParty.get(url, :headers => headers) : HTTParty.get(url)\r\n end", "def http_get(url)\n require \"open-uri\"\n URI.parse(url).read\n end", "def get(url, headers={})\n RestClient.get url, headers\n end", "def get(params)\n request.method = :get\n execute(params)\n end", "def get(params = {})\n http_helper.send_get_request(\"#{@url_prefix}\", params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def do_request()\n uri = URI.parse(API_BASE_URL + build_request_path())\n response = Net::HTTP.get_response(uri)\n response.body\n end", "def get(options={}, &block)\n response = http.get_uri(options, &block)\n handle_response(response)\n end", "def get(path)\n request(:get, path, {})\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, options={}, &block)\n uri = URI.join(@endpoint, path)\n headers = options.delete(:headers)\n query = options.delete(:query)\n\n if query\n uri.query = URI.encode_www_form(query)\n end\n\n request = Net::HTTP::Get.new uri.request_uri, headers\n @http.request request, &block\n end", "def get(path, params = {})\n\t\trequest(path, :get, params)\n\tend", "def get(http: HTTParty)\n http.get(url)\n end", "def get(path, arguments = {})\n perform_request { connection.get(path, arguments).body }\n end", "def get(path = nil)\n url = URI.parse(@url.scheme + '://' + @url.host + ':' + @url.port.to_s + path.to_s)\n headers = { \"Authorization\" => \"Basic \" + [@user + \":\" + @password].pack(\"m\") } if @user\n \n server = Net::HTTP.new(@url.host, @url.port)\n server.read_timeout = @timeout\n server.use_ssl = url.scheme == 'https'\n server.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n res, data = server.get(url.request_uri, headers)\n \n case res\n when Net::HTTPSuccess\n # OK\n else\n raise res.inspect\n end\n [res, data]\n end", "def get(url)\n uri = URI(url)\n Net::HTTP.get(uri)\nend", "def get(path, data={})\n request(:get, path, data)\n end", "def get(path, query = { }, headers = { })\n clear_response\n path = process_path(path, query)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end", "def http_get(endpoint)\n uri= URI.parse \"#{@main_url}#{endpoint}\"\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n request.basic_auth(@username, @api_key)\n response = http.request(request)\n response.body\nend", "def make_request(url,headers,query)\n c = HTTPClient.new\n c.get_content(url,query,headers)\nend", "def get(path, params = {}, request_options = {})\n request(:get, path, params)\n end", "def do_the_get_call(args)\n\tputs \"----- GET: #{args[:url]} -----\"\n\tc = Curl::Easy.new(args[:url]) do |curl|\n\t\tcurl.http_auth_types = :basic\n\t\tcurl.username = args[:user]\n\tend\n\tc.perform\n\tc.body_str\nend", "def http_get(domain,path,params)\n return Net::HTTP.get(domain, \"#{path}?\".concat(params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\" }.join('&'))) if not params.nil?\n return Net::HTTP.get(domain, path)\n end", "def get(url)\n call(url: url)\n end", "def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def get(url, headers = {})\n http :get, \"#{url}.json\", headers\n end", "def do_get(uri = \"\", query = {})\n url_query = query.size > 0 ? \"?\" + query.map {|k, v| \"#{k}=#{v}\"}.join(\"&\") : \"\"\n @connection.get(uri + url_query)\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase connection\", \"Error trying to send a GET to #{uri + url_query}\"\n Faraday::Response.new\n end", "def get\n url = prefix + \"get\" + id_param\n return response(url)\n end", "def get(path, params = {})\n request(:get, path, params)\n end", "def get(path, params = {})\n request(:get, path, params)\n end", "def http_method\n :get\n end", "def do_GET(request, _response)\n log_request(request)\n end", "def get(url, options)\n headers = options[:headers] || {}\n params = options[:params] || {}\n url = url_with_params(url, params)\n req = Net::HTTP::Get.new(url)\n request_with_headers(req, headers)\n end", "def http_get(path)\n http_methods(path, :get)\n end" ]
[ "0.8169531", "0.81619596", "0.81461626", "0.81273323", "0.80387366", "0.7898414", "0.78717077", "0.78717077", "0.7795393", "0.7720315", "0.77144223", "0.77144223", "0.76941705", "0.7624536", "0.7618683", "0.758023", "0.7574224", "0.7571272", "0.7539143", "0.753509", "0.7527728", "0.7516718", "0.7513552", "0.7500558", "0.74928856", "0.74876386", "0.7468075", "0.744987", "0.7446728", "0.7416588", "0.7413749", "0.7409935", "0.74020696", "0.74007034", "0.74007034", "0.7365017", "0.7352297", "0.7349774", "0.7348059", "0.73191625", "0.72890705", "0.72848046", "0.7281736", "0.7276155", "0.72600406", "0.72455907", "0.72455907", "0.7244252", "0.7240822", "0.7237572", "0.72242534", "0.7218312", "0.7214213", "0.72141224", "0.72113234", "0.7206999", "0.72050595", "0.71995795", "0.7196576", "0.7188533", "0.7169075", "0.7163662", "0.7162729", "0.7160363", "0.7160363", "0.7160363", "0.7160363", "0.7160363", "0.7160363", "0.7160363", "0.7160363", "0.7160363", "0.7160363", "0.7153278", "0.71532345", "0.7149653", "0.71482897", "0.7143912", "0.71433425", "0.7141847", "0.7133589", "0.7132242", "0.71286273", "0.7124347", "0.7114794", "0.7096359", "0.7089585", "0.70879537", "0.70870346", "0.70847523", "0.7074238", "0.7073416", "0.7071414", "0.7067712", "0.70636666", "0.7062759", "0.7062759", "0.7062099", "0.7055119", "0.7052966", "0.70484525" ]
0.0
-1
Perform HTTP POST request
def post(path, params={}) RestClient.post request_base+path, params end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end", "def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end", "def post()\n return @http.request(@req)\n end", "def post(url, post_vars={})\n send_request url, post_vars, 'POST'\n end", "def post(url, body, headers = {})\n do_request Net::HTTP::Post, url, headers, body\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def post(url, headers, body)\n request(:post, url, headers, body)\n end", "def http_post\n req = Net::HTTP::Post.new @uri.request_uri, request_headers\n req.set_form_data params\n req.basic_auth @proxy_user, @proxy_pass if @proxy_pass && @proxy_user\n req\n end", "def post\n uri = URI.parse(self.url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.open_timeout = 10\n http.read_timeout = 10\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n data = self.params.collect { |k, v| \"#{k}=#{CGI.escape(v.to_s)}\" }.join(\"&\")\n Freemium.log_test_msg(\"POST\\n url: #{self.url}\\n query: #{data}\")\n http.post(uri.request_uri, data).body\n end", "def post(request)\n do_request(request) { |client| client.http_post request.body }\n end", "def post_http(args)\n\t\t return(Net::HTTP.post_form @uri, args)\t\t\t\n \tend", "def post\n resource.post(request, response)\n end", "def post!\n self.https.request self.http_request # Net::HTTPResponse object\n end", "def http_post_request\n begin\n return http_client.post(http_path_query, compressed_request, http_headers)\n rescue APIKeyError\n log 'error - you must set your api_key.'\n rescue TimeoutError\n log 'fail - timeout while contacting the api server.'\n rescue Exception => e\n log \"fail - exception raised during http post. (#{e.class.name}: #{e.message})\"\n end\n nil\n end", "def post_request(path, params={}, options={})\n request(:post, path, params, options)\n end", "def post url, object = nil\n request url, HTTP::Post, object\n end", "def http_post(url, data)\n\turi = URI(url)\n\treq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\n req.body = data.to_json\n response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }\n return response\nend", "def post_request(url,args)\n uri = URI.parse(url)\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data(args)\n request(uri,req)\n end", "def POST(data=nil)\n\n if not data.nil? #if request data passed in, use it.\n @data = data\n end\n\n uri = URI(@url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n if @set_cert_file\n http = set_cert_file(http)\n end\n request = Net::HTTP::Post.new(uri.path)\n request.body = @data\n request.basic_auth(@user_name, @password)\n\n response = http.request(request)\n return response\n end", "def post(uri, request_headers, body)\n request('post', uri, request_headers, body)\n end", "def do_request\n\t\t\tself.response = post_request(options)\n\t\tend", "def post(url, data, headers = {})\n request(:post, url, headers, :data => data)\n end", "def http_post(uri, data)\n RestClient.post uri, data\n end", "def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def post query=nil, content_type='application/x-www-form-urlencoded'\n\t\treq = Net::HTTP::Post.new(@uri.path)\n\n\t\treq.body= make_query query if query\n\t\treq.content_type=content_type if query\n\t\treq.content_length=query ? req.body.length : 0\n\n\t\tdo_http req\n\tend", "def httppost(url, corpNum, postData, action = '', userID = '', contentsType = '')\n\n headers = {\n \"x-pb-version\" => BaseService::POPBILL_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if contentsType == ''\n headers[\"Content-Type\"] = \"application/json; charset=utf8\"\n else\n headers[\"Content-Type\"] = contentsType\n end\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n if action.to_s != ''\n headers[\"X-HTTP-Method-Override\"] = action\n end\n\n uri = URI(getServiceURL() + url)\n\n https = Net::HTTP.new(uri.host, 443)\n https.use_ssl = true\n Net::HTTP::Post.new(uri)\n\n res = https.post(uri.request_uri, postData, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise PopbillException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end", "def http_post_request(url, body = nil)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = body || ''\n response = http.request(request)\n return response.body\n end", "def post(data)\n uri = URI(@host)\n res = Net::HTTP.post_form(uri, {shell: data})\n # puts res.body\nend", "def post(params = nil)\n request.method = :post\n execute(params)\n end", "def post(url, body, headers)\n conn = create_connection_object(url)\n\n http = conn.post(:body => body,\n :head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end", "def send_post_request(url, payload, content_type = 'application/json')\n # set the uri\n url = URI(url)\n\n # set http settings\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # set request\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = content_type\n request[\"cache-control\"] = 'no-cache'\n\n # set the payload\n request.body = payload\n\n # send the request and get whatever is the response\n response = http.request(request)\n\n # return the response by reading the body\n return response.read_body\n end", "def post(url, options = {}, &block)\n request HttpPost, url, options, &block\n end", "def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end", "def post(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end", "def post(url, args = {})\r\n make_request(:post, url, args)\r\n end", "def http_post(path, data, content_type = 'application/json')\n http_methods(path, :post, data, content_type)\n end", "def POST; end", "def post(*args)\n request(:post, *args)\n end", "def do_post_request(data)\n\t\tresponse = Net::HTTP.post_form(URI(@url),data)\n if response.message == \"OK\"\n\t\t\tresult = {}\n\t\t\tresponse.body.split('&').each do |res|\n\t\t\t\tif res != ''\n\t\t\t\t\ttemp = res.split('=')\n\t\t\t\t\tif temp.size > 1\n\t\t\t\t\t\tresult[temp[0]] = temp[1]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n else\n result = \"Error in the HTTP request\"\n end\n return result\n\tend", "def http_post(url, hash=nil, _port=nil, headers=nil)\n \n resp, data = http_request(url, \"post\", hash, _port, headers)\n\treturn [resp, data]\nend", "def post(url, req_hash={})\n res = nil\n res = perform_op(:post, req_hash) do\n res = @wrapper.post(url, req_hash)\n end\n return res\n end", "def http_post(path, request)\n @http.post(\n :body => JSON(:request => request.to_hash),\n :headers => headers,\n :path => \"/api/v2/#{path}\",\n :expects => [200, 201, 202]\n )\n end", "def post(*args)\n Request.post(*args)\n end", "def http_post(path, data, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 201\n @response = http.post(path, data, headers)\n parse_response? ? parsed_response : response.body\n end", "def POST(data=nil, headers=nil)\n\n\t\tif not data.nil? #if request data passed in, use it.\n\t\t\t@data = data\n\t\tend\n\n\t\turi = URI(@url)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\thttp.use_ssl = true\n\t\trequest = Net::HTTP::Post.new(uri.path)\n\t\trequest.body = @data\n\n\t\tif @search_type == 'premium'\n\t\t\trequest['Authorization'] = \"Bearer #{@app_token}\"\n\t\telse\n\t\t\trequest.basic_auth(@app_token, @password)\n\t\tend\n\n\t\tbegin\n\t\t\tresponse = http.request(request)\n\t\trescue\n\t\t\tlogger()\n\t\t\tsleep 5\n\t\t\tresponse = http.request(request) #try again\n\t\tend\n\n\t\treturn response\n\tend", "def do_post(uri = \"\", body = \"\")\n @connection.post do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Error trying to send a POST to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Request sent: #{body}\"\n Faraday::Response.new\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 post(*args)\n request :post, *args\n end", "def send!\n request = Net::HTTP::Post.new(uri.path, headers)\n request.body = @body\n request.content_type = @@content_type\n response = Net::HTTP.start(uri.host, uri.port) do |http|\n http.request(request)\n end\n ok?(response)\n end", "def post(payload)\n post_like payload, Net::HTTP::Post.new(@uri.path)\n end", "def post_request(uri, body, token)\n http = build_http(uri)\n request = Net::HTTP::Post.new(uri.request_uri, initheader = build_headers(token))\n request.body = body\n return http.request(request)\t\t\n end", "def post path_and_params, post_body\n start if not @pid\n @lock.synchronize do\n @last_use = Time.new.to_f\n\n # Make request to xtractr\n Net::HTTP.start('localhost', @port) do |http|\n http.request_post \"/#{path_and_params}\", post_body do |response|\n headers = {}\n response.each_header {|name,val| headers[name] = val}\n return response.code.to_i, headers, response.body\n end\n end\n end\n end", "def post\n @response_body = make_request(\"#{api_url}#{endpoint}\", request_body.to_json)\n puts \"GLIMR POST: #{endpoint} - #{request_body.to_json}\" if ENV.key?('GLIMR_API_DEBUG')\n end", "def post(request)\n request.method = :post\n request.call\n end", "def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end", "def post_request(uri, body, token = nil, manage_errors = true)\n request = Net::HTTP::Post.new(uri.request_uri, initheader = build_headers(token))\n request.body = body.to_json\n return do_request(uri, request, manage_errors) \n end", "def send_post(uri, data)\n _send_request('POST', uri, data)\n end", "def post(request)\n _request(request) { |client, options| client.post options }\n end", "def simple_post(plain_url, params, user_headers)\n url = URI.parse(plain_url)\n\n headers = self.class.default_headers.merge(user_headers)\n\n req = Net::HTTP::Post.new(url.path, headers)\n req.set_form_data(params)\n\n if DEBUG_REQ\n puts \"=== Debug Http Request\"\n puts \"url => #{url}\"\n puts \"body => #{req.body}\"\n puts \"=== Fim Debug Http Request\"\n end\n\n res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n else\n res.error!\n end\n\n plain_html = res.body\n if DEBUG_REQ\n puts \"=== Debug Http Response Body\"\n puts plain_html\n puts \"=== Fim Debug Http Response Body\"\n end\n plain_html\n end", "def post(uri, params = {})\n send_request(uri, :post, params)\n end", "def post(data = {})\n call data, method: :post\n end", "def exec_post(req, data, exit_on_fail = false)\n response_hash = exec_api_call('POST', req, data, exit_on_fail)\n response_hash[:response]\n end", "def http_post(payload)\n LOGGER.info(\"Sending POST request to #{@collector_uri}...\")\n LOGGER.debug(\"Payload: #{payload}\")\n destination = URI(@collector_uri)\n http = Net::HTTP.new(destination.host, destination.port)\n request = Net::HTTP::Post.new(destination.request_uri)\n if destination.scheme == 'https'\n http.use_ssl = true\n end\n request.body = payload.to_json\n request.set_content_type('application/json; charset=utf-8')\n response = http.request(request)\n LOGGER.add(is_good_status_code(response.code) ? Logger::INFO : Logger::WARN) {\n \"POST request to #{@collector_uri} finished with status code #{response.code}\"\n }\n\n response\n end", "def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end", "def perform_post(path, options = {})\n perform_request(:post, path, options)\n end", "def api_post(action, data)\n api_request(action, data, 'POST')\n end", "def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end", "def post(path, headers, body, &callback)\n request('POST', path, headers, body, &callback)\n end", "def _http_post resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Post.new(path)\n _build_request resource, request\nend", "def _http_post resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Post.new(path)\n _build_request resource, request\nend", "def post(url, options)\n headers = options[:headers] || {}\n params = options[:params] || {}\n req = Net::HTTP::Post.new(url)\n req = request_with_headers(req, headers)\n request_with_params(req, params)\n end", "def post(resource_url, params, data=nil)\n headers = {'Authorization' => authorization('POST', resource_url, params)}\n url = resource_url + '?' + URI.encode_www_form(params)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n res = http.request_post(url, data, headers)\n Response.new(res)\n end", "def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend", "def post(path, data, params = {}, request_options = {})\n request(:post, path, data, params)\n end", "def post(path, options={})\n send_request 'post', path, options\n end", "def post(url, post_data, custom_headers = {})\n headers = @default_headers.merge(custom_headers)\n # slow down the request rate! otherwise you will get blocked\n sleep 1\n return @agent.post(url, post_data, headers)\n end", "def http_post(*args)\n url = args.shift\n c = Curl::Easy.new url\n yield c if block_given?\n c.http_post *args\n c\n end", "def post(body)\n body = body.to_s\n request = Net::HTTP::Post.new(@uri.path)\n request.content_length = body.size\n request.body = body\n request['Content-Type'] = @http_content_type\n\n # Server will disconnect @http_inactivity seconds after receiving previous client\n # response, unless it receives the post we are now sending.\n # Net::HTTP defaults to 60 seconds, which would not always be appropriate.\n # In particular, the default would not work if @http_wait is > 60!\n if @initial_post == true\n read_timeout = @http_connect\n @initial_post = false\n elsif @previous_send == Time.at(0)\n read_timeout = @http_inactivity + 1\n else\n read_timeout = (Time.now - @previous_send).ceil + @http_inactivity\n end\n\n opts = {\n :read_timeout => read_timeout, # wait this long for a response\n :use_ssl => @use_ssl # Set SSL/no SSL\n }\n opts[:verify_mode] = @verify_mode if @use_ssl # Allow caller to defeat certificate verify\n\n Jabber::debuglog(\"#{@protocol_name} REQUEST (#{@pending_requests + 1}/#{@http_requests}) with timeout #{read_timeout}:\\n#{request.body}\")\n response = @http.start(@uri.host, @uri.port, nil, nil, nil, nil, opts ) { |http|\n http.request(request)\n }\n Jabber::debuglog(\"#{@protocol_name} RESPONSE (#{@pending_requests + 1}/#{@http_requests}): #{response.class}\\n#{response.body}\")\n\n unless response.kind_of? Net::HTTPSuccess\n # Unfortunately, HTTPResponses aren't exceptions\n # TODO: rescue'ing code should be able to distinguish\n raise Net::HTTPBadResponse, \"#{response.class}\"\n end\n\n body = REXML::Document.new(response.body).root\n if body.name != 'body' and body.namespace != 'http://jabber.org/protocol/httpbind'\n raise REXML::ParseException.new('Malformed body')\n end\n body\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post_request(params, useSSL=false)\n # get a server handle\n port = (useSSL == true) ? 443 : 80\n http_server = Net::HTTP.new(API_HOST, port)\n http_server.use_ssl = useSSL\n \n # build a request\n http_request = Net::HTTP::Post.new(API_PATH_REST)\n http_request.form_data = params\n \n # get the response XML\n return http_server.start{|http| http.request(http_request)}.body\n end", "def post(path, payload)\n req = Net::HTTP::Post.new(path)\n action(req, payload)\n end", "def post_request(url, params)\n res = Net::HTTP.post_form(url, params)\n Nokogiri::HTML(res.body)\n end", "def post(path, params = {})\n\t\trequest(path, :post, params)\n\tend", "def post_http_content\n res = Net::HTTP.post_form(uri, params)\n\n raise HTTPError.new(\"invalid #{res.code} response\") unless res.is_a?(Net::HTTPSuccess)\n\n res.body\n end", "def http_post(path, query, format = :json)\n raise JamendoError.new('Please authenticate application before posting!') if @access_token.nil?\n uri = URI.parse(\"http://#{Jamendo::API_SERVER}/v#{Jamendo::API_VERSION}/?client_id=#{@client_id}&format=#{format.to_s}&#{path}#{query}\")\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n begin\n response = http.request(request)\n parse_response(response)\n rescue => e\n e.inspect \n end\n end", "def post(path, options={})\n request :post, path, options\n end", "def post(path, body = nil, options = {})\n request = Net::HTTP::Post.new(request_uri(path))\n request.body = body\n make_request(request, options)\n end", "def http_post_request(req_body)\n\t\t#New http request (uri library deals with port and host on its own when parsing the url)\n\t\thttp = Net::HTTP.new(@uri.host, @uri.port)\n\t\t#Original api url get does not need SSL (bad solution but any other way would not seem to work properly)\n\t\tif caller[1][/`.*'/].nil? or not (caller[1][/`.*'/][1..-2] == \"initialize\")\n\t\t\t#Https security stuff (don't need security when getting initial api url)\n\t\t\thttp.use_ssl = true\n\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\tend\n\t\t#Post request using uri\n\t\trequest = Net::HTTP::Post.new(@uri.request_uri)\n\t\t#Sets request to use basic authentication using the given username and api_key\n\t\trequest.basic_auth(@username, @api_key)\n\t\t#Sets request to use json content type\n\t\trequest.content_type = \"application/json\"\n\t\t#Sets request body to json file passed\n\t\trequest.body = req_body\n\t\t#Executes setup request and returns body\n\t\thttp.request(request).body\n\tend", "def post(url, data={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"POST #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n post_raw(response['location'], data, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end", "def post(path, query_string, data)\n # ...and delegate to the Faraday connection we created on initilization\n @conn.post \"#{path}?#{query_string}\", data\n end", "def post(url, body = {})\n call(url: url, action: :post, body: body)\n end", "def post(object, url, headers={})\n do_request(\"post\", url, object, headers)\n end", "def post(path, params)\n request(:post, path, params)\n end", "def http_request(params)\n Net::HTTP::Post.new(endpoint.request_uri).tap do |request|\n request.body = URI.encode_www_form params\n request.content_type = 'application/x-www-form-urlencoded; charset=utf-8'\n end\n end", "def post(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::POST,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end", "def post(path, data, headers = {})\n request(:post, path, data, headers).body\n end", "def post(path, data = { }, query = { }, headers = { })\n clear_response\n path = process_path(path, query)\n @success_code = 201\n @response = http.post(path, data, headers)\n parse_response? ? parsed_response : response.body\n end", "def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend", "def post_request(api_server_base_url, api_server_path, method, params, use_ssl)\n \n # get a server handle\n port = (use_ssl == true) ? 443 : 80\n http_server = Net::HTTP.new(@api_server_base_url, port)\n http_server.use_ssl = use_ssl\n \n # build a request\n http_request = Net::HTTP::Post.new(@api_server_path)\n http_request.form_data = params\n response = http_server.start{|http| http.request(http_request)}.body\n # return the text of the body\n return response\n \n end" ]
[ "0.8005528", "0.7863485", "0.7784612", "0.76306975", "0.761245", "0.75891095", "0.7472876", "0.7463129", "0.7410558", "0.7406992", "0.73663586", "0.73638415", "0.7342552", "0.7334187", "0.73337", "0.7293983", "0.7286432", "0.7272447", "0.72401774", "0.7210085", "0.7208627", "0.7146188", "0.7139056", "0.71358085", "0.7128924", "0.7104475", "0.70960504", "0.7080183", "0.7077188", "0.70702845", "0.70571816", "0.70560676", "0.70418274", "0.70250815", "0.70241386", "0.70232886", "0.6997456", "0.69961655", "0.69876564", "0.69800895", "0.69618183", "0.6942676", "0.6941321", "0.6937684", "0.6935057", "0.6929371", "0.6925142", "0.69183785", "0.69177216", "0.69160926", "0.6906679", "0.6900598", "0.6895403", "0.6895314", "0.68950903", "0.68797", "0.68768257", "0.6873754", "0.68651617", "0.6844453", "0.68397975", "0.6836196", "0.6834227", "0.6823523", "0.68227017", "0.681828", "0.68126124", "0.6810562", "0.6807621", "0.6807621", "0.6802478", "0.6799946", "0.67958903", "0.6795422", "0.6791681", "0.67873776", "0.678563", "0.67830884", "0.6776857", "0.6776857", "0.6776857", "0.67755127", "0.67608154", "0.6755657", "0.67540234", "0.6747152", "0.6746526", "0.6738774", "0.6738725", "0.6730712", "0.6729891", "0.67276204", "0.6722207", "0.6718711", "0.67169696", "0.6702854", "0.6698214", "0.6690548", "0.6690473", "0.668934", "0.6687742" ]
0.0
-1
Perform HTTP PUT request
def put(path, params={}) RestClient.put request_base+path, params end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put url, body, headers = {}\n http_request(url, Net::HTTP::Put, body, headers)\n end", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def put!\n request! :put\n end", "def put(*args)\n request :put, *args\n end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def perform_put(path, options = {})\n perform_request(:put, path, options)\n end", "def put(*args)\n request(:put, *args)\n end", "def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end", "def put(url, vars={})\n send_request url, vars, 'PUT'\n end", "def put(object, url, headers={})\n do_request(\"put\", url, object, headers)\n end", "def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end", "def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def raw_put(path, body, options = {})\n # Allow format override\n format = options.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Create PUT request\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", \n :verbose => DEBUG,\n :method => \"put\",\n :body => body,\n :headers => { :'Content-type' => options[:content_type] || content_type(format) }\n )\n # Send request\n do_request(put, format)\n end", "def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put(uri, request_headers, body)\n request('put', uri, request_headers, body)\n end", "def do_put(uri = \"\", body = \"\")\n @connection.put do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Error trying to send a PUT to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Request sent: #{body}\"\n Faraday::Response.new\n end", "def put(path, options={})\n request :put, path, options\n end", "def do_put(uri = '', body = '')\n build_request(:put, uri, body)\n end", "def put(path, options={})\n send_request 'put', path, options\n end", "def put(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Put.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end", "def put(request)\n do_request(request) { |client| client.http_put request.body }\n end", "def put(path, data, params = {}, request_options = {})\n request(:put, path, data, params)\n end", "def put(url, body = {})\n call(url: url, action: :put, body: body)\n end", "def make_put_request(url, data)\n headers = {\n \"Content-Type\" => \"application/json\",\n }\n\n response = HTTParty.put(url, body: data.to_json, headers: headers)\n\n if response.success?\n response\n else\n puts \"Request failed with response code: #{response.code}\"\n puts \"Response message: #{response.message}\"\n nil\n end\nend", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def put(path, body: {}, headers: nil)\n response = conn.put do |req|\n build_request(req, path: path, body: body, headers: headers)\n end\n puts response.body\n response.body unless response.blank?\n end", "def http_put(url, params, &request_modifier)\n uri = URI.parse url\n req = Net::HTTP::Put.new uri.path\n req.set_form_data(params)\n request_modifier && (request_modifier.call req)\n\n session = (Net::HTTP.new uri.host, uri.port)\n case res = session.start { |http| http.request req }\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n else\n res.error!\n end\n end", "def put(path, options = {}, raw = false)\n request(:put, path, options, raw)\n end", "def put(uri, params = {})\n send_request(uri, :put, params)\n end", "def put(path, options={}, raw=false)\n request(:put, path, options, raw)\n end", "def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def put(path, data=nil)\n request(:put, path, data)\n end", "def put url, payload\n RestClient::Request.execute(:method => :put, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(resource, body = \"\", headers = {})\n prepare_request(:put, resource, body, headers)\n end", "def request_put(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"PUT\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Put.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend", "def put(path, data={})\n request(:put, path, data)\n end", "def put(url, options = {}, &block)\n request HttpPut, url, options, &block\n end", "def put(path, opts = {})\n request(:put, path, opts).body\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, body = '', headers = {})\n with_auth { request(:put, path, body.to_s, build_request_headers(headers, :put, build_uri(path))) }\n end", "def put(request)\n request.method = :put\n request.call\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def make_put_request\n options = {\n use_ssl: true,\n cert: OpenSSL::X509::Certificate.new(@certificate),\n key: OpenSSL::PKey::RSA.new(@key),\n ca_file: @uw_ca_file,\n verify_mode: OpenSSL::SSL::VERIFY_PEER\n }\n Net::HTTP.start(@uri.host, @uri.port, options) do |http|\n request = Net::HTTP::Put.new(@uri.request_uri)\n request.body = @request_text\n @response = http.request(request)\n end\n puts \"Response is: #{get_response_code}\"\n puts \"Body is: #{@response.body}\"\n @response.body\n end", "def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def put(request)\n _request(request) { |client, options| client.put options }\n end", "def put(path, headers = {})\n process :put, path, headers\n end", "def http_put(request, response)\n body = request.body_as_stream\n path = request.path\n\n # Intercepting Content-Range\n if request.header('Content-Range')\n # An origin server that allows PUT on a given target resource MUST send\n # a 400 (Bad Request) response to a PUT request that contains a\n # Content-Range header field.\n #\n # Reference: http://tools.ietf.org/html/rfc7231#section-4.3.4\n fail Exception::BadRequest, 'Content-Range on PUT requests are forbidden.'\n end\n\n # Intercepting the Finder problem\n expected = request.header('X-Expected-Entity-Length').to_i\n if expected > 0\n # Many webservers will not cooperate well with Finder PUT requests,\n # because it uses 'Chunked' transfer encoding for the request body.\n #\n # The symptom of this problem is that Finder sends files to the\n # server, but they arrive as 0-length files in PHP.\n #\n # If we don't do anything, the user might think they are uploading\n # files successfully, but they end up empty on the server. Instead,\n # we throw back an error if we detect this.\n #\n # The reason Finder uses Chunked, is because it thinks the files\n # might change as it's being uploaded, and therefore the\n # Content-Length can vary.\n #\n # Instead it sends the X-Expected-Entity-Length header with the size\n # of the file at the very start of the request. If this header is set,\n # but we don't get a request body we will fail the request to\n # protect the end-user.\n\n # Only reading first byte\n first_byte = body.read(1)\n unless first_byte\n fail Exception::Forbidden, 'This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'\n end\n\n # The body needs to stay intact, so we copy everything to a\n # temporary stream.\n\n new_body = StringIO.new\n new_body.write(first_byte)\n IO.copy_stream(body, new_body)\n new_body.rewind\n\n body = new_body\n end\n\n if @server.tree.node_exists(path)\n node = @server.tree.node_for_path(path)\n\n # If the node is a collection, we'll deny it\n unless node.is_a?(IFile)\n fail Exception::Conflict, 'PUT is not allowed on non-files.'\n end\n\n etag = Box.new\n return false unless @server.update_file(path, body, etag)\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 204\n else\n # If we got here, the resource didn't exist yet.\n etag = Box.new\n unless @server.create_file(path, body, etag)\n # For one reason or another the file was not created.\n return false\n end\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 201\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end", "def put(url, payload = {}, headers = {})\n http :put, \"#{url}.json\", payload.to_json, headers\n end", "def put(path, options={}, format=format)\n request(:put, path, options, format)\n end", "def send_put_request endpoint, params={}, api_key=nil, ssl=false\n uri = URI.parse(endpoint)\n\n Net::HTTP.start(uri.host, uri.port) do |http|\n http.use_ssl = true if ssl\n request = Net::HTTP::Put.new(uri.request_uri)\n request['authorization'] = \"Token token=#{api_key}\" if api_key\n request.set_form_data(params)\n http.request request\n end\n end", "def put(url, payload, headers={})\n RestClient.put url, payload, headers\n end", "def put(url, options = {}, &block)\n run! Request.new(url, :put, options.slice(:headers, :params, :payload), &block)\n end", "def put(uri, request_headers, body)\n raise NotImplementedError\n end", "def put(path, options={})\n response = request(path, :put, options)\n validate response\n responsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end", "def put(path, params)\n request(:put, path, params)\n end", "def do_PUT(req, res)\n perform_proxy_request(req, res) do |http, path, header|\n http.put(path, req.body || '', header)\n end\n end", "def put(path, payload)\n req = Net::HTTP::Put.new(path)\n action(req, payload)\n end", "def put(path, options = {})\n request(:put, parse_query_and_convenience_headers(path, options))\n end", "def put(options={}, &block)\n response = http.put_uri(options.merge(:body => serialize), &block)\n handle_response(response)\n self\n end", "def put_request(uri, body, token = nil, manage_errors = true)\n request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))\n request.body = body.to_json\n return do_request(uri, request, manage_errors) \n end", "def put(url, body, headers: {}, params: {}, options: {})\n raise ArgumentError, \"'put' requires a string 'body' argument\" unless body.is_a?(String)\n url = encode_query(url, params)\n\n request = Net::HTTP::Put.new(url, @default_headers.merge(headers))\n request.body = body\n request.content_length = body.bytesize\n\n raise ArgumentError, \"'put' requires a 'content-type' header\" unless request['Content-Type']\n\n execute_streaming(request, options: options)\n end", "def put(path, data, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Put.new(uri.request_uri)\n set_authorisation_header(request)\n request.set_form_data(data)\n\n response = https_client(uri).request(request)\n end", "def put(path, data, headers = { })\n path = \"/#{path}\" unless path.start_with?('/')\n request = Net::HTTP::Put.new(path, headers)\n process_put_and_post_requests(request, data)\n end", "def put_request(uri, body, token)\n http = build_http(uri)\n request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))\n request.body = body\n return http.request(request)\t\t\n end", "def put(url, payload, headers={})\n payload = MultiJson.encode(payload)\n headers = headers.merge({:content_type => 'application/json'})\n request(:put, url, payload, headers)\n end", "def put(resource, **params)\n\n execute(Net::HTTP::Put, 'PUT', resource, **params)\n\n end", "def api_put_request(url_prefix, data, raw_response = false)\n to_put = URI.escape(url_prefix)\n request = Net::HTTP::Put.new(to_put)\n request.body = data\n @logger.info \"PUT #{to_put}\"\n exec_request(request, raw_response, data)\n end", "def put(uri, request_headers, body)\n request('put', uri, request_headers, body) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end", "def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end", "def put(url, payload, headers: {}, options: {})\n request_with_payload(:put, url, payload, headers, options)\n end", "def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end", "def put(attrs = nil)\n attrs ||= attributes\n\n execute_request('PUT') do |uri, headers|\n HTTP.http_client.put(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end", "def put(path, params)\n parse_response @client[path].put(params)\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def put(href, additional_parameters = {})\n rest_connect do |base_uri, headers|\n href = \"#{base_uri}/#{href}\" unless begins_with_slash(href)\n new_path = URI.escape(href)\n req = Net::HTTP::Put.new(new_path, headers) \n req.set_content_type('application/json')\n req.body = additional_parameters.to_json\n req\n end\n end" ]
[ "0.79793304", "0.7931324", "0.79307526", "0.7918318", "0.78683215", "0.78636295", "0.78534824", "0.78447163", "0.77293915", "0.7729186", "0.7683448", "0.76762205", "0.76661795", "0.7662284", "0.7611254", "0.7611254", "0.7608692", "0.75811964", "0.7579723", "0.7560995", "0.7546515", "0.75440764", "0.7511722", "0.7508284", "0.74974555", "0.74887073", "0.7472108", "0.7471887", "0.7465933", "0.74553424", "0.7450762", "0.7440713", "0.742683", "0.7424984", "0.74060553", "0.7395456", "0.73756117", "0.73750776", "0.735294", "0.7345821", "0.7345821", "0.73435", "0.73435", "0.7337603", "0.7323464", "0.7318972", "0.7313314", "0.731031", "0.7310248", "0.72984993", "0.72980857", "0.72903574", "0.72903574", "0.72903574", "0.72903574", "0.72903574", "0.72903574", "0.72903574", "0.72903574", "0.7279025", "0.7279025", "0.7279025", "0.7276056", "0.7276056", "0.72668505", "0.72630507", "0.7258408", "0.72389215", "0.7238641", "0.7235108", "0.7229647", "0.71934843", "0.71890885", "0.71885335", "0.71789455", "0.71746624", "0.71734154", "0.7171158", "0.7170669", "0.7169081", "0.7163308", "0.7161326", "0.7157155", "0.71520865", "0.71461606", "0.7144907", "0.714183", "0.7136988", "0.7131334", "0.7129063", "0.709574", "0.709574", "0.7077046", "0.7077046", "0.7076856", "0.7074355", "0.7046375", "0.7038537", "0.70193416", "0.70168644" ]
0.72167075
71
Perform HTTP DELETE request
def delete(path) RestClient.delete request_base+path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def do_delete(uri = '')\n build_request(:delete, uri)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete\n request(:delete)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete(uri)\r\n request(Net::HTTP::Delete.new(uri)) \r\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def delete(url)\n do_request(\"delete\", url)\n end", "def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def delete(url, vars={})\n send_request url, vars, 'DELETE'\n end", "def delete(request)\n do_request(request) { |client| client.http_delete }\n end", "def delete!\n request! :delete\n end", "def delete(uri = nil)\n requestor(Net::HTTP::Delete.new(build_uri(uri)))\n end", "def delete(name)\n request(uri = uri(name), Net::HTTP::Delete.new(uri.request_uri))\n end", "def delete(*args)\n request(:delete, *args)\n end", "def delete(uri, params = {})\n send_request(uri, :delete, params)\n end", "def http_delete(path, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 204\n @response = http.delete(path, headers)\n parse_response? ? parsed_response : response.body\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete(url, headers = {})\n request(:delete, url, headers)\n end", "def delete(url, headers = {})\n request(:delete, url, headers)\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete(payload)\n post_like payload, Net::HTTP::Delete.new(@uri.path)\n end", "def delete(path, options = {})\n request = Net::HTTP::Delete.new(request_uri(path))\n make_request(request, options.merge(no_callbacks: true))\n end", "def delete(uri, request_headers)\n request('delete', uri, request_headers)\n end", "def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end", "def delete(path, params = {}, request_options = {})\n request(:delete, path, params)\n end", "def delete(url, headers: {}, params: {}, options: {})\n url = encode_query(url, params)\n\n request = Net::HTTP::Delete.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options)\n end", "def delete(path)\n uri = build_uri(path)\n\n request = Net::HTTP::Delete.new(uri.request_uri)\n set_authorisation_header(request)\n\n response = https_client(uri).request(request)\n end", "def delete\n client.delete(url)\n @deleted = true\n end", "def delete(url, headers={})\n RestClient.delete url, headers\n end", "def delete\n request('delete').auth_required!\n end", "def delete(path)\n request 'DELETE', path\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(uri, options = {})\n build_response(request.delete(uri, build_request_options({:input => options.to_params})))\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path)\n request(:delete, path)\n end", "def delete_request(uri)\n http = build_http(uri)\n request = Net::HTTP::Delete.new(uri.request_uri, initheader = build_headers())\n return http.request(request)\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\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 delete(path, payload = nil)\n req = Net::HTTP::Delete.new(path)\n action(req, payload)\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def delete(request)\n request.method = :delete\n request.call\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\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 delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end", "def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def delete(*args)\n Request.delete(*args)\n end", "def delete(url, headers)\n conn = create_connection_object(url)\n\n http = conn.delete(:head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end", "def delete(path, params)\n request(:delete, path, {})\n end", "def send_delete_request(path)\n response = self.class.delete(path)\n # need auth\n case (response.code)\n when 200\n # just continue\n when 401\n authenticate(response)\n response = self.class.delete(path)\n else\n end\n if response.code != 200 && response.code != 202\n throw \"Could not finish request, status #{response.code}\"\n end\n response\n end", "def delete(url, headers: {}, options: {})\n request_without_payload(:delete, url, headers, options)\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpDeleteWithEntity, url, options, &block\n end", "def delete\n api_client.delete(url)\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete(path, accept, content = {})\n execute HttpConnect::HttpDelete.new(path, nil, accept, content)\n end", "def delete(path, data={})\n request(:delete, path, data)\n end", "def delete(url)\n call(url: url, action: :delete)\n end", "def delete(user)\n Rails.logger.debug \"Call to poll.delete\"\n reqUrl = \"/api/poll/#{self.id}\" #Set the request url\n rest_response = MwHttpRequest.http_delete_request(reqUrl,user['email'],user['password']) #Make the DELETE request to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n return true, rest_response #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n end", "def delete(params = {})\n Client.current.delete(resource_url, params)\n end", "def delete(request)\n _request(request) { |client, options| client.delete options }\n end", "def delete(headers = {}, path = '', parameters = {})\n full_path = [path, URI.encode_www_form(parameters)].join(PARAM_STARTER)\n uri = URI.parse(\"#{@url}#{full_path}\")\n request = Net::HTTP::Delete.new(uri.request_uri)\n request.body = nil\n send_request(uri, request, headers)\n end", "def delete(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::DELETE,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end", "def delete\n api(\"Delete\")\n end", "def delete(uri, request_headers)\n raise NotImplementedError\n end", "def delete(path)\n request(:delete, path)\n end", "def api_delete(action, data)\n api_request(action, data, 'DELETE')\n end", "def http_delete(opts={})\n ret=http_delete_low(opts)\n if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then\n\tauthdefault\n\tret=http_delete_low(opts)\n\treturn ret\n else\n\treturn ret\n end\n end", "def delete(uri, options = {})\n execute(uri, :delete, options)\n end", "def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def delete(resource, **params)\n\n execute(Net::HTTP::Delete, 'DELETE', resource, **params)\n\n end", "def delete(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n # nothing returned in response body for DELETE\n Response.new(@client[url].delete headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end", "def delete(url, options = {}, &block)\n run! Request.new(url, :delete, options.slice(:headers, :params, :payload), &block)\n end", "def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end", "def delete(uri, parameters)\n response = Unirest.delete uri, parameters: parameters\n response.body\n end", "def make_delete_request\n options = {\n use_ssl: true,\n cert: OpenSSL::X509::Certificate.new(@certificate),\n key: OpenSSL::PKey::RSA.new(@key),\n ca_file: @uw_ca_file,\n verify_mode: OpenSSL::SSL::VERIFY_PEER\n }\n Net::HTTP.start(@uri.host, @uri.port, options) do |http|\n request = Net::HTTP::Delete.new(@uri.request_uri)\n @response = http.request(request)\n end\n @response.body\n end", "def delete\n delete_from_server single_url\n end" ]
[ "0.8399885", "0.83332837", "0.83332837", "0.8220235", "0.8210298", "0.8210298", "0.820187", "0.8188731", "0.8074704", "0.8021655", "0.80212134", "0.80030185", "0.7978033", "0.79605097", "0.79425305", "0.79425305", "0.79425305", "0.79425305", "0.7917079", "0.79062206", "0.7856824", "0.7808001", "0.7790838", "0.7774885", "0.77655834", "0.7719326", "0.7709363", "0.7707022", "0.766317", "0.76541793", "0.76541793", "0.7651275", "0.7627475", "0.7618767", "0.7609087", "0.7600092", "0.75553083", "0.7552247", "0.7550086", "0.7543914", "0.7531589", "0.7519818", "0.751674", "0.7514409", "0.7511805", "0.74835974", "0.74835974", "0.74792707", "0.7478261", "0.7478261", "0.7478261", "0.7478261", "0.7478261", "0.7478261", "0.7478261", "0.7478114", "0.7478114", "0.7478114", "0.7466461", "0.74574834", "0.74545676", "0.7451743", "0.7451524", "0.7448424", "0.74457765", "0.7436918", "0.7426074", "0.7422759", "0.7414144", "0.74131525", "0.7411961", "0.7397216", "0.73927253", "0.73899746", "0.7386881", "0.7371576", "0.73701334", "0.73640823", "0.73548627", "0.7348066", "0.73431647", "0.73356855", "0.73220205", "0.73216337", "0.73214245", "0.7316239", "0.73149335", "0.7314381", "0.73074853", "0.7306098", "0.73036116", "0.72670925", "0.7266674", "0.72518057", "0.7241517", "0.72409415", "0.72325593", "0.7225667", "0.7225416", "0.7221895" ]
0.745061
63
returns the global unread notification count for a user
def count_for_target NotifyUser::BaseNotification.for_target(target) .where('parent_id IS NULL') .where('state IN (?)', ["sent_as_aggregation_parent", "sent", "pending"]) .count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unread_notification_count\n unread_notifications.count\n end", "def unread_count(user)\n public_replies(user).unread_by(user).size + (unread?(user) ? 1 : 0)\n end", "def notification_count\n return NotificationReader.where(user: current_user, read_at: nil).count\n end", "def unread_count\n @status = Messenger.inbox_status(current_user)\n return_message(200, :ok, :count => @status[:unread])\n end", "def get_unread_message_count(user)\n username = Digest::MD5.hexdigest(user.id.to_s)\n begin\n response = RestClient.get(\"#{DOMAIN}/#{ORG}/#{APP}/users/#{username}/offline_msg_count\",\n \"Authorization\" => \"Bearer #{access_token}\",\n :content_type => :json,\n :accept => :json\n )\n if response.code == 200\n p response\n\n body = JSON.parse(response.body)\n p body\n end\n rescue => e\n puts e.response\n end\n end", "def num_unread_messages(user)\n Rails.cache.fetch(\"#{cache_key_with_version}/num_unread_messages/#{user.id}\") do\n Message.unread_by(user).where(chat_room: self).where.not(user: user).count\n end\n end", "def unread_messages_count\n Rails.cache.fetch(\"user-unread_messages_count-#{id}\") do\n unread_conversations.count('messages.id')\n end\n end", "def unread_messages\n current_user.messages_in.where(read: false).count\n end", "def notifications_count\n notifications_count ||= self.notifications_to_show_user.where(:seen_by_user => false).count\n end", "def unread_messages_count\n @unread_messages_count ||= messages.unread.count\n end", "def unread_message_count(current_user)\n \tself.messages.where(\"user_id != ? AND read = ?\", current_user.id, false).count\n \tend", "def notification_number\n @notifications = Notification.get_number_of_notifications current_user\n end", "def unread_inbox_count\n mailbox.inbox(unread: true).count\n end", "def unread_inbox_count\n mailbox.inbox(unread: true).count\n end", "def unread_inbox_count\n mailbox.inbox(unread: true).count\n end", "def count_pending_messages_for(_user)\n Rails.cache.fetch(get_unread_cache_key_for(_user.id), expires_in: 1.week.from_now) do\n _member = conversation_members.where(user_id: _user).take\n if _member.present?\n messages.where('messages.created_at > ?', _member.last_seen).count\n else\n 0\n end\n end\n end", "def unread_count\n read_status.split(',').select{|read| read == '0'}.size\n end", "def events_notification_number\n @notifications = Notification.number_of_notifications_for_events current_user\n end", "def load_notifications\n \t\tif current_user\n \t\t\t@notifications = current_user.notifications.limit 5\n \t\t\t@unseen_notifications_count = current_user.notifications.unseen.count\n \t\tend\n \tend", "def unread_count( params={} )\n unread_count = get_connections(\"unread_count\", params)\n return map_connections unread_count, :to => Facebook::Graph::Generic\n end", "def workspace_unread_count\n unread = 0\n workspaces = WorkspaceLancer.or(\n { employer_username: self.username },\n { freelancer_username: self.username },\n { service_provider_username: self.username }\n )\n\n\n # Count each message as unread\n if workspaces.any?\n workspaces.each do |w|\n u = w.events.where(\n read: false,\n :member_id.ne => self.id\n ).count\n\n unread = unread + u\n end\n end\n\n return unread\n end", "def unread_messages\n @user_wise_unread_messages = current_user.user_messages\n .where(is_read: false)\n .joins(:message)\n .group('messages.user_id').count\n end", "def num_unread_messages\n return Message.where({:receiver_id => self.id, :read => false}).count\n end", "def chat_unread_count\n unread = 0\n chats = Chat.or(\n { employer_username: self.username },\n { freelancer_username: self.username },\n { service_provider_username: self.username }\n )\n\n # Count each message as unread\n if chats.any?\n chats.each do |c|\n u = c.events.in(\n :\"_type\" => [\n \"ChatMessageEvent\",\n \"ChatBidEvent\",\n \"ChatBidAcceptEvent\"\n ]\n ).where(\n read: false\n ).nin(\n member_id: [self.id]\n ).count\n\n unread = unread + u\n end\n end\n\n return unread\n end", "def get_notification_count(params = {})\n get('notifications/count', params)\n end", "def notification_count\n @notifications.size\n end", "def notification_count(notify)\n notifies = Notification.user_unread_notifications(current_user.id, notify.id)\n notifies.count > 0 ? [notifies.first.id, notifies.count] : []\n end", "def feed_unread_count(feed)\n SubscriptionsManager.feed_unread_count feed, self\n end", "def unread_message_count\n eval 'messages.count(:conditions => [\"recepient_id = ? AND read_at IS NULL\", self.beamer_id])'\n end", "def unread_count(sender)\n if current_airline.present?\n sender.messages.where('customer_id = ? AND airline_id = ? AND sender = ? AND seen = ?', sender.id, current_airline.id, 'user-message', false).count\n elsif current_customer.present?\n sender.messages.where('customer_id = ? AND airline_id = ? AND sender = ? AND seen = ?', current_customer.id, sender.id, 'airline-message', false).count\n end\n end", "def get_unread_message_restaurant\n unread = Location.find_by_sql(\"select n.restaurant, count(*) as total\n from notifications n\n where n.status=0 and n.restaurant='#{self.id}' and n.to_user='#{self.useremail}'\n group by n.restaurant\")\n\n if unread.blank?\n return 0\n else\n return unread.first.total\n end\n end", "def display_count(user, force_recount = false)\n @display_count = nil if force_recount\n @display_count ||= count(unread_conditions(user, true))\n end", "def display_notif_unseen(usr_id)\n num = PublicActivity::Activity.where(is_seen: false, owner_id: usr_id, owner_type: \"User\").count\n return num if num > 0\n return \"\" # Else return blank string\n end", "def count_for_target(target)\n BaseNotification.unread_count_for_target(target)\n end", "def notification_badge\n if current_user.notifications.any?\n mi.notifications\n else\n mi.notifications_none\n end\n end", "def unread_messages\n @attributes[\"unread_messages\"]\n end", "def unopened_group_member_notifier_count\n group_members.unopened_only\n .filtered_by_association_type(\"notifier\", notifier)\n .where(\"notifier_key.ne\": notifier_key)\n .to_a\n .collect {|n| n.notifier_key }.compact.uniq\n .length\n end", "def new_mail\n poll_response['num_unread'].to_i\n end", "def unread_chats_count\n # Rails.cache.fetch(unread_chats_count_cache_key) do\n Chat.unread_by(self).count\n # end\n end", "def unopened_group_member_notifier_count\n group_members.unopened_only\n .where(notifier_type: notifier_type)\n .where(:notifier_id.ne => notifier_id)\n .distinct(:notifier_id)\n .count\n end", "def load_notifications\n if user_signed_in?\n @all_notifications = current_user.get_notifications\n @notifications = @all_notifications.first(10)\n @count = current_user.unread_notifications_count\n end\n end", "def get_unread_cache_key_for(_user_id)\n \"cache-count_pending_messages_for-#{id}-#{(last_activity || Time.current).to_i}-#{_user_id}\"\n end", "def unopened_notification_count(options = {})\n target_notifications = _unopened_notification_index(options)\n target_notifications.present? ? target_notifications.count : 0\n end", "def get_counter\n conversations = (Conversation.where(buyer_id: @current_user.id).all + Conversation.where(seller_id: @current_user.id).all)\n total = 0\n conversations.each do |conversation|\n count = conversation.messages.count - conversation.buyer_marker if conversation.buyer_id == @current_user.id\n count = conversation.messages.count - conversation.seller_marker if conversation.seller_id == @current_user.id\n total = total + count\n end\n render status: 200, json: {unread_count: total}\n end", "def fAmountOfNotificationsFrom (email)\n @users.amountOfNotificationsFrom(email)\n end", "def unread_messages user_id\n messages.unread(user_id)\n end", "def unread\n @notifications = current_user.notifications.unread.page(params[:page]).per(5)\n end", "def unread\n read_attribute(:unread)\n end", "def unopened_group_member_notifier_count\n # Cache group by query result to avoid N+1 call\n unopened_group_member_notifier_counts = target.notifications\n .unopened_index_group_members_only\n .includes(:group_owner)\n .where(\"group_owners_#{self.class.table_name}.notifier_type = #{self.class.table_name}.notifier_type\")\n .where.not(\"group_owners_#{self.class.table_name}.notifier_id = #{self.class.table_name}.notifier_id\")\n .references(:group_owner)\n .group(:group_owner_id, :notifier_type)\n .count(\"distinct #{self.class.table_name}.notifier_id\")\n unopened_group_member_notifier_counts[[id, notifier_type]] || 0\n end", "def unopened_group_member_count\n # Cache group by query result to avoid N+1 call\n unopened_group_member_counts = target.notifications\n .unopened_index_group_members_only\n .group(:group_owner_id)\n .count\n unopened_group_member_counts[id] || 0\n end", "def imapMailCount\n # Init the email count to start fresh every time this is called\n total_count = 0\n\n # Get the total count of emails in the IMAP inboxes\n imap_inbox = Array.new\n count = 0\n @imap_accounts.each do |acct|\n imap_inbox[count] = @imap_accounts[count].IMAPInboxFolder.get\n total_count += imap_inbox[count].unreadMessageCount\n count += 1\n end\n\n return total_count\n end", "def reset_unread_notification_count\n post('notifications/markAsRead')\n end", "def unread_chats_count_cache_key\n \"#{self.cache_key}/unread_chats_count\"\n end", "def user_count\n users.count\n end", "def message_count\n\t s = status\n\t\t\ts[:message_count]\n\t end", "def users_count\n @attributes[:users_count]\n end", "def total_users_count\n return @total_users_count\n end", "def current_user_last_messages\n @last_messages = current_user.messages.unseen.limit(5) if current_user\n end", "def unseen_memberships_count\n messages.watchable.unseen.group_by(&:membership_id).length\n end", "def get_count\n user_page = Habr::open_page(Habr::Links.userpage(@userslug))\n # get text with favs count\n user_page.css(\".left .count\").first.text.to_i\n end", "def seen\n if @ok\n @ok = @notification.has_been_seen\n end\n @new_notifications = current_user.number_notifications_not_seen\n end", "def user_count; end", "def opened_group_member_notifier_count(limit = ActivityNotification.config.opened_index_limit)\n limit == 0 and return 0\n group_members.opened_only(limit)\n .filtered_by_association_type(\"notifier\", notifier)\n .where(\"notifier_key.ne\": notifier_key)\n .to_a\n .collect {|n| n.notifier_key }.compact.uniq\n .length\n end", "def get_notifications\n \t\n \t@notifs = []\n\n \tif current_user\n @notifs = Notification.where(:user_id => current_user.id, :seen => false)\n \tend\n end", "def get_num\n\t\treturn @num_users\n\tend", "def unread\n all(UNREAD)\n end", "def unread\n @notifications = Notification.where(user_id: current_user.uid).where(is_read: false).page(params[:page]).order(created_at: :desc)\n end", "def unread_feed_news_count(feed_id)\n count(:all, :conditions => [\"feed_id = ? AND user_id = ? AND read = ?\",\n feed_id, User.current_user_id, false])\n end", "def user_count\n respond_with json_response('user_count', User.active.count)\n end", "def user_notification_threshold\n 1024 * (NOTIFICATION_THRESHOLD_OFFSET_GB + NOTIFICATION_USER_AFTER_EXCEEDED_GB * server.exceed_bw_user_notif)\n end", "def number_of_unread_feedbacks(tags)\n \n if current_user.is_agent\n unread = Feedback.not_in(read_by: [current_user.id]).for_agent(current_user.agent_profile.agent_for).count\n else\n unread = Feedback.not_in(read_by: [current_user.id]).count\n end\n \n \n if unread != 0\n if tags\n return \"(#{unread})\"\n end\n \n return \"#{unread}\"\n end\n \n return nil\n end", "def increase_unseen_notification_count!(options, **)\n increase_unseen_notification_count(options['my.notification'])\n end", "def interested_users_count\n self.users.size\n end", "def notifications\n\t\tif signed_in?\n\t\t\tn = current_user.extra.notifications\n\t\t\tif n > 0\n\t\t\t\t\"(\" + n.to_s + \")\"\n\t\t\tend\n\t\tend\n\tend", "def notification_level\n unless first_expiring_value.nil?\n return first_expiring_value.notification_level\n end\n return 0\n end", "def count\n active_message_count || 0\n end", "def get_counts\n #1 - @friend_count -> gets the number of current friends you have.\n @friend_count = current_user.active_friends.size\n \n #2 - @pending_count -> gets the number of pending friend requests you have.\n @pending_count = current_user.pending_friend_requests_to.map(&:friend).size\n end", "def opened_group_member_notifier_count(limit = ActivityNotification.config.opened_index_limit)\n limit == 0 and return 0\n group_members.opened_only(limit)\n .where(notifier_type: notifier_type)\n .where(:notifier_id.ne => notifier_id)\n .distinct(:notifier_id)\n .to_a.length #.count(true)\n end", "def unread_qotds\n admin_conversations.current.recent.find_unread_by(self)\n end", "def set_unread_message_count\n self.unread_messages = 1\n end", "def unread_messages(user)\n Rails.cache.fetch(\"#{cache_key_with_version}/unread_messages/#{user.id}\") do\n Message.unread_by(user).where(chat_room: self).where.not(user: user).to_a\n end\n end", "def unread_notifications_since_last_read\n notification.class.for_target(notification.target)\n .where(group_id: notification.group_id)\n .where(read_at: nil)\n .where('notify_user_notifications.created_at >= ?', last_read_notification.try(:read_at) || 24.hours.ago)\n .where.not(id: notification.id)\n .order(created_at: :desc)\n end", "def issue_counter(repository, user)\n count = readable_open_issues(repository.issues, user).length\n count == 0 ? '' : \"(#{count})\"\n end", "def high_users_count\n @attributes[:high_users_count]\n end", "def total_users\n users.count\n end", "def o_ucount_notify\n User.bot.lobby_speak(\"#{linked_name}さんが本日#{today_total_o_ucount}問解きました\")\n end", "def count_user\n count = 0\n @f_net.each do |followees|\n count += 1 unless !followees or followees.empty?\n end\n count\n end", "def ntf\n\t\tif current_user.admin?\n \t\tceknotif = Notification.all.where(readStat_admin: nil).count()\n \telsif current_user.pimpinan?\n \t\tceknotif = Notification.where(recipient_id: current_user.outlet_id).where(readStat_manager: nil).count()\n \telse\n \t\tceknotif = Notification.where(recipient_id: current_user.outlet_id).where(readStat_receiver: nil).count()\n \tend\n\t\tif ceknotif > 0\n\t\t\treturn \"<i class='fa fa-bell faa-horizontal animated'></i>\".html_safe\n\t\telse\n\t\t\treturn \"<i class='fa fa-bell'></i>\".html_safe\n\t\tend\n\tend", "def notices_count\n @notices_count ||= error.search('notices-count').first.text.to_i\n end", "def index\n @notifications = current_user.notifications.unread.page(params[:page]).per(20)\n end", "def mailCount count_type=nil\n # Init the email count to start fresh every time this is called\n total_count = 0\n\n # Get the total count of emails in the Exchange inboxes\n exch_count = exchangeMailCount\n total_count += exch_count\n \n # Get the total count of emails in the IMAP inboxes\n imap_count = imapMailCount\n total_count += imap_count\n\n @email_count = total_count\n puts total_count\n growlNotify\n return @email_count.to_s\n end", "def total_susus_global\n susus = Susu.all.count\n end", "def check\n\n\t\t@unseenNotifications = {notifications: current_user.notifications.unseen.count}\n\t\trespond_to do |format|\n\n\t\t\tformat.json { render json: @unseenNotifications }\n\n\t\tend\n\n\tend", "def get_unread(user)\n list = []\n if unread?(user)\n list.push(self)\n end\n public_replies(user).unread_by(user).each do |reply|\n list.push(reply)\n end\n list\n end", "def e_counts\n Rails.cache.fetch(\"#{cache_key}/e_counts\", expires_in: 12.hours) do\n User.all.count\n end\n end", "def my_count\n count = my_followers.count\n end", "def is_there_notification\n current_user.notifications\n end", "def index\n\t\t@notifications = Notification.where(recipient_id: current_user.id).unread\n\tend", "def retrieve_message_count_from_server\n response = retrieve_messages_from_server(1)\n response[\"count\"]\n end", "def index\n @users = User.all\n @notifications = Notification.where(recipient: current_user).unread\n end", "def unread_notifications\n notifications_received.where('activities.created_at > ?', notifications_checked_at)\n end" ]
[ "0.81357384", "0.8015549", "0.79157573", "0.7775203", "0.7546733", "0.74842507", "0.7461307", "0.7437711", "0.7395174", "0.7371511", "0.73703545", "0.7270429", "0.7192974", "0.7192974", "0.7192974", "0.7144261", "0.7119244", "0.7015296", "0.69902104", "0.68873596", "0.68813264", "0.68754625", "0.6869741", "0.6852344", "0.68126917", "0.6781905", "0.6777269", "0.6713818", "0.6695314", "0.6689748", "0.6682782", "0.668277", "0.66515756", "0.66302526", "0.6598627", "0.6583114", "0.6521195", "0.65093994", "0.64862865", "0.6485786", "0.64495176", "0.6442021", "0.63607734", "0.6277693", "0.6263948", "0.6245997", "0.6237159", "0.61948836", "0.61794543", "0.61702555", "0.6162335", "0.61513495", "0.614261", "0.6141049", "0.6106967", "0.6097561", "0.60948807", "0.60933423", "0.6090662", "0.6067669", "0.6038436", "0.6037034", "0.60281795", "0.6022187", "0.60194904", "0.6015225", "0.60142934", "0.6001279", "0.5978787", "0.5970157", "0.59630275", "0.5955613", "0.59501797", "0.59491867", "0.59476346", "0.59452045", "0.59417987", "0.593197", "0.5928122", "0.5927747", "0.5924509", "0.5916383", "0.59062517", "0.5905806", "0.59047025", "0.5901322", "0.5889833", "0.5888589", "0.5880932", "0.5877017", "0.5869301", "0.58505267", "0.58435893", "0.5834005", "0.58248156", "0.5822534", "0.5820244", "0.581895", "0.58000124", "0.57991433", "0.579117" ]
0.0
-1
Returns all parent notifications with a given group_id
def current_parents self.class .for_target(self.target) .where(group_id: group_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_members\n Notification.where(group_owner_id: id)\n end", "def parents\n @key.nil? ? [] : [@group.parents, @group].compact.flatten\n end", "def group_notifications\n @attributes[:group_notifications]\n end", "def parent_groups(group_id=nil) \n # {{{\n groups = []\n group_id ||= user_group_id\n return groups unless group_id && group_id > 0\n \n parents = User_Group_Hierarchy.select { |e| \n e.where(User_Group_Hierarchy.user_group_id__child == group_id)\n e.order_by(:user_group_name, :asc)\n }.to_a\n\n parents.each { |group|\n group = User_Group.get(group.user_group_id__parent)\n\n if group && !group.atomic then \n groups.push(group) \n next_parents = group.parent_groups\n groups += next_parents if next_parents\n end\n }\n return groups\n end", "def child_group_ids\n child_groups.map(&:id)\n end", "def notifications\n Group.find_by_sql(\"\n SELECT * FROM (\n SELECT * FROM(\n SELECT u.id, u.name, '0' sp_id, u.bio info, gu.updated_at, 'new_user' type\n FROM users u, group_users gu\n WHERE u.id = gu.user_id AND gu.group_user_state_id = 1 AND gu.group_id = \"+self.id.to_s+\"\n ORDER BY gu.updated_at DESC \n LIMIT 35) NUEVOS_USUARIOS\n UNION ALL\n SELECT * FROM(\n SELECT s.id, s.sci_name name, '0' sp_id, s.family info, sg.updated_at, 'new_species' type\n FROM species s, species_groups sg\n WHERE sg.species_id = s.id AND sg.species_group_state_id = 1 AND sg.group_id = \"+self.id.to_s+\"\n ORDER BY sg.updated_at DESC \n LIMIT 35) NUEVAS_ESPECIES\n UNION ALL\n SELECT * FROM(\n SELECT u.id, u.name, s.id sp_id, s.sci_name info, r.updated_at, 'review' type\n FROM users u, species s, reviews r, models m, group_users gu, species_groups sg\n WHERE u.id = r.user_id AND u.id = gu.user_id AND m.id = r.model_id AND s.id=m.species_id AND s.id = sg.species_id AND gu.group_user_state_id = 1 AND sg.species_group_state_id = 1 AND gu.group_id = \"+self.id.to_s+\" AND sg.group_id = \"+self.id.to_s+\"\n ORDER BY sg.updated_at DESC\n LIMIT 35) NUEVA_EDICION\n )\n ORDER BY updated_at DESC\n LIMIT 35\")\n end", "def all_notifications\n self.notifications.all\n end", "def get_groups_by_parent parent_group_uuid\n parent_group_uuid = parent_group_uuid.uuid if parent_group_uuid.is_a?(Group)\n \n @resources.find_all{|res|res.parent_uuid == parent_group_uuid && (name.blank? || res.name == name)}\n end", "def get_parent_notification\n\t\tAuth.configuration.notification_class.constantize.find(self.parent_notification_id)\n\tend", "def parents(change_id=nil)\n self[change_id].parents\n end", "def chatting_with\n ChatMessage.participant(self).map do |chat|\n if chat.parent.id != self.id\n chat.parent\n else\n Parent.find(chat.recipient_fk)\n end\n end.uniq\n end", "def index\n @parent_to_teacher_notifications = ParentToTeacherNotification.all\n end", "def get_parent_nodegroups(group)\n parents = Set.new\n @group_hierarchy.each do |parent, children|\n if children.include?(group)\n parents << parent\n parents.merge get_parent_nodegroups(parent)\n end\n end\n parents\n end", "def parents\n self.class.where(id: parent_ids)\n end", "def find_all_parents\n @attachments = Attachment.order(:io_stream_updated_at)\n end", "def findParententries(givendate,userid)\n\t #entries = Entry.find(:all, :conditions => [\"user_id=? and entries.end_dt_tm >= ? \", userid, givendate])\n\t entries = Entry.find(:all, :include => [:entry_status], :conditions => [\"entries.user_id= ? and entry_statuses.ended = 0\", userid])\n\t #Also pull out the selected child entries if not already \n\t #Get already selected child entries\n\t selected_children = find_selected_childentries(userid)\n\n\t @otherentries = []\n\t foundCurrentParent = false\n\t entries.each do |e|\n\t if e.id != id && !isItemInList(selected_children,e) && e[:type] != 'Goal' then\n\t @otherentries << e\n\t if e.id == parent_id then\n\t\tfoundCurrentParent = true\n\t end\n\t end \n\t end\n\t #Even if the stored parent task has expired, pull it out for display\n\t if foundCurrentParent == false then\n\t parent = Entry.find(:first, :conditions => [\"user_id =? and entries.id = ?\", userid, parent_id])\n\t @otherentries << parent if parent != nil\n\t end\n\t return @otherentries\n end", "def notifications\n ::Users::Notification.where(related_model_type: self.class.to_s, related_model_id: self.id)\n end", "def receive_kroogi_notifications_for!(ids)\n return nil if user.project?\n project_ids = user.projects.map(&:id) + [user.id]\n tracked_ids = receives_kroogi_notifications_for.map(&:id)\n\n # Remove trackings to projects user no longer follows, or no longer owns\n dead_ids = tracked_ids.select{|t| !project_ids.include?(t) || (ids.nil? || !ids.include?(t))}\n Tracking::KroogiNotification.delete_all({:tracked_item_type => 'User', :tracked_item_id => dead_ids, :tracking_user_id => user.id}) unless dead_ids.empty?\n\n return nil if ids.nil?\n\n # Add trackings that don't already exist\n ids.uniq.each do |pid|\n pid = pid.id if pid.is_a?(User)\n if project_ids.include?(pid.to_i) && !tracked_ids.include?(pid)\n Tracking::KroogiNotification.create(:tracking_user_id => user.id, :tracked_item_type => 'User', :tracked_item_id => pid)\n end\n end\n return receives_kroogi_notifications_for\n end", "def index\n @groupreplies = Groupreply.where(\"groupmessage_id = ?\", params[:groupmessage_id])\n end", "def find_all_parents\n end", "def parent_ids\n []\n end", "def child_replies\n Reply.find_by_parent_id(self.id) \n end", "def unread_unsent_notifications_for_group\n @unread_unsent_notifications_for_group ||= unread_unsent_notifications.where('notify_user_notifications.group_id = ?', notification.group_id)\n end", "def get_conversations\n n = Notification.where(user_id:current_user)\n conversation_ids = Array.new\n n.each do |v|\n conversation_ids << v.conversation_id\n end\n conversations = Conversation.where(id:conversation_ids)\n\n end", "def get_group_by_id(id)\n $r.hgetall(\"group:#{id}\")\n end", "def inherited_group_ids\n self.ancestors.map(&:group_ids).flatten.uniq\n end", "def get_notifications notifiable_type\n n = Notification.where(user_id:current_user, notifiable_type: notifiable_type)\n events_id = Array.new\n n.each do |v|\n events_id << v.notifiable_id\n end\n events = Event.where(id:events_id)\n\n end", "def group_ids\n groups.pluck(:id)\n end", "def find_ancestor_ids(package_id)\n ancestor_ids = []\n if package = package_get(PackageExpr.new(package_id: package_id))\n ancestor_ids += package.parent_ids\n package.parent_ids.each do |parent_id|\n find_ancestor_ids(parent_id).each do |ancestor_id|\n if not(ancestor_ids.include?(ancestor_id))\n ancestor_ids << ancestor_id\n end\n end\n end\n end\n return ancestor_ids\n end", "def getEventNotifications(u, e)\n @result = []\n @ns = Notification.all\n @ns.each do |n|\n if u == nil\n if (n.notification_type == 3 || n.notification_type == 4) && n.sender_id == e.to_i\n @result.push(n)\n end\n else\n if (n.notification_type == 3 || n.notification_type == 4) && n.sender_id == e.to_i && n.user_id == u.to_i\n @result.push(n)\n end\n end\n end\n return @result\n end", "def find_child_entries_for(givendate,userid,parent)\n @entries = Entry.find_all_current_entries(givendate,userid)\n @otherChildentries = []\n \n @ancestors = []\n \n if parent != 0 then \n parentid = parent\n while parentid != nil\n @ancestors << parentid\n parent = Entry.find_by_id(parentid)\n parentid = parent.parent_id\n end\n end\n @entries.each do |e|\n if e.id != id && !isAncestor(@ancestors,e.id) then\n @otherChildentries << e\n end \n #@otherChildentries << e unless e.id == id || isAncestor(@ancestors)\n end\n \n return @otherChildentries\n end", "def get_issue_project_parent\t \n\t project = Project.find(params[:project_id]) \n issues = Issue.visible.where(\"project_id = ? and issues.parent_id is null\", project).to_a || []\n logger.info \"Get projects parent issue: #{issues}\"\n if issues && issues.size >= 1\n return issues\n else\n return []\n end\n\tend", "def children\n return [] unless category?\n\n server.channels.select { |c| c.parent_id == id }\n end", "def get_comment_notifications(issue_id_or_key, comment_id)\n get(\"issues/#{issue_id_or_key}/comments/#{comment_id}/notifications\")\n end", "def group_users\n DiscussionGroupUser.where(\"discussion_group_id=? AND is_member=?\", self.id, true)\n end", "def group_watchers\n return [] unless group\n\n user_ids = group\n .notification_settings\n .where(source_or_global_setting_by_level_query(:watch)).select(:user_id)\n\n user_scope.where(id: user_ids)\n end", "def get_ids_of_all_child_jobs_old\r\n ids_of_child_jobs = []\r\n if parent_job_id.blank?\r\n child_jobs = Job.where(\"jobs.parent_job_id = #{id}\").all\r\n child_jobs.each do |child_job|\r\n ids_of_child_jobs << child_job.id\r\n end\r\n end\r\n \r\n ids_of_child_jobs\r\n end", "def subscribed_comment_ids(mock)\n comments = Comment.by(self).about(mock).all(:select => \"id, parent_id\")\n comments.map do |c|\n c.parent_id || c.id\n end\n end", "def all_notifications(options = {})\n reverse = options[:reverse] || false\n with_group_members = options[:with_group_members] || false\n as_latest_group_member = options[:as_latest_group_member] || false\n target_notifications = Notification.filtered_by_target_type(self.name)\n .all_index!(reverse, with_group_members)\n .filtered_by_options(options)\n .with_target\n case options[:filtered_by_status]\n when :opened, 'opened'\n target_notifications = target_notifications.opened_only!\n when :unopened, 'unopened'\n target_notifications = target_notifications.unopened_only\n end\n target_notifications = target_notifications.limit(options[:limit]) if options[:limit].present?\n as_latest_group_member ?\n target_notifications.latest_order!(reverse).map{ |n| n.latest_group_member } :\n target_notifications.latest_order!(reverse).to_a\n end", "def parents\n Contact.find(:all, :conditions => [\"merged_to_form_contact_id = ?\", self.id])\n end", "def notified_projects_ids\n @notified_projects_ids ||= memberships.select { |m| m.mail_notification? }.collect(&:project_id)\n end", "def group_ids_for(group)\n strong_memoize(:group_ids) do\n groups = groups_to_include(group)\n\n # Because we are sure that all groups are in the same hierarchy tree\n # we can preset root group for all of them to optimize permission checks\n Group.preset_root_ancestor_for(groups)\n\n groups_user_can_read_items(groups).map(&:id)\n end\n end", "def get_group_by_group_id(group_id)\n id = $r.get(\"group_id.to.id:#{group_id}\")\n return nil if !id\n get_group_by_id(id)\n end", "def parent\n return @parent unless @parent.nil?\n return Message.find(parent_id) unless parent_id.nil?\n end", "def get_notifications\n \t\n \t@notifs = []\n\n \tif current_user\n @notifs = Notification.where(:user_id => current_user.id, :seen => false)\n \tend\n end", "def groupchats\n @groupchat = []\n @group_comments = GroupComment.all\n @group_comments.each { |comment|\n if (comment.studygroup_id == group_comment_params[:studygroup_id].to_f)\n @groupchat.push(comment)\n end\n }\n render json: @groupchat\n end", "def groups()\n id_list = SQLQuery.new.get('groups_handler', ['group_id']).where.if('user_id', @id).send\n groups_list = []\n id_list.each do |id|\n groups_list << Groupchat.get(id['group_id'])\n end\n return Sorter.last_interaction(groups_list)\n end", "def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end", "def all_parents\n parents(all: true)\n end", "def messages(group_id)\n get(\"/groups/#{group_id}/messages\").messages\n end", "def find_relatives\n Email.where(\"conversation_id = ?\", self.conversation_id)\n end", "def group_ids\n @attributes[:group_ids]\n end", "def group_ids\n @attributes[:group_ids]\n end", "def group_ids\n @attributes[:group_ids]\n end", "def group_ids\n groups.map{|g| g.id}\n end", "def list_group\n RequestListGroup.where(:request_id => id).last\n end", "def get_ids_of_all_jobs_old\r\n ids_of_jobs = []\r\n \r\n if parent_job_id.blank?\r\n child_jobs = Job.where(\"jobs.parent_job_id = #{id}\").all \r\n ids_of_jobs << id\r\n else\r\n child_jobs = Job.where(\"jobs.parent_job_id = #{parent_job_id}\").all\r\n ids_of_jobs << parent_job_id\r\n end\r\n\r\n child_jobs.each do |child_job|\r\n ids_of_jobs << child_job.id\r\n end\r\n\r\n ids_of_jobs\r\n end", "def groups\n @parent.groups(@filter)\n end", "def parent_reply\n Reply.find_by_id(self.parent_id)\n end", "def hc_group_list(id)\n org=Org.find(id)\n org.hc_groups.group_list\n end", "def hc_group_list_all(id)\n org=Org.find(id)\n org.hc_groups.all(:order=>'group_name')\n end", "def report_children(parent_id) \n\t\tReport.find(:all, :conditions => [\"parent_id=?\",parent_id])\t\t\t\n\tend", "def sub_issues\n MatterIssue.all(:conditions => [\"parent_id = ?\", self.id])\n end", "def notification_id\n @id\n end", "def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end", "def relationships_as_parent(entity_id)\n API::request(:get, \"entities/#{entity_id}/relationships_as_parent\")\n end", "def find_parents(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['child_node_id=?', self.parent_node_id]}) do\n self.class.find(*args)\n end\n end", "def ancestors_of_filtered_projects\n projects_to_load_ancestors_of = projects.where.not(namespace: parent_group)\n groups_to_load_ancestors_of = Group.where(id: projects_to_load_ancestors_of.select(:namespace_id))\n ancestors_of_groups(groups_to_load_ancestors_of)\n .with_selects_for_list(archived: params[:archived])\n end", "def get(\n id,\n deadline: nil\n )\n return @peering_groups.get(\n id,\n deadline: deadline,\n )\n end", "def direct_children_by_id(*args)\n scope = args.last.is_a?(Hash) ? args.pop : {}\n ids = args.flatten.compact.uniq\n self.class.find_in_nested_set(:all, { \n :conditions => [\"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id} AND #{self.class.table_name}.#{self.class.primary_key} IN (?)\", ids]\n }, scope) \n end", "def list(\n filter,\n *args,\n deadline: nil\n )\n return @peering_groups.list(\n filter,\n *args,\n deadline: deadline,\n )\n end", "def set_parent_to_teacher_notification\n @parent_to_teacher_notification = ParentToTeacherNotification.find(params[:id])\n end", "def list_notifications\n BrickFTP::API::Notification.all\n end", "def list_notifications\n BrickFTP::API::Notification.all\n end", "def groups\n FfcrmMailchimp::Group.groups_for(id)\n end", "def get(\n id,\n deadline: nil\n )\n return @peering_group_resources.get(\n id,\n deadline: deadline,\n )\n end", "def test_parent\n @usergroups.each do |x|\n next if x.parentusergroupid == 0\n assert_not_nil x.parent, \"#{x.id} has no parent\"\n end\n end", "def notifications\n return notification_data_source.notifications\n end", "def by_parent_id(parent_id)\n parameters[:parent_ids] = parent_id\n self\n end", "def parents(*args)\n find_parents(:all, *args)\n end", "def currently_persisted_parent_uids\n DigitalObject.where(id: currently_persisted_parent_ids).pluck(:uid)\n end", "def list_notifications # :norobots:\n @notifications = Notification.find_all_by_user_id(@user.id, order: :flavor)\n end", "def showgrp\n @grp = params[:id].to_s\n @groups=Group.where(\"kls_parent=\"+@grp).order(\"name asc\")\n render json: @groups\n end", "def parent\n map do |q|\n q.get_parent_element\n end\n end", "def report_parent(id) \n\t\tReport.find(id)\t\t\t\n\tend", "def living_parents\n dirstate.parents.select {|p| p != NULL_ID }\n end", "def notifications\n response = self.class.get('/notifications.xml')\n notifications_array = []\n response['notifications'].each do |note|\n new_note = Notification.new(:body => note[\"body\"],\n :subject => note[\"subject\"],\n :send_at => note[\"send_at\"],\n :id => note[\"id\"],\n :escalation => note[\"escalation\"])\n note[\"recipients\"].each do |rcpt|\n new_note.add_recipient(Recipient.new(:id => rcpt[\"id\"],\n :channel => rcpt[\"channel\"],\n :address => rcpt[\"address\"],\n :status => rcpt[\"status\"],\n :send_at => rcpt[\"send_at\"]))\n end\n notifications_array << new_note \n end\n notifications_array\n end", "def fellow_group_member_ids\n user_ids = GroupUser\n .where(group_id: group_ids + owned_group_ids)\n .uniq\n .pluck(:user_id)\n\n # don't include self\n user_ids.delete(id)\n\n user_ids\n end", "def with_ancestors(id)\n ids = Set.new\n while node = nodes_by_id[id]\n ids.add(node.id)\n id = node.parent_id\n end\n ids\n end", "def comments\n \tComment.where(commentable: commentable, parent_id: id)\n end", "def group_ids\n @group_ids ||= current_user.group_ids\n end", "def get_notifications\n @notifications = Broadcast.joins(:feeds).where(feeds: {name: \"notification\"}).order(created_at: :desc).limit(20)\n end", "def allparent\n\t\t@parent = parent_user\n\t\t@all_parent = Parent.all\n\t\t@parent_children = @parent.children\n\tend", "def get_parents\n return @parents\n end", "def unread_notifications\n notifications_received.where('activities.created_at > ?', notifications_checked_at)\n end", "def root_comments\n comment_threads.where(parent_id: nil)\n end", "def root_comments\n self.comment_threads.where(:parent_id => nil)\n end", "def notification_cmt\n @notifications = current_user.notifications.where(notification_type: \"comment\").order(\"created_at desc\")\n\n\n\n # evidence_id_slot_owner = @notifications.where(obj_type: \"evidence_id_slot_owner\").group_by(&:obj_id)\n # evidence_id_slot = @notifications.where(obj_type: \"evidence_id_slot\").group_by(&:obj_id)\n # evidence_id_other_subject_owner = @notifications.where(obj_type: \"evidence_id_other_subject_owner\").group_by(&:obj_id)\n # evidence_id_other_subject = @notifications.where(obj_type: \"evidence_id_other_subject\").group_by(&:obj_id)\n # short_term_objective_id_owner = @notifications.where(obj_type: \"short_term_objective_id_owner\").group_by(&:obj_id)\n # short_term_objective_id = @notifications.where(obj_type: \"short_term_objective_id\").group_by(&:obj_id)\n # current_title_id_short_term_owner = @notifications.where(obj_type: \"current_title_id_short_term_owner\").group_by(&:obj_id)\n # current_title_id_short_term = @notifications.where(obj_type: \"current_title_id_short_term\").group_by(&:obj_id)\n # current_title_id_long_term_owner = @notifications.where(obj_type: \"current_title_id_long_term_owner\").group_by(&:obj_id)\n # current_title_id_long_term = @notifications.where(obj_type: \"current_title_id_long_term\").group_by(&:obj_id)\n\n\n render :layout => false\n end", "def ooc_group_list_all(id,group_type=nil)\n org = Org.find(id)\n group_type_cond = group_type.nil? ? nil:\"AND ooc_group_type='#{group_type}'\"\n org.ooc_groups.all(:conditions=>\"ooc_group_status!='deleted' #{group_type_cond}\",:order=>'ooc_group_type,ooc_group_name')\n end", "def items_for_parent(parent_id)\n items.find_all_by_parent_id(parent_id).sort! { |a,b| a.sequence <=> b.sequence }\n end" ]
[ "0.63251024", "0.60283846", "0.59159684", "0.5813343", "0.55704826", "0.5561866", "0.5533756", "0.5521814", "0.5468248", "0.54294735", "0.53218937", "0.5301007", "0.5291579", "0.5290425", "0.5253127", "0.5249965", "0.5249956", "0.5203", "0.5184262", "0.51752794", "0.5162705", "0.5161923", "0.5148424", "0.51476717", "0.5144523", "0.5130752", "0.5116463", "0.51036936", "0.5080544", "0.5077215", "0.50656337", "0.5058146", "0.5040958", "0.50249547", "0.50135595", "0.499772", "0.4993203", "0.49869937", "0.49723542", "0.4961922", "0.49314445", "0.49203214", "0.4913319", "0.49097422", "0.48970637", "0.4865361", "0.48650238", "0.48568353", "0.4855334", "0.48472995", "0.48467022", "0.48415294", "0.48415294", "0.48415294", "0.4824733", "0.4823325", "0.48103046", "0.48044795", "0.47948328", "0.47885993", "0.47866598", "0.4766885", "0.47623983", "0.47585806", "0.47520718", "0.4747382", "0.47416544", "0.47215995", "0.47154826", "0.47134283", "0.47056592", "0.4703431", "0.47009248", "0.47009248", "0.4699189", "0.4696009", "0.46914133", "0.46856046", "0.4685328", "0.46825254", "0.46766812", "0.46681625", "0.4665379", "0.4656713", "0.46468064", "0.4642137", "0.4641771", "0.46348172", "0.46312848", "0.46282393", "0.46250257", "0.46186095", "0.46177083", "0.46170738", "0.46165702", "0.45995554", "0.45994806", "0.4597786", "0.45898432", "0.45877406" ]
0.5774728
4
Sends immediately and without aggregation
def deliver! if pending_no_aggregation? and not user_has_unsubscribed? self.mark_as_sent! self.class.deliver_channels(self.id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_pending; end", "def send!\n @_sended = true\n self\n end", "def send!\n return if @buffer.empty?\n recursive_send(@buffer)\n @buffer.clear\n end", "def sync_send\n sync_write.putc(\"!\")\n sync_write.flush\n end", "def send_to_acx\n @result[:sent] = @transaction_class.with_status(:new).with_result(:unreconciled).inject(0) do |count, transaction|\n response = {\"command\"=> \"reconcile_#{transaction_name}\", transaction_name => transaction}\n AMQPQueue.enqueue(response)\n transaction.status = :sent\n transaction.send_times += 1\n transaction.save\n count += 1\n end\n end", "def on_sendable(sender)\n if @duration.zero? # Send immediately\n send(sender) while (sender.credit > 0) && (@sent < @count)\n elsif (sender.credit > 0) && (@sent < @count) && !@scheduled # Schedule to send after delay\n @scheduled = true\n c = sender.connection.container\n c.schedule(delay) do\n send(sender)\n @scheduled = false # Need to re-schedule for another send\n end\n end\n end", "def send(message)\n ## empty\n end", "def send_to peer\n peer.semaphore.synchronize do \n data = { id: service_id, data: self.data }.to_json\n buffer = Buffer::Writer.new data\n buffer.segments.each { |segment| peer.send_data segment }\n peer.last_used_at = Time.now\n sleep 0.3\n end\n end", "def flush\n @sendbuf_lock.synchronize {\n while @sendbuf.size > 0\n send_data(@sendbuf[0..@block_size-1])\n @sendbuf = @sendbuf[@block_size..-1].to_s\n end\n }\n end", "def execute_send\n record_start_time\n queue_attempt\n end", "def wait_for_pending_sends; end", "def flush\n # NOOP\n end", "def flush\n # NOOP\n end", "def send\n @sent_at = Time.now\n sender.publish(data, meta)\n self\n end", "def send\n puts \"a fake implementation of `send`\"\n end", "def send_pending\n if output.length > 0\n sent = send(output.to_s, 0)\n debug { \"sent #{sent} bytes\" }\n output.consume!(sent)\n return sent > 0\n else\n return false\n end\n end", "def send_deferred()\n thesize = 0\n @mutex.synchronize do\n thesize = @deferred.size\n end # synchronize\n if (thesize > 0 && up?)\n da = @deferred\n @deferred = []\n da.each { |e|\n command = e[0]\n args = e[1]\n debug \"send_deferred(#{args.class}:#{args.length}):#{args.join('#')}\"\n send(command, *args)\n }\n end\n end", "def enqueue_pending_output; end", "def send\n # discard if sampling rate says so\n if @libhoney.should_drop(self.sample_rate)\n @libhoney.send_dropped_response(self, \"event dropped due to sampling\")\n return\n end\n\n self.send_presampled()\n end", "def flush(&blk)\n queue_server_rt(&blk) if blk\n end", "def flush\n while [email protected]? || @consumer.is_requesting?\n sleep(0.1)\n end\n end", "def flush_async\n activity_buffer.flush_async\n end", "def broadcast\n queued_data = JSON.generate(@send_queue.shift)\n @sockets.each do |socket|\n socket.send queued_data\n end\n end", "def flush\n until @work_queue.empty? && @requests.zero?\n @main_queue.drain!\n sleep 0.1\n end\n end", "def send_message( message )\n\t\tself.send_queue << message\n\t\tself.reactor.enable_events( self.socket, :write ) unless\n\t\t\tself.reactor.event_enabled?( self.socket, :write )\n\tend", "def flush_async\n @last_async_flush = Time.now\n msgs = @msg_queue.flush\n return if msgs.empty?\n\n req = build_request(msgs)\n if !req.nil?\n Timber::Config.instance.debug { \"New request placed on queue\" }\n request_attempt = RequestAttempt.new(req)\n @request_queue.enq(request_attempt)\n end\n end", "def write_and_schedule sock\n outbound_data.each_with_index do |t_data,index|\n leftover = write_once(t_data,sock)\n if leftover.empty?\n outbound_data.delete_at(index)\n else\n outbound_data[index] = leftover\n reactor.schedule_write(sock)\n break\n end\n end\n reactor.cancel_write(sock) if outbound_data.empty?\n end", "def flush() end", "def flush() end", "def flush() end", "def flush!\n clear!.each do | message |\n @transport.send_message(message)\n end\n self\n end", "def run_once(send_twice: false)\n num_streamed = 0\n\n # Need at least repeatable read isolation level so that our DELETE after\n # enqueueing will see the same records as the original SELECT.\n DB.transaction(isolation_level: :repeatable_read) do\n records = StagedLogRecord.order(:id).limit(BATCH_SIZE)\n\n unless records.empty?\n RDB.multi do\n records.each do |record|\n stream(record.data)\n num_streamed += 1\n\n # simulate a double-send by adding the same record again\n if send_twice\n stream(record.data)\n num_streamed += 1\n end\n\n $stdout.puts \"Enqueued record: #{record.action} #{record.object} #{record.id}\"\n end\n end\n\n StagedLogRecord.where(Sequel.lit(\"id <= ?\", records.last.id)).delete\n end\n end\n\n num_streamed\n end", "def send_request; end", "def output_thread_step\n obj = @send_q.deq\n case obj\n when Message\n# rt_debug \"output: sending message #{obj}\" + (obj.id == :request ? \" (request queue size #{@want_blocks.length})\" : \"\")\n send_bytes obj.to_wire_form\n @time[:send] = Time.now\n when Block\n# rt_debug \"output: sending block #{obj}\"\n send_bytes Message.new(:piece, {:length => obj.length, :index => obj.pindex, :begin => obj.begin}).to_wire_form\n obj.each_chunk(BUFSIZE) { |c| send_bytes c }\n @time[:send] = Time.now\n @ulmeter.add obj.length\n# rt_debug \"sent block #{obj} ul rate now #{(ulrate / 1024.0).round}kb/s\"\n else\n raise \"don't know what to do with #{obj}\"\n end\n end", "def unsend!\n @_sended = false\n end", "def _send_result state\n unless @one_way || state.message.one_way\n # $stderr.write \"\\n _send_result #{state.result_payload.inspect}\\n\\n\"\n _write(state.result_payload, state.out_stream, state)\n true\n end\n end", "def send_a_message(conn, dest, message, headers={})\n return if not @need_sends \n @log.debug \"send_s_message starts\"\n return if not conn.connected?\n 1.upto(@max_msgs) do |mnum|\n outmsg = \"#{message} |:| #{mnum}\"\n conn.send(dest, outmsg, headers) # EM supplied Stomp method\n end\n @need_sends = false\n @need_subscribe = true\n @log.debug \"send_s_message done\"\nend", "def flushQueue() \n done=0\n while ([email protected]?) do\n done=done+1\n @sender_plugin.send_data(@data.pop)\n end\n @@log.info \"Flushed \"+done.to_s\n end", "def realtime_sender() \n loop {\n @sender_plugin.send_data(@data.pop)\n }\n end", "def _send_message data\n response << data\n end", "def ensure_one_pending_request\n return if is_disconnected?\n\n if @lock.synchronize { @pending_requests } < 1\n send_data('')\n end\n end", "def flush\n while [email protected]? || @worker.is_requesting?\n ensure_worker_running\n sleep(0.1)\n end\n end", "def autoflush\n @connection.autoflush\n end", "def peer_queued_send(peer,message)\r\n\t\t\toutbound_enqueue('puts',peer,message)\r\n\t\tend", "def send_data(data)\n super(data)\n @@log.warn \"#{self} send_data done: #{data.inspect}\"\n end", "def flush\n @socket&.flush\n end", "def send_data(data)\n super(data)\n puts \"#{self} send_data done: #{data.inspect}\"\n end", "def send_data(data)\n super(data)\n puts \"#{self} send_data done: #{data.inspect}\"\n end", "def send_event( data )\n\t\tuntil data.empty?\n\t\t\tbytes = self.socket.sendmsg_nonblock( data, 0, exception: false )\n\n\t\t\tif bytes == :wait_writable\n\t\t\t\tIO.select( nil, [self.socket], nil )\n\t\t\telse\n\t\t\t\tself.log.debug \"Sent: %p\" % [ data[0, bytes] ]\n\t\t\t\tdata[ 0, bytes ] = ''\n\t\t\tend\n\t\tend\n\tend", "def flush\n self.channel.flush\n end", "def flush\n self.channel.flush\n end", "def send\n # discard if sampling rate says so\n if @libhoney.should_drop(sample_rate)\n @libhoney.send_dropped_response(self, 'event dropped due to sampling')\n return\n end\n\n send_presampled\n end", "def flush\n # super \n # self.info \"FLUSH_CALLED\"\n end", "def local_flush\n end", "def flush_buffer\n # note we must discard cancelled timer or else we never create a new timer and stay cancelled.\n if @timer\n @timer.cancel\n @timer = nil\n end\n\n to_send = nil\n @mutex.synchronize do\n unless @buffer.empty?\n to_send = @buffer\n @buffer = ''\n end\n end\n\n if to_send\n internal_send_audit(:kind => :output, :text => to_send, :category => EventCategories::NONE)\n end\n end", "def send_single_message\n now = Time.now.to_i\n delay = Bot::Conf[:core][:throttle]\n\n if not @send_queue_fast.empty?\n str = @send_queue_fast.pop\n elsif not @send_queue_slow.empty?\n str = @send_queue_slow.pop\n end\n\n if str\n if str.length > 512\n $log.error(\"IRCConnection.send_single_message #{@name}\") { \"Message too large: #{str}\" }\n\n EM.add_timer(delay) do\n send_single_message\n end\n end\n\n send_data str\n\n if @registereed\n @history << now\n @history.shift if @history.length == 5\n\n if @history.length == 5 and @history[0] > now - 2\n delay = 2\n $log.info(\"IRCConnection.send_single_essage #{@name}\") { \"Throttling outgoing messages.\" }\n end\n end\n end\n\n @timer = EM.add_timer(delay) { send_single_message }\n end", "def write_asynchronic_msg\n begin\n puts \"=============== Advices from server ===================\" \n @advices.size.times do\n puts @advices.pop\n end\n puts \"========================================================\" \n rescue => e\n puts \"MODE PUSH: Error Writing asynchronic advices : #{e}\"\n end \n end", "def send_all(messages, dry_run: false)\n raise NotImplementedError\n end", "def flush\n return @transport.flush unless @write\n\n out = [@wbuf.length].pack('N')\n out << @wbuf\n @transport.write(out)\n @transport.flush\n @wbuf = ''\n end", "def flush\n return @transport.flush unless @write\n\n out = [@wbuf.length].pack('N')\n out << @wbuf\n @transport.write(out)\n @transport.flush\n @wbuf = ''\n end", "def send_commands_from_queue\n synchronize do\n return unless can_write?\n\n while @can_send > 0 && @send_queue.length > 0\n send_to_printer(@send_queue.pop)\n end\n end\n end", "def send_when_clear cmd_msg\n snooze = 0.05 + rand / 100 # 50-60ms\n unless @carrier_sense == 0 and @last_message < Time.now - snooze\n loop do\n @carrier_sense = 0\n sleep snooze\n break if @carrier_sense == 0\n end\n end\n @io.write cmd_msg\n end", "def send_data(data)\n @lock.synchronize do\n\n @send_buffer += data\n limited_by_polling = (@last_send + @http_polling >= Time.now)\n limited_by_requests = (@pending_requests + 1 > @http_requests)\n\n # Can we send?\n if !limited_by_polling and !limited_by_requests\n data = @send_buffer\n @send_buffer = ''\n\n Thread.new do\n Thread.current.abort_on_exception = true\n post_data(data)\n end\n\n elsif !limited_by_requests\n Thread.new do\n Thread.current.abort_on_exception = true\n # Defer until @http_polling has expired\n wait = @last_send + @http_polling - Time.now\n sleep(wait) if wait > 0\n # Ignore locking, it's already threaded ;-)\n send_data('')\n end\n end\n\n end\n end", "def send_delayed(request)\n delay_command\n\n @socket.send_bytes(request)\n @socket.receive_bytes\n\n record_last_time\n end", "def flush\n @queued = {}\n end", "def flush(allow_reconnect = false)\n queue_metric('flush', nil, {\n :synchronous => true,\n :allow_reconnect => allow_reconnect\n }) if running?\n end", "def send(*rest) end", "def send(*rest) end", "def send(*rest) end", "def send_event( data )\n\n\t\tuntil data.empty?\n\t\t\tbytes = self.socket.send( data, 0, self.multicast_address, self.port )\n\n\t\t\tself.log.debug \"Sent: %p\" % [ data[0, bytes] ]\n\t\t\tdata[ 0, bytes ] = ''\n\t\tend\n\tend", "def flush\n if !@write\n return @transport.flush\n end\n\n out = [@wbuf.length].pack('N')\n out << @wbuf\n @transport.write(out)\n @transport.flush\n @wbuf = ''\n end", "def flush\n send_batch( Traject::Util.drain_queue(@batched_queue) )\n end", "def send_and_get_data data\n send_data data\n get_data_with_timeout data.size\n end", "def send str\n\n @send_buffer.push [Time.now.to_i + @send_buffer_delay, str] if @send_buffer_delay > 0\n\n begin\n if @send_buffer_delay > 0\n Protocol.write @client, (@send_buffer.shift)[1], :debug => 5 if Time.now.to_i >= (@send_buffer.first)[0]\n else\n Protocol.write @client, str, :debug => 5\n end\n false\n rescue Exception=>e\n puts \"!D connection terminated: #{e}\" if Config.debug\n true\n end\n end", "def send(options={})\n end", "def flush\n end", "def flush\n end", "def flush\n end", "def flush\n end", "def flush\n if @state == :flushing\n Log.info(\"[offline] Starting to flush request queue of size #{@queue.size}\") unless @mode == :initializing\n unless @queue.empty?\n r = @queue.shift\n if r[:callback]\n Sender.instance.__send__(r[:kind], r[:type], r[:payload], r[:target]) { |result| r[:callback].call(result) }\n else\n Sender.instance.__send__(r[:kind], r[:type], r[:payload], r[:target])\n end\n end\n if @queue.empty?\n Log.info(\"[offline] Request queue flushed, resuming normal operations\") unless @mode == :initializing\n @mode = :online\n @state = :running\n else\n EM.next_tick { flush }\n end\n end\n true\n end", "def send_message\n self.get_message\n self.conn.get.status\n end", "def execute\n previous_time = Time.now\n\n publish_message(message(@channel, @data))\n\n @response_time = (Time.now - previous_time) * 1000 # Miliseconds\n @response_code = 1\n rescue Exception => e\n @response_code = @response_time = nil\n @response_body = e.message\n end", "def flush\n while [email protected]? || @worker.is_requesting?\n ensure_worker_running\n sleep(0.1)\n end\n end", "def flush; end", "def flush; end", "def flush; end", "def flush; end", "def flush; end", "def send(*args)\n @collector.sending_stream.puts pack(*args)\n end", "def send(args, &block)\n args = {\"obj\" => args} if !args.is_a?(Hash)\n \n my_id = nil\n raise \"No 'obj' was given.\" if !args[\"obj\"]\n str = Marshal.dump(args[\"obj\"])\n \n if args.key?(\"type\")\n type = args[\"type\"]\n else\n type = \"send\"\n end\n \n raise \"Invalid type: '#{type}'.\" if type.to_s.strip.length <= 0\n args[\"wait_for_answer\"] = true if !args.key?(\"wait_for_answer\")\n \n @out_mutex.synchronize do\n my_id = @out_count\n @out_count += 1\n \n if block\n if type == \"send\"\n if args[\"buffer_use\"]\n type = \"send_block_buffer\"\n @blocks[my_id] = {:block => block, :results => [], :finished => false, :buffer => args[\"buffer_use\"], :mutex => Mutex.new}\n else\n type = \"send_block\"\n end\n end\n end\n \n $stderr.print \"Writing #{type}:#{my_id}:#{args[\"obj\"]} to socket.\\n\" if @debug\n @out.write(\"#{type}:#{my_id}:#{str.length}\\n#{str}\")\n end\n \n #If block is broken it might never give us control to return anything - thats why we use ensure.\n begin\n if type == \"send_block\"\n loop do\n res = self.send(\"obj\" => my_id, \"type\" => \"send_block_res\")\n \n if res == \"StopIteration\"\n break\n elsif res.is_a?(Hash) and res.key?(\"result\")\n #do nothing.\n else\n raise \"Unknown result: '#{res}'.\"\n end\n \n block.call(res[\"result\"])\n end\n end\n ensure\n #Tell the subprocess we are done with the block (if break, exceptions or anything else like that was used).\n if type == \"send_block\"\n res = self.send(\"obj\" => my_id, \"type\" => \"send_block_end\")\n raise \"Unknown result: '#{res}'.\" if res != \"ok\"\n end\n \n if args[\"wait_for_answer\"]\n #Make very, very short sleep, if the result is almost instant this will heavily optimize the speed, because :sleep_answer-argument wont be used.\n sleep 0.00001\n return self.read_answer(my_id)\n end\n \n return {:id => my_id}\n end\n end", "def flush\n #\n end", "def send_queue\n worker_threaded do\n while @connected\n @queue_lock.synchronize do\n @queue.each do |to, queue|\n break if @frame.exceeded?\n if reply = queue.pop\n send_socket_reply(reply)\n end\n end\n @queue.select! { |to,queue| !queue.empty? }\n @queue = Hash[@queue.sort_by { |to,queue| queue.penalty }]\n end\n sleep @frame.sleeptime\n end\n end\n end", "def send_all(event, data)\n\t\tEM.next_tick {\n\t\t\[email protected] do |s|\n\t\t\t\ts.send(event, data) \n\t\t\tend\n\t\t}\n\tend", "def send_msg(data)\n @send_lock.synchronize{\n TCP.em.schedule { send_data(data) }\n }\n end", "def raw_send(cmd, nsock = self.sock)\n\t\tnsock.put(cmd)\n\tend", "def flush()\n wakeup()\n @flows.each_value { |f| f.flush() }\n while busy?\n sleep(0.2)\n end\n end", "def send_data(*args)\n EM.next_tick do\n @socket.send_data(*args)\n end\n end", "def flush\n Thread.exclusive do\n while !output_queue.empty? do\n write_message(output_queue.pop)\n end\n end\n end", "def send_json label, obj\n # parse before send in case of issues\n message = obj.to_json\n @publisher.send_string label, ZMQ::SNDMORE\n @publisher.send_string message\n end", "def send_to_all(message)\n EM.next_tick do\n settings.sockets.each do |s|\n s.send(message.to_json)\n end\n end\n end", "def send_io(p0) end" ]
[ "0.76913196", "0.69535685", "0.68107665", "0.6663291", "0.66390145", "0.65293276", "0.6468909", "0.6455954", "0.6440212", "0.64241695", "0.63724124", "0.630033", "0.630033", "0.6286948", "0.6219972", "0.61882526", "0.61790526", "0.6154586", "0.6142397", "0.61392266", "0.6122525", "0.61173356", "0.610972", "0.6099825", "0.60900676", "0.6071255", "0.6048118", "0.60348046", "0.60348046", "0.60348046", "0.6031287", "0.60287774", "0.6012232", "0.600671", "0.6006477", "0.59995997", "0.59966016", "0.5992147", "0.59901494", "0.59746313", "0.5959276", "0.5936283", "0.5932198", "0.5925827", "0.59075826", "0.59043956", "0.58981264", "0.58981264", "0.5892067", "0.588918", "0.588918", "0.5888141", "0.58830404", "0.5882853", "0.5879485", "0.5875361", "0.58743984", "0.5873085", "0.5855663", "0.5855663", "0.5854261", "0.5850203", "0.5839583", "0.5839474", "0.58360434", "0.58279353", "0.58235186", "0.58235186", "0.58235186", "0.5818057", "0.58108974", "0.57999814", "0.5797394", "0.5796105", "0.5787192", "0.57819813", "0.57819813", "0.57819813", "0.57819813", "0.5780795", "0.57744217", "0.5770995", "0.5767646", "0.57654256", "0.57654256", "0.57654256", "0.57654256", "0.57654256", "0.57595694", "0.57579184", "0.57571834", "0.575579", "0.5754422", "0.5752822", "0.57465905", "0.57419074", "0.57409126", "0.5738847", "0.57386", "0.57345486", "0.5726962" ]
0.0
-1
watch comment user id list without `ignore` option
def watch_comment_by_user_ids self.watch_comment_by_user_actions.where("action_option is null or action_option != ?", "ignore").pluck(:user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def watch_comment_by_user_ids\n user_ids = watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n user_ids += repository.watch_by_user_ids\n user_ids.uniq!\n\n user_ids - unwatch_comment_by_user_ids\n end", "def notify_watchers(comment_id)\n comment = Comment.find comment_id\n\n article_id = comment.article_id\n favs = Favorite.where(favorable_id: article_id)\n uid = comment.user_id\n ids = []\n favs.each do |f|\n i = f.user_id\n next if uid == i or i == 0\n ids << i\n f.updated_at = Time.now()\n f.save!\n end\n end", "def watch_comment_status_by_user_id(user_id)\n action = watch_comment_by_user_actions.where(\"user_type = 'User' and user_id = ?\", user_id).take\n return action.action_option == \"ignore\" ? \"ignore\" : \"watch\" if action\n\n repo_action = repository.watch_by_user_actions.where(\"user_type = 'User' and user_id = ?\", user_id).take\n return \"watch\" if repo_action\n \"unwatch\"\n end", "def commented_by(name)\n get_data(\"user/#{name}/commented\")\n end", "def comments_given(user_id)\n comments = Comment.where(user_id: user_id)\n end", "def watch\n klass = params[:commentable_type].constantize\n @commentable = klass.find(params[:commentable_id])\n\n authorize! :read, @commentable\n\n if request.post?\n User.create_action(:watch_comment, target: @commentable, user: current_user, action_option: \"watch\")\n else\n User.create_action(:watch_comment, target: @commentable, user: current_user, action_option: \"ignore\")\n end\n end", "def comments\n pull_comments\n @comments_list\n end", "def send_comment_notifications(comment)\n plan_detail = comment.commentable\n plan = plan_detail.plan\n users = plan.members.select { |u| u.opt_in == true }\n # exclude user making the comment\n users = users - Array(comment.user)\n\n users.each do |user|\n logger.info \"[soph] sending notification email to #{user.email} about comment.id #{comment.id}\"\n UserMailer.delay.new_comment_notification(to_user: user,\n comment_text: comment.comment,\n commenter: comment.user,\n passage_ref: plan_detail.passage_ref,\n plan_url: plan_path(plan))\n end\n end", "def get_user_comments(user_id,start,count)\n numitems = $r.zcard(\"user.comments:#{user_id}\").to_i\n ids = $r.zrevrange(\"user.comments:#{user_id}\",start,start+(count-1))\n comments = []\n ids.each{|id|\n news_id,comment_id = id.split('-')\n comment = Comments.fetch(news_id,comment_id)\n comments << comment if comment\n }\n [comments,numitems]\nend", "def get_user_comments(user_id,start,count)\n numitems = $r.zcard(\"user.comments:#{user_id}\").to_i\n ids = $r.zrevrange(\"user.comments:#{user_id}\",start,start+(count-1))\n comments = []\n ids.each{|id|\n news_id,comment_id = id.split('-')\n comment = Comments.fetch(news_id,comment_id)\n comments << comment if comment\n }\n [comments,numitems]\n end", "def show_comment_on_comment(id)\n if session[:shown_reply_to_comment].nil? ||\n\tsession[:shown_reply_to_comment].empty?\n session[:shown_reply_to_comment] = [ id ]\n else\n session[:shown_reply_to_comment] << id unless session[:shown_reply_to_comment].include? id\n end\n end", "def notifys_by_username mem\n notifys(mem).map { |doc| doc['owner_id'] }\n end", "def comments(user)\n self.design_review_comments.to_ary.find_all { |comment| comment.user == user }\n end", "def watch_for_me(m, chan, pass, name)\n create(:watches, { \"chan\" => \"##{chan}\", \"chan_pass\" => pass, \"watch_pattern\" => name, \"created_by\" => m.user.nick })\n refresh_watches\n m.reply \"gerrit notification enabled.\"\n end", "def set_user_id\n User.stats.limit(2).each do |user|\n self.user_id = user['id']\n\n # prevents us from setting back to the same user\n if self.changes['user_id'][0] != self.changes['user_id'][0]\n break\n end\n end\n end", "def like_comment(id = nil, user_id = nil)\n comment = Comment.where(:id => id).first\n if not comment.nil?\n #check to make sure user cant like comment more than once\n #users_who_liked is a string which is a comma-separated list of ids of users who like a comment\n\n users = comment.users_who_liked\n if not users.nil?\n users = comment.users_who_liked.split(\",\")\n end\n\n if not user_id.nil? and (users.nil? or not users.include?(user_id.to_s))\n comment.numlikes += 1\n users = users.join(\",\")\n users += \",\" + user_id.to_s\n comment.users_who_liked = users\n comment.save\n return SUCCESS\n end\n end\n return FAILED\n end", "def commenters\n comments = Comment.find_by_sql(\"select distinct user_id from comments \"\\\n \"where commentable_type='Package' \"\\\n \"and commentable_id=#{id}\")\n # return the commenters\n comments.map {|comment| User.find(comment.user_id)}\n end", "def user_want_notified_new_comment user_eject\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND users.mail_comments = ? AND users.id != ?\", \n self.id, \n true, \n user_eject.id)\n .collect { |l| l.user }\n end", "def notes_to_self(user_id)\n Comment.find(:all, :order => \"created_at DESC\", :conditions => [\"commentable_id = ? AND commentable_type = ? AND comment_type = ? AND user_id = ?\", id, 'Screen', 6, user_id])\n end", "def notify_comment(comment_id)\n puts \"comment parent #{comment_id}\"\n comment = Comment.find comment_id\n\n if comment.parent_id\n parent = Comment.find(comment.parent_id, include:[:user,:article])\n puts parent\n if parent and comment.user_id != parent.user_id\n commented_user= parent.user\n commented_article = parent.article\n\n if commented_user && commented_article\n\n key=\"new_comment.#{commented_article.id}.#{comment.user_id}\"\n notification = Notification.find_by_key(key)\n puts key\n\n if !notification\n Notification.create user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\"\n else\n Notification.update(notification.id,\n user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\",read:false)\n end\n end\n end\n end\n end", "def received_comments\n my_comments = []\n self.pictures.each do |picture|\n picture.comments.each do |comment|\n if comment.user_id != self.id\n my_comments.push(comment)\n end\n end\n end\n my_comments\n end", "def users_comments(post_id)\n @comments = []\n comments = Post.find(post_id).comments\n for comment in comments\n if (is_admin? || comment.commentable.user == current_user)\n @comments << comment\n end\n end\n @comments\n end", "def also_receive_kroogi_notifications_for(uid)\n u = uid.is_a?(User) ? uid.id : uid\n receive_kroogi_notifications_for!(receives_kroogi_notifications_for.map(&:id) + [u])\n end", "def comments_mentioning_user(other_user_id, options={})\n self.class.parse_comments(request(singular(user_id) + \"/comments/#{other_user_id}\", options))\n end", "def liked_by\n\t\tcomment = Comment.includes(:liked_by).find_by(id: params[:id])\n\t\t@users = comment.has_been_liked_by\t\t\t\t\t\t\t\t\t\n\tend", "def users\n watches_unique_by_user.map(&:user)\n end", "def listeners\n users_to_notify = Set.new\n users_to_notify += self.proposal.currently_awaiting_approvers\n users_to_notify += self.proposal.individual_steps.approved.map(&:user)\n users_to_notify += self.proposal.observers\n users_to_notify << self.proposal.requester\n # Creator of comment doesn't need to be notified\n users_to_notify.delete(self.user)\n users_to_notify\n end", "def edited_comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Edited comment on \" + @comment.ultimate_parent.commentable_name.gsub(\"&gt;\", \">\").gsub(\"&lt;\", \"<\")\n )\n end", "def watch_commits\n watch( \"COMMIT_EDITMSG\") do |md| \n run_all\n end\nend", "def commenters # the user who commented on you\n self.comments.map do |comment|\n comment.user\n end\n end", "def notify_all_users_in_the_conversation(current_user, video, video_owner)\n # send e-mail to the video owner unless the person commented on their own video\n # or their notification settings say not to\n unless (video.user_id == self.user_id)\n # for whatever reason, delayed_job won't send the email unless you do it as a delayed_job\n UserMailer.delay(:priority => 40).new_comment(self, video_owner, false) if video_owner.send_email_for_new_comments\n # Add event to activity feed\n UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment), \n :event_object_id => self.id,\n :user_id => video_owner.id,\n :event_creator_id => current_user.id)\n end\n # send e-mail to other people (except the video owner, or the person that just commented) \n # that have commented on the video unless their notification settings say not to\n users_we_will_not_notify = []\n users_we_will_not_notify << video_owner.id << self.user_id\n \n commenters = Comment.where('video_id = ? AND user_id NOT IN (?)', self.video_id, users_we_will_not_notify).group_by(&:user_id)\n unless commenters.blank?\n commenters.each do |comment_owner_id, comment|\n the_commenter = User.find_by_id(comment_owner_id)\n # for whatever reason, delayed_job won't send the email unless you do it as a delayed_job\n UserMailer.delay(:priority => 40).new_comment(self, the_commenter, true) if the_commenter.send_email_for_replies_to_a_prior_comment\n # Add event to activity feed\n UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment_response), \n :event_object_id => self.id,\n :user_id => the_commenter.id,\n :event_creator_id => current_user.id)\n end\n end\n end", "def list_watch(response)\n room_name = response.room.andand.name\n user_name = response.user.andand.name\n response.reply \"#{response.user.name}, list for '#{room_name || user_name}': \"\\\n \"#{list_spam(room_name, user_name)}\"\n rescue Error => e\n log.error e.inspect\n log.error response.inspect\n response.reply \"#{response.user.name}, #{e}\"\n end", "def user_comment?(user_id)\n @current_user.id == user_id\n end", "def commentsBy\n c = comments.where(:user_id => self.id).all\n if c\n c\n end\n end", "def comments\n object.comments.where(:user_id => current_user)\n end", "def liked_comments_count\n # Creating comments\n comment_ids = \"SELECT id FROM comments WHERE user_id = :user_id\"\n # Except for self like\n CommentLike.where(\"comment_id IN (#{comment_ids}) AND user_id <> :user_id\", user_id: id).count\n end", "def before_update_save(record)\n record.comments.each do |comment|\n comment.user = current_user\n end\n end", "def comments\n # event_ids = events(@user).pluck(:id)\n # Comment.where(commentable_type: \"Event\", commentable_id: event_ids, program_favorite: true)\n # events(@user).unscope(:order).order(start_date_time: :asc).each { |event| event.map { |event| event.favorite_comments.first } }\n events(@user).map { |e| e.comments.select { |c| c.event_favorite == true }.first(2) }.flatten\n end", "def change_user\n if self.id.present?\n self.user_id = Comment.find(self.id).user_id\n end\n\n end", "def trigger_comment(comment) end", "def subscribed_comment_ids(mock)\n comments = Comment.by(self).about(mock).all(:select => \"id, parent_id\")\n comments.map do |c|\n c.parent_id || c.id\n end\n end", "def feedback(user_id_param)\n if user_id == user_id_param\n Comment.find(:all, :order => \"created_at DESC\", :conditions => [\"commentable_id = ? AND commentable_type = ? AND comment_type = ?\", id, 'Screen', 5])\n else\n Comment.find(:all, :order => \"created_at DESC\", :conditions => [\"commentable_id = ? AND commentable_type = ? AND comment_type = ? AND user_id = ?\", id, 'Screen', 5, user_id_param])\n end\n end", "def update_ignores\n @ignore_users |= WhitelistedUser.all.map(&:user_id)\n end", "def subscription_on_comments user\n commentable_subscriptions.where{user_id == user.id}.first \n end", "def already_commented_by_user?(the_user)\n !self.comments.where([\"user_id = ?\", the_user.id]).empty?\n end", "def subscribe_to_comments_if_unset user\n subscription = subscription_on_comments user\n unless subscription\n subscription = build_comment_subscription user\n subscription.subscribed = true\n subscription.save!\n end\n end", "def watches_unique_by_user\n (watches +\n (cis + cis.map(&:ancestors).flatten)\n .map(&:watches)\n .flatten)\n .uniq(&:user)\n end", "def notify_users_and_add_it\n return # disabled for now\n return true if remote?\n User.find_all_by_notify_on_new_torrents(true).each do |user|\n Notifier.send_new(user,self) if user.notifiable_via_jabber?\n user.watch(self) unless user.dont_watch_new_torrents?\n end\n end", "def comments\n @list.client.get(\"#{url}/comments\")\n end", "def comments\n @list.client.get(\"#{url}/comments\")\n end", "def comments\n client.get(\"/#{id}/comments\")\n end", "def check_mentions\n if self.send(\"#{column_name}_changed?\")\n _mentions = column_value.scan(/@([\\S.]*)/)\n User.where(mention_key: [*_mentions].map(&:first).uniq).pluck(:id).each do |_user_id|\n mentions.where(user_id: _user_id).first_or_create! if notify_on_mention?\n end\n end\n end", "def comments\n @user = User.find(params[:id])\n end", "def list_owner_cannot_watch\n if self.list.user == self.user\n errors.add(:base, \"List owner cannot add it to watchlist\")\n end\n end", "def comment\n\t Hookup.where(:user_id => params[:user_id], :challenge_id => params[:challenge_id]).update_attribute(:u,:c)\n end", "def ignore_user(user)\n @ignored_ids << user.resolve_id\n end", "def ignore_user(user)\n @ignored_ids << user.resolve_id\n end", "def commenters\n # User.joins(:comments).where(comments: {discussion_id: id}).uniq\n User.where(id: comments.pluck(:author_id))\n end", "def all_comments(app_id, c=[], &progress)\n progress ||= proc { |s| sleep 1.5 } # avoid those 503/502\n\n comments_resp = comments(app_id, c.size, 10)\n c += comments_resp.comments_list.to_a\n if comments_resp.entriesCount == c.size\n c\n else\n progress.call(c.size)\n all_comments(app_id, c, &progress)\n end\n end", "def all_commenters_except(user)\n commenters = self.all_commenters\n commenters.delete_if { |commenter| commenter == user }\n end", "def listen_for_user_messages(username, client)\n loop {\n msg = client.gets.chomp\n # send a braodcast message, a message for all connected users, but not to self\n @connections[:clients].each do |other_name, other_client|\n unless other_name == username\n other_client.puts \"#{username}: #{msg}\"\n end\n end\n }\n end", "def subscribe_to_comments user\n subscription = find_or_build_comment_subscription user\n subscription.subscribed = true\n subscription.save!\n end", "def test_ID_25863_comment_on_review()\n login_as_user1\n read_all_updates\n share_review(\"outside-in\")\n logout_common\n login_as_user2\n leave_comment_on_share_review_group(\"outside-in\")\n logout_common\n login_as_user1\n verify_updates\n end", "def spam_check\n CommentSpamCheckWorker.perform_in(5.seconds, id)\n end", "def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end", "def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end", "def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end", "def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end", "def user_want_notified_new_comment_advanced user_eject\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND users.mail_comments = ? AND users.id != ? AND entr_mission_users.state = ?\", \n self.id, \n true, \n user_eject.id, \n EntrMissionUser::Status::CONFIRMED)\n .collect { |l| l.user }\n end", "def handle_changed_sis_user_ids\n if Settings.canvas_proxy.dry_run_import.present?\n logger.warn \"DRY RUN MODE: Would change #{@sis_user_id_changes.length} SIS user IDs #{@sis_user_id_changes.inspect}\"\n else\n logger.warn \"About to change #{@sis_user_id_changes.length} SIS user IDs\"\n @sis_user_id_changes.each do |canvas_user_id, new_sis_id|\n self.class.change_sis_user_id(canvas_user_id, new_sis_id)\n end\n end\n end", "def all_comments\n render :json => User.find(params[:user_id]).comments\n end", "def user_ids_who_liked_status(id)\n\t\tHTTP.get(\"https://twitter.com/i/activity/favorited_popup?id=#{id}\").body.to_s.scan(/data-user-id=\\\\\"(\\d+)/).flatten.uniq\n\tend", "def notification (user_id)\n requests = Requests.requests_for_edit_notification(user_id)\n if(requests != nil)\n senders_id = Array.new\n requests.each do |t|\n sender_id = t.senders_id\n senders_id.push sender_id\n end\n senders_id.each do |s|\n notification = Notifications.set_notification(s)\n user = Users.find_by_id(user_id).username\n requests.each do |t|\n if (t.senders_id == s)\n description = user + \" \" + \"edited his/her trip, please check it!\"\n Notifications.create_notification_trip(notification, description)\n end\n end\n end\n return\n end\n end", "def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end", "def CommentCount\n return Comment.where(:user_id => id).count\n end", "def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n puts \"this is a test\"\n end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def scan\n return nil unless @data\n \n comments = []\n \n @data.scan(/(\\d+)\\s+(\\d+)[^']+'[^']+'\\(([^\\)]+)/m).each do |m|\n comments << {\n :reaktoruser_id => m[0],\n :timestamp => m[1],\n :text => m[2],\n # TODO:title ?\n }\n Log.write_log(@@log_name, \"#<comment (reaktor_id:#{m[0]}, timestamp:#{m[1]}, text:#{m[2]})>\")\n end\n return comments\n end", "def list_watchers(user, repo_name)\n @connection.get(\"/repos/#{user}/#{repo_name}/watchers\").map do |user_data|\n GitHubApi::User.new(@connection.users, user_data)\n end\n end", "def seen(user)\n puts \"Should have updated last seen time for %s\" % user.to_s\n @add_seen.execute(user)\n end", "def index\n @comments = @secret.commentsIndex(current_user)\n #@comments = @secret.comments.asc(:created_at)\n #@comments.each do |comment|\n # if @user.friends.include?(comment.user_id)\n # comment.author_is_friend = true\n # elsif comment.user_id == @user.id\n # comment.i_am_author = true\n # end\n #end\n end", "def checkData(iUserID, iComment)\n # Nothing to test\n end", "def on_comment(msg)\n end", "def watched?(userid, taskid)\n cnt = Watchlist.where(user_id: userid).where(task_id: taskid).count\n if cnt > 0\n true\n else\n false\n end\n end", "def audio_event_comments(user)\n user = Access::Validate.user(user, false)\n AudioEventComment\n .where('(audio_event_comments.creator_id = ? OR audio_event_comments.updater_id = ?)', user.id, user.id)\n .order('audio_event_comments.updated_at DESC')\n end", "def remove_from_notification (n)\n logger.debug2 \"comment id #{id}. Notification id #{n.id}. notification key #{n.noti_key}\" if debug_notifications\n # only modify unread notifications\n return unless n.noti_read == 'N'\n cn = notifications.where(\"notification_id = ?\", n.id).first\n logger.debug2 \"cn.class = #{cn.class}\" if debug_notifications\n logger.debug2 \"cn.id = #{cn.id}\" if cn and debug_notifications\n logger.debug2 \"cn.noti_key = #{cn.noti_key}\" if cn and debug_notifications\n logger.debug2 \"cn.from_user.short_user_name = #{cn.from_user.short_user_name}\" if cn and cn.from_user and debug_notifications\n logger.debug2 \"cn.to_user.short_user_name = #{cn.to_user.short_user_name}\" if cn and cn.to_user and debug_notifications\n # find no users before and after removing this comment from notification\n old_no_users = n.api_comments.collect { |c| c.user_id }.uniq.size\n new_users = n.api_comments.find_all { |ac| ac.id != id }.collect { |ac| ac.user }.uniq\n new_no_users = new_users.size\n if new_no_users == 0\n # last user for this unread notification has been removed\n logger.debug2 \"last user for this unread notification has been removed\" if debug_notifications\n n.destroy!\n return\n end\n return if old_no_users == new_no_users # unchanged number of users => unchanged notification\n if new_no_users > 3\n # unchanged noti_key and username array. Just change number of users\n logger.debug2 \"unchanged noti_key and username array. Just change number of users\" if debug_notifications\n notifications.delete(cn) if cn\n noti_options = n.noti_options\n noti_options[:no_users] = new_no_users\n noti_options[:no_other_users] = new_no_users - 2\n n.noti_options = noti_options\n n.save!\n return\n end\n # change noti_key, username array and number of users\n if n.noti_key !~ /^([a-z_]+)_(\\d)_v(\\d+)$/\n logger.debug2 \"invalid noti key format. noti key = #{noti_key}\"\n return\n end\n logger.debug2 \"change noti_key, username array and number of users\" if debug_notifications\n noti_key_prefix, noti_key_no_users, noti_key_version = $1, $2, $3\n noti_options = n.noti_options\n (1..3).each { |i| noti_options[\"username#{i}\".to_sym] = nil }\n usernames = new_users.collect { |u| u.short_user_name }\n 0.upto(usernames.size-1).each do |i|\n noti_options[\"username#{i+1}\".to_sym] = usernames[i]\n end\n noti_options[:no_users] = new_no_users\n noti_options[:no_other_users] = new_no_users - 2\n n.noti_key = \"#{noti_key_prefix}_#{new_no_users}_v#{noti_key_version}\"\n logger.debug2 \"noti_key: old = #{n.noti_key_was}, new = #{n.noti_key}\" if debug_notifications\n n.noti_options = noti_options\n notifications.delete(cn) if cn\n n.save!\n end", "def up_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif downed_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,2).destroy #if user disliked it, now make him like it!\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif upped_before\n old_up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # if upped before, then un-up\n old_up.add_to_log(self.user,2)\n old_up.destroy\n return true\n else\n return false\n end \n end", "def consume_comments; end", "def comment_moderation(user_id, comment_id, url_title, response)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Comment.find(comment_id)\n\n mail :to => recipient(@user.email), :subject => \"25c Testimonial Notification for #{@utitle}\"\n end", "def users_for_new_pull_watchers(pull)\n users_for_new_pull(pull)\n end", "def comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Comment on \" + @comment.ultimate_parent.commentable_name.gsub(\"&gt;\", \">\").gsub(\"&lt;\", \"<\")\n )\n end", "def perform\n return unless users_to_notify.present?\n \n CommentStatus.transaction do \n users_to_notify.each do |u|\n CommentStatus.create!(comment_id: @comment.id, user_id: u.id)\n end\n Notification.create!(comment_id: @comment.id)\n end\n end", "def get_unviewed_ids(user); end", "def collect_followers twitter_id\n while @@client.application.rate_limit_status?.resources.followers.send(\"/followers/ids\").remaining == 0\n puts \"collect friends waiting...\"\n sleep(60) \n end\n \n begin\n puts \"COLLECTING Follower IDS OF #{twitter_id}\"\n result = @@client.followers.ids? :id => twitter_id, :cursor => -1\n follower_ids = result.ids\n old_cursor = 0\n next_cursor = result.next_cursor\n while old_cursor != next_cursor and next_cursor != 0\n old_cursor = next_cursor\n result = @@client.followers.ids? :id => twitter_id, :cursor => next_cursor\n follower_ids += result.ids\n next_cursor = result.next_cursor\n end \n rescue\n follower_ids = []\n tmp_person = @@client.users.show? :id => twitter_id\n SystemMessage.add_message(\"error\", \"Collect Followers\", \"Followers of Person with twitter id: \" + tmp_person.screen_name + \" could be not found.\") \n end\n if follower_ids != [] \n follower_ids_hash = Hash.new(0)\n store = PStore.new(FOLLOWER_IDS_PATH + twitter_id.to_s)\n store.transaction{store[twitter_id] = follower_ids_hash} #empty store if updating\n follower_ids.each do |follower_id|\n follower_ids_hash[follower_id] = 1 \n end\n store.transaction{store[twitter_id] = follower_ids_hash} #store values\n end\n end", "def update_comment_cache_counters\n update_attributes!(\n comment_count: comments.length,\n participants_count: watchers_count || ([self]+comments).map { |obj| obj[:author_linked_account_id] || obj[:author_name] }.uniq.length,\n )\n update_thumbs_up_count\n end" ]
[ "0.8032371", "0.69915086", "0.67108715", "0.60207844", "0.5932253", "0.58122885", "0.5720991", "0.571276", "0.57055014", "0.5673911", "0.5670132", "0.56651604", "0.56452847", "0.564112", "0.56228155", "0.5617142", "0.551847", "0.550706", "0.54384184", "0.5428817", "0.5418359", "0.54096276", "0.5408729", "0.54035777", "0.5390284", "0.53881013", "0.5364895", "0.5351451", "0.53276104", "0.5316515", "0.5310545", "0.5305525", "0.5304486", "0.5301824", "0.5297542", "0.5285951", "0.52566326", "0.52436614", "0.5242346", "0.52420473", "0.5225115", "0.5218347", "0.52004397", "0.5191366", "0.51796865", "0.51794237", "0.51790845", "0.5172086", "0.5166235", "0.5166235", "0.5162331", "0.51558506", "0.5153408", "0.5148962", "0.5137562", "0.51291305", "0.51291305", "0.5118253", "0.5112802", "0.507884", "0.507538", "0.5073005", "0.50719404", "0.5067922", "0.5067636", "0.5067636", "0.5067636", "0.5067636", "0.50481147", "0.50469816", "0.5036336", "0.5033728", "0.5033589", "0.50332856", "0.50326204", "0.5030408", "0.50096506", "0.50096506", "0.50096506", "0.50096506", "0.50096506", "0.50096506", "0.50086963", "0.50041497", "0.50026584", "0.49998835", "0.49963027", "0.49944088", "0.49874508", "0.49864915", "0.49839127", "0.49833855", "0.49807113", "0.4979826", "0.49759746", "0.49736285", "0.49728352", "0.49694407", "0.49688166", "0.496128" ]
0.77821356
1
Computes the words I have written today on my MEng report
def midnight 86_400 * (Time.now.to_i / 86_400) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date_duration_in_words(date)\n if date > DateTime.now\n t('datetime.distance_in_words.in') + ' ' + (distance_of_time_in_words DateTime.current, date)\n else\n t('datetime.distance_in_words.ago')\n end\n end", "def date_age_in_words(date)\n (distance_of_time_in_words DateTime.current, date)\n end", "def get_data_words_this_week\n words_per_day = Array.new( 7, 0 )\n \n # Get the current day of week\n dateCurrent = DateTime.now\n dayCurrent = dateCurrent.wday().to_i\n \n # Get date at the start of the week\n timeStart = Time.utc( dateCurrent.year, dateCurrent.month, dateCurrent.day )\n timeStart = timeStart - 24 * 60 * 60 * dayCurrent\n \n # Get date at the end of the week\n timeEnd = Time.utc( dateCurrent.year, dateCurrent.month, dateCurrent.day )\n timeEnd = timeEnd + 24 * 60 * 60 * ( 7 - dayCurrent )\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n dayEntry = entry.starttime.wday().to_i\n timeEntry = Time.utc( entry.starttime.year, entry.starttime.month, entry.starttime.day, entry.starttime.hour, entry.starttime.min )\n \n if( timeStart.to_i <= timeEntry.to_i && timeEnd.to_i >= timeEntry.to_i )\n words_per_day[dayEntry] += entry.words\n end\n end\n \n # Assemble Data String\n data_string = \"\"\n \n (0..(words_per_day.length - 1)).each do |i|\n data_string = data_string + words_per_day[i].to_s\n if( i < words_per_day.length - 1 )\n data_string = data_string + \",\"\n end\n end\n \n return data_string\n end", "def in_words(t)\n # to get the number of minutes subtract out days\n # Then calculate hours and subtract those out to get minutes.\n s = []\n days = t.round(4).to_i\n s << \"#{ days } day(s)\" unless days == 0\n \n remainder = t - days\n minutes = remainder * 1440.0 # number of minutes in a day\n hours = (minutes / 60.0).round.to_i\n s << \"#{ hours } hours\" unless hours == 0\n \n # round to 2 decimal places and call it\n minutes = (minutes - hours * 60).round\n s << \"#{ minutes } minutes\" unless minutes == 0\n \n if s.empty?\n s << \"now\"\n else\n s << \"ago\"\n end\n \n s.join(\" \")\n end", "def get_data_words_every_week\n words_per_day = Array.new( 7, 0 )\n \n # Get current day\n timeNow = Time.now\n time60Days = timeNow - 60 * 24 * 60 * 60\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n # Must have occurred in the last 60 days\n if( entry.starttime.time < time60Days )\n next\n end\n \n dayEntry = entry.starttime.wday().to_i\n\n words_per_day[dayEntry] += entry.words\n end\n \n # Assemble Data String\n data_string = \"\"\n \n (0..(words_per_day.length - 1)).each do |i|\n data_string = data_string + words_per_day[i].to_s\n if( i < words_per_day.length - 1 )\n data_string = data_string + \",\"\n end\n end\n \n return data_string\n end", "def frequency_in_words\n @cron_expression.frequency_in_words\n end", "def word_date()\n #Find date action was completed (from database using date_completed function)\n date_string = self.date_completed\n #Return if date does not exist\n return if date_string == nil\n date_string = self.date_completed\n #Parse date into DATETIME format\n date = DateTime.parse(date_string)\n #if the action has not been completed return string anouncing when the action\n #will occur. Logic needed to check if the date is upcoming or overdue.\n if @completed == 'f'\n if date.to_date > Date.today\n return \"DUE: #{date.strftime(\"%B %e, %Y\")}\"\n elsif date.to_date == Date.today\n return \"DUE Today\"\n elsif date.to_date < Date.today\n return \"OVERDUE: #{date.strftime(\"%B %e, %Y\")}\"\n end\n #if action has already been completed, return the date completed.\n else\n return \"#{date.strftime(\"%B %e, %Y\")}\"\n end\n end", "def linear(test_words = words)\n start_time = Time.now\n puts \"Linear Test\"\n puts curr_time\n puts \"------------------\"\n results = []\n test_words.each do |word|\n linear_doer = Wikier.new\n results << linear_doer.process(word)\n end\n puts \"------------------\"\n puts \"Finished: #{curr_time} - #{Time.now - start_time} secs\"\n return count_results(results)\n end", "def analyze phrase\n\t\t@meaningful_words = meaningful_words(phrase, \" \")\n\tend", "def time_file (doc2, estimate)\n\n#Hash to store the count of [Next], [Submit], etc.\n\tcounthash = Hash.new\n\tcounthash[\"[Next]\"] = 0\n\tcounthash[\"[Submit]\"] = 0\n\n#TO DO: update so that it finds the search criteria from the entered keywords\n# Count the number of [Next]s, [Submit, Long]s\n# and multiply by the time assigned to each keyword\n\tdoc2.paragraphs.each do |p|\n\t\tcounthash[\"[Next]\"] += 6*p.to_s.scan(/(\\[(n|N)ext)|((n|N)ext\\])/).size\n\t\tcounthash[\"[Submit]\"] += estimate*p.to_s.scan(/\\[(S|s)ubmit/).size\n\tend\n\n#prints times associated with [Next], [Submit, *], etc.\n\treturn counthash\n\nend", "def lex_en_interp_words; end", "def lex_en_interp_words; end", "def lex_en_interp_words; end", "def english?(text)\n num_english = 0\n text_words = text.split(\" \")\n text_words.each do |text_word|\n WORDS_BY_FREQUENCY.each do |dict_word|\n if text_word == dict_word.upcase\n num_english += 1\n break\n end\n end\n end\n return num_english.to_f / text_words.length > 0.75\nend", "def get_word_freq\n speech_links = get_links_to_speeches\n word_freq = Hash.new(0)\n \n speech_links.each do |link|\n speech_page = link.click\n if (speech_obj = speech_page.at SPEECH_DIV_IDENTIFIER)\n speech = speech_obj.text\n words = speech.split(' ')\n words.each{ |word| word_freq[clean_str(word)] += 1 }\n end\n end\n\n word_freq.sort_by{ |x,y| y }.reverse\n end", "def getspeechtext( date,bmr,input,activity,deficit )\n # Will return a written version of the calory calculation\n\n speechtext=\"\";\n today=false;\n is_was=\"was\";\n have_did=\"did\";\n record_ed=\"record\";\n\n today = false; \n\n if date == Date.current\n speechtext=\"Today, \";\n today=true;\n is_was=\"is\";\n have_did=\"have\"\n record_ed=\"recorded\"\n elsif date == Date.current - 1 \n speechtext=\"Yesterday, \"\n elsif date == Date.current - 7\n speechtext=\"Last week, \"\n else\n #Will say the day\n speechtext = \"On \" + date.strftime(\"%A\") + \", \" \n end\n\n if bmr > 0 \n speechtext += \"Your resting calorie requirement \" + is_was + \" \" + bmr.to_s + \" calories. \"\n end \n\n if input == 0 && activity == 0\n speechtext = speechtext + \"You \" + have_did + \" not \" + record_ed + \" any food, drinks or activities. \"\n end\n\n if input == 0 && activity != 0\n speechtext = speechtext + \"You \" + have_did + \" not \" + record_ed + \" any food or drinks. \"\n elsif input != 0\n speechtext = speechtext + \"Your food and drink intake \" + is_was + \" \" + input.to_s + \" calories. \" \n end\n\n if activity == 0 && input != 0\n speechtext = speechtext + \"You \" + have_did + \" not \" + record_ed + \" any activities. \"\n elsif activity != 0\n speechtext = speechtext + \"You burnt \" + activity.to_s + \" calories through exercise. \"\n end\n\n\n if (deficit > (bmr*0.05)) && (input > 0 || activity > 0)\n if today \n speechtext = speechtext + \"You need to burn off \" + deficit.to_s + \" calories, if you want to maintain your current weight. \"\n else\n speechtext = speechtext + \"Your intake was \" + deficit.to_s + \" calories greater than you needed, possibly leading to weight gain.\"\n end \n elsif (deficit < (0-(bmr*0.05))) && (input > 0 || activity > 0)\n if today \n speechtext = speechtext + \"You can eat or drink \" + (0-deficit).to_s + \" calories more, and maintain your current weight.\"\n else \n speechtext = speechtext + \"You burnt \" + (0-deficit).to_s + \" calories more than you needed, possibly leading to weight loss. \"\n end \n end\n\n if input>0 && activity>0\n speechtext = speechtext + \" Well done using Evos, your health pal. \"\n else \n speechtext = speechtext + \" To get the best out of me, please do make sure you use me every day.\" \n end\n\n speechtext\n\n end", "def days_to_words(days)\n period_in_words = case days\n when 27..32 then 'month'\n when 87..92 then 'three months'\n when 179..184 then 'six months'\n when 361..367 then 'year' # should be 361 on lower bound\n when 544..549 then 'year and a half'\n when 728..732 then 'two years'\n when 1822..1827 then 'five years'\n when 3649..3653 then 'ten years'\n when 7301..7307 then 'two decades' # add a bit of extra buffer to make sure nothing gets out\n else days.to_s + ' days'\n end\n return period_in_words\n end", "def get_data_words_each_week\n \n # Get Current Year\n yearCurrent = Time.now.year\n \n # One entry for each week of the year\n words_per_week = Array.new( 52, 0 )\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n if( yearCurrent != entry.starttime.year )\n next\n end\n \n week = entry.starttime.strftime( \"%W\" ).to_i\n puts \"Week: #{week} Time: #{entry.starttime}\"\n \n words_per_week[week] = words_per_week[week] + entry.words\n end\n \n # Assemble Data String\n data_string = \"\"\n \n (0..(words_per_week.length - 1)).each do |i|\n data_string = data_string + words_per_week[i].to_s\n if( i < words_per_week.length - 1 )\n data_string = data_string + \",\"\n end\n end\n \n puts data_string\n return data_string\nend", "def word_count\n\t\tputs \"There are #{@dictionary_analyzer.word_count(@dictionary)} words in this dictionary.\"\n\tend", "def eval_date\n # FIXME: Make pref?\n h = Hash[\"mo\", 1, \"di\", 2, \"mi\", 3, \"do\", 4, \"fr\", 5, \"???\", 6]\n h.merge(Hash[\"mo\", 1, \"tu\", 2, \"we\", 3, \"th\", 4, \"fr\", 5, \"???\", 6])\n a = description.strip.downcase\n a = \"???\" if a.length < 3 || !h.include?(a[0..1])\n day = h[a[0..1]]\n time = a[2..a.length-1].strip.rjust(3, \"0\")\n \"#{day} #{time}\"\n end", "def whisper_words(words)\n\nend", "def period_in_words\n case recurring_month\n when 12\n 'yearly'\n when 1\n 'monthly'\n when 0\n \"once\"\n else\n \"every #{recurring_month} months\"\n end\n end", "def words\n words = @phrase.split(\" \")\n words.each do |word|\n translate(word)\n end\n end", "def relative_word_time(time)\n now = Time.now\n if time - now > 0\n 'in ' + distance_of_time_in_words(time, now)\n elsif now - time > 7.days\n 'on ' + l(time, format: :short)\n else\n distance_of_time_in_words(time, now) + ' ago'\n end\n end", "def display_words\n words = self.dictionary.map do |dictionary_entry|\n dictionary_entry.word.lexical_item\n end\n words \n end", "def time_ago_in_words(once_upon_a)\n dt = Time.now.to_f - once_upon_a.to_f\n\n words = nil\n\n TIME_INTERVALS.each do |pair|\n mag, term = pair.first, pair.last\n if dt >= mag\n units = Integer(dt / mag)\n words = \"%d %s%s\" % [units, term, units > 1 ? 's' : '']\n break\n end\n end\n\n if words\n words\n else\n once_upon_a.strftime(\"%Y-%m-%d\")\n end\n end", "def in_words\n num_in_words = \"\"\n ones, tens = \"\", \"\"\n number = self\n return \"zero\" if number == 0\n if number % 100 > 9 && number % 100 < 20\n # we've hit a teen number\n tens = TEENS[number % 100]\n num_in_words.insert(0, tens)\n else\n ones = ONES[number % 10]\n number -= number % 10\n num_in_words.insert(0, ones) if !ones.nil?\n\n if number % 100 > 0\n tens = TENS[number % 100]\n number -= number % 100\n num_in_words.insert(0, tens + \" \")\n end\n end\n\n if (number%1000) >= 100 && (number%1000) < 1000\n hundreds = ONES[(number % 1000)/100] + \" hundred\"\n number -= number % 1000\n num_in_words.insert(0, hundreds + \" \")\n end\n\n greater_than_num = \"\"\n if number >= 1000000000000\n trillions = (number / 1000000000000).in_words + \" trillion\"\n number -= (number / 1000000000000) * 1000000000000\n greater_than_num << trillions + \" \"\n end\n if number >= 1000000000\n billions = (number / 1000000000).in_words + \" billion\"\n number -= (number / 1000000000) * 1000000000\n greater_than_num << billions + \" \"\n end\n if number >= 1000000\n millions = (number / 1000000).in_words + \" million\"\n number -= (number / 1000000) * 1000000\n greater_than_num << millions + \" \"\n end\n if number >= 1000\n thousands = (number / 1000).in_words + \" thousand\"\n number = 0\n greater_than_num << thousands + \" \"\n end\n (greater_than_num + num_in_words).strip\n end", "def e_words(str)\r\n \r\nend", "def words_per_project\n respond_with Translation.total_words_per_project\n end", "def time_ago_in_words_with_word(date, word = \"ago\")\n \"#{time_ago_in_words(date)} #{word}\"\n end", "def calculate_word_frequency\n # not a class method, it is used to poulate what are essentially properties on an instance of the class\n #word_frequency = @content.split(\" \").each_with_object(Hash.new(0)) {|word,count| count[word] +=1}\n word_frequency = Hash.new(0)\n #puts word_frequency\n @content.split.each do |word|\n word_frequency[word] += 1\n end\n\n\n @highest_wf_count = word_frequency.values.max\n @highest_wf_words = word_frequency.select { |word, freq| freq == @highest_wf_count }.keys\n @highest_wf_words\n\n end", "def ymmText\n ans = date_of_manufacture\n ans += ' ' + make.name \n\tif model\n \tans += ' ' + model.name\n\tend\n if submodel\n ans += ' ' + submodel.name\n end\n return ans\n end", "def translate words\n\tarray = words.split \n\ti = 0\n\ttotal = \"\"\n\twhile i < array.length\n\t\tstring = array[i]\n\t\tif string[0] =~ /[aeiou]/\n\t\t\tresult = string + \"ay\"\n\t\telse\n\t\t\tletters = \"\"\n\t\t\tcounter = 0\n\t\t\tnumberConsanants = 0\n\t\t\twhile counter < string.length\n\t\t\t\tif string[counter] =~ /[aeiou]/\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tletters = letters + string[counter]\n\t\t\t\t\tif string[counter] == 'q' && string[counter+1] == 'u'\n\t\t\t\t\t\tletters = letters + 'u'\n\t\t\t\t\t\tnumberConsanants = numberConsanants + 1\n\t\t\t\t\tend\n\t\t\t\t\tnumberConsanants = numberConsanants + 1\n\t\t\t\tend\n\t\t\t\tcounter = counter + 1\n\t\t\tend\n\t\t\tresult = string.slice(numberConsanants, string.length) + letters + \"ay\"\n\t\tend\n\t\ttotal = total + result\n\t\tif i != array.length - 1\n\t\t\ttotal = total + \" \"\n\t\tend\n\t\ti = i + 1\n\tend\n\ttotal\nend", "def kase_activity_in_words(kase)\n \"last active %{time} ago\".t % {:time => \"\"}\n end", "def duration_in_words(started_at, finished_at)\n # difference in seconds\n diff = (finished_at - started_at).to_i\n\n hours = hours_part(diff)\n minutes = minutes_part(diff)\n seconds = seconds_part(diff)\n\n time_pieces = []\n\n time_pieces << I18n.t(:'datetime.distance_in_words.hours_exact', :count => hours) if hours > 0\n time_pieces << I18n.t(:'datetime.distance_in_words.minutes_exact', :count => minutes) if hours > 0 || minutes > 0\n time_pieces << I18n.t(:'datetime.distance_in_words.seconds_exact', :count => seconds)\n\n time_pieces.to_sentence\n end", "def analyze_words(words)\n pos_count = 0\n neg_count = 0\n neu_count = 0\n search_dictionary(words).each do |w|\n case w\n when 1\n pos_count +=1\n when -1\n neg_count +=1\n when 0\n neu_count +=1\n end\n end\n {positive: pos_count, negative: neg_count, neutral: neu_count}\n end", "def tfreq word, labellist\n @tfreq=0\n labellist.each do |doc|\n @tfreq+=doc[word] if doc.has_key?(word)\n end\n @tfreq\nend", "def search_terms_summary terms_and_scores \n return \"<span class='none_text'>No search queries during this period</span>\" if terms_and_scores.empty?\n words=terms_and_scores.collect{|ts| \"#{ts[0]}(#{ts[1]})\" }\n words.join(\", \")\n end", "def search_terms_summary terms_and_scores \n return \"<span class='none_text'>No search queries during this period</span>\".html_safe if terms_and_scores.empty?\n words=terms_and_scores.collect{|ts| \"#{h(ts[0])}(#{ts[1]})\" }\n words.join(\", \").html_safe\n end", "def get_words(qty = 30)\n raise \"Error on quantity of words.\" if qty < 1\n\n words = []\n\n qty.times do\n words += [apply_replacements(@evaluated_expression.sample)]\n end \n\n words\n end", "def words_for_last\n @words_for_last\n end", "def word_count_engine(document)\n document = document.gsub(/[^ 0-9A-Za-z]/, '').downcase.split(' ')\n\n store = {}\n max = 0\n\n document.each do |element|\n if store[element]\n store[element] += 1\n max = [store[element], max].max\n else\n store[element] = 1\n max = 1 if max == 0\n end\n end\n\n buckets = Array.new(max) { [] }\n\n store.each do |key, value|\n buckets[max - value].push([key, value.to_s])\n end\n\n buckets.flatten(1)\nend", "def votes_count_localized_word(record)\n votes_count_in_words(record).split(' ').last\n end", "def words_count\n get_at_words_count + \n get_ata_words_count + \n get_noun_words_count + \n get_adjective_words_count\n end", "def frequency(number_of_hours)\n word_count = Word.where(\"name = ? AND story_date > ?\", self, Time.now - number_of_hours.hours).count\n total_words = Word.where(\"story_date > ?\", Time.now - number_of_hours.hours).count\n return word_count.to_f / total_words.to_f\n end", "def printWords(file, lines, htmlOutput=false) \ntranslated = []\nFile.open(\"german_vocabulary.c\") { |german| \n translated = german.readlines.collect { |l|\n if l =~ /\\{\"[^\"]*\", (\"[A-Z0-9_]+\")/ then\n $1\n end\n }.uniq\n}\n\ncount = 0\nlines.each { |line|\n if line =~ /\\#define.*NAM_.*(\".*\")/ then\n if not translated.include? $1 then\n puts $1+' nicht uebersetzt!' unless htmlOutput\n count += 1\n end\n end\n}\n\nif htmlOutput then\n puts '<tr>'\n puts ' <td>'+file+'</td>'\n puts ' <td align=\"right\">'+lines.size.to_s+'</td>'\n puts ' <td align=\"right\">'+count.to_s+'</td>'\n puts ' <td align=\"right\">'+sprintf(\"%4d\", lines.size-count)+'</td>'\n puts ' <td align=\"right\">'+sprintf(\"%2g\", (lines.size-count)*100.0/lines.size)+'</td>'\n puts '</tr>'\nelse\n puts\n puts \"Gesamtzahl: \"+sprintf(\"%4d\", lines.size.to_s)\n puts \"Nicht uebersetzte Wort: \"+sprintf(\"%4d\", count.to_s)\n puts \"Uebersetzte Worte: \"+sprintf(\"%4d\", lines.size-count)\n puts \"Prozentual uebersetzt: \"+sprintf(\"%2g\", (lines.size-count)*100.0/lines.size)\nend\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 report_words_per_minute\n self.test_session.words_per_minute\n end", "def common_word\n words = {}\n record.records.each do |record|\n record.title.split(' ').each do |word|\n words[word] = 0 if words[word].nil?\n words[word] += 1\n end\n end\n return if words.empty?\n words.sort.first[0]\n end", "def process_wikiwords(full_document)\n doc = full_document.dup\n doc.gsub!(/\\[\\[([A-Za-z0-9_\\-\\ ]+)\\]\\]/) do |match|\n name = $1\n link = name.gsub(/\\s+/, '-')\n if md = /^(\\d\\d\\d\\d-\\d\\d-\\d\\d-)/.match(link)\n date = md[1].gsub('-', '/')\n link = link.sub(md[1], date)\n end\n \"[#{name}](#{link}.html)\"\n end\n return doc\n end", "def edgy_words(hash)\n return hash if hash.keys.size <= 15\n\n h = hash.dup\n h.each do |word, prob|\n h[word] = 1.0 - h[word] if h[word] >= 0.5\n end\n arr = h.to_a.sort{|x, y| x[1] <=> y[1]}\n words = arr[0, 15].collect{|x| x.first}\n\n result = words.inject({}){|h, w| h[w] = hash[w]; h}\n end", "def format_words\n return \"@words = #{@words.inspect}\"\n end", "def wordCollector(pageName)\n\twordHash = Hash.new 0\n\twords = Array.new\n\n\tcurrentPage = Nokogiri::HTML(open(pageName, :allow_redirections => :safe))\n\tpageText = currentPage.css('p').to_s\n\twords = pageText.split(/\\W+|\\d/)\n\twords.each do |string|\n\t wordHash[string] += 1\n\tend\n\treturn Website.new(pageName, wordHash, words.length)\nend", "def analysis\n @str = params[:text] ||= '解析対象の文字列'\n @words = Tag.counter(Tag.generate(@str))\n end", "def page_sentiment (positive, negative)\n totalwords = 0\n count = 0.0\n sentimentwords = 0.0\n if(@thewords)\n #This is the main loop, if each word is positive or negative in the document adjust variables accordingly.\n @thewords.each do |word|\n totalwords+= 1\n if positive.map(&:downcase).include? word[0].downcase\n # puts word[0]\n count +=word[1]\n sentimentwords +=word[1]\n elsif negative.map(&:downcase).include? word[0].downcase\n # puts word[0]\n count -=word[1]\n sentimentwords +=word[1]\n end\n end\n end\n ratio = count/sentimentwords\n if (ratio > 0.10)\n count = 1\n elsif (ratio < -0.10)\n count = -1\n else\n count = 0\n end\n return count\n 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 calculate_nice_words (users)\n\thappy_word = Hash.new(0)\n\tfile_name = \"happywords.txt\"\n\tyour_happy_Words = []\n\tFile.open(file_name, \"r\").each_line do |line|\n\t\tline.strip.split(' ' || '\\t').each do |s|\n\t\t\thappy_word[s] = 1\n\t\tend \n\tend\n\thappy_count = 0\n\tusers.each do |user|\n\t\tuser[\"text\"].strip.split(' ').each do |s|\n\t\t\tif happy_word[s] == 1 then\n\t\t\t\tnewWordObj= Word.new(s, user[\"text\"])\n\t\t\t\tyour_happy_Words.push(newWordObj)\n\t\t\tend\n\t\tend\n\tend\n\tyour_happy_Words\nend", "def word_stats(force_recount = false)\n process_words unless @num_words && @num_words > 0 && force_recount\n {\n :num_words => @num_words,\n :num_sentences => @num_sentences,\n :num_blanks => @num_blanks,\n :num_blanks_by_type => @num_blanks_by_type\n }\n end", "def word_counter(mots,dictionnaire)\n words = word_counter.downcase.split(\" \")\n #puts words => [\"howdy\",....\"going?\"]\n frequencies = Hash.new(0)\n words.each{ |mot| \n if mot.include?(dictionnaire) #si le mot est dans le dictionnaire\n frequencies[mot] += 1 #si oui\n end\n \n }\n puts frequencies\nend", "def word_freq(text)\n frequency = {}\n unique_words(text).each do |word|\n frequency[word] = 0\n end\n split_normalise(text).each do |word|\n frequency[word] += 1\n end\n frequency\nend", "def main()\n mylist = [\"Perl and Raku belong to the same family.\",\n \"I love Perl.\",\n \"The Perl and Raku Conference.\"\n ]\n puts max_words(mylist)\n\n mylist = [\"The Weekly Challenge.\",\n \"Python is the most popular guest language.\",\n \"Team PWC has over 300 members.\"]\n puts max_words(mylist)\nend", "def _search_text\n [_concatenated_brand,\n _concatenated_description,\n _concatenated_sell_unit,\n classic_mbid\n ].compact.map { |w| w.hanize.split(' ') }.flatten.uniq.reject { |w| w.size < 3 || self.class.stop_words.include?(w) }.join(' ')\nend", "def countWords(href)\n\n # Use mechanize to follow link and get contents\n mechanize = Mechanize.new\n mechanize.user_agent_alias = \"Windows Mozilla\"\n mechanize.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n mechanize.redirect_ok = true\n\n begin\n\n page = mechanize.get(href)\n\n rescue\n\n return { :Positive => 0, :Negative => 0, :Symbol => @symbol, :Date => Time.now.strftime(\"%d/%m/%Y\")}\n\n end\n\n # Use Nokogiri to get the HTML content of a link.\n # html_doc = Nokogiri::HTML(open(href,:allow_redirections => :all, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE))\n\n html_doc = Nokogiri::HTML(page.content)\n\n # Look for all <p> tags and store their contents\n paragraph = html_doc.css(\"p\").inner_text\n\n # Split the content in single sentences and store in array\n strings = Array[]\n strings = paragraph.split('.')\n\n #Counters for positive and negative words\n positiveCounter = 0\n negativeCounter = 0\n\n # Iterate the sentence array\n strings.each do |s|\n\n # If the sentence includes the @symbol or the @symbolName, split in single words\n if s.upcase.include?(@symbolName) or s.upcase.include?(@symbol)\n\n words = Array[]\n words = s.gsub(/\\s+/m, ' ').strip.split(\" \")\n\n # Iterate the words array\n words.each do |s2|\n\n # Count word if it equals a positive words\n @positiveWordsArray.each do |line|\n if s2.upcase == line\n Scraper.logger.info s2\n #puts s2\n positiveCounter = positiveCounter + 1\n end\n end\n\n # Count word if it equals a negative words\n @negativeWordsArray.each do |line|\n if s2.upcase == line\n Scraper.logger.info s2\n #puts s2\n negativeCounter = negativeCounter + 1\n end\n end\n\n end\n\n end\n\n end\n\n Scraper.logger.info positiveCounter\n Scraper.logger.info positiveCounter\n\n return { :Positive => positiveCounter, :Negative => negativeCounter, :Symbol => @symbol, :Date => Time.now.strftime(\"%d/%m/%Y\")}\n\n end", "def get_words(mensagem_texto)\n mensagem_texto.scan(/[\\w-]+/)\nend", "def deadline_as_words\n\t\ttoday = Time.now.localtime.to_date\n\t\tcase self.deadline\n\t\twhen nil\n\t\t\t'indefinido'\n\t\twhen today\n\t\t\t'hoy'\n\t\twhen today + 1\n\t\t\t'mañana'\n\t\telse\n\t\t\tself.deadline\n\t\tend\n\tend", "def to_words\n num_hash = {\n 20 => \"twenty\",\n 19=>\"nineteen\",\n 18=>\"eighteen\",\n 17=>\"seventeen\",\n 16=>\"sixteen\",\n 15=>\"fifteen\",\n 14=>\"fourteen\",\n 13=>\"thirteen\",\n 12=>\"twelve\",\n 11 => \"eleven\",\n 10 => \"ten\",\n 9 => \"nine\",\n 8 => \"eight\",\n 7 => \"seven\",\n 6 => \"six\",\n 5 => \"five\",\n 4 => \"four\",\n 3 => \"three\",\n 2 => \"two\",\n 1 => \"one\"\n }\n text = num_hash[1]\n puts text\nend", "def output_words\n if @number <= self.class.total_included_words\n convert_paragraphs_to_words(self.class.included_paragraphs_joined)\n else\n repeat = (@number / self.class.total_included_words.to_f).ceil\n convert_paragraphs_to_words((PARAGRAPHS * repeat).join(\"\\n\\n\"))\n end\n end", "def kase_description_in_words(kase)\n result = []\n result << followers_count_in_words(kase).to_s.capitalize\n\t result << replies_count_in_words(kase)\n\t result << kase_type_and_time_in_words(kase)\n\t result.compact.map {|m| m.to_s.strip}.reject {|i| i.empty?}.join(', ')\n end", "def names_of_people_who_passed_english(results_set)\nend", "def calculate_term_frequencies\n results = []\n\n @tokenized_documents.each do |tokens|\n document_result = {}\n tokens[:words].each do |term, count|\n document_result[term] = (count/tokens[:total_count].to_f).round(6)\n end\n\n results << document_result\n end\n\n results\n end", "def completed_text_extraction\n end", "def top_words\n\t\ttgr = EngTagger.new\n\t\tdesc_string = @desc_array.join(\" \").downcase.delete \".\"\n\n\t\t#Adds parts of speech to each word in the descriptions\n\t\ttagged = tgr.add_tags(desc_string)\n\t\t#Collects all words tagged as nouns or noun phrases with the number of times they occur\n\t\tnouns = tgr.get_noun_phrases(tagged)\n\t\t#collects all words tagged as adjectives with the number of times they occur\n\t\tadj = tgr.get_adjectives(tagged)\n\t\tif nouns #prevents app from breaking with invalid username\n\t\t\t@valid_username = true\n\t\t\t#Combines noun phrases and adjectives into one hash\n\t\t\twords = nouns.merge(adj)\n\t\t\t#Removes some meaningless words as keys. Didn't remove them earlier because I imagine some could potentially still be useful in noun phrases\n\t\t\twords = words.except(\"beer\", \"brew\", \"flavor\", \"first\", \"character\", \"finish\", \"color\", \"style\", \"taste\", \"aroma\", \"aromas\", \"brewery\", \"brewing\", \"%\", \"other\", \"one\", \"perfect\", \"bottle\", \"flavors\", \"abv\", \"profile\", \"new\", \"notes\", \"great\", \"delicious\", \"beers\", \"such\", \"alcohol\")\n\t\t\t#Exclude words with count of 2 (for now) or fewer\n\t\t\tvalid_keys = []\n\t\t\twords.each do |k,v| \n\t\t\t\tif v > 2\n\t\t\t\t\tvalid_keys.push(k)\n\t\t\t\tend\t\n\t\t\tend\n\t\t\twords.slice!(*valid_keys)\n\t\t\t#Converts hash into array and sorts with highest value first\n\t\t\t@words_array = words.sort {|k,v| v[1]<=>k[1]}\n\t\t\t@words_array = @words_array.first(60)\n\t\t\tbubble_chart_hack\n\t\telse\n\t\t\t@valid_username = false\n\t\tend\n\tend", "def calculate\n document_frequency.each_with_object({}) do |(word, freq), idf|\n idf[word] = Math.log(@corpus.size/freq)\n end\n end", "def wookie_sentence; end", "def summary\n\t\tsummary = \"\"\n\t\tget = @text.split(/ /)\n\t\tget.each_index do |word|\n\t\t\tsummary << get[word] << \" \" if word < 10\n\t\tend\n\t\tsummary.strip\n\tend", "def word_frequency\n @word_use = Hash.new(0)\n words.each { |w| @word_use[w] += 1 }\n @word_use\n end", "def word_yeller(sentence)\n\n\nend", "def calculate_wcfts(target_word, tar_char_scrs)\n scores_sum = 0.0\n return scores_sum if target_word.nil?\n char_arr = target_word.entry.scan(/./)\n char_arr.each { |entry| scores_sum += tar_char_scrs[entry] }\n scores_sum / target_word.entry.length\nend", "def get_my_words\n # Words associated with online harassment\n trigger_words = [\"rape\",\"murder\",\"nigger\",\"slut\",\"whore\",\"bitch\",\"cunt\",\"kill\",\"die\",\"testword\"]\n my_words = Word.where(user_id: self.id)\n my_words.each do |word|\n trigger_words << word.word\n end\n return trigger_words\n end", "def persist_words!\n start = Time.now\n # gdbm is a fast, simple key-value DB\n require 'gdbm'\n gdbm = GDBM.new('db/word_count.db')\n count = 0\n read_text_into_hash.each do |k, v|\n # gdbm stores values as strings, so values have to be converted to\n # integers, added together and then converted to strings again\n # to be stored\n current_value = gdbm[k].to_i\n gdbm[k] = (v.to_i + current_value).to_s\n count += 1\n end\n print_status(start, count)\n end", "def process_words\n reset_counts\n # iterate through radlib_array and add counts\n self.each do |w|\n Rails.logger.debug(w.inspect)\n case w[\"type\"]\n when \"word\"\n @num_words += 1\n if w[\"selectable\"] && w[\"selected\"]\n @num_blanks += 1\n # fix for old radlibs\n unless w[\"user_pos\"]\n w[\"user_pos\"] = w[\"predicted_pos\"]\n end\n type = w[\"user_pos\"].gsub(\"-\", \"_\").to_sym\n Rails.logger.debug(type)\n @num_blanks_by_type[type] += 1\n end\n when \"whitespace\"\n # don't need to do anything here\n when \"punc\"\n @num_sentences += 1 if w[\"text\"] == \".\" || w[\"text\"] == \"!\" || w[\"text\"] == \"?\"\n end\n end\n end", "def score(literatureText, wordsToExclude)\n excluded_word_hash = Hash.new(0)\n wordsToExclude.each do |key| \n excluded_word_hash[key] = 1\n end\n word_list = Array.new\n \n \n freq_hash, max = convert_to_freq_hash(literatureText.split(\" \"), excluded_word_hash) \n \n freq_hash.each do |k, v| \n word_list << k if v == max \n end\n \n word_list\nend", "def word_count_mr\n self.words = Hash[self.class.where(:_id=>self.id).map_reduce(MapReduce::word_count(\"title\"),MapReduce::word_count_reduce).out(inline:1).collect { |x,y| [ x[\"_id\"],x[\"value\"][\"count\"].to_i ] }]\n end", "def long_word_count(text)\n \nend", "def compile_wls_script(words, wts_scores_obj)\n max_length = max_word_length(words)\n words.each do |word|\n score = (max_length - word.entry.length.to_f) / max_length\n wts_scores_obj[word.id] += score * WLSW\n end\nend", "def texts_score(text1, text2)\n words1 = text1.downcase.scan(/[a-zA-Z]+/) - noise_words\n words2 = text2.downcase.scan(/[a-zA-Z]+/) - noise_words\n common_words = words1 & words2\n p common_words\n common_words.length.to_f / (words1.length + words2.length)\n end", "def create_title(word)\n\tcurrent = word\n\tword_num = 1 # begin word number at one\n\ttitle = \"\" # title begins as empty\n\ttitle += word # add current word\n\twhile word_num !=20 # while we have less than 20 words...\n\t\t\tif ($bigrams.has_key?(current)) # if the word exists in the bigram\n\t\t\t\tif (mcw(current) == nil)\n\t\t\t\t\t# do nothing and exit\n\t\t\t\t\tword_num = 20\n\t\t\t\telse\n\t\t\t\t\taddition = mcw(current) # thing to add is mcw\n\t\t\t\t\ttitle += \" \" # add space for readability\n\t\t\t\t\ttitle += addition # add addition to the title\n\t\t\t\t\tcurrent = addition # set current to the new wordtitle += addition # add the mcw\n\t\t\t\t\tword_num += 1 # increment by one and then go throuh\n\t\t\t\tend\n\t\t\telse word_num = 20 # otherwise, we exit\n\t\t\tend\n\t\tend\n\t\treturn title\nend", "def word_frequency(text)\n norm_array = normalize(text).to_a\n freq = { }\n norm_array.each_with_object(Hash.new(0)){|key,hash| hash[key] += 1}\nend", "def mltify_text text\n \n coder = HTMLEntities.new\n text = coder.decode text\n text = sanitize( text, okTags = \"\" )\n text = coder.encode text\n words = text.downcase.gsub( /[^A-za-z0-9\\s'\\-#]/, \" \" ).split( /\\s/ )\n \n final_words = []\n words.each do |w|\n unless stop_words.include? w\n final_words << w\n end\n end\n RAILS_DEFAULT_LOGGER.info final_words.join( ' ' ).squish\n final_words.join( ' ' ).squish\n end", "def score\n\t\t@meaningful_words.count\n\tend", "def search_terms_summary(terms_and_scores)\n return \"<span class='none_text'>No search queries during this period</span>\".html_safe if terms_and_scores.empty?\n words = terms_and_scores.collect { |ts| \"#{h(ts[0])}(#{ts[1]})\" }\n words.join(', ').html_safe\n end", "def existing_words\n draw_current = draw\n p \"The 7 letters drawn are:\"\n p draw_current\n p \"-\"*70\n\n combinations = combine(draw_current).flat_map{ |w| w.permutation.to_a}.uniq.map { |e| e.join }\n combinations.map{|i| search(i, UPPER_BOUND_INI, LOWER_BOUND_INI, NO_ITERATION_INI)}.flatten.reject{|x| x==nil}\nend", "def get_infinitives(rus_words)\n shell_output = \"\"\n IO.popen('mystem.exe -nl', 'r+') do |pipe|\n rus_words.each { |word|\n pipe.puts (word)\n }\n pipe.close_write\n\n shell_output = pipe.read\n end\n\n shell_output.force_encoding(Encoding::UTF_8)\n\n result= shell_output.split(\"\\n\")\n i= 0\n infinitives= Array.new(@rus_sentence.length) { Array.new(0) }\n result.each { |inf|\n infinitives[i]= inf.split('|')\n i+= 1\n }\n infinitives\n end", "def create_wind_text\n text = I18n.t(\"forecast_text.wind.text_maximum\")\n text.concat((@extreme_values.maximum * 3.6).ceil.to_s)\n text.concat(I18n.t(\"forecast_text.wind.text_maximum_unit\"))\n text.concat(create_prevalent_direction_text)\n text.concat(I18n.t(\"forecast_text.wind.text_mean\"))\n mean = (@extreme_values.maximum + @extreme_values.minimum) / 2.0\n text.concat((mean * 3.6).ceil.to_s)\n text.concat(I18n.t(\"forecast_text.wind.text_finish\"))\n return text\n end", "def words(n)\n str = ''\n\n # process < 100\n if n.zero? || n < 20\n str = Words[n]\n else\n d, n = n / 10, n % 10\n str = Words[d*10]\n str += '-' + Words[n] unless n.zero?\n end\n \n str\n end", "def names_of_people_better_at_english_than_maths(results_set)\nend", "def extract\n # create hash of words with number of their instances in tokens excluding stopwords\n words_hash = Hash.new(0)\n @tokens.each { |w| \n unless w.empty? or stop_words_for(@language)[w]\n words_hash[w] += 1 \n end\n }\n\n idfs_hash = get_idfs(words_hash.keys)\n\n # calculate tf-idf for each word into keywords array\n keywords = []\n max_num = words_hash.values.max.to_f\n words_hash.each do |word, num|\n tf = num / max_num\n idf = idfs_hash[word]\n keywords << [word, (tf * idf).round(5), idf.round(5)]\n end\n\n # return keywords sorted by rank descending\n keywords.sort_by {|word, rank, idf| -rank}\n end", "def score_term word, year_hash, year\n # Must exceed this usage floor\n min_norm_count = 0.000001\n curr_nc = 0.0\n prev_nc = 0.0\n # Get total normalized usage counts over current period\n (year-GROUPSIZE+1).upto(year) do |y|\n begin\n curr_nc += year_hash[y][word][:nc] || 0.0\n rescue\n curr_nc += 0.0\n end\n end\n # Get total normalized usage counts over previous period\n (year-GROUPSIZE*2+1).upto(year-GROUPSIZE) do |y|\n begin\n prev_nc += year_hash[y][word][:nc] || 0.0\n rescue\n prev_nc += 0.0\n end\n end\n\n # Check to prevent divide y zero\n if prev_nc > 0.0\n growth = curr_nc / prev_nc\n else\n growth = 0.0\n end\n\n # Can balance growth with normalized usage; currently\n # only using growth.\n return growth #+ Math.log(nc*1000000)\nend", "def word_freq(categories, word)\n [*categories].inject(0){|sum, category|\n sum += self.counter.freq(category, word)\n }\n end", "def word_count(text)\n\tnew_text = text.split(\" \") #-->Use text.split to turn text into an array that breaks(splits) at each space.\n\t\n \tcounter = Hash.new(0) #-->Next create an empty hash for your results with count = Hash.new (0)\n\n \tnew_text.each {|word| counter[word] += 1} #-->Use a method that will take each word in the array\n\n \tputs counter #-->This will give us our results printed on the screen\nend", "def get_writing_stats_in_week( in_date )\n \n # Initialize Hash\n stats = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 }\n \n # Get the current day of week\n dayCurrent = in_date.wday().to_i\n \n # Get date at the start of the week\n timeStart = Time.utc( in_date.year, in_date.month, in_date.day )\n timeStart = timeStart - 24 * 60 * 60 * dayCurrent\n \n # Get date at the end of the week\n timeEnd = Time.utc( in_date.year, in_date.month, in_date.day )\n timeEnd = timeEnd + 24 * 60 * 60 * ( 7 - dayCurrent )\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n timeEntry = Time.utc( entry.starttime.year, entry.starttime.month, entry.starttime.day, entry.starttime.hour, entry.starttime.min )\n \n if( timeStart.to_i <= timeEntry.to_i && timeEnd.to_i >= timeEntry.to_i )\n stats[ \"words\" ] += entry.words\n stats[ \"total\" ] += entry.hours + entry.minutes.to_f / 60\n if entry.editing\n stats[ \"editing\" ] += entry.hours + entry.minutes.to_f / 60\n else\n stats[ \"writing\" ] += entry.hours + entry.minutes.to_f / 60\n end \n end\n end\n \n return stats\n \n end" ]
[ "0.6362605", "0.6351187", "0.6284629", "0.6258469", "0.6142604", "0.6124343", "0.59700376", "0.5961985", "0.59395224", "0.5924927", "0.58823943", "0.58823943", "0.58823943", "0.5877987", "0.58677", "0.58579755", "0.5851423", "0.584507", "0.5830766", "0.5824773", "0.58173835", "0.5806339", "0.5803589", "0.5794292", "0.57930994", "0.57834035", "0.5773977", "0.57739437", "0.5769877", "0.5769349", "0.5757866", "0.5738691", "0.57349485", "0.5722492", "0.5708632", "0.5686581", "0.56822747", "0.56787175", "0.566225", "0.5621693", "0.56117445", "0.5609172", "0.56041616", "0.5596281", "0.5588022", "0.5586207", "0.5585051", "0.55497515", "0.5538169", "0.5530517", "0.5525882", "0.5518173", "0.55122817", "0.5509909", "0.55074066", "0.5500653", "0.5499812", "0.54872096", "0.5482393", "0.54816586", "0.54734844", "0.5441465", "0.54406005", "0.5437623", "0.5434097", "0.5428815", "0.54285026", "0.5427809", "0.5424135", "0.54103017", "0.5408985", "0.54088736", "0.5408362", "0.54019105", "0.5400752", "0.5396007", "0.5392877", "0.5391914", "0.5391351", "0.5379379", "0.53779316", "0.53774136", "0.5376792", "0.537494", "0.5373637", "0.53715515", "0.5351882", "0.5348571", "0.53438693", "0.5343458", "0.5335549", "0.5334447", "0.5333289", "0.5332218", "0.5324128", "0.5317408", "0.5312666", "0.5311239", "0.5309199", "0.5306333", "0.5305227" ]
0.0
-1
if (i % 3 == 0 && i % 4 == 0 && i % 5 == 0) puts 'FizzSussBuzz' elsif (i % 3 == 0 && i % 4 == 0) puts 'FizzSuss' elsif (i % 4 == 0 && i % 5 == 0) puts 'SussBuzz' elsif (i % 3 == 0) puts 'Fizz' elsif (i % 4 == 0) puts 'Suss' elsif (i % 5 == 0) puts 'Buzz' else puts i end end
def dynamic_fizz_buzz(range, rules) range.each do |i| result = '' rules.each do |(text, divisor)| result << text if (i % divisor == 0) end puts result == '' ? i : result end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fizz_buzz()\n for i in 1..100\n if i % 3 == 0 && i % 5 == 0\n puts 'FizzBuzz'\n elsif i % 3 == 0\n puts 'Fizz'\n elsif i % 5 == 0\n puts 'Buzz'\n else\n puts i\n end\n end\nend", "def fizz_buzz (i)\n 1.upto 100 do |i|\n if i % 5 == 0 && i % 3 == 0 \n puts \"FizzBuzz\"\n elsif i % 5 == 0\n puts \"Buzz\" \n elsif\n puts i % 3 == 0\n else \"Fizz\"\n puts i\n end\nend\nend", "def fizz_buzz(i)\nif i % 3 == 0 && i % 5 == 0\n\t\"fizzbuzz\"\nelsif i % 3 == 0 \n\t \"fizz\"\nelsif i % 5 == 0\n \"buzz\"\nelse\n\t i \n end\nend", "def fizzbuzz (i)\n if i % 3 == 0 && i % 5 == 0\n return \"FizzBuzz\"\nend\n if i % 3 == 0 \n return \"Fizz\"\nend\n if i % 5 == 0 \n return \"Buzz\"\nend \nend", "def fizzbuzz\n\n\tfor i in (1..100) do\n\t\tif i % 3 == 0 and i % 5 == 0\n\t\t\tputs 'FizzBuzz'\n\t\telsif i % 5 == 0\n\t\t\tputs 'Buzz'\n\t\telsif i % 3 == 0\n\t\t\tputs 'Fizz'\n\t\telse puts i\n\n\t\tend\n\tend\n\nend", "def fizzbuzz(int)\n if int % 3 == 0 and int % 5 == 0\n \"FizzBuzz\"\n elsif int % 3 == 0 \n \"Fizz\"\n elsif int % 5 == 0 \n \"Buzz\"\n else\n end\nend", "def fizzbuzz(int)\n if int % 3 == 0 && int % 5 == 0 \n \"FizzBuzz\"\n \n elsif int % 5 == 0 # if the number int is divisible by 5\n \"Buzz\"\n \n # if number is divisible by 3 and 5 print \"FizzBuzz\"\n \n elsif int % 3 == 0 # if the number int is divisible by 3\n \"Fizz\"\n \n end\n end", "def fizzbuzz(number)\n\n if number % 3 == 0 && number % 5 == 0\n puts \"Fizzbuzz\"\n\n elsif number % 3 == 0 \n puts \"Fizz\"\n \n elsif number % 5 == 0\n puts \"Buzz\"\n \n end\n\nend", "def fizzbuzz(number)\n\t\n\tif number % 3 == 0 && number % 5 == 0\n\t\tputs \"FizzBuzz\"\n\n\telsif number % 3 == 0\n\t\tputs \"Fizz\"\n\t\n\telsif number % 5 == 0\n\t\tputs \"Buzz\"\n\n\telse \n\t\tputs number\n\tend\n\nend", "def fizzbuzz (int)\n\n if int % 3 == 0 && int % 5 == 0\n \"FizzBuzz\"\n \n#returns \"FizzBuzz\" when the number is divisible by 3 and 5\n\n elsif int % 3 == 0\n \"Fizz\"\n \n#returns \"Fizz\" when the number is divisible by 3\n \n elsif int % 5 == 0\n \"Buzz\" \n \n#returns \"Buzz\" when the number is divisible by 5\n\n end\nend", "def fizzbuzz\n\t 1.upto(100) do |i|\n\tif i % 5 == 0 and i % 3 == 0\n\t puts \"FizzBuzz\"\n\telsif i % 5 == 0\n\t puts \"Buzz\"\n\telsif i % 3 == 0\n\t puts \"Fizz\"\n\telse\n\t puts i\n\tend\n\tend\nend", "def fizzBuzz (number)\n for i in 1..number\n if (i % 15 == 0)\n puts \"fizzbuzz\"\n elsif (i % 3 ==0)\n puts \"fizz\"\n elsif (i % 5 ==0)\n puts \"buzz\"\n else\n puts i\n end\n end\nend", "def fizzbuzz (int)\n if int%3==0 && int%5==0 # if the number int is divisible by 3\n \"FizzBuzz\"\n elsif int%3==0\n \"Fizz\"\n elsif int%5==0\n \"Buzz\"\n else\n end\nend", "def fizzbuzz(num)\n test_3 = num % 3\n test_5 = num % 5\n \n if test_3 == 0 && test_5 == 0\n \"FizzBuzz\"\n elsif test_3 == 0 && test_5 != 0\n \"Fizz\"\n elsif test_3 != 0 && test_5 == 0\n \"Buzz\"\n end\nend", "def fizzbuzz(number)\n if number % 3 == 0 && number % 5 == 0\n \"FizzBuzz\"\n elsif number % 3 == 0\n \"Fizz\"\n elsif number % 5 == 0\n \"Buzz\"\n end\nend", "def determine_fizz_buzz (num)\n if num % 3 == 0 and num % 5 == 0 and num != 0\n puts \"#{num} is FIZZ BUZZ\"\n elsif num % 5 == 0 and num != 0\n puts \"#{num} is BUZZ\"\n elsif num % 3 == 0 and num != 0\n puts \"#{num} is FIZZ\"\n else\n puts \"#{num} is boring...\"\n end\nend", "def fizzbuzz(integer)\n if integer %3 ==0 && integer %5==0\n return \"FizzBuzz\"\nelsif integer % 3 == 0\n return \"Fizz\"\n elsif integer % 5 ==0 \n return \"Buzz\"\n \n end\n end", "def fizzBuzz\n array = [*1..100]\n array.each { |num|\n if ((num % 3) == 0) && ((num % 5) == 0)\n puts \"FizBuzz\"\n elsif num % 5 == 0\n puts \"Buzz\"\n elsif num % 3 == 0\n puts \"Fizz\"\n else \n puts num\n end\n }\nend", "def fizz_buzz number \n # for i in number\n # \tif i%3 == 0 \n # \t\treturn \"fiz\"\n # \telsif i%5 == 0\n # \t\treturn \"buzz\"\n # \tend \n # end\n\n if ((number % 3 == 0) && (number % 5 == 0))\n \treturn \"FizzBuzz\"\n elsif (number % 3 == 0)\n \treturn \"Fizz\"\n elsif (number % 5 == 0)\n \treturn \"Buzz\"\n else \n \treturn number\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0 && num % 5 == 0\n \"FizzBuzz\"\n elsif num % 3 == 0\n \"Fizz\"\n elsif num % 5 == 0\n \"Buzz\"\n else\n num\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0 && num % 5 == 0\n \"FizzBuzz\"\n elsif num % 3 == 0\n \"Fizz\"\n elsif num % 5 == 0\n \"Buzz\"\n else\n num\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0 && num % 5 == 0\n \"FizzBuzz\"\n elsif num % 3 == 0\n \"Fizz\"\n elsif num % 5 == 0\n \"Buzz\"\n else\n num\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0 && num % 5 == 0\n \"FizzBuzz\"\n elsif num % 3 == 0\n \"Fizz\"\n elsif num % 5 == 0\n \"Buzz\"\n else\n num\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0 && num % 5 == 0\n \"FizzBuzz\"\n elsif num % 3 == 0\n \"Fizz\"\n elsif num % 5 == 0\n \"Buzz\"\n else\n num\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0 && num % 5 == 0\n \"FizzBuzz\"\n elsif num % 3 == 0\n \"Fizz\"\n elsif num % 5 == 0\n \"Buzz\"\n else\n num\n end\nend", "def fizzbuzz(number)\n if number % 3 == 0 && number % 5 == 0\n puts \"FizzBuzz\"\n elsif number % 3 == 0\n puts \"Fizz\"\n \"FizzBuzz\"\n elsif number % 5 == 0\n puts \"Buzz\"\n # originally had `else puts number`. \n # removed because this isn't in instructions.\n end\nend", "def fizzbuzz(num)\nif num % 3 == 0 && num % 5 == 0\n \"FizzBuzz\"\n\nelsif num % 3 == 0\n \"Fizz\"\n\nelsif num % 5 == 0\n \"Buzz\"\n\n else\n nil\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0\n return \"fizz\"\n elsif num % 5 == 0\n return \"buzz\"\n elsif num % 3 ==0 && num % 5 == 0\n return \"fizzbuzz\"\n else\n end\nend", "def fizzbuzz(fiz_3)\n if fiz_3 % 3 == 0 && fiz_3 % 5 == 0 \n return \"FizzBuzz\"\n end \n \n if fiz_3 % 3 == 0 \n return \"Fizz\"\n end\n \n if fiz_3 % 5 == 0 \n return \"Buzz\"\n end\nend", "def fizzbuzz\n\t(1..100).each do |num|\n\t if num % 3 == 0 && num % 5 == 0\n\t\tputs \"Fizzbuzz\"\n\t elsif num % 3 == 0\n\t\tputs \"Fizz\"\n\t elsif num % 5 == 0 \n\t\tputs \"Buzz\"\n\t else\n\t\tputs num\n\t end\n\tend\nend", "def fizzbuzz(x)\n if x % 3== 0 && x % 5== 0\n \"FizzBuzz\"\n \n elsif x % 3 == 0 \n \"Fizz\"\n elsif x % 5 == 0\n \"Buzz\"\n else\n end\nend", "def fizzbuzz(input)\nif (input % 3 == 0) && (input % 5 == 0)\n \"FizzBuzz\"\nelsif input % 3 == 0\n \"Fizz\"\nelsif input % 5 == 0\n \"Buzz\"\nend\nend", "def fizzbuzz(number)\n if number % 5 == 0 && number % 3 == 0\n return \"FizzBuzz\"\n end\n if number % 3 == 0\n return \"Fizz\"\n end\n if number % 5 == 0\n return \"Buzz\"\n end\nend", "def fizzbuzz()\n numbers = Array(1..100)\n numbers.each do |num|\n if num % 15 == 0\n puts \"FizzBuzz\" \n elsif num % 3 == 0\n puts \"Fizz\"\n elsif num % 5 == 0\n puts \"Buzz\"\n else\n puts num\n end\n end\nend", "def fizzbuzz(num)\n i = 0;\n num.times do\n i += 1\n # Check to see if num is a multiple of 3 but not 5\n if (i % 3 == 0 && i % 5 != 0)\n p \"Fizz\"\n # Check to see if num is a multiple of 5 but not 3\n elsif (i % 5 == 0 && i % 3 != 0)\n p \"Buzz\"\n # Check to see if num is a multiple of 3 and 5\n elsif (i % 5 == 0 && i % 3 == 0)\n p \"FizzBuzz\"\n else\n p i\n end\n end\nend", "def fizzbuzz(number)\n if number % 3 === 0 and number % 5 === 0\n return \"fizzbuzz\"\n elsif number % 3 === 0\n return \"fizz\"\n elsif number % 5 === 0\n return \"buzz\"\n else\n return number\n end\nend", "def FizzBuzz\n\t\n1.upto(100) {|i| \n\tputs \"Fizz\" if i%3 == 0 && i%5 != 0\n\tputs \"Buzz\" if i%3 != 0 && i%5 == 0\n\tputs \"FizzBuzz\" if i%3 == 0 && i%5 == 0\n\tputs i if i%3 != 0 && i%5 != 0\n}\t\n\nend", "def fizz(number)\t\t\t\t# creates fizz function had number argument\n\tfor\ti in 1..number\t\t\t# for loop i is the current value runs from 1 to 100 the agrument\n if i % 5 == 0 and i % 3 == 0 # if the current number is both divisible by 3\n puts \"FizzBuzz\"\t\t\t# prints FizzBuzz\n elsif i % 5 == 0\t\t\t# else if the current number is divisible by 5\n puts \"Buzz\"\t\t\t\t# prints Buzz\n elsif i % 3 == 0\t\t\t# esle if the current number is divisible by 3\n puts \"Fizz\"\t\t\t\t# prints Fizz\n else\t\t\t\t\t\t# else if none of the above conditions exist\n puts i\t\t\t\t\t# print the current number\n end\t\t\t\t\t\t# ends if\n end\t\t\t\t\t\t# ends \n end", "def fizzbuzz(int)\n\n if int % 3==0 && int % 5==0\n return \"FizzBuzz\"\n elsif int % 3==0\n return \"Fizz\"\n elsif int % 5==0\n return \"Buzz\"\n else\n nil\n end\n\nend", "def fizzbuzz(int)\n divBy3 = int % 3 == 0\n divBy5 = int % 5 == 0\n if divBy3 && !divBy5\n \"Fizz\"\n elsif divBy5 && !divBy3\n \"Buzz\"\n elsif divBy3 && divBy5\n \"FizzBuzz\"\n else\n nil\n end\nend", "def super_fizz(number)\n(0..1000).each do |number|\ndivisible_by_3 = number % 3\ndivisible_by_5 = number % 5\ndivisible_by_7 = number % 7\nif divisible_by_3 == 0\n if divisible_by_5 == 0\n if divisible_by_7 == 0\n puts \"SuperFizzBuzz\"\n else\n puts \"FizzBuzz\"\n end\n elsif divisible_by_7 == 0\n puts \"SuperFizz\"\n else\n puts \"Fizz\"\n end\nelsif divisible_by_5 == 0\n if divisible_by_7 == 0\n puts \"SuperBuzz\"\n else\n puts \"Buzz\"\n end\nelsif divisible_by_7 == 0\n puts \"Super\"\nelse\n puts number\nend\nend\nend", "def fizzbuzz(number)\nif (number%3==0) && (number%5==0)\n \"FizzBuzz\"\nelsif (number%3)==0\n \"Fizz\"\nelsif (number%5)==0\n \"Buzz\"\nelse\n nil\nend\nend", "def fizzbuzz(int)\n # Checks to see if the number int is divisible by both 3 and 5\n if int % 3 == 0 && int % 5 == 0\n # If true, returns FizzBuzz\n \"FizzBuzz\"\n # Checks to see if the number int is divisible by 3\n elsif int % 3 == 0\n # If true, return Fizz\n \"Fizz\"\n # Checks to see if the number int is divisible by 5\n elsif int % 5 == 0\n # If true, return Buzz\n \"Buzz\"\n else\n # Return nil for all other cases\n nil\nend", "def fizzbuzz(num_1, num_2, range)\n# looping through the code block using iteration.\n (1..range).each do |i|\n# If left hand operand i devided by right hand operand num_1 is equal to 0 and left hand operand i devided by right hand operand num_2 is equal to 0 then print fizzbuzz\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n# If not the first if check left hand operand i devided by right hand operand num_1 is equal to 0 if so print fizz.\n elsif i % num_1 === 0\n puts 'fizz'\n# If not the first if or first elsif check left hand operand i devided by right hand operand num_2 is equal to 0 if so print buzz. \n elsif i % num_2 === 0\n puts 'buzz'\n# If non of the above print i\n else\n puts i\n# End block of code\n end\n end\nend", "def fizzbuzz(num)\n if num%3 == 0\n print \"Fizz\"\n elsif num%5 == 0\n print \"Buzz\"\n else\n puts num\nend", "def fizzbuzz (int)\n if int % 15 == 0 \n \"FizzBuzz\"\n\n elsif int % 5 == 0 \n \"Buzz\"\n \n \nelsif int % 3 == 0\n \"Fizz\"\n else \n \n end \n end", "def fizzbuzz(num)\n if num % 3 == 0\n if num % 5 == 0\n \"FizzBuzz\"\n else\n \"Fizz\"\n end\nelsif num % 5 == 0\n \"Buzz\"\nelse\n nil\n end\nend", "def fizzbuzz(number)\n #if the number is divisible by both 3 and 5\n if number % 3 == 0 && number % 5 == 0\n \"FizzBuzz\"\n #else div by only 3\n elsif number % 3 == 0\n \"Fizz\"\n #else div by only 5\n elsif number % 5 == 0\n \"Buzz\"\n #else nil\n end\nend", "def fizz_buzz number\n if number%3 == 0 && number%5 == 0\n return \"FizzBuzz\"\n elsif number%3 == 0\n return \"Fizz\"\n elsif number%5 == 0\n return \"Buzz\"\n else\n return number\n end\nend", "def fizzbuzz(int)\n #if 1 \n if int%3 == 0\n #if 1A \n if int%5 == 0 \n \"FizzBuzz\"\n else\n \"Fizz\"\n end #end of if 1A\n \n elsif int%5 == 0\n if int%3 == 0\n \"FizzBuzz\"\n else \n \"Buzz\"\n end #END OF 1B\n \n else\n nil\nend \nend", "def fizzbuzz(num)\n num.times do |i|\n \n if i % 15 == 0\n puts \"fizzbuzz\"\n elsif i % 3 == 0 \n puts \"fizz\"\n elsif i % 5 == 0\n puts \"buzz\"\n else\n puts \"num\"\n end\n end\nend", "def fizzbuzz (int)\n if (int % 5 == 0) && (int % 3 == 0) \n return \"FizzBuzz\" \n elsif int % 3 == 0 \n \"Fizz\" \n elsif int % 5 == 0 \n \"Buzz\"\n else\n nil\nend\nend", "def fizzbuzz(int)\n if int % 3 == 0 && int % 5 == 0# if the number int is divisible by 3\n \"FizzBuzz\" # Go fizz\nelsif int % 5 == 0\n \"Buzz\"\nelsif int % 3 == 0\n \"Fizz\"\nelse int = nil\n end\nend", "def fizzbuzz(n)\n if n % (3 and 5) == 0 \n \"FizzBuzz\"\n elsif n % 3 == 0\n \"Fizz\"\n elsif n % 5 == 0\n \"Buzz\"\n else\n n\n end\nend", "def fizzbuzz\n\ty = (1..100)\n\ty.each { |x|\n\t\tif x % 3 == 0 && x % 5 == 0\n\t\t\tputs \"fizzbuzz\"\n\t\telsif x % 3 == 0\n\t\t\tputs \"fizz\"\n\t\telsif x % 5 == 0\n\t\t\tputs \"buzz\"\n\t\telse\n\t\t\tputs x\n\t\tend\n\t}\nend", "def fizzbuzz(int)\n if (int % 3 == 0) && (int % 5 != 0) #if entered number is divided by 3 and the remainder equals (==) 0\n \"Fizz\"\n elsif (int % 5 == 0) && (int % 3 != 0) #else int is div / 5 and remainder == 0\n \"Buzz\"\n elsif (int % 3 == 0) && (int % 5 == 0)\n \"FizzBuzz\"\n else \n end\nend", "def fizzbuzz(num_1, num_2, range)\n#iterate throughout the number set\n (1..range).each do |i|\n #boolean, === is exact equals, % is the remainder from division (modulo), && is AND both conditions are met\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n #otherwise, if this exact number is met, put this phrase\n elsif i % num_1 === 0\n puts 'fizz'\n #otherwise, if this exact number is met, put this phrase\n elsif i % num_2 === 0\n puts 'buzz'\n #if all else fails, put i\n else\n puts i\n end\n end\nend", "def fizzbuzz(num)\n if num % 3 == 0 && num % 5 == 0 # return 'FizzBuzz' when number is divisible by 3 and 5\n return \"FizzBuzz\"\n elsif num % 5 == 0 # return 'Buzz' when number is divisible by 5\n return \"Buzz\"\n elsif num % 3 == 0 # return 'Fizz' when number is divisible by 3\n return \"Fizz\"\n else # return nil when number is not divisible by 3 or 5\n return nil\n end\nend", "def fizzbuzz(number)\n if (number % 5 == 0 && number % 3 == 0)\n 'fizzbuzz'\n elsif number % 5 == 0\n 'buzz'\n elsif number % 3 == 0\n 'fizz'\n else \n number\n end\nend", "def fizzbuzz(num_given)\n \n if(num_given % 3 == 0)&&(num_given % 5 == 0)\n \"FizzBuzz\"\n elsif (num_given % 3 == 0)\n \"Fizz\"\n elsif (num_given % 5 == 0)\n \"Buzz\"\n else\n nil\n end\nend", "def fizzbuzz(input)\n if input%3 ==0 && input%5 == 0 \n return \"FizzBuzz\"\n elsif input%3 == 0 \n return \"Fizz\"\n elsif input%5 == 0 \n return \"Buzz\"\n else\n end \nend", "def fizz_buzz(number)\n if(number % 3 == 0 && number % 5 == 0)\n return \"FizzBuzz\"\n elsif(number % 3 == 0)\n return \"Fizz\"\n elsif(number % 5 == 0)\n return \"Buzz\"\n else\n return number\n end\nend", "def fizzbuzz(int)\n\n if int % 3 == 0 && int % 5 == 0\n \"FizzBuzz\"\n\n elsif int % 3 == 0\n \"Fizz\"\n\n elsif int % 5 == 0\n \"Buzz\"\n\n else\n nil\n\n end\n end", "def fizzbuzz(int)\n if int % 3 == 0 && int % 5 != 0 \n fizz_string = \"Fizz\"\n fizz_string\n elsif int % 3 != 0 && int % 5 == 0 \n buzz_string = \"Buzz\"\n buzz_string\n elsif int % 3 == 0 && int % 5 == 0 \n fizzbuzz_string = \"FizzBuzz\"\n puts fizzbuzz_string\n fizzbuzz_string\n end\nend", "def fizz_buzz\n num = 0\n 100.times do\n num +=1\n if num % 5 == 0 && num % 3 == 0\n puts 'FizzBuzz'\n elsif num % 5 == 0\n puts 'Buzz'\n elsif num % 3 == 0\n puts 'Fizz'\n else\n puts num\n end\n end\nend", "def fizzbuzz(number)\n #binding.pry\n if (number % 3 == 0 && number % 5 == 0)\n then \"FizzBuzz\"\n elsif number % 3 == 0\n then \"Fizz\"\n elsif number % 5 == 0\n then \"Buzz\"\n else\n nil\n end\nend", "def FizzBuzz()\n x=0\n while x < 100\n x += 1\n if x % 3 == 0 && x % 5 !=0\n puts \"Fizz\"\n elsif x % 5 == 0 && x% 3 !=0\n puts \"Buzz\"\n elsif x % 15 == 0\n puts \"FizzBuzz\"\n else puts x\n end\n end\nend", "def fizz_buzz()\n for i in 0..100\n# nested if for multiple of 3 and 5\n if i%3 ==0\n if i%5 ==0\n puts \"FizzBuzz\"\n else \n puts \"Fizz\"\n end\n elsif i%5 ==0\n puts \"Buzz\"\n else\n puts i\n end\n end\nend", "def fizzbuzz(num)\n\tif num % 15 == 0\n\t\"FizzBuzz\"\n\telsif num % 3 == 0\n\t\"Fizz\"\n\telsif num % 5 == 0\n\t\"Buzz\"\n\t\n\telse num % 15 != 0\n\tputs\n\nend\nend", "def fizzbuzz(num)\n num3 = num % 3\n num5 = num % 5\n if num3 + num5 == 0 \n return \"FizzBuzz\"\n elsif num3 == 0\n return \"Fizz\"\n elsif num5 == 0 \n return \"Buzz\"\n end\nend", "def fizzbuzz(num_1, num_2, range)\n# Take every integer between 1 and the range argument and do the following:\n (1..range).each do |i|\n # If the integer's modulous with num_1 argument equals zero and the integer's modulous with the num_2 argument equals zero\n if i % num_1 === 0 && i % num_2 === 0\n # print fizzbuzz\n puts 'fizzbuzz'\n # Otherwise if the integer's modulous with num_1 argument equals zero\n elsif i % num_1 === 0\n # print fizz\n puts 'fizz'\n # Otherwise if the integer's modulous with num_2 argument equals zero\n elsif i % num_2 === 0\n # print buzz\n puts 'buzz'\n # None of the above?\n else\n # Then just print the integer\n puts i\n # close if statement\n end\n # close .each method\n end\n# close fizz buzz method\nend", "def fizzbuzz(number)\n if (number % 3).zero? && (number % 5).zero?\n \"FizzBuzz\"\n elsif (number % 3).zero?\n \"Fizz\"\n elsif (number % 5).zero?\n 'Buzz'\n else\n number\n end\nend", "def fizzbuzz(num_1, num_2, range)\n # Declare a function that does the following for each argument (i) beginning at 1 and ending at\n # the range:\n (1..range).each do |i|\n # If the value of i divided by num_1 is an integer AND the value of i divided\n # by num_2 is also an integer, print the value 'fizzbizz' on the next line\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n # If the value of i divided by num_1 is an integer, print 'fizz' on the next line\n elsif i % num_1 === 0\n puts 'fizz'\n # If the value of i divided by num_2 is an integer, print 'buzz' on the next line\n elsif i % num_2 === 0\n puts 'buzz'\n # If none of the above conditions are met, print the value of i on the next line.\n else\n puts i\n end\n end\nend", "def fizzbuzz(int)\n\tif int % 3 == 0 && int % 5 == 0\n\t\t\"FizzBuzz\"\n\telsif int % 5 == 0\n\t\t\"Buzz\"\n\telsif int % 3 == 0\n\t\t\"Fizz\"\n\telse\n\t\tnil\n\tend\n\nend", "def fizzbuzz(number)\n\n if number % 5 == 0 && number % 3 == 0\n \t\"FizzBuzz\"\n elsif number % 5 == 0\n \t\"Buzz\"\n elsif number % 3 == 0\n \t\"Fizz\"\n else\n \tnumber\n end\nend", "def fizzbuzz(int)\n if int % 15 == 0\n return \"FizzBuzz\"\nend\n if int % 3 == 0 # if the number int is divisible by 3\n return \"Fizz\" # Go fizz\nend\n if int % 5 == 0\n return \"Buzz\"\n end\nend", "def fizzbuzz(number)\n if (number % 3).zero? && (number % 5).zero?\n \"FizzBuzz\"\n elsif number % 5 == 0\n \"Buzz\"\n elsif number % 3 == 0\n \"Fizz\"\n else\n nil\n end\nend", "def fizz_buzz_woof(max)\n 1.upto(max).each do |x|\n if (x % 3 == 0) && (x % 5 == 0) && (x % 7 == 0)\n puts \"FizzBuzzWoof\"\n elsif (x % 3 == 0) && (x % 5 == 0)\n puts \"FizzBuzz\"\n elsif (x % 3 == 0) && (x % 7 == 0)\n puts \"FizzWoof\"\n elsif (x % 5 == 0) && (x % 7 == 0)\n puts \"BuzzWoof\"\n elsif x % 3 == 0\n puts \"Fizz\"\n elsif x % 5 == 0\n puts \"Buzz\"\n elsif x % 7 == 0\n puts \"Woof\"\n else\n puts x\n end\n end\nend", "def fizz_buzz number \n#prints numbers from 1 to 200\n #Modulo\n if number % 3 == 0 && number % 5 == 0\n 'FizzBuzz'\n elsif number % 3 == 0\n 'Fizz'\n elsif number % 5 == 0\n 'Buzz'\n else\n return number\n end\n\nend", "def fizzbuzz(num)\n collection = (1..num).to_a\n collection.each do |num|\n if (num % 3 == 0) && (num % 5 != 0)\n puts \"Fizz #{num}\"\n elsif (num % 5 == 0) && (num % 3 != 0)\n puts \"Buzz #{num}\"\n elsif (num % 3 == 0) && (num % 5 == 0)\n puts \"FizzBuzz #{num}\"\n end\n end\nend", "def fizz_buzz(number)\n if number % 3 == 0 && number % 5 == 0\n 'Fizz Buzz'\n elsif number % 3 == 0\n 'Fizz'\n elsif number % 5 == 0\n 'Buzz'\n else\n number.to_s\n end\nend", "def fizzbuzz(num_1, num_2, range)\n# Do i for all the numbers in a range from 1 to the value that will be assigned to the variable \"range\".\n (1..range).each do |i|\n# If i divided by the value assigned to num_1 is equal to 0 and i divided by the value assigned to num_2 is equal to zero then print \"fizzbuzz\".\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n# If i divided by the value assigned to num_1 is equal to zero print \"fizz\".\n elsif i % num_1 === 0\n puts 'fizz'\n# If i divided by the value assigned to num_2 is equal to zero print \"buzz\".\n elsif i % num_2 === 0\n puts 'buzz'\n# If none of the previous conditions are true print i.\n else\n puts i\n# Ends the if/else statement.\n end\n# Ends the argument.\n end\n# Ends the method.\nend", "def fizzbuzz(number)\n (1..number).each do |num|\n if (num % 15).zero?\n puts 'FizzBuzz'\n elsif (num % 3).zero?\n puts 'Fizz'\n elsif (num % 5).zero?\n puts 'Buzz'\n else\n puts num\n end\n end\nend", "def fizz_buzz num\n puts \"FizzBuzz\" if num % 15 == 0\n puts \"Fizz\" if num % 3 == 0\n puts \"Buzz\" if num % 5 == 0\n puts num\nend", "def fizzbuzz(num_1, num_2, range)\n # starts a loop which runs through all integers between 1 and whatever 'range' argument is equal to. i is the variable where each integer is stored during the loop.\n (1..range).each do |i|\n # starts if/else statement by detecting whether integer i is evenly divisible by both num_1 and num_2.\n if i % num_1 === 0 && i % num_2 === 0\n #If so, it prints 'fizzbuzz.'\n puts 'fizzbuzz'\n # detects if integer i is evenly divisible by num_1 (and only num_1, since line 45 would have caught it if it were divisible by both)\n elsif i % num_1 === 0\n # If so, it prints 'fizz'\n puts 'fizz'\n # detects if integer i is evenly divisible by num_2 (and only num_2)\n elsif i % num_2 === 0\n # If so, it prints 'buzz'\n puts 'buzz'\n # If integer i is evenly divisible by neither num_1 nor num_2, the function just prints integer i\n else\n puts i\n end\n end\nend", "def fizzbuzz(any)\n if any % 3 == 0 && any % 5 == 0\n val=\"FizzBuzz\"\n elsif any % 3 == 0\n val=\"Fizz\"\n elsif any % 5 == 0\n val=\"Buzz\"\n else\n puts \"Not divisible by 3 or 5\"\n end \n \nend", "def fizzbuzz(number)\n return \"please enter a positive integer\" if number < 1\n if number % 3 == 0 and number % 5 == 0\n \"fizzbuzz\"\n elsif number % 3 == 0\n \"fizz\"\n elsif number % 5 == 0\n \"buzz\"\n else\n number\n end\nend", "def fizzbuzz(number)\n number.times do |i|\n i += 1\n # case i\n # when (i % 15).zero? then puts 'Fizzbuzz'\n # when (i % 5).zero? then puts 'Buzz'\n # when (i % 3).zero? then puts 'Fizz'\n # else puts i\n # end\n if (i % 15).zero?\n puts 'Fizzbuzz'\n elsif (i % 5).zero?\n puts 'Buzz'\n elsif (i % 3).zero?\n puts 'Fizz'\n else\n puts i\n end\n end\nend", "def fizzbuzz(num)\nif (num % 3 == 0)\n return \"Fizz\"\n elsif ((num % 3 == \"Fizz\") && (num % 5 == \"Buzz\"))\n return \"FizzBuzz\"\n elsif (num % 5 == 0)\n return \"Buzz\"\n else (num /15 == 0)\n \"FizzBuzz\"\n \nend\n return nil\nend", "def fizzbuzz(num_1, num_2, range)\n #loop with .each do instead of for loop\n (1..range).each do |i|\n #Use modulo operator to get the remainder of the division i on num-1\n #if i modulo num_1 triple equals 0 AND i modulo num_2 triple equals 0\n if i % num_1 === 0 && i % num_2 === 0\n #print \"fizzbuzz\"\n puts 'fizzbuzz'\n #else if i modulo num_1 triple equals 0\n elsif i % num_1 === 0\n #print \"fizz\"\n puts 'fizz'\n #else if i modulo num_2 triple equals 0\n elsif i % num_2 === 0\n #print \"buzz\"\n puts 'buzz'\n #otherwise\n else\n #print i\n puts i\n #end\n end\n #end\n end\n #end\nend", "def fizzbuzz(num_1, num_2, range)\n#from integer 1 to argument range above, execute the code below for each element. variable i stands for the element in the range the program is currently using at the time.\n (1..range).each do |i|\n#conditional, if variable i modulo argument num_1 is equal to 0 AND variable i modulo argument num_2 is also equal to 0, print string \"fizzbuzz\"\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n#if the above conditional is not true, check if variable i modulo argument num_1 is equal to 0 by itself. if true, print string \"fizz\"\n elsif i % num_1 === 0\n puts 'fizz'\n#if neither of the above conditionals are true, check if variable i modulo argument num_2 is equal to 0 by itself. if true, print string \"buzz\"\n elsif i % num_2 === 0\n puts 'buzz'\n#if none of the above conditionals are found to be true, print the value of variable i (the number in the range the program was checking)\n else\n puts i\n end\n end\nend", "def fizzbuzz(num_1, num_2, range)\n # this declaring the iteration range\n (1..range).each do |i|\n # this is an if statement that if true it will print fizzbuzz. if it is false it will go to the next elsif satement\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n # this is an elsif satement that if the above is found false and this statement is true it will print 'fizz'. If this statement is also false it will move on to the next elsif statement\n elsif i % num_1 === 0\n puts 'fizz'\n # this is an elsif satement that if the above two statements found false and this statement is true it will print 'buzz'. If this statement is also false it will move on to the final else statement\n elsif i % num_2 === 0\n puts 'buzz'\n # this is an else satement that if all of the above are found false it will print 'i'.\n else\n puts i\n end\n end\nend", "def fizzbuzz(num_1, num_2, range)\n # for each number in the range parameter (1 to range), do the following where i represents that number\n (1..range).each do |i|\n # if the remainder when you divide i by num_1 AND when you divide i by num_2 is 0 in both cases\n if i % num_1 === 0 && i % num_2 === 0\n # then print 'fizzbuzz'\n puts 'fizzbuzz'\n # if it IS true that the remainder when you divide i by num_1 is 0 (but not when you divide i by num_2)\n elsif i % num_1 === 0\n # then print just 'fizz'\n puts 'fizz'\n # if it's only true that the remainder is 0 when you divide i by num_2 and not num_1\n elsif i % num_2 === 0\n # then print just 'buzz'\n puts 'buzz'\n # if none of the three previous situations applies (is true)\n else\n #then instead, just print the number (i)\n puts i\n # close the if statement\n end\n # close the iteration loop\n end\n# close the method definition\nend", "def fizzbuzz(int)\n # Why did this operation have to be first? \n if int % 3 == 0 && int % 5 == 0\n \"FizzBuzz\"\n elsif int % 3 == 0 \n \"Fizz\" \n elsif int % 5 == 0 \n \"Buzz\"\n end \nend", "def fizzbuzz(num_1, num_2, range)\n # sets 1 to range (last number) where each number will do the following\n (1..range).each do |i|\n # if the remainder of each number i divided by the first number num_1 should have a zero AND\n # the remainder of each number i divided by the second number num_2 should have a zero\n if i % num_1 === 0 && i % num_2 === 0\n # then print 'fizzbuzz'\n puts 'fizzbuzz'\n # otherwise, if the remainder of number i divdied by num_1 should have a zero\n elsif i % num_1 === 0\n # then print 'fizz'\n puts 'fizz'\n # otherwise, if the remainder of number i divided by num_2 should have a zero\n elsif i % num_2 === 0\n # then print 'buzz'\n puts 'buzz'\n else\n # if all the conditions above are not met, then print the number i\n puts i\n end\n end\nend", "def fizzbuzz(num_1, num_2, range)\n#Repeats the following code for the duration of the range argument.\n (1..range).each do |i|\n#If i is divisible by both num_1 and num_2, it displays string fizzbuzz\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n#If i is divisible by num_1, it displays string fizz\n elsif i % num_1 === 0\n puts 'fizz'\n#If i is divisible by num_2, it displays string buzz\n elsif i % num_2 === 0\n puts 'buzz'\n#If i isn't divisible by either num_1 or num_2, it displays integer i\n else\n puts i\n#Ends the if, elsif, elsif, else check\n end\n#ends our loop\n end\n#ends our method\nend", "def fizzbuzz(number)\n \n if\n \n number % 3 == 0 && number % 5 == 0\n \n \"FizzBuzz\"\n \n elsif \n \n number % 3 == 0\n \n \"Fizz\"\n \n elsif\n\n number % 5 == 0 \n \n \"Buzz\"\n \n \n else\n \n number % 15 != 0\n \n puts \"nil\"\n \n end\nend", "def fizzbuzz(num_1, num_2, range)\n #iterates over the parameters of fizzbuzz\n (1..range).each do |i|\n #if the number i's remainder after dividing into num_1 is equal to 0 & i's remainder after dividing by num_2 is also 0 is true\n if i % num_1 === 0 && i % num_2 === 0\n #print fizzbuzz\n puts 'fizzbuzz'\n #if i's remainder from dividing into num_1 equals 0 is true\n elsif i % num_1 === 0\n #print fizz\n puts 'fizz'\n #if i's remainder from dividing into num_2 equals 0 is true\n elsif i % num_2 === 0\n #print buzz\n puts 'buzz'\n #if none of the above conditions are true, then\n else\n #print i\n puts i\n #closes if/else statements\n end\n #closes iteration\n end\n# closes fizzbuzz method\nend", "def fizzbuzz(number)\n case\n when number % 3 == 0 && number % 5 == 0 then \"fizzbuzz\"\n when number % 3 == 0 then \"fizz\"\n when number % 5 == 0 then \"buzz\"\n else number\n end\nend", "def fizzbuzz\n\t1.upto(100) do |i|\n\t\tprint \"Fizz \" if a = (i % 3).zero?\n\t\tprint \"Buzz \" if b = (i % 5).zero?\n\t\tprint \"FizzBuzz \" if c = (i % 15).zero?\n\t\tprint i.to_s + \" \" unless (a || b || c)\n\tend\nend", "def fizzbuzz(num_1, num_2, range)\n #set range of numbers for fizzbuzz\n (1..range).each do |i|\n #set initial condition\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n #set alternate condition\n elsif i % num_1 === 0\n puts 'fizz'\n #set alternate condition\n elsif i % num_2 === 0\n puts 'buzz'\n #set else condition\n else\n puts i\n #close if-statement\n end\n #close .each method\n end\n#close fizzbuzz\nend" ]
[ "0.89109665", "0.88788414", "0.8861966", "0.8715799", "0.869283", "0.8648231", "0.8645187", "0.86160666", "0.8597036", "0.8540557", "0.85397387", "0.8529209", "0.85081273", "0.84942144", "0.8493825", "0.84891117", "0.8473097", "0.8465373", "0.845641", "0.84555525", "0.84555525", "0.84555525", "0.84555525", "0.84555525", "0.84555525", "0.8453684", "0.84426737", "0.8436553", "0.84362656", "0.84350216", "0.8423423", "0.84144443", "0.8387576", "0.83783454", "0.83728313", "0.8370697", "0.8370682", "0.83667713", "0.8360306", "0.83567846", "0.83527535", "0.83512026", "0.8343488", "0.8330072", "0.8327256", "0.83264476", "0.8325275", "0.83251035", "0.8319167", "0.8314191", "0.8312447", "0.83024436", "0.8302084", "0.82860225", "0.82853866", "0.8281783", "0.8278033", "0.8276996", "0.82732373", "0.82693124", "0.82661015", "0.82615215", "0.82561076", "0.82518405", "0.82502484", "0.8246216", "0.8241683", "0.82383156", "0.82287055", "0.82117903", "0.8210014", "0.82014275", "0.81934196", "0.81879324", "0.81799126", "0.81734467", "0.81715256", "0.81632787", "0.8157125", "0.81569046", "0.814847", "0.8145066", "0.81439644", "0.8140988", "0.8139309", "0.8131967", "0.81297654", "0.8129229", "0.8118886", "0.81181526", "0.81143016", "0.81122583", "0.8109876", "0.81063277", "0.8104916", "0.8099798", "0.80988795", "0.80975544", "0.8090355", "0.80876684", "0.80864125" ]
0.0
-1
GET /meetings GET /meetings.json def index
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @meetings = Meeting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n render json: meeting.all\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 @meetings = Meeting.all\nend", "def index\n @meetings_lists = MeetingsList.all\n end", "def index\n\n @staticpage = Staticpage.find(:first, :conditions => [\"page_name = ?\", \"MeetingNotes\"]) \n \n @meetings = Meeting.find(:all, :order => [\"meeting_date desc\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end", "def index\n\n if params[:meeting_id]\n @meeting = Meeting.find(params[:meeting_id])\n end\n\n respond_to do |f|\n f.json {\n @meetings = Meeting\n start_p = Time.parse(params[:start])\n end_p = Time.parse(params[:end])\n @meetings = @meetings.where(\"start_at > ?\", params[:start])\n if start_p and end_p\n duration = end_p - start_p\n @meetings = @meetings.where(\"duration < ?\", duration)\n end\n\n render :json => @meetings.map{|m|\n {\n :id => m.id,\n :title => m.label,\n :start => m.start_at,\n :end => m.end_at,\n :url => \"/reunions/#{m.id}.js\",\n color: '#D42700',\n textColor: 'white'\n }\n }\n }\n f.html\n end\n end", "def index\n @meetings = Meeting.paginate(:page => params[:page], :per_page => 20)\n\t\t@title = \"Spotkania\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n format.rss { render :layout => false }\n end\n end", "def index\n @meetings = Meeting.recent\n @past_meetings = Meeting.recent.past\n @upcoming_meetings = Meeting.upcoming\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings }\n format.atom\n end\n end", "def index\n @games = Game.find_all_by_meeting_id(@meeting.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @users_meetings = UsersMeeting.all\n end", "def index\n @annual_meetings = AnnualMeeting.all\n end", "def index\n @meetings = Meeting.all\n @users = User.all\n @atendees = Atendee.all\n @presentes = Presenter.all\n end", "def index\n if current_user.usertype == \"superadmin\"\n @meetings = Meeting.all\n elsif params[:type] == nil\n @meetings = Meeting.find(:all, :conditions => [\"user_id = ? \", session[:user_id]] )#you are student\n elsif params[:type]=='pending' #meeting requested by the current user\n @meetings = Meeting.find(:all, :conditions=> [\"accept =0 and status = 0 and (tutor_id = ? or user_id = ?)\", session[:tutor_id], session[:user_id]])\n elsif params[:type]=='past'#meeting you attended in the past\n @meetings = Meeting.find(:all, :conditions=> [\"(tutor_id = ? OR user_id = ? )and status >= ?\", session[:tutor_id], session[:user_id], 3])\n elsif params[:type]=='attending' #meeting list that you will be attending(accepted, paid)\n @meetings = Meeting.find(:all, :conditions => ['(user_id = ? or tutor_id = ?) AND status = ? AND paid = ?', session[:user_id],session[:tutor_id], 1, true])\n else\n @meetings = Meeting.find(:all, :conditions => ['(user_id = ? or tutor_id = ?) AND status = ? AND paid = ?', session[:user_id],session[:tutor_id], 1, true])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end", "def index\n # # @meetings = Meeting.all\n # # Why check params for user_holder, but then using the root user one?\n # # I assume it is root user for now.\n # if params[:user_holder_id]\n # @cur_user_holder = current_user.user_holder\n # @meetings = @cur_user_holder.meetings\n # else\n # # No point to show all meeting.\n # @meetings = Meeting.all\n # end\n @pending_meetings = current_user.user_holder.meetings.where(status: \"pending\")\n @confirmed_meetings = current_user.user_holder.meetings.where(status: \"confirmed\")\n end", "def get_meetings\n prepare\n @api.get_meetings\n end", "def index\n @meetings_results = MeetingsResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings_results }\n end\n end", "def index\n @meetings = Meeting.all(:order => \"date\")\n end", "def index\n #@meeting_assignments = Assignment.find_all_meetings\n @meeting_assignments = Assignment.find_all_meetings(@user.id, params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings }\n end\n end", "def index\n @meetusers = Meetuser.all\n end", "def index\n @meetings = User.find(params[:user_id]).meetings\n #@meetings = Array.new\n Meeting.all.each do |m|\n if m.user_id == current_user.id\n @meetings.push(m)\n end\n end\n end", "def index\n # if current_user.admin?\n # @meetings = Meeting.all\n # else\n # @meetings = current_user.meetings.where(user_id: current_user)\n # end\n end", "def index\n #@meeting_threads = MeetingThread.all\n\n @calendar_guesses = @current_user.calendar_guesses\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @calendar_guesses }\n end\n end", "def index\n @meetings = Meeting.for_school(@_current_school).paginate(page: params[:page], per_page: 50)\n end", "def index\n @type_of_meetings = TypeOfMeeting.all\n end", "def index\n\n #@meeting_threads = MeetingThread.all\n @meeting_threads = current_user.meeting_threads\n @current_user = current_user\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meeting_threads }\n end\n end", "def index\n \n @meeting_threads = @current_user.available_jobs\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meeting_threads }\n end\n end", "def index\n if current_user.admin?\n if params[:dom].present?\n @request_meetings = RequestMeeting.includes(:meeting).where(meetings: { domain_id: params[:dom] })#.per(50).page(params[:page])\n @domain = Domain.find params[:dom]\n else\n @request_meetings = RequestMeeting.all\n end\n else \n @request_meetings = current_user.request_meetings\n if params[:dom].present?\n @request_meetings.where(meetings: { domain_id: params[:dom] })\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @request_meetings }\n end\n end", "def index\n @sayings = Saying.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sayings }\n end\n end", "def show\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meeting }\n end\n end", "def show\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meeting }\n end\n end", "def index\n if params[:meeting_id] && params[:team_id]\n @passages = Passage.includes(:team, :meeting).where(\n 'meetings.id' => params[:meeting_id],\n 'teams.id' => params[:team_id]\n ).to_a\n else\n @passages = []\n end\n render status: 200, json: @passages\n end", "def index\n @rooms = Room.all\n @meetings = Meeting.all\n respond_to do |format|\n format.html\n format.ics do\n cal = Icalendar::Calendar.new\n @meetings.each do |meeting|\n event = Icalendar::Event.new\n event.dtstart = meeting.start_at\n event.dtend = meeting.end_at\n event.summary = meeting.notes\n event.description = meeting.room.name\n cal.add_event(event)\n end\n render :text => cal.to_ical\n end\n end\n end", "def index\n @appointments = Appointment.all \n render json: @appointments\n end", "def new\n @meeting = Meeting.new\n @all = User.all\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def show\n @users_meetings = UsersMeeting.where(meeting_id_id: @meeting.id)\n end", "def index\n @meet_up_comments = MeetUpComment.in_conference(current_conference).all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def show\n \n @meetup = Meetup.find(params[:id])\n render json: {\n meetup: MeetupSerializer.new(@meetup)\n }\n end", "def pending_meets \n assert_internal_error(@user)\n @pending_meets = @user.true_pending_meets\n respond_to do |format|\n format.html {\n # redirect back to user meets view if no more pending meets\n if @pending_meets.empty?\n redirect_back user_meets_path(@user)\n else\n @pending_meets = @pending_meets.paginate(:page => params[:page], :per_page => 25)\n attach_meet_infos(current_user, @pending_meets, true)\n end\n }\n format.json {\n cursor = params[:cursor] || params\n @pending_meets = @pending_meets.cursorize(cursor,\n :only=>[:time, :created_at, :updated_at, :lat, :lng])\n attach_meet_infos(current_user, @pending_meets, true)\n @pending_meets.each {|meet|\n meet.friends_name_list_params = {:except=>current_user,:delimiter=>\", \",:max_length=>80}\n }\n render :json => @pending_meets.to_json(MeetsController::JSON_PENDING_MEET_LIST_API)\n }\n end\n end", "def index\n @meetings = Meeting.includes(:organization).order('date_and_time DESC')\n @grouped_meetings = @meetings.group_by(&:organization)\n end", "def index\n @attendees = Attendee.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @attendees }\n end\n end", "def set_meetings_list\n @meetings_list = MeetingsList.find(params[:id])\n end", "def index\n @attendees = Attendees.all\n render json: @attendees\n end", "def index\n # only list current user's hangouts\n @hangouts = current_user.hangouts.order(\"start_date_time DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hangouts }\n end\n end", "def index\n @goals = Goal.all\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 @talks = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talks }\n end\n end", "def index\n @meals = Meal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meals }\n end\n end", "def index\n @guests = @wedding.guests.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @guests }\n end\n end", "def show\n @users_meeting = UsersMeeting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users_meeting }\n end\n end", "def index\n @programmes = Programme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programmes }\n end\n end", "def index\n render json: TeachingActivity.all\n end", "def index\n @meeting_plans = MeetingPlan.all\n end", "def all_running_meetings\n bbb_server.get_meetings\n end", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def index\n @user = current_user\n @meetings = @user.meetings.all.where('date >= ?', Date.today).order('date ASC')\n @old_meetings = @user.meetings.all.where('date <= ?', Date.today).order('date ASC')\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 count_meetings\n team = Team.find_by_id( params[:id] )\n if team\n render( json: team.meetings.collect{|row| row.id}.uniq.size )\n else\n render( json: 0 )\n end\n end", "def show\n @meal_meeting = MealMeeting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meal_meeting }\n end\n end", "def index\n\t\tall_people = Person.all.sort_by(&:id)\n\t\tif all_people\n\t\t\trender json: {people: all_people}\n\t\telse\n\t\t\trender body: 'People Not Found', status: 404\n\t\tend\n\tend", "def index\n @you_owe_mes = YouOweMe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @you_owe_mes }\n end\n end", "def show\n\n \n @meet = Meet.find(params[:id])\n @track = @meet.track\n @cards = @meet.cards\n @comments = @meet.comments\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meet }\n end\n end", "def index\n @workouts = Workout.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workouts }\n end\n end", "def index\n @listings = Listing.all\n render json: @listings\n end", "def index\n\t\t@participants = Participant.all\n\n\t\trender json: @participants\n\tend", "def show\n user = self.load_user(params)\n meeting = load_meeting(params)\n\n if user != nil && meeting != nil\n self.send_json(\n meeting.to_json(:include => {\n :participants => {:only => [:id, :name, :email]},\n :suggestions => {:include => [:votes]}\n })\n )\n else\n self.send_error 401\n end\n end", "def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end", "def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end", "def index\n\t\t@people = People.all\n\t\t#render json: \"test\"\n\t\tresponse = @people\n\t\trender json: response\n\t\treturn response\n\tend", "def index\n @meeting_groups = MeetingGroup.all\n end", "def index\n @talk = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk }\n end\n end", "def index\n @harvestings = Harvesting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @harvestings }\n end\n end", "def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def index\n @postings = Posting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postings }\n end\n end", "def index\n @meeting_types = MeetingType.all\n end", "def index\n @employments = Employment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employments }\n end\n end", "def index\n @listings = Listing.by_user(current_user).all\n\n render json: @listings\n end", "def index\n \n if current_user.parent == nil \n redirect_to parents_new_path()\n end\n\n @parent = current_user.parent\n @meetings = current_user.meetings\n end", "def index\n @user = User.find(params[:user_id])\n @mycontact = Mycontact.find(params[:mycontact_id])\n if @mycontact\n @meetings = @mycontact.meetings\n else\n @meetings = Meeting.all\n end\n end", "def show\n @request_meeting = RequestMeeting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request_meeting }\n end\n end", "def index\n bookings = Room.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all rooms', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end", "def index\n @workouts = Workout.all \n render 'index.json.jbuilder', status: :created\n end", "def index\n @meetings = current_user.meetings \n \n @meeting_prev = current_user.meetings.where('date < ?' ,Date.today).order(:date)\n @meeting_next = current_user.meetings.where('date > ?' ,Date.today).order(:date)\n @meeting_curr = current_user.meetings.where('date = ?' ,Date.today).order(:date)\n end", "def show\n @meeting = Meeting.find(params[:id])\n @user = User.find_by_watiam(session[:cas_user])\n\n @allattendees = Attendee.where(:meeting_id => @meeting.id).all\n @allattendees.find(:sort => 'weight')\n @allusers = []\n \n \n #creates array of users that are attending the meeting\n @allattendees.each do |attendee|\n @userall = User.find(:first, :conditions => {:id => attendee.user_id})\n @allusers << @userall\n end\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meeting }\n end\n end", "def index\n @hostel_rooms = HostelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hostel_rooms }\n end\n end", "def index\n @meetups = Meetup.all\n @tags = Tag.all\n @tagmeetups = Tagmeetup.all\n\n end", "def index\n @employes = Employe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employes }\n end\n end", "def index\n @innings = Inning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @innings }\n end\n end", "def index\n @workout_days = WorkoutDay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workout_days }\n end\n end", "def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end", "def index\n @employers = Employer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employers }\n end\n end", "def index\n @mailings = Mailing.order(\"created_at DESC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mailings }\n end\n end", "def index\n @hours = Hour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hours }\n end\n end", "def index\n @meetingrooms = @space.meetingrooms.all\n end" ]
[ "0.86881256", "0.81708425", "0.81708425", "0.81708425", "0.81708425", "0.81708425", "0.81708425", "0.8025989", "0.7966836", "0.7900239", "0.78949094", "0.7830946", "0.7798126", "0.7752799", "0.7608941", "0.7580707", "0.7494635", "0.7447039", "0.74112105", "0.73653543", "0.73025304", "0.72573894", "0.7252033", "0.7240805", "0.7215655", "0.7145126", "0.71167564", "0.7110214", "0.7104761", "0.7079142", "0.69763225", "0.6959675", "0.69309306", "0.690847", "0.69011545", "0.6896196", "0.6896196", "0.68302363", "0.68190557", "0.68101454", "0.67879605", "0.6785934", "0.6785371", "0.6689359", "0.6650057", "0.6649687", "0.66397506", "0.6631583", "0.6626978", "0.66264486", "0.6618824", "0.66152203", "0.66148335", "0.6607765", "0.659987", "0.6597789", "0.65907085", "0.6586632", "0.6580189", "0.65582216", "0.6549989", "0.65421736", "0.65409124", "0.6539", "0.653743", "0.65255237", "0.6514223", "0.6509516", "0.6508912", "0.6507199", "0.65028447", "0.6498073", "0.64980185", "0.6492273", "0.6490192", "0.64896154", "0.6487448", "0.648224", "0.648224", "0.648224", "0.6479892", "0.6475989", "0.6474716", "0.6472538", "0.6471297", "0.6470289", "0.64666194", "0.646353", "0.64613354", "0.646089", "0.64593583", "0.64572144", "0.6451674", "0.64467096", "0.6446365", "0.64343566", "0.6431295", "0.64305633", "0.642228", "0.6419609", "0.6409539" ]
0.0
-1
POST /meetings POST /meetings.json
def create @team = Team.find(params[:team_id]) @meeting = @team.meetings.new(meeting_params) respond_to do |format| if @meeting.save format.js {render json: @meeting.id} format.json { render :show, status: :created, location: @meeting } format.html { redirect_to team_meeting_path(@team, @meeting), notice: 'הפגישה נוצרה בהצלחה.' } else format.json { render json: @meeting.errors, status: :unprocessable_entity } format.js format.html { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @meeting = current_user.meetings.new(meeting_params)\n new_event(@meeting)\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to new_event_path, notice: 'Meeting was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to meetings_path, notice: 'Meeting was successfully created.' }\n format.json { render json: @meeting, status: :created, location: @meeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to meeting_path(@meeting), notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @meeting = Meeting.new(meeting_params)\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to meetings_path, notice: 'La réunion a bien été ajoutée.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = current_user\n @meeting = current_user.meetings.build(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to root_path, notice: 'Enhorabuena! Tienes una nueva reunion.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n @meeting.user_id = current_user.id\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to user_meetings_path, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @meetings = Meeting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n @meeting.checked_out_participant_count = 0\n @meeting.participant_count ||= 0\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render action: 'show', status: :created, location: @meeting }\n else\n format.html { render action: 'new' }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meetup = Meetup.new(meetup_params)\n @meetup.on_ranking = true\n authorize @meetup\n respond_to do |format|\n if @meetup.save\n @meetup.sessions.create(location_id: Location.where(active: true).first.id)\n @activity = @meetup.create_activity(current_user.id)\n @notifications = @activity.create_notification\n @meetup.holdings.create(user_id: current_user.id)\n notify_collaborators\n format.html { redirect_to meetup_path(@meetup) }\n format.json do\n render :show,\n status: :created, location: @meetup\n end\n else\n format.html { render :new }\n format.json do\n render json: @meetup.errors,\n status: :unprocessable_entity\n end\n end\n end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to root_path, flash: {success: 'Meeting was successfully created.'} }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { redirect_to new_meeting_path, flash: {danger: \"Unable to create meeting. \" + @meeting.errors.full_messages.join('. ')} }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to weekly_calendar_url, notice: 'Meeting was successfully created.' }\n format.json { render json: @meeting, status: :created, location: @meeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n # respond_to do |format|\n # if @meeting.save\n # format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n # format.json { render :show, status: :created, location: @meeting }\n # else\n # format.html { render :new }\n # format.json { render json: @meeting.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n\n create_meetings_topics(@meeting)\n end", "def create\n @meetings_list = MeetingsList.new(meetings_list_params)\n\n respond_to do |format|\n if @meetings_list.save\n format.html { redirect_to @meetings_list, notice: 'Die Meeting-Liste wurde erfolgreich erstellt.' }\n format.json { render :show, status: :created, location: @meetings_list }\n else\n format.html { render :new }\n format.json { render json: @meetings_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(create_params)\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n add_user_meeting_relation\n end", "def create\n @meeting = Meeting.new(meeting_params)\n @meeting.created_by = current_user.id\n @meeting.users << current_user\n @meeting.users << User.find(params[:teacher_id])\n\n respond_to do |format|\n if @meeting.save && @meeting.date > DateTime.now\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n elsif @meeting.date <= DateTime.now\n format.html { redirect_to '/meetings/new', alert: 'You cannot create a meeting in the past.' }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.find(params[:user_id])\n @mycontact = Mycontact.find(params[:mycontact_id])\n @meeting = @mycontact.meetings.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to user_mycontact_meetings_path, notice: 'Meeting was successfully created.' }\n format.json { render action: 'show', status: :created, location: @meeting }\n else\n format.html { render action: 'new' }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @users_meeting = UsersMeeting.new(params[:users_meeting])\n\n respond_to do |format|\n if @users_meeting.save\n format.html { redirect_to @users_meeting, notice: 'Users meeting was successfully created.' }\n format.json { render json: @users_meeting, status: :created, location: @users_meeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @users_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meet = Meet.new(params[:meet])\n @meet.site_id = @site.id\n respond_to do |format|\n if @meet.save\n format.html { redirect_to @meet, notice: 'Meet was successfully created.' }\n format.json { render json: @meet, status: :created, location: @meet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rooms = Room.all\n @users = User.all\n @meeting = Meeting.new(meeting_params)\n @meeting.users << current_user\n \n respond_to do |format|\n if @meeting.save\n EventMailer.with(meeting: @meeting, users: @meeting.users.map {|u| u}).new_meeting_email.deliver_now\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meal_meeting = MealMeeting.new(params[:meal_meeting])\n\n respond_to do |format|\n if @meal_meeting.save\n format.html { redirect_to @meal_meeting, notice: 'Meal meeting was successfully created.' }\n format.json { render json: @meal_meeting, status: :created, location: @meal_meeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meal_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @meeting = Meeting.new\n @all = User.all\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def save\n if new_record?\n overwrite @api.post(\"/meetings.json\", writeable_attributes)\n else\n overwrite @api.put(\"/meetings/#{shortcode_url}.json\",\n writeable_attributes)\n end\n end", "def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n\n @meeting.user = @current_user\n @meeting.location = Location.find(params[:location])\n \n if u = params[:name]\n u.sub(/,$/,'').split(',').each{|a| @meeting.people << Person.find(a)}\n end\n if t = params[:time]\n if t =~ /m/\n @meeting.duration = 60*t.to_i\n elsif t =~ /h/\n @meeting.duration = 3600*t.to_i\n end\n end\n \n respond_to do |format|\n if @meeting.save\n format.html do\n # redirect_to(@meeting)\n render :partial => @meeting\n end\n format.xml { render :xml => @meeting, :status => :created, :location => @meeting }\n format.json { render :text => {\"name\" => @meeting.people.map(&:name).join(\", \"), \"time_str\" => @meeting.time_str}.to_json }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n format.json { render :text => {\"error\" => \"could not save\"}.to_json }\n end\n end\n end", "def set_meetings_list\n @meetings_list = MeetingsList.find(params[:id])\n end", "def meeting_params\n params.require(:meeting).permit(:name, :date, :s_time, :e_time, :room_id, :attending, user_ids: [])\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = Meeting.all\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n @iteration = Iteration.find(params[:meeting][:iteration_id])\n respond_to do |format|\n if developer?\n if @meeting.save\n flash[:notice] = 'Meeting was successfully created.'\n format.html do \n \n params[:users].each do |uid|\n user = User.find(uid)\n MeetingParticipant.create(:user => user, :meeting => @meeting)\n end if params.key? :users\n \n redirect_to(iteration_stories_url(@iteration))\n end\n format.xml { render :xml => @meeting, :status => :created, :location => @meeting }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n else\n format.xml { render :xml => XML_ERRORS[:not_authorized] }\n end\n end\n end", "def index\n render json: meeting.all\n end", "def index\n\n if params[:meeting_id]\n @meeting = Meeting.find(params[:meeting_id])\n end\n\n respond_to do |f|\n f.json {\n @meetings = Meeting\n start_p = Time.parse(params[:start])\n end_p = Time.parse(params[:end])\n @meetings = @meetings.where(\"start_at > ?\", params[:start])\n if start_p and end_p\n duration = end_p - start_p\n @meetings = @meetings.where(\"duration < ?\", duration)\n end\n\n render :json => @meetings.map{|m|\n {\n :id => m.id,\n :title => m.label,\n :start => m.start_at,\n :end => m.end_at,\n :url => \"/reunions/#{m.id}.js\",\n color: '#D42700',\n textColor: 'white'\n }\n }\n }\n f.html\n end\n end", "def create\n @users_meeting = UsersMeeting.new(users_meeting_params)\n\n respond_to do |format|\n if @users_meeting.save\n format.html { redirect_to @users_meeting, notice: 'Users meeting was successfully created.' }\n format.json { render :show, status: :created, location: @users_meeting }\n else\n format.html { render :new }\n format.json { render json: @users_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_meetings\n prepare\n @api.get_meetings\n end", "def create\n @title = \"ミーティング登録\"\n @catch_phrase = \"  新規にミーティングを登録します。\"\n @notice = \"\"\n @meeting = Meeting.new(params[:meeting])\n @projects = Project.where(\"id > 0\").order(\"name ASC\")\n @users = User.where(\"id > 0\").where(\"available=TRUE\").order(\"user_name ASC\")\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: '作成が完了しました!' }\n format.json { render json: @meeting, status: :created, location: @meeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting_member = MeetingMember.new(params[:meeting_member])\n\n respond_to do |format|\n if @meeting_member.save\n format.html { redirect_to @meeting_member, :notice => 'Meeting member was successfully created.' }\n format.json { render :json => @meeting_member, :status => :created, :location => @meeting_member }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @meeting_member.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @request_meeting = RequestMeeting.new params[:request_meeting]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request_meeting }\n end\n end", "def index\n @meetings = Meeting.all\nend", "def meeting_params\n params.require(:meeting).permit(:meeting, :user_id, :mycontact_id, :name)\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 create\n\t@meeting = Meeting.create(params[:meeting])\n \n print \"URL\", url_for(@meeting) + \"?key=\" + @meeting.uuid\n\tredirect_to url_for(@meeting) + \"?key=\" + @meeting.uuid\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n @meeting.attendeePW = rand(36**20).to_s(36)\n @meeting.moderatorPW = rand(36**20).to_s(36)\n @meeting.user_id = session[:user_id]\n #puts session[:user_id].inspect\n @meeting.name = Subject.find(@meeting.subject).title + Time.now.strftime('_%y%m%d%h%m')\n if @meeting.tutor.rate == 0\n @meeting.paid = true\n end\n @meeting.status = 0\n respond_to do |format|\n if @meeting.save\n ta = TutorAvailability.find(@meeting.tutor_availability_id)\n ta.taken = 1\n ta.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render json: @meeting, status: :created, location: @meeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def meetings_list_params\n params.require(:meetings_list).permit(:title, :responsible)\n end", "def create\n @request_meeting = RequestMeeting.new(params[:request_meeting])\n @request_meeting.user = current_user\n respond_to do |format|\n if @request_meeting.save\n format.html { redirect_to @request_meeting, notice: 'Заявка подана. Ожидается подтверждение администратором' }\n format.json { render json: @request_meeting, status: :created, location: @request_meeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @request_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def meeting_params\n params.require(:meeting).permit(:title, :date, :location, :description, :created_by, :address)\n end", "def meeting_params\n params.require(:meeting).permit(:start_time, :end_time, :name, :participant_count, :salary, :cost, :location, :agenda, :actions, :checked_out_participant_count, :phone_number_to_text)\n end", "def create\n @fetmeeting = Fetmeeting.new(params[:fetmeeting])\n\n respond_to do |format|\n if @fetmeeting.save\n format.html { redirect_to @fetmeeting, notice: 'Fetmeeting was successfully created.' }\n format.json { render json: @fetmeeting, status: :created, location: @fetmeeting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fetmeeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n\n respond_to do |format|\n if @meeting.save\n flash[:notice] = 'Meeting was successfully created.'\n format.html { redirect_to(@meeting) }\n format.xml { render :xml => @meeting, :status => :created, :location => @meeting }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @meetings_lists = MeetingsList.all\n end", "def meeting_params\n params.require(:meeting).permit(:name, :start_date, :end_time)\n end", "def meeting_params\n params.require(:meeting).permit(:date, :group_id)\n end", "def new\n @users_meeting = UsersMeeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @users_meeting }\n end\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n\n respond_to do |format|\n if @meeting.save\n flash[:notice] = 'Meeting creato con successo.'\n format.html { redirect_to(@meeting) }\n format.xml { render :xml => @meeting, :status => :created, :location => @meeting }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @meeting_time = MeetingTime.new(meeting_time_params)\n\n respond_to do |format|\n if @meeting_time.save\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @meeting_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @annual_meeting = AnnualMeeting.new(annual_meeting_params)\n\n respond_to do |format|\n if @annual_meeting.save\n format.html { redirect_to @annual_meeting, notice: 'Annual meeting was successfully created.' }\n format.json { render :show, status: :created, location: @annual_meeting }\n else\n format.html { render :new }\n format.json { render json: @annual_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if meeting.save\n format.html { redirect_to( meeting, flash: { success: 'Meeting created.' } ) }\n format.xml { render xml: meeting, status: :created, location: meeting }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n dateFormats = ['%m/%d/%Y %I:%M %p %Z', '%Y-%m-%dT%H:%M %Z']\n # 2016-05-10T10:10 or 05/21/2015 10:07 pm\n # 2016-10-18T00:24\n dateStr = meeting_params[:date] + \" \" + Time.zone.now.strftime('%Z')\n logger.info(\"dateStr: \" + dateStr)\n parsedDate = nil\n\n dateFormats.each do |format|\n parsedDate ||= DateTime.strptime(dateStr, format) rescue nil\n end\n\n if parsedDate.nil?\n logger.error(\"No date found for input date: \" + dateStr)\n raise ActiveRecord::RecordNotFound()\n end\n\n @meeting = Meeting.new({\n meeting_type: MeetingType.find(meeting_params[:meeting_type]),\n met: parsedDate,\n school_id: @_current_school.id,\n comment: meeting_params[:comment]\n })\n\n memberIds = meeting_params[:students].split(\",\")\n assistIds = meeting_params[:assistants].split(\",\")\n student_role = Role.student_role\n instructor_role = Role.teacher_role\n assistant_role = Role.assistant_role\n\n # Create an array of tuples, role to member to then add.\n students = Member.find(memberIds)\n assistants = Member.find(assistIds)\n instructor = Member.find(meeting_params[:instructor])\n\n mmembs = students.collect {|mem| [student_role, mem]} + assistants.collect {|mem| [assistant_role, mem]} + [instructor].collect {|mem| [instructor_role, mem]}\n\n mmembs.each do |mmem|\n puts mmem.inspect\n role, member = mmem\n mm = MeetingMember.new({\n meeting: @meeting,\n member: member,\n belt: member.belt,\n role: role,\n })\n\n mm.save\n end\n\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to meetings_path(), notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meetup = Meetup.new(params[:meetup])\n\[email protected]\n\n\n respond_to do |format|\n if @meetup.save\n\n\t\t\n\t\t\n \n\n format.html { redirect_to @meetup, notice: 'Meetup was successfully created.' }\n format.json { render json: @meetup, status: :created, location: @meetup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def meeting_params\n params.require(:meeting)\n .permit(\n :name, :kind_id, :related_meeting_id, :dates, :start_time, :lock_version,:approver_id,\n :scheduled_time_id, :venue, :message, :unregistered_guest,\n proceeding_attributes: [:id, :meeting_id],\n observers_attributes: [:id, :user_id],\n participants_attributes: [:id, :user_id])\n end", "def meeting_params\n params.require(:meeting).permit(\n :calendar_id,\n :start_time,\n :end_time,\n :title,\n :attendees_number,\n :agenda\n )\n end", "def meeting_params\n params.require(:meeting).permit(:name, :start_time, :end_time, :category)\n end", "def meeting_params\n params.require(:meeting).permit(:title, :meeting_start, :meeting_end, :user_id, :room_id)\n end", "def create\n @horse_meet = HorseMeet.new(horse_meet_params)\n\n respond_to do |format|\n if @horse_meet.save\n format.html { redirect_to @horse_meet, notice: 'Horse meet was successfully created.' }\n format.json { render :show, status: :created, location: @horse_meet }\n else\n format.html { render :new }\n format.json { render json: @horse_meet.errors, status: :unprocessable_entity }\n end\n end\n end", "def meeting_params\n params.require(:meeting).permit(:user_id, :room_id, :start_time, :end_time, :date, :summary)\n end", "def meeting_params\n params.require(:meeting).permit(:title, :start_datetime, :summary, :finished_flg)\n end", "def index\n\n @staticpage = Staticpage.find(:first, :conditions => [\"page_name = ?\", \"MeetingNotes\"]) \n \n @meetings = Meeting.find(:all, :order => [\"meeting_date desc\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end", "def meeting_params\n params.require(:meeting).permit(:user_id, :friend_id, :location_id, :agenda, :start_time, :end_time, :state)\n end", "def index\n @meetings = User.find(params[:user_id]).meetings\n #@meetings = Array.new\n Meeting.all.each do |m|\n if m.user_id == current_user.id\n @meetings.push(m)\n end\n end\n end", "def pending_meets \n assert_internal_error(@user)\n @pending_meets = @user.true_pending_meets\n respond_to do |format|\n format.html {\n # redirect back to user meets view if no more pending meets\n if @pending_meets.empty?\n redirect_back user_meets_path(@user)\n else\n @pending_meets = @pending_meets.paginate(:page => params[:page], :per_page => 25)\n attach_meet_infos(current_user, @pending_meets, true)\n end\n }\n format.json {\n cursor = params[:cursor] || params\n @pending_meets = @pending_meets.cursorize(cursor,\n :only=>[:time, :created_at, :updated_at, :lat, :lng])\n attach_meet_infos(current_user, @pending_meets, true)\n @pending_meets.each {|meet|\n meet.friends_name_list_params = {:except=>current_user,:delimiter=>\", \",:max_length=>80}\n }\n render :json => @pending_meets.to_json(MeetsController::JSON_PENDING_MEET_LIST_API)\n }\n end\n end", "def index\n if current_user.usertype == \"superadmin\"\n @meetings = Meeting.all\n elsif params[:type] == nil\n @meetings = Meeting.find(:all, :conditions => [\"user_id = ? \", session[:user_id]] )#you are student\n elsif params[:type]=='pending' #meeting requested by the current user\n @meetings = Meeting.find(:all, :conditions=> [\"accept =0 and status = 0 and (tutor_id = ? or user_id = ?)\", session[:tutor_id], session[:user_id]])\n elsif params[:type]=='past'#meeting you attended in the past\n @meetings = Meeting.find(:all, :conditions=> [\"(tutor_id = ? OR user_id = ? )and status >= ?\", session[:tutor_id], session[:user_id], 3])\n elsif params[:type]=='attending' #meeting list that you will be attending(accepted, paid)\n @meetings = Meeting.find(:all, :conditions => ['(user_id = ? or tutor_id = ?) AND status = ? AND paid = ?', session[:user_id],session[:tutor_id], 1, true])\n else\n @meetings = Meeting.find(:all, :conditions => ['(user_id = ? or tutor_id = ?) AND status = ? AND paid = ?', session[:user_id],session[:tutor_id], 1, true])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end", "def create\n @meetup = Meetup.new(meetup_params)\n\n respond_to do |format|\n if @meetup.save\n # this should take us to conversations.\n # format.html { redirect_to @meetup, notice: \"Meetup was successfully created.\" }\n # instead of showing the meetup, we want to share it!\n format.html { redirect_to conversations_path(@meetup), notice: \"Meetup was successfully created. Please click on a conversation to share your meetup.\" }\n format.json { render :show, status: :created, location: @meetup }\n # p @meetup, '< MEETUP'\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @meal_meeting = MealMeeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meal_meeting }\n end\n end", "def meeting_params\n params.require(:meeting).permit(:meeting_on, :structure_id, :location, :duration, :starts_at, :attendees_male, :attendees_females, :meeting_held, :closenote, :reopennote, issue_ids: [])\n end", "def meeting_params\n params.require(:meeting).permit(:name, :division_id, :user_id)\n end", "def create\n @meeting = Meeting.new(meeting_params)\n @meeting.valid?\n @meeting.save\n redirect_to users_show_path\n end", "def create\n # @meeting_thread = MeetingThread.new(params[:meeting_thread])\n\n respond_to do |format|\n if @meeting_thread.save\n format.html { redirect_to @meeting_thread, notice: 'Meeting thread was successfully created.' }\n format.json { render json: @meeting_thread, status: :created, location: @meeting_thread }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting_thread.errors, status: :unprocessable_entity }\n end\n end\n end", "def meeting_params\n params.require(:meeting).permit(:name, :start_time)\n end", "def fetch_meetings\n response = self.api.get_meetings\n\n # updates the information in the rooms that are currently in BBB\n @meetings = []\n response[:meetings].each do |attr|\n room = BigbluebuttonRoom.find_by_server_id_and_meetingid(self.id, attr[:meetingID])\n if room.nil?\n room = BigbluebuttonRoom.new(:server => self, :meetingid => attr[:meetingID],\n :name => attr[:meetingID], :attendee_password => attr[:attendeePW],\n :moderator_password => attr[:moderatorPW], :external => true,\n :randomize_meetingid => false, :private => true)\n else\n room.update_attributes(:attendee_password => attr[:attendeePW],\n :moderator_password => attr[:moderatorPW])\n end\n room.running = attr[:running]\n\n @meetings << room\n end\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n @user = User.find_by_watiam(session[:cas_user])\n @meeting.user_id = @user.id\n @all = User.all\n\n respond_to do |format|\n if @meeting.save\n \n AgendaReminder.reminder_email(@user, @meeting).deliver\n \n if params[:all?] == true\n @all.each do |id|\n @a = Attendee.new\n @d = Discussion.new\n @a.meeting_id = @meeting.id\n @a.user_id = id\n @d.meeting_id = @meeting.id\n @d.user_id = id\n @a.weight = @a.user_id\n @a.save\n @d.save\n end\n else \n params[:user_ids].each do |id|\n @a = Attendee.new\n @d = Discussion.new\n @a.meeting_id = @meeting.id\n @a.user_id = id\n @d.meeting_id = @meeting.id\n @d.user_id = id\n @a.weight = @a.user_id\n @a.save\n @d.save\n end\n end\n \n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render json: @meeting, status: :created, location: @meeting }\n \n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def meetup_params\n params.permit(:title, :description, :location, :start_time, :end_time, :date, :game_id)\n end", "def create\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n @role_player = RolePlayer.new\n @role_player.member = Member.find(params['meeting']['member_id'])\n @role_player.role = Role.find(params['meeting']['role_id'])\n @role_player.meeting = @meeting\n @role_player.save\n\n if @meeting.save\n format.html { redirect_to edit_meeting_path(@meeting), notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def meeting_params\n params.require(:meeting).permit(:meetingname,:date)\n end", "def meeting_params\n params.require(:meeting).permit(:room_id, :date_time, :message, :phone)\n end", "def create\n @meeting_group = MeetingGroup.new(meeting_group_params)\n\n respond_to do |format|\n if @meeting_group.save\n format.html { redirect_to @meeting_group, notice: 'Meeting group was successfully created.' }\n format.json { render :show, status: :created, location: @meeting_group }\n else\n format.html { render :new }\n format.json { render json: @meeting_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def meeting_params\n params.require(:meeting).permit(:meeting_type, :date, :instructor, :assistants, :students, :comment)\n end", "def new\n @meetup = Meetup.new\n @recipient = User.find_by_id(params[:recipient_id])\n \n @recipient_meetups = []\n @recipient.upcoming_meetups.each do |m|\n @recipient_meetups.push({:title=> @recipient.name, :start=> m.date.strftime('%m-%d-%Y %H:%M:%S'), :end=> (m.date + 1.hour).strftime('%m-%d-%Y %H:%M:%S'), :allDay=> false})\n end\n \n @my_meetups = []\n current_user.upcoming_meetups.each do |m|\n @my_meetups.push({:title=> current_user.name, :start=> m.date.strftime('%m-%d-%Y %H:%M:%S'), :end=> (m.date + 1.hour).strftime('%m-%d-%Y %H:%M:%S'), :allDay=> false})\n end\n\n gon.recipient = @recipient\n gon.me = current_user\n gon.recipient_meetups = @recipient_meetups\n gon.my_meetups = @my_meetups\n \n @current_user = current_user\n @prev_meetup_id = params[:prev_meetup_id]\n \n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def meeting_create(*args)\n options = Zoom::Params.new(Utils.extract_options!(args))\n options.require(%i[user_id])\n Utils.process_datetime_params!(:start_time, options)\n Utils.parse_response self.class.post(\"/users/#{options[:user_id]}/meetings\", body: options.except(:user_id).to_json, headers: request_headers)\n end", "def create\n @meeting_type = MeetingType.new(meeting_type_params)\n\n respond_to do |format|\n if @meeting_type.save\n format.html { redirect_to @meeting_type, notice: 'Meeting type was successfully created.' }\n format.json { render :show, status: :created, location: @meeting_type }\n else\n format.html { render :new }\n format.json { render json: @meeting_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting = Meeting.new(params[:meeting])\n @meeting.club_id = params[:club_id]\n meeting_date = @meeting.meeting_date.strftime(\"%m/%d/%Y\") if @meeting.meeting_date\n @meeting.meeting_time = params[:meeting][:meeting_time]\n \n respond_to do |format|\n if @meeting.save\n format.html { redirect_to new_club_meeting_path(params[:club_id]), notice: \"Meeting for #{meeting_date} was successfully created.\" }\n format.json { render json: @meeting, status: :created, location: @meeting }\n \n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity } \n end\n end\n end", "def create\n\n @meeting = Meeting.new(meeting_params)\n\n respond_to do |format|\n if @meeting.save\n Userlog.create(user_id: current_user.id, loggable_type: 'Meeting', loggable_id: @meeting.id, action: 'Create')\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render :show, status: :created, location: @meeting }\n else\n format.html { render :new }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meetingroom = @space.meetingrooms.new(meetingroom_params)\n @meetingroom.user = current_user\n\n respond_to do |format|\n if @meetingroom.save\n format.html { redirect_to [@space, @meetingroom], notice: 'Meetingroom was successfully created.' }\n format.json { render :show, status: :created, location: [@space, @meetingroom] }\n else\n format.html { render :new }\n format.json { render json: @meetingroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def count_meetings\n team = Team.find_by_id( params[:id] )\n if team\n render( json: team.meetings.collect{|row| row.id}.uniq.size )\n else\n render( json: 0 )\n end\n end" ]
[ "0.70881873", "0.7059875", "0.67819774", "0.67814976", "0.6768945", "0.6760446", "0.6747356", "0.67396617", "0.6738901", "0.67336243", "0.6678363", "0.6646479", "0.66382647", "0.6622729", "0.66189617", "0.6601062", "0.65877753", "0.65678734", "0.6533456", "0.64769936", "0.6474063", "0.64435196", "0.6440459", "0.6415573", "0.64121455", "0.63912606", "0.63912606", "0.63912606", "0.63598347", "0.63483655", "0.63421094", "0.63420206", "0.63420206", "0.63420206", "0.63420206", "0.63420206", "0.63420206", "0.6321787", "0.6319155", "0.6310566", "0.63055885", "0.6305048", "0.6242658", "0.6209663", "0.62026423", "0.6192533", "0.6140771", "0.6138797", "0.61355776", "0.61276656", "0.6122457", "0.6110245", "0.61101305", "0.6108683", "0.61059153", "0.608339", "0.608065", "0.6070681", "0.6068287", "0.6065569", "0.6061517", "0.6041713", "0.60385567", "0.6032881", "0.6030721", "0.6025718", "0.60241747", "0.6023755", "0.6015179", "0.60127866", "0.60101426", "0.6009779", "0.59983295", "0.5997168", "0.59851944", "0.5981651", "0.5980913", "0.597757", "0.5967982", "0.5963014", "0.5940867", "0.5933987", "0.5925104", "0.5912851", "0.5907862", "0.58863467", "0.5883346", "0.5879283", "0.5877321", "0.5873805", "0.5870928", "0.5863383", "0.5849168", "0.58370507", "0.5836403", "0.583603", "0.58328766", "0.58204675", "0.58126557", "0.5807469" ]
0.6625905
13
PATCH/PUT /meetings/1 PATCH/PUT /meetings/1.json
def update @team = Team.find(params[:team_id]) respond_to do |format| if @meeting.update(meeting_params) format.js {render json: @meeting.id} format.html { redirect_to team_meeting_path(@team, @meeting), notice: 'הפגישה עודכנה בהצלחה.' } format.json { render :show, status: :ok, location: @meeting } else format.html { render :edit } format.json { render json: @meeting.errors, status: :unprocessable_entity } format.js {render json: @meeting.id} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.json { head :no_content }\n else\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meet = Meet.find(params[:id])\n\n respond_to do |format|\n if @meet.update_attributes(params[:meet])\n format.html { redirect_to @meet, notice: 'Meet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to meetings_path, notice: 'Meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n \n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @request_meeting = RequestMeeting.find(params[:id])\n\n respond_to do |format|\n if @request_meeting.update_attributes(params[:request_meeting])\n format.html { redirect_to @request_meeting, notice: 'Request meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:user_id])\n @mycontact = @user.mycontacts.find(params[:mycontact_id])\n @meeting= @mycontact.meetings.find(params[:id])\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to user_mycontact_meetings_path, notice: 'Meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if @meeting.update_attributes(meeting_params)\n format.html { redirect_to weekly_calendar_url, notice: 'Meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n\n\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = current_user\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to user_meetings_path(@user), notice: 'Editado correctamente.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meetup = Meetup.find(params[:id])\n\n respond_to do |format|\n if @meetup.update_attributes(params[:meetup])\n format.html { redirect_to @meetup, notice: 'Meetup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @meeting.assign_attributes(params[:meeting])\n if @meeting.save\n format.js { head :no_content }\n format.html { redirect_to @meeting, notice: 'Meeting successfully updated.' }\n format.json { head :no_content }\n else\n format.js { render :json => { :errors => @meeting.errors.full_messages, :message => \"Problem updating meeting\" }, :status => :unprocessable_entity }\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update_attributes(meeting_params)\n format.html { redirect_to user_meeting_path, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meal_meeting = MealMeeting.find(params[:id])\n\n respond_to do |format|\n if @meal_meeting.update_attributes(params[:meal_meeting])\n format.html { redirect_to @meal_meeting, notice: 'Meal meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meal_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @users_meeting = UsersMeeting.find(params[:id])\n\n respond_to do |format|\n if @users_meeting.update_attributes(params[:users_meeting])\n format.html { redirect_to @users_meeting, notice: 'Users meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @users_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @meetup\n respond_to do |format|\n if @meetup.update(meetup_params)\n notify_collaborators\n format.html { redirect_to meetup_path(@meetup) }\n format.json { render :show, status: :ok, location: @meetup }\n else\n format.html { render :edit }\n format.json do\n render json: @meetup.errors,\n status: :unprocessable_entity\n end\n end\n end\n end", "def meeting_update(*args)\n options = Zoom::Params.new(Utils.extract_options!(args))\n options.require(%i[meeting_id])\n Utils.process_datetime_params!(:start_time, options)\n # TODO Handle `topic` attr, Max of 300 characters.\n # TODO Handle `timezone` attr, refer to the id value in timezone list JSON file. like \"America/Los_Angeles\"\n # TODO Verify `password` attr, may only contain the following characters: a-z A-Z 0-9 @ - _\n # TODO Handle `option_audio` attr, Can be \"both\", \"telephony\", \"voip\".\n # TODO Handle `option_auto_record_type`, Can be \"local\", “cloud” or \"none\".\n Utils.parse_response self.class.patch(\"/meetings/#{options[:meeting_id]}\", body: options.except(:meeting_id).to_json, headers: request_headers)\n end", "def update\n respond_to do |format|\n if meeting.save\n format.html { redirect_to meeting, flash: { success: 'Meeting updated.' } }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n if @meeting.update_attributes(meeting_params)\n flash[:info] = \"successfully updated\"\n redirect_to meetings_path\n else\n flash[:info] = \"fail to update\"\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to root_path, flash: {success: 'Meeting was successfully updated.'} } \n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { redirect_to edit_meeting_path, flash: {danger: \"Unable to edit meeting. \" + @meeting.errors.full_messages.join('. ')} }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if developer?\n #take care of meeting participants\n param_users = (params[:users].map {|i| i.to_i} rescue []).to_set\n meeting_users = (@meeting.meeting_participants.map {|mp| mp.user.id}).to_set\n (param_users - meeting_users).each {|uid| MeetingParticipant.create(:user => User.find(uid), :meeting => @meeting)}\n (meeting_users - param_users).each {|uid| MeetingParticipant.find(:first, :conditions => [\"meeting_id = ? and user_id = ?\", @meeting.id, uid]).destroy rescue nil}\n\n if @meeting.update_attributes(params[:meeting])\n flash[:notice] = 'Meeting was successfully updated.'\n format.html { redirect_to(iteration_stories_url(@meeting.iteration)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n else\n format.xml { render :xml => XML_ERRORS[:not_authorized] }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to meetings_path, notice: 'La réunion a bien été modifiée.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.user == current_user && @meeting.update(meeting_params)\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n @meeting.meeting_time = params[:meeting][:meeting_time]\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to club_meeting_path(params[:club_id],@meeting), notice: 'Meeting was successfully updated.' }\n format.json { head :ok }\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n \n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n\n create_meetings_topics(@meeting)\n end", "def update\n @fetmeeting = Fetmeeting.find(params[:id])\n\n respond_to do |format|\n if @fetmeeting.update_attributes(params[:fetmeeting])\n format.html { redirect_to @fetmeeting, notice: 'Fetmeeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fetmeeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n respond_to do |format|\n if @meeting.update(meeting_params)\n @meeting.users << current_user\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n flash[:notice] = 'Meeting was successfully updated.'\n format.html { redirect_to(@meeting) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to(@meeting, :notice => t(:meeting_notice_correctly_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meetup.update(meetup_params)\n format.html { redirect_to @meetup, notice: \"Meetup was successfully updated.\" }\n format.json { render :show, status: :ok, location: @meetup }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting_point = MeetingPoint.find(params[:id])\n\n respond_to do |format|\n if @meeting_point.update_attributes(params[:meeting_point])\n format.html { redirect_to @meeting_point, notice: 'Meeting point was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting_point.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meetup.update(meetup_params)\n format.html { redirect_to @meetup, notice: 'Meetup was successfully updated.' }\n format.json { render :show, status: :ok, location: @meetup }\n else\n format.html { render :edit }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @horse_meet.update(horse_meet_params)\n format.html { redirect_to @horse_meet, notice: 'Horse meet was successfully updated.' }\n format.json { render :show, status: :ok, location: @horse_meet }\n else\n format.html { render :edit }\n format.json { render json: @horse_meet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n flash[:notice] = 'Meeting aggiornato con successo.'\n format.html { redirect_to(@meeting) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @meeting_member = MeetingMember.find(params[:id])\n\n respond_to do |format|\n if @meeting_member.update_attributes(params[:meeting_member])\n format.html { redirect_to @meeting_member, :notice => 'Meeting member was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @meeting_member.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @users_meeting.update(users_meeting_params)\n format.html { redirect_to @users_meeting, notice: 'Users meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @users_meeting }\n else\n format.html { render :edit }\n format.json { render json: @users_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting_time.update(meeting_time_params)\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @meeting_type = MeetingType.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @meeting_type.update_attributes(params[:meeting_type])\r\n format.html { redirect_to @meeting_type, only_path: true, notice: 'Meeting type 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: @meeting_type.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @meetings_list.update(meetings_list_params)\n format.html do\n redirect_to @meetings_list,\n notice: 'Die Meeting-Liste wurde erfolgreich aktualisiert.'\n end\n format.json { render :show, status: :ok, location: @meetings_list }\n else\n format.html { render :edit }\n format.json { render json: @meetings_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meetuser.update(meetuser_params)\n format.html { redirect_to @meetuser, notice: 'Meetuser was successfully updated.' }\n format.json { render :show, status: :ok, location: @meetuser }\n else\n format.html { render :edit }\n format.json { render json: @meetuser.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @annual_meeting.update(annual_meeting_params)\n format.html { redirect_to @annual_meeting, notice: 'Annual meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @annual_meeting }\n else\n format.html { render :edit }\n format.json { render json: @annual_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @meetings = current_user.meetings.all\n end", "def update\n begin\n @appointment = Appointment.find(params[:id])\n rescue\n respond_info('error', 'internal_server_error', 'Update Appointment Failed', :internal_server_error)\n return\n end\n if @appointment.update(appointment_params)\n render :json => @appointments, :status => :no_content #HTTP status code: 204 No Content\n else\n render json: @appointment.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:meetup])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update_attributes(params[:participant]) && @meeting.update_attributes(@meeting.new_meeting_params_from(@participant, params[:participant]))\n flash[:notice] = 'Participant was successfully updated.'\n format.html { redirect_to(meeting_path(@meeting)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_meeting\n @meeting = current_user.meetings.find(params[:id] || params[:meeting_id])\n end", "def meeting_update_status(*args)\n options = Zoom::Params.new(Utils.extract_options!(args))\n options.require(%i[meeting_id])\n Utils.parse_response self.class.put(\"/meetings/#{options[:meeting_id]}/status\", body: options.except(:meeting_id).to_json, headers: request_headers)\n end", "def update\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n if user != nil and meeting != nil\n title = params[\"meeting\"][\"title\"]\n if title != nil\n meeting.title = title\n end\n result = meeting.save!\n if result\n self.send_ok\n else\n self.send_error 422\n end\n else\n self.send_error 401\n end\n end", "def update\n @sponsor_meeting = SponsorMeeting.find(params[:id])\n\n respond_to do |format|\n if @sponsor_meeting.update_attributes(params[:sponsor_meeting])\n format.html { redirect_to @sponsor_meeting, notice: 'Sponsor meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sponsor_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def save\n if new_record?\n overwrite @api.post(\"/meetings.json\", writeable_attributes)\n else\n overwrite @api.put(\"/meetings/#{shortcode_url}.json\",\n writeable_attributes)\n end\n end", "def update\n respond_to do |format|\n if @meeting_type.update(meeting_type_params)\n format.html { redirect_to @meeting_type, notice: 'Meeting type was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting_type }\n else\n format.html { render :edit }\n format.json { render json: @meeting_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_meetings_list\n @meetings_list = MeetingsList.find(params[:id])\n end", "def update\n respond_to do |format|\n if @meeting_follow_up.update(meeting_follow_up_params)\n format.html { redirect_to @meeting_follow_up, notice: 'Meeting follow up was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting_follow_up }\n else\n format.html { render :edit }\n format.json { render json: @meeting_follow_up.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @appointment.check_updated_params(appointment_params)\n if @appointment.update(appointment_params)\n render json: @appointment, status: 200\n else\n render json: @appointment.errors, status: 422\n end\n else\n p \"did not work\"\n end\n end", "def update\n respond_to do |format|\n if @meetingroom.update(meetingroom_params)\n format.html { redirect_to [@space, @meetingroom], notice: 'Meetingroom was successfully updated.' }\n format.json { render :show, status: :ok, location: [@space, @meetingroom] }\n else\n format.html { render :edit }\n format.json { render json: @meetingroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @appointment_request = current_user.requests.find_by(\n id: params[:request_id]\n )\n\n if @appointment_request.present?\n render json: { appointment_request: @appointment_request, status: 200 }\n else\n render json: { status: 404, layout: false }, status: 404\n end\n end", "def update\n @title = \"ミーティング編集\"\n @catch_phrase = \"  ミーティングの編集及び議事録の登録・編集を行います。\"\n @notice = \"\"\n \n @meeting = Meeting.find(params[:id])\n @projects = Project.joins('INNER JOIN project_users ON project_users.project_id = projects.id').where('project_users.user_id = ?', current_user.id).order(\"name ASC\")\n @users = User.where(\"id > 0\").order(\"user_name ASC\")\n\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to @meeting, notice: '更新が完了しました!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end", "def update\n #@meeting_thread = MeetingThread.find(params[:id])\n\n respond_to do |format|\n if @meeting_thread.update_attributes(params[:meeting_thread])\n format.html { redirect_to @meeting_thread, notice: 'Meeting thread was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting_thread.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting_location = MeetingLocation.find(params[:id])\n\n respond_to do |format|\n if @meeting_location.update_attributes(params[:meeting_location])\n format.html { redirect_to @meeting_location, notice: 'Meeting location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meetup_profile = MeetupProfile.find(params[:id])\n\n respond_to do |format|\n if @meetup_profile.update_attributes(params[:meetup_profile])\n format.html { redirect_to meetup_profile_path(@meetup_profile.id), notice: 'Meetup profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meetup_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end", "def set_meeting\n @meeting = User.find(params[:user_id]).meetings.find(params[:id])\n end", "def update\n @appointment = person.appointments.find(params[:id])\n respond_to do |format|\n if @appointment.update_attributes(params[:appointment])\n format.html { redirect_to([person, @appointment], :notice => 'Appointment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @appointment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @meetup_comment = MeetupComment.find(params[:id])\n\n respond_to do |format|\n if @meetup_comment.update_attributes(params[:meetup_comment])\n format.html { redirect_to meetup_path(@meetup_comment.event_id), notice: 'Meetup comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meetup_comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_midpoint\n @user = current_user.id\n @meetings = current_user.meetings\n @meeting = Meeting.find(params[\"meeting\"])\n @user_meeting = UserMeeting.find_by(\n :user_id => @user,\n :meeting_id => @meeting\n )\n @user_meeting.update(:start_address => params[\"startLocation\"])\n @user_meeting.get_lat_lng(params[\"startLocation\"])\n if @user_meeting.user_status == 'created'\n @pending_guests = UserMeeting.where(\n :user_status => 'invited',\n :meeting_id => @meeting\n )\n @pending_guests.update(:start_address => params[\"startLocation\"])\n @pending_guests.each{|pg| pg.get_lat_lng(params[\"startLocation\"])}\n end \n @meeting.recalculate_midpoint\n render json: @meetings, each_serializer: MeetingsInfoSerializer\n \n end", "def update\n respond_to do |format|\n if @waiter.update(waiter_params.slice(:name, :email, :mobile))\n format.html { redirect_to waiters_manager_path(current_user), notice: i18n_notice('updated',@waiter) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @waiter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lunch.update(lunch_params)\n format.html { redirect_to @lunch, notice: 'Lunch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lunch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @witness = Witness.find(params[:id])\n\n respond_to do |format|\n if @witness.update_attributes(params[:witness])\n # commented so hosts font receive emails off season\n # if(params[:witness][:host_id].present?)\n # HostMailer.witness_assigned(\n # params[:witness][:host_id],\n # @witness.id,\n # I18n.locale\n # ).deliver\n\n #@host = Host.find(params[:witness][:host_id])\n #@host.update_attributes(assignment_time: Time.now.utc.localtime)\n #end\n\n\n \n format.json { render json: @witness, status: :created, location: @witness }\n else\n format.json { render json: @witness.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @site = Site.first\n @meetup_info = @site.meetup_info\n\n respond_to do |format|\n if @meetup_info.update(meetup_info_params)\n format.html { redirect_to backstage_index_path, notice: 'meetup_info was successfully updated.' }\n # format.json { render :show, status: :ok, location: @meetup_info }\n else\n format.html { render :edit }\n # format.json { render json: @meetup_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n goal = Goal.find params[:id]\n if goal.update(goal_params)\n render json: goal, status: 200\n else\n render json: goal.errors.full_messages, status: 422\n end\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def update\n @appointment = Appointment.find(params[:id])\n\n respond_to do |format|\n if @appointment.update_attributes(params[:appointment])\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @appointment = Appointment.find(params[:id])\n\n respond_to do |format|\n if @appointment.update_attributes(params[:appointment])\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @meet_metadata = args[:meet_metadata] if args.key?(:meet_metadata)\n end", "def update\n @user_meeting_location = UserMeetingLocation.find(params[:id])\n\n respond_to do |format|\n if @user_meeting_location.update_attributes(params[:user_meeting_location])\n format.html { redirect_to user_meeting_locations_path, notice: 'User meeting location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_meeting_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n @assignment = Assignment.find(:first,\n :conditions => [\"assignable_type = ? and assignable_id = ?\",\n @meeting.class.to_s, @meeting.id])\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment]) &&\n @meeting.update_attributes(params[:meeting])\n flash[:notice] = 'Meeting was successfully updated.'\n format.html { redirect_to(@meeting) }\n format.xml { head :ok }\n else\n flash[:notice] = 'Meeting was not updated.'\n @statuses = get_status_dropdown\n @categories = get_category_dropdown\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end", "def set_meeting\n @meeting = Meeting.find(params[:id])\n end" ]
[ "0.72733486", "0.7263451", "0.720192", "0.7171919", "0.7135676", "0.70852876", "0.688029", "0.6860292", "0.6836023", "0.681179", "0.681179", "0.681179", "0.681179", "0.67926973", "0.67924505", "0.6791691", "0.6779588", "0.6758554", "0.67407507", "0.6720899", "0.67122144", "0.669359", "0.66813993", "0.6675525", "0.66747826", "0.666963", "0.66682035", "0.66615313", "0.6655645", "0.66276", "0.6596438", "0.6595764", "0.6579304", "0.65587544", "0.6554635", "0.65477544", "0.64939785", "0.64913005", "0.64893275", "0.64775914", "0.6432926", "0.6404786", "0.6404141", "0.63391286", "0.62792337", "0.62669986", "0.6264718", "0.6236397", "0.618704", "0.6176997", "0.61685085", "0.61649984", "0.6157057", "0.61566263", "0.6149039", "0.61451393", "0.6141993", "0.6132671", "0.6131608", "0.61142117", "0.61029834", "0.6093516", "0.6083224", "0.60820866", "0.60810226", "0.60585564", "0.6048155", "0.60301006", "0.60252774", "0.6018951", "0.59845376", "0.5975877", "0.59678525", "0.596215", "0.59592056", "0.59421945", "0.5941434", "0.5941434", "0.5941434", "0.5941434", "0.5941434", "0.5932345", "0.59230316", "0.59209603", "0.5914901", "0.5901768", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577", "0.58891577" ]
0.62381095
47
DELETE /meetings/1 DELETE /meetings/1.json
def destroy @team = @meeting.team @meeting.destroy respond_to do |format| format.html { redirect_to team_path(@team), notice: 'הפגישה נמחקה בהצלחה.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup = Meetup.find(params[:id])\n @meetup.destroy\n\n respond_to do |format|\n format.html { redirect_to meetups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request_meeting = RequestMeeting.find(params[:id])\n @request_meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to request_meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n delete_meetings_from_users\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n if !checkme? @meeting then return end\n \n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to(meetings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to(meetings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to(meetings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @meal_meeting = MealMeeting.find(params[:id])\n @meal_meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to meal_meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\t\t@title = \"Usuwanie spotkania\"\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :ok }\n end\n end", "def destroy\n @users_meeting = UsersMeeting.find(params[:id])\n @users_meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to users_meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to club_meetings_path(params[:club_id]) }\n format.json { head :ok }\n end\n end", "def destroy\n @fetmeeting = Fetmeeting.find(params[:id])\n @fetmeeting.destroy\n\n respond_to do |format|\n format.html { redirect_to fetmeetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to user_holder_meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to user_meetings_path, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup.destroy\n respond_to do |format|\n format.html { redirect_to meetups_url, notice: \"Meetup was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup.destroy\n respond_to do |format|\n format.html { redirect_to meetups_url, notice: 'Meetup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Reunion borrada :(' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'La réunion a bien été détruite.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting_point = MeetingPoint.find(params[:id])\n @meeting_point.destroy\n\n respond_to do |format|\n format.html { redirect_to meeting_points_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting_time.destroy\n respond_to do |format|\n format.html { redirect_to meeting_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting_member = MeetingMember.find(params[:id])\n @meeting_member.destroy\n\n respond_to do |format|\n format.html { redirect_to meeting_members_url }\n format.json { head :ok }\n end\n end", "def destroy\r\n @meeting_type = MeetingType.find(params[:id])\r\n @meeting_type.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to meeting_types_url, only_path: true }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to( committee_meetings_url( meeting.committee ),\n flash: { success: \"Meeting destroyed.\" } ) }\n format.xml { head :ok }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to request.referer, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @meetings_list.destroy\n authorize(@meetings_list.destroy)\n respond_to do |format|\n format.html do\n redirect_to root_url,\n notice: 'Liste erfolgreich vernichtet.'\n end\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to root_path, flash: {success:'Meeting was successfully removed.'} }\n format.json { head :no_content }\n end\n end", "def destroy\n @users_meeting.destroy\n respond_to do |format|\n format.html { redirect_to users_meetings_url, notice: 'Users meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetuser.destroy\n respond_to do |format|\n format.html { redirect_to meetusers_url, notice: 'Meetuser was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup = Meetup.find_by(id: params[:id])\n @meetup.destroy\n \n redirect_to user_meetups_url(current_user)\n end", "def destroy\n @horse_meet.destroy\n respond_to do |format|\n format.html { redirect_to horse_meets_url, notice: 'Horse meet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @annual_meeting.destroy\n respond_to do |format|\n format.html { redirect_to annual_meetings_url, notice: 'Annual meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:user_id])\n @mycontact = @user.mycontacts.find(params[:mycontact_id])\n @meeting= @mycontact.meetings.find(params[:id])\n @user = User.find(params[:user_id])\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to user_mycontact_meetings_path }\n format.json { head :no_content }\n end\n end", "def meeting_delete(*args)\n options = Zoom::Params.new(Utils.extract_options!(args))\n options.require(%i[meeting_id])\n Utils.parse_response self.class.delete(\"/meetings/#{options[:meeting_id]}\", query: options.except(:meeting_id), headers: request_headers)\n end", "def destroy\n @meet = Meet.find(params[:id])\n @meet.destroy\n @track = @meet.track\n respond_to do |format|\n format.html { redirect_to track_url(:id => @track.id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting_location = MeetingLocation.find(params[:id])\n @meeting_location.destroy\n\n respond_to do |format|\n format.html { redirect_to meeting_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type_of_meeting.destroy\n respond_to do |format|\n format.html {redirect_to type_of_meetings_url, notice: 'Type of meeting was successfully destroyed.'}\n format.json {head :no_content}\n end\n end", "def destroy\n @user = Meetup.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to meetups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy if @meeting.user == current_user\n respond_to do |format|\n format.html { redirect_to @meeting.user, notice: 'Meeting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup_profile = MeetupProfile.find(params[:id])\n @meetup_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\n @sponsor_meeting = SponsorMeeting.find(params[:id])\n @sponsor_meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to sponsor_meetings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @meeting_thread = MeetingThread.find(params[:id])\n @meeting_thread.destroy\n\n respond_to do |format|\n format.html { redirect_to meeting_threads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @meetup\n @meetup.destroy\n redirect_to(meetups_path)\n end", "def destroy\n @meeting_type.destroy\n respond_to do |format|\n format.html { redirect_to meeting_types_url, notice: 'Meeting type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetings_result = MeetingsResult.find(params[:id])\n @meetings_result.destroy\n\n respond_to do |format|\n format.html { redirect_to(meetings_results_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @meeting_follow_up.destroy\n respond_to do |format|\n format.html { redirect_to meeting_follow_ups_url, notice: 'Meeting follow up was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_meeting_location = UserMeetingLocation.find(params[:id])\n @user_meeting_location.destroy\n\n respond_to do |format|\n format.html { redirect_to user_meeting_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetingroom.destroy\n respond_to do |format|\n format.html { redirect_to space_meetingrooms_url(@space), notice: 'Meetingroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment.destroy\n head 204\n end", "def destroy\n @appointment = Appointment.find(params[:id])\n @appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to appointments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @appointment = Appointment.find(params[:id])\n @appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to appointments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment = Appointment.find(params[:id])\n @appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to appointments_url }\n format.json { head :no_content }\n end\n end", "def delete\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n participants = meeting.participants\n meeting.participants.delete(participants)\n meeting.delete\n self.send_ok\n else\n self.send_error 401\n end\n end", "def destroy\n @meetup_comment = MeetupComment.find(params[:id])\n @meetup_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting_group.destroy\n respond_to do |format|\n format.html { redirect_to meeting_groups_url, notice: 'Meeting group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @judge_activity.destroy\n respond_to do |format|\n format.html { redirect_to judge_activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup_rsvp = MeetupRsvp.find(params[:id])\n @meetup_rsvp.destroy\n\n respond_to do |format|\n format.html { redirect_to request.referer}\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment.destroy\n return render json: {status: :ok, message: 'Appointed deleted', code: 00}\n end", "def destroy\n @meeting_plan.destroy\n respond_to do |format|\n format.html { redirect_to meeting_plans_url, notice: 'Meeting plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @meal_time = MealTime.find(params[:id])\n @meal_time.destroy\n\n respond_to do |format|\n format.html { redirect_to meal_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url, notice: 'Exercise event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_timeslot.destroy\n respond_to do |format|\n format.html { redirect_to day_timeslots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment = Appointment.find(params[:id])\n @appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to user_appointments_path(current_user.id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @goat = Goat.find(params[:id])\n @goat.destroy\n\n respond_to do |format|\n format.html { redirect_to goats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_appointment = TestAppointment.find(params[:id])\n @test_appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to test_appointments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment.destroy\n respond_to do |format|\n format.html { redirect_to appointments_url, notice: t('destroy_success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @attendee = Attendee.find(params[:id])\n @attendee.destroy\n\n respond_to do |format|\n format.html { redirect_to attendees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attendee = Attendee.find(params[:id])\n @attendee.destroy\n\n respond_to do |format|\n format.html { redirect_to attendees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attendee = Attendee.find(params[:id])\n @attendee.destroy\n\n respond_to do |format|\n format.html { redirect_to attendees_url }\n format.json { head :ok }\n end\n end", "def destroy\n if @diet.destroy\n head :no_content, status: 200\n else\n render json: @diet.errors, status: 405\n end\n end", "def destroy\n @appointment.destroy\n respond_to do |format|\n format.html { redirect_to appointments_url, notice: 'appointment was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hangout = Hangout.find(params[:id])\n @hangout.destroy\n\n respond_to do |format|\n format.html { redirect_to hangouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment = person.appointments.find(params[:id])\n @appointment.destroy\n respond_to do |format|\n format.html { redirect_to(patient_appointments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lunch.destroy\n respond_to do |format|\n format.html { redirect_to lunches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @talk.destroy\n respond_to do |format|\n format.html { redirect_to event_talks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @elective_day.destroy\n respond_to do |format|\n format.html { redirect_to elective_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment.destroy\n\n @appointment.destroy\n respond_to do |format|\n format.html { redirect_to appointments_url, notice: 'Appointment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lifespan = Lifespan.find(params[:id])\n @lifespan.destroy\n\n respond_to do |format|\n format.html { redirect_to lifespans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal = Goal.find(params[:id])\n @goal.destroy\n render json: @goal\n end", "def destroy\n @appointment.destroy\n respond_to do |format|\n format.html { redirect_to appointments_url, notice: 'Appointment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.80827785", "0.7949581", "0.7949581", "0.7949581", "0.793943", "0.7925257", "0.7883001", "0.78429943", "0.78148264", "0.7774949", "0.770833", "0.770833", "0.770833", "0.7698673", "0.76632965", "0.7661452", "0.76605344", "0.76529425", "0.76492286", "0.7649177", "0.7645561", "0.76094675", "0.7594607", "0.7594607", "0.7594607", "0.7594607", "0.7594607", "0.7594607", "0.7594607", "0.7576606", "0.75765073", "0.7549213", "0.7535894", "0.74423516", "0.74352413", "0.7428151", "0.7403945", "0.737157", "0.73339146", "0.7327695", "0.73257655", "0.7322815", "0.7303154", "0.72825927", "0.7271222", "0.7269115", "0.7237955", "0.72362167", "0.72118735", "0.71811795", "0.71809715", "0.7170412", "0.7166822", "0.7163214", "0.7152308", "0.71162206", "0.70704657", "0.70288056", "0.7016709", "0.70099574", "0.69605637", "0.6925745", "0.69059676", "0.685885", "0.6828905", "0.68140155", "0.68140155", "0.68139696", "0.68041134", "0.6778603", "0.67560554", "0.6753159", "0.67523557", "0.6744786", "0.6741648", "0.67330563", "0.67208195", "0.67053604", "0.67023903", "0.66978174", "0.6697755", "0.6693863", "0.6675777", "0.6675777", "0.66685766", "0.6666183", "0.6647139", "0.6643317", "0.6640276", "0.66312194", "0.66232926", "0.6621325", "0.6621325", "0.6621325", "0.6621325", "0.6621325", "0.6621114", "0.6613765", "0.66112787", "0.6609933", "0.66037095" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_meeting @meeting = Meeting.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Only allow a list of trusted parameters through.
def meeting_params params.require(:meeting).permit(:team_id, :content, :privacy, :subject, tag_list: [], attachments: [], user_ids: []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end", "def whitelisted_args\n args.select &:allowed\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def filtered_parameters; end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def param_whitelist\n [:rating, :review]\n end", "def check_params; true; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\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 secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\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 permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end", "def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end", "def valid_params_request?; end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def safelists; end", "def authorize_own_lists\n authorize_lists current_user.lists\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def check_params\n true\n end", "def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end", "def filter_parameters; end", "def filter_parameters; end", "def whitelist; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.permit(:name)\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def permitted_params\n []\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end", "def params(list)\n @declared_params = list\n end", "def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end", "def allow(ids); end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def safelist; end", "def valid_for_params_auth?; end", "def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def permitters\n @_parametrizr_permitters || {}\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def url_allowlist; end", "def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end", "def quote_params\n params.permit!\n end" ]
[ "0.6950644", "0.68134046", "0.68034387", "0.6796522", "0.674668", "0.6742105", "0.6527854", "0.65214247", "0.6491907", "0.64294493", "0.64294493", "0.64294493", "0.64004904", "0.6356768", "0.63556653", "0.6348119", "0.6344521", "0.63386923", "0.632588", "0.632588", "0.632588", "0.6315317", "0.6300307", "0.6266357", "0.62616897", "0.62586933", "0.623662", "0.6228699", "0.6222646", "0.6221808", "0.62095183", "0.6200624", "0.6197454", "0.61747247", "0.6158626", "0.61565846", "0.6152596", "0.6137625", "0.6123762", "0.61105245", "0.6076312", "0.6071771", "0.60621834", "0.60548234", "0.6044156", "0.603494", "0.6019818", "0.60173535", "0.60154593", "0.60121197", "0.6008601", "0.6008049", "0.60078037", "0.60059106", "0.60059106", "0.5997147", "0.599462", "0.59918606", "0.5984179", "0.59706646", "0.59698576", "0.5966363", "0.5965114", "0.59620297", "0.5961917", "0.59358233", "0.5929989", "0.59241587", "0.59088653", "0.59052056", "0.59033877", "0.58932143", "0.58890563", "0.5880874", "0.5880874", "0.5880874", "0.58739555", "0.5863163", "0.585503", "0.5845768", "0.58438927", "0.58353096", "0.583153", "0.58292353", "0.58277905", "0.58186984", "0.58164775", "0.581428", "0.58108085", "0.5805045", "0.5805045", "0.58009875", "0.5796557", "0.5785622", "0.57814676", "0.5777818", "0.577579", "0.57690275", "0.5768062", "0.57632935", "0.57591033" ]
0.0
-1
in params complete donation needed (with charity, amount, etc.)
def create @donation = Donation.new(donation_params) before_donation_creation @donation if @donation.save after_donation_creation @donation set_after_create_flash_message redirect_to donation_path(@donation) else redirect_to charities_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def donation_params\n params.require(:donation).permit(:amount, :donation_date, :contact_id, :payment_purpose_id, :payment_mode_id, :currency_id, :event_id, :bank_name, :cheque_number)\n end", "def donation_params\n params.require(:donation).permit(:description, :expires, :donor_id, :food_bank_id)\n end", "def donation_params\n params.permit(:first_name,:last_name,:email_id,:phone_no,:address,:eighty_g_required, \n :donation_amount, :amount, :donation_type, :version, :fundraiser_id, :donour_id, :event_ticket_type_id,\n :donation_status, :event_id, :ticket_type_id, :source_id)\n end", "def donation_params\n params.require(:donation).permit(:name, :amount, :email, :tag, :project_id, :url, :approval)\n end", "def donation_params\n params.require(:donation).permit(:campaign_id, :email, :amount, :credit_card_details, :user_id)\n end", "def donation_params\n params.require(:donation).permit(:pickup_window_start, :pickup_window_end, :comments, :anonymous, :vehicle, :pickup_address, :personal)\n end", "def donation_params\n params.require(:donation).permit(:date, :donor_id, :type_cd, :amount, :cheque_no, :remarks, :payment_details, :receipt_number, :person_id, :thank_you_sent, :category, transaction_items_attributes: [:id, :quantity, :item_id, :_destroy])\n end", "def donation_params\n params.require(:donation).permit(:donator, :institute, :items, :quantity)\n end", "def donation_params\n\t\t\tparams.require(:donation).permit(:amount, :campaign_id, :date)\n\t\tend", "def donor_params\n params.require(:donor).permit(:name, :age, :gender, :race, :religion, :networth, :employer, :position, :education, :associations, :military, :location, :zip, :description, :life_event, :donation_goal, :donation_YTD, :image)\n end", "def charitable_donation_params\n params.require(:charitable_donation).permit(:charity_id, :amount, :instruction, :allow_alternate, :popular_charity, :popular_charity_name, :name, :registered_charity_number, :address_one, :address_two, :city, :postcode, :county, :country)\n end", "def donation_params\n params.require(:donation).permit(:amount, :comment)\n end", "def donation_params\n params.require(:donation).permit(:pickup_start, :pickup_end, :status, :donor_id, :recipient_id,\n food_portion_attributes: [:raw_amount, :processed_amount, :description, :image_url])\n end", "def donation_params\n params.require(:donation).permit(:amount, :comment, :donorname, :companyname, :project_ids => [])\n end", "def donation_params\n params.require(:donation).permit(:category, :quantity, :organization_id, :user_id)\n end", "def donate\n\n # amount is the amount that the user wants to donate\n\t\tamount = params[:donation][:amount].to_i\n # this is the amount that can be deferred to someone else\n # for example if someone wants to donate $1.00 and your policy is that\n # $0.05 will come out of every dollar to go towards a charity, then you would set\n # that amount here. This exists because of PayPal's adaptive payment system\n # https://www.x.com/developers/paypal/products/adaptive-payments\n\t\tweeve_amount = 0.01\n\t\t\n\t\t@donation = Donation.new\n\n # if this is a guest checkout (without the need to sign in)\n # refer to schema.rb for more details about guest checkouts\n if params[:guest_checkout]\n @guest = Guest.new(params[:guest])\n\t @guest.save\n @donation.user_id = -1\n else\n @user = current_usertype\n @donation.user_id = params[:user_id]\n end\n\n\t\t@project = Project.find(params[:project_id])\n\t\[email protected]_id = @project.id\n\t\t@npo = Npo.find_by_account_id(@project.account_id)\n\n # calls paypal with the right amounts\n # for more information on how to use this\n # refer to https://github.com/jpablobr/active_paypal_adaptive_payment\n\t\tif @donation.save && @project && @npo.paypal_email\n \n if params[:guest_checkout]\n @guest.update_attribute(:donation_id, @donation.id)\n end\n \n\t\t\tconfig = Weeverails::Application.config\n\n\t\t\tgateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new(\n\t\t\t\t\t\t\t:login => config.paypal_login,\n\t\t\t\t\t\t\t:password => config.paypal_password,\n\t\t\t\t\t\t\t:signature => config.paypal_apikey,\n\t\t\t\t\t\t\t:appid => config.app_id )\n\n\t\t\trecipients = [{:email => @npo.paypal_email,\n\t\t\t\t\t\t\t :amount => amount,\n\t\t\t\t\t\t\t :primary => true},\n\t\t\t\t\t\t\t{:email => config.weeve_paypal_email,\n\t\t\t\t\t\t\t :amount => weeve_amount,\n\t\t\t\t\t\t\t :primary => false}\n\t\t\t\t\t\t\t ]\n\n\t\t\tresponse = gateway.setup_purchase(\n\t\t\t\t\t:currency_code => @npo.paypal_currency,\n\t\t\t\t\t:return_url => url_for(:action => :complete, :project_id => params[:project_id], :only_path => false),\n\t\t\t\t\t:cancel_url => url_for(:action => :cancel, :project_id => params[:project_id],:only_path => false),\n\t\t\t\t\t:ipn_notification_url => url_for(:action => :success, :donation_id => @donation.id, :only_path => false),\n\t\t\t\t\t:receiver_list => recipients\n\t\t\t)\n\n\t\t\tif response.success?\n\t\t\t\tredirect_to (gateway.redirect_url_for(response[:pay_key]))\n\t\t\telse\n\t\t\t\t#flash[:error] = \"There was an error in processing your donation, please try again or contact administration at [email protected]\"\n\t\t\t\tflash[:error] = response.inspect\n\t\t\t\tredirect_to :controller => :projects, :action => :show, :id => params[:project_id]\n\t\t\tend\n\t\telse\n\t\t\tflash[:error] = \"Invalid donation URL\"\n\t\t\tredirect_to root_url\n\t\tend\n\tend", "def donator_params\n params.require(:donator).permit(:amount, :user_id, :product_id)\n end", "def donation_params\n params.require(:donation).permit(:project_id, :user_id, :value)\n end", "def donation_params\n params.permit(:all)\n end", "def donation_params\n params.permit(:amount_dollars)\n end", "def donation_params\n\n params.require(:donation).permit(:full_name, :email, :phone, :county, :meet, :address, :availability, :comments,\n :send_to_settle, :send_to_screen,\n item_changes_attributes: [:id, :category_id, :quantity, :itemType, :size,\n :change_type, :settle, :_destroy])\n end", "def donation_params\n # params.permit(:price).merge(user_id: user.id)\n params.require(:user_donation).permit(:name, :name_reading, :nickname, :postal_code, :prefecture, :city, :house_number, :building_name, :price)\n end", "def donation_params\n params.require(:donation).permit(:user_id, :charity_id, :package_cost_id, :address_id, :total_price, :number_of_cartons,\n :is_fragile, :wimo_task_id, donation_category_ids: [], attachments_attributes: [:id, :file, :_destroy])\n end", "def donation_credit_params\n params.require(:donation_credit).permit(:user_id, :quantity)\n end", "def donate_params\n\t\t params.require(:donate).permit(:donatur, :tgl_donasi, :dana, :barang, :besar_dana)\n\t\t end", "def donation_params\n params.require(:donation).permit(:name,\n :description,\n :latitude,\n :longitude,\n :pickup_notes,\n :available_until,\n :is_perishable,\n :requires_preparation,\n :is_vegetarian,\n :is_vegan,\n :contains_gluten,\n :contains_peanuts,\n :contains_tree_nuts,\n :contains_dairy,\n :contains_soy,\n :contains_egg,\n :contains_fish,\n :contains_shellfish,\n images: [])\n end", "def get_fee_params(npo_ein = '68-0480736')\n {\n DonationLineItems: {\n DonationItem: {\n NpoEin: npo_ein,\n Designation: 'annual_fund',\n Dedication: 'For my grandfather',\n donorVis: 'ProvideAll',\n ItemAmount: 100.00,\n RecurType: 'NotRecurring',\n AddOrDeduct: 'Add',\n TransactionType: 'Donation'\n }\n },\n TipAmount: 1.00,\n CardType: 'Visa'\n }\nend", "def donate\n @campaign = Campaign.find_by_id(params[:campaign_id])\n @user = User.find_by_id(@campaign.user_id)\n if(@user.checkout_method == \"iframe\")\n redirect_to(\"/campaign/donate_iframe/#{@campaign.id}\")\n end\n params[:user_name] ||= \"Test User\"\n params[:user_email] ||= \"[email protected]\"\n params[:cc_number] ||= \"5496198584584769\"\n params[:cvv] ||= \"123\"\n params[:zip] ||= \"12345\"\n params[:expiration_month] ||= \"11\"\n params[:expiration_year] ||= \"2025\"\n end", "def food_donor_params\n params.require(:food_donor).permit(:has_transport, :available_till, :sufficient_for, :name, :email, :phone, :address, :lat, :lang, :food_details)\n end", "def donate\n\n @context_user = @receiver.user\n \n # Test that the transfer money between the two people is a viable option\n rec_acc = @receiver.monetary_processor_account\n pay_acc = @sender.monetary_processor_account\n \n rec_usid = rec_acc.account_identifier\n pay_usid = pay_acc.account_identifier\n \n @donation.update_attributes do |d|\n d.receiver_wmid = rec_acc\n d.sender_wmid = pay_acc\n end\n store_donation\n \n res = WebMoney::Ext::Client.get_max_transaction_amount(pay_usid, rec_usid, @donation.purse_type[0].to_i)\n \n # Verify maximum transaction possible\n @max_amount = res.maxAmount\n if @max_amount < @amount.to_f\n @amount = @max_amount\n if @amount.to_i != -1\n flash.now[:warning] = \"The maximum that you can contribute is %s.\" / \"#{@amount}\"\n end\n end\n \n # We are confirmed, lets do it!\n if params[:confirm]\n \n # confirm their password\n @account_setting = current_user.account_setting\n unless @account_setting.validate_password(current_user,params[:password])\n flash.now[:error] = \"Invalid Password\".t\n return\n end\n \n # want to see the result logged for debugging?\n # WebMoney::Ext::Client.config.merge!({:debug => true, :wiredump => true})\n transfer = WebMoneyTransfer.create(\n :source_wmid => @sender.webmoney_account,\n :destination_wmid => @receiver.webmoney_account,\n :purse_type => @donation.purse_type[0].to_i,\n :amount => @donation.amount)\n \n res = WebMoney::Ext::Client.send_funds(\n pay_usid,\n rec_usid,\n transfer.request_number,\n @donation.purse_type[0].to_i,\n @donation.amount,\n @donation.item_name)\n \n if res.errordesc == 'Success'\n MonetaryDonation.from_webmoney_donation(@donation).save\n \n transfer.update_attribute(:success, true)\n flash[:success] = \"You have successfully transfered %s\" / [@donation.amount]\n clear_donation\n redirect_back_or_default '/'\n else\n transfer.update_attributes(:success => false, :response => res.errordesc)\n flash.now[:error] = res.errordesc.t\n end\n end\n end", "def donation\n @charityRep = CharityRep.find(params[:charityRep_id])\n amount = params[:money_raised].to_i\n\n if amount <= current_user.money_available\n donation = Donation.create(donor: current_user, charity_rep:@charityRep, amount: amount)\n\n if @charityRep.money_raised == nil\n # if charityRep's money_raised = nil, update amt of money_raised in db with amt the donor donates, update amt of money_requested\n updated_money_raised_amt = amount\n updated_money_amt = @charityRep.money_requested - amount\n @charityRep.update(money_raised: updated_money_raised_amt, money_requested: updated_money_amt)\n else\n # if charityRep has already raised money, update amt of money_raised, update amt of money_requested\n updated_money_raised_amt = @charityRep.money_raised + amount\n updated_money_amt = @charityRep.money_requested - amount\n @charityRep.update(money_raised: updated_money_raised_amt, money_requested: updated_money_amt)\n end\n\n #update donor's account balance\n updated_acctbal = current_user.money_available - amount\n current_user.update(money_available: updated_acctbal)\n\n elsif current_user.money_available == 0\n initialize_donationErrors_flash\n flash[:donation_errors] << \"you can no longer donate since your account balance is 0!\"\n else\n initialize_donationErrors_flash\n flash[:donation_errors] << \"there is not enough money in your account! Please select a lower amount.\"\n end\n redirect_to \"/donor/#{current_user.id}\"\n end", "def set_donation\n @donation = Donation.find(params[:id])\n @payment_purposes = PaymentPurpose.all_active\n @events = Event.all_active\n @currencies = Currency.all_active\n @payment_modes = PaymentMode.all_active\n end", "def warranty_params\n params.require(:warranty).permit(:garantia1, :garantia2, :garantia3, :garantia4, :client_id)\n end", "def payment_donation_params\n params.require(:payment_donation).permit(policy(@donation || Payment::Donation).permitted_attributes)\n end", "def charge!(cents, idempotency_key)\n # we are not charging anything - customer pays via bank transfer\n { paymentmethod: payment_info }\n end", "def donation_cash_params\n params.require(:donation_cash).permit(:user_id, :amount)\n end", "def donateinfo\n case @@donation_type\n when \"One-off\"\n @@donation_reference = TestBrowser.browser.url.split(\"=\")[2][16..51]\n @@donation_amount = '%.2f' % (TestBrowser.browser.url.split(\"paymentAmount=\")[1][0..3].to_i/100)\n when \"Monthly\"\n @@donation_amount = '%.2f' % (TestBrowser.browser.url.split(\"=\")[3].to_i/100)\n when \"One-off PayPal\"\n @@donation_amount = '%.2f' % (TestBrowser.browser.url.split(\"=\")[2].split(\"&\").first.to_i/100)\n end\n donate_info = \"#{@@donation_type} donation of #{@@donation_amount}\"\n return donate_info\n end", "def payment_params\n params.fetch(:payment, {}).permit(\n :effect,\n :description, \n :due_date,\n :due_value,\n :payment_date,\n :payment_value,\n :interest_value,\n :penalty_value,\n :discount_value,\n :payable_id,\n :payable_type\n )\n end", "def duel_info_params\n params.require(:duel_info).permit(:result_no, :generate_no, :battle_id, :left_party_no, :right_party_no)\n end", "def charge_donor\n return true unless (self.amount and (self.amount > 0))\n\n begin\n Stripe::Charge.create({\n # amount is in dollars, stripe takes cents\n :amount => self.amount * 100,\n :currency => \"usd\",\n :card => self.stripe_token,\n :description => \"Donation to #{participation.volunteer.name} for #{participation.event.name}\"\n }, self.participation.event.organization.stripe_token)\n return true\n rescue Stripe::StripeError => e\n # Something went wrong. Report that billing failed.\n errors.add(:billing, \"Failed: #{e.message}\")\n return false\n end\n end", "def donation_params\n params.require(:donation).permit(:nombreItem, :marca, :modelo, :cantidad, :unidadMedida, :tipo, :numDocumento, :fechaDocumento, :estimado, :document,\n item_donados_attributes:[:id,\n :Nombre,\n :Marca,\n :Modelo,\n :UniDeMedida,\n :tipo,\n :NoDonacion])\n end", "def create\n @donation_form = DonationForm.new(donation_params)\n @product = Donation.find(donation_params[:donation_id])\n\n payment = PagSeguro::CreditCardTransactionRequest.new\n payment.notification_url = notifications_url\n # payment.notification_url = \"\"\n payment.payment_mode = \"default\"\n\n # Aqui vão os itens que serão cobrados na transação, caso você tenha multiplos itens\n # em um carrinho altere aqui para incluir sua lista de itens\n payment.items << {\n id: @product.id,\n description: @product.description,\n amount: @product.price,\n weight: 0\n }\n\n # Criando uma referencia para a nossa ORDER\n reference = \"REF_#{(0...8).map { (65 + rand(26)).chr }.join}_#{@product.id}\"\n payment.reference = reference\n payment.sender = {\n hash: donation_params[:sender_hash],\n name: donation_params[:name],\n email: donation_params[:email],\n cpf: donation_params[:cpf],\n document: { type: \"CPF\", value: donation_params[:cpf] },\n phone: {\n area_code: donation_params[:phone_code],\n number: donation_params[:phone_number]\n }\n }\n\n shipping_address = {\n type_name: ENV['DEV_SHIPPING_TYPE'],\n address: {\n street: ENV['DEV_SHIPPING_STREET'],\n number: ENV['DEV_SHIPPING_NUMBER'],\n complement: ENV['DEV_SHIPPING_COMPLEMENT'],\n city: ENV['DEV_SHIPPING_CITY'],\n state: ENV['DEV_SHIPPING_STATE'],\n district: ENV['DEV_SHIPPING_DISTRICT'],\n postal_code: ENV['DEV_SHIPPING_POSTAL_CODE']\n }\n }\n\n payment.shipping = shipping_address\n payment.billing_address = shipping_address[:address]\n\n payment.credit_card_token = donation_params[:card_token]\n payment.holder = {\n name: donation_params[:card_name],\n birth_date: donation_params[:birthday],\n document: {\n type: \"CPF\",\n value: donation_params[:cpf]\n },\n phone: {\n area_code: donation_params[:phone_code],\n number: donation_params[:phone_number]\n }\n }\n\n payment.installment = {\n value: donation_params[:card_installment_value],\n quantity: donation_params[:card_options].to_i\n }\n\n # payment.extra_params << { shippingAddressRequired: 'false' }\n\n puts \"=> REQUEST\"\n puts PagSeguro::TransactionRequest::RequestSerializer.new(payment).to_params\n puts\n\n payment.create\n\n # Cria uma Order para registro das transações\n if @donation_form.valid? && payment.errors.empty?\n Order.create(donation_id: @product.id, buyer_name: donation_params[:name], reference: reference, status: 'pending')\n\n redirect_to wedding_supports_path,\n flash: { notice: 'Obrigado. Sua doação foi realizada com sucesso!' }\n else\n @donation_form.payment_errors = payment.errors\n puts \"Payment Errors:\"\n puts payment.errors.join(\"\\n\")\n puts @donation_form.errors.messages\n @donation = @product\n @session_id = (PagSeguro::Session.create).id\n render :new and return\n end\n end", "def payment_params\n params.require(:payment).permit(:numcard, :name_owner, :expiry_date, :code, :dues_number)\n end", "def payment_params\n params.require(:payment).permit(:fact_firstname, :fact_lastname, :fact_address, :fact_addresscomplement, :fact_addresscomplementbis, :fact_zipcode, :fact_city, :deliver_firstname, :deliver_lastname, :deliver_address, :deliver_addresscomplement, :deliver_addresscomplementbis, :deliver_zipcode, :deliver_city)\n end", "def donation_type_params\n params.require(:donation_type).permit(:name, :non_monetary, :inactive)\n end", "def donate_education_material_params\n params.require(:donate_education_material).permit(:name, :email, :address, :contact, :text_donation)\n end", "def debt_payment_params\n params.require(:debt_payment).permit(:payment_date, :transaction_id, :transaction_type_id, :consumer_id, :consumer_type_id, :total_transaction, :amount, :debt_remaining, :consumer_name, :consumer_address, :debt_status, :is_valid)\n end", "def donate(amount, charity_group_id)\n raise PaymentAccountInvalid if !self.valid?\n raise CharityGroupInvalid if !(charity = CharityGroup.find(charity_group_id))\n raise AmountInvalid if amount.blank? || amount < 0\n\n Dwolla::token = token\n transaction_id = Dwolla::Transactions.send({:destinationId => App.dwolla['account_id'],\n :amount => amount.to_f,\n :pin => pin})\n\n # amount = amount after processing fee(s)\n donation = donor.donations.build(:amount => amount,\n :charity_group_id => charity.id,\n :transaction_id => transaction_id,\n :transaction_processor => processor)\n donation.save(false)\n donation\n end", "def pay_agreement_params\n params.require(:pay_agreement).permit(:fee_id, :user_registration_id,\n :discount, :discount_in_percent, :comment, :slug, :version, { details: [:information]})\n end", "def donated\n \tdonations.sum(&:amount)\n end", "def payment_donation_params\n params.require(:payment).permit(policy(Payment).permitted_attributes)\n end", "def saldo_params\n params\n end", "def fake_donation\n if params[:donate_token]\n Donation.create!(:amount => params[:amount].to_f, \n :user => current_user, \n :fundraiser => User.find_by_donate_token(params[:donate_token]))\n end\n render :action => 'thanks'\n end", "def transaction_params\n params.require(:transaction).permit(\n donor_attributes: [:id, :planning_center_person_id]\n )\n end", "def donate\r\n @fund += 25\r\n puts \"Project #{@name} received a generous donation!\"\r\n end", "def recharge_params\n params.require(:recharge).permit(:user_id, :agent_id, :last4, :card_type, :paid, :amount, :currency, :refunded, :fee, :captured, :failure_message, :failure_code, :amount_refunded, :customer, :invoice, :description, :dispute, :number, :card_name, :exp_month, :exp_year, :cvc)\n end", "def payment_params\n params.require(:payment).permit(:legalname, :request)\n end", "def build_payment_info\n {'ShipmentCharge' => build_shipment_charge }\n end", "def cost\n\t\treturn @extra_cost + @real_donation.cost\n\tend", "def garantor_params\n params.require(:garantor).permit(:name, :address, :telephone, :value_tranfer)\n end", "def make_donation\n # try to see if the donor is already in the database\n @user = User.find_by_email(params[:user_email])\n if !@user # if not, then create the user\n @user = User.new({\n name: params[:user_name],\n email: params[:user_email]\n })\n unless @user.valid? && @user.save\n error(@user.errors.full_messages)\n return redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n end\n # create the payment object with the details provided\n @payment = Payment.new({\n campaign_id: @campaign.id,\n payer_id: @user.id,\n wepay_payment_id: params[:payment_method_id],\n wepay_payment_type: params[:payment_method_type],\n amount: params[:amount]\n })\n if [email protected]?\n error(@payment.errors.full_messages)\n return redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n # if the payment is valid, make the /checkout/create call\n # and then save the updated details\n if @payment.valid? && @payment.create_checkout && @payment.save\n @user.add_role(User::ROLE_PAYER)\n @user.save\n @campaign.update_amount_donated\n message(\"Donation Made!\")\n redirect_to(\"/campaign/donation_success/#{@campaign.id}/#{@payment.id}\")\n else\n error(@payment.errors.full_messages)\n redirect_to(\"/campaign/donate/#{@campaign.id}\")\n end\n end", "def charge(opts)\n\n amount = opts[:amount]\n currency = opts[:currency]\n\n end", "def read_donation donation\n puts \"Organization:\"\n puts \"Amount:\"\n puts \"Date:\"\n puts \"Completed?\"\n end", "def donations_requested(user)\n setup_email_admin(user)\n @recipients = \"[email protected]\"\n @from = head_encode('\"Kroogi Contributions Request (system)\"'.t) + \" <[email protected]>\"\n @subject += head_encode(\"Contributions requested by %s\" / user.login)\n @content_type = \"text/html\" \n @body[:url] = \"http://#{APP_CONFIG[:hostname]}/admin/donation_requests\"\n @body[:user] = user\n end", "def pledge_params\n params.\n require(:pledge).\n permit(:amount, :goal_id).\n merge(email: stripe_params[\"stripeEmail\"], card_token: stripe_params[\"stripeToken\"])\n end", "def payment_params\n params.permit(:transaction_id, :sender_email, :receiver_email, :date, :charitytype, :amount)\n end", "def relatory_params\n params.require(:relatory).permit(:buyer, :description, :price,:quantity, :address, :owner)\n end", "def payment_params\n params.require(:payment).permit(:asignation_id, :quantify, :description)\n end", "def donation\n @donation = FinanceDonation.new(params[:donation])\n @donation_additional_details = DonationAdditionalDetail.find_all_by_finance_donation_id(@donation.id)\n @additional_fields = DonationAdditionalField.find(:all, :conditions => \"status = true\", :order => \"priority ASC\")\n if request.post? && @donation.valid?\n @error=false\n mandatory_fields = DonationAdditionalField.find(:all, :conditions => {:is_mandatory => true, :status => true})\n mandatory_fields.each do |m|\n unless params[:donation_additional_details][m.id.to_s.to_sym].present?\n @donation.errors.add_to_base(\"#{m.name} must contain atleast one selected option.\")\n @error=true\n else\n if params[:donation_additional_details][m.id.to_s.to_sym][:additional_info]==\"\"\n @donation.errors.add_to_base(\"#{m.name} cannot be blank.\")\n @error=true\n end\n end\n end\n unless @error==true\n @donation.save\n additional_field_ids_posted = []\n additional_field_ids = @additional_fields.map(&:id)\n if params[:donation_additional_details].present?\n params[:donation_additional_details].each_pair do |k, v|\n addl_info = v['additional_info']\n additional_field_ids_posted << k.to_i\n addl_field = DonationAdditionalField.find_by_id(k)\n if addl_field.input_type == \"has_many\"\n addl_info = addl_info.join(\", \")\n end\n prev_record = DonationAdditionalDetail.find_by_finance_donation_id_and_additional_field_id(params[:id], k)\n unless prev_record.nil?\n unless addl_info.present?\n prev_record.destroy\n else\n prev_record.update_attributes(:additional_info => addl_info)\n end\n else\n addl_detail = DonationAdditionalDetail.new(:finance_donation_id => @donation.id,\n :additional_field_id => k, :additional_info => addl_info)\n addl_detail.save if addl_detail.valid?\n end\n end\n end\n if additional_field_ids.present?\n DonationAdditionalDetail.find_all_by_finance_donation_id_and_additional_field_id(params[:id], (additional_field_ids - additional_field_ids_posted)).each do |additional_info|\n additional_info.destroy unless additional_info.donation_additional_field.is_mandatory == true\n end\n end\n flash[:notice] = \"#{t('flash1')}\"\n redirect_to :action => 'donation_receipt', :id => @donation.id\n end\n end\n end", "def payment_params\n params.require(:payment).permit(:total_fee, :pay_method, :customer, :ip, :equipment)\n end", "def has_paid (driver, person, amount)\n # debt - amount\n end", "def food_donation_params\n params.fetch(:food_donation, {}).permit(:note, :available_at, :quantity)\n end", "def outsourcing_cost_params\n #udp190930 \n #purchase_order_datum_id追加\n \n params.require(:outsourcing_cost).permit(:purchase_order_datum_id, :construction_datum_id, :staff_id, :purchase_amount, :supplies_expense, \n :labor_cost, :misellaneous_expense, :execution_amount, :billing_amount, :purchase_order_amount, \n :closing_date, :source_bank_id, :payment_amount, :unpaid_amount, :payment_due_date, :payment_date, \n :unpaid_payment_date)\n end", "def accepted_params\n [\n :Amount,\n :isPreAuth,\n :ServiceId, \n :RequestLang, \n :FullName, \n :Email, \n :Phone, \n :MaxInstallments,\n :MerchantTrns,\n :CustomerTrns,\n :SourceCode,\n :PaymentTimeOut,\n :ExpirationDate,\n :AllowRecurring,\n :Tags,\n :AllowTaxCard,\n :ActionUser,\n :DisableCash,\n :DisableCard\n ]\n end", "def set_donation\n @donation = Donation.includes(:donation_categories, :attachments, :address, :package_cost, :charity, :user).find(params[:id])\n end", "def payment_params\n #params.require(:payment).permit(:amount, :profile_id, :reference_key, :status, :succeed_time)\n params.require(:payment).permit(:amount)\n end", "def payment_params\n # params.require(:payment).permit(:user_id, :customer, :funding_source, :routing_number, :account_number, :type, :account_name)\n params.require(:payment).permit!\n end", "def donation_receipt\n @donation = FinanceDonation.find_by_id(params[:id], :include => {:transaction => :transaction_ledger},\n :joins => \"INNER JOIN finance_transactions ft ON ft.finance_type = 'FinanceDonation' AND ft.finance_id = finance_donations.id\n INNER JOIN finance_transaction_receipt_records ftrr ON ftrr.finance_transaction_id = ft.id\n LEFT JOIN fee_accounts fa ON fa.id = ftrr.fee_account_id\",\n :conditions => \"#{active_account_conditions(true, 'ftrr')}\")\n if @donation.present?\n @additional_details = @donation.donation_additional_details.find(:all,:include => [:donation_additional_field],\n :conditions => [\"donation_additional_fields.status = true\"],:order => \"donation_additional_fields.priority ASC\")\n @additional_fields_count = DonationAdditionalField.count(:conditions => \"status = true\")\n else\n flash[:notice] = t('flash_msg5')\n redirect_to :controller => \"user\", :action => \"dashboard\"\n end\n end", "def payment_params\n params.require(:payment).permit(:total, :collector_id, :company_id, :debt_id)\n end", "def consignment_params\n params.require(:consignment).permit(:merchant_id, :plan_id, :tracking_code, :receiver_name, :receiver_phone, :receiver_addr, :amount, :weight, :charge, :additional_cost, :compensation, :payment_status, :merchant_order_no, :package_description, :delivered_on, :current_hub_id, :target_hub_id, :rider, :assigned_by, :data_entry_by, :completed_by, :assigned_on, :assigned_on, :completed_on, :data_entry_on, :status)\n end", "def donate_credit\n @donation_credit = DonationCredit.new(donation_credit_params)\n @sender = User.find(@donation_credit.user_id)\n @donation_credit.pot = @pot\n @donation_credit.user = @sender\n @pot.credits_collected = @pot.credits_collected + @donation_credit.quantity\n\n respond_to do |format|\n if @donation_credit.save && @pot.save\n format.json\n else\n format.json { render json: @donation_credit.errors, status: :unprocessable_entity }\n end\n end\n end", "def debit_payment_params\n params.fetch(:debit_payment, {})\n end", "def checkout\n \n # there must be a payment\n @payment = session[:payment]\n if !@payment || [email protected]\n @message = \"Sorry an internal error has occured\"\n render :action => 'error'\n return\n end\n\n # the donation can change based on parameters supplied\n if @payment.amount < 1\n # collect both possible donations\n donation = params[:donation]\n donation2 = params[:donation2]\n donation2 = donation if donation2\n donation = donation2.to_i\n @payment.update_attributes( :amount => donation )\n end\n if @payment.amount < 1\n @message = \" bad donation amount entered. Please hit back and try again\"\n render :action => 'error'\n return\n end\n\n # capture the company match if there is one\n matching_company = params[:matching_company]\n if matching_company\n @payment.update_attributes( :matching_company => matching_company)\n end\n\n # try get a party if there is one passed - this overrides anything from before.\n @party = nil\n @party = User.find(params[:party].to_i) if params[:party]\n @partyid = 0\n @partyid = @party.id if @party\n @payment.update_attributes( :owner_id => @partyid ) if @partyid > 0\n \n #if @payment.owner_id == 0\n # @message = \"Sorry no person to donate to found\"\n # render :action => 'error'\n # return\n #end\n\n # move payment along to the next stage\n @payment.update_attributes( :description=> Payment::CHECKOUT , :amount => donation )\n\n @notify_url = url_for(\n :controller=>\"payment\",\n :action => 'payment_received',\n :id => @payment.id,\n :only_path => false\n )\n\n @return_url = url_for(\n :controller=>\"payment\",\n :action => 'confirm_standard',\n :only_path => false\n )\n\n @paypal_business_email = SETTINGS[:paypal_business_email]\n @business_key = PAYPAL_MYPRIVKEY\n @business_cert = PAYPAL_MYPUBCERT\n @business_certid = SETTINGS[:paypal_cert]\n @action_url = \"http://www.paypal.com/cgi-bin/webscr\"\n Paypal::Notification.ipn_url = @action_url\n Paypal::Notification.paypal_cert = PAYPAL_CERT\n\n end", "def compensation_payment_params\n params.require(:compensation_payment).permit(:total, :payment_id, :active, :asociatedClientInvoice, :observation, :concept, :client_id)\n end", "def rent_payment_params\n params.require(:rent_payment).permit(:leaseID, :paymentAmount, :dateReceived, :name)\n end", "def recepient_params\n params.require(:recepient).permit(:about_info, :home_address, :country_of_origin, :reason_for_need, :need_amount, :avatar, :category_id)\n end", "def create\n\n amount = params[:amount].to_i\n charity = params[:charity]\n\n\n\t customer = Stripe::Customer.create(\n\t :email => params[:stripeEmail],\n\t :card => params[:stripeToken]\n\t )\n\n\t charge = Stripe::Charge.create(\n\t :customer => customer.id,\n\t :amount => amount,\n\t :description => 'Easy Giving Customer',\n\t :currency => 'usd'\n\t )\n\n new_donation= Donation.create(\n amount: amount,\n charity_name: charity\n )\n\n new_donation.user = current_user\n new_donation.save\n\n @donation = new_donation\n redirect_to donation_path(@donation) #donation show\n\n #if there's a processing error, show error,redirect to make a new donation\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_donation_path\n\tend", "def disbursement_params\n params.require(:disbursement).permit(:date, :account_id, :cleared, :amount, :user_id, :note)\n end", "def donation_item_params\n params.require(:donation_item).permit(:name, :price, :price, :image_url)\n end", "def payment_params\n params.require(:payment).permit(:user_id, :unit_id, :utility_charge_id, :total_paid, :pay_type)\n end", "def payment_params\n params.require(:payment).permit(:ref, :company_id, :user_id, :paymethod_id, :companyaccount_id, :price, :vat, :total, :date, :inc_type, :notes, :state)\n end", "def payment_params\n params.require(:payment).permit(:first_name, :last_name, :last4, :card_security_code, :credit_card_number, :expiration_month, :expiration_year, :amount, :amount, :success, :authorization_code, :user_id, :notify, :parking_id)\n end", "def save_with_payment\n if(self.merchandise_id.present?) #if a purchase is being made\n puts \"13x\" ##########\n @merchandise = Merchandise.find(self.merchandise_id)\n self.pricesold = @merchandise.price\n self.author_id = @merchandise.user_id \n seller = User.find(@merchandise.user_id)\n amt = (@merchandise.price * 100).to_i \n desc = @merchandise.name \n %%if self.group_id.present?\n self.groupcut = ((@merchandise.price * 5).to_i).to_f/100\n self.authorcut = ((@merchandise.price * 92).to_i - 30).to_f/100 - self.groupcut\n else%\n self.groupcut = 0.0\n self.authorcut = ((@merchandise.price * 92.1).to_i - 30).to_f/100\n %%end%\n\n else #If a donation is being made\n puts \"14x\" ##########\n self.pricesold = pricesold\n self.author_id = author_id\n seller = User.find(self.author_id)\n amt = (pricesold * 100).to_i\n self.authorcut = ((pricesold * 92.1).to_i - 30).to_f/100\n if self.user_id.present?\n purchaser = User.find(self.user_id)\n desc = \"Donation of $\" + String(pricesold) + \" from \" + purchaser.name\n else\n desc = \"Donation of $\" + String(pricesold) + \" from anonymous customer\"\n end\n end\n\n sellerstripeaccount = Stripe::Account.retrieve(seller.stripeid)\n puts seller.stripeid + \" <-- SELLER stripeid\" ###########\n %%if self.group_id.present? #not used right now\n group = Group.find(self.group_id)\n groupstripeaccount = Stripe::Account.retrieve(group.stripeid)\n end%\n\n if self.email.present?\n puts \"15x\" ##########\n #\n customer = Stripe::Customer.create(\n :source => stripe_card_token, #token from? purchases.js.coffee?\n :description => \"anonymous customer\", # what info do I really want here\n :email => self.email\n )\n puts customer.id ###########\n puts customer.email\n\n else\n puts \"16x\" ##########\n @purchaser = User.find(self.user_id)\n puts @purchaser.name + \" here 16x\" ###########################\n if(@purchaser.stripe_customer_token).present?\n puts \"17x stripe customer token is present\" ##########\n customer = Stripe::Customer.retrieve(@purchaser.stripe_customer_token)\n puts customer.id + \" getting customer id from stripe customer token \"########### CHECKING\n if stripe_card_token.present?\n customer.source = stripe_card_token\n customer.save\n end\n else\n puts \"18x\" ##########\n customer = Stripe::Customer.create(\n :source => stripe_card_token, #token from? purchases.js.coffee?\n :description => @purchaser.name, # what info do I really want here\n :email => @purchaser.email\n )\n @purchaser.update_attribute(:stripe_customer_token, customer.id)\n puts customer.id + \" BUYER customer id\"######## this is customer id for the buyer\n # works upto here\n end\n end\n\n if seller.id == 143 || seller.id == 1403 || seller.id == 1452 || seller.id == 1338 || seller.id == 1442\n puts \"19x\" ##########\n charge = Stripe::Charge.create({\n :amount => amt,\n :currency => \"usd\",\n :customer => customer.id,\n :description => desc\n })\n else\n puts \"20x\" ##########\n # transfergrp = \"purchase\" + (Purchase.maximum(:id) + 1).to_s #won't work when lots of simultaneous purchases\n appfee = ((amt * 5)/100)\n\n puts customer.id ########\n puts sellerstripeaccount.id ########\n token = Stripe::Token.create({\n :customer => customer.id,\n }, {:stripe_account => sellerstripeaccount.id} )\n\n puts \"token end here 20x\" #############\n\n charge = Stripe::Charge.create( {\n :amount => amt, # amt charged to customer's credit card\n :currency => \"usd\",\n :source => token.id, #token from? purchases.js.coffee?\n # :customer => customer.id, # This will be necessary for subscriptions. See Stripe Docs & Stackoverflow\n :description => desc,\n :application_fee => appfee, #this is amt crowdpublishtv keeps - it includes groupcut since group gets paid some time later\n # :transfer_group => transfergrp\n } ,\n {:stripe_account => sellerstripeaccount.id } #appfee only needed for old way of 1 connected acct per transaction\n )\n # transfer = Stripe::Transfer.create({\n # :amount => (self.authorcut * 100).to_i,\n # :currency => \"usd\",\n # :destination => sellerstripeaccount.id,\n # :source_transaction => charge.id, # stripe attempts transfer when this isn't here, even when transfer_group is\n # :transfer_group => transfergrp #does this mean anything when there is a source transaction?\n # })\n puts \"charge here 20x\" #############\n if self.group_id.present? #this is for when groups affiliate to help sell\n puts \"21x\" #############\n transfer = Stripe::Transfer.create({\n :amount => (self.groupcut * 100).to_i,\n :currency => \"usd\",\n :destination => groupstripeaccount.id,\n :source_transaction => charge.id,\n :transfer_group => transfergrp\n })\n end\n end\n\n puts \"23x\" #############\n save!\n\n rescue Stripe::InvalidRequestError => e\n puts \"Stripe error in model!\"\n logger.error \"Stripe error while creating customer: #{e.message}\"\n errors.add :base, \"There was a problem with your credit card.\"\n false\n\n end", "def deduction_params\n params.require(:deduction).permit(:date, :reason, :amount, :rate)\n end", "def create\n @donation = Donation.new(donation_params)\n @donation.donor_id = current_user.id # automatically set donor to current user\n @recipients = Stakeholder.recipients # load all possible recipients\n\n respond_to do |format|\n if @donation.save\n format.html { redirect_to @donation, notice: 'Donation was successfully created.' }\n format.json { render :show, status: :created, location: @donation }\n else\n format.html { render :new }\n format.json { render json: @donation.errors, status: :unprocessable_entity }\n end\n end\n end", "def organization_charge_params\n params.require(:organization_charge).permit(:organization_charge_total_id, :organization_customer_id, :organization_id, :user_id, :price_shebao_base, :price_shebao_qiye, :price_shebao_geren, :price_canbao, :price_shebao_guanli, :price_gongjijin_base, :price_gongjijin_qiye, :price_gongjijin_geren, :price_gongjijin_guanli, :price_geshui, :price_qita_1, :price_qita_2, :price_qita_3, :price_bujiao, :price_yujiao, :price_gongzi, :start_date, :end_date, :comment)\n end", "def deal_params\n params.require(:deal).permit(:profile_id, :item_id, :bye, :sell, :status, :messenger, :paid, :ransom, :comment, :payment_method, :h, :w, :l, :weight)\n end", "def payment_params\n params.require(:payment).permit(:user_transaction_id, :programmed_date, :done_date, :amount, :confirm_payer, :confirm_payee)\n end", "def dutiable(dutiable_params = {})\n @duty = {\n :declared_value => dutiable_params[:value].to_f,\n :declared_currency => dutiable_params[:currency_code].slice(0,3).upcase,\n :terms_of_trade=> dutiable_params[:terms_of_trade]\n }\n end", "def payment_request_to_buyer(order_param, atts = {})\n around_mail_action(:payment_request_to_buyer, order_param, atts) do\n return true unless EffectiveOrders.mailer[:send_payment_request_to_buyer]\n\n @order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param))\n @user = @order.user\n\n @subject = subject_for(@order, :payment_request_to_buyer, \"Request for Payment: Invoice ##{@order.to_param}\")\n\n mail({to: @order.email, cc: @order.cc, subject: @subject}.compact)\n end\n end", "def payment_params\n params[:payment][:bill_id] = params[:bill_id] if params[:bill_id]\n params.require(:payment).permit(:date, :amount, :notes, :payment_type_id,\n :patient_id, :claim_type_id,\n :payment_type_id, :insurance_company_id, :bill_id)\n end" ]
[ "0.7051192", "0.6878747", "0.6869624", "0.6772619", "0.67369765", "0.66817933", "0.6671248", "0.665159", "0.66196316", "0.65792584", "0.6561108", "0.65296704", "0.64958656", "0.6488371", "0.6467558", "0.6453972", "0.6403663", "0.6393339", "0.6380814", "0.63760096", "0.63684964", "0.6341938", "0.6337917", "0.6317352", "0.6304464", "0.6268939", "0.6260716", "0.6253706", "0.6251981", "0.62443554", "0.6203348", "0.6183832", "0.6122087", "0.6105502", "0.609997", "0.6071879", "0.606729", "0.6039265", "0.6035705", "0.60349244", "0.60337985", "0.60185236", "0.6013185", "0.5996867", "0.59679735", "0.59664965", "0.5959803", "0.5947017", "0.5938304", "0.59310263", "0.5917036", "0.59140366", "0.58978695", "0.5893893", "0.5888408", "0.58816546", "0.5867158", "0.58652264", "0.58603734", "0.5858231", "0.5849076", "0.5846517", "0.58463633", "0.58325565", "0.58313864", "0.58293766", "0.5805989", "0.5800432", "0.57944626", "0.5790544", "0.5786495", "0.57851094", "0.5784586", "0.57759875", "0.57731074", "0.57691175", "0.57688254", "0.57665485", "0.57556665", "0.5747016", "0.5746521", "0.57452613", "0.5740076", "0.57318866", "0.57268476", "0.5725763", "0.5723492", "0.57217216", "0.5709813", "0.5704393", "0.5702588", "0.56990695", "0.5690164", "0.5688232", "0.56877637", "0.5682973", "0.5681003", "0.5680989", "0.56736755", "0.56719244", "0.56661874" ]
0.0
-1
redefine your position_taken? method here, so that you can use it in the valid_move? method above.
def position_taken?(board, index) if board[index] == " " || board[index] == "" p false elsif board[index] == nil p false elsif board[index] == "X" || board[index] == "O" p true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend", "def position_taken?\nend", "def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #valid_move? method above.\n def position_taken?(board, index)\n if board[index] == \" \"\n !false\n elsif board[index] == \"\"\n !false\n elsif board[index] == nil\n !false\n elsif board[index] == \"X\" || board[index] == \"O\"\n !true\n end\n end\n position_taken?(board, index)\nend\nend", "def valid_move?(board, index)\nif position_taken?(board, index) == false\n if between?(index) == true\n true\n else\n false\n end\nelse\n false\nend\nend", "def valid_move?(board, position)\n position = position.to_i\n return false if !valid_position?(position)\n return false if position_taken?(board, position)\n return true\nend", "def valid_move?(position)\n position.between?(0,8) && !position_taken?(position)\n end", "def valid_move?(board, index)\n\nif position_taken?(board,index) == true\n return false\nelsif index > -1 && index < 9\n return true\nelse\n return false\nend\n\nend", "def valid_move?(position)\r\n @index = position.to_i-1\r\n if @index.between?(0,8) && !position_taken?(@index)\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def valid_move?(board,position)\n valid = nil\n if position >= 0 && position <=8\n case position_taken?(board,position)\n when true\n valid = false\n when false\n valid = true\n end\n end\n\n return valid\nend", "def valid_move?(position)\n if is_number?(position)\n if position.to_i.between?(0, 10)\n if position_taken?(position.to_i-1)\n false\n else\n true\n end\n else \n false\n end\n else\n false\n end\n end", "def valid_move?( board, index )\n if index >= 0 && index <= 8\n if position_taken?( board, index ) # this is the one\n return false\n else\n return true\n end\n else\n return false\n end\nend", "def valid_move?(fir, sec)\n if (sec < 0) || (sec > 8)\n return false\n elsif position_taken?(fir,sec)\n return false\n else\n return true\n end\nend", "def valid_move?(board,pos)\n if !position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return true\n elsif position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return false\n end\nend", "def valid_move?(board, ix)\n if position_taken?(board, ix) == false && move_val?(ix) == true\n return true\n else\n false\n end\nend", "def valid_move?(new_x, new_y)\n true\n end", "def valid_move?(board, new_index)\n if 8 < new_index || new_index < 0\n return false\n elsif position_taken?(board, new_index) == true\n return false\n else\n return true\n end\nend", "def valid_move?(position)\n !taken?(position) && position.to_i >0 && position.to_i <=9\n end", "def valid_move?(board,position)\n if position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n true\n else\n end\nend", "def valid_move?(board, position)\n # position = position.to_i \n position.to_i. between?(1, 9) && !position_taken?(board, position.to_i-1)\nend", "def valid_move?(board, indx)\n if position_taken?(board, indx)\n false \n elsif (indx < 0 || indx > 8)\n false\n else \n true \n end \nend", "def valid_move? (board, position)\n position = position.to_i - 1\n (position.between?(0,8)) && (position_taken?(board, position) == false)\nend", "def valid_move?(board, indx)\n if indx>=0 && indx<board.length && !position_taken?(board,indx)\n true\n else\n false\n end\nend", "def valid_move?(board, index)\n if position_taken?(board, index) == true\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend", "def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board, position.to_i-1)\nend", "def valid_move?(board, position)\n position_taken?(board, position) == false && position.between?(0, 8) ? true : false\nend", "def valid_move?(position)\n position = position.to_i - 1\n if position_taken?(position) == false && position.to_i.between?(0, 8)\n return true\nelsif position_taken?(position) == true\n return false\nelse \n return false\nend\nend", "def valid_move?(position)\n index=position.to_i - 1\n index.between?(0, 8) && !(position_taken?(index))\n end", "def valid_move?(board,index)\n if index > 9 || index < 0\n return false\n elsif position_taken?(board,index)\n return false\n else\n return true\n end\nend", "def position_taken?(board,position)\n return false if [\" \", \"\", nil].include?(board[position])\n return true if [\"X\", \"O\"].include?(board[position])\n raise \"#{board[position]} is not a valid move\"\nend", "def valid_move?(board, index)\n if position_taken?(board, index) or !(index >= 0 and index < 9)\n false\n else\n true\n end\nend", "def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n\nend", "def valid_move?(board, position)\n position = position.to_i\n if(position.between?(1,9))\n position -=1\n if(position_taken?(board, position))\n false\n else\n true\n end\n end\nend", "def valid_move?(board,position)\n if !position.is_a?(Integer)\n position = position.to_i\n end\n if(position>=1 && position<=board.length && !position_taken?(board,position))\n return true\n end\n return false\nend", "def valid_move?(board, position)\n if !(position_taken?(board, position)) && position.between?(0, 8)\n return true\n else\n return false\n end\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n if position_taken?(board, position) == false && position.to_i.between?(0, 8)\n return true\nelsif position_taken?(board, position) == true\n return false\nelse \n return false\nend\nend", "def valid_move?(board, index)\n if position_taken?(board, index)\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n if position_taken?(board, position)\n return false\n else\n if position.between?(0,8) && (board[position] != \"X\" || board[position] != \"O\")\n return true\n else\n return false \n end\n end\nend", "def valid_move?(input_position)\n num = self.convert_to_i(input_position)\n num.between?(1, 9) && !self.taken?(num)\n end", "def valid_move?(board, position)\n if position.to_i>=1 && position.to_i<=9 && !position_taken?(board, position.to_i-1)\n return true\n else\n return false\n end\nend", "def valid_move?(board,position)\n position=position.to_i-1\n if position.between?(0,8) && !position_taken?(board, position)\n true\n else\n false\n end\nend", "def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend", "def valid_move?(position)\n if !position_taken?(position) && position.between?(0,8)\n true\n else\n false\n end\n end", "def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else\n false\n end\nend", "def valid_move?(board, i)\n # check if position taken or 'out-of-bounds'\n if (position_taken?(board, i) == true) || (i > 8) || (i < 0)\n return false\n else \n return true\n end \nend", "def move_is_valid?(position)\n\t\tif @played_positions.index(position)\n\t\t\tresult = false\n\t\telse \n\t\t\t@played_positions << position \n\t\t\tresult = true\n\t\tend\n\t\tresult\n\tend", "def valid_move?(board, position)\n indexed_position = position.to_i - 1\n indexed_position.between?(0,8) && !position_taken?(board, indexed_position)\nend", "def valid_move?(board,index)\n if (index >= 0 && index <=8)\n if (position_taken?(board,index))\n return false\n else\n return true\n end\n else\n return false\n end\nend", "def valid_move?(board, position)\n position = (position.to_i - 1)\n\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n else false\n end\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n position_taken?(board, position) == false && position.between?(0,8) == true\nend", "def valid_move?(board, index)\n if index.between?(0, board.count - 1) && position_taken?(board, index) == false\n true\n else\n false\n end\nend", "def valid_move?(board, index)\n \nif position_taken?(board, index) === false && index.between?(0, 8)\n return true\nelse \n return false\nend\nend", "def valid_move?(position)\n if !position.is_a?(Integer)\n position = position.to_i\n end\n if(position>=1 && position<[email protected] && !position_taken?(position))\n return true\n end\n return false\n end", "def valid_move?(board, position)\n !position_taken?(board, position) && position.between?(0,8)\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n end\nend", "def valid_move?(board,index)\n if position_taken?(board,index) == true\n return false\n elsif index > 8 or index < 0\n return false\n else\n return true\n end\n end", "def valid_move?(board, position)\n position = position.to_i\n \n if (position_taken?(board, position) ==false) && position.between?(1,9)\n return true\n else\n return false\n end\nend", "def valid_move?( board, index )\n\n if (index.between?(0,8) ) && ( position_taken?(board, index) == false )\n return true\n else\n return false\n end\n\nend", "def valid_move?(board, index)\n if board[index].nil? || position_taken?(board, index) || board[index] == \"X\" || board[index] == \"O\"\n false\n else\n true\n end\nend", "def valid_move? (board, index)\n if index.between?(0, 8) && !position_taken?(board, index)\n true \n end \nend", "def valid_move?(board, position)\n position = position.to_i\n \n if !(position_taken?(board, position-1)) && position.between?(1,9)\n return true\n else\n return false\n end\nend", "def valid_move?(board, index)\nif !(index.between?(0,8))\n return false\nelsif position_taken?(board, index)\n return false \nelse \n return true\n end\nend", "def valid_move?(a,i)\r\n if i.between?(0,8) && !position_taken?(a,i)\r\n true\r\n else\r\n false\r\n end\r\nend", "def valid_move?(board,index)\n if index < 0\n false\n else\n if index > 8\n false\n else\n !position_taken?(board,index)\n end\n end\nend", "def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\nelse\n false\nend\nend", "def valid_move?(location)\n location.to_i.between?(1,9) && !position_taken?(location.to_i-1)\n end", "def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else position_taken?(board, index) == true\n nil\n end\nend", "def position_taken?(board, position)\n if !(board[position.to_i - 1] == \"X\" || board[position.to_i - 1] == \"O\")\n return true\n else \n return false\n end\nend", "def valid_move?(board, idx)\n if position_taken?(board, idx) == false && idx.between?(0, 8)\n return true\n else\n return false\n end\nend", "def valid_move?(index)\n\t\tindex < 9 && !position_taken?(index) ? true : false\n\tend", "def valid_move?(position) ### changed from index to position - ER 2017\n\n if (position > 9) || (position < 0) #if index (position on board entered by user) is greater than 9 or less than 0, return false\n false\n elsif position_taken?(position) ###otherwise, if position on board is taken, return false\n false\n else position.between?(0, 8) ###finally, if the position isn't taken, and the index (position on board entered by user) is between 0 and 8, return true\n true\n end # end if...elsif statements\n end", "def position_taken?(board, index_to_validate)\n if (board[index_to_validate] == \"X\" || board[index_to_validate] == \"O\")\n return true\n end\n return false # NOTE: if we arrive here, the position is definitely not taken\nend", "def position_taken?(board, pos)\n if board[pos]==\"X\" || board[pos]==\"O\"\n taken = true\n else\n taken = false\n end\n taken\nend", "def valid_move?(board,index)\n if index >= 0 && index <= 8\n if !position_taken?(board, index)\n return true\n else \n return false\n end\n else \n return false\n end\nend", "def valid_move?(board, position)\n if position_taken?(board, position) == false && position.to_i.between?(0,8)\n true\n else\n false\n end\n end", "def valid_move?(board, index)\n if index.between?(0, 8) && (position_taken?(board, index) == false)\n true\n elsif (index.between?(0,8) == false) || (position_taken?(board, index) == true)\n false\n end\nend", "def valid_move?(move_index)\r\n #valid if position is NOT taken\r\n valid = !self.position_taken?(move_index)\r\n if valid == true\r\n if move_index.between?(0,8)\r\n valid = true\r\n else\r\n valid = false\r\n end\r\n end\r\n valid\r\n end", "def valid_move?(board,index)\n if position_taken?(board,index) == FALSE && index.between?(0, 8) == TRUE\n TRUE\n else\n FALSE\n end\nend", "def valid_move?(board, index)\nif position_taken?(board, index)\nreturn false\nelsif !index.between?(0, 8)\n return false\n else\n return true\n end\nend", "def valid_move?(board, index)\n index.between?(0, 8) && position_taken?(board, index) == false\n\nend", "def valid_move?(board,index)\n if index.between?(0,8) && !position_taken?(board,index)\n true\n else\n false\n end\n\nend", "def position_taken?(board, new_index)\n if board[new_index] == \"X\" || board[new_index] == \"O\"\n return true\n else\n return false\n end\nend", "def valid_move?(board,index)\n if index.between?(0, 8) && !(position_taken?(board, index))\n true\n else \n false\n end\nend", "def valid_move?(board, index)\n if !(index.between?(0,8))\n return false\n end\n if (position_taken?(board,index))\n return false\n end\n true\nend", "def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\n else\n false\n end\nend", "def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n puts \"this is a valid move\"\n return true\n else\n return false\n end\nend", "def valid_move?(board, index)\r\n if index.between?(0, 8) && ! position_taken?(board, index)\r\n return TRUE\r\n else \r\n return FALSE\r\n end\r\nend", "def valid_move?(board, index)\n if position_taken?(board, index) == false && index.between?(0, 8) == true\n true\n else\n false\nend\nend", "def position_taken?(move_index)\r\n if @board[move_index] == \" \"\r\n false\r\n else\r\n true\r\n end\r\n end", "def valid_move?(board,index)\n if !position_taken?(board,index) && index >= 0 && index <=8\n return true\n else \n return false\n end\nend", "def valid_move? (board, index)\n if (index).between?(0,8) == true && position_taken?(board, index) == false\n return true\n else\n return false\n end\nend", "def valid_move?(board,index)\n if index.between?(0,8) && position_taken?(board,index)\n true\n end\nend", "def position_taken?(board,move)\n if board[move]!=\" \"\n return false\n end\nreturn true\nend", "def position_taken?(board,pos)\n if board[pos.to_i]==\"X\" || board[pos.to_i] ==\"O\"\n return true\n else\n return false\n end\nend", "def position_taken?(board, position)\n return true if board[position - 1] == \"X\" || board[position - 1] == \"O\"\n false\nend", "def position_taken?(location)\n !(board[location] == \" \" || board[location].nil?)\nend", "def valid_move?(input)\n (0..8).include?(input) && !position_taken?(input)\n end", "def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend", "def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend", "def valid_move?(index)\n if position_taken?(index)\n false\n elsif index < 0 || index > 8\n false\n else\n true \n end\n end", "def valid_move?(board, index)\n# binding.pry\n index.between?(0,8) && !position_taken?(board, index)\nend", "def valid_move?(board, position)\n index = position.to_i\n if position_taken?(board, index) == false && index.between?(0, 8)\n return true\n else\n return false\n end\nend" ]
[ "0.84084135", "0.8163241", "0.8090029", "0.8027103", "0.8012905", "0.7896375", "0.7893138", "0.78846574", "0.7842956", "0.7841005", "0.7831056", "0.7813726", "0.78123397", "0.78094643", "0.78016865", "0.7800575", "0.7799216", "0.7788002", "0.7781558", "0.77737105", "0.7772456", "0.77703243", "0.7766281", "0.77566034", "0.77541864", "0.77529645", "0.77484506", "0.77405787", "0.7738696", "0.7737704", "0.7726189", "0.7725278", "0.7724784", "0.772413", "0.77207065", "0.7720363", "0.7717095", "0.7715057", "0.7714467", "0.7696031", "0.76904947", "0.76843005", "0.76790047", "0.7678052", "0.76731956", "0.7672384", "0.76714236", "0.7669352", "0.7660934", "0.76577836", "0.7657217", "0.76418674", "0.7641307", "0.7640897", "0.7640766", "0.76355284", "0.76325184", "0.7624486", "0.7622769", "0.7619667", "0.76172286", "0.761326", "0.7611823", "0.76083183", "0.7608145", "0.76008254", "0.7598243", "0.759449", "0.7590879", "0.7590771", "0.75900877", "0.75784135", "0.7576633", "0.7576531", "0.7574092", "0.7572586", "0.75654346", "0.75654024", "0.7556784", "0.75528336", "0.7550141", "0.75498146", "0.75480473", "0.7548029", "0.7540344", "0.7538331", "0.75382143", "0.7538164", "0.7537544", "0.753618", "0.75342107", "0.7532227", "0.75316787", "0.7531169", "0.75291747", "0.75286615", "0.75277793", "0.75277793", "0.75258815", "0.75248575", "0.7524408" ]
0.0
-1
The ASCII string value is the sum of the ASCII values of every character in the string. (You may use Stringord to determine the ASCII value of a character.)
def ascii_value(string) sum = 0 string.each_char { |char| sum += char.ord} sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ascii_value(str)\n ascii_sum = 0\n\n str.each_char { |char| ascii_sum += char.ord }\n ascii_sum\nend", "def ascii_value(string)\n sum = 0\n string.chars.each do |char|\n sum += char.ord\n p char.ord.chr # Further Exploration\n end\n sum\nend", "def ascii_value(str)\n str.chars.map { |chr| chr.ord }.sum\nend", "def ascii_value(str)\n sum = 0\n str.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |x| sum += x.ord }\n sum\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(str)\n # str.chars.map(&:ord).reduce(0) { |a, e| a + e } # 0 is default sum\n # OR:\n str.chars.reduce(0) { |a, e| a + e.ord }\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(str)\n\tarr = str.chars\n\n\tarr.map! do |element|\n\t\telement.ord\n\tend\n\n\tarr.sum\nend", "def ascii_value(str)\n sum = 0\n str.each_char {|char| sum += sum += digit.ord}\n sum\nend", "def ascii_value(string)\n string.each_char.reduce(0) { |sum, char| sum + char.ord }\nend", "def ascii_value(str)\n# characters = str.chars\n# sum = 0\n\n# characters.each do |char|\n# sum += char.ord # sum = sum + char.ord\n# end\n\n# sum\n\n return 0 if str == ''\n\n ords = str.chars.map {|c| c.ord }\n\n ords.reduce do |sum, c|\n sum + c\n end\nend", "def ascii_value(string)\n letters = string.chars\n ascii_total = 0\n letters.each do |letter|\n ascii_total += letter.ord\n end\n ascii_total\nend", "def ascii_value(string)\n string.chars.inject(0) { |sum, char| sum += char.ord }\nend", "def ascii_value(str)\n str.split('').reduce(0) {|sum,chr| sum + chr.ord }\nend", "def ascii_value(str)\n sum = 0\n # str.split(\"\").each { |val| sum += val.ord } My ans. Better method each_char\n str.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(str)\n str.bytes.sum\nend", "def ascii_value(str)\r\n ascii_values = str.chars.map{|char| char.ord}\r\n (str == '') ? 0 : ascii_values.reduce(:+)\r\nend", "def ascii_value(string)\n result = 0\n string.chars.each do |char|\n result += char.ord\n end\n result\nend", "def ascii_value(string)\n value = 0\n string.chars.each do |char|\n value += char.ord\n end\n value\nend", "def ascii_value(string)\n value = 0 \n\n string.each_char { |char| value += char.ord }\n\n value\nend", "def ascii_value(string)\n return 0 if string.empty?\n string.chars.map { |char| char.ord }.reduce(:+)\nend", "def ascii_value(string)\n value = 0\n string.chars { |c| value += c.ord }\n value\nend", "def ascii_value(str)\n str.chars.map(&:ord).inject(0, &:+)\nend", "def ascii_value(str)\n val = str.chars.map(&:ord).reduce(:+)\n !val ? 0 : val\nend", "def ascii_value(string)\n ascii_value = 0\n\n string.each_char { |char| ascii_value += char.ord }\n\n ascii_value\nend", "def ascii_value(string)\n string.emtpy? ? 0 : string.chars.map{|letter| letter.ord }.reduce(&:+)\nend", "def ascii_value(string)\n string.chars.reduce(0) { |result, char| result += char.ord }\nend", "def ascii_value(string)\n if string.empty?\n 0\n else\n values = string.chars.map { |char| char.ord }\n values.reduce(:+)\n end\nend", "def ascii_value(string)\n ascii_array = string.split('').map(&:ord)\n ascii_array.reduce(0) { |acc, elem| acc + elem }\nend", "def ascii_value(str)\n string_value = 0\n if str.is_a? String \n str.each_char do |char|\n string_value += char.ord\n end\n else\n puts \"Invalid entry!\"\n end\n string_value\nend", "def ascii_value(string)\n value = 0\n for i in (0..string.length-1)\n value += string[i].ord\n end\n value\nend", "def ascii_value(ascii_string)\n string_array = ascii_string.chars\n ascii_value_array = [0]\n\n string_array.each do |char|\n ascii_value_array << char.ord\n end\n\n ascii_value = ascii_value_array.reduce(:+)\nend", "def ascii_value(string)\r\n integer = 0\r\n string.each_char { |chr| integer += chr.ord }\r\n integer\r\nend", "def ascii_value(str)\n counter = 0\n str.each_char do |char|\n counter = counter + char.ord\n end\n counter\nend", "def ascii_value(string)\n counter = 0\n string.chars.map { |e| counter += e.ord }\n counter\nend", "def sum_of_ascii_values(message)\n\treturn message.map{|c| c.to_i}.reduce(:+)\nend", "def sumWithFctChar(string)\n sum = 0\n string.each_char do\n |chr|\n sum += chr.to_i\n end\n puts \"La somme des chiffres de \\\"#{string}\\\" est égal à #{sum}\"\nend", "def strsum(str)\n total = 1\n str.chars.each do |c|\n total = total * c.to_i\n end\n total\nend", "def charsSum (s)\n\t\tsum = 0\n\t\ts.each_char { |c| sum += self.letterToInt(c) }\n\t\treturn sum\n\tend", "def getASCII(c)\n c.ord\nend", "def string_sum(string)\n sum = 0\n alphabets = (\"a\"..\"z\").to_a\n string.chars.each do |ch|\n sum += alphabets.index(ch) + 1\n end\n sum\nend", "def ascii_value(url)\n ascii_value = 0;\n url.each_char {|url| ascii_value += url.ord}\n return ascii_value\n end", "def atoi(string_int)\n sum = 0\n string_int.each_byte do |char|\n sum = (sum * 10) + (char - ZERO_ASCII_CODE)\n end\n\n return sum\nend", "def string_sum(string)\n letters = ('a'..'z').to_a\n sum = 0\n string.split(\"\").each{|x| sum += letters.index(x) + 1}\n sum \nend", "def atoi\n\t\t _int = []; _sum = 0\n\t\t\n\t\t@ascii_string.each do |value| \n\t\t\t_int.push(NILTO9[value])\n\t\tend\n\t\t\n\t\te = _int.length \t\t\n\t\n\t\t_int.each do |value|\n\t\t\t_sum = _sum + ((value/BASE)/(1/(BASE**e))).floor\n\t\t\te -= 1\n\t\tend\t\n\n\t \t_sum\n\tend", "def parseAscii str\n\tstr.chars.map { |c| c !~ /[[:print:]]/ ? \"0x\" + c.ord.to_s : c}.join\nend", "def ord(char)\n char.bytes.first\nend", "def sum(num)\n sum = 0\n num.to_s.chars.each do |ch|\n sum += ch.to_i\n end\n sum\nend", "def encode_string(str)\n str.chars.map(&:ord)\n end", "def str_to_ints(str)\n str.chars.map{|c| c == ' ' ? c : c.ord - 64 }\nend", "def ord(x)\n if x.is_a? String\n x.ord\n else\n x\n end\nend", "def to_ascii(string)\n\t\tstring.unpack(\"U*\").map do |c| \n\t\t\tc.chr if c < 128\n\t\tend.join\n\tend", "def hand_score(string)\n cards = { A: 4, K: 3, Q: 2, J: 1 }\n score = 0\n string.each_char do |char|\n score += cards[char.upcase.to_sym]\n end\n\n score\nend", "def compare_sum_char_code(chars1, chars2)\n chars1 = '' unless chars1&.match?(/\\A[a-zA-Z]+\\z/)\n chars2 = '' unless chars2&.match?(/\\A[a-zA-Z]+\\z/)\n\n num1 = chars1.to_s.upcase.split('').map(&:ord).sum\n num2 = chars2.to_s.upcase.split('').map(&:ord).sum\n\n num1 == num2\nend", "def calculate\n string.\n each_byte.\n to_a.\n each_with_index.\n map { |byte, index| (index + 1) * byte }.\n reduce(0, :+)\n end", "def sum(name)\n # Get rid of new line character and convert to lowercase\n name.chomp!.downcase!\n # Loop through each byte and get the sum\n result = 0\n name.each_byte do |c|\n result += c\n end\n result\n end", "def lookup(string)\r\n return 2 ** (string.chr.downcase.ord - ('a'.ord))\r\n end", "def task_4(string)\n sum = 0\n string.each_char do |chr|\n !chr.to_i.nil? ? sum += chr.to_i : nil\n end\n sum\nend", "def add(chars)\n result = chars[0]\n \n for i in 1...chars.length\n result = binaryAdd(result, chars[i])\n end\n \n result\n end", "def locNumToInt(str)\n\tnum = 0\n\tstr.split('').each {|c|\n\t\tnum += 2**(c.ord - 97)\n\t}\n\tnum\nend", "def ae_count(string)\n hash = Hash.new(0)\n string.each_char do |char|\n if char == 'a' || char == 'e'\n hash[char] += 1 \n end\n end\n\n hash\nend", "def calc_characters(string)\n words = string.split\n chars = 0\n words.each { |word| chars += word.size }\n chars\nend", "def ae_count(str)\n count = {\"a\"=>0, \"e\"=>0}\n\n str.each_char do |char|\n if (char == \"a\" || char == \"e\")\n count[char] += 1\n end\n end\n\n return count\nend", "def get_ords(string)\n\tstring.each_char do |char|\n\t\tputs \"#{char} > #{char.ord}\"\n\tend\nend", "def count_characters_v2(str)\n\tcount = Array.new(26, 0)\n\tstr.each_char do |char|\n\t\tcount[char.ord - \"a\".ord] += 1\n\tend\t\n\t0.upto(count.length-1) do |i|\n\t\tputs \"(\" + (\"a\".ord + i).chr + \"; \" + count[i].to_s + \")\" if count[i] > 0\n\tend\nend", "def letterToInt (c)\n\t\treturn c.ord() -'A'.ord() + 1\n\tend", "def hash_code(str)\n str.each_char.reduce(0) do |result, char|\n [((result << 5) - result) + char.ord].pack('L').unpack('l').first\n end\n end", "def string_to_integer(str)\n arr = []\n str.each_char { |char| arr << char if STR_TO_INT.key?(char) }\n\n sum = 0\n arr.reverse.each.with_index do |num, index|\n sum += STR_TO_INT[num] * 10**index\n end\n sum\nend", "def scrabble_score(str)\n str = str.upcase.delete(\"^A-Z\")\n return 0 if str.nil? || str.empty?\n str.chars.map{ |chr| $dict[chr] }.reduce(:+)\nend", "def sum num\n value = 0\n str = num.to_s\n arr = str.split('')\n arr.map! {|char| char.to_i}\n arr.each {|x| value += x}\n value\nend", "def s_to_i(string)\n string.chars.reduce(0) do |output, char|\n output * charset.length + char_to_codepoint(char)\n end\n end", "def string(str)\n old = @pos\n @buffer << str.force_encoding('ASCII-8BIT')\n @pos = @buffer.bytesize\n return @pos, old\n end", "def atoi(s)\n\t\tnum = 0\n\t\tacc = 0\n\t\ts.length.downto(0) { |i|\n\t\t\tif s[i] == '0'\n\t\t\t\tnum = 0\n\t\t\telsif s[i] == '1'\n\t\t\t\tnum = 1\n\t\t\telsif s[i] == '2'\n\t\t\t\tnum = 2\n\t\t\telsif s[i] == '3'\n\t\t\t\tnum = 3\n\t\t\telsif s[i] == '4'\n\t\t\t\tnum = 4\n\t\t\telsif s[i] == '5'\n\t\t\t\tnum = 5\n\t\t\telsif s[i] == '6'\n\t\t\t\tnum = 6\n\t\t\telsif s[i] == '7'\n\t\t\t\tnum = 7\n\t\t\telsif s[i] == '8'\n\t\t\t\tnum = 8\n\t\t\telsif s[i] == '9'\n\t\t\t\tnum = 9\n\t\t\telsif s[i] == '-' && i == 0\n\t\t\t\tnum = 0\n\t\t\t\t\tacc *= -1\n\t\t\t\telsif s[i] == nil || (s[i] == '+' && i == 0)\n\t\t\t\tnum = 0\n\t\t\telse\n\t\t\t\tabort(\"No se ingreso un número válido.\")\n\t\t\tend\n\t\t\tif num > 0\n\t\t\t\tacc += num * 10** (s.length-1-i)\n\t\t\tend\n\t\t}\n\t\tacc\n\tend", "def string_to_integer(str)\n str.chars.map { |chr| chr.ord - 48 }.reduce { |a, e| (a * 10) + e }\nend", "def ae_count(str)\n count = {\"a\"=> 0, \"e\" => 0}\n puts count\n str.each_char do |char|\n if (char == \"a\" || char == \"e\")\n count[char] += 1\n end \n end\n return count\nend", "def string(str)\n integer(str.bytesize, 0) + str.dup.force_encoding('binary')\n end", "def string_to_integer(str)\n convert_hash = {\n '0' => 0,\n '1' => 1,\n '2' => 2,\n '3' => 3,\n '4' => 4,\n '5' => 5,\n '6' => 6,\n '7' => 7,\n '8' => 8,\n '9' => 9,\n }\n sum = 0\n value = 0\n str_arr = str.chars\n str_arr.each do |num|\n value = convert_hash[num]\n sum += value * (10 ** (str_arr.length - (str_arr.index(num) + 1)))\n end\n sum\nend", "def letter_count(str)\nletters = Hash.new(0)\n\tstr.each_char do |letter| letters[letter] += 1 end\n\t\treturn letters\nend", "def roman_to_int(s)\n letters = {'I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000}\n words = s.split(\"\")\n result = words.reduce do |accumulator, current|\n letters[accumulator] + letters[current]\n end \n result\nend", "def to_i(str)\n i = 0\n b = 1\n str.each_byte { |c| i += b*c; b *= 256 }\n return i\n end", "def decode(s)\n i = 0\n base = ALPHABET.length\n s.each_char { |c| i = i * base + ALPHABET.index(c) }\n i\n end", "def calculate_alphabet(str)\nend", "def letter_to_number(letter)\n letter.ord - 64\nend", "def sum_of_digit(n)\n sum = 0\n n.to_s.each_char {|i| sum = sum + i.to_i}\n puts sum\nend", "def +(chr)\n @str += chr\n end", "def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end", "def atoi(word)\n results = []\n word.chars.each do |char|\n letter = change_letter(char)\n results << letter\n end\n results.each do |integer|\n print integer\n end\n puts \"\"\nend", "def char_count(string)\n\tchar_count = Hash.new\n\t\"abcdefghijklmnopqrstuvwxyz\".chars.each {|char| char_count[char] = 0}\n\tstring.chars.each {|char| char_count[char] += 1}\n\tchar_count\nend", "def sum(num)\n num.to_s.chars.map(&:to_i).sum\nend", "def sum(int)\n int.to_s.chars.map(&:to_i).reduce(:+)\nend", "def myAtoi( str)\n value = 0\n size = str.length\n i = 0\n while (i < size)\n value = (value << 3) + (value << 1) + (str[i].ord - '0'.ord)\n i += 1\n end\n return value\nend", "def roman_to_int(str)\n hash = {\n 'M' => 1000,\n 'D' => 500,\n 'C' => 100,\n 'L' => 50,\n 'X' => 10,\n 'V' => 5,\n 'I' => 1,\n }\n sum = 0\n cur = 0\n\n str.chars.each do |l|\n prev = cur\n cur = hash[l]\n sum += cur\n sum -= (prev * 2) if prev < cur\n end\n\n sum\nend", "def sum_of_integers(string)\n num_as_str = (0..9).to_a.map(&:to_s)\n integer_array = string.chars.select {|char| num_as_str.include?(char)}.map(&:to_i)\n integer_array.reduce(:+)\nend", "def replace_with_ascii(input)\n\tints = input.split\n\toutput = \"\"\n\tints.each do |t|\n\t\tt = t.to_i\n\t\toutput += t.chr \n\tend\n\tputs output\nend", "def sentence_score(hex_string) # rubocop:disable Metrics/MethodLength\n real_string = hex_to_chars(hex_string).chars\n real_string.map do |chr|\n case chr.ord\n when 33..64, 91..96, 123..127\n 0.5 # punctuation / numbers\n when 32, 65..90, 97..122\n 1\n else\n -2.5 # control characters\n end\n end.sum / real_string.length.to_f\nend", "def change(str)\n if str.class == String\n array = str.split(//)\n binary = Array.new(26, 0)\n array.uniq.sort!\n base = \"a\".ord\n base_upcase = \"A\".ord\n array.each do |x|\n if (65..90).include?(x.ord)\n binary[x.ord - base_upcase] = 1\n elsif (97..122).include?(x.ord)\n binary[x.ord - base] = 1\n end\n end\n end\n binary.join('')\nend", "def decode(str)\n num = 0\n str.each_char {|c| num = num * BASE + ALPHANUM.index(c) }\n return num;\n end", "def str_hash(key)\n key.bytes.inject(&:+)\n end" ]
[ "0.90551573", "0.901951", "0.90099114", "0.9006021", "0.8973511", "0.8946076", "0.8946076", "0.89357096", "0.89142203", "0.8910129", "0.88800824", "0.88703007", "0.88498753", "0.8836479", "0.8778884", "0.8757993", "0.8751687", "0.8745328", "0.8687609", "0.8637994", "0.8609859", "0.8608651", "0.8596984", "0.8587895", "0.8573429", "0.85725373", "0.856463", "0.85627645", "0.8536907", "0.8533436", "0.8412573", "0.8412239", "0.84074867", "0.8377529", "0.8361059", "0.8311374", "0.8250905", "0.72745407", "0.7222127", "0.70706445", "0.69969606", "0.6929722", "0.6913784", "0.6761592", "0.6680952", "0.65816224", "0.65253586", "0.6467415", "0.63933337", "0.63789785", "0.636023", "0.6308092", "0.6290295", "0.62880635", "0.6228438", "0.6155099", "0.61308444", "0.6116985", "0.6110726", "0.6063331", "0.60465264", "0.602976", "0.60256463", "0.6016799", "0.60128796", "0.59927815", "0.59769076", "0.5956488", "0.5926146", "0.59235233", "0.5894633", "0.5891663", "0.58908755", "0.58692497", "0.5842731", "0.58248633", "0.581121", "0.57959336", "0.57858217", "0.5779994", "0.57682836", "0.5765412", "0.5761476", "0.5759954", "0.57553", "0.5747167", "0.57447124", "0.5735702", "0.57341516", "0.5705535", "0.57047427", "0.5686761", "0.5685015", "0.56742334", "0.5673486", "0.5632922", "0.56310606", "0.5627407", "0.56258947", "0.5625778" ]
0.8958713
5
=begin Input: string create a sum variable set to 0 Iterate through each character in the string by using the each_char method add char.ord to sum variable return the sum variable Output: integer sum =end
def ascii_value(string) value = 0 string.chars.each do |char| value += char.ord end value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strsum(str)\n total = 1\n str.chars.each do |c|\n total = total * c.to_i\n end\n total\nend", "def charsSum (s)\n\t\tsum = 0\n\t\ts.each_char { |c| sum += self.letterToInt(c) }\n\t\treturn sum\n\tend", "def sumWithFctChar(string)\n sum = 0\n string.each_char do\n |chr|\n sum += chr.to_i\n end\n puts \"La somme des chiffres de \\\"#{string}\\\" est égal à #{sum}\"\nend", "def ascii_value(str)\n sum = 0\n # str.split(\"\").each { |val| sum += val.ord } My ans. Better method each_char\n str.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(str)\n sum = 0\n str.each_char {|char| sum += sum += digit.ord}\n sum\nend", "def ascii_value(string)\n sum = 0\n string.chars.each do |char|\n sum += char.ord\n p char.ord.chr # Further Exploration\n end\n sum\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |x| sum += x.ord }\n sum\nend", "def string_sum(string)\n sum = 0\n alphabets = (\"a\"..\"z\").to_a\n string.chars.each do |ch|\n sum += alphabets.index(ch) + 1\n end\n sum\nend", "def ascii_value(str)\n# characters = str.chars\n# sum = 0\n\n# characters.each do |char|\n# sum += char.ord # sum = sum + char.ord\n# end\n\n# sum\n\n return 0 if str == ''\n\n ords = str.chars.map {|c| c.ord }\n\n ords.reduce do |sum, c|\n sum + c\n end\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord}\n sum\nend", "def string_sum(string)\n letters = ('a'..'z').to_a\n sum = 0\n string.split(\"\").each{|x| sum += letters.index(x) + 1}\n sum \nend", "def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend", "def ascii_value(str)\n sum = 0\n str.each_char { |char| sum += char.ord }\n sum\nend", "def sum(num)\n sum = 0\n num.to_s.chars.each do |ch|\n sum += ch.to_i\n end\n sum\nend", "def task_4(string)\n sum = 0\n string.each_char do |chr|\n !chr.to_i.nil? ? sum += chr.to_i : nil\n end\n sum\nend", "def ascii_value(str)\n ascii_sum = 0\n\n str.each_char { |char| ascii_sum += char.ord }\n ascii_sum\nend", "def sum num\n value = 0\n str = num.to_s\n arr = str.split('')\n arr.map! {|char| char.to_i}\n arr.each {|x| value += x}\n value\nend", "def sum_of_digit(n)\n sum = 0\n n.to_s.each_char {|i| sum = sum + i.to_i}\n puts sum\nend", "def ascii_value(string)\n letters = string.chars\n ascii_total = 0\n letters.each do |letter|\n ascii_total += letter.ord\n end\n ascii_total\nend", "def ascii_value(str)\n str.chars.map { |chr| chr.ord }.sum\nend", "def ascii_value(string)\n string.chars.inject(0) { |sum, char| sum += char.ord }\nend", "def ascii_value(str)\n # str.chars.map(&:ord).reduce(0) { |a, e| a + e } # 0 is default sum\n # OR:\n str.chars.reduce(0) { |a, e| a + e.ord }\nend", "def ascii_value(string)\n string.each_char.reduce(0) { |sum, char| sum + char.ord }\nend", "def ascii_value(str)\n\tarr = str.chars\n\n\tarr.map! do |element|\n\t\telement.ord\n\tend\n\n\tarr.sum\nend", "def sum(name)\n # Get rid of new line character and convert to lowercase\n name.chomp!.downcase!\n # Loop through each byte and get the sum\n result = 0\n name.each_byte do |c|\n result += c\n end\n result\n end", "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 ascii_value(str)\n counter = 0\n str.each_char do |char|\n counter = counter + char.ord\n end\n counter\nend", "def calc_characters(string)\n words = string.split\n chars = 0\n words.each { |word| chars += word.size }\n chars\nend", "def sum_of_numbers_in_string(str)\n str.scan(/\\d+/).map { |chars| chars.to_i }.reduce(0, :+)\nend", "def ascii_value(string)\n value = 0 \n\n string.each_char { |char| value += char.ord }\n\n value\nend", "def sum_digits( i )\n sum = 0\n\n i.to_s.split( // ).each do |d|\n sum += d.to_i\n# sum += $a_to_i[d.ord]\n end\n\n sum\nend", "def sum(input)\n arr = input.to_s.chars.map { |x| x.to_i }\n arr.reduce { |sum, num| sum + num }\n # number.to_s.chars.map(&:to_i).reduce(:+) # read up on symbols and procs\nend", "def ascii_value(string)\n string.emtpy? ? 0 : string.chars.map{|letter| letter.ord }.reduce(&:+)\nend", "def sum_of_digits(n)\n sum = 0\n n.each_char {|digit| sum += digit.to_i}\n\n puts sum\nend", "def sum_of_integers(string)\n num_as_str = (0..9).to_a.map(&:to_s)\n integer_array = string.chars.select {|char| num_as_str.include?(char)}.map(&:to_i)\n integer_array.reduce(:+)\nend", "def ascii_value(string)\n result = 0\n string.chars.each do |char|\n result += char.ord\n end\n result\nend", "def ascii_value(string)\n counter = 0\n string.chars.map { |e| counter += e.ord }\n counter\nend", "def sum(num)\n num.to_s.chars.map(&:to_i).sum\nend", "def ascii_value(str)\n str.bytes.sum\nend", "def ascii_value(str)\n string_value = 0\n if str.is_a? String \n str.each_char do |char|\n string_value += char.ord\n end\n else\n puts \"Invalid entry!\"\n end\n string_value\nend", "def NumberAddition(str)\n\n str.gsub!(/[^0-9]/, \" \")\n arr = str.split(\" \")\n sum = 0\n arr.each do |x|\n sum += x.to_i\n end\n return sum\n \nend", "def ascii_value(str)\n str.split('').reduce(0) {|sum,chr| sum + chr.ord }\nend", "def ascii_value(string)\r\n integer = 0\r\n string.each_char { |chr| integer += chr.ord }\r\n integer\r\nend", "def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\n \nend", "def get_sum_one(str)\n sum = 0\n str.scan(/(-?\\d+)/).each { |item| sum += item[0].to_i }\n sum\nend", "def sum(number)\n numbers = number.to_s.chars\n\n numbers.reduce {|sum, i| sum.to_i + i.to_i }\nend", "def ascii_value(string)\n if string.empty?\n 0\n else\n values = string.chars.map { |char| char.ord }\n values.reduce(:+)\n end\nend", "def ascii_value(string)\n value = 0\n string.chars { |c| value += c.ord }\n value\nend", "def sum(num)\n num.to_s.chars.map(&:to_i).reduce(:+)\nend", "def sum(num)\n num.to_s.chars.map(&:to_i).reduce(:+)\nend", "def ascii_value(string)\n value = 0\n for i in (0..string.length-1)\n value += string[i].ord\n end\n value\nend", "def ascii_value(string)\n return 0 if string.empty?\n string.chars.map { |char| char.ord }.reduce(:+)\nend", "def ascii_value(str)\r\n ascii_values = str.chars.map{|char| char.ord}\r\n (str == '') ? 0 : ascii_values.reduce(:+)\r\nend", "def digits_sum\n self.split('').map {|x| x.to_i}.inject(0) do |res,elt|\n res += elt\n res\n end\n end", "def ascii_value(string)\n ascii_value = 0\n\n string.each_char { |char| ascii_value += char.ord }\n\n ascii_value\nend", "def sum(num)\n num.to_s.split('').inject(0) do |total, num|\n total + num.to_i\n end\nend", "def sum(num)\n sum = 0\n num.to_s.split('').each do |number|\n sum += number.to_i\n end\n sum\nend", "def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\nend", "def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\nend", "def sum(number)\n sum = number.to_s.chars\n total = sum.map {|num| num.to_i }\n total.reduce(:+)\nend", "def atoi(string_int)\n sum = 0\n string_int.each_byte do |char|\n sum = (sum * 10) + (char - ZERO_ASCII_CODE)\n end\n\n return sum\nend", "def sum(int)\n int.to_s.chars.map(&:to_i).reduce(:+)\nend", "def string_to_integer(str)\n convert_hash = {\n '0' => 0,\n '1' => 1,\n '2' => 2,\n '3' => 3,\n '4' => 4,\n '5' => 5,\n '6' => 6,\n '7' => 7,\n '8' => 8,\n '9' => 9,\n }\n sum = 0\n value = 0\n str_arr = str.chars\n str_arr.each do |num|\n value = convert_hash[num]\n sum += value * (10 ** (str_arr.length - (str_arr.index(num) + 1)))\n end\n sum\nend", "def add(chars)\n result = chars[0]\n \n for i in 1...chars.length\n result = binaryAdd(result, chars[i])\n end\n \n result\n end", "def string_to_integer(str)\n arr = []\n str.each_char { |char| arr << char if STR_TO_INT.key?(char) }\n\n sum = 0\n arr.reverse.each.with_index do |num, index|\n sum += STR_TO_INT[num] * 10**index\n end\n sum\nend", "def sum(integer)\n sum = integer.to_s.chars.map do |num|\n num.to_i\n end\n\n result = sum.inject(:+)\n result\nend", "def sum(int)\n int.to_s.split(\"\").map(&:to_i).reduce(&:+)\nend", "def sum(number)\n sum = 0\n str_digits = number.to_s.chars\n\n str_digits.each do |str_digit|\n sum += str_digit.to_i\n end\n\n sum\nend", "def sumDigits(number)\n sol = 0\n number.abs.to_s.each_char do |x|\n sol += x.to_i\n end\n print sol\n\nend", "def sumdig_i(num)\n num.to_s.split('').map(&:to_i).reduce(:+)\nend", "def ascii_value(string)\n string.chars.reduce(0) { |result, char| result += char.ord }\nend", "def custom_count(string, char)\ncurrent = 0\nstring.chars do |i|\nif i == char\n current += 1\nend\nend\np current\nend", "def sum(integer)\n digits = integer.to_s.chars.map {|x|x.to_i}\n total = digits.reduce(0) {|sum,x| sum += x}\n #integer.to_s.chars.map(&:to_i).reduce(&:+)\nend", "def sum(num)\n num.to_s.split('').reduce do |sum, num|\n sum.to_i + num.to_i\n end\nend", "def sum_digits\n self.to_s.split('').inject(0) { |memo, c| memo + c.to_i }\n end", "def sumdig_i(n)\n nums = n.to_s.chars.map(&:to_i).inject(:+)\nend", "def calculate\n string.\n each_byte.\n to_a.\n each_with_index.\n map { |byte, index| (index + 1) * byte }.\n reduce(0, :+)\n end", "def sum(number)\n number.to_s.split('').sum { |n| n.to_i }\nend", "def ascii_value(str)\n str.chars.map(&:ord).inject(0, &:+)\nend", "def ascii_value(string)\n ascii_array = string.split('').map(&:ord)\n ascii_array.reduce(0) { |acc, elem| acc + elem }\nend", "def parse (str)\n result = []\n i = 0\n\n str.chars.each { |x|\n case x\n when \"i\"\n i += 1\n when \"d\"\n i -= 1\n when \"s\"\n i = i * i\n when \"o\"\n result.push(i)\n end\n }\n return result\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 solution(s)\n # write your code in Ruby\n a = s.split(',')\nd = 0 \na.each{|b| d = d + b.to_i}\nd\nend", "def sum(int)\n int.to_s.split(//).reduce(0){|sum, item| sum += item.to_i}\nend", "def sum_of_ascii_values(message)\n\treturn message.map{|c| c.to_i}.reduce(:+)\nend", "def string_to_integer(string)\n integer = 0\n idx = 0\n while idx < string.length\n integer = integer * 10\n integer += string[idx].to_i\n idx += 1\n end\n\n integer\nend", "def count(str, char)\n i = 0\n output = 0\n while i < str.length\n if str[i] == char\n output += 1\n end\n i += 1\n end\n return output\nend", "def ascii_value(str)\n val = str.chars.map(&:ord).reduce(:+)\n !val ? 0 : val\nend", "def sum\n local_array = multiply_word_with_letter_multiplier\n local_array.inject(:+)\n end", "def num_decodings(s)\n return 0 if !s || s == '0'\n return 1 if s.size == 1\n dp = [0] * (s.size + 1)\n dp[0] = 1\n dp[1] = s[0] == '0' ? 0 : 1\n\n for i in 2..s.size do \n char = s[i - 1].to_i\n chars = s[(i - 2)..(i - 1)].to_i\n\n if char >= 1 && char <= 9\n dp[i] += dp[i - 1]\n end\n\n if chars >= 10 && chars <= 26\n dp[i] += dp[i - 2]\n end\n end\n\n dp.last\nend", "def sum_of_digits(number)\n sum = 0\n digits = number.to_s\n digits.each_char { |c| sum += c.to_i }\n sum\nend", "def ascii_value(ascii_string)\n string_array = ascii_string.chars\n ascii_value_array = [0]\n\n string_array.each do |char|\n ascii_value_array << char.ord\n end\n\n ascii_value = ascii_value_array.reduce(:+)\nend", "def count_char(string, character)\n i = 0\n output = 0\n while i < string.length\n if character == string[i]\n output += 1\n end\n i += 1\n end\n return output\nend", "def duos(str)\n count = 0\n str.each_char.with_index do |char,idx|\n\n count += 1 if str[idx+1] == char \n\n end\n count\n\nend", "def digit_count(string)\n string = string.split('')\n digit_count = 0\n string.each do |character|\n if 48 <= character.ord && character.ord <= 57\n digit_count += 1 \n end\n end\n digit_count\n end", "def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend", "def countA(string)\n counter = 0\n string.each_char do |char|\n if char == \"a\"\n counter +=1\n end\n end\n return counter\nend", "def atoi(s)\n offset = '0'.ord\n neg = false\n sum = 0\n\n begin\n s.each_byte do |i|\n if i == 45 # the number is negative\n neg = true\n next\n elsif i == 46 # Number is a float, disregard mantissa\n break \n elsif (i < 48 || i > 57) # Not a valid number\n raise InvalidNumberException, \"Error: Invalid Number\"\n end\n\n # Get value of char as int and add to current sum\n tmp = i - offset\n sum = (sum * 10) + tmp\n end \n\n # Make number negative if it was originally negative\n return neg ? -sum : sum\n\n rescue InvalidNumberException => e\n abort(e.message) # inform user about error\n end\nend" ]
[ "0.8613297", "0.83934045", "0.8299811", "0.813995", "0.81080836", "0.80640167", "0.80244374", "0.8006212", "0.79956317", "0.79784065", "0.79538584", "0.79369724", "0.79276717", "0.79276717", "0.78806394", "0.7879771", "0.7860485", "0.7747146", "0.7591318", "0.74320817", "0.74267906", "0.73433334", "0.73132986", "0.73017365", "0.7288921", "0.72206926", "0.72188056", "0.7203707", "0.7180633", "0.7173344", "0.7148697", "0.71448886", "0.71309054", "0.7121367", "0.7073273", "0.7055317", "0.70297414", "0.70167136", "0.70149577", "0.7010633", "0.6995514", "0.69761735", "0.69714046", "0.6944282", "0.691668", "0.6906988", "0.6886278", "0.6873364", "0.68647516", "0.68575203", "0.68530864", "0.68530864", "0.68433195", "0.6838927", "0.68213016", "0.680273", "0.6794085", "0.67865443", "0.6766307", "0.67607415", "0.67607415", "0.6753594", "0.67482877", "0.67394507", "0.6730578", "0.6726792", "0.6723831", "0.6722097", "0.67160076", "0.6714032", "0.6691125", "0.6674603", "0.6669092", "0.664701", "0.66381615", "0.6614962", "0.6602663", "0.65879774", "0.65847707", "0.65669066", "0.65639395", "0.6547476", "0.6546583", "0.65424037", "0.6541982", "0.6538475", "0.65292096", "0.648517", "0.648052", "0.6474783", "0.64534974", "0.64461744", "0.64350826", "0.643163", "0.64113665", "0.64089066", "0.6408825", "0.64013165", "0.63974863", "0.6391437" ]
0.6899766
46
TODO: some private logic
def private? false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def identify; end", "def refutal()\n end", "def suivre; end", "def formation; end", "def implementation; end", "def implementation; end", "def weber; end", "def offences_by; end", "def operations; end", "def operations; end", "def internal; end", "def sitemaps; end", "def verdi; end", "def custom; end", "def custom; end", "def berlioz; end", "def original_result; end", "def processor; end", "def terpene; end", "def anchored; end", "def strategy; end", "def used?; end", "def intensifier; end", "def stderrs; end", "def from; end", "def from; end", "def from; end", "def from; end", "def next() end", "def next() end", "def isolated; end", "def isolated; end", "def reflector; end", "def reflector; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def wrapper; end", "def post_process; end", "def trd; end", "def who_we_are\r\n end", "def villian; end", "def parts; end", "def parts; end", "def parts; end", "def spec; end", "def spec; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def extra; end", "def executor; end", "def executor; end", "def executor; end", "def handle; end", "def next()\n \n end", "def next()\n \n end", "def transformations; end", "def zuruecksetzen()\n end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def init; end", "def init; end", "def init; end", "def init; end", "def operation; end", "def internship_passed; end", "def first; end", "def first; end", "def user_os_complex\r\n end", "def common\n \n end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def loc; end", "def loc; end", "def loc; end", "def transform; end", "def original; end", "def celebration; end", "def process; end", "def process; end" ]
[ "0.7482358", "0.64615995", "0.62793696", "0.62793696", "0.62793696", "0.62793696", "0.6171039", "0.5978112", "0.5900025", "0.58132946", "0.58092445", "0.57382625", "0.57382625", "0.5698134", "0.56953293", "0.5670021", "0.5670021", "0.56016326", "0.55965436", "0.5593278", "0.55923367", "0.55923367", "0.557674", "0.5536951", "0.55310535", "0.5521276", "0.5505801", "0.55000746", "0.5488596", "0.5454251", "0.54528767", "0.5442067", "0.5442067", "0.5442067", "0.5442067", "0.5439159", "0.5439159", "0.5436096", "0.5436096", "0.5434598", "0.5434598", "0.54196566", "0.54196566", "0.54196566", "0.54196566", "0.54196566", "0.54196566", "0.54196566", "0.54196566", "0.54196566", "0.5410061", "0.54033744", "0.53900576", "0.5383152", "0.5375821", "0.5370576", "0.5370576", "0.5370576", "0.535961", "0.535961", "0.53560615", "0.53560615", "0.5355631", "0.5351067", "0.5351067", "0.5351067", "0.53484774", "0.5312544", "0.5312544", "0.5296148", "0.5291004", "0.52898914", "0.52898914", "0.52898914", "0.52898914", "0.52811116", "0.52811116", "0.52811116", "0.52811116", "0.5275316", "0.52740985", "0.527326", "0.527326", "0.52697736", "0.52630305", "0.5243332", "0.5243332", "0.5243332", "0.5243332", "0.5243332", "0.5243332", "0.5243332", "0.5243332", "0.5236443", "0.5236443", "0.5236443", "0.5236031", "0.5226182", "0.5223008", "0.521655", "0.521655" ]
0.0
-1
autofetch coordinates attr_accessible :locations_attributes
def full_street_address return "#{self.street}, #{self.city}, #{self.state}, #{self.zip}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_coordinates!\n fetch_coordinates(true)\n end", "def populate_orig_coordinates\n\t\tself.lat_orig = read_attribute(:lat)\n\t\tself.lon_orig = read_attribute(:lon)\n\tend", "def search_data\n attributes.merge(location: {lat: latitude, lon: longitude})\n end", "def location= attrs\n self.location_attributes= attrs\n end", "def fetch_coordinates(save = false)\n coords = Geocoder.fetch_coordinates(\n send(self.class.geocoder_options[:method_name])\n )\n unless coords.blank?\n method = (save ? \"update\" : \"write\") + \"_attribute\"\n send method, self.class.geocoder_options[:latitude], coords[2][0]\n send method, self.class.geocoder_options[:longitude], coords[2][1]\n end\n coords\n end", "def set_location_coordinates\n address = \"#{self.address.gsub('|', '+')}+\" +\n \", #{self.city}+\" +\n \", #{self.state unless self.state.nil?}+\" +\n \"#{self.country}\"\n address.gsub!(' ', '+')\n GetLocationCoordinatesJob.perform_later(self, address)\n end", "def coordinates=(coordinates)\n self.latitude, self.longitude = coordinates\n end", "def fetch_all(save = false)\n coords = Geocoder.fetch_coordinates(\n send(self.class.geocoder_options[:method_name])\n )\n # Returned 4 data with in 1 array\n unless coords.blank?\n method = (save ? \"update\" : \"write\") + \"_attribute\"\n send method, self.class.geocoder_options[:formatted_address], coords[0]\n send method, self.class.geocoder_options[:geometry], coords[1]\n # send method, self.class.geocoder_options[:location_type], coords[2]\n send method, self.class.geocoder_options[:latitude], coords[2][0]\n send method, self.class.geocoder_options[:longitude], coords[2][1]\n end\n coords\n end", "def update_location\n # Get all empty records\n to_update = Restaurant.where(longitude: [false, nil, 1.0])\n # Update each\n to_update.each do |restaurant|\n restaurant.address\n long_lat = Location.long_lat(restaurant.address)\n Restaurant.where({id: restaurant.id}).update_all({longitude: long_lat[:longitude], latitude: long_lat[:latitude]})\n end\n end", "def load_locations\n\t \t\n\t \tself.locations = []\n\n\t \tsearch_request = Geo::Location.search({\n\t \t\tquery: {\n\t \t\t\tterm: {\n\t \t\t\t\tmodel_id: self.id.to_s\n\t \t\t\t}\n\t \t\t}\n\t \t})\n\n\t \tsearch_request.response.hits.hits.each do |hit|\n\t \t\tlocation = Geo::Location.new(hit[\"_source\"])\n\t \t\tlocation.id = hit[\"_id\"]\n\t \t\tlocation.run_callbacks(:find)\n\t \t\tself.locations << location\n\t \tend\n\t \t\n\tend", "def map_locations # :nologin: :norobots:\n @query = find_or_create_query(:Location)\n if @query.flavor == :all\n @title = :map_locations_global_map.t\n else\n @title = :map_locations_title.t(:locations => @query.title)\n end\n @query = restrict_query_to_box(@query)\n @timer_start = Time.now\n columns = %w(name north south east west).map {|x| \"locations.#{x}\"}\n args = { :select => \"DISTINCT(locations.id), #{columns.join(', ')}\" }\n @locations = @query.select_rows(args).map do |id, name, n,s,e,w|\n MinimalMapLocation.new(id, name, n,s,e,w)\n end\n @num_results = @locations.count\n @timer_end = Time.now\n end", "def mongoize\n {:city=>@city, :state=>@state, :loc=>Point.mongoize(@location)}\n end", "def coordinates\n location = Location.new(location_params)\n if location.save\n render json: location\n else\n render json: \"ERROR\"\n end\n end", "def query\n { :locations => [] }\n end", "def construct_coordinates\n construct_latitude\n construct_longitude\n end", "def mongoize\n\t{:type => 'Point', :coordinates => [@longitude, @latitude]}\nend", "def map_coordinates\n loc = find_or_create_geolocation(params)\n respond_to do |format|\n @geolocation_boxes = GeolocationBox.only_geo_bbox(resource.id)\n @geolocation_box = loc.geolocation_box\n format.js { render template: 'stash_datacite/geolocation_boxes/create.js.erb' }\n end\n end", "def update_location (new_lonlat)\n @survivor.update_attribute(:lonlat, new_lonlat) \n end", "def client_locations\n @entries = @locations\n end", "def build_centroids\n #sql = \"SELECT b.ogc_fid as id, ST_AsGeoJSON(ST_centroid(b.wkb_geometry)) as geo FROM buildings b\"\n sql = \"SELECT b.ogc_fid as id,\n st_x(st_transform(ST_Centroid(b.wkb_geometry),4326)) as lng,\n st_y(st_transform(ST_Centroid(b.wkb_geometry),4326)) as lat\n FROM buildings b;\"\n result_set = ActiveRecord::Base.connection.execute(sql)\n results = {}\n\n result_set.each do |row|\n results[row['id']] = [row['lng'],row['lat']]\n end\n results\n end", "def get_all_locations\n @locations = []\n results = Location.all\n results.each do |loc|\n @locations << loc.to_hash\n end\n end", "def assign_lon_lat_locator_fields\n box = getBoxForCoordinates( view_path_coordinates[\"LonLat\"] )\n self.nw_lon= box[0][0]\n self.nw_lat= box[0][1]\n self.se_lon= box[1][0]\n self.se_lat= box[1][1]\n end", "def mongoize\n\t\treturn {:city=>@city,:state=>@state,:loc=>Point.mongoize(@location)}\n\tend", "def map_observations # :nologin: :norobots:\n @query = find_or_create_query(:Observation)\n @title = :map_locations_title.t(locations: @query.title)\n @query = restrict_query_to_box(@query)\n @timer_start = Time.now\n\n # Get matching observations.\n locations = {}\n columns = %w(id lat long location_id).map { |x| \"observations.#{x}\" }\n args = {\n select: columns.join(\", \"),\n where: \"observations.lat IS NOT NULL OR \" \\\n \"observations.location_id IS NOT NULL\"\n }\n @observations = @query.select_rows(args).map do |id, lat, long, location_id|\n locations[location_id.to_i] = nil unless location_id.blank?\n MinimalMapObservation.new(id, lat, long, location_id)\n end\n\n if locations.length > 0\n # Eager-load corresponding locations.\n @locations = Location.connection.select_rows(%(\n SELECT id, name, north, south, east, west FROM locations\n WHERE id IN (#{locations.keys.sort.map(&:to_s).join(\",\")})\n )).map do |id, name, n, s, e, w|\n locations[id.to_i] = MinimalMapLocation.new(id, name, n, s, e, w)\n end\n @observations.each do |obs|\n obs.location = locations[obs.location_id] if obs.location_id\n end\n end\n @num_results = @observations.count\n @timer_end = Time.now\n end", "def search_data\n slice = [\n :state,\n :city,\n :formatted_address,\n ]\n merge = {\n # https://github.com/ankane/searchkick#geospatial-searches\n location: { lat: latitude, lon: longitude },\n floorplan_bedroom_count: floorplans&.map(&:bedroom_count).uniq.sort,\n floorplan_bathroom_count: floorplans&.map(&:bathroom_count).uniq.sort,\n }\n attributes.symbolize_keys.slice(*slice).merge(merge)\n end", "def locations=(value)\n @locations = value\n end", "def locations=(value)\n @locations = value\n end", "def coordinates\n coordinates = Array.new\n \n coordinates.push self.lat\n coordinates.push self.lng\n \n return coordinates\n end", "def update!(**args)\n @geo_coordinates = args[:geo_coordinates] if args.key?(:geo_coordinates)\n @label = args[:label] if args.key?(:label)\n @location = args[:location] if args.key?(:location)\n end", "def mongoize\n \t\treturn {:city=>@city,:state=>@state,:loc=>Point.mongoize(@location)}\n \tend", "def create\n super\n location = request.location\n @user.latitude = location.latitude\n @user.longitude = location.longitude\n @user.save\n end", "def update\n @location = Location.find(params[:id])\n @location.update_attributes(params[:location])\n @locations = Location.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n end", "def coords; {:x => @x, :y => @y} end", "def update!(**args)\n @box_coordinates = args[:box_coordinates] if args.key?(:box_coordinates)\n @circle_coordinates = args[:circle_coordinates] if args.key?(:circle_coordinates)\n @contained_in_mid = args[:contained_in_mid] if args.key?(:contained_in_mid)\n @location_mid = args[:location_mid] if args.key?(:location_mid)\n @location_mid_label = args[:location_mid_label] if args.key?(:location_mid_label)\n @location_name = args[:location_name] if args.key?(:location_name)\n @location_source = args[:location_source] if args.key?(:location_source)\n @point_coordinates = args[:point_coordinates] if args.key?(:point_coordinates)\n @unformatted_coordinates = args[:unformatted_coordinates] if args.key?(:unformatted_coordinates)\n end", "def from_search\n name = params[:id]\n lat = params[:lat]\n lon = params[:lon]\n @locations = Location.locations_from_candy_ids(Candy.ids_by_name(name))\n if(lat and lon)\n @locations = Location.nearest_five(lat.to_f, lon.to_f, @locations)\n end\n\n respond_to do |format|\n format.html\n format.json { render :json => @locations }\n end\n end", "def index\n @positives = Positive.all\n @positives_json= Positive.all.map(&:lonlat).as_json\n\n\n\n\n\n end", "def locations\n unless defined?(@locations)\n @locations=[]\n for loc in Location.order(\"id ASC\").includes(:bottom_right_coordinate, :top_left_coordinate)\n @locations << loc if do_overlap_with?(loc.area)\n end \n end \n @locations\n end", "def geocode_locations\n coords = Geocoder.coordinates(self.location)\n if coords.nil?\n self.lat = nil\n self.long = nil\n else\n self.lat = coords[0]\n self.long = coords[1]\n end\n end", "def index\n @coords_num = Coordinate.count\n if @coords_num >= 4800\n @latest_coords = Coordinate.order('created_at DESC').limit(10000).reverse\n else\n @latest_coords = Coordinate.all\n end\n @coords = { 'c' => [] }\n @latest_coords.each do |v|\n\n a = []\n colour = v['colour']\n colour[0] = ''\n a << colour\n a << v['x']\n a << v['y']\n @coords['c'] << a\n\n end\n render json: @coords\n end", "def location_params\n params.require(:location).permit(:latitude, :longitude, :address, :description, :title, :user_ids => [])\n end", "def coordinates\n return {latitude: self.latitude, longitude: self.longitude}\n end", "def coordquery(p)\r\nend", "def coordinates\n raw_coords = multivalue_field('coordinates_ssim')\n coords = []\n raw_coords.each do |raw_coord|\n split_coord = raw_coord.split('|')\n coords << { :name => split_coord[0], :lat => split_coord[1], :lon => split_coord[2] }\n end\n coords\n end", "def get_all_locations\n @locations = []\n Location.all.each do |loc|\n @locations << loc.to_hash\n end\n end", "def perform\n add_location\n save\n end", "def add_lat_longt\n users = User.find(:all)\n for user in users\n if !user.city.blank? && !user.country_id.blank?\n address = Country.get_alt_longt(user.city,user.country_id)\n if address != nil\n user.update_attributes(:lat => address.latitude, :longt => address.longitude)\n end\n end\n end \n end", "def reset_coordinates\n self.latitude = nil\n self.longitude = nil\n end", "def coordinates\n @coordinates\n end", "def get_all_locations\n @locations = []\n\n Location.all.each do|loc|\n @locations << loc.to_hash\n end\n end", "def update_location(latitude, longitude)\n self.update_columns(latitude: latitude, longitude: longitude)\n end", "def location\n attributes.fetch(:location)\n end", "def popular_location_params\n params.require(:popular_location).permit(:address, :city, :coords)\n end", "def location_params\n params.require(:location).permit(:longitude, :latitude, :review_id)\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def build_simple_attributes(document)\n simple_attributes.each do |a|\n document.send(\"#{a}=\", geo_concern.send(a.to_s))\n end\n end", "def user_location(user)\n geo = user.geolocation\n geo.latitude = 32.7157\n geo.longitude = -117.1611\n geo.fetch_address\n geo.save\n end", "def update_geo_location\n self.class.update_geo_location(self)\n self.reload\n end", "def fetch_address_and_geometry(save = false)\n coords = Geocoder.fetch_coordinates(\n send(self.class.geocoder_options[:method_name])\n )\n unless coords.blank?\n method = (save ? \"update\" : \"write\") + \"_attribute\"\n send method, self.class.geocoder_options[:formatted_address], coords[0]\n send method, self.class.geocoder_options[:geometry], coords[1]\n end\n coords\n end", "def location_params\n params.require(:location).permit(:target_x, :target_y, :target_z, :finder_id, :name)\n end", "def set_coordinate\n @coordinate = Coordinate.find(params[:id])\n end", "def reset_coordinates\n self.other_latitude = nil\n self.other_longitude = nil\n end", "def location_params\n params.require(:location).permit(:latitude, :longitude, :description,\n :points, :hint1, :hint1_points, :hint2, :hint2_points, :area, :image)\n end", "def location\n b = []\n b << latitude\n b << longitude\n Geocoder.coordinates(b)\n end", "def location_params\n\t\tparams.require(:location).permit(:city, :state, :latitude, :longitude)\n\tend", "def location_params\n params.require(:location).permit(:name, :address, :description, :image_attributes => [:file, :id])\n # TOOD: delete latitude and longitude\n end", "def set_lonlat\n return unless persisted? && latitude.present? && longitude.present?\n\n sql = <<~SQL\nUPDATE stores\nSET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)\nWHERE id = #{id}\n SQL\n ActiveRecord::Base.connection.execute sql\n end", "def at(*coordinates)\n position.coordinates = coordinates\n end", "def get_coordinates\n if self.country_status == 'closed'\n self.latitude = nil\n self.longitude = nil\n else\n q = self.city || ''\n q += ','+self.state if self.state\n q += ','+self.country\n begin\n self.latitude, self.longitude = Geocoder.coordinates(q)\n # We need to make sure that that no 2 projects have exactly the same\n # coordinates. If they do, they will overlap on the flash map and\n # you won't be able to click on one of them.\n while SpProject.where(['latitude = ? and longitude = ?', self.latitude, self.longitude]).first\n delta_longitude, delta_latitude = 0,0\n delta_longitude = rand(6) - 3 while delta_longitude.abs < 2\n delta_latitude = rand(6) - 3 while delta_latitude.abs < 2\n # move it over a little.\n self.longitude += delta_longitude.to_f/10\n self.latitude += delta_latitude.to_f/10\n end\n rescue => e\n Airbrake.notify_or_ignore(e, :parameters => attributes)\n end\n end\n true\n end", "def create\n @locations = Location.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @location = Location.create(params[:location])\n end", "def set_location(lon, lat)\n\t\tfactory = Driver.rgeo_factory_for_column(:location)\n\t\t# update(location: factory.point(lon,lat))\n\t\tself.location = factory.point(lon,lat)\n\tend", "def correct_geo_coords\n coords = params.seek :geo, :geojson, :geometry, :coordinates\n if coords\n array = GeosHelper.geo_coords_to_array(coords)\n params[:geo][:geojson][:geometry][:coordinates] = array\n end\n end", "def set_coord\n @coord = Coord.find(params[:id])\n end", "def update_params_from_loc(loc)\n { :id => loc.id,\n :location => {\n :display_name => loc.display_name,\n :north => loc.north,\n :west => loc.west,\n :east => loc.east,\n :south => loc.south,\n :high => loc.high,\n :low => loc.low,\n :notes => loc.notes\n },\n }\n end", "def load_precise_info\n @coordinates = @location[:coordinates] unless @location[:coordinates].nil?\n return if @location[:formattedAddress].nil?\n @formatted_address = @location[:formattedAddress]\n end", "def search_data\n attributes.merge(\n places_city: places.map(&:city),\n places_country: places.map(&:country),\n places_state: places.map(&:state)\n )\n end", "def edit_batch\n observation_ids = params[:o].is_a?(String) ? params[:o].split(',') : []\n @observations = Observation.where(\"id in (?) AND user_id = ?\", observation_ids, current_user).\n includes(\n :quality_metrics, :observation_field_values, :sounds, :taggings,\n { observation_photos: :photo },\n { taxon: { taxon_photos: :photo } },\n )\n @observations.map do |o|\n if o.coordinates_obscured?\n o.latitude = o.private_latitude\n o.longitude = o.private_longitude\n o.place_guess = o.private_place_guess\n end\n if qm = o.quality_metrics.detect{|qm| qm.user_id == o.user_id}\n o.captive_flag = qm.metric == QualityMetric::WILD && !qm.agree? ? 1 : 0\n else\n o.captive_flag = \"unknown\"\n end\n o\n end\n end", "def coordinates\n [@y_location, @x_location]\n end", "def load_yelp_attributes \n client = Yelp::Client.new\n search = Yelp::V2::Search::Request::Location.new(\n :term => name, \n :city => city,\n :country => nation,\n :category => [\"lounges\"], \n :limit => 1,\n :consumer_key => YelpConfig[\"yelp_config\"][\"consKey\"], \n :consumer_secret => YelpConfig[\"yelp_config\"][\"consSecret\"], \n :token => YelpConfig[\"yelp_config\"][\"token\"], \n :token_secret => YelpConfig[\"yelp_config\"][\"tokenSecret\"])\n response = client.search(search);\n # self.yelp_rating = response['businesses'][0]['rating']\n # self.yelp_review = response['businesses'][0]['snippet_text']\n self.phone_number = response['businesses'][0]['display_phone']\n #cats = response['businesses'][0]['categories']\n self.display_address = response['businesses'][0]['location']['display_address'].join(\"<br/>\")\n self.latitude = response['businesses'][0]['location']['coordinate'][\"latitude\"]\n self.longitude = response['businesses'][0]['location']['coordinate'][\"longitude\"]\n end", "def map_locs\n [location]\n end", "def map_locs\n [location]\n end", "def initialize\n @locations = []\n l00 = Location.new\n l00.coordinates.insert(0, 0, 0)\n l03 = Location.new\n l03.coordinates.insert(0, 0, 3)\n l06 = Location.new\n l06.coordinates.insert(0, 0, 6)\n l11 = Location.new\n l11.coordinates.insert(0, 1, 1)\n l13 = Location.new\n l13.coordinates.insert(0, 1, 3)\n l15 = Location.new\n l15.coordinates.insert(0, 1, 5)\n l22 = Location.new\n l22.coordinates.insert(0, 2, 2)\n l23 = Location.new\n l23.coordinates.insert(0, 2, 3)\n l24 = Location.new\n l24.coordinates.insert(0, 2, 4)\n l30 = Location.new\n l30.coordinates.insert(0, 3, 0)\n l31 = Location.new\n l31.coordinates.insert(0, 3, 1)\n l32 = Location.new\n l32.coordinates.insert(0, 3, 2)\n l34 = Location.new\n l34.coordinates.insert(0, 3, 4)\n l35 = Location.new\n l35.coordinates.insert(0, 3, 5)\n l36 = Location.new\n l36.coordinates.insert(0, 3, 6)\n l42 = Location.new\n l42.coordinates.insert(0, 4, 2)\n l43 = Location.new\n l43.coordinates.insert(0, 4, 3)\n l44 = Location.new\n l44.coordinates.insert(0, 4, 4)\n l51 = Location.new\n l51.coordinates.insert(0, 5, 1)\n l53 = Location.new\n l53.coordinates.insert(0, 5, 3)\n l55 = Location.new\n l55.coordinates.insert(0, 5, 5)\n l60 = Location.new\n l60.coordinates.insert(0, 6, 0)\n l63 = Location.new\n l63.coordinates.insert(0, 6, 3)\n l66 = Location.new\n l66.coordinates.insert(0, 6, 6)\n @locations.push([l00, nil, nil, l03, nil, nil, l06])\n @locations.push([nil, l11, nil, l13, nil, l15, nil])\n @locations.push([nil, nil, l22, l23, l24, nil, nil])\n @locations.push([l30, l31, l32, nil, l34, l35, l36])\n @locations.push([nil, nil, l42, l43, l44, nil, nil])\n @locations.push([nil, l51, nil, l53, nil, l55, nil])\n @locations.push([l60, nil, nil, l63, nil, nil, l66])\n end", "def set_lonlat\n return unless persisted? && latitude.present? && longitude.present?\n\n sql = <<~SQL\n UPDATE stores\n SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)\n WHERE id = #{id}\n SQL\n ActiveRecord::Base.connection.execute sql\n end", "def update_expert_location\n @exp = Expert.find(params[:expert_id])\n #@job = Job.find(params[:job_id])\n if @exp.update_attributes(:latitude => params[:lat], :longitude => params[:lon])\n render :json=> {:success => true, :lat => @exp.latitude, :lon => @exp.longitude}, :status=>200\n else\n render :json=> {:success => false}, :status=>204\n end \n end", "def restrict_fields\n allowed_fields=Location.new.attributes.keys+[\"top_left_coordinate_str\", \"bottom_right_coordinate_str\"]-[\"top_left_coordinate_id\", \"bottom_right_coordinate_id\"]\n @fields=allowed_fields & (params[:fields] || \"\").split(\",\")\n \n if @fields.present?\n @[email protected](@fields) \n else\n @fields=allowed_fields\n end \n\n end", "def build\n objects.each do |@current_object|\n coords = current_object.coordinates\n if coords.is_a?(Array)\n coords = current_object.coordinates = PhoenixCartographer::Coordinates.new(*coords)\n elsif !coords.is_a?(PhoenixCartographer::Coordinates)\n next\n end\n next if coords.empty?\n locations[coords] ||= MapLocation.new(coords)\n locations[coords] << new_marker\n adjust_points\n end\n @built = true\n end", "def location_params\n params.require(:location).permit(:address, :latitude, :longitude, :user_id)\n end", "def locations_within_proximity\n field.locations.where( x_coordinate: x_proximity,\n y_coordinate: y_proximity )\n end", "def locations\n # blank\n end", "def location_params\n params.require(:location).permit(:longitude, :latitude, :altitude, :user_id)\n end", "def initialize(attrs = {})\n attrs = attrs.dup.stringify_keys!\n @lon = attrs['lon'].to_f rescue nil\n @lat = attrs['lat'].to_f rescue nil\n super(attrs)\n end", "def index\n @apartment_geopoints = ApartmentGeopoint.all\n end", "def initialize(params={})\n @id = params[:_id].to_s\n @formatted_address = params[:formatted_address]\n @location = Point.new(params[:geometry][:geolocation])\n @address_components = params[:address_components]\n .map{ |a| AddressComponent.new(a)} unless params[:address_components].nil?\n end", "def location_params\n params.require(:location).permit(:latitude, :longitude, :customid, :title, :building_number)\n end", "def set_coordinate\n @coordinate = Coordinate.find(params[:id])\n end", "def userlocation_params\n params.require(:userlocation).permit(:user_id, :lat, :lon)\n end", "def compute_geometry_in_memory\n sites_with_location = sites.select{|x| x.lat && x.lng}\n min_lat, max_lat, min_lng, max_lng = 90, -90, 180, -180\n sites_with_location.each do |site|\n min_lat = site.lat if site.lat < min_lat\n max_lat = site.lat if site.lat > max_lat\n min_lng = site.lng if site.lng < min_lng\n max_lng = site.lng if site.lng > max_lng\n end\n set_bounding_box min_lat, max_lat, min_lng, max_lng\n end", "def location_params\n params.require(:location).permit(:latitude, :longitude)\n end", "def geography_columns!; end", "def initialize_map\n @locations.set_map\n end" ]
[ "0.6653244", "0.65302724", "0.6476917", "0.62029", "0.6137368", "0.6108511", "0.6107448", "0.60984814", "0.60765374", "0.5998545", "0.5936057", "0.59213346", "0.5855976", "0.5800555", "0.57760185", "0.57533", "0.5731248", "0.5696278", "0.5639646", "0.5636842", "0.56250894", "0.5615707", "0.5613864", "0.5609057", "0.56056637", "0.5599382", "0.5599382", "0.55921674", "0.5579976", "0.5577061", "0.5571289", "0.5568241", "0.5550877", "0.554846", "0.5545052", "0.5540874", "0.5537201", "0.55359375", "0.5530516", "0.552504", "0.5516053", "0.55085945", "0.550227", "0.5499115", "0.54912734", "0.54881644", "0.5486326", "0.5482009", "0.5476712", "0.54766136", "0.54761153", "0.547068", "0.54605395", "0.54560286", "0.54554605", "0.54554605", "0.54519594", "0.5448756", "0.5435913", "0.5431946", "0.5430157", "0.5416431", "0.5403094", "0.53995484", "0.53938246", "0.5382157", "0.53798574", "0.53782153", "0.5366416", "0.5364212", "0.53641236", "0.5359994", "0.5356444", "0.5345336", "0.5344479", "0.5338073", "0.5337085", "0.5330638", "0.5328932", "0.53229994", "0.53194076", "0.53194076", "0.53159404", "0.5315015", "0.53124386", "0.5309831", "0.5305447", "0.5304021", "0.5300063", "0.528719", "0.5286045", "0.5282736", "0.5274454", "0.5272941", "0.52678984", "0.5261238", "0.52564365", "0.5255463", "0.5254784", "0.52466035", "0.5243346" ]
0.0
-1
methods for adding to users clipboard
def pbcopy(input) str = input.to_s IO.popen('pbcopy', 'w') { |f| f << str } str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paste; clipboard_paste; end", "def do_clipboard_paste\n dat = if Wx::PLATFORM == \"WXMAC\" \n # XXX i feel dirty\n `pbpaste`\n else\n dobj=RawDataObject.new\n Wx::Clipboard.open {|clip| clip.fetch dobj}\n dobj.raw_data\n end\n\n self.gui_set_value(self.cur_pos, dat) if dat and dat.size > 0\n end", "def copy_to_clipboard\n end", "def copyFromClipboard \n \"copyFromClipboard\" \n end", "def pbpaste\n Clipboard.paste\nend", "def cmd_clip reference, description = 'TODO description'\n path = reference2path reference\n unless create_if_not_exist reference, path\n return\n end\n puts \"adding clipboard content to \" + reference\n open_vim path, :end_of_file, \n :add_line, \n :add_line, \n :append_desc, description, :add_line,\n :append_date, \n :add_line, \n :add_line, \n :inject_clipboard\n\n end", "def copyToClipboard _args\n \"copyToClipboard _args;\" \n end", "def show\n @clipboard = find_clipboard\n end", "def push_text_in_clipboard(text)\n OpenClipboard.call(0)\n EmptyClipboard.call()\n hmem = GlobalAlloc.call(0x42, text.length)\n mem = GlobalLock.call(hmem)\n Memcpy.call(mem, text, text.length)\n SetClipboardData.call(1, hmem) # Format CF_TEXT = 1\n GlobalFree.call(hmem)\n CloseClipboard.call()\n self\n end", "def clipboard\n IO.popen('pbcopy', 'w') {|f| f << selected_items.map(&:path).join(' ')} if osx?\n end", "def notifyClipboardContentChanged\n updateCommand(Wx::ID_PASTE) do |ioCommand|\n if (@Clipboard_CopyMode == nil)\n # The clipboard has nothing interesting for us\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n # Cancel eventual Copy/Cut pending commands\n notifyCancelCopy\n # Notify everybody\n notifyRegisteredGUIs(:onClipboardContentChanged)\n elsif (@Clipboard_CopyMode == Wx::ID_DELETE)\n # Check that this message is adressed to us for real (if many instances of PBS are running, it is possible that some other instance was cutting things)\n if (@CopiedID == @Clipboard_CopyID)\n # Here we have to take some action:\n # Delete the objects marked as being 'Cut', as we got the acknowledge of pasting it somewhere.\n if (@CopiedMode == Wx::ID_CUT)\n if (!@Clipboard_AlreadyProcessingDelete)\n # Ensure that the loop will not come here again for this item.\n @Clipboard_AlreadyProcessingDelete = true\n executeCommand(Wx::ID_DELETE, {\n :parentWindow => nil,\n :selection => @CopiedSelection,\n :deleteTaggedShortcuts => false,\n :deleteOrphanShortcuts => false\n })\n # Then empty the clipboard.\n Wx::Clipboard.open do |ioClipboard|\n ioClipboard.clear\n end\n # Cancel the Cut pending commands.\n notifyCutPerformed\n notifyRegisteredGUIs(:onClipboardContentChanged)\n @Clipboard_AlreadyProcessingDelete = false\n end\n else\n log_bug 'We have been notified of a clipboard Cut acknowledgement, but no item was marked as to be Cut.'\n end\n end\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n else\n lCopyName = nil\n case @Clipboard_CopyMode\n when Wx::ID_CUT\n lCopyName = 'Move'\n when Wx::ID_COPY\n lCopyName = 'Copy'\n else\n log_bug \"Unsupported copy mode from the clipboard: #{@Clipboard_CopyMode}.\"\n end\n if (@Clipboard_CopyID != @CopiedID)\n # Here, we have another application of PBS that has put data in the clipboard. It is not us anymore.\n notifyCancelCopy\n end\n if (lCopyName != nil)\n # Activate the Paste command with a cool title\n ioCommand[:Enabled] = true\n ioCommand[:Title] = \"Paste #{@Clipboard_SerializedSelection.getDescription} (#{lCopyName})\"\n else\n # Deactivate the Paste command, and explain why\n ioCommand[:Enabled] = false\n ioCommand[:Title] = \"Paste (invalid type #{@Clipboard_CopyMode}) - Bug ?\"\n end\n notifyRegisteredGUIs(:onClipboardContentChanged)\n end\n end\n end", "def pbpaste\n a = IO.popen(\"osascript -e 'the clipboard as unicode text' | tr '\\r' '\\n'\", 'r+').read\n a.strip.force_encoding(\"UTF-8\")\nend", "def paste link\n clipboard = %w{\n /usr/bin/pbcopy\n /usr/bin/xclip\n }.find { |path| File.exist? path }\n\n if clipboard\n IO.popen clipboard, 'w' do |io| io.write link end\n end\n end", "def paste\n\t\t\t$ruvim.insert $ruvim.buffers[:copy].data\n\t\t\t$ruvim.editor.redraw\n\t\tend", "def do_copy\n @editor.value = @current_copycode\n @editor.focus\n end", "def paste\n `pbpaste`\n end", "def cp(string)\n `echo \"#{string} | pbcopy`\n puts 'copied to clipboard'\nend", "def do_clipboard_copy\n return nil unless sel=@selection and dat=@data[sel]\n # XXX i feel dirty\n if Wx::PLATFORM == \"WXMAC\"\n IO.popen(\"pbcopy\", \"w\") {|io| io.write dat}\n stat = $?.success?\n else\n dobj = RawDataObject.new(dat)\n stat = Wx::Clipboard.open {|clip| clip.place dobj}\n end\n return stat\n end", "def paste\n `pbpaste`\nend", "def do_clipboard_cut\n if do_clipboard_copy()\n pos = @selection.first\n self.gui_set_value(nil, '')\n self.cur_pos = pos\n end\n end", "def copy_bbcode\n str = EventPrinter::BBcode::head(@event.printed_name)\n str << (@list.map { |e| e.bbcode }).join(\"\\n\")\n str << EventPrinter::BBcode::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end", "def pbcopy(text)\n # work around, ' wrecks havoc on command line, but also caused some weird regexp substitution\n rtf = text.index('{\\rtf1')\n File.open(\"/tmp/script.scpt\", 'w') do |f|\n if rtf\n f << text\n else\n f << \"set the clipboard to \\\"#{text}\\\"\"\n end\n end\n if rtf\n `cat /tmp/script.scpt | pbcopy -Prefer rtf`\n else\n `osascript /tmp/script.scpt`\n end\nend", "def to_clipboard\n #prettified = self.pretty_inspect.strip\n prettified = self.to_s\n stringified = self.to_s\n printable = (\n if prettified.length > 80 then\n prettified.slice(0, 80) + '...'\n else\n prettified\n end\n ).inspect\n $clipboard.write(stringified)\n $stderr.puts(\"to_clipboard: wrote #{printable} to clipboard\")\n return nil\n end", "def copy(item)\n copy_command = darwin? ? \"pbcopy\" : \"xclip -selection clipboard\"\n\n Kernel.system(\"echo '#{item.value.gsub(\"\\'\",\"\\\\'\")}' | tr -d \\\"\\n\\\" | #{copy_command}\")\n\n \"Boom! We just copied #{item.value} to your clipboard.\"\n end", "def copy(content)\n cmd = case true\n when system(\"type pbcopy > /dev/null 2>&1\")\n :pbcopy\n when system(\"type xclip > /dev/null 2>&1\")\n :xclip\n when system(\"type putclip > /dev/null 2>&1\")\n :putclip\n end\n\n if cmd\n IO.popen(cmd.to_s, 'r+') { |clip| clip.print content }\n end\n\n content\n end", "def copy(content)\n cmd = case true\n when system(\"type pbcopy > /dev/null 2>&1\")\n :pbcopy\n when system(\"type xclip > /dev/null 2>&1\")\n :xclip\n when system(\"type putclip > /dev/null 2>&1\")\n :putclip\n end\n\n if cmd\n IO.popen(cmd.to_s, 'r+') { |clip| clip.print content }\n end\n\n content\n end", "def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend", "def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend", "def paste(str)\n send_command_to_control(\"EditPaste\", str)\n end", "def filecopy(input)\n\tosascript <<-END\n\t\tdelay #{@moreimage}\n\t\tset the clipboard to POSIX file (\"#{input}\")\n\t\ttell application \"Copied\"\n\t\t\tsave clipboard\n\t\tend tell\n\tEND\nend", "def textcopy(input)\n\tosascript <<-END\n\t\ttell application \"Copied\"\n\t\t\tsave \"#{input}\"\n\t\tend tell\n\tEND\nend", "def copy\n\n # FIXME: #copy, #cut and #paste really shouldn't use platform-\n # dependent keypresses like this. But until DSK-327491 is fixed,\n # this will have to do.\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'c']\n else\n keys.send [:control, 'c']\n end\n end", "def copy\n out = ''\n\n Selection.each do |dd|\n docu = dd.cite_key.get\n docu.strip!\n out << \"[@#{docu}] \"\n end\n\n pbcopy(out.strip)\n growl(\"#{Selection.size} citation references copied to the clipboard\")\nend", "def copy(*args) IO.popen('pbcopy', 'r+') { |clipboard| clipboard.puts args.map(&:inspect) }; end", "def pbcopy(str)\n IO.popen('pbcopy', 'r+') {|io| io.puts str }\n output.puts \"-- Copy to clipboard --\\n#{str}\"\nend", "def apps_block_copy_paste=(value)\n @apps_block_copy_paste = value\n end", "def paste\n\n # FIXME\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'v']\n else\n keys.send [:control, 'v']\n end\n end", "def pbcopy(str)\n IO.popen('pbcopy', 'r+') {|io| io.puts str }\n puts \"-- Copy to clipboard --\\n#{str}\"\nend", "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 copy(str = nil)\n clipboard_copy(:string => (!$stdin.tty? ? $stdin.read : str))\n end", "def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end", "def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end", "def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end", "def paste_from_clipboard(page_id, element, method, position)\n element_copy = copy(element, :page_id => page_id)\n element_copy.insert_at(position)\n if method == \"move\" && element_copy.valid?\n element.destroy\n end\n element_copy\n end", "def copy(sender)\n filteredData[tableView.selectedRow].symbol.sendToPasteboard\n end", "def check_clipboard\n value = @clipboard.read\n return unless value\n\n links = @parser.parse(value)\n return if links.empty?\n\n @filter.filter(links) do |link|\n $log.debug(\"adding #{link}\")\n entry = LinkTable::Entry.new(link)\n @link_table.add(entry)\n @resolver_manager.add(entry, link)\n end\n end", "def copy\n self.public_send('|', 'pbcopy')\n self\n end", "def copy_actions\r\n end", "def copy(content)\n case RUBY_PLATFORM\n when /darwin/\n return content if `which pbcopy`.strip == ''\n IO.popen('pbcopy', 'r+') { |clip| clip.print content }\n when /linux/\n return content if `which xclip 2> /dev/null`.strip == ''\n IO.popen('xclip', 'r+') { |clip| clip.print content }\n when /i386-cygwin/\n return content if `which putclip`.strip == ''\n IO.popen('putclip', 'r+') { |clip| clip.print content }\n end\n\n content\n end", "def paste\n # no authorization applied as the method must always render\n if @section.changeable?(current_visitor)\n @original = clipboard_object(params)\n if @original\n @container = params[:container] || 'section_pages_list'\n if @original.class == Page\n @component = @original.duplicate\n else\n @component = @original.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at]\n @component.name = \"copy of #{@original.name}\"\n end\n if (@component)\n # @component.original = @original\n @component.section = @section\n @component.save\n end\n @component.deep_set_user current_visitor\n end\n end\n render :update do |page|\n page.insert_html :bottom, @container, render(:partial => 'page_list_item', :locals => {:page => @component})\n page.sortable :section_pages_list, :handle=> 'sort-handle', :dropOnEmpty => true, :url=> {:action => 'sort_pages', :params => {:section_id => @section.id }}\n page[dom_id_for(@component, :item)].scrollTo()\n page.visual_effect :highlight, dom_id_for(@component, :item)\n end\n end", "def paste(at: caret)\n editable? and @native.paste_text(at.to_i)\n end", "def paste(text)\n can_refresh = false\n # Attempt to insert every character individually\n text.split(\"\").each do |ch|\n break unless @helper.insert(ch)\n can_refresh = true\n end\n # Only refresh if characters were inserted\n self.refresh if can_refresh\n end", "def copy\n \n end", "def paste\n # no authorization applied as the method must always render\n if @activity.changeable?(current_visitor)\n @original = clipboard_object(params)\n if (@original)\n @component = @original.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at], :include => :pages\n if (@component)\n # @component.original = @original\n @container = params[:container] || 'activity_sections_list'\n @component.name = \"copy of #{@component.name}\"\n @component.deep_set_user current_visitor\n @component.activity = @activity\n @component.save\n end\n end\n end\n render :update do |page|\n page.insert_html :bottom, @container, render(:partial => 'section_list_item', :locals => {:section => @component})\n page.sortable :activity_sections_list, :handle=> 'sort-handle', :dropOnEmpty => true, :url=> {:action => 'sort_sections', :params => {:activity_id => @activity.id }}\n page[dom_id_for(@component, :item)].scrollTo()\n page.visual_effect :highlight, dom_id_for(@component, :item)\n end\n end", "def get_clipboard_contents\n out = \"\"\n\n Open3.popen3(\"xclip -o -selection clipboard\") do |_, o, _, _|\n out = o.read.strip\n end\n\n out\n end", "def _cp(obj = Readline::HISTORY.entries[-2], *options)\n if obj.respond_to?(:join) && !options.include?(:a)\n if options.include?(:s)\n obj = obj.map { |element| \":#{element.to_s}\" }\n end\n out = obj.join(\", \")\n elsif obj.respond_to?(:inspect)\n out = obj.is_a?(String) ? obj : obj.inspect\n end\n \n if out\n IO.popen('pbcopy', 'w') { |io| io.write(out) } \n \"copied!\"\n end\nend", "def render_copy(code_str, display_str = nil)\n display_str = code_str if !display_str \n stack :margin_bottom => 12 do \n background rgb(210, 210, 210), :curve => 4\n para display_str, {:size => 9, :margin => 12, :font => 'monospace'}\n stack :top => 0, :right => 2, :width => 70 do\n background \"#8A7\", :margin => [0, 2, 0, 2], :curve => 4 \n para link(\"Copy this\", :stroke => \"#eee\", :underline => \"none\") { self.clipboard = code_str },\n :margin => 4, :align => 'center', :weight => 'bold', :size => 9\n end\n end\n end", "def paste_clipboard\r\n # Only administrators can perform this operation\r\n return render(plain: t('drgcms.not_authorized') ) unless dc_user_can(DcPermission::CAN_ADMIN,'dc_site')\r\n\r\n result = ''\r\n respond_to do |format|\r\n # just open new window to same url and come back with html request\r\n format.html { return render('paste_clipboard', layout: 'cms') }\r\n format.json {\r\n table, id, ids = nil\r\n params[:data].split(\"\\n\").each do |line|\r\n line.chomp!\r\n next if line.size < 5 # empty line. Skip\r\n\r\n begin\r\n if line[0] == '[' # id(s)\r\n result << \"<br>#{line}\"\r\n line = line[/\\[(.*?)\\]/, 1] # just what is between []\r\n table, id, ids = line.split(',')\r\n elsif line[0] == '{' # document data\r\n result << process_document(line, table, id, ids)\r\n end\r\n rescue Exception => e \r\n result << \" Runtime error. #{e.message}\\n\"\r\n break\r\n end\r\n end\r\n }\r\n end\r\n dc_render_ajax(div: 'result', value: result )\r\nend", "def copy_script\n\n end", "def copy_raw\n Win32API.push_text_in_clipboard(((@list.map {|e| e.raw}).join(\"\\n\") + \"\\0\").to_ascii)\n end", "def apps_block_copy_paste\n return @apps_block_copy_paste\n end", "def paste_clipboard\r\n# Only administrators can perform this operation \r\n return render(text: t('drgcms.not_authorized') ) unless dc_user_has_role('admin')\r\n \r\n result = ''\r\n respond_to do |format|\r\n# just open new window to same url and come back with html request \r\n format.html { return render('paste_clipboard', layout: 'cms') }\r\n format.json {\r\n table, id, ids = nil\r\n params[:data].split(\"\\n\").each do |line|\r\n line.chomp!\r\n next if line.size < 5 # empty line. Skip\r\n begin\r\n if line[0] == '[' # id(s)\r\n result << \"<br>#{line}\"\r\n line = line[/\\[(.*?)\\]/, 1] # just what is between []\r\n table, id, ids = line.split(',')\r\n elsif line[0] == '{' # document data\r\n result << process_document(line, table, id, ids)\r\n end\r\n rescue Exception => e \r\n result << \" Runtime error. #{e.message}\\n\"\r\n break\r\n end\r\n end\r\n }\r\n end\r\n dc_render_ajax(div: 'result', value: result )\r\nend", "def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend", "def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend", "def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend", "def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend", "def find_clipboard\n return session[:clipboard] ||= Clipboard.new\n end", "def copy(text)\n IO.popen('pbcopy', 'w') {|f| f << text}\nend", "def do_clip(pagename, titletxt, onlytext = false)\n pagepath = (\"#{Wiki_path}/data/pages/#{clean_pagename(pagename)}.txt\").gsub(\":\",\"/\")\n\n curpage = cururl.split(\"/\").last\n sel = has_selection\n\n # format properly if citation\n unless onlytext\n if curpage.index(\"ref:\")\n curpage = \"[@#{curpage.split(':').last.downcase}]\"\n elsif cururl.index(\"localhost/wiki\")\n curpage = \"[[:#{capitalize_word(curpage.gsub(\"_\", \" \"))}]]\"\n else\n title = (titletxt ? titletxt : curtitle)\n curpage =\"[[#{cururl}|#{title}]]\"\n end\n else\n curpage = ''\n end\n\n insert = (sel ? \"#{sel} \" : \" * \" ) # any text, or just a link (bullet list)\n insert.gsubs!( {:all_with=> \"\\n\\n\"}, \"\\n\", \"\\n\\n\\n\" )\n\n if File.exists?(pagepath)\n prevcont = File.read(pagepath)\n\n haslinks = prevcont.match(/\\-\\-\\-(\\n \\*[^\\n]+?)+?\\Z/m) # a \"---\"\" followed by only lines starting with \" * \"\n\n # bullet lists need an extra blank line after them before the \"----\"\n if sel\n divider = (haslinks ? \"\\n\\n----\\n\" : \"\\n----\\n\")\n else\n divider = (haslinks ? \"\\n\" : \"\\n----\\n\")\n end\n\n growltext = \"Selected text added to #{pagename}\"\n else\n prevcont = \"h1. #{capitalize_word(pagename)}\\n\\n\"\n growltext = \"Selected text added to newly created #{pagename}\"\n end\n filetext = [prevcont, divider, insert, curpage].join\n dwpage(pagename, filetext)\n\n growl(\"Text added\", growltext)\nend", "def copy_html\n str = EventPrinter::HTML::head(@event.printed_name)\n str << (@list.map { |e| e.html }).join\n str << EventPrinter::HTML::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end", "def notifyInit\n registerGUI(Controller::OptionsListener.new(self))\n # Initialize appearance of many components\n notifyUndoUpdate\n notifyRedoUpdate\n notifyClipboardContentChanged\n notifyCurrentOpenedFileUpdate\n @Commands.each do |iCommandID, iCommandParams|\n updateImpactedAppearance(iCommandID)\n end\n # Notify everybody that we are initializing\n notifyRegisteredGUIs(:onInit)\n # Create the Timer monitoring the clipboard\n # This Timer populates the following variables with the clipboard content in real-time:\n # * @Clipboard_CopyMode\n # * @Clipboard_CopyID\n # * @Clipboard_SerializedSelection\n # Note that we are already in the process of a delete event from the clipboard.\n @Clipboard_AlreadyProcessingDelete = false\n safeTimerEvery(@TimersManager, 500) do\n # Check if the clipboard has some data we can paste\n Wx::Clipboard.open do |iClipboard|\n if (iClipboard.supported?(Tools::DataObjectSelection.getDataFormat))\n # OK, this is data we understand.\n # Get some details to display what we can paste\n lClipboardData = Tools::DataObjectSelection.new\n iClipboard.get_data(lClipboardData)\n lCopyMode, lCopyID, lSerializedSelection = lClipboardData.getData\n # Do not change the state if the content has not changed\n if ((lCopyMode != @Clipboard_CopyMode) or\n (lCopyID != @Clipboard_CopyID))\n # Clipboard's content has changed.\n @Clipboard_CopyMode = lCopyMode\n @Clipboard_CopyID = lCopyID\n @Clipboard_SerializedSelection = lSerializedSelection\n notifyClipboardContentChanged\n # Else, nothing to do, clipboard's state has not changed.\n end\n elsif (@Clipboard_CopyMode != nil)\n # Clipboard has nothing interesting anymore.\n @Clipboard_CopyMode = nil\n @Clipboard_CopyID = nil\n @Clipboard_SerializedSelection = nil\n notifyClipboardContentChanged\n # Else, nothing to do, clipboard's state has not changed.\n end\n end\n end\n end", "def apps_block_clipboard_sharing=(value)\n @apps_block_clipboard_sharing = value\n end", "def copied(src_item, item)\n end", "def copy_list \n\n\tend", "def application_guard_block_clipboard_sharing=(value)\n @application_guard_block_clipboard_sharing = value\n end", "def copy\n move(:copy)\n end", "def apps_block_clipboard_sharing\n return @apps_block_clipboard_sharing\n end", "def mark_as_copied(file)\n cmd = cmd(\"setlabel\", [ file, COPIED ])\n system(cmd)\nend", "def clipboard_select_tag(items, html_options = {})\n options = [[_t('Please choose'), \"\"]]\n items.each do |item|\n options << [item.class.to_s == 'Alchemy::Element' ? item.display_name_with_preview_text : item.name, item.id]\n end\n select_tag(\n 'paste_from_clipboard',\n [email protected]_record? && @page.can_have_cells? ? grouped_elements_for_select(items, :id) : options_for_select(options),\n {\n :class => [html_options[:class], 'alchemy_selectbox'].join(' '),\n :style => html_options[:style]\n }\n )\n end", "def copy_clipboard\r\n # Only administrators can perform this operation\r\n return render(plain: t('drgcms.not_authorized') ) unless dc_user_can(DcPermission::CAN_ADMIN,'dc_site')\r\n\r\n respond_to do |format|\r\n # just open new window to same url and come back with html request\r\n format.json { dc_render_ajax(operation: 'window', url: request.url ) }\r\n \r\n format.html do\r\n table = CmsHelper.table_param(params)\r\n doc = dc_find_document(table, params[:id], params[:ids])\r\n text = '<style>body {font-family: monospace;}</style><pre>'\r\n text << \"JSON:<br>[#{table},#{params[:id]},#{params[:ids]}]<br>#{doc.as_document.to_json}<br><br>\"\r\n text << \"YAML:<br>#{doc.as_document.to_hash.to_yaml.gsub(\"\\n\", '<br>')}</pre>\"\r\n render plain: text\r\n end\r\n end \r\nend", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def pbcopy(input)\n str = input.to_s\n IO.popen('pbcopy', 'w') { |f| f << str }\n str\nend", "def puts something\n command = 'pbcopy'\n command << \" -pboard #{@board}\" if @board\n command << \" -Prefer #{@format}\" if @format\n out = IO::popen command, 'w+'\n out.print something\n out.close\n @current = something\n end", "def application_guard_block_clipboard_sharing\n return @application_guard_block_clipboard_sharing\n end", "def copy(segment=selection)\n\t\t\t$ruvim.buffers[:copy].data.replace segment\n\t\tend", "def pbcopy(input)\n str = input.to_s\n IO.popen('pbcopy', 'w') { |f| f << str }\n str\nend", "def copy_bbcode(no_page = 0)\n @pages[no_page].copy_bbcode\n end", "def gets\n @last = @current\n command = 'pbpaste'\n command << \" -pboard #{@board}\" if @board\n @current = %x[#{command}].chomp\n end", "def cp(*args, **kwargs)\n queue CopyCommand, args, kwargs\n end", "def copy\n create_obj(obj.amoeba_dup)\n build_enabled(obj)\n\n #add (copy) suffix to name/title, etc.\n obj.send(obj.class.columns_for_table[0] + '=', obj.send(obj.class.columns_for_table[0]) + I18n.t('backend.copy_suffix'))\n end", "def copy(element)\n puts element.text\nend", "def dialog_copy_editor\n assert_privileges(\"dialog_copy_editor\")\n record_to_copy = find_record_with_rbac(Dialog, checked_or_params)\n @record = Dialog.new\n javascript_redirect(:controller => 'miq_ae_customization',\n :action => 'editor',\n :copy => record_to_copy.id,\n :id => @record.id)\n end", "def notifyCutPerformed\n if (@CopiedSelection != nil)\n notifyRegisteredGUIs(:onCutPerformed, @CopiedSelection)\n @CopiedSelection = nil\n @CopiedMode = nil\n @CopiedID = nil\n end\n end", "def copydaysedit\n end", "def paste\n if @yanked_items\n if current_item.directory?\n FileUtils.cp_r @yanked_items.map(&:path), current_item\n else\n @yanked_items.each do |item|\n if items.include? item\n i = 1\n while i += 1\n new_item = load_item dir: current_dir, name: \"#{item.basename}_#{i}#{item.extname}\", stat: item.stat\n break unless File.exist? new_item.path\n end\n FileUtils.cp_r item, new_item\n else\n FileUtils.cp_r item, current_dir\n end\n end\n end\n ls\n end\n end", "def onCopied(src_item, item)\n @object.copied(import(src_item), import(item));\n end", "def copy_to_desktop(path)\n system(\"cp #{path}/playlist.md ~/Desktop/playlist.md\")\n puts 'Exported playlist to your Desktop!'\n @prompt.keypress('Press any key to return to the previous menu..')\n menu\n end" ]
[ "0.8140096", "0.8104369", "0.78697044", "0.78418976", "0.77520657", "0.71522474", "0.70974034", "0.7069569", "0.70478046", "0.6902639", "0.68902194", "0.68568355", "0.681232", "0.6803679", "0.675421", "0.6701881", "0.6697091", "0.6688792", "0.66147995", "0.65574133", "0.64975184", "0.6487206", "0.6389283", "0.633406", "0.6258317", "0.6258317", "0.625514", "0.625514", "0.62327826", "0.622506", "0.6222376", "0.6222331", "0.62207675", "0.6208989", "0.6204917", "0.61561644", "0.6152331", "0.61124307", "0.604717", "0.60170144", "0.59967244", "0.59967244", "0.59967244", "0.5995805", "0.59924674", "0.59895074", "0.59869003", "0.59752375", "0.5957265", "0.5923077", "0.5900199", "0.5881094", "0.58780116", "0.58573395", "0.58540875", "0.5838801", "0.5786154", "0.5741454", "0.5731566", "0.56905216", "0.5683299", "0.56659037", "0.56328255", "0.56328255", "0.56328255", "0.56328255", "0.56233776", "0.56115824", "0.5604024", "0.55876625", "0.5549765", "0.55207974", "0.5475814", "0.54479057", "0.541146", "0.54056925", "0.5397939", "0.53945917", "0.53541285", "0.5351078", "0.5348364", "0.5348364", "0.5348364", "0.5348364", "0.53134584", "0.53046966", "0.5303108", "0.5287504", "0.5268807", "0.5257729", "0.5254215", "0.5248616", "0.52465135", "0.5245867", "0.5225143", "0.5224664", "0.5215359", "0.5206691", "0.51927316", "0.5192724" ]
0.5217439
96
This action is called on ajax autocomplete call. It checks if user has rights to view data. URL parameters: [table] Table (collection) model name in lower case indicating table which will be searched. [id] Name of id key field that will be returned. Default is '_id' [input] Search data entered in input field. [search] when passed without dot it defines field name on which search will be performed. When passed with dot class_method.method_name is assumed. Method name will be parsed and any class with class method name can be evaluated. Class method must accept input parameter and return array [ [_id, value],.. ] which will be used in autocomplete field. Return: JSON array [label, value, id] of first 20 documents that confirm to query.
def autocomplete # return '' unless session[:edit_mode] > 0 # return render text: t('drgcms.not_authorized') unless dc_user_can(DcPermission::CAN_VIEW) # TODO Double check if previous line works as it should. table = params['table'].classify.constantize id = [params['id']] || '_id' # call method in class if search parameter has . This is for user defined searches # result must be returned as array of [id, search_field_value] a = if params['search'].match(/\./) name, method = params['search'].split('.') table.send(method, params['input']).inject([]) do |r,v| r << { label: v[0], value: v[0], id: v[1].to_s } end # simply search which will search and return field_name defined in params['search'] else table.where(params['search'] => /#{params['input']}/i).limit(20).inject([]) do |r,v| r << { label: v[params['search']], value: v[params['search']], id: v.id.to_s } end end render inline: a.to_json, formats: 'js' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def autocomplete\r\n # table parameter must be defined. If not, get it from search parameter\r\n if params['table'].nil? && params['search'].match(/\\./)\r\n name = params['search'].split('.').first\r\n params['table'] = name.underscore\r\n end\r\n if params['table'].match('_control')\r\n # it must be at least logged on\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW, 'dc_memory')\r\n else\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW)\r\n end\r\n\r\n table = params['table'].classify.constantize\r\n input = params['input'].gsub(/\\(|\\)|\\[|\\]|\\{|\\|\\.|\\,}/, '')\r\n # call method in class if search parameter contains . This is for user defined searches\r\n a = if params['search'].match(/\\./)\r\n #method, additional_params = params['search'].split('.')\r\n #data = additional_params ? table.send(method, input, additional_params, self) : table.send(method, input)\r\n name, method = params['search'].split('.')\r\n data = table.send(method, input)\r\n data.map do |v|\r\n { label: v[0], value: v[0], id: (v[1] || v[0]).to_s }\r\n end\r\n # will search and return field_name defined in params['search']\r\n else\r\n table.where(params['search'] => /#{input}/i).limit(20).map do |v|\r\n { label: v[params['search']], value: v[params['search']], id: v.id.to_s }\r\n end\r\n end\r\n\r\n render json: a\r\nend", "def search\n end", "def search\n\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\nend", "def search\r\nend", "def auto_complete\n @query = params[:auto_complete_query]\n @auto_complete = self.controller_name.classify.constantize.scoped(:limit => 10).search(@query)\n render :template => \"common/auto_complete\", :layout => nil\n end", "def search \n\n end", "def search\n search_param = params[:term]\n matching_keys = UserKey.submitted.search(search_param).collect { |u| { value: \"#{u.name}\", data: u.id } }\n render json: { suggestions: matching_keys }\n end", "def autocomplete\n search_params = params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field)\n (_, @document_list) = search_results(search_params.merge(public: true), search_params_logic)\n\n respond_to do |format|\n format.json do\n render json: { docs: autocomplete_json_response(@document_list) }\n end\n end\n end", "def autocomplete_on\n\t\tconditions = if params[:name]\n [\"name LIKE :name\", { :name => \"%#{params['name']}%\"} ]\n else\n {}\n end\n\t\t @objects = params[:model_name].classify.constantize.find(:all, :conditions => conditions)\n\t\t render :text => '<ul>'+ @objects.map{ |e| '<li>' + e.name + '</li>' }.join(' ')+'</ul>'\n\tend", "def search\n\n end", "def search; end", "def search_for(data)\n # if incoming data is a hash, use it, otherwise, set field directly.\n data.is_a?(Hash) ? populate(data) : self.search_field = data\n self.search\n wait_for_ajax\n end", "def autocomplete(opts={})\n type, request, assoc, query, exclude = opts.values_at(:type, :request, :association, :query, :exclude)\n if assoc\n if exclude && association_type(assoc) == :edit\n ref = model.association_reflection(assoc)\n block = lambda do |ds|\n ds.exclude(S.qualify(ref.associated_class.table_name, ref.right_primary_key)=>model.db.from(ref[:join_table]).where(ref[:left_key]=>exclude).select(ref[:right_key]))\n end\n end\n return associated_model_class(assoc).autocomplete(opts.merge(:type=>:association, :association=>nil), &block)\n end\n opts = autocomplete_options_for(type, request)\n callback_opts = {:type=>type, :request=>request, :query=>query}\n ds = all_dataset_for(type, request)\n ds = opts[:callback].call(ds, callback_opts) if opts[:callback]\n display = opts[:display] || S.qualify(model.table_name, :name)\n display = display.call(callback_opts) if display.respond_to?(:call)\n limit = opts[:limit] || 10\n limit = limit.call(callback_opts) if limit.respond_to?(:call)\n opts[:filter] ||= lambda{|ds1, _| ds1.where(S.ilike(display, \"%#{ds.escape_like(query)}%\"))}\n ds = opts[:filter].call(ds, callback_opts)\n ds = ds.select(S.join([S.qualify(model.table_name, model.primary_key), display], ' - ').as(:v)).\n limit(limit)\n ds = yield ds if block_given?\n ds.map(:v)\n end", "def autocomplete\n\t\tquery_params = QueryFormat.autocomplete_format()\n\t\tbegin\n\t\t\tQueryFormat.transform_raw_parameters(params)\n\t\t\tquery = QueryFormat.create_solr_query(query_params, params, request.remote_ip)\n\t\t\tquery['field'] = \"content_auto\" if query['field'].blank?\n\t\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t\tis_test = :shards if params[:test_index]\n\t\t\tsolr = Solr.factory_create(is_test)\n\t\t\tmax = query['max'].to_i\n\t\t\tquery.delete('max')\n\t\t\twords = solr.auto_complete(query)\n\t\t\twords.sort! { |a,b| b[:count] <=> a[:count] }\n\t\t\twords = words[0..(max-1)]\n\t\t\t@results = words.map { |word|\n\t\t\t\t{ :item => word[:name], :occurrences => word[:count] }\n\t\t\t}\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # index.html.erb\n\t\t\t\tformat.json { render json: { results: @results } }\n\t\t\t\tformat.xml\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\trender_error(e.to_s)\n\t\trescue SolrException => e\n\t\t\trender_error(e.to_s, e.status())\n\t\trescue Exception => e\n\t\t\tExceptionNotifier.notify_exception(e, :env => request.env)\n\t\t\trender_error(\"Something unexpected went wrong.\", :internal_server_error)\n\t\tend\n\tend", "def autocomplete\n @leader = Leaders.find(:all, :conditions => [\"name like ?\",\"%\" + params[:term].upcase + \"%\"])\n render json: @leader \n end", "def autocomplete\n render json: Post.search(params[:query],operator: \"or\", autocomplete: true,limit: 10,boost_by_distance: {field: :location, origin: [current_user.lat, current_user.lon]}).map {|post| {title: post.title, value: post.id}}\n end", "def index\n @users = User.nonadmin.order('users.created_at desc')\n if params[:search].present?\n if params[:search][:name].blank?\n @users = User.nonadmin.order(\"users.id desc\").order('users.created_at desc')\n elsif params[:search][:name].present?\n search_terms = params[:search][:name].split(' ').join('%')\n @users = User.nonadmin.where(\"concat(LOWER(first_name), ' ', LOWER(last_name)) like ?\",\"%#{search_terms}%\").order('users.created_at desc')\n end\n\n if params[:search][:ic].present?\n @users = @users.where(ic_number: params[:search][:ic])\n end\n end\n if params[:filter].present?\n @users = @users.send(params[:filter])\n end\n @klass = Class\n @users = Kaminari.paginate_array(@users).page(params[:page]).per(6)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def autocomplete\n\t\tcond = get_search_conditions(params[:term], {\n\t\t\t'vacancies.exec_approval_no' => :like,\n\t\t\t'vacancies.org_no' => :like,\n\t\t\t'vacancies.cost_center' => :like,\n\t\t\t'vacancies.position_no' => :like,\n\t\t\t'vacancies.position' => :like,\n\t\t\t'vacancies.last_incumbent' => :like\n\t\t})\n\t\tcond << 'vacancies.exec_decision = \"Approved\"'\n\t\tuser_limited = @current_user.agency_level? && !@current_user.allow_vacancy_omb && !@current_user.allow_vacancy_admin\n\t\tagency_id = user_limited && @current_user.agency_id || params[:agency_id]\n\t\tdepartment_id = user_limited && @current_user.department_id || params[:department_id]\n\t\tdivision_id = user_limited && @current_user.division_id || params[:division_id]\n\t\tcond << 'vacancies.agency_id = %d' % agency_id.to_i if !agency_id.blank?\n\t\tcond << 'vacancies.department_id = %d' % department_id.to_i if !department_id.blank?\n\t\tcond << 'vacancies.division_id = %d' % division_id.to_i if !division_id.blank?\n\t\tobjs = @model.find(:all, :include => :vacancy_data, :conditions => get_where(cond), :limit => 10, :order => 'vacancies.id desc').map { |o|\n\t\t\to.autocomplete_json_data\n\t\t}\n\t\trender :json => objs.to_json\n\tend", "def autocomplete\n\t\t\tusers = User.search(params[:keyword]).limit(10)\n\t\t\t\n\t\t\tusers = users.where.not(id: params[:except]) if params[:except].present?\n\n\t\t\trender json: { \n\t\t\t\tstatus: 0,\n\t\t\t\tresult: users.all.map do |user|\n\t\t\t\t\t[user.id, \"#{user.full_name} &lt;#{user.email}&gt;\"]\n\t\t\t\tend.to_h\n\t\t\t}\n\t\tend", "def index\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n @methods = Methods.sorted_order(\"#{sort_column('methods','name')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page], \n :per_page => params[:DataTables_Table_0_length]\n )\n log_searches(Methods)\n else # Allow url queries of data, with scopes, only xml & csv ( & json? )\n @methods = Methods.api_search(params)\n log_searches(Methods.method(: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 => @methods }\n end\n end", "def auto_complete\n @query = params[:term] || ''\n @auto_complete = hook(:auto_complete, self, query: @query, user: current_user)\n if @auto_complete.empty?\n exclude_ids = auto_complete_ids_to_exclude(params[:related])\n @auto_complete = klass.my(current_user).text_search(@query).ransack(id_not_in: exclude_ids).result.limit(10)\n else\n @auto_complete = @auto_complete.last\n end\n\n session[:auto_complete] = controller_name.to_sym\n respond_to do |format|\n format.any(:js, :html) { render partial: 'auto_complete' }\n format.json do\n results = @auto_complete.map do |a|\n {\n id: a.id,\n text: a.respond_to?(:full_name) ? a.full_name : a.name\n }\n end\n render json: {\n results: results\n }\n end\n end\n end", "def autocomplete; end", "def handle_search\n if request.id == 'csv'\n csv(:search_results)\n elsif request.id\n table_page(*model.search_results(normalized_type, request))\n else\n page do\n Forme.form(model.new(nil, request), form_attributes(:action=>url_for(\"search/1\"), :method=>:get), form_opts) do |f|\n model.columns_for(:search_form, request).each do |column|\n col_opts = column_options_for(:search_form, request, f.obj, column).merge(:name=>column, :id=>column)\n if html = model.edit_html_for(f.obj, column, :search_form, request)\n col_opts[:html] = html\n end\n f.input(column, col_opts)\n end\n f.button(:value=>'Search', :class=>'btn btn-primary')\n end\n end\n end\n end", "def search\n @users ||= User.search_user(params[:search])\n authorize! :read, @user\n end", "def render \n# search field name\n if @yaml['search'].to_s.match(/\\./)\n table, field_name, method = @yaml['search'].split(/\\.|\\,/) \n search = method.nil? ? field_name : \"#{field_name}.#{method}\"\n else # search and table name are separated\n search = field_name = @yaml['search']\n end\n# determine table name \n if @yaml['table']\n table = if @yaml['table'].class == String\n @yaml['table']\n# eval(how_to_get_my_table_name) \n elsif @yaml['table']['eval']\n eval @yaml['table']['eval']\n else\n p \"Field #{@yaml['name']}: Invalid table parameter!\"\n nil\n end\n end\n unless (table and search)\n @html << 'Table or search field not defined!' \n return self\n end\n# \n return ro_standard(table, search) if @readonly\n# TODO check if table exists \n collection = table.classify.constantize\n unless @record.respond_to?(@yaml['name'])\n @html << \"Invalid field name: #{@yaml['name']}\" \n return self\n end\n# put field to enter search data on form\n @yaml['html'] ||= {}\n @yaml['html']['value'] = '' # must be. Otherwise it will look into record and return error\n _name = '_' + @yaml['name']\n @html << '<table class=\"ui-autocomplete-table\"><td>'\n @html << @parent.link_to(@parent.fa_icon('plus-square lg', class: 'dc-animate dc-green'), '#',onclick: 'return false;') # dummy add. But it is usefull.\n\n record = record_text_for(@yaml['name']) \n @html << ' ' << @parent.text_field(record, _name, @yaml['html']) # text field for autocomplete\n @html << \"<div id =\\\"#{record}#{@yaml['name']}\\\">\" # div to list active records\n# find value for each field inside categories \n unless @record[@yaml['name']].nil?\n @record[@yaml['name']].each do |element|\n# this is quick and dirty trick. We have model dc_big_table which can be used for retrive \n# more complicated options\n# TODO retrieve choices from big_table\n rec = if table == 'dc_big_table'\n collection.find(@yaml['name'], @parent.session)\n else\n collection.find(element)\n end\n# Related data is missing. It happends.\n @html << if rec\n link = @parent.link_to(@parent.fa_icon('remove lg', class: 'dc-animate dc-red'), '#',\n onclick: \"$('##{rec.id}').hide(); var v = $('##{record}_#{@yaml['name']}_#{rec.id}'); v.val(\\\"-\\\" + v.val());return false;\")\n field = @parent.hidden_field(record, \"#{@yaml['name']}_#{rec.id}\", value: element)\n \"<div id=\\\"#{rec.id}\\\" style=\\\"padding:2px;\\\">#{link} #{rec.send(field_name)}<br>#{field}</div>\"\n else\n '** error **'\n end\n end\n end\n @html << \"</div></td></table>\"\n# Create text for div to be added when new category is selected \n link = @parent.link_to(@parent.fa_icon('remove lg', class: 'dc-animate dc-red'), '#', \n onclick: \"$('#rec_id').hide(); var v = $('##{record}_#{@yaml['name']}_rec_id'); v.val(\\\"-\\\" + v.val());return false;\")\n field = @parent.hidden_field(record, \"#{@yaml['name']}_rec_id\", value: 'rec_id')\n one_div = \"<div id=\\\"rec_id\\\" style=\\\"padding:2px;\\\">#{link} rec_search<br>#{field}</div>\"\n \n# JS stuff \n @js << <<EOJS\n$(document).ready(function() {\n $(\"##{record}_#{_name}\").autocomplete( {\n source: function(request, response) {\n $.ajax({\n url: \"#{ @parent.url_for( controller: 'dc_common', action: 'autocomplete' )}\",\n type: \"POST\",\n dataType: \"json\",\n data: { input: request.term, table: \"#{table}\", search: \"#{search}\" #{(',id: \"'+@yaml['id'] + '\"') if @yaml['id']} },\n success: function(data) {\n response( $.map( data, function(key) {\n return key;\n }));\n }\n });\n },\n change: function (event, ui) { \n var div = '#{one_div}';\n div = div.replace(/rec_id/g, ui.item.id)\n div = div.replace('rec_search', ui.item.value)\n $(\"##{record}#{@yaml['name']}\").append(div);\n $(\"##{record}_#{_name}\").val('');\n },\n minLength: 2\n });\n});\nEOJS\n\n self \nend", "def search_input(method, options)\n basic_input_helper(:search_field, :search, method, options)\n end", "def search\n render json: User.first(10)\n end", "def autocomplete\n render :json => end_of_association_chain.ordered.search(params[:term]).limit(params[:limit] || 10).to_autocomplete\n end", "def autocomplete\n @response, = search_service.search_results do |builder|\n builder.with(builder.blacklight_params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field, public: true, rows: 100))\n end\n\n respond_to do |format|\n format.json do\n render json: { docs: autocomplete_json_response(@response.documents) }\n end\n end\n end", "def execute\n @model_class.search(KEYWORD)\n end", "def search\n @search = Ransack::Search.new(Student)\n end", "def search\n request.write_attributes request_attributes\n @search ||= request.call\n end", "def search_model\n end", "def search_input(method, options)\n basic_input_helper(:search_field, :search, method, options)\n end", "def autosuggest(object, name, options={})\n options[:display] ||= name\n options[:limit] ||= 10\n options[:name] = name\n options[:search_in] ||= [name]\n options[:order] ||= \"#{options[:search_in].first} ASC\"\n\n define_method \"autosuggest_#{object}_#{name}\" do\n options.merge!(:query => params[:query], :object => object.to_s.camelize.constantize)\n query = ''\n values = []\n\n for column in options[:search_in]\n query += \"#{column} ILIKE ? OR \"\n values.push(\"#{options[:query]}%\")\n end\n results = options[:object].where(query[0..-4], *values).order(options[:order]).limit(options[:limit])\n render :json => Yajl::Encoder.encode(results.map{|r| {:name => r.send(options[:display]), :value => r.id.to_s}})\n end\n end", "def ajax_auto_complete\n type = params[:type].to_s\n instr = params[:id].to_s\n letter = ' '\n scientific = false\n user = login_for_ajax\n if user\n scientific = (user.location_format == :scientific)\n end\n @items = []\n if instr.match(/^(\\w)/)\n letter = $1\n case type\n\n when 'location'\n @items = Observation.connection.select_values(%(\n SELECT DISTINCT `where` FROM observations\n WHERE `where` LIKE '#{letter}%' OR\n `where` LIKE '% #{letter}%'\n )) + Location.connection.select_values(%(\n SELECT DISTINCT `name` FROM locations\n WHERE `name` LIKE '#{letter}%' OR\n `name` LIKE '% #{letter}%'\n ))\n if scientific\n @items.map! {|i| Location.reverse_name(i)}\n end\n @items.sort!\n\n when 'name'\n @items = Name.connection.select_values %(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{letter}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )\n\n when 'name2'\n @items = Name.connection.select_values(%(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{instr}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )).sort_by {|x| (x.match(' ') ? 'b' : 'a') + x}\n # This sort puts genera and higher on top, everything else on bottom,\n # and sorts alphabetically within each group.\n letter = ''\n\n when 'project'\n @items = Project.connection.select_values %(\n SELECT title FROM projects\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'species_list'\n @items = SpeciesList.connection.select_values %(\n SELECT title FROM species_lists\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'user'\n @items = User.connection.select_values %(\n SELECT CONCAT(users.login, IF(users.name = \"\", \"\", CONCAT(\" <\", users.name, \">\")))\n FROM users\n WHERE login LIKE '#{letter}%'\n OR name LIKE '#{letter}%'\n OR name LIKE '% #{letter}%'\n ORDER BY login ASC\n )\n end\n end\n\n # Result is the letter requested followed by results, one per line. (It\n # truncates any results that have newlines in them -- that's an error.)\n render(:layout => false, :inline => letter +\n %(<%= @items.uniq.map {|n| h(n.gsub(/[\\r\\n].*/,'')) + \"\\n\"}.join('') %>))\n end", "def search\n\t authorize! :search, Book\n\n\t query = params[:search] || \"\"\n page = params[:page] ? params[:page].to_i : 1\n \n @conditions = Condition.all\n\t @result = Book.search(query, page)\n @result = Book.calculate_hidden(@result, session[:user_id])\n\n\tend", "def search\n return @search\n end", "def suggest\n if !params.has_key? :q then\n head :ok\n return\n end\n\n search_stmt = params[:q].upcase\n current_user_id = current_user.id\n\n results = UrContact.where.has{\n (user_id == current_user_id) &\n (upper(name).like \"%#{search_stmt}%\") |\n (upper(email).like \"%#{search_stmt}%\") |\n (upper(telephone).like \"%#{search_stmt}%\")\n }\n\n if params[:format] == \"search\" then\n formattedResults = results\n else\n formattedResults = {query:params[:q], suggestions:results.map{|x| {value:x.name, data:x}} }\n end\n\n #render json: {query:params[:q], suggestions:results}\n render json: formattedResults\n end", "def search\n\t\tif params[:term]\n\t\t\tto_match = '%' + params[:term] + '%'\n\t\t\t@users = User.where(\"(name ILIKE :search OR surname ILIKE :search OR nickname ILIKE :search) AND id != :current_id\", search: to_match, current_id: current_user.id)\n\t\telse\n\t\t\t@users = User.all\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json {render :json => @users.to_json}\n\t\tend\n\tend", "def autocomplete_sn\n render :partial => 'autocomplete', :object => Scientificname.find(:all, :conditions => ['name ILIKE ?', params[:sn] + '%' ])\n end", "def getAutocomplete(query, type)\n request('getAutocomplete', {'query' => query, 'type' => type})\nend", "def auto_complete\n type = params[:type].to_s\n string = CGI.unescape(params[:id].to_s).strip_squeeze\n if string.blank?\n render(text: \"\\n\\n\")\n else\n auto = AutoComplete.subclass(type).new(string, params)\n results = auto.matching_strings.join(\"\\n\") + \"\\n\"\n render(text: results)\n end\n end", "def search_account\n data=params\n search_result =[]\n unless data[:q].blank?\n search_result = @company.accounts.search data[:q], :star => true, :limit => 10000\n else\n search_result = @company.accounts.all(:order => 'name ASC')\n end\n render :partial=> 'account_auto_complete', :locals => {:search_result => search_result}\n end", "def autocomplete\n \n @credits = Credit.select([:id, :department, :credit]).where(\"credit ILIKE ? \", \"%#{params[:filter]}%\" ).limit(params[:limit])\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @credits }\n format.js\n format.json { render :json => @credits }\n end\n\n\n end", "def call\n if @search.blank?\n patients = Patient.limit(28)\n elsif @search.present?\n patients = Patient.search(@search)\n else\n end\n end", "def autocomplete\n @design_methods = DesignMethod.where(['name LIKE ?', \"#{params[:term]}%\"])\n @design_hash = []\n @design_methods.each do |d|\n @design_hash << { label: d.name }\n end\n respond_to do |format|\n format.json { render json: @design_hash}\n end\n end", "def autocomplete_clase_nombre \n respond_to do |format|\n @clases = Clase.joins(:partida_parcial => [:partida_principal]).where(\"clases.fecha_de_baja IS NULL AND clases.nombre ILIKE ?\", \"%#{params[:term]}%\").order(\"partidas_principales.codigo\").order(\"partidas_parciales.codigo\").order(\"clases.codigo\").paginate(:page => params[:page], :per_page => 30) \n render :json => @clases.map { |clase| {:id => clase.id, :label => clase.nombre, :value => clase.nombre} } \n format.js { } \n end \n end", "def typeahead\n # :searcher param expected to be name of a searcher with underscores, ie: ematrix_journal\n searcher = params[:searcher]\n query = params[:q] or ''\n total = params[:total] or 3\n\n if searcher.blank?\n logger.error \"Typeahead request: no searcher param provided\"\n head :bad_request\n return nil\n end\n\n searcher_string = \"QuickSearch::#{searcher.camelize}Searcher\"\n\n begin \n klass = searcher_string.constantize\n rescue NameError\n logger.error \"Typeahead request: searcher #{searcher} does not exist\"\n head :bad_request\n return nil\n end\n\n if klass.method_defined? :typeahead\n typeahead_result = klass.new(HTTPClient.new, query, total).typeahead\n\n if params.has_key? 'callback'\n render json: typeahead_result, callback: params['callback']\n else\n render json: typeahead_result\n end\n else\n logger.error \"Typeahead request: searcher #{searcher} has no typeahead method\"\n head :bad_request\n return nil\n end\n end", "def search_prof\n # Search for email or name of professor\n term = \"%#{params[:term]}%\"\n @users = User.all(:conditions => [\"(LOWER(first_name) LIKE LOWER(?) OR LOWER(last_name) LIKE LOWER(?) OR LOWER(email) LIKE LOWER(?)) AND role = ?\", term, term, term, \"Professor\"])\n\n # Return a JSON with \"label\" and \"value\" as key required by JQUeryUI autocomplete\n result = Array.new\n @users.each do |user| \n label = user.first_name + \" \" + user.last_name + \" - \" + user.email\n item = Hash[ \"label\" => label, \"value\" => user.email ]\n result.push item\n end\n\n render :json => result\n end", "def causeautocomplete\n searchtext = params['searchText']\n\n if session[:roleid] == ADMIN_ROLE\n # this will do a like search ignoring case\n @searchcauseresults = Charity.where(\"charityname ILIKE ?\", \"%\" + searchtext + \"%\")\n \n else\n \n # this will do a like search ignoring case\n @searchcauseresults = Charity.where(\"charityname ILIKE ?\", \"%\" + searchtext + \"%\")\n .where(isapproved: true)\n \n end\n\n \n\n #if @searchcauseresults.count == 0\n # @searchcauseresults = Charity.new\n #end\n \n render :json => @searchcauseresults\n\n end", "def suggestion_search\n keywords = params[:q]\n keywords = Utils.nomalize_string(keywords)\n\n if keywords.include? '-'\n keywords = keywords.gsub! '-', \" \"\n end\n\n pattern = /#{Regexp.escape(keywords)}/i\n\n users = User.or({:name => pattern}, {:email => pattern}).map { |user|\n UserSerializer.new(user).suggestion_search_hash\n }\n\n render json: users, root: false\n return\n end", "def fetch_search\n @search = Question.find_by_id(params[:id])\n end", "def search\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n @data = search_term(sname)\n render partial: \"shared/search\"\n end", "def search(query); end", "def Search query\n \n APICall(path: \"search.json?query=#{query}\",method: 'GET')\n \n end", "def auto_complete_for(object, association, method, options={}) #:nodoc:\n conditions = \"\"\n conditions = \" AND \"+options[:and_conditions].to_s unless options[:and_conditions].nil?\n options.delete(:and_conditions)\n if object.to_s.camelize.constantize.reflections[association].class_name.constantize.columns_hash[\"company_id\"].nil?\n define_method(\"auto_complete_belongs_to_for_#{object}_#{association}_#{method}\") do\n find_options = {\n :conditions => [\"LOWER(#{method}) LIKE ? #{conditions}\", '%' + params[association][method].downcase + '%'],\n :order => \"#{method} ASC\",\n :limit => 10\n }.merge!(options)\n klass = object.to_s.camelize.constantize.reflect_on_association(association).options[:class_name].constantize\n @items = klass.find(:all, find_options)\n render :inline => \"<%= model_auto_complete_result @items, '#{method}' %>\"\n end\n else\n define_method(\"auto_complete_belongs_to_for_#{object}_#{association}_#{method}\") do\n find_options = {\n :conditions => [\"LOWER(#{method}) LIKE ? AND company_id=? #{conditions}\", '%' + params[association][method].downcase + '%', @current_company_id],\n :order => \"#{method} ASC\",\n :limit => 10\n }.merge!(options)\n klass = object.to_s.camelize.constantize.reflect_on_association(association).options[:class_name].constantize\n @items = klass.find(:all, find_options)\n render :inline => \"<%= model_auto_complete_result @items, '#{method}' %>\"\n end\n end\n end", "def typeahead\n input = params[:input]\n users = User.all\n valid_users = []\n users.each do |user|\n valid_users.push(\"#{user.firstName} #{user.lastName}\") if user.firstName.include?(input) || user.lastName.include?(input) || user.email.include?(input)\n end\n render json: valid_users, status: :ok\n end", "def show\n \tif params[:id].nil?\n \t\t# search all\n \telse\n \t\t# search specific id\n \t\t@id = params[:id]\n\t\tend\n end", "def auto_complete_for_ces\r\n value = params[:term]\r\n field = %w(collectors locality mthd verbatim_method macro_habitat micro_habitat).include?(params[:field]) && params[:field]\r\n\r\n if field && value\r\n @ids = Ce.select(field.downcase).where([ \"ces.proj_id = ? AND LOWER(ces.#{field.downcase}) LIKE (?)\", params[:proj_id], '%' + value.downcase + '%' ])\r\n .group(field.downcase).order(\"#{field.downcase} ASC\").limit(100).map {|v| v.send(field.downcase.to_sym)}\r\n\r\n render :json => Json::simple_autocomplete(@ids)\r\n elsif value\r\n @ces = Ce.find_for_auto_complete(value)\r\n render :json => Json::format_for_autocomplete_with_display_name(:entries => @ces, :method => params[:method])\r\n else\r\n head(:bad_request)\r\n end\r\n end", "def index \n # set the default value for the clear button \n params[:clear] = \"\" unless params[:clear]\n params[:sort] = \"last_name_asc\" unless params[:sort]\n #params[:filter] = {} unless params[:filter]\n \n # save the model names for use by the views (filter & sort)\n @plural_model_name = 'users'\n @model_name = 'user'\n @act_restful = true\n \n # sanatize the display param.\n params[:display] = sanitize_display(params[:display])\n\n # sanatize the sort params\n @sort_col, @sort_dir, model_name, @orig_col_name = sanitize_sort(params[:sort], '', @plural_model_name)\n \n # sanatize the filter params\n params[:filter] = nil if params[:clear].downcase == \"clear\" # if the user clicked on the 'clear' toss the filter params to the bit bucket.\n conditions = HashWithIndifferentAccess.new\n conditions.merge!(logged_in? ? {:is_active => 1} : {:show_personal_info => 1, :is_active => 1}) # the built in filter.\n conditions = params[:filter].merge!(conditions) if params[:filter]\n \n @filter = sanitize_filter(conditions)\n \n # create the params for the find method\n find_params = {:per_page => params[:display].to_i}\n \n # we need to remove the single quotes so the order works with included tables.\n # because rails alises all of the columns to generated names i.e. t0_r0, t0_r1\n find_params.merge!({:order => ActiveRecord::Base.send(:sanitize_sql, [\" #{model_name}.? #{@sort_dir}\", @sort_col]).delete(\"'\")}) if @sort_col\n find_params.merge!({:conditions => @filter}) if @filter\n find_params.merge!({:include => :discipline })\n\n # do the search\n @user_pages, @user_data = paginate :users, find_params\n \n # take care of rendeing if the user wants us to.\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @user_data.to_xml }\n format.text { render :text => data_text(false) }\n format.csv { render :text => data_text }\n end \n end", "def scaffold_auto_complete_for(klass, association=nil)\n meth = \"scaffold_auto_complete_for_#{klass.scaffold_name}\"\n (self.scaffolded_auto_complete_associations[klass] ||= Set.new).add(association.to_s)\n allowed_associations = scaffolded_auto_complete_associations[klass]\n unless instance_methods.include?(meth)\n scaffold_define_method(meth) do\n association = scaffold_request_param(:association).to_s\n if scaffold_request_param(:association) && !allowed_associations.include?(association)\n scaffold_method_not_allowed\n else\n @items = klass.scaffold_auto_complete_find(scaffold_request_id.to_s, :association=>(association.to_sym if scaffold_request_param(:association)), :session=>scaffold_session)\n scaffold_render_template(meth, {}, :inline => \"<%= scaffold_auto_complete_result(@items) %>\")\n end\n end\n end\n end", "def get_search\n\t\t\t@search = Search.find(params[:id])\n\t\tend", "def search\n book = Book.new(params)\n render json: book.search\n end", "def search_field(object_name, method, options = T.unsafe(nil)); end", "def index\n=begin\n search_inputs = params[:search_inputs]\n klass = class_for(search_inputs[:model]) || Person\n search_term = search_inputs[:search_term] || \"\"\n institutions = search_inputs[:institutions] || \"\"\n tag_list = search_inputs[:tag_list] || \"\"\n\n @records = Search.new(model: klass, search_term: search_term, tag_list: tag_list, institutions: institutions, page: params[:page]).search\n @search_inputs = params[:search_inputs]\n=end\n\n #@people = Person.all.order(:name).page(params[:page]).per(20)\n #@people = Person.all.limit(25)\n #@people = Person.all\n #@people = Person.all.order(:name).page(params[:page])\n if params[:search_inputs].present?\n @search_inputs = OpenStruct.new(params[:search_inputs])\n else\n @search_inputs = OpenStruct.new(model: \"Person\")\n end\n @records = Search.new(@search_inputs).search\n @records = @records.page(params[:page]).per(20)\n\n respond_to do |format|\n format.html\n format.js { render :file => \"/people/search_people.js.erb\" }\n end\n end", "def fetchControllerForTableView(tableView)\n Cliente.searchController(@searchString, withScope:nil) \n end", "def search\n\n if params[:query].present?\n\n @result = search_book(params[:query])\n\n\n render :partial => 'searchresult' , :layout => false #,:content_type => :json\n\n end\n\n end", "def index\n @animals = Animal.search(params[:term])\n # @tasks = Task.search(params[:term])\n # @my_input = params['my_input']\n end", "def search_foods type = \"html\"\n # Prepare the pagination with 10 per page\n page = params[:p].blank? || params[:p].to_i < 1 ? 1 : params[:p].to_i\n per_page = params[:per_page] || 10\n per_page = per_page.to_i\n\n # Search the wider database with a preference for the user's saved and liked foods\n\n # Break the search into its parts and search for each term\n if type == \"json\"\n query = params[:q].squish\n # Cache this request\n results = Rails.cache.fetch(\"json-food-search-\" + query + \"-p-\" + page.to_s, :expires_in => 15.minutes) do\n Food.autocomplete_foods(query)\n .limit(per_page + 1)\n .offset((page - 1) * per_page)\n .includes(:measurements)\n end\n else\n query = params[:q].squish\n results = Food.search_foods(query)\n .limit(per_page + 1) # We do +1 here because if, at the end, we have per_page + 1 entries, we know there's a next page\n .offset((page - 1) * per_page)\n .includes(:measurements)\n end\n\n @searchresults = results.each { |x| x.data_source = \"local\" }\n\n # Matches? Show the search form\n # Prepare simple pagination\n @prev_page = page > 1 ? (page - 1).to_s : nil\n @next_page = @searchresults.size > per_page ? (page + 1).to_s : nil\n @base_url = food_search_path + \"?q=\" + URI.encode(params[:q])\n # Pop the end off the results array so we can stick to per_page items per page\n @searchresults.try(:pop)\n end", "def search(params)\n raise NotImplementedError\n end", "def search?\n unless /GET|HEAD/ =~ request_method\n return false\n end\n \n if id? \n false\n else\n true\n end\n end", "def search\n @listings = Listing.where(id: params[:id])\n @listings = Listing.search(params[:search])\n end", "def auto_search\n\t\t@city=ActiveRecord::Base.connection.execute(\"select c.id, c.name,co.name from City c, Country co where c.name like '%\"+params[:search]+\"%' and c.countrycode=co.code\")\n\t\trender :json =>@city\n\t\treturn\n\t\tend", "def search_results(type, request, opts={})\n params = request.params\n ds = apply_associated_eager(:search, request, all_dataset_for(type, request))\n columns_for(:search_form, request).each do |c|\n if (v = params[c.to_s]) && !(v = v.to_s).empty?\n if association?(c)\n ref = model.association_reflection(c)\n ads = ref.associated_dataset\n if model_class = associated_model_class(c)\n ads = model_class.apply_filter(:association, request, ads)\n end\n primary_key = S.qualify(ref.associated_class.table_name, ref.primary_key)\n ds = ds.where(S.qualify(model.table_name, ref[:key])=>ads.where(primary_key=>v).select(primary_key))\n elsif column_type(c) == :string\n ds = ds.where(S.ilike(S.qualify(model.table_name, c), \"%#{ds.escape_like(v)}%\"))\n else\n begin\n typecasted_value = model.db.typecast_value(column_type(c), v)\n rescue S::InvalidValue\n ds = ds.where(false)\n break\n else\n ds = ds.where(S.qualify(model.table_name, c)=>typecasted_value)\n end\n end\n end\n end\n paginate(type, request, ds, opts)\n end", "def auto_complete_for_club_member_login\n\n # split by spaces, downcase and create query for each.\n # Remember to Sanitize the SQL\n conditions = params[:club_member][:login].downcase.split.map {\n\t\t # Sanitize ***********************************\n\t\t |w| \"LOWER(login) LIKE '%\" + (w.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")) +\"%'\" } # AND the queries.\n\n # AND the queries.\n find_options = {\n :conditions => conditions.join(\" AND \"),\n :order => \"login ASC\",\n :limit => AC_CLUB_MEMBER_NAME_LIMIT }\n\n @items = ClubMember.find(:all, find_options)\n\n render :inline => \"<%= auto_complete_result_2 @items %>\"\n end", "def index\n\t\t# Creation of the search object and search do\n if params[:filter]\n params[:by] = \"#{params[:filter][:field]}-#{params[:filter][:way]}\"\n params[:per_page] = \"#{params[:filter][:limit]}\".to_i\n end\n\t\t@search = Search.new(setting_searching_params(:from_params => params))#.advance_search_fields\n\t\t@paginated_objects = @current_objects = @search.do_search\n\t\t# Definition of the template to use to retrieve information\n\t\tif @search.category == 'user' || @search.category == 'workspace'\n\t\t\t@templatee = \"#{@search.category.pluralize}/index\"\n\t\telse\n \t@templatee = \"generic_for_items/index\"\n\t\tend\n\t\t@ajax_url = request.path\n\t\t# Management of the response depending of the request type\n\t\tif !request.xhr?\n\t\t\trespond_to do |format|\n\t \t\t\tformat.html { render :template => \"admin/searches/index.html.erb\" }\n\t\t\t\tformat.xml { render :xml => @paginated_objects }\n\t\t\t\tformat.json { render :json => @paginated_objects }\n\t\t\t\tformat.atom { render :template => \"#{@templatee}.atom.builder\", :layout => false }\n\t\t\tend\n\t\telse\n @no_div = true\n\t\t\trender :partial => @templatee, :layout => false\n\t\tend\n end", "def index\n if request.xhr?\n @data = InstructorInfo.search(params)\n sort_by = params[:sort_by]\n order_by = params[:order_by]\n\n if sort_by == 'price'\n @results = @data.order(\"min_price #{order_by}\")\n else\n arr=[]\n @results = []\n @data.each do |obj|\n arr << [obj.id, obj.user_info.user.get_rating]\n end\n sorted_arr = arr.sort {|a,b| a[1] <=> b[1]}\n sorted_arr = sorted_arr.reverse if order_by == 'desc'\n sorted_arr.each{|obj| @results << InstructorInfo.find(obj[0]) }\n end\n else\n if params[:service].present? || params[:specialization].present?\n @results = InstructorInfo.search(params)\n @service = params[:service] #pass in service to view, and ajax will be able to send back for order-by\n @specialization = params[:specialization] #pass in specialization to view, and ajax will be able to send back for order-by\n else\n @results = InstructorInfo.limit(20)\n end\n end\n end", "def search\n render json: Consultation.first(10)\n end", "def perform_search\n if self.class == Alchemy::Admin::PagesController && params[:query].blank?\n params[:query] = 'lorem'\n end\n return if params[:query].blank?\n @search_results = search_results\n if paginate_per\n @search_results = @search_results.page(params[:page]).per(paginate_per)\n end\n end", "def index\n #search method will search model based on the params\n respond_to do |format|\n format.html {}\n format.json {\n @users = User.search_get_json(@current_page, @rows_per_page,params)\n render json: @users\n }\n end\n end", "def result\n case params[:search_type]\n when \"purchaseorders\"\n @class = PurchaseOrder\n @name = \"Purchase Orders\"\n when \"keys\"\n @class = Key\n @name = \"Key Codes\"\n when \"endusers\"\n @class = EndUser\n @name = \"End Users\"\n when \"purchasers\"\n @class = Purchaser\n @name = \"Purchasers\"\n end\n \n @css_class = params[:search_type]\n @search = @class.search(params[:q])\n @list = @search.result\n\n respond_to do |format|\n format.js\n end\n end", "def searchauthor\n end", "def search_load\n @search = current_user.saved_page_infos.find(params[:id]).load(@sssn).model\n draw_search_form\n end", "def index\n if params.has_key?(:search) && params[:search].strip != \"\" #for rental search across site\n @books = Book.search(params[:search], :match_mode => :any, :star => true, :page => params[:page], :per_page => 10)\n if (@books.count == 0)\n @books = nil\n end\n\n elsif params[:category] #for category search\n @book_ids = BookCategory.where('category_id = ?', params[:category]).pluck(:book_id)\n if (@book_ids)\n @books = Book.where(:id => @book_ids).paginate(:page => params[:page], :per_page => 10)\n if (UserBook.find_by_book_id(@book_ids) == nil)\n @books = nil\n end\n else\n @books = nil\n #flash[:alert] = \"We didn't find any book in this category :(\" #not showing up\n end\n \n #elsif params[:value] #for autosuggest on search bar\n # @books = Book.search(params[:value], :match_mode => :any, :star => true)\n \n else \n @books = Book.where(:id => [1..191]).paginate(:page => params[:page], :per_page => 10) #paginate(:page => params[:page], :per_page => 1) #(limit: 10)\n flash.now[:alert] = \"Please type in something to search. Some recent listings have been shown. Also, we just opened up the listing feature :)\"\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n\n end", "def index \n unless(params[:search==nil]) \n @requests = Request.search(params[:search]) \n end \n end", "def search\n @members = Member.search_by params[:category], params[:keywords], params[:is_active]\n\n render :template => '/api/members/index'\n end", "def search\n @utils = UtilsController.new\n query_params = @utils.construct_like_search_query(params[:patient])\n json_response(Patient.search(query_params));\n end", "def search_results\n @results = User.search(params[:search])\n end" ]
[ "0.74884635", "0.5927023", "0.5922668", "0.59110004", "0.59110004", "0.59110004", "0.59110004", "0.59110004", "0.59110004", "0.59110004", "0.59110004", "0.59110004", "0.59110004", "0.5908016", "0.5892678", "0.5855081", "0.583393", "0.57894963", "0.5746241", "0.57433057", "0.57378733", "0.5737812", "0.56845057", "0.5654256", "0.56322455", "0.55904573", "0.5570869", "0.5568837", "0.5548464", "0.55433226", "0.55427575", "0.5524936", "0.54894084", "0.54836464", "0.54702663", "0.5468625", "0.5465209", "0.54611415", "0.54535", "0.54524636", "0.54324657", "0.5406814", "0.5401253", "0.53974545", "0.5395653", "0.53842735", "0.5377385", "0.53771347", "0.53523284", "0.53509957", "0.53471714", "0.53461975", "0.53460735", "0.5344705", "0.5341969", "0.53324324", "0.5329929", "0.52987266", "0.52975214", "0.52968395", "0.52959144", "0.5294481", "0.52916056", "0.5290495", "0.52809536", "0.52747834", "0.5271757", "0.52653223", "0.52536803", "0.52482146", "0.5247469", "0.5246116", "0.52315515", "0.5223857", "0.5212309", "0.52118593", "0.5199204", "0.51729167", "0.51643455", "0.51612395", "0.5151676", "0.5150832", "0.5149232", "0.5148272", "0.5145447", "0.513452", "0.5130506", "0.51292866", "0.5127923", "0.5122204", "0.5121953", "0.5117727", "0.5114959", "0.5113148", "0.51110893", "0.5109498", "0.5106342", "0.5105414", "0.51015097", "0.50985" ]
0.7519833
0
Register and record click when ad link is clicked.
def ad_click if (ad = DcAd.find(params[:id])) ad.clicked += 1 ad.save DcAdStat.create!(dc_ad_id: params[:id], ip: request.ip, type: 2 ) else logger.error "ERROR ADS: Invalid ad id=#{params[:id]} ip=#{request.ip}." end render :nothing => true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def click(link); end", "def ga_ad_click(advertiser, ad_name, link)\n adv = advertiser.blank? ? \"\" : advertiser\n adv_name = ad_name.blank? ? \"\" : ad_name\n #adv_link = link.blank? ? \"\" : link\n category = adv + \" - Ad Data\"\n action = adv_name + \" - Clicks\"\n\n adv_link = request.url\n result = \"_gaq.push(['_trackEvent', '\" + category + \"', '\" + action + \"', '\" + adv_link +\"']);\"\n\n # Tell rails not to escape output.\n result.html_safe\n end", "def click_on_alink(link_id)\r\n\r\n link_using_id = get_link_using_id(link_id)\r\n\r\n link_using_id.click\r\n\r\n # With logout button, it is noted that click on it doesn't cause the\r\n # 'onclick' event to be automatically fired, so having to explicitly fire the event\r\n link_using_id.fire_event('onclick')\r\n\r\n sleep(1)\r\n\r\n end", "def click_add_advertiser_contact_link\n add_advertiser_contact_link.click\n end", "def click_add_agency_link\n add_agency_link.click\n end", "def click_on_event option\n visits event_path(option.event)\n clicks_link option.description\n end", "def regclick\n @ad = Ad.find(params[:id])\n curr_count = @ad.click_count || 0\n @ad.click_count = curr_count + 1\n @ad.save\n redirect_to params[:url]\n end", "def clicks_post_link(link_text)\n clicks_link_with_method(link_text, :post)\n end", "def click_on_link(selector)\n\n click_link(selector)\n\n end", "def clicks_post_link(link_text)\n link = find_link(link_text)\n link.click(:post)\n end", "def clicks_link(link_text)\n link = links.detect { |el| el.innerHTML =~ /#{link_text}/i }\n return flunk(\"No link with text #{link_text.inspect} was found\") if link.nil?\n \n onclick = link.attributes[\"onclick\"]\n href = link.attributes[\"href\"]\n \n http_method = http_method_from_js(onclick)\n authenticity_token = authenticity_token_value(onclick)\n \n request_page(http_method, href, authenticity_token.blank? ? {} : {\"authenticity_token\" => authenticity_token})\n end", "def click_act_as_link\n act_as_link.click\n sleep(10)\n end", "def ad_click\r\n if params[:id] and (ad = DcAd.find(params[:id]))\r\n ad.clicked += 1\r\n ad.save\r\n DcAdStat.create!(dc_ad_id: params[:id], ip: request.ip, type: 2 ) \r\n else\r\n logger.error \"ERROR ADS: Invalid ad id=#{params[:id]} ip=#{request.ip}.\"\r\n end\r\n\r\n render body: nil\r\nend", "def on_click\n\t\tend", "def click_add_agency_contact_link\n add_agency_contact_link.click\n end", "def after_click(clicker)\n end", "def show\n @link.clicks.create(ip_address: request.remote_ip)\n redirect_to @link.full_url\n end", "def click(page, doc)\n js = doc[\"href\"] || doc[\"onclick\"]\n if js =~ /javascript:__doPostBack\\('(.*)','(.*)'\\)/\n event_target = $1\n event_argument = $2\n form = page.form_with(id: \"aspnetForm\")\n form[\"__EVENTTARGET\"] = event_target\n form[\"__EVENTARGUMENT\"] = event_argument\n form.submit\n elsif js =~ /return false;__doPostBack\\('(.*)','(.*)'\\)/\n nil\n else\n # TODO Just follow the link likes it's a normal link\n raise\n end\nend", "def link_account_click\n link_account_button.click\n end", "def click_fin_aid_details_link\n logger.debug 'Clicking link to FinAid Details'\n details_link\n activity_heading_element.when_visible WebDriverUtils.page_load_timeout\n end", "def on_click(&block)\n click_handlers << block\n self\n end", "def click; end", "def click; end", "def click; end", "def click link\n case link\n when Page::Link then\n referer = link.page || current_page()\n if @agent.robots\n if (referer.is_a?(Page) and referer.parser.nofollow?) or\n link.rel?('nofollow') then\n raise RobotsDisallowedError.new(link.href)\n end\n end\n if link.noreferrer?\n href = @agent.resolve(link.href, link.page || current_page)\n referer = Page.new\n else\n href = link.href\n end\n get href, [], referer\n when String, Regexp then\n if real_link = page.link_with(:text => link)\n click real_link\n else\n button = nil\n # Note that this will not work if we have since navigated to a different page.\n # Should rather make each button aware of its parent form.\n form = page.forms.find do |f|\n button = f.button_with(:value => link)\n button.is_a? Form::Submit\n end\n submit form, button if form\n end\n when Form::Submit, Form::ImageButton then\n # Note that this will not work if we have since navigated to a different page.\n # Should rather make each button aware of its parent form.\n form = page.forms.find do |f|\n f.buttons.include?(link)\n end\n submit form, link if form\n else\n referer = current_page()\n href = link.respond_to?(:href) ? link.href :\n (link['href'] || link['src'])\n get href, [], referer\n end\n end", "def on_add(clicker)\n end", "def show\n @link = Link.find_by(token: params[:token])\n @link.times_visited = @link.times_visited + 1\n @link.save\n Click.create(link: @link) # for reporting on most popular\n redirect_to @link.original_url\n end", "def link!\n self.linkbutton = true\n self.save\n self.linkbutton\n end", "def click(locator, opts = {}, &block)\n actions << lambda {\n path = find_link(locator, opts)[:href] rescue nil\n raise SpiderCore::ClickPathNotFound, \"#{locator} not found\" if path.nil?\n if block_given?\n spider = self.spawn\n spider.entrance(path)\n spider.learn(&block)\n current_location[:click] ||= []\n current_location[:click] << spider.crawl[:results]\n else\n visit(path)\n end\n }\n end", "def click_through\n if ClickEvent.create!(hash_params)\n logger.info \"Databse Entry created\"\n else\n logger.error \"\\n\\nError on #{Date.today}:\"\\\n \"\\n\\tIp Address: #{request.ip}\"\\\n \"\\n\\Access Path: #{request.path}\"\\\n \"\\n\\tBrowser Type: #{request.user_agent}\"\n end\n redirect_to @decoded[:redirect]\n end", "def clicks_get_link(link_text)\n clicks_link_with_method(link_text, :get)\n end", "def track_click\n with_monitoring do\n Faraday.post(url_with_params, '')\n end\n rescue => e\n e\n end", "def click_selenium_test1\n @session.click_link(@link_text)\n end", "def click_link(string)\n name_link(string).click\n wait_for_ajax\n end", "def clicks(link, opts={})\n opts.merge!(:access_token => @access_token.token, :link => link)\n result = self.class.get(\"/link/clicks\", :query => opts)\n if result['status_code'] == 200\n if opts[:rollup].nil? || opts[:rollup]\n # Have total clicks so just return total\n result['data']['link_clicks']\n else\n # Have an array of reults so process\n result['data']['link_clicks'].map { |lc| {:time => Time.at(lc['dt']), :clicks => lc['clicks']}}\n end\n else\n raise BitlyError.new(result['status_txt'], result['status_code'])\n end\n \n end", "def click!\n Dogo.redis.incr(click_key)\n end", "def click!\n Dogo.redis.incr(click_key)\n end", "def on_click &b\n on :click, &b\n end", "def clicks_link(link_text, options = {})\n link = find_link(link_text)\n link.click(nil, options)\n end", "def trigger_click_link(selector)\n find_link(selector).trigger(\"click\")\n end", "def show\n @short_url = ShortUrl.where(:shortcode => params[:id]).first\n @link = Link.find(@short_url.link_id)\n @click = Click.new(:ip => request.remote_ip, :referer => request.referer, :clickdate => Time.now).save!\n redirect_to @link.fullurl, :status => 301\n end", "def click_add_salesperson_link\n add_salesperson_link.click\n end", "def click(&block)\n @clicks << block\n end", "def clickable\n @clickable ||= %i[a link button]\n end", "def clicks_get_link(link_text)\n link = find_link(link_text)\n link.click(:get)\n end", "def clicks_put_link(link_text)\n clicks_link_with_method(link_text, :put)\n end", "def link(link_text)\n element(damballa(link_text+\"_link\")) { |b| b.link(:text=>link_text) }\n action(damballa(link_text)) { |b| b.link(:text=>link_text).click }\n end", "def click_link_within(wrapper, link)\n within(wrapper) do\n find(:link, link).click\n end\n end", "def on_click(elem)\n elem.fire_event('onClick')\n end", "def follow(link_text)\n Praline::browser.find_element(:link, link_text).click\n end", "def clicks_put_link(link_text)\n link = find_link(link_text)\n link.click(:put)\n end", "def click_reports_link\n wait_for_page_and_click reports_link\n end", "def link_click(ele)\n ref=$array[\"#{ele}\"]\n path=ele.split(\"_\").last\n $log.info \"verifying the #{ele} present or not \"\n if $browser.link(:\"#{path}\", \"#{ref}\").exists?\n $log.info \"#{ele} is prsented on the webpage\"\n $browser.link(:\"#{path}\", \"#{ref}\").click\n $log.info \"clicked the #{ele} link\"\n\n elsif $browser.span(:\"#{path}\", \"#{ref}\").exists?\n $log.info \"{ele} is presented on the webpage\"\n $browser..span(:\"#{path}\", \"#{ref}\").click\n $log.info \"clicked the #{ele}\"\n else\n $log.info \"failed to find the #{ele} link\"\n raise(\"failed to find the #{ele} link\") \n end\n \n \nend", "def link_to_identifier; end", "def link_to_identifier; end", "def dClick\n doubleClick(waitForObject(@symbolicName))\n Log.AppendLog(@@logCmd.dClick(self))\n end", "def advert(driver)\n raise Error.new(ARGUMENT_UNDEFINE, :values => {:variable => \"driver\"}) if driver.nil?\n link = nil\n links = []\n count_try = 0\n adverts = []\n begin\n DOMAINS.each { |domain|\n frame = driver.domain(domain)\n\n if frame.domain_exist?\n adverts += frame.link(\"/.*googleads.g.doubleclick.net.*/\").collect_similar\n adverts += frame.link(\"/.*googleadservices.*/\").collect_similar\n adverts.each{|a| @@logger.an_event.debug \"advert : #{a.text}\"}\n links += adverts\n else\n @@logger.an_event.debug \"frame with domain <#{domain}> not exist\"\n end\n=begin\n adverts.map! { |f|\n href = f.fetch(\"href\")\n frame.link(href) unless /.*googleads.g.doubleclick.net.*/.match(href).nil?\n }.compact!\n=end\n }\n raise \"no advert link found\" if links.empty?\n\n rescue Exception => e\n @@logger.an_event.warn \"#{e.message}, try #{count_try}\"\n sleep 5\n count_try += 1\n retry if count_try < 3\n @@logger.an_event.error e.message\n raise Error.new(NONE_ADVERT, :error => e)\n\n else\n @@logger.an_event.info \"count advert #{self.class.name} links : #{links.size}\"\n link = links.sample\n @@logger.an_event.debug \"advert link chosen #{link}\"\n\n end\n\n link\n\n end", "def click_link(link_text, options = {})\n find_link(link_text).click(options)\n end", "def click\n @mech.click self\n end", "def queue_link( tag, source )\n return if tag.attributes['class'] && tag.attributes['class']['thickbox'] == 'thickbox'\n return if tag.attributes['onclick']\n dest = (tag.attributes['onclick'] =~ /^new Ajax.Updater\\(['\"].*?['\"], ['\"](.*?)['\"]/i) ? $1 : tag.attributes['href']\n if !(dest =~ %r{^(mailto:|#|javascript:|http://|.*\\.jpg|aim:|ichat:|xmpp:)})\n @links_to_visit << Link.new( dest, source )\n end\n end", "def show\n if @link\n @link.clicked!(:referrer => request.referrer)\n redirect_to @link.url\n else\n render text: \"No such link.\", status: 404\n end\n end", "def click_add_line_items_link\n add_line_items_link.click\n end", "def js_click\n href = node.attributes['onclick'].to_s.match(/location.href='(.*)'/)[1]\n full_uri = URI::HTTP.build({scheme: page.uri.scheme, host: page.uri.host, path: href})\n mech.get(full_uri)\n end", "def trackClick(selector, *args)\n raise 'Not enough arguments' if args.empty?\n raise 'Too many arguments' if args.size > 2\n\n queue << ['trackClick', selector, *args]\n end", "def clicked;end", "def show\n if params[:short]\n @link = Link.find_by(short: params[:short])\n if redirect_to @link.source_url\n @link.clicks += 1\n @link.save\n end\n else\n @link = Link.find(params[:id])\n end\n end", "def click_batch_link\n wait_for_page_and_click batch_link\n end", "def clicked!\n self.click_count += 1\n self.save\n end", "def click(ip_address)\n # Add the clicks\n clicks.new(ip: ip_address)\n # Increments the number of clicks\n self.number_of_click += 1\n save\n end", "def onDoubleClick _obj, _args\n \"_obj onDoubleClick _args;\" \n end", "def clickable\n @clickable ||= [:a, :link, :button]\n end", "def onLButtonDoubleClick(flags, x, y, view)\n end", "def click_web_link(text)\n\t\[email protected](\"Clicking web link #{text}\")\n\t\t\n\t\t@main_window.click(text)\n\tend", "def link_self; end", "def click\n raise \"Must implement custom click method.\"\n end", "def link *a; app.link *a end", "def navigate_to_link(link_name)\n find_link(link_name).click\n end", "def test_link\n authenticated_client.link test_link_full_name\nend", "def clicked(e)\n \n end", "def click_add_dialect_link(link_name)\n find(:xpath, \"//div[@id='dialect-list-content']//a[text()='#{link_name}']\").click\n end", "def click_link(link_text, link_index: nil)\n if link_index\n Element.new(\"Clicking #{link_text} Link (#{link_index})\", :xpath, \"(//a[contains(., \\\"#{link_text}\\\")])[#{link_index}]\").click\n else\n Element.new(\"Clicking #{link_text} Link\", :xpath, \"//a[contains(., \\\"#{link_text}\\\")]\").click\n end\n end", "def clicks_delete_link(link_text)\n clicks_link_with_method(link_text, :delete)\n end", "def click_link_with_href(href)\n find(:xpath, \"//a[@href='#{href}']\").click\n wait_for_turbolinks\n end", "def flag_link_dom_id(object)\n dom_id(object, :flag_link)\n end", "def select_link (linktext)\n\t\t@link = @browser.link :text => linktext\n\t\[email protected]\n\tend", "def add_this(text, url)\n link_to text, \"http://www.addthis.com/bookmark.php\", :onmouseover => \"return addthis_open(this, '', '#{url}', '');\", :onmouseout => \"addthis_close();\", :onclick => \"return addthis_sendto();\"\n end", "def buy_gift_card_link_button\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(a.className(\"ats-buyagiftcardlnk\"), __method__, self)\n end", "def mark_link game, ref\n\t$links[ref] << game\nend", "def get_da_detail_page(page, da_container)\n\n tds = da_container.search('td')\n\n href = tds[0].at('a')['href']\n\n detail_page = page.link_with(:href => \"#{href}\").click\n\n \n\n return detail_page\n\nend", "def get_da_detail_page(page, da_container)\n\n tds = da_container.search('td')\n\n href = tds[0].at('a')['href']\n\n detail_page = page.link_with(:href => \"#{href}\").click\n\n \n\n return detail_page\n\nend", "def link\n \"/events/#{id}\"\n end", "def register_click(blk)\n if blk.nil?\n blk = if @style[:click].respond_to? :call\n @style[:click]\n else\n # Slightly awkward, but we need App, not InternalApp, to call visit\n proc { app.app.visit @style[:click] }\n end\n end\n\n click(&blk)\n end", "def add_advertiser_contact_link\n self.get_element(@browser, '//a[contains(@href, \"/insertion_orders_persons_advertisers/create?insertion_orders.id=\")]')\n end", "def click_engagement_index_link(driver)\n driver.switch_to.default_content\n WebDriverUtils.wait_for_element_and_click engagement_index_link_element\n current_url\n end", "def show\n @link = Link.find_by_short_name(params[:short_name])\n\n if @link\n @link.clicked!\n redirect_to @link.url\n else\n render text: 'No such link.', status: 404\n end\n end", "def navigating_link(name, link_text, class_name=nil)\n define_method(name) { \n self.link(:text=>/#{Regexp.escape(link_text)}/).click\n sleep 2 # wait_for_ajax keeps throwing unknown JS errors in Selenium-webdriver\n unless class_name==nil\n eval(class_name).new @browser\n end\n }\n end", "def initialize(**args)\n # trace __FILE__, __LINE__, self, __method__, \"(#{args})\"\n @on_click = (args[:on] || {})[:click]\n href = args[:href]\n if href && href != '#'\n @args = args.merge( on: { click: method(:handle_click) } )\n @args[:key] = href\n check_active(href)\n else\n @args = args\n end\n end", "def click_url\n @hash[\"ClickUrl\"]\n end", "def click\n { 'ts' => self['ts'], 'url' => self['url'] } if self['ts'] && self['url']\n end", "def register_clickable(clickable, absorb_click=nil)\n @clickables << clickable\n @absorb_list << clickable if absorb_click || (clickable.respond_to?(:absorb_click?) && clickable.absorb_click?)\n @clickables.sort! do |a, b|\n next 1 unless a&.respond_to?(:z)\n next -1 unless b&.respond_to?(:z)\n\n b.z <=> a.z\n end\n clickable\n end" ]
[ "0.74522126", "0.67892927", "0.6601028", "0.6556179", "0.6340476", "0.6272195", "0.625987", "0.62356323", "0.6069521", "0.6012836", "0.6007723", "0.5996763", "0.598204", "0.5975354", "0.5946643", "0.5946271", "0.5930583", "0.5930029", "0.5912502", "0.5867862", "0.5839945", "0.58244354", "0.58244354", "0.58244354", "0.5819282", "0.5813936", "0.5812539", "0.5810327", "0.57940376", "0.5788374", "0.5778987", "0.5747254", "0.57196134", "0.5707285", "0.57015353", "0.5658243", "0.5658243", "0.56571966", "0.5619644", "0.56165725", "0.5599477", "0.55869734", "0.5569425", "0.5564151", "0.5562789", "0.55193144", "0.5510023", "0.5487289", "0.5480612", "0.546967", "0.54635626", "0.54515153", "0.54454446", "0.5423127", "0.5423127", "0.5420247", "0.5405515", "0.5389002", "0.53878874", "0.53722566", "0.53510064", "0.53243667", "0.5316382", "0.52903014", "0.52509063", "0.52412814", "0.52410084", "0.5239382", "0.5222766", "0.5221504", "0.5218764", "0.52107626", "0.52094626", "0.5204701", "0.5193098", "0.5191274", "0.5185887", "0.5185383", "0.5160864", "0.51566654", "0.51459634", "0.5138265", "0.5135195", "0.5132278", "0.5123806", "0.5114207", "0.5112667", "0.5097378", "0.50943846", "0.50943846", "0.5093402", "0.5090895", "0.50865245", "0.5080096", "0.50578696", "0.5056084", "0.5052431", "0.50470906", "0.50456166", "0.5039948" ]
0.5801601
28
Toggle CMS edit mode.This action is called when user clicks CMS option on top of the browser.
def toggle_edit_mode session[:edit_mode] ||= 0 # called without logged in if session[:edit_mode] < 1 dc_render_404 else session[:edit_mode] = (session[:edit_mode] == 1) ? 2 : 1 redirect_to params[:return_to] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toggle_editmode\n\t\t@editmode = true\n\t\t$screen.write_message(\"Edit mode\")\n\tend", "def toggle_edit_mode\r\n session[:edit_mode] ||= 0 \r\n # error when not logged in\r\n return dc_render_404 if session[:edit_mode] < 1\r\n\r\n # if return_to_ypos parameter is present it will forward it and thus scroll to\r\n # aproximate position it was when toggle was clicked\r\n session[:edit_mode] = (session[:edit_mode] == 1) ? 2 : 1\r\n uri = Rack::Utils.parse_nested_query(request.url)\r\n # it parses only on & so first (return_to) parameter also contains url\r\n url = uri.first.last\r\n if (i = url.index('return_to_ypos')).to_i > 0\r\n url = url[0, i-1]\r\n end \r\n # offset CMS menu\r\n if (ypos = uri['return_to_ypos'].to_i) > 0\r\n ypos += session[:edit_mode] == 2 ? 250 : -250\r\n end\r\n url << (url.match(/\\?/) ? '&' : '?')\r\n url << \"return_to_ypos=#{ypos}\"\r\n redirect_to(url, allow_other_host: true)\r\nend", "def editing?\n @mode == :edit\n end", "def edit\n\t\t# must have admin access or be in the course\n\tend", "def is_editing_page?\n params[:controller] == 'management/cms' && params[:action] == 'edit_page_content'\n end", "def toggle_content_type\n @blog = Blog.find(params[:blog_id])\n @blog.change_content_type\n respond_to do |format|\n format.html {render :edit}\n end\n end", "def edit\n @comment = Comment.find(params[:id])\n switch_to_admin_layout\n end", "def edit?\n false\n end", "def edit\n\t\t@page_name = \" - Edit Show\"\n\tend", "def smart_edit(content_type=0,save_url)\n if content_type == 1\n render \"shared/wysihtml5_js\", {url: save_url}\n else\n render \"shared/autosave_js\", {url: save_url}\n end\n end", "def edit\r\n end", "def edit\n #Nothing necessary\n end", "def visit_edit_page(model, **opt, &block)\n action = opt[:id] ? :edit : :edit_select\n visit_action_page(model, action, **opt, &block)\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit?\n show?\n end", "def edit\r\n \r\n end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit\n\t\t\n\tend", "def edit\n \n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end" ]
[ "0.7615129", "0.7475761", "0.6415849", "0.63457733", "0.6326886", "0.6284163", "0.62730086", "0.62044823", "0.61972916", "0.6189394", "0.61700845", "0.61543614", "0.6149204", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61425793", "0.61327606", "0.61165667", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.6098581", "0.60899526", "0.6082681", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232", "0.6069232" ]
0.63565624
3
Default user login action.
def process_login # Somebody is probably playing return dc_render_404 unless ( params[:record] and params[:record][:username] and params[:record][:password] ) unless params[:record][:password].blank? #password must not be empty user = DcUser.find_by(username: params[:record][:username]) if user and user.authenticate(params[:record][:password]) fill_login_data(user, params[:record][:remember_me].to_i == 1) return redirect_to params[:return_to] || '/' end end flash[:error] = t('drgcms.invalid_username') redirect_to params[:return_to_error] || '/' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n\t\tif @current_user != nil\n\t\t\tredirect_to user_path(@current_user.id)\n\t\tend\n\tend", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def default_login\n login(\"[email protected]\",\"codetheoryio\")\n end", "def action_login!()\n @action = TAC_PLUS_AUTHEN_LOGIN\n\n end", "def login\n\n end", "def login\n\n end", "def login\n\tend", "def login; end", "def login\n @user = User.find_or_create_from_auth_hash(auth_hash)\n @user_name = @user.display_name\n\n session[:current_user_id] = @user.id\n\n render :login, :layout => false\n end", "def displayLoginPage()\n\t# User Name: \n\t# Password:\n\t# Forgot Password?\tNew User?\n\treturn\nend", "def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end", "def login\n # show LOGIN form\n\n end", "def login\n @user = User.find_by nickname: params[:nickname]\n if @user\n if (@user.is_password?(params[:password]))\n session[:id] = @user.id\n redirect_to url_for(:controller => :users, :action => :show, id: @user.id)\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid password.\"\n end\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid username.\"\n end\n end", "def login\r\n if request.get?\r\n # Logout user\r\n self.logged_in_user = nil\r\n else\r\n # Authenticate user\r\n user = User.try_to_login(params[:login], params[:password])\r\n if user\r\n self.logged_in_user = user\r\n # user.update_attribute(:ip_last, request.remote_ip)\r\n journal(\"log_in\",user.id)\r\n # generate a key and set cookie if autologin\r\n if params[:autologin] && Setting.autologin?\r\n token = Token.create(:user => user, :action => 'autologin')\r\n cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }\r\n end\r\n puts \"aqui\"\r\n if user.show? \r\n puts \"1\"\r\n redirect_back_or_default :controller => 'my', :action => 'athletes'\r\n else \r\n puts \"2\" \r\n redirect_back_or_default :controller => 'my', :action => 'page'\r\n end\r\n else\r\n # if user.locked?\r\n # flash.now[:notice] = l(:status_locked)\r\n # else\r\n flash.now[:notice] = l(:notice_account_invalid_creditentials)\r\n # end\r\n journal(\"invalid-\"+params[:login]+\"-\"+params[:password],0)\r\n end\r\n end\r\n end", "def login\n @user = User.authenticate(params[:username], params[:user_password])\n if @user\n session[:user] = @user\n flash['notice'] = \"Login successful\"\n redirect_back_or_default :controller => 'schedule', :action => \"index\"\n else\n if !params[:username].blank? or !params[:user_password].blank? \n flash.now['notice'] = \"Login unsuccessful\"\n end\n @login = params[:username]\n end\n end", "def login(user=:joerg)\r\n login_as(user)\r\n end", "def login\n render :layout => 'login_user'\n end", "def loginpage\n end", "def login\n make_login_call\n end", "def login\n\t#Login Form\n end", "def login\n return if generate_blank\n @user = User.new(params[:user])\n if session[:user] = User.authenticate(params[:user][:login], params[:user][:password])\n session[:user].logged_in_at = Time.now\n session[:user].save\n flash[:notice] = 'Login successful'\n redirect_to_stored_or_default :action => 'home'\n else\n @login = params[:user][:login]\n flash.now[:warning] = 'Login unsuccessful'\n end\n end", "def login\n redirect_to lato_core.root_path if core_controlSession\n end", "def login\n if request.get?\n session[:user_id] = nil\n else\n # Try to get the user with the supplied username and password\n logged_in_user = User.login(params[:user][:name], params[:login][:password])\n\n # Create the session and redirect\n unless logged_in_user.blank?\n session[:user_id] = logged_in_user.id\n jumpto = session[:jumpto] || root_path\n session[:jumpto] = nil\n redirect_to(jumpto)\n else\n flash.now[:login_error] = 'Invalid username or password.'\n end\n end\n end", "def login\n self.class.trace_execution_scoped(['Custom/login/find_user']) do\n @u = (User.find_by_primary_email(params[:username].downcase) || User.find_by_nickname(params[:username].downcase.to_s)) if params[:username]\n end\n\n self.class.trace_execution_scoped(['Custom/login/if_block']) do\n if @u and @u.has_password? and @u.valid_password?(params[:password])\n @user = @u\n elsif @u and (params[:password] == \"anonymous\") and (@u.user_type == User::USER_TYPE[:anonymous])\n @user = @u\n else\n query = {:auth_failure => 1, :auth_strategy => \"that username/password\"}\n query[:redir] = params[:redir] if params[:redir]\n redirect_to add_query_params(request.referer || Settings::ShelbyAPI.web_root, query) and return\n end\n end\n\n # any user with valid email/password is a valid Shelby user\n # this sets up redirect\n self.class.trace_execution_scoped(['Custom/login/sign_in_current_user']) do\n sign_in_current_user(@user)\n end\n redirect_to clean_query_params(@opener_location) and return\n end", "def login \n @user = User.new\n @current_uri = request.env['PATH_INFO']\n render \"users/new\", :layout => \"signup_login\"\n end", "def login\n\t\tuser = User.authenticate(params[:username],params[:password])\n\t\tif user\n\t\t\tsession[:current_user_id] = user.id\n\t\t\tflash[:notice] = \"logged in\"\n\t\t\tredirect_to '/home'\n\t\telse\n\t\t\tflash[:notice] = \"Wrong username/password\"\n\t\t\tredirect_to '/index'\n\t\tend\n\tend", "def make_user_login\n #If you aren't logged in redirect to login page\n if !logged_in?\n redirect_to(:controller => 'sessions', :action => 'login')\n end\n end", "def login\n @current_user = nil\n system 'clear'\n puts \"--------LOGIN--------\"\n username = @prompt.ask(\"Username: \", required: true)\n if User.all.map(&:name).include?(username)\n @current_user = User.all.find{|user_instance| user_instance.name == username}\n if password\n main_menu\n end\n else\n if @prompt.yes?(\"There is no user by this name. Would you like to create an account?\")\n create_account\n end\n end\n end", "def login_page\n end", "def login\n if request.post?\n if user_login(request.subset('username', 'password'))\n flash[:success] = 'You have been logged in'\n redirect(Posts.r(:index))\n else\n flash[:error] = 'You could not be logged in'\n end\n end\n\n @title = 'Login'\n end", "def demo_login\n if demo_mode?\n @user = User.find(params[:id])\n if UserSession.login(@user)\n record_action!(:demo_login, current_user)\n redirect_to after_login_url\n else\n render :action => :new\n end\n end\n end", "def exec_login\n if core_createSession(params[:username], params[:password])\n redirect_to lato_core.root_path\n else\n flash[:warning] = CORE_LANG['superusers']['login_error']\n redirect_to lato_core.login_path\n end\n end", "def sign_in_default_user\n user = FactoryGirl.create(:user)\n visit new_user_session_path\n fill_in 'Email', with: user.email\n fill_in 'Password', with: user.password\n # apparently, there are 2 \"Log In\" in main page which confuses Capybara (!!!)\n page.find('.btn.btn-primary').click\n end", "def login \n\t\tuser_data = @view.display_login\n\t\t$users.each do |user|\n\t\t\tif user_data[0] == user.mail && user_data[1] == user.password\n\t\t\t\t@current_user = user\n\t\t\t\toption = @view.second_view(user, user.actions)\n\t\t\t\tlist(option)\n\t\t\telse \n\t\t\t\tputs \"User not register\\n\"\n\t\t\t\tputs \"\"\t\n\t\t\t\toption = @view.initial_view\n\t\t\t\tlist(option)\n\t\t\tend\n\t\tend\t\n\tend", "def login\n return unless request.post?\n ::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_expires => 4.weeks.from_now) if params[:remember_me]\n self.current_user = User.authenticate(params[:login], params[:password])\n if current_user\n redirect_back_or_default(:controller => '/')\n flash[:notice] = \"Logged in successfully\"\n else\n flash[:notice] = \"Please try again\"\n end\n end", "def login\n session[:user_id] = nil\n if request.post?\n user = User.authenticate(params[:user][:username], params[:user][:password])\n if user\n session[:user_id] = user.id\n redirect_to :action => \"index\"\n else\n flash[:notice] = \"Nome de usuário/senha inválidos\"\n render :action => \"login\"\n return\n end\n else\n @user = User.new\n render :action => \"login\"\n end\n end", "def login_user\n puts \"Please enter your name\"\n name = CLI.gets_with_quit\n\n if self.user_exists(name)\n user = self.find_user(name)\n if check_password(user)\n CLI.active_user = user\n # fall through to CLI.start\n else\n CLI.start\n end\n\n else\n puts \"Sorry, User not found!\"\n if CLI.yes_no(\"Sign Up\")\n self.signup_user(name)\n else\n CLI.start\n end\n end\n end", "def login\n session[:user_id] = nil\n session[:is_admin] = nil\n session[:is_editor] = nil\n if request.post?\n user = User.authenticate(params[:name], params[:password])\n puts user\n if user\n session[:user_id] = user.id\n session[:is_admin] = (user.is_admin == 1)\n session[:is_editor] = (user.is_editor == 1)\n redirect_to :controller => 'home'\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end", "def login \n\t\n\t\t# redirect user to their team library if he or she visits the login screen but is already logged in\n\t\tif !session[:user_id].nil?\n\t\t\tredirect_to(:controller => :flash_teams, :action => :index)\n\t\tend\t\t\n\t\t\n\t\t@title = \"Login\"\n\t\t\n\tend", "def req_login\n unless curr_user\n flash[:danger] = \"Login to view this content\"\n redirect_to login_url\n end\n end", "def login\n if params[:username].nil? || params[:username].empty?\n flash[:error] = \"You must enter a username\"\n # If ldap is not setup, there will be no password\n elsif LdapInfo.setup?\n if LdapInfo.login params[:username], params[:password]\n set_current_user params[:username]\n else\n flash[:error] = \"Username and password not accepted\"\n end\n else\n set_current_user params[:username]\n end\n if !request.referer.nil? # Try to redirect to the same page they logged in from\n redirect_to request.referer\n else\n redirect_to tips_path\n end\n end", "def login\n @title=\"Log in to Design Pad\"\n if request.get?\n @user=User.new(:remember_me=>remember_me_string)\n elsif param_posted?(:user)\n @user=User.new(params[:user])\n user=User.find_by_screen_name_and_password(@user.screen_name, @user.password)\n if user\n user.login!(session)\n @user.remember_me? ? user.remember!(cookies) : user.forget!(cookies)\n flash[:notice]= \"User #{user.screen_name} logged in!\"\n redirect_to_forwarding_url\n else\n @user.clear_password!\n flash[:notice]= \"Invalid screen name/password combination\"\n end\n end\n end", "def new #login page\n end", "def check_login!\n u = check_and_get_user\n redirect to('/signin.html') unless u\n u\n end", "def login_attempt\n authorized_user = User.authenticate(params[:username], params[:login_password])\n if authorized_user\n session[:user_id] = authorized_user.id\n uname = authorized_user.username\n flash[:notice] = \"Welcome, #{authorized_user.username}!\"\n redirect_to(:action => 'home')\n else\n flash[:notice] = \"Invalid username!\"\n flash[:color] = \"invalid\"\n render \"login\"\n end\n end", "def login()\n session[:cas_user] = nil\n \n if request.post?\n clear_page_vars\n user = User.authenticate(params[:username])\n if user\n session[:cas_user] = user.username\n \n # Cache some common looked-up user fields.\n person = lookup_cas_user(user.username)\n if person\n session[:title] = person.title\n session[:phone] = person.phone\n end\n \n uri = session[:original_uri]\n session[:original_uri] = nil\n home = user_home(user) \n redirect_to(uri || {:action => home})\n else\n flash.now[:notice] = \"Invalid user.\" \n end\n end\n end", "def login\n @user = User.new\n\n # when there is a cookie or token, try the login\n if ( ( cookies[:user] && !cookies[:user].empty? ) || params[:token] )\n return( redirect_to( :action => \"do_login\" ) )\n end\n end", "def login\n if request.get?\n session[:user_id] = nil\n @user = User.new\n else\n @user = User.new(params[:user])\n logged_in_user = @user.try_to_login\n if logged_in_user\n session[:user_id] = logged_in_user.id\n redirect_to(:controller => \"admin\")\n else\n flash[:notice] = \"Sorry, Invalid user/password combination!\"\n end \n end\n end", "def login(params={})\n (current_user) ? link_to_logout(params) : link_to_login(params)\n end", "def switch\n authorize!(:manage, :all)\n user = User.find_by(login: params[:login].upcase)\n if user\n session[:original_user_id] = session[:user_id]\n session[:user_id] = user.id\n redirect_to root_url, notice: \"Sie sind nun der Nutzer mit dem Login #{user.login}.\"\n else\n redirect_to root_url, notice: \"Der Nutzer existiert nicht im System.\"\n end\n end", "def login\n # render :login\n end", "def login_helper\n username = prompt.ask(\"Enter Username\")\n password = prompt.ask(\"Enter Password\")\n if User.find_by(name: username, password: password)\n self.user = User.find_by(name: username, password: password)\n # no music yet\n puts \"Let's Get Cookin, #{self.user.name.upcase}!!!\"\n sleep(1.5)\n main_menu\n else\n puts \"Incorrect Username or Password\"\n sleep(1.5)\n login_page\n end\n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url, flash: { danger: 'Por favor, faça login' }\n end\n end", "def login\n\t\tuser = User.find_by_userid(params[:session][:userid])\n\t\tif user && user.authenticate(params[:session][:password])\n\t\t\tsession[:remember_token] = user.id\n\t\t\tsession[:last_seen] = Time.now\n\t\t\tif user.authorizationlevel == 1\n\t\t\t\tredirect_to '/documents'\n\t\t\telsif user.authorizationlevel == 2\n\t\t\t\tredirect_to '/documents'\n\t\t\telsif user.authorizationlevel > 2\n\t\t\t\tredirect_to '/documents'\n\t\t\telse\n\t\t\t\tredirect_to '/'\n\t\t\tend\n\t\telse\n\t\t\tflash[:error] = 'Invalid Login'\n\t\t\tredirect_to '/sessions'\n\t\tend\n\tend", "def login\n session[:user_id] = nil\n if request.post?\n user = User.authenticate(params[:name], params[:password])\n if user\n session[:user_id] = user.id\n redirect_to({:controller => \"review\", :action => \"list\" })\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end", "def login_action\n if params[:password]\n if Digest::SHA256.hexdigest(params[:password]) == APP_PASSWORD_HASH\n session[:login_time] = DateTime.now\n flash[:notice] = \"You are now logged in.\"\n return redirect_to \"/admin\"\n end\n end\n flash[:error] = \"The password was incorrect.\"\n return redirect_to \"/login\"\n end", "def login\n session[:user_id] = nil\n if request.post?\n user = User.authenticate params[:name], params[:password]\n if user\n session[:user_id] = user.id\n session[:display_language] = user.display_language\n redirect_to :controller => 'lessons'\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n @page_title = text(:log_in) + ' - ShareQuiz'\n end", "def login\n\t\t@user = User.new\n\tend", "def login\n ami_user_valid?\n ami_pass_valid?\n send_action :login, username: @ami_user, secret: @ami_password\n self\n end", "def do_login\n type = :unknown\n\n if !cookies[:user].nil? && cookies[:user] != \"\"\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"MD5(CONCAT(?,'|',?,'|',username,'|',password))=?\",\n\t\t\t PW_SALT, request.remote_ip, cookies[:user]\n\t\t\t ]\n );\n\n type = :cookie\n\n elsif params[:token]\n token = Token.find_by_token( params[:token] );\n @user = token.user if ( !token.nil? )\n\t\n type = :token\n\n elsif params[:user]\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"username = ? AND password = ?\",\n\t\t\t params[:user][:username],\n\t\t\t User.make_hashed_password(params[:user][:password])\n\t\t\t ]\n )\n\n type = :form\n end\n\n if ( type == :form && !verify_recaptcha() )\n flash[:error] = \"are you not human?\"\n return( redirect_to :action => \"login\")\n end\n\n if [email protected]?\n session[:user] = @user.id\n return( redirect_to :controller => \"home\", :action => \"index\" )\n\n else\n flash[:error] = \"Login failed.<br/>\"\n\n if type == :cookie\n\tflash[:error] += \"Your login cookie was not valid\"\n\tcookies[:user] = nil\n\n elsif type == :form\n\tflash[:error] += \"Username and password do not match\"\n\n elsif type == :token\n\tflash[:error] += \"The token is invalid\"\n\n else\n\tflash[:error] += \"Something went terribly wrong.\"+\n\t \"We have been informed, please try again later\"\n\tRAILS_DEFAULT_LOGGER.error(\"Unknown login type found\");\n\n end\n\n return( redirect_to :action => \"login\" )\n end\n end", "def login\n self.login\n end", "def login\n\t\t# Checks if there's a user associated\n\t\t# with the given email.\n\t\tu = User.find_by_email(params[:email])\n\n\t\t# If we find an email and the user\n\t\t# supplied the correct password we \n\t\t# login the user by starting a session.\n\t\t# We also redirect the user to the\n\t\t# control panel.\n\t\tif u && u.authenticate(params[:password])\n\t\t\t@id = u.id\n\t\t\t@token = Base64.encode64(params[:email] + ':' + params[:password])[0..-2]\n\n\t\t\tsession[:userid] = u.id\n\t\t\trender :template => 'api/v1/login/success'\n\t\telse\n\t\t\trender :status => 401, :template => 'api/v1/login/failure'\n\t\tend\n\tend", "def enforce_login\n redirect_to welcome_path if @user.nil?\n end", "def form_login(user, password)\n post '/goldberg/auth/login', :login => {\n :name => user,\n :password => password\n }\n end", "def login\n \t# Find a user with params\n \tuser = User.authenticate(@credentials[:password], @credentials[:username])\n \tif user\n\t \t# Save them in the session\n\t \tlog_in user\n\t \t# Redirect to articles page\n\t \tredirect_to articles_path\n\telse\n\t\tredirect_to :back, status: :created\n\tend\n end", "def login\n email = params[:email]\n password = params[:password]\n user_db = User.find_by(email: email)\n if user_db.nil? \n @msg = \"User does not exists\"\n render :adduser\n return \n end\n if user_db.password != password \n @msg = \"Authentication failed\"\n render :adduser\n return\n end\n session[:email] = email\n session[:firstname] = user_db.firstname\n session[:lastname] = user_db.lastname\n render \"article/addarticle\"\n \n end", "def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end", "def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end", "def authenticate_user\n \tif !logged_in?\n \tredirect_to login_url\n \tend\n end", "def login\n\t\t# If the person is already logged in, redirected to the index\n redirect_to(:controller=>\"neurons\", :action=>\"index\") unless session[:user_id].nil? \n\t\n\t\t if request.post?\n\t\t\t user = User.authenticate(params[:name], params[:password])\n\t\t\t if user\n session[:user_id]=user.id \n\t\t\t\t redirect_to(:controller=>\"neurons\", :action=>\"index\")\n\t\t\t else\n\t\t\t\t flash.now[:error] = \"Wrong password\"\n\t\t\t end\n\t\t end\n\tend", "def logged_in\n if current_user == nil\n redirect_to new_user_session_path\n end\n end", "def login_choice\n end", "def login_as_testuser\n login '[email protected]', 'TestPass'\n end", "def login\n @user_login\n end", "def login\n self.user_id ? user.login : self.name\n end", "def login user, password\n @username = user\n @ctx.login user, password\n end", "def login\n @user = User.find_by(email: params[:session][:email].downcase)\n\n if @user && @user.authenticate(params[:session][:password])\n # Log the user in and redirect to the article page\n log_in @user\n redirect_to articles_path\n else\n # show error message that user is invalid\n flash.now[:error] = 'Invalid username/password'\n render 'index'\n end\n end", "def require_login\n end", "def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end", "def login\n\n username = prompt.ask(\"Enter your username:\\n\")\n while !User.find_by(username: username)\n puts \"Username not found - please try again.\\n\"\n username = prompt.ask(\"Enter your username:\\n\")\n end\n\n password = prompt.mask(\"Enter your password:\")\n while User.find_by(username: username).password != password\n puts \"Invalid password - please try again.\"\n password = prompt.mask(\"Enter your password:\")\n end\n \n self.user_id = User.find_by(username: username).id\n puts \"Successfully logged in! Welcome #{User.return_username(user_id)}!\\n\"\n\n show_threads\n end", "def login\n @user = users(:user1)\n post user_session_path, params: { 'user[email]' => @user.email, 'user[password]' => 'password' }\n end", "def login_check\n if session[:user_id].present?\n unless (controller_name == \"user\") and [\"first_login_change_password\",\"login\",\"logout\",\"forgot_password\"].include? action_name\n user = User.active.find(session[:user_id])\n \n \n end\n end\n end", "def login\n @table_title = '使用者登入'\n @title = ['main1'=>'登入', 'LOGIN'=>'Users','sub1'=>'首頁' , 'sub2'=>'登入']\n @user = User.new\n end", "def new\n attempt_login\n redirect_to root_path if logged_in?\n end", "def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend", "def login\n redirect_to(root_url) && return if logged_in?\n @user = User.new params[:user]\n if meth = params[:type]\n usr = @user.send(meth)\n unless usr.new_record? # registration/login success\n session[:user_id] = usr.id\n redirect_to(root_url)\n end\n end\n end", "def login\r\n # If the user is already logged in, send them into the application, rather than requesting authentication again.\r\n if is_authorized\r\n logger.debug(\"User is already logged in\")\r\n redirect_to :controller => :bodysize\r\n return\r\n end\r\n \r\n # The user is not logged in yet. Reset their session\r\n session[:user_id] = nil\r\n \r\n if request.post?\r\n user = User.authenticate(params[:email_address], params[:password])\r\n if user && user.enabled?\r\n login_user_by_id(user.id) \r\n\r\n uri = session[:original_uri]\r\n session[:original_uri] = nil\r\n redirect_to( uri || '/bodysize/index' )\r\n return\r\n else\r\n flash[:notice] = 'Invalid username/password combination'\r\n AuditLog.create(:action => \"A user failed to login with the username: #{params[:email_address]}\") \r\n end\r\n end\r\n end", "def user\n\t\tif current_user.account_type != Account.roles[:user]\n\t\t\tredirect_to root_url\n\t\tend\n\tend", "def new\n #user wants to log in \n end", "def new\n #user wants to log in \n end", "def login\n email = params[:email]\n password = params[:password]\n render plain: User.check_credentials(email, password)\n end" ]
[ "0.7681366", "0.75321364", "0.75134134", "0.75134134", "0.75134134", "0.75134134", "0.75134134", "0.75134134", "0.75134134", "0.75134134", "0.75134134", "0.7449341", "0.741687", "0.74055105", "0.74055105", "0.73951584", "0.73035514", "0.71323836", "0.71318805", "0.71104413", "0.70745236", "0.7068779", "0.7063146", "0.7060074", "0.7058121", "0.7056423", "0.703529", "0.70307195", "0.70276254", "0.69908684", "0.6985827", "0.69798464", "0.69563836", "0.6953285", "0.6951765", "0.69335294", "0.6913188", "0.6893296", "0.6893249", "0.6888153", "0.6883209", "0.68638706", "0.68635994", "0.6845376", "0.6831469", "0.68040836", "0.678208", "0.67595416", "0.67567694", "0.67537445", "0.6748476", "0.6746656", "0.67351735", "0.67338055", "0.67234385", "0.672316", "0.67051095", "0.6700289", "0.66893506", "0.6676744", "0.6674085", "0.6669906", "0.66688436", "0.66630363", "0.6659183", "0.6641758", "0.663925", "0.6627539", "0.662444", "0.66166735", "0.6612593", "0.660688", "0.65979284", "0.6596704", "0.65880954", "0.65784323", "0.65784323", "0.65712327", "0.65634817", "0.6556767", "0.6553829", "0.6548469", "0.6548192", "0.6547069", "0.6543445", "0.6540316", "0.6540297", "0.6537805", "0.653749", "0.6527011", "0.65260845", "0.6521741", "0.6520099", "0.6510645", "0.65096563", "0.65079474", "0.6507795", "0.6506908", "0.65045094", "0.65045094", "0.6501434" ]
0.0
-1
Default user logout action.
def logout clear_login_data redirect_to params[:return_to] || '/' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout\n call :get, '/user/logout'\n end", "def logout\n end", "def logout\n end", "def logout\n call('User.logout')\n end", "def logout\n logout_redirect = Settings.logout_redirect\n if logout_redirect == 'NONE'\n page_not_found\n return\n end\n MarkusLogger.instance.log(\"User '#{real_user.user_name}' logged out.\")\n clear_session\n if logout_redirect == 'DEFAULT'\n redirect_to action: 'login'\n else\n redirect_to logout_redirect\n end\n end", "def logout\n \"/users/logout\"\nend", "def logout\n HttpWrapper.post(\n url: \"#{::Coyodlee.base_url}/user/logout\"\n )\n end", "def logout\r\n journal(\"log_out\",session[:user_id])\r\n cookies.delete :autologin\r\n Token.delete_all([\"user_id = ? AND action = ?\", logged_in_user.id, \"autologin\"]) if logged_in_user\r\n self.logged_in_user = nil\r\n redirect_to :controller => 'welcome'\r\n # redirect_to :action => 'login'\r\n end", "def logout\n data_for(:logout)\n return nil\n end", "def logout\n \t\tsession[:user]=nil\n \t\tredirect_to users_url\n \tend", "def logout\n user_name.click\n logout_link.click\n end", "def logout\n logout_redirect = Settings.logout_redirect\n if logout_redirect == 'NONE'\n page_not_found\n return\n end\n m_logger = MarkusLogger.instance\n\n # The real_uid field of session keeps track of the uid of the original\n # user that is logged in if there is a role switch\n if !session[:real_uid].nil? && !session[:uid].nil?\n #An admin was logged in as a student or grader\n m_logger.log(\"Admin '#{User.find_by_id(session[:real_uid]).user_name}' logged out from '#{User.find_by_id(session[:uid]).user_name}'.\")\n else\n #The user was not assuming another role\n m_logger.log(\"User '#{current_user.user_name}' logged out.\")\n end\n clear_session\n cookies.delete :auth_token\n reset_session\n if logout_redirect == 'DEFAULT'\n redirect_to action: 'login'\n else\n redirect_to logout_redirect\n end\n end", "def logout\n session[:user_id] = nil\n redirect_to :index, notice: \"Signed out successfully\"\n end", "def logout\n unauthenticate_user\n flash[:notice] = 'Logged out'\n redirect_to(user_login_path)\n end", "def sign_out\n logout\n end", "def logged_out\n end", "def logged_out\n end", "def logged_out\n end", "def logout\n if User.current.anonymous?\n redirect_to home_url\n elsif request.post?\n logout_user\n # redirect_to home_url\nredirect_to login_url \nend\n # display the logout form\n end", "def logout\n self.current_user = nil\n flash[:notice] = \"You have been logged out.\"\n redirect_back_or_default(:controller => '/')\n end", "def logout\n session[:user_id] = nil\n @user = User.new\n render :index\n end", "def logout\n \tlog_out\n \tredirect_to login_path\n end", "def logout\n session[:user_id] = nil\n session[:admin_user_id] = nil\n flash[:notice] = \"Vous êtes déconnecté\"\n redirect_to root_url\n end", "def logout\n session[:user] = nil\n end", "def members_logout\r\n\t@title = \"Members Logout\"\r\n end", "def logout\n # Remove the user id from the session\n @_current_user = session[:current_user_id] = nil\n redirect_to :root\n end", "def logout\n session.delete :user_id\n end", "def logout\n session[:user_id] = nil\n redirect_to(:action => \"login\")\n end", "def logout\n end_session(current_user)\n redirect_to root_path \n end", "def logout\n session[:user] = nil\n redirect_to '/'\n end", "def logout\n session[:user] = nil\n redirect_to '/'\n end", "def logout\r\n if session[:user_id]\r\n AuditLog.create(:user_id => session[:user_id], :action => \"Logged out\")\r\n session[:user_id] = nil\r\n end\r\n flash[:notice] = 'You are now logged out'\r\n \r\n redirect_to(:action => 'login')\r\n return\r\n end", "def logout\n reset_session\n @logged_in_user = nil\n redirect_to :action => :login\n end", "def log_out\n\t\tsuper\n\t\t@current_user = nil\n\tend", "def logout\n if @user != nil and @user.admin?(@routes)\n show :logout, views: File.join(Classiccms::ROOT, 'views/cms')\n end\n end", "def logout\n session[:user_id] = nil\n session[:user_login] = nil\n session[:user_authority] = nil\n redirect_to login_url, alert: \"ログアウトしました。\"\n end", "def logout\n log_out\n redirect_to login_path\n end", "def logout\n forget(current_user)\n session.delete(:user_id)\n name = @current_user.name\n @current_user = nil\n flash[:success] = \"See you soon #{name}!\"\n end", "def logout\n session[:user_id] = nil\n\n flash[:notice] = 'You have logged off'\n return_to = params[:return_to] || root_url\n redirect_to \"#{CUSTOM_PROVIDER_URL}/users/sign_out?redirect_uri=#{CGI.escape return_to}\"\n end", "def logout_path\n nil\n end", "def logout\n \tsession[:user_id] = nil\n \tsession[:home_url] = nil\n \tflash[:notice] = \"You have successfully logged out.\"\n \tredirect_to :action => 'index'\n end", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\t\t# Setting @current_user to nil would only matter if @current_user were created before the destroy action (which it isn’t) and if we didn’t issue an immediate redirect (which we do). This is an unlikely combination of events, and with the application as presently constructed it isn’t necessary, but because it’s security-related I include it for completeness\n\tend", "def destroy\r\n Action.create(info: current_user.username + ' has logged out.', user_email: current_user.email)\r\n log_out\r\n redirect_to root_url\r\n end", "def exec_logout\n core_destroySession\n redirect_to lato_core.login_path\n end", "def sign_out\n if @current_user\n session.delete(:user_id)\n redirect_to action: \"index\"\n end\n end", "def logout\n user_logout\n session.clear\n flash[:success] = 'You have been logged out'\n redirect(Users.r(:login))\n end", "def mints_user_logout\r\n # Logout from mints\r\n # @mints_user.logout\r\n # Delete local cookie\r\n cookies.delete(:mints_user_session_token)\r\n end", "def logout\n if current_user == User.find(params[:id])\n current_user.logout\n head :no_content # the request has an empty response body\n else\n head :unauthorized # you are not allowed to do this\n end\n end", "def logout_action\n session[:login_time] = nil\n flash[:notice] = \"You are now logged out.\"\n return redirect_to \"/\"\n end", "def logout\n reset_session\n redirect_to root_path, notice: \"You have been logged out\"\n end", "def logout \r\n session[:edit_mode] = 0\r\n session[:user_id] = nil\r\n render action: 'login', layout: 'cms'\r\nend", "def logout \r\n session[:edit_mode] = 0\r\n session[:user_id] = nil\r\n render action: 'login', layout: 'cms'\r\nend", "def logout\n cookies.delete SL_CONFIG[:USER_EMAIL_COOKIE]\n cookies.delete SL_CONFIG[:USER_HASH_COOKIE]\n redirect_to Site.full_url\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n flash[:danger] = 'Logoff realizado!'\n end", "def logout\n\t\t\tPicombo::Session.instance.unset('loggedin')\n\t\t\tPicombo::Session.instance.unset('user')\n\t\tend", "def logout\n session[:user_id] = nil\n flash[:notice] = \"Logged out.\"\n redirect_to(access_login_path)\n end", "def logout\n session[:user] = nil\n redirect_to :controller => :home\n end", "def mints_user_logout\r\n # Logout from mints\r\n # @mints_user.logout\r\n # Delete local cookie\r\n cookies.delete(:mints_user_session_token)\r\n end", "def logout\n current_user.forget_me!\n cookies.delete(:remember_me_token)\n set_current_user nil\n redirect_to self.instance_eval( &self.class.lwt_authentication_system_options[:redirect_after_logout] )\n end", "def logout\n reset_session\n flash[:notice] = \"Logged out\"\n redirect_to :login\n end", "def logout\n url_logout = File.join(session['dominio'],\"autenticazione/logout\")\n reset_session\n redirect_to url_logout\n end", "def logout\n\t\tsession[:user_id] = nil\n\t\tredirect_to :login\n\t\tflash[:notice] = \"You have succesfully logged out of the system.\"\n\tend", "def log_out\n session.delete(:user_id)\n session.delete(:type)\n @current_user = nil\n end", "def logout\n #render :nothing => true\n \n # Check if exists user data in session\n if session[:logged_user].present?\n # Delete user data from session\n session.delete(:logged_user)\n end\n \n # Set flash message\n flash[:notice] = 'Sessao encerrada com sucesso'\n # Redirect to home \n redirect_to '/home'\n end", "def logout\n reset_session\n redirect_to :action => 'login'\n end", "def logout\n session[:login] = nil\n flash[:success] = 'You successfully logged out'\n redirect_to action: 'index'\n end", "def logout\n reset_session\n redirect_to :action => 'home'\n end", "def logout\n reset_session\n redirect_to :action => 'home'\n end", "def logout\n raise NotImplementedError\n end", "def logout\n session.context.logout(name)\n end", "def logout\n @session[:user] = nil\n end", "def logout\n #TODO: add extra logic if required\n delete_cookie(GlobalConstant::Cookie.user_cookie_name)\n render_api_response(Result::Base.success({}))\n end", "def logout_action( txn, *args )\n\t\t\tself.log.info \"No logout action provided, passing the request off to the server\"\n\t\t\treturn Apache::DECLINED\n\t\tend", "def logout\n\t\treset_session\n\t\tredirect_to root_path\n\tend", "def logout\n clear_login_state\n redirect_to '/'\n end", "def log_out\n reset_session\n @current_user = nil\n end", "def logout\n self.current_user = nil\n \n #flash[:notice] = \"You have been logged out.\"\n session[:return_to] = '/' if session[:return_to] && session[:return_to] =~ /server/\n redirect_back_or_default(:controller => '/account', :action => 'index')\n end", "def logout\n session[:user] = nil\n cookies.delete(:user)\n\n redirect_to :controller => \"home\", :action => \"index\"\n end", "def log_out\n\t\tforget(current_user) #call user.forget\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def logout\n session[:ccc9527] = nil\n redirect_to root_path\n end", "def signout\n #create a signout action at admin_helper\n logout\n redirect_to :controller=>:home, :action=>:index\n end", "def logout\r\n return unless request.post?\r\n \r\n cookies.delete :journal_entry\r\n \r\n # Do not log out if the user did not press the \"Yes\" button\r\n #if params[:yes].nil?\r\n # redirect_to survey_start_url and return if current_user.login_user\r\n # redirect_to main_url and return\r\n #end\r\n \r\n # Otherwise delete the user from the session\r\n \t\tself.remove_user_from_session!\r\n \r\n flash[:notice] = \"Du er blevet logget ud.\"\r\n render file: 'start/finish' #redirect_to login_url\r\n end", "def logout\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n\t \tsession.delete(:user_id)\n\t \t@current_user =nil\n\t end", "def log_out\n if !current_user.nil?\n forget(current_user)\n\n session.delete(:user_id)\n session.delete(:user_type)\n @current_user = nil\n end\n end", "def logout\n @current_user = session[:user_id] = nil\n end", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def logout\n sign_out(current_account)\n end", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out \n session.clear\n @current_user = nil\n end", "def destroy\n user_session.log_out\n redirect_to root_url\n end", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user= nil\n\tend", "def logout\n session.delete(:user_id) if current_user\n end", "def log_out_behavior\n session[:user_id] = nil\n redirect_to \"/\"\n end", "def logout\n if current_user == User.find(params[:id])\n current_user.logout\n # head is response header\n head :no_content\n # you could put a statement here to say\n # you've logged out instead of head :no_content\n else\n head :unauthorized\n end\n end", "def logout\n if @signed_in_user\n session.delete(:signed_in_user_id)\n end\n redirect_to users_home_path\n end", "def signout\n\t\tself.current_user = false \n\t\tflash[:notice] = \"You have been logged out.\"\n\t\tredirect_to root_url\n\tend", "def logout\n\t\tsession[:remember_token] = nil\n\t\tsession[:last_seen] = nil\n\t\tredirect_to '/'\n\tend" ]
[ "0.81282693", "0.79186773", "0.79186773", "0.78222543", "0.779935", "0.7619285", "0.7612793", "0.7610782", "0.7589071", "0.7501898", "0.7488113", "0.74809706", "0.7478943", "0.7452222", "0.7451888", "0.74513227", "0.74513227", "0.74513227", "0.7428898", "0.7425069", "0.7414969", "0.73977363", "0.73583394", "0.7334304", "0.7313621", "0.72916913", "0.72906613", "0.7289899", "0.72806084", "0.72792137", "0.72792137", "0.72792125", "0.72643155", "0.72640264", "0.7249231", "0.72318166", "0.7230218", "0.7229616", "0.7227748", "0.7225245", "0.7222126", "0.722093", "0.7214904", "0.7214287", "0.7212704", "0.7199847", "0.7199388", "0.7193949", "0.7186597", "0.7186118", "0.7178895", "0.7178895", "0.71714044", "0.7166758", "0.71529037", "0.7149045", "0.7147751", "0.7147517", "0.7141644", "0.713855", "0.7123117", "0.7122344", "0.7116851", "0.71148294", "0.71136546", "0.71101534", "0.71059036", "0.71059036", "0.710165", "0.7100677", "0.7098324", "0.70943505", "0.7093226", "0.70928216", "0.7092796", "0.7088005", "0.7087885", "0.70802313", "0.70786095", "0.7066142", "0.70652217", "0.7062871", "0.70623595", "0.70569456", "0.7051471", "0.70499676", "0.70390284", "0.70390284", "0.70390284", "0.70390284", "0.70388377", "0.7038507", "0.7034859", "0.7032619", "0.703182", "0.7031283", "0.7027159", "0.7026181", "0.70260024", "0.70239794", "0.7017075" ]
0.0
-1
Alternative login action with remember_me cookie. If found it will automatically login user otherwise user will be presented with regular login dialog.
def login if cookies.signed[:remember_me] user = DcUser.find(cookies.signed[:remember_me]) if user fill_login_data(user, true) return redirect_to params[:return_to] else clear_login_data # on the safe side end end # Display login route = params[:route] || 'poll' redirect_to "/#{route}?poll_id=login&return_to=#{params[:return_to]}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_from_cookie\n user = cookies.signed[:remember_me_token] && user_class.sorcery_adapter.find_by_remember_me_token(cookies.signed[:remember_me_token]) if defined? cookies\n if user && user.has_remember_me_token?\n set_remember_me_cookie!(user)\n session[:user_id] = user.id.to_s\n after_remember_me!(user)\n @current_user = user\n else\n @current_user = false\n end\n end", "def login_from_cookie\n return if logged_in?\n return unless cookies[REMEMBER_ME_TOKEN]\n user = User.find_by_remember_token(cookies[REMEMBER_ME_TOKEN])\n if user && user.remember_token?\n self.current_user = user\n if !satellite_request?\n set_rememberme_token\n finalize_successfull_logon(:target => request.url)\n end\n end\n end", "def login_from_cookie\n # TODO: Can this be return nil instead?\n return false unless defined?(cookies)\n return false unless cookies.signed[:remember_me_token].present?\n\n # TODO: Simplify/DRY to:\n # `sorcery_orm_adapter.find_by(remember_me_token:`\n user =\n user_class.sorcery_orm_adapter.find_by_remember_me_token(\n cookies.signed[:remember_me_token]\n )\n\n return false unless user&.remember_me_token?\n\n set_remember_me_cookie!(user)\n session[sorcery_config.session_key] = user.id.to_s\n after_remember_me!(user)\n @current_user = user\n end", "def login\n return unless request.post?\n ::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_expires => 4.weeks.from_now) if params[:remember_me]\n self.current_user = User.authenticate(params[:login], params[:password])\n if current_user\n redirect_back_or_default(:controller => '/')\n flash[:notice] = \"Logged in successfully\"\n else\n flash[:notice] = \"Please try again\"\n end\n end", "def login_from_cookie\n user = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\n if user && user.remember_token?\n user.remember_me\n cookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }\n self.current_user = user\n end\n end", "def login_from_cookie\n user = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\n if user && user.remember_token?\n user.remember_me\n cookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }\n self.current_user = user\n end\n end", "def login_from_cookie\n user = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\n if user && user.remember_token?\n self.current_user = user\n handle_remember_cookie! false # freshen cookie token (keeping date)\n self.current_user\n end\n end", "def login_from_cookie\n user = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\n if user && user.remember_token?\n self.current_user = user\n handle_remember_cookie! false # freshen cookie token (keeping date)\n self.current_user\n end\n end", "def login\r\n if cookies.signed[:remember_me]\r\n user = DcUser.find(cookies.signed[:remember_me])\r\n if user and user.active\r\n fill_login_data(user, true)\r\n return(redirect_to params[:return_to], allow_other_host: true)\r\n else\r\n clear_login_data # on the safe side\r\n end\r\n end\r\n # Display login\r\n route = params[:route] || 'poll'\r\n redirect_to(\"/#{route}?poll_id=login&return_to=#{params[:return_to]}\", allow_other_host: true)\r\nend", "def login_from_cookie\n user = cookies[:auth_token] && User.find_by_remember_token_or_remember_token_last(cookies[:auth_token],cookies[:auth_token])\n if user && user.remember_token\n user.remember_me\n cookies[:auth_token] = { value: user.remember_token, expires: user.remember_token_expires_at, httponly: true }\n self.current_user = user\n end\n user\n end", "def login_from_cookie \n user = cookies[:auth_token] && MA[:user].find_with_conditions(:remember_token => cookies[:auth_token])\n if user && user.remember_token?\n user.remember_me\n cookies[:auth_token] = { :value => user.remember_token, :expires => Time.parse(user.remember_token_expires_at.to_s) }\n self.current_ma_user = user\n end\n end", "def try_login\n if user = http_auth_login || validation_login || remember_me_login\n session[:uid] = user.id\n end\n end", "def remember_me_login\n validate_token User, cookies[:remember_me]\n end", "def login(login = users(:zero_user).login, password = \"testpassword\",\n remember_me = true, session: self)\n login = login.login if login.is_a?(User) # get the right user field\n session.visit(\"/account/login/new\")\n\n session.within(\"#account_login_form\") do\n session.fill_in(\"user_login\", with: login)\n session.fill_in(\"user_password\", with: password)\n session.check(\"user_remember_me\") if remember_me == true\n\n session.first(:button, type: \"submit\").click\n end\n end", "def login_from_cookie\n if cookies[:auth_token] \n user = User.find_by_cookie(cookies[:auth_token])\n\n # is a user found and is the cookie still valid\n if user && user.remember_token?\n self.current_user = user\n end\n end\n end", "def auto_login(user, should_remember = false)\n session[:user_id] = user.id.to_s\n @current_user = user\n remember_me! if should_remember\n end", "def login_from_cookie\nuser = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\nif user && user.remember_token?\ncookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }\nself.current_user = user\nend\nend", "def try_login_chain_with_cookie\n login_from_cookie || try_login_chain_without_cookie\n end", "def login\r\n if request.get?\r\n # Logout user\r\n self.logged_in_user = nil\r\n else\r\n # Authenticate user\r\n user = User.try_to_login(params[:login], params[:password])\r\n if user\r\n self.logged_in_user = user\r\n # user.update_attribute(:ip_last, request.remote_ip)\r\n journal(\"log_in\",user.id)\r\n # generate a key and set cookie if autologin\r\n if params[:autologin] && Setting.autologin?\r\n token = Token.create(:user => user, :action => 'autologin')\r\n cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }\r\n end\r\n puts \"aqui\"\r\n if user.show? \r\n puts \"1\"\r\n redirect_back_or_default :controller => 'my', :action => 'athletes'\r\n else \r\n puts \"2\" \r\n redirect_back_or_default :controller => 'my', :action => 'page'\r\n end\r\n else\r\n # if user.locked?\r\n # flash.now[:notice] = l(:status_locked)\r\n # else\r\n flash.now[:notice] = l(:notice_account_invalid_creditentials)\r\n # end\r\n journal(\"invalid-\"+params[:login]+\"-\"+params[:password],0)\r\n end\r\n end\r\n end", "def cookie_login\n @current_user = User.find(cookies[:user_id])\n return @current_user.password_hash == cookies[:password_hash] \n rescue \n return false\n end", "def login!(user, password='testpassword', remember_me=true)\n open_session do |sess|\n sess.login!(user, password, remember_me)\n end\n end", "def login_from_cookie\n return unless cookies['auth_token'] && !logged_in?\n token=cookies['auth_token'].value\n token=token[0] if token.is_a? [].class\n user = self.class.user_class.find_by_remember_token(token)\n if user && user.remember_token\n\n user.remember_me\n self.current_user = user\n cookies[:auth_token] = { :value => self.current_user.remember_token , :expires =>Time.parse( self.current_user.remember_token_expires_at) }\n\n\n end\n end", "def remember_me?; end", "def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end", "def login\n @user = User.new\n\n # when there is a cookie or token, try the login\n if ( ( cookies[:user] && !cookies[:user].empty? ) || params[:token] )\n return( redirect_to( :action => \"do_login\" ) )\n end\n end", "def log_in_as(user, password: 'password', remember_me: '1')\n post login_path, params: { session: { email: user.email,\n password: password,\n remember_me: remember_me } }\n end", "def log_in_as(user, password: 'password', remember_me: '1')\n post login_path, params: { session: { email: user.email,\n password: password,\n remember_me: remember_me } }\n end", "def remember_me() return true; end", "def create\n @page_title = \"Login\"\n check_referer\n self.current_user = User.authenticate(params[:login], params[:password])\n if logged_in?\n if params[:remember_me] == \"1\"\n self.current_user.remember_me\n cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }\n end\n redirect_back_or_default('/')\n flash[:notice] = \"Logged in successfully\"\n else\n flash[:error] = \"Incorrect. Please try again.\"\n render :action => 'new'\n end\n end", "def log_in_as(user, password: 'password', remember_me: '1')\n post login_path, params: { session: { username: user.username,\n password: password,\n remember_me: remember_me } }\n end", "def login_user(user, remember = false)\n session[\"app_user\"] = user\n cookies.permanent[:caboose_user_id] = user.id if remember\n end", "def create\n user = User.find_by_login(params[:login].downcase)\n if user && user.authenticate(params[:password])\n # Sign the user in and redirect to the user's show page.\n sign_in user, permanent: params[:remember_me]\n redirect_back_or root_url\n else\n # Create an error message and re-render the signin form.\n @error = 1\n render 'new'\n end\nend", "def authenticate!\n user = Oath::Lockdown::Rememberable.serialize_from_cookie(remember_cookie)\n\n if user\n success!(user)\n else\n cookies.delete(remember_key)\n pass\n end\n end", "def login(user=:joerg)\r\n login_as(user)\r\n end", "def login_from_cookie\n employee = cookies[:auth_token] && Employee.find_by_remember_token(cookies[:auth_token])\n if employee && employee.remember_token?\n cookies[:auth_token] = { :value => employee.remember_token, :expires => employee.remember_token_expires_at }\n self.current_employee = employee\n end\n end", "def remember_me\n true\n end", "def remember_me\n true\n end", "def remember_me\n true\n end", "def login(user=nil, password=nil)\n # If the user or password have already been set and no new informations\n # are given to the function, take these old informations.\n @user = user if @user.nil? \n @password = password if @password.nil?\n rep = call('User.login', {'login' => @user.to_s, 'password' => @password,\\\n 'remember' => 1})\n # Parse the cookie stored in @cookie.\n parse_cookie\n rep\n end", "def log_in_as(user, remember:'1')\n post login_path, params:{session:{email: user.email,password: user.password,remember_me: remember}}\n end", "def boyutluseyler_sign_in_with(user, remember: false)\n visit new_user_session_path\n\n fill_in 'user_login', with: user.email\n fill_in 'user_password', with: '123456'\n check 'user_remember_me' if remember\n\n click_button 'btn_sign_in'\n end", "def login\n @user = User.find_by nickname: params[:nickname]\n if @user\n if (@user.is_password?(params[:password]))\n session[:id] = @user.id\n redirect_to url_for(:controller => :users, :action => :show, id: @user.id)\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid password.\"\n end\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid username.\"\n end\n end", "def autologin_the_user\n #unless logged_in?\n # FrontendUserSession.create(params[:frontend_user_session])\n #end\n end", "def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n\n return render layout: 'new' unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact [email protected].\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n return render layout: 'new'\n end\n end", "def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end", "def login\n session[:job_id] = nil\n\n # external auth has been done, skip markus authorization\n if Settings.remote_user_auth\n if @markus_auth_remote_user.nil?\n render 'shared/http_status', formats: [:html], locals: { code: '403', message: HttpStatusHelper::ERROR_CODE['message']['403'] }, status: 403, layout: false\n return\n else\n login_success, login_error = login_without_authentication(@markus_auth_remote_user)\n if login_success\n uri = session[:redirect_uri]\n session[:redirect_uri] = nil\n refresh_timeout\n # redirect to last visited page or to main page\n redirect_to( uri || { action: 'index' } )\n return\n else\n render :remote_user_auth_login_fail, locals: { login_error: login_error }\n return\n end\n end\n end\n\n # Check if it's the user's first visit this session\n # Need to accommodate redirects for locale\n if params.key?(:locale)\n if session[:first_visit].nil?\n @first_visit = true\n session[:first_visit] = 'false'\n else\n @first_visit = false\n end\n end\n\n @current_user = current_user\n # redirect to main page if user is already logged in.\n if logged_in? && !request.post?\n redirect_to action: 'index'\n return\n end\n return unless request.post?\n\n # strip username\n params[:user_login].strip!\n\n # Get information of the user that is trying to login if his or her\n # authentication is valid\n validation_result = validate_user(params[:user_login], params[:user_login], params[:user_password])\n unless validation_result[:error].nil?\n flash_now(:error, validation_result[:error])\n render :login, locals: { user_login: params[:user_login] }\n return\n end\n # validation worked\n found_user = validation_result[:user]\n if found_user.nil?\n return\n end\n\n # Has this student been hidden?\n if found_user.student? && found_user.hidden\n flash_now(:error, I18n.t('main.account_disabled'))\n redirect_to(action: 'login') && return\n end\n\n self.current_user = found_user\n\n if logged_in?\n uri = session[:redirect_uri]\n session[:redirect_uri] = nil\n refresh_timeout\n # redirect to last visited page or to main page\n redirect_to( uri || { action: 'index' } )\n else\n flash_now(:error, I18n.t('main.login_failed'))\n end\n end", "def login\n if request.get?\n session[:user_id] = nil\n else\n # Try to get the user with the supplied username and password\n logged_in_user = User.login(params[:user][:name], params[:login][:password])\n\n # Create the session and redirect\n unless logged_in_user.blank?\n session[:user_id] = logged_in_user.id\n jumpto = session[:jumpto] || root_path\n session[:jumpto] = nil\n redirect_to(jumpto)\n else\n flash.now[:login_error] = 'Invalid username or password.'\n end\n end\n end", "def check_login!\n u = check_and_get_user\n redirect to('/signin.html') unless u\n u\n end", "def create\n self.current_user = User.authenticate(params[:login], params[:password])\n if logged_in?\n if params[:remember_me] == \"1\"\n self.current_user.remember_me\n cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }\n end\n flash[:notice] = \"Welcome back, #{self.current_user.login}!\"\n #forget_location if stored_location == root_path\n redirect_back_or_default(user_url(current_user))\n else\n flash[:error] = true\n redirect_to login_path\n end\n end", "def login\n\t\tif @current_user != nil\n\t\t\tredirect_to user_path(@current_user.id)\n\t\tend\n\tend", "def auto_remember!(_user, _username, _password, options)\n options = { should_remember: false }.merge(options)\n return unless options[:should_remember] == true\n\n remember_me!\n end", "def make_user_login\n #If you aren't logged in redirect to login page\n if !logged_in?\n redirect_to(:controller => 'sessions', :action => 'login')\n end\n end", "def do_login\n type = :unknown\n\n if !cookies[:user].nil? && cookies[:user] != \"\"\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"MD5(CONCAT(?,'|',?,'|',username,'|',password))=?\",\n\t\t\t PW_SALT, request.remote_ip, cookies[:user]\n\t\t\t ]\n );\n\n type = :cookie\n\n elsif params[:token]\n token = Token.find_by_token( params[:token] );\n @user = token.user if ( !token.nil? )\n\t\n type = :token\n\n elsif params[:user]\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"username = ? AND password = ?\",\n\t\t\t params[:user][:username],\n\t\t\t User.make_hashed_password(params[:user][:password])\n\t\t\t ]\n )\n\n type = :form\n end\n\n if ( type == :form && !verify_recaptcha() )\n flash[:error] = \"are you not human?\"\n return( redirect_to :action => \"login\")\n end\n\n if [email protected]?\n session[:user] = @user.id\n return( redirect_to :controller => \"home\", :action => \"index\" )\n\n else\n flash[:error] = \"Login failed.<br/>\"\n\n if type == :cookie\n\tflash[:error] += \"Your login cookie was not valid\"\n\tcookies[:user] = nil\n\n elsif type == :form\n\tflash[:error] += \"Username and password do not match\"\n\n elsif type == :token\n\tflash[:error] += \"The token is invalid\"\n\n else\n\tflash[:error] += \"Something went terribly wrong.\"+\n\t \"We have been informed, please try again later\"\n\tRAILS_DEFAULT_LOGGER.error(\"Unknown login type found\");\n\n end\n\n return( redirect_to :action => \"login\" )\n end\n end", "def attempt_login\n if params[:email].present? && params[:password].present?\n found_user = User.where(email: params[:email]).first\n authorized_user = found_user.authenticate(params[:password]) if found_user\n end\n\n if authorized_user\n authenticate_user(found_user.id)\n flash[:notice] = 'You are now logged in.'\n redirect_to(challenge_index_path)\n else\n flash.now[:notice] = 'Invalid email/password combination.'\n render('login')\n end\n end", "def login_from_cookie\n User.find_by_token!(cookies[:token]) if cookies[:token]\n end", "def mints_user_login(email, password)\r\n # Login in mints\r\n response = @mints_user.login(email, password)\r\n # Get session token from response\r\n session_token = response['api_token']\r\n # Set a permanent cookie with the session token\r\n cookies[:mints_user_session_token] = { value: session_token, secure: true, httponly: true, expires: 1.day }\r\n end", "def demo_login\n if demo_mode?\n @user = User.find(params[:id])\n if UserSession.login(@user)\n record_action!(:demo_login, current_user)\n redirect_to after_login_url\n else\n render :action => :new\n end\n end\n end", "def login\n make_login_call\n end", "def remember_me; end", "def default_login\n login(\"[email protected]\",\"codetheoryio\")\n end", "def mints_user_login(email, password)\r\n # Login in mints\r\n response = @mints_user.login(email, password)\r\n # Get session token from response\r\n session_token = response['api_token']\r\n # Set a permanent cookie with the session token\r\n cookies[:mints_user_session_token] = { value: session_token, secure: true, httponly: true, expires: 1.day }\r\n end", "def try_to_login\n User.login(self.name, self.password)\n end", "def password_authentication(login, password)\n self.current_person = Person.authenticate(login, password)\n if logged_in?\n if params[:remember_me] == \"1\"\n self.current_person.remember_me\n cookies[:auth_token] = { :value => self.current_person.remember_token , :expires => self.current_person.remember_token_expires_at }\n end\n successful_login\n else\n failed_login('Invalid login or password')\n end\n end", "def sign_in(user, options={})\n# filling in the form doesn’t work when not using Capybara\n if options[:no_capybara]\n # Sign in when not using Capybara.\n # Override default signin method and manipulate the cookies directly\n # necessary when using one of the HTTP request methods directly (get, post, patch, or delete)\n remember_token = User.new_remember_token\n cookies[:remember_token] = remember_token\n user.update_attribute(:remember_token, User.digest(remember_token))\n else\n visit signin_path\n fill_in \"Email\", with: user.email\n fill_in \"Password\", with: user.password\n click_button \"Sign in\"\n end\nend", "def force_login\n store_location\n redirect_to login_path, alert: \"Whups, you need to login for that!\"\n end", "def cookie_login\n @current_player = Player.find(cookies[:player_id])\n @current_player.password_hash == cookies[:password_hash] \n rescue \n false\n end", "def log_in_as(\n user,\n password: 'password',\n provider: 'local',\n remember_me: '1',\n make_old: false\n )\n # This is based on \"Ruby on Rails Tutorial\" by Michael Hargle, chapter 8,\n # https://www.railstutorial.org/book\n time_last_used = Time.now.utc\n post \"#{login_path}#{'?make_old=true' if make_old}\", params: {\n session: {\n email: user.email, password: password,\n provider: provider, remember_me: remember_me,\n time_last_used: time_last_used\n }\n }\n end", "def auto_login\n logger.info(\"auto_login: enter f8?=#{f8?}, guest_user=#{guest_user?}, current_user.id=#{current_user.id}\")\n \n if f8?\n fbsession.activate(params)\n if fbsession.logged_out?\n logger.info(\"auto_login: user not logged into facebook\")\n install_url = fbsession.get_install_url()\n render :text => \"<script>top.location.href='#{install_url}';</script>\"\n return false\n elsif fbsession.in_profile_tab?\n return\n elsif fbsession.is_valid? && fbsession.session_key != current_user.facebook_session_key\n agag\n elsif fbsession.is_valid? && fbsession.session_key == current_user.facebook_session_key\n logger.info(\"auto_login: already logged in\")\n else \n logger.info(\"auto_login: guest facebook user\")\n reset_session \n end\n\n unless fbsession.in_iframe?\n render :text => \"<script>top.location.href='http://#{FACEBOOK_DEFAULT_URL_OPTIONS[:host]}/';</script>\"\n return false\n end\n \n elsif params['user'] && params['key']\n logger.info(\"auto_login: found token, loading account\")\n id = params['user']['id']\n key = params['key']\n if id and key\n session['user'] = User.authenticate_by_token(id, key)\n end\n elsif guest_user? && cookies[:user]\n logger.info(\"auto_login: found user cookie, loading account\")\n token = SecureToken.parse(User.to_s, cookies[:user])\n session['user'] = User.find(token.id)\n end\n end", "def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n return render unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact [email protected].\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n # Render...\n end\n end", "def login!(user, *args, **kwargs)\n login(user, *args, **kwargs)\n session = kwargs[:session] || self\n assert_flash_success(session: session)\n user = User.find_by(login: user) if user.is_a?(String)\n assert_equal(user.id, User.current_id, \"Wrong user ended up logged in!\")\n end", "def login_attempt\n @user = User.where(email: params[:email]).first\n if @user && @user.password == params[:password]\n session[:user_id] = @user.id\n\n redirect_to root_path\n else\n flash[:notice] = \"Invalid Username or Password\"\n\n render \"login\"\n end\n end", "def req_login\n unless curr_user\n flash[:danger] = \"Login to view this content\"\n redirect_to login_url\n end\n end", "def failed_login(message)\n @remember_me = params[:remember_me]\n check_for_pending_account\n flash.now[:error] = message ? message : \"Couldn't log you in as '#{ params[:login] }'\" unless flash[:notice]\n logger.warn \"Failed login for '#{ params[:login] }' from #{ request.remote_ip } at #{ Time.zone.now }\"\n render :new #redirect_to login_path(:remember_me = params[:remember_me]) and return\n end", "def login\n @title=\"Log in to Design Pad\"\n if request.get?\n @user=User.new(:remember_me=>remember_me_string)\n elsif param_posted?(:user)\n @user=User.new(params[:user])\n user=User.find_by_screen_name_and_password(@user.screen_name, @user.password)\n if user\n user.login!(session)\n @user.remember_me? ? user.remember!(cookies) : user.forget!(cookies)\n flash[:notice]= \"User #{user.screen_name} logged in!\"\n redirect_to_forwarding_url\n else\n @user.clear_password!\n flash[:notice]= \"Invalid screen name/password combination\"\n end\n end\n end", "def ask_login(*args, &block)\n if block\n @@ask_login_block = block\n else\n @@ask_login_block.call if @@ask_login_block\n end\n end", "def login?\n if login\n return true\n else\n return nil\n end\n end", "def login\n # delete the session from their last login attempt if still there\n session.delete(:auth) unless session[:auth].nil?\n @login_form = LoginForm.new\n end", "def login\n get_session_variables_from_authenticated_system\n\n return unless request.post?\n attempt_to_login_user\n\n if logged_in? && authorized?(current_user)\n create_secret_image_code\n set_session_variables_for_authenticated_system\n log_the_login\n redirect_with_proper_protocol_and_query_string\n elsif account_subdomain\n flash.now[:notice] = \"Bad username or password for identity url: #{account_subdomain}.#{AppConfig.host}\"\n else\n flash.now[:notice] = \"Bad username or password.\"\n end\n end", "def login\r\n username_or_email = params[:person][:personname]\r\n person = verify_person(username_or_email)\r\n\r\n if person\r\n update_authentication_token(person, params[:person][:remember_me])\r\n person.last_signed_in_on=DateTime.now\r\n person.save\r\n session[:person_id] = person.id\r\n flash[:notice] = 'Welcome.'\r\n redirect_to :root\r\n else\r\n flash.now[:error] = 'Unknown person. Please check your username and password.'\r\n render :action => \"sign_in\"\r\n end\r\n end", "def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post login_path, session: { email: user.email, password: password, remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end", "def remember_me_for\n return unless remember_me?\n self.class.remember_me_for\n end", "def login\n @user = User.find_or_create_from_auth_hash(auth_hash)\n @user_name = @user.display_name\n\n session[:current_user_id] = @user.id\n\n render :login, :layout => false\n end", "def login(user, password)\n @@user = user\n password2 = password.to_s.gsub(/./, '*')\n debug \"login called for user=#{user} pass=#{password2}\"\n # trash and recreate cookie\n saveCookie(nil)\n cookie = getLoginCookie(user, password)\n if cookie\n saveCookie(cookie)\n else\n debug \"no cookie from login\"\n end\n # get the current (set of) cookie(s) and pretend that login was successful\n return cookie\n end", "def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post login_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end", "def login(auto_refresh: false, force: false, timeout: \"60\")\n return _login(auto_refresh: auto_refresh, force: force, timeout: timeout)\n end", "def log_in_as(user)\n cookies[:remember_token] = user.remember_token\n end", "def _login? redirect_url = nil\n\t\tislogin = _user[:uid] > 0 ? true : false\n\t\tif islogin\n\t\t\t_session_update _user[:sid], _user[:uid]\n\t\telse\n\t\t\tif redirect_url != nil and redirect_url != request.path\n\t\t\t\t@qs[:come_from] = request.path\n\t\t\t\tredirect _url2(redirect_url)\n\t\t\tend\n\t\tend\n\t\tislogin\n\tend", "def login\n \t# Find a user with params\n \tuser = User.authenticate(@credentials[:password], @credentials[:username])\n \tif user\n\t \t# Save them in the session\n\t \tlog_in user\n\t \t# Redirect to articles page\n\t \tredirect_to articles_path\n\telse\n\t\tredirect_to :back, status: :created\n\tend\n end", "def login(params={})\n (current_user) ? link_to_logout(params) : link_to_login(params)\n end", "def detect_auto_login_cookie \r\n logger.info(\"-----------------detecting loginf cookie\")\r\n if session[:user_session].nil? && cookies[WebappConstants::AUTO_LOGIN_COOKIE_NAME]\r\n session[:return_to] = request.request_uri\r\n logger.info(\"doing auto login\")\r\n do_auto_login\r\n #redirect_to :controller=>:session, :action=>do_auto_login\r\n end\r\n \r\n end", "def sign_in_default_user\n user = FactoryGirl.create(:user)\n visit new_user_session_path\n fill_in 'Email', with: user.email\n fill_in 'Password', with: user.password\n # apparently, there are 2 \"Log In\" in main page which confuses Capybara (!!!)\n page.find('.btn.btn-primary').click\n end", "def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post login_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end", "def process_login\r\n # Somebody is probably playing\r\n return dc_render_404 unless ( params.dig(:record, :username) && params.dig(:record, :password) )\r\n\r\n return_to = request.env['HTTP_REFERER'] || '/'\r\n if params[:record][:password].present? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username], active: true)\r\n if user && user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to(params[:return_to] || return_to, allow_other_host: true)\r\n else\r\n clear_login_data # on the safe side\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to return_to\r\nend", "def log_in_as(user, options = {})\n # note the password must match with the users.yml in fixtures folder\n password = options[:password] || \"123456\" # a better way would be to use fetch\n remember_me = options[:remember_me] || \"1\"\n if integration_test? # if it is integration test\n post login_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else # if not integration test, set this\n session[:user_id] = user.id\n end\n end", "def sign_in(user, password, auto_signout)\n remember_token = user.try_sign_in(password)\n if remember_token\n auto_signout_time = auto_signout ? ShiftTime.next_shift_start : 20.years.from_now\n cookies[:auto_signout_time] = auto_signout_time\n flash[:notice] = \"You will be automatically signed out in #{distance_of_time_in_words_to_now(auto_signout_time)}\"\n cookies.permanent[:remember_token] = remember_token\n self.current_user = user\n end\n end", "def login_from_cookie\n return unless cookies[:token] && !logged_in?\n self.current_user = site.user_by_token(cookies[:token])\n # TODO - We allow the token to be changed on GET requests and we log\n # the user in. I haven't fully analyzed the consequences of allowing\n # session and token updates on hostile GET requests triggered by CSRF\n # attacks. If this helps out in some kind of attack, it would affect\n # almost every single web application in existence.\n ActiveRecord::Base.with_writable_records do\n cookies[:token] = {\n :value => self.current_user.reset_token!,\n :expires => self.current_user.token_expires_at\n } if logged_in?\n end\n true\n end", "def check_login\n if !check_authentication\n redirect_to controller: \"account\", action: \"login\"\n end\n end", "def new\n attempt_login\n redirect_to root_path if logged_in?\n end", "def login\n self.class.trace_execution_scoped(['Custom/login/find_user']) do\n @u = (User.find_by_primary_email(params[:username].downcase) || User.find_by_nickname(params[:username].downcase.to_s)) if params[:username]\n end\n\n self.class.trace_execution_scoped(['Custom/login/if_block']) do\n if @u and @u.has_password? and @u.valid_password?(params[:password])\n @user = @u\n elsif @u and (params[:password] == \"anonymous\") and (@u.user_type == User::USER_TYPE[:anonymous])\n @user = @u\n else\n query = {:auth_failure => 1, :auth_strategy => \"that username/password\"}\n query[:redir] = params[:redir] if params[:redir]\n redirect_to add_query_params(request.referer || Settings::ShelbyAPI.web_root, query) and return\n end\n end\n\n # any user with valid email/password is a valid Shelby user\n # this sets up redirect\n self.class.trace_execution_scoped(['Custom/login/sign_in_current_user']) do\n sign_in_current_user(@user)\n end\n redirect_to clean_query_params(@opener_location) and return\n end", "def login_from_session\n self.current_user = User.find_by_id( session[ :user_id ] ) if session[ :user_id ]\n end" ]
[ "0.7886776", "0.7876253", "0.7576935", "0.75066894", "0.73956376", "0.73566896", "0.73438495", "0.7331722", "0.7320255", "0.72132355", "0.71868324", "0.71839726", "0.7167887", "0.7110418", "0.7040266", "0.7032847", "0.6974125", "0.6946315", "0.6893927", "0.68904424", "0.6881217", "0.6867565", "0.6831549", "0.67788255", "0.6760703", "0.67371947", "0.67371947", "0.672637", "0.6723388", "0.67135465", "0.67119426", "0.66909564", "0.66440415", "0.6638322", "0.6607499", "0.660044", "0.660044", "0.660044", "0.6595121", "0.6570948", "0.654934", "0.65349174", "0.653417", "0.65334946", "0.65105253", "0.64757967", "0.6464327", "0.6462562", "0.64621526", "0.6450109", "0.64495724", "0.6436009", "0.64348036", "0.64327246", "0.6424992", "0.64231527", "0.64209884", "0.64209676", "0.6414161", "0.6405273", "0.6401081", "0.6389819", "0.6388376", "0.6383926", "0.6375176", "0.63660705", "0.63594896", "0.63497925", "0.6345", "0.6337286", "0.6336152", "0.6329379", "0.63197315", "0.6318025", "0.63137853", "0.6311216", "0.6300772", "0.62986404", "0.6289909", "0.6281747", "0.6277776", "0.62741166", "0.6263352", "0.6261816", "0.62614596", "0.62592715", "0.6257855", "0.62381923", "0.62366235", "0.6234666", "0.62290174", "0.6227804", "0.62264717", "0.6224041", "0.6221117", "0.62072325", "0.6206708", "0.6203718", "0.6202844", "0.62014467" ]
0.7169219
12
Action for restoring document data from journal document.
def restore_from_journal # Only administrators can perform this operation unless dc_user_has_role('admin') return render inline: { 'msg_info' => (t ('drgcms.not_authorized')) }.to_json, formats: 'js' end # selected fields to hash restore = {} params[:select].each {|key,value| restore[key] = value if value == '1' } result = if restore.size == 0 { 'msg_error' => (t ('drgcms.dc_journal.zero_selected')) } else journal_doc = DcJournal.find(params[:id]) # update hash with data to be restored JSON.parse(journal_doc.diff).each {|k,v| restore[k] = v.first if restore[k] } # determine tables and document ids tables = journal_doc.tables.split(';') ids = (journal_doc.ids.blank? ? [] : journal_doc.ids.split(';') ) << journal_doc.doc_id # find document doc = nil tables.each_index do |i| doc = if doc.nil? (tables[i].classify.constantize).find(ids[i]) else doc.send(tables[i].pluralize).find(ids[i]) end end # restore and save values restore.each { |field,value| doc.send("#{field}=",value) } doc.save # TODO Error checking { 'msg_info' => (t ('drgcms.dc_journal.restored')) } end render inline: result.to_json, formats: 'js' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore_from_journal\r\n # Only administrators can perform this operation\r\n unless dc_user_has_role('admin')\r\n return render plain: { 'msg_info' => (t ('drgcms.not_authorized')) }.to_json\r\n end\r\n # selected fields to hash\r\n restore = {} \r\n params[:select].each { |key,value| restore[key] = value if value == '1' }\r\n result = if restore.size == 0\r\n { 'msg_error' => (t ('drgcms.dc_journal.zero_selected')) }\r\n else\r\n journal_doc = DcJournal.find(params[:id])\r\n # update hash with data to be restored\r\n JSON.parse(journal_doc.diff).each {|k,v| restore[k] = v.first if restore[k] }\r\n # determine tables and document ids\r\n tables = journal_doc.tables.split(';')\r\n ids = (journal_doc.ids.blank? ? [] : journal_doc.ids.split(';') ) << journal_doc.doc_id\r\n # find document\r\n doc = nil\r\n tables.each_index do |i|\r\n doc = if doc.nil?\r\n (tables[i].classify.constantize).find(ids[i])\r\n else\r\n doc.send(tables[i].pluralize).find(ids[i])\r\n end\r\n end\r\n # restore and save values\r\n restore.each { |field,value| doc.send(\"#{field}=\",value) }\r\n doc.save\r\n # TODO Error checking\r\n { 'msg_info' => (t ('drgcms.dc_journal.restored')) }\r\n end\r\n render plain: result.to_json\r\nend", "def restore_archive\n end", "def restore\n end", "def restore\n RESTORE\n end", "def restore!\n restore\n save!(validate: false)\n end", "def restore!\n record = self.restore\n record.save!\n self.destroy\n return record\n end", "def restore\n @post = Post.find(params[:id])\n @post.state = 'draft'\n if @post.save\n flash[:notice] = \"the post have been restored\"\n else\n flash[:errors] = @post.errors\n end\n redirect_to params.merge(:action => :list)\n end", "def restore\n update(archived_at: nil)\n end", "def restore_save version\n @body = version.body\n end", "def _restore(level)\n # Find the most recently stored state of this object. This could be on\n # any previous stash level or in the regular object DB. If the object\n # was created during the transaction, there is no previous state to\n # restore to.\n data = nil\n if @_stash_map\n (level - 1).downto(0) do |lvl|\n break if (data = @_stash_map[lvl])\n end\n end\n if data\n # We have a stashed version that we can restore from.\n _deserialize(data)\n elsif @store.db.include?(@_id)\n # We have no stashed version but can restore from the database.\n db_obj = store.db.get_object(@_id)\n _deserialize(db_obj['data'])\n end\n end", "def restore_archive\n file_id = params[:id]\n file = Archive.find_by(id:file_id)\n file.is_deleted=false\n file.save\n redirect_to archives_show_path\n end", "def restore_patron\r\n Admin.restore params[:id]\r\n redirect_to :action => 'show_patrons' \r\n end", "def restore; end", "def restore_post\n Post.restore(params[:id], :recursive => true)\n flash.keep[:success] = \"Post was restored and is now public again. You can view post here: <a href=\\\"#{post_path(params[:id])}\\\">Restored Post</a>\".html_safe\n redirectPath = request.env[\"HTTP_REFERER\"] ||= posts_path\n redirect_to redirectPath\n end", "def restore_admin\r\n Admin.restore params[:id]\r\n redirect_to :action => 'show_admins' \r\n end", "def restore(*args); end", "def reset!\n self.draft = find_original_file!.read\n save!\n end", "def restore_comment\n Comment.restore(params[:id], :recursive => true)\n flash.keep[:success] = \"Post was restored and is now public again. You can view post here: <a href=\\\"#{post_path(params[:id])}\\\">Restored Post</a>\".html_safe\n redirectPath = request.env[\"HTTP_REFERER\"] ||= posts_path\n redirect_to redirectPath\n end", "def restore(options = {})\n self.class.restore(id, options)\n end", "def restore\n self.archived_at = nil\n end", "def restore\n @item = @collection.items.get(params[:item_id])\n old_item = @item.versions.first(:deleted_at => params[:deleted_at])\n att = old_item.attributes\n att.delete(:deleted_at)\n att.delete(:original_uid)\n att.delete(:id)\n if @item.update(att)\n flash[:notice] = \"Item Restored Successfully!\"\n redirect_to project_collection_item_path(@project, @collection, @item)\n else\n flash[:error] = \"Item failed to restore!\"\n render :show\n end\n end", "def restore(account)\n # takes account as an arg\n memento = find account.id\n # uses the accounts id to find the relevant memento\n account.restore_state memento\n # calls the accounts restore method passing the memento as an arg\n end", "def do_revision\n @record = find_if_allowed(params[:id], :read)\n @current_revision_number = @record.current_revision_number\n @revision_number ||= @current_revision_number\n @rev_record_1 = @record.restore_revision(@revision_number) if @revision_number\n @rev_record_2 = @record.restore_revision(@revision_number - 1) if @revision_number > 1\n end", "def restore_trash (id)\n trash = TrashRecord.find_trash(self, id)\n return trash.restore if trash\n end", "def restore_trash! (id)\n trash = TrashRecord.find_trash(self, id)\n return trash.restore! if trash\n end", "def restore_agent\r\n Admin.restore params[:id]\r\n redirect_to :action => 'show_agents' \r\n end", "def restore_revision! (revision)\n self.class.restore_revision!(self.id, revision)\n end", "def restore_from_checkpoint(checkpoint_data)\n commit_ts = checkpoint_data.commit_ts\n\n if commit_ts.nil? then\n # Nothing to do here since we need to perform a full dump\n return\n end\n\n # Make sure that everything before the last commit timestamp is already indexed\n # to Solr. Possible cases of having these kind of entries include:\n #\n # 1. A newly added collection/field to index was not able to completely consume\n # its backlog.\n checkpoint_data.each do |ns, ts|\n unless ts == commit_ts then\n replay_oplog_and_sync(ns, ts, commit_ts, true)\n end\n end\n end", "def restore\n return unless @session\n @data = @session.data\n end", "def restore_revision!(revision_number)\n self.class.restore_revision!(self.id, revision_number)\n end", "def restore(path, rev)\n params = {\n 'rev' => rev.to_s\n }\n\n response = @session.do_post build_url(\"/restore/#{@root}#{format_path(path)}\", params)\n parse_response(response)\n end", "def cmd_restore argv\n setup argv\n filepath = @hash['filepath']\n clear_existing = to_boolean(@hash['boolean'])\n response = @api.restore(filepath, clear_existing)\n msg response\n return response\n end", "def restore(location, revision)\n @client.restore(location, revision)\n rescue\n puts $! if @@verbose\n nil\n end", "def restore\r\n self.update(deleted: false)\r\n end", "def restore\n if @session\n @data = unmarshalize(@session.data)\n end\n end", "def rollback!\n restore_attributes\n end", "def revert\n end", "def restore\n @fichier = Fichier.find(params[:id])\n @fichier.trash = false\n @fichier.save\n flash[:notice] = 'File was successfully retored from trash.'\n respond_to do |format|\n format.html { redirect_to fichiers_url }\n format.json { head :no_content }\n format.js { render :nothing => true } \n end\n end", "def undo_deletion\n RankParticipant.only_deleted.find(params[:id]).restore\n\n respond_to do |format|\n format.html { redirect_to rank_participants_url, notice: 'RankParticipant was successfully recovered.' }\n format.json { head :no_content }\n end\n end", "def restore_revision!(id, revision_number)\n record = restore_revision(id, revision_number)\n if record\n record.store_revision do\n save_restorable_associations(record, revisionable_associations)\n end\n end\n return record\n end", "def restore_from_dump!\n @agent_context = ScoutApm::Agent.instance.context\n @recorder = @agent_context.recorder\n @store = @agent_context.store\n end", "def restore_checkpoint\n @api.send(\"world.checkpoint.restore()\")\n end", "def restore\n authorize @page\n @version = @page.versions.find(params['version_id'])\n @page = @version.reify\n\n respond_to do |format|\n if @page.save\n format.html { redirect_to page_versions_path(@page), notice: 'Page version was successfully restored.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :versions }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def restore!(date, filename)\n\n object_name = \"#{date.strftime('%Y-%m-%d')}_#{filename}\"\n unless container.object_exists?(object_name)\n raise \"Object #{object_name} not found in container.\"\n end\n if File.exists?(filename)\n raise \"File #{filename} already exists locally, not overwriting.\"\n end\n\n object = container.object(object_name)\n object.save_to_filename(filename)\n\n puts \" -> Restored #{object_name} as #{filename} to the current directory\"\n\n end", "def undo_deletion\n Rank.only_deleted.find(params[:id]).restore\n\n respond_to do |format|\n format.html { redirect_to ranks_url, notice: 'Rank was successfully recovered.' }\n format.json { head :no_content }\n end\n end", "def revert_to_snapshot(name)\n Fission::Action::Snapshot::Reverter.new(self).revert_to_snapshot(name)\n end", "def restore\n path = PathHelper.path(fid)\n begin\n $mg.store_file(dkey, classname, path)\n rescue => e\n raise e if $debug\n end\n end", "def revert\n @update_span = params[:update]\n @object = referenced_object\n if current_user.role? :superadmin\n @version = PaperTrail::Version.find(params[:id])\n @version.reify.save!\n @object = @Klass.find(@version.item_id)\n authorize!(:revert, @object) if cancan_enabled?\n respond_to do |format|\n format.html { } unless @Klass.not_accessible_through_html?\n format.js { render :close }\n end\n end\n end", "def restore(*args)\n call_engines_method(:restore, *args)\n end", "def restore_revision(id, revision_number)\n revision_record = find_revision(id, revision_number)\n return revision_record.restore(self) if revision_record\n end", "def restore\n @list.activate(with: :list_items)\n\n respond_to do |format|\n format.html { redirect_to trashed_lists_url, notice: \"List #{@list.name} was successfully restored.\" }\n format.json { head :no_content }\n end\n end", "def revert!\n published_pid = PidUtils.to_published(pid)\n draft_pid = PidUtils.to_draft(pid)\n\n if self.class.exists? published_pid\n destroy_draft_version!\n deep_copy_fedora_object from: published_pid, to: draft_pid\n end\n end", "def revert!\n track_changes_save = self.class.track_changes_save\n self.class.track_changes_save = false\n self.transaction do\n content_versions.each do | c |\n if c.content.version == c.version\n c.content.revert_to(c)\n end\n end\n content_key_versions.each do | c |\n if c.content_key.version == c.version\n c.content_key.revert_to(c)\n end\n end\n end\n ensure \n self.class.track_changes = track_changes_save\n end", "def undo\n\n if @upload.nil?\n notify_user(:alert, \"Record not found!\")\n redirect_to uploads_url\n return\n end\n\n @upload.reset\n @upload.update(file_status_type: FileStatusType.find_by(name: \"Reverted\"))\n\n notify_user(:notice, \"Upload has been reverted.\")\n\n # show the original upload\n redirect_to(upload_url(@upload))\n\n end", "def restore(*args)\n argv = to_pointer([\"restore\"] + args)\n rrd_restore(args.size+1, argv) == 0\n ensure\n free_pointers\n end", "def revert\n @version = PaperTrail::Version.find(params[:id])\n if @version.reify\n @version.reify.save!\n else\n @version.item.destroy\n end\n link_name = params[:redo] == \"true\" ? \"undo\" : \"redo\"\n link = view_context.link_to(link_name, revert_version_path(@version.next, :redo => !params[:redo]), class: \"btn btn-warning\", :method => :post)\n redirect_to :back, :notice => \"Undid #{@version.event}. #{link}\".html_safe\n end", "def restore_revision! (id, revision)\n record = restore_revision(id, revision)\n if record\n record.store_revision do\n save_restorable_associations(record, revisionable_associations)\n end\n end\n return record\n end", "def rollback opts = {}\n update opts.merge(:data => xml.rollback)\n end", "def payload_for_reverted\n super\n end", "def rollback\n self.revert_to self.previous_version\n end", "def restore(snapshot, signatures, validation_token = nil, relations = nil)\n @snapshot = snapshot\n @signatures = signatures\n @validation_token = validation_token\n @relations = relations\n model = JSON.parse(Crypto::Bytes.new(snapshot).to_s)\n restore_from_snapshot_model(model)\n end", "def restore path_to_database\n path_to_database.sub Dir.pwd, \"\"\n path_to_database.sub \"/\", \"\"\n \n @database ||= Database.new(path_to_database, @log)\n @entries.each do |entry|\n unless @database[entry.sha512].nil?\n oldfile = entry.file\n entry.add_file @database[entry.sha512]\n @log.puts \"[II] restored #{ oldfile } => #{ entry.file }\"\n puts \"[II] restored #{ oldfile } => #{ entry.file }\" if $VERBOSE\n else\n @log.puts \"[WW] couldn't find and restore #{ entry.file } in Database\"\n puts \"[WW] couldn't find and restore #{ entry.file } in Database\" if $VERBOSE\n end\n end\n end", "def revert(evt)\n version = Version.find(evt[:id])\n if version.reify\n version.reify.save!\n else\n version.item.destroy\n end\n is_redo = evt[:redo] == 'true'\n trigger :flash, :notice => undo_notice(is_redo, version)\n trigger :reload_grid\n render :nothing => true\n end", "def restore(body = {}, params = {})\n response = client.post \"/_snapshot/{repository}/{snapshot}/_restore\", update_params(params, body: body, action: \"snapshot.restore\", rest_api: \"snapshot.restore\")\n response.body\n end", "def restore(path)\n raise NotImplementedError\n end", "def do_restore(restore_obj)\n aws_init\n restore_obj.each do |key, value|\n if value[:retain_versions].empty?\n # discard all version\n value[:obj].delete\n else\n value[:retain_versions].sort_by! { |x| x.last_modified }\n restore_to = value[:retain_versions].last\n if restore_to.delete_marker?\n value[:obj].delete\n else\n # Don't remove any version, overwrite it with the content so we can roll back\n # TODO: streaming content, + log the process + restore from fail point\n @bucket.objects.create(key, restore_to.read)\n end\n end\n end\n end", "def restore\n _update_hash = {}\n object.attributes.reject {|k,v| object.class.ignore_fields_on_restore.include?(k)}.each do |key, value|\n _update_hash.merge! get_restore_hash(key,value)\n end\n object.update_attributes(parameterize(_update_hash))\n end", "def restore(restore_id, &block)\n get \"/restore/#{restore_id}/\", nil, &block\n end", "def unarchive\n perform_action(:post, 'unarchive')\n end", "def rollback!\n self.revert_to! self.previous_version\n end", "def trash_document(guid)\n post \"/api/documents/#{guid}/trash.xml\", {}\n end", "def restore( page )\n load page, take_snapshot: false\n end", "def rollback()\n #This is a stub, used for indexing\n end", "def rollback\n objects.clear\n load\n finish_transaction\n end", "def xRestoreDump()\n puts \"Back up commencing...\"\n Dir.chdir('/Users/jeydurai')\n system('start_mongorestore.bat')\n end", "def restore\n authorize @page\n @version = @page.versions.find(params['version_id'])\n @page = @version.reify\n @page.reify_page_slots!\n\n respond_to do |format|\n if @page.save\n format.html { redirect_to page_versions_path(@page), notice: 'Page version was successfully restored.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :versions }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def restore(key, data_store = nil, default = nil)\n data_store.transaction do\n data_store[key.to_sym] || default\n end\n end", "def restore\n parse\n end", "def restore(name)\n Session.instance.load name\n end", "def restore(id)\n http.put(\"#{endpoint_base}/#{id}/restore\") do |response|\n respond_with_object response\n end\n end", "def save_draft\n Rails.logger.debug('Actioning Save Draft')\n @slft_return = load_step\n Rails.logger.debug('Wizard Loaded')\n @slft_return.save_draft(current_user)\n Rails.logger.debug('Out of Save')\n @post_path = '.'\n wizard_save(@slft_return)\n end", "def wRestoreDump()\n puts \"Back up commencing...\"\n Dir.chdir('/Users/jeydurai')\n system('start_mongorestore.bat')\n end", "def restore_from_snapshot_model(snapshot_model)\n self.identity = snapshot_model['identity']\n self.identity_type = snapshot_model['identity_type']\n self.public_key = snapshot_model['public_key']\n self.scope = snapshot_model['scope']\n self.data = snapshot_model.fetch('data', {})\n self.info = snapshot_model['info']\n end", "def revert_to(version_hash)\n tree = self.git.tree(version_hash)\n dir = tree.contents[0] # posts/\n data = dir.contents[0] # 6/\n data.contents.each do |f| # title.txt\n field = f.name.gsub(\".txt\",\"\")\n send(\"#{field.to_sym}=\", f.data)\n end\n save # hm, not sure if I want to do this\n end", "def restore\n self.suspended = false\n save(:validate => false)\n end", "def restore_previous_version_to_draft(object_id, revision_id, opts = {})\n data, _status_code, _headers = restore_previous_version_to_draft_with_http_info(object_id, revision_id, opts)\n data\n end", "def rollback\n super\n each { |transition| transition.machine.write(object, :event, transition.event) unless transition.transient? }\n end", "def rollback\n end", "def restore_school_year(school_year)\n school_year.restore!\n school_year.save!\n end", "def on_file_set_restored(event)\n ContentRestoredVersionEventJob\n .perform_later(event[:file_set], event[:user], event[:revision])\n end", "def set_journal\n @journal = current_user.records.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def set_journal\n @journal = Journal.find(params[:id])\n end", "def restore(path, rev, opts = {})\n input_json = {\n path: path,\n rev: rev,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/restore\", input_json)\n Dropbox::API::File.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end" ]
[ "0.7390467", "0.63006765", "0.62760204", "0.62753516", "0.61917746", "0.6177054", "0.61600447", "0.615471", "0.60448", "0.59916365", "0.59766567", "0.5932643", "0.58583075", "0.5843801", "0.57998765", "0.57667685", "0.5734534", "0.5678913", "0.56276613", "0.5625284", "0.5624609", "0.5603275", "0.5598932", "0.55787104", "0.5549655", "0.554914", "0.55463177", "0.5535081", "0.5524895", "0.5510117", "0.55026305", "0.5501406", "0.5492057", "0.5491794", "0.5482734", "0.5476528", "0.5475811", "0.5464011", "0.5441604", "0.542332", "0.5398411", "0.53803146", "0.53657645", "0.5359812", "0.5346613", "0.5346515", "0.532761", "0.5314559", "0.5312796", "0.53053105", "0.5304253", "0.5299595", "0.52859604", "0.52775913", "0.5276172", "0.5272719", "0.5260578", "0.5259536", "0.52537656", "0.5247416", "0.5246482", "0.5243577", "0.5232919", "0.5226253", "0.5221746", "0.5216823", "0.51880527", "0.51747376", "0.5171157", "0.5168206", "0.5146885", "0.5140191", "0.513383", "0.5128003", "0.51224476", "0.51136327", "0.5102102", "0.5092896", "0.50872934", "0.50868", "0.5084628", "0.50809103", "0.50798935", "0.5079748", "0.507137", "0.50366926", "0.5028565", "0.5020327", "0.50158083", "0.49997014", "0.49994352", "0.49966556", "0.49966556", "0.49966556", "0.49966556", "0.49966556", "0.49966556", "0.49966556", "0.49966556", "0.49963853" ]
0.73040944
1
Copy current record to clipboard as json text. It will actually ouput an window with data formatted as json.
def copy_clipboard # Only administrators can perform this operation return render(text: t('drgcms.not_authorized') ) unless dc_user_has_role('admin') # respond_to do |format| # just open new window to same url and come back with html request format.json { dc_render_ajax(operation: 'window', url: request.url ) } format.html do doc = dc_find_document(params[:table], params[:id], params[:ids]) text = "<br><br>[#{params[:table]},#{params[:id]},#{params[:ids]}]<br>" render text: text + doc.as_document.to_json end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_clipboard\r\n # Only administrators can perform this operation\r\n return render(plain: t('drgcms.not_authorized') ) unless dc_user_can(DcPermission::CAN_ADMIN,'dc_site')\r\n\r\n respond_to do |format|\r\n # just open new window to same url and come back with html request\r\n format.json { dc_render_ajax(operation: 'window', url: request.url ) }\r\n \r\n format.html do\r\n table = CmsHelper.table_param(params)\r\n doc = dc_find_document(table, params[:id], params[:ids])\r\n text = '<style>body {font-family: monospace;}</style><pre>'\r\n text << \"JSON:<br>[#{table},#{params[:id]},#{params[:ids]}]<br>#{doc.as_document.to_json}<br><br>\"\r\n text << \"YAML:<br>#{doc.as_document.to_hash.to_yaml.gsub(\"\\n\", '<br>')}</pre>\"\r\n render plain: text\r\n end\r\n end \r\nend", "def paste_clipboard\r\n # Only administrators can perform this operation\r\n return render(plain: t('drgcms.not_authorized') ) unless dc_user_can(DcPermission::CAN_ADMIN,'dc_site')\r\n\r\n result = ''\r\n respond_to do |format|\r\n # just open new window to same url and come back with html request\r\n format.html { return render('paste_clipboard', layout: 'cms') }\r\n format.json {\r\n table, id, ids = nil\r\n params[:data].split(\"\\n\").each do |line|\r\n line.chomp!\r\n next if line.size < 5 # empty line. Skip\r\n\r\n begin\r\n if line[0] == '[' # id(s)\r\n result << \"<br>#{line}\"\r\n line = line[/\\[(.*?)\\]/, 1] # just what is between []\r\n table, id, ids = line.split(',')\r\n elsif line[0] == '{' # document data\r\n result << process_document(line, table, id, ids)\r\n end\r\n rescue Exception => e \r\n result << \" Runtime error. #{e.message}\\n\"\r\n break\r\n end\r\n end\r\n }\r\n end\r\n dc_render_ajax(div: 'result', value: result )\r\nend", "def paste_clipboard\r\n# Only administrators can perform this operation \r\n return render(text: t('drgcms.not_authorized') ) unless dc_user_has_role('admin')\r\n \r\n result = ''\r\n respond_to do |format|\r\n# just open new window to same url and come back with html request \r\n format.html { return render('paste_clipboard', layout: 'cms') }\r\n format.json {\r\n table, id, ids = nil\r\n params[:data].split(\"\\n\").each do |line|\r\n line.chomp!\r\n next if line.size < 5 # empty line. Skip\r\n begin\r\n if line[0] == '[' # id(s)\r\n result << \"<br>#{line}\"\r\n line = line[/\\[(.*?)\\]/, 1] # just what is between []\r\n table, id, ids = line.split(',')\r\n elsif line[0] == '{' # document data\r\n result << process_document(line, table, id, ids)\r\n end\r\n rescue Exception => e \r\n result << \" Runtime error. #{e.message}\\n\"\r\n break\r\n end\r\n end\r\n }\r\n end\r\n dc_render_ajax(div: 'result', value: result )\r\nend", "def do_clipboard_paste\n dat = if Wx::PLATFORM == \"WXMAC\" \n # XXX i feel dirty\n `pbpaste`\n else\n dobj=RawDataObject.new\n Wx::Clipboard.open {|clip| clip.fetch dobj}\n dobj.raw_data\n end\n\n self.gui_set_value(self.cur_pos, dat) if dat and dat.size > 0\n end", "def copy_to_clipboard\n end", "def show\n @clipboard = find_clipboard\n end", "def to_clipboard\n #prettified = self.pretty_inspect.strip\n prettified = self.to_s\n stringified = self.to_s\n printable = (\n if prettified.length > 80 then\n prettified.slice(0, 80) + '...'\n else\n prettified\n end\n ).inspect\n $clipboard.write(stringified)\n $stderr.puts(\"to_clipboard: wrote #{printable} to clipboard\")\n return nil\n end", "def paste; clipboard_paste; end", "def do_copy\n @editor.value = @current_copycode\n @editor.focus\n end", "def do_clipboard_copy\n return nil unless sel=@selection and dat=@data[sel]\n # XXX i feel dirty\n if Wx::PLATFORM == \"WXMAC\"\n IO.popen(\"pbcopy\", \"w\") {|io| io.write dat}\n stat = $?.success?\n else\n dobj = RawDataObject.new(dat)\n stat = Wx::Clipboard.open {|clip| clip.place dobj}\n end\n return stat\n end", "def render_textarea_json(data)\n headers[\"Content-Type\"] = \"text/html; charset=utf-8\"\n render :text => \"<textarea>#{data.to_json}</textarea>\" \n end", "def paste\n\t\t\t$ruvim.insert $ruvim.buffers[:copy].data\n\t\t\t$ruvim.editor.redraw\n\t\tend", "def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end", "def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end", "def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def copy_output\n copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\\d+ (.*)/, '\\1')\n \"The session output history has been copied to the clipboard.\"\n end", "def copy(sender)\n filteredData[tableView.selectedRow].symbol.sendToPasteboard\n end", "def pbpaste\n Clipboard.paste\nend", "def copyFromClipboard \n \"copyFromClipboard\" \n end", "def copy_raw\n Win32API.push_text_in_clipboard(((@list.map {|e| e.raw}).join(\"\\n\") + \"\\0\").to_ascii)\n end", "def copy(item)\n copy_command = darwin? ? \"pbcopy\" : \"xclip -selection clipboard\"\n\n Kernel.system(\"echo '#{item.value.gsub(\"\\'\",\"\\\\'\")}' | tr -d \\\"\\n\\\" | #{copy_command}\")\n\n \"Boom! We just copied #{item.value} to your clipboard.\"\n end", "def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend", "def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend", "def formatJSON\n # @formattedContents = .... whatever puts it into JSON\n end", "def clipboard\n IO.popen('pbcopy', 'w') {|f| f << selected_items.map(&:path).join(' ')} if osx?\n end", "def copy_bbcode\n str = EventPrinter::BBcode::head(@event.printed_name)\n str << (@list.map { |e| e.bbcode }).join(\"\\n\")\n str << EventPrinter::BBcode::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end", "def _cp(obj = Readline::HISTORY.entries[-2], *options)\n if obj.respond_to?(:join) && !options.include?(:a)\n if options.include?(:s)\n obj = obj.map { |element| \":#{element.to_s}\" }\n end\n out = obj.join(\", \")\n elsif obj.respond_to?(:inspect)\n out = obj.is_a?(String) ? obj : obj.inspect\n end\n \n if out\n IO.popen('pbcopy', 'w') { |io| io.write(out) } \n \"copied!\"\n end\nend", "def paste\n # no authorization applied as the method must always render\n if @activity.changeable?(current_visitor)\n @original = clipboard_object(params)\n if (@original)\n @component = @original.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at], :include => :pages\n if (@component)\n # @component.original = @original\n @container = params[:container] || 'activity_sections_list'\n @component.name = \"copy of #{@component.name}\"\n @component.deep_set_user current_visitor\n @component.activity = @activity\n @component.save\n end\n end\n end\n render :update do |page|\n page.insert_html :bottom, @container, render(:partial => 'section_list_item', :locals => {:section => @component})\n page.sortable :activity_sections_list, :handle=> 'sort-handle', :dropOnEmpty => true, :url=> {:action => 'sort_sections', :params => {:activity_id => @activity.id }}\n page[dom_id_for(@component, :item)].scrollTo()\n page.visual_effect :highlight, dom_id_for(@component, :item)\n end\n end", "def print_json_obj\n \n end", "def write_json(a)\n write \"(\" + a.write_json_item + \")\\n\"\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n end", "def pbpaste\n a = IO.popen(\"osascript -e 'the clipboard as unicode text' | tr '\\r' '\\n'\", 'r+').read\n a.strip.force_encoding(\"UTF-8\")\nend", "def copy\n out = ''\n\n Selection.each do |dd|\n docu = dd.cite_key.get\n docu.strip!\n out << \"[@#{docu}] \"\n end\n\n pbcopy(out.strip)\n growl(\"#{Selection.size} citation references copied to the clipboard\")\nend", "def export\n send_data current_user.records.select(:json).order('updated_at desc').collect(&:json).to_json, filename: 'records.json'\n end", "def copy\n obj = self.dup\n obj.attributes = {\n :name => \"Copy of #{name}\",\n :active => false,\n :created_at => nil,\n :updated_at => nil\n }\n obj\n end", "def render_copy(code_str, display_str = nil)\n display_str = code_str if !display_str \n stack :margin_bottom => 12 do \n background rgb(210, 210, 210), :curve => 4\n para display_str, {:size => 9, :margin => 12, :font => 'monospace'}\n stack :top => 0, :right => 2, :width => 70 do\n background \"#8A7\", :margin => [0, 2, 0, 2], :curve => 4 \n para link(\"Copy this\", :stroke => \"#eee\", :underline => \"none\") { self.clipboard = code_str },\n :margin => 4, :align => 'center', :weight => 'bold', :size => 9\n end\n end\n end", "def render\n Oj.dump(to_json)\n end", "def push_text_in_clipboard(text)\n OpenClipboard.call(0)\n EmptyClipboard.call()\n hmem = GlobalAlloc.call(0x42, text.length)\n mem = GlobalLock.call(hmem)\n Memcpy.call(mem, text, text.length)\n SetClipboardData.call(1, hmem) # Format CF_TEXT = 1\n GlobalFree.call(hmem)\n CloseClipboard.call()\n self\n end", "def pbcopy(text)\n # work around, ' wrecks havoc on command line, but also caused some weird regexp substitution\n rtf = text.index('{\\rtf1')\n File.open(\"/tmp/script.scpt\", 'w') do |f|\n if rtf\n f << text\n else\n f << \"set the clipboard to \\\"#{text}\\\"\"\n end\n end\n if rtf\n `cat /tmp/script.scpt | pbcopy -Prefer rtf`\n else\n `osascript /tmp/script.scpt`\n end\nend", "def copy_html\n str = EventPrinter::HTML::head(@event.printed_name)\n str << (@list.map { |e| e.html }).join\n str << EventPrinter::HTML::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end", "def copy(obj)\n obj.to_s.copy\nend", "def display!\n escaped = self.map(&:to_json)\n puts(\"[\" + escaped.join(\",\") + \"],\\n\\n\") || $stdout.flush\n self.clear\n end", "def puts something\n command = 'pbcopy'\n command << \" -pboard #{@board}\" if @board\n command << \" -Prefer #{@format}\" if @format\n out = IO::popen command, 'w+'\n out.print something\n out.close\n @current = something\n end", "def copyToClipboard _args\n \"copyToClipboard _args;\" \n end", "def json_get\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n write_json @note if @note\n render :nothing => true\n end", "def render\n Oj.dump(to_json)\n end", "def find_clipboard\n return session[:clipboard] ||= Clipboard.new\n end", "def dialog_copy_editor\n assert_privileges(\"dialog_copy_editor\")\n record_to_copy = find_record_with_rbac(Dialog, checked_or_params)\n @record = Dialog.new\n javascript_redirect(:controller => 'miq_ae_customization',\n :action => 'editor',\n :copy => record_to_copy.id,\n :id => @record.id)\n end", "def cp(string)\n `echo \"#{string} | pbcopy`\n puts 'copied to clipboard'\nend", "def copy(str = nil)\n clipboard_copy(:string => (!$stdin.tty? ? $stdin.read : str))\n end", "def copy_timestamp\n data[:copy_timestamp]\n end", "def get_clipboard_contents\n out = \"\"\n\n Open3.popen3(\"xclip -o -selection clipboard\") do |_, o, _, _|\n out = o.read.strip\n end\n\n out\n end", "def new\n @copy_target = CopyTarget.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @copy_target }\n end\n end", "def show\n @copy_target = CopyTarget.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @copy_target }\n end\n end", "def pbcopy(str)\n IO.popen('pbcopy', 'r+') {|io| io.puts str }\n output.puts \"-- Copy to clipboard --\\n#{str}\"\nend", "def do_clipboard_cut\n if do_clipboard_copy()\n pos = @selection.first\n self.gui_set_value(nil, '')\n self.cur_pos = pos\n end\n end", "def to_textile\n \n \n headings(@workingcopy)\n structure(@workingcopy)\n text_formatting(@workingcopy)\n entities(@workingcopy)\n tables(@workingcopy)\n @workingcopy = CGI::unescapeHTML(@workingcopy)\n @workingcopy\n \n end", "def json(obj)\n obj.to_json.html_safe\n end", "def json(obj)\n obj.to_json.html_safe\n end", "def result\n ActiveSupport::JSON.encode(@buffer)\n end", "def write_epilogue\n puts @json.to_json\n super\n end", "def copy_reference\n @copy_reference ||= @data['copy_reference']\n end", "def as_json\n record\n end", "def pbcopy(str)\n IO.popen('pbcopy', 'r+') {|io| io.puts str }\n puts \"-- Copy to clipboard --\\n#{str}\"\nend", "def setData(iCopyType, iCopyID, iSerializedSelection)\n @Data = Marshal.dump( [ iCopyType, iCopyID, iSerializedSelection ] )\n if (iSerializedSelection == nil)\n @DataAsText = nil\n else\n @DataAsText = iSerializedSelection.getSingleContent\n end\n end", "def save_as_JSON\n @result_pretty = JSON.pretty_generate(@result_scrap)\n File.open(\"./db/#{@name}.json\",\"w\") do |f|\n f.write(@result_pretty)\n end\n end", "def request_copy\n @reader = Reader.new\n\n respond_to do |format|\n format.html # request_copy.html.erb\n format.json { render json: @reader }\n end\n end", "def paste\n # no authorization applied as the method must always render\n if @section.changeable?(current_visitor)\n @original = clipboard_object(params)\n if @original\n @container = params[:container] || 'section_pages_list'\n if @original.class == Page\n @component = @original.duplicate\n else\n @component = @original.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at]\n @component.name = \"copy of #{@original.name}\"\n end\n if (@component)\n # @component.original = @original\n @component.section = @section\n @component.save\n end\n @component.deep_set_user current_visitor\n end\n end\n render :update do |page|\n page.insert_html :bottom, @container, render(:partial => 'page_list_item', :locals => {:page => @component})\n page.sortable :section_pages_list, :handle=> 'sort-handle', :dropOnEmpty => true, :url=> {:action => 'sort_pages', :params => {:section_id => @section.id }}\n page[dom_id_for(@component, :item)].scrollTo()\n page.visual_effect :highlight, dom_id_for(@component, :item)\n end\n end", "def copy_to_string options = {}\n data = ''\n self.copy_to(nil, options){|l| data << l }\n if options[:format] == :binary\n data.force_encoding(\"ASCII-8BIT\")\n end\n data\n end", "def buffer\n $curwin.buffer\n end", "def raw_json(*)\n # We need to pass no arguments to `Oj::StringWriter` because it expects 0 arguments\n # because its method definition `oj_dump_raw_json` defined in the C classes is defined\n # without arguments. Oj gets confused because it checks if the class is `Oj::StringWriter`\n # and if it is, then it passes 0 arguments, but when it's not (e.g. `NonBlankJsonWriter`)\n # then it passes both. So in this case, we're calling super() to `Oj::StringWriter` with\n # two arguments.\n #\n # https://github.com/ohler55/oj/commit/d0820d2ac1a72584329bc6451d430737a27f99ac#diff-854d0b67397d7006482043d1202c9647R532\n super()\n end", "def paste(str)\n send_command_to_control(\"EditPaste\", str)\n end", "def process(record)\n $stdout.puts record\n end", "def to_json\n io = StringIO.new << \"{\"\n\n io << JSON.create_id.to_json << \":\" << self.class.name.to_json << \",\"\n\n @data.each {|key, value|\n io << key.to_json.to_s << \":\" << value.to_json << \",\"\n }\n\n io.seek(-1, IO::SEEK_CUR)\n io << \"}\"\n\n io.string\n end", "def create_snapshot\n @current_snapshot = @bitmap.to_json if @bitmap\n end", "def save(file = RC_FILE)\n @original['todo']['notes'] = @notes\n json = @original.to_json\n open(file, 'wb+') { |f| f.write(json) }\n end", "def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end", "def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end", "def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end", "def json_reflect\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n h = {}\n params.each do |x,y|\n h[x]=y\n end\n write_json h\n end", "def make_copy\n\t\t\tMarshal.load(Marshal.dump(self))\n\t\tend", "def to_string_copy(exception = nil)\n res = super(context,self,exception)\n return JS.read_string(res)\n end", "def to_json(repr = nil)\n @js.to_s\n end", "def attach_console(autohide: true)\n\n @window.activate()\n open_web_console(); sleep 1\n\n clipboard = Clipboard.paste\n Clipboard.copy javascript(); sleep 1\n ctrl_v(); sleep 0.5; carriage_return()\n\n close_web_console() if autohide\n Clipboard.copy clipboard\n\n end", "def textcopy(input)\n\tosascript <<-END\n\t\ttell application \"Copied\"\n\t\t\tsave \"#{input}\"\n\t\tend tell\n\tEND\nend", "def notifyClipboardContentChanged\n updateCommand(Wx::ID_PASTE) do |ioCommand|\n if (@Clipboard_CopyMode == nil)\n # The clipboard has nothing interesting for us\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n # Cancel eventual Copy/Cut pending commands\n notifyCancelCopy\n # Notify everybody\n notifyRegisteredGUIs(:onClipboardContentChanged)\n elsif (@Clipboard_CopyMode == Wx::ID_DELETE)\n # Check that this message is adressed to us for real (if many instances of PBS are running, it is possible that some other instance was cutting things)\n if (@CopiedID == @Clipboard_CopyID)\n # Here we have to take some action:\n # Delete the objects marked as being 'Cut', as we got the acknowledge of pasting it somewhere.\n if (@CopiedMode == Wx::ID_CUT)\n if (!@Clipboard_AlreadyProcessingDelete)\n # Ensure that the loop will not come here again for this item.\n @Clipboard_AlreadyProcessingDelete = true\n executeCommand(Wx::ID_DELETE, {\n :parentWindow => nil,\n :selection => @CopiedSelection,\n :deleteTaggedShortcuts => false,\n :deleteOrphanShortcuts => false\n })\n # Then empty the clipboard.\n Wx::Clipboard.open do |ioClipboard|\n ioClipboard.clear\n end\n # Cancel the Cut pending commands.\n notifyCutPerformed\n notifyRegisteredGUIs(:onClipboardContentChanged)\n @Clipboard_AlreadyProcessingDelete = false\n end\n else\n log_bug 'We have been notified of a clipboard Cut acknowledgement, but no item was marked as to be Cut.'\n end\n end\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n else\n lCopyName = nil\n case @Clipboard_CopyMode\n when Wx::ID_CUT\n lCopyName = 'Move'\n when Wx::ID_COPY\n lCopyName = 'Copy'\n else\n log_bug \"Unsupported copy mode from the clipboard: #{@Clipboard_CopyMode}.\"\n end\n if (@Clipboard_CopyID != @CopiedID)\n # Here, we have another application of PBS that has put data in the clipboard. It is not us anymore.\n notifyCancelCopy\n end\n if (lCopyName != nil)\n # Activate the Paste command with a cool title\n ioCommand[:Enabled] = true\n ioCommand[:Title] = \"Paste #{@Clipboard_SerializedSelection.getDescription} (#{lCopyName})\"\n else\n # Deactivate the Paste command, and explain why\n ioCommand[:Enabled] = false\n ioCommand[:Title] = \"Paste (invalid type #{@Clipboard_CopyMode}) - Bug ?\"\n end\n notifyRegisteredGUIs(:onClipboardContentChanged)\n end\n end\n end", "def to_s\n text =\"\"\n {'type'=>@type, 'copy'=>(@copy) ? \":copy\" : nil, 'target'=>@target}.each do |name,item|\n if ['target'].index(name)\n text += \"\\\"#{item}\\\" \" unless item.nil?\n else\n text += \"#{item} \" unless item.nil?\n end\n\n end\n text[text.length-1] = \";\" if text.length > 0\n text\n end", "def process record\n $stdout.puts record\n $stdout.flush\n end", "def print_b2json(io)\n while not io.eof? do\n bsonobj = BSON.read_bson_document(io)\n Yajl::Encoder.encode(bsonobj, STDOUT)\n STDOUT << \"\\n\"\n end\nend", "def copy\n self.public_send('|', 'pbcopy')\n self\n end", "def to_jq_record\n {\n \"id\" => read_attribute(:id),\n \"description\" => read_attribute(:description),\n \"name\" => read_attribute(:record),\n \"size\" => record.size,\n \"url\" => '/download_record?id=' + read_attribute(:id).to_s,\n \"thumbnail_url\" => is_image? ? '/thumbnail?id=' + read_attribute(:id).to_s : \"/assets/icon_file_lock_24.png\",\n \"delete_url\" => records_path.to_s + \"/\" + self.id.to_s,\n \"delete_type\" => \"DELETE\" \n }\n end", "def to_textile\n headings(@workingcopy)\n structure(@workingcopy)\n text_formatting(@workingcopy)\n entities(@workingcopy)\n tables(@workingcopy)\n @workingcopy = lists(@workingcopy)\n image_links(@workingcopy)\n links(@workingcopy)\n @workingcopy = CGI::unescapeHTML(@workingcopy)\n @workingcopy\n end", "def save\n File.open(filepath, 'w') do |file|\n file.write to_json + \"\\n\"\n end\n end", "def show\n render json: @capture\n end", "def save\n File.write @name, Oj.dump(as_json)\n end", "def to_json\n @object.marshal_dump.to_json\n end", "def create\n \n @copy = Copy.new(copy_params)\n\n respond_to do |format|\n if @copy.save\n format.html { redirect_to @copy, notice: \"Copy was successfully created.\" }\n format.json { render :show, status: :created, location: @copy }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @copy.errors, status: :unprocessable_entity }\n end\n end\n end", "def paste(at: caret)\n editable? and @native.paste_text(at.to_i)\n end" ]
[ "0.62859005", "0.6171048", "0.60664254", "0.5919167", "0.5677381", "0.56047636", "0.5596036", "0.559588", "0.54933274", "0.54467565", "0.5411955", "0.5361212", "0.5313138", "0.5313138", "0.5313138", "0.53060913", "0.53060913", "0.53060913", "0.53060913", "0.52356064", "0.5222407", "0.51836437", "0.51083374", "0.5082171", "0.50780517", "0.50780517", "0.50625104", "0.5030355", "0.5013158", "0.5001206", "0.49913016", "0.49779636", "0.49538445", "0.49376622", "0.49332893", "0.48887774", "0.48833767", "0.48623604", "0.48440942", "0.48423934", "0.48098832", "0.4804395", "0.48038167", "0.48027086", "0.4801016", "0.47956127", "0.47323415", "0.472295", "0.4715624", "0.46814615", "0.46787795", "0.46750706", "0.46748343", "0.46631792", "0.46584982", "0.46490723", "0.46466833", "0.46423554", "0.46124047", "0.46077603", "0.4607664", "0.4607491", "0.45994434", "0.4597235", "0.4585041", "0.4578989", "0.45784402", "0.45761824", "0.45698392", "0.4568983", "0.45682883", "0.45611", "0.45602125", "0.45589077", "0.45498037", "0.4547844", "0.45462078", "0.45451236", "0.45376855", "0.45376855", "0.45376855", "0.4530445", "0.45125967", "0.45100576", "0.4507413", "0.4499076", "0.4498865", "0.44915882", "0.44915405", "0.44906804", "0.449004", "0.44749367", "0.44737568", "0.44656926", "0.4465438", "0.44595492", "0.44555107", "0.4452646", "0.4449047", "0.44409868" ]
0.57165
4