query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
sequencelengths
19
19
metadata
dict
PATCH/PUT /rationales/1 PATCH/PUT /rationales/1.json
def update respond_to do |format| if @rationale.update(rationale_params) format.html { redirect_to position_rationale_path, notice: 'Rationale was successfully updated.' } format.json { render :show, status: :ok, location: @rationale } else format.html { render :edit } format.json { render json: @rationale.errors, status: :unprocessable_entity } end end end
[ "def update\n respond_to do |format|\n if @rationale.update(rationale_params)\n format.html { redirect_to @rationale, notice: 'Rationale was successfully updated.' }\n format.json { render :show, status: :ok, location: @rationale }\n else\n format.html { render :edit }\n format.json { render json: @rationale.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lenguage = Lenguage.find(params[:id])\n\n respond_to do |format|\n if @lenguage.update_attributes(params[:lenguage])\n format.html { redirect_to @lenguage, notice: 'Lenguage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lenguage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client_sex = ClientSex.find(params[:id])\n\n respond_to do |format|\n if @client_sex.update_attributes(params[:client_sex])\n format.html { redirect_to @client_sex, notice: 'Client sex was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_sex.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_glossary = MyGlossary.find(params[:id])\n\n respond_to do |format|\n if @my_glossary.update_attributes(params[:my_glossary])\n format.html { redirect_to @my_glossary, notice: 'My glossary was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_glossary.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n word = Word.find(params[:id])\n word.gender = params[:gender]\n if word.save\n head :ok\n end\n end", "def update\n respond_to do |format|\n if @nomenclature.update(nomenclature_params)\n format.html { redirect_to @nomenclature, notice: 'Изменения успешно внесены.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nomenclature.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @set_gender.update(set_gender_params)\n format.html { redirect_to set_genders_url, notice: 'Set gender was successfully updated.' }\n format.json { render :index, status: :ok, location: @set_genders }\n else\n format.html { render :edit }\n format.json { render json: @set_gender.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sex = Sex.find(params[:id])\n\n respond_to do |format|\n if @sex.update_attributes(params[:sex])\n format.html { redirect_to @sex, :notice => 'Sex was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sex.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @relational.update(relational_params)\n format.html { redirect_to rental_relationals_path(@rental), notice: '予約の変更が完了しました!!' }\n format.json { render :show, status: :ok, location: @relational }\n else\n format.html { render :edit }\n format.json { render json: @relational.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @alligator = Alligator.find(params[:id])\n\n respond_to do |format|\n if @alligator.update_attributes(params[:alligator])\n format.html { redirect_to @alligator, notice: 'Alligator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @alligator.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 @religion = Religion.find(params[:id])\n\n respond_to do |format|\n if @religion.update_attributes(params[:religion])\n format.html { redirect_to @religion, notice: 'Religion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @religion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @language_family.update(language_family_params)\n format.html { redirect_to @language_family, notice: 'Language family was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @language_family.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @gender = Gender.find(params[:id])\n\n respond_to do |format|\n if @gender.update_attributes(params[:gender])\n format.html { redirect_to @gender, notice: 'Gender was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gender.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @formal_education.update(formal_education_params)\n format.html { redirect_to @formal_education, notice: 'Formal education was successfully updated.' }\n format.json { render :show, status: :ok, location: @formal_education }\n else\n format.html { render :edit }\n format.json { render json: @formal_education.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @appreciation = Appreciation.find(params[:id])\n\n respond_to do |format|\n if @appreciation.update_attributes(params[:appreciation])\n format.html { redirect_to @appreciation, notice: 'Appreciation was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appreciation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recital.update(recital_params)\n format.html { redirect_to @recital, notice: 'Recital was successfully updated.' }\n format.json { render :show, status: :ok, location: @recital }\n else\n format.html { render :edit }\n format.json { render json: @recital.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @documentation.update(documentation_params)\n format.html { redirect_to url_for(@documentation.metamorphosize),\n notice: 'Documentation was successfully updated.' }\n format.json { render :show, status: :ok, location: @documentation }\n else\n format.html { render :edit }\n format.json { render json: @documentation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fonctionn.update(fonctionn_params)\n format.html { redirect_to @fonctionn, notice: 'Fonctionn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fonctionn.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets the property name from the +PropertyInfo+ when the property is an indexer it will return +[]+
def property_name_from(property_info) return property_info.name.underscore if property_info.get_index_parameters.empty? "get_Item" end
[ "def property_name(property)\n property.name.to_s\n end", "def get_name_at_index(array,index)\n JavaScriptCore::Lib.JSPropertyNameArrayGetNameAtIndex(array,index)\n end", "def name_property\n p = properties.find { |n, p| p.name_property? }\n p ? p.first : nil\n end", "def name\n @property_name\n end", "def property_names\n @properties.values.map(&:name)\n end", "def nested_property_names\n @nested_property_names ||= Concurrent::Array.new(property_name_expression.split(/\\[|\\./).map {|pne| pne.end_with?(']') ? \"[#{pne}\" : pne }.reject {|pne| pne.empty? })\n end", "def property_label_method\n\t\tself.property_name\n\tend", "def property_names\n properties.symbolize_keys.keys\n end", "def property_names; @properties.keys; end", "def nested_property_name\n nested_property_names.last\n end", "def []( name )\n return @properties[name]\n end", "def prop(prop_name)\n props[prop_name]\n end", "def [](property)\n data[property]\n end", "def []( name )\n return @properties[name]\n end", "def get_attr_name(index)\n return @attributes.fetch(index)['name']\n end", "def prop_name(property, key)\n case key\n when :id\n property.attributes['name'] = 'groupId'\n when :name\n property.attributes['name'] = 'groupName'\n when :description\n property.attributes['name'] = 'description'\n when :perms\n property.attributes['name'] = 'emailPermissions'\n end\n\n property\n end", "def reflection_or_attribute_name\n reflection ? reflection.name : attribute_name\n end", "def _property(p_name)\n __t_stringish(p_name)\n _jinja.properties[__attribute_key(p_name)]\n end", "def reflection_or_attribute_name; end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the binding flags for instance members of a CLR type
def instance_flags System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.instance end
[ "def class_flags\n System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.static\n end", "def initialize_instance_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:properties] = clr_type.collect_interface_properties\n context[:methods] = clr_type.collect_interface_methods\n context[:events] = clr_type.collect_interface_events\n\n @instance_members = build_member_collections context\n end", "def all_flags\n my_flags = @flag_objects || []\n my_flags += self.superclass.all_flags if self.superclass < HasFlags::InstanceMethods\n return my_flags\n end", "def attrib_bits; end", "def init_flags(flags)\n @flags ||= []\n @flags << flags\n metaclass = (class << self; self; end)\n\n flags.each do |attr|\n m_name = \"#{attr}?\".to_sym\n unless self.methods.include? m_name\n metaclass.send(:define_method, m_name) do\n self.send(attr.to_sym)\n end\n end # mthods.include? m_name\n end #flags.each\n end", "def reflection\n bond.reflection\n end", "def initialize_class_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:methods] = clr_type.get_methods(class_flags)\n context[:properties] = clr_type.get_properties(class_flags)\n context[:events] = clr_type.get_events(class_event_flags)\n\n @class_members = build_member_collections context, false\n end", "def num_type_methods\n __ub2(OCI_ATTR_NUM_TYPE_METHODS)\n end", "def flags\n @flags\n end", "def allowed_member_types\n return @allowed_member_types\n end", "def methods_from_instance_methods instance, hash\n InstanceMethodsToMethods.new(instance, hash).instance_eval { binding }\nend", "def instance_bindings\n @instance_bindings ||= {}\n end", "def flags\n @flags\n end", "def feature_flags\n @feature_flag_delegate.to_a\n end", "def class_instance_variables\n field_mirrors(reflectee_send_from_module(:instance_variables))\n end", "def list_type_methods\n __param(OCI_ATTR_LIST_TYPE_METHODS)\n end", "def _isLoadableMember(attr)\n return ( (not attr.nil?) and (isPointerType(attr) and # ( Haystack.hasRef?(attr.class) ) and\n not isFunctionType(attr) ) or\n isStructType(attr) or isCStringPointer(attr) or\n (isArrayType(attr) and not isBasicTypeArrayType(attr) ) ) # should we iterate on Basictypes ? no\n end", "def attrib_bits_valid; end", "def proxy_java_fields\n fields = %w[key frameRate mousePressed keyPressed]\n methods = fields.map { |field| java_class.declared_field(field) }\n @declared_fields = Hash[fields.zip(methods)]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the binding flags for class members of a CLR type
def class_flags System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.static end
[ "def instance_flags\n System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.instance\n end", "def initialize_class_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:methods] = clr_type.get_methods(class_flags)\n context[:properties] = clr_type.get_properties(class_flags)\n context[:events] = clr_type.get_events(class_event_flags)\n\n @class_members = build_member_collections context, false\n end", "def init_flags(flags)\n @flags ||= []\n @flags << flags\n metaclass = (class << self; self; end)\n\n flags.each do |attr|\n m_name = \"#{attr}?\".to_sym\n unless self.methods.include? m_name\n metaclass.send(:define_method, m_name) do\n self.send(attr.to_sym)\n end\n end # mthods.include? m_name\n end #flags.each\n end", "def attrib_bits; end", "def property_class\n @property_class ||= lambda { |type, members, is_flags|\n klass = Class.new ::FrOData::Properties::Enum\n klass.send(:define_method, :type) { type }\n klass.send(:define_method, :members) { members }\n klass.send(:define_method, :is_flags?) { is_flags }\n klass\n }.call(type, members, is_flags?)\n end", "def class_attributes; end", "def class_variables\n field_mirrors(reflectee_send_from_module(:class_variables))\n end", "def get_class_variable_pins(namespace); end", "def all_flags\n my_flags = @flag_objects || []\n my_flags += self.superclass.all_flags if self.superclass < HasFlags::InstanceMethods\n return my_flags\n end", "def proxy_java_fields\n fields = %w[key frameRate mousePressed keyPressed]\n methods = fields.map { |field| java_class.declared_field(field) }\n @declared_fields = Hash[fields.zip(methods)]\n end", "def num_type_methods\n __ub2(OCI_ATTR_NUM_TYPE_METHODS)\n end", "def class_variables() end", "def reflection\n bond.reflection\n end", "def type_available\n type.property_names_to_types.map do |name, type|\n attr_accessor(name) unless method_defined?(name)\n alias_method(:\"#{name}?\", name) if type.excluding_null.is_a?(Type::Boolean)\n end\n end", "def list_type_methods\n __param(OCI_ATTR_LIST_TYPE_METHODS)\n end", "def class_variables; end", "def class_instance_variables\n field_mirrors(reflectee_send_from_module(:instance_variables))\n end", "def initialize_instance_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:properties] = clr_type.collect_interface_properties\n context[:methods] = clr_type.collect_interface_methods\n context[:events] = clr_type.collect_interface_events\n\n @instance_members = build_member_collections context\n end", "def define_bit_magic_methods(klass)\n names = @field_list\n bit_magic_name = @bit_magic_name\n \n klass.instance_eval do\n \n define_method(:\"#{bit_magic_name}_enabled?\") do |*fields|\n self.send(bit_magic_name).enabled?(*fields)\n end\n \n define_method(:\"#{bit_magic_name}_disabled?\") do |*fields|\n self.send(bit_magic_name).disabled?(*fields)\n end\n end\n \n if @action_options[:helpers]\n \n klass.instance_eval do\n names.each_pair do |name, bits|\n \n define_method(:\"#{name}\") do\n self.send(bit_magic_name)[name]\n end\n \n define_method(:\"#{name}=\") do |val|\n self.send(bit_magic_name)[name] = val\n end\n \n if bits.is_a?(Integer) or bits.length == 1\n define_method(:\"#{name}?\") do\n self.send(bit_magic_name)[name] == 1\n end\n end\n \n end\n end\n \n end\n \n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
collects instance members on this interface it will collect properties, methods and property setters
def initialize_instance_members_for(klass) clr_type = klass.to_clr_type context = {} context[:properties] = clr_type.collect_interface_properties context[:methods] = clr_type.collect_interface_methods context[:events] = clr_type.collect_interface_events @instance_members = build_member_collections context end
[ "def instance_variables() end", "def add_attr_accessors_to_self\n instance_variables.each do |name|\n method_name = name[1..-1].to_sym\n MetricFu::Configuration.send(:attr_accessor, method_name)\n end\n end", "def all_attributes\n super.each do |op|\n op.class_eval { include AmiMember } unless op.singleton_class.included_modules.include?(AmiMember)\n end\n end", "def initialize_class_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:methods] = clr_type.get_methods(class_flags)\n context[:properties] = clr_type.get_properties(class_flags)\n context[:events] = clr_type.get_events(class_event_flags)\n\n @class_members = build_member_collections context, false\n end", "def attributes\n super.each do |op|\n op.class_eval { include AmiMember } unless op.singleton_class.included_modules.include?(AmiMember)\n end\n end", "def accessors\n self.class.accessors\n end", "def collect_interface_properties\n iface_properties = []\n iface_properties += self.get_interfaces.collect { |t| t.collect_interface_properties }\n self.get_properties + iface_properties.flatten\n end", "def interface_methods; end", "def members(*) end", "def instance_attributes; end", "def members\n members = []\n\n attributes.each do |name, value|\n members << Member.new(name, :attr, value)\n end\n\n self.class.reflections.each do |name, reflection|\n case reflection.macro\n when :has_many\n members << Member.new(name, reflection.macro, self.send(name).send(:count))\n when :belongs_to\n member = self.send(name)\n members << Member.new(name, reflection.macro, member.ari_name, member.class, member.id)\n else\n members << Member.new(name, reflection.name, \"foo\")\n end\n end\n\n members\n end", "def members\n\n Placeholder_Generator.init(self.placeholder_rules, @members)\n\n Placeholder_Generator.run\n\n return Placeholder_Generator.members\n\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 run\n methods = self.class.instance_methods - Object.instance_methods\n methods.grep(%r!^set_!).each do |v|\n send(v)\n end\n end", "def all_instance_variables\n reflection_api = Rubinius::Mirror.reflect(self)\n instance_variables = reflection_api.instance_variables\n all_instance_variables = Set.new(instance_variables)\n all_instance_variables.merge(reflection_api.instance_fields)\n end", "def properties\n # Make sure we remove the leading @.\n #\n iv = instance_variables.collect { |v| v = v[1..-1] }\n iv.delete( '__val__' )\n iv\n end", "def getters\n self.class.getters || []\n end", "def metadata_accessors\n metamodel_klass.attributes.each do |attribute|\n next if respond_to?(attribute.name)\n\n define_singleton_method(attribute.name) do\n metamodel_store[attribute.name]\n end\n\n define_singleton_method(\"#{attribute.name}=\") do |value|\n metamodel_store[attribute.name] = value\n end\n end\n end", "def instance_methods\n all_methods().find_all{|m| (!m.singleton) && (@options.show_all || m.visibility == :public || m.visibility == :protected)}.collect{|m| method_hash(m)}\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
collects all the static members of the provided CLR class type
def initialize_class_members_for(klass) clr_type = klass.to_clr_type context = {} context[:methods] = clr_type.get_methods(class_flags) context[:properties] = clr_type.get_properties(class_flags) context[:events] = clr_type.get_events(class_event_flags) @class_members = build_member_collections context, false end
[ "def initialize_instance_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:properties] = clr_type.collect_interface_properties\n context[:methods] = clr_type.collect_interface_methods\n context[:events] = clr_type.collect_interface_events\n\n @instance_members = build_member_collections context\n end", "def members_by_type(mtype)\n # TBD\n end", "def all_c_methods\n self.all_classes_and_modules.flat_map do |klassmod|\n klassmod.select_c_methods\n end\n end", "def member_classes\n (@member_klasses ||= Set.new).merge(superclass.method_defined?(:member_classes) ? superclass.member_classes : [])\n end", "def class_variables_in(mod)\n result = Set.new\n collector = proc { |cvar_node| result << cvar_node.name }\n [:cvar, :cvasgn, :cvdecl].each do |stmt_type|\n mod.local_nodes(stmt_type, &collector)\n end\n result\n end", "def record_class_definitions\n extant, novel = [], []\n ObjectSpace.each_object(Class) { |k| extant << k }\n yield\n ObjectSpace.each_object(Class) { |k| novel << k if !extant.include?(k) }\n novel\n end", "def class_variables\n field_mirrors(reflectee_send_from_module(:class_variables))\n end", "def class_variables() end", "def class_methods\n all_methods().find_all{|m| m.singleton && (@options.show_all || m.visibility == :public || m.visibility == :protected)}.collect{|m| method_hash(m)}\n end", "def class_flags\n System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.static\n end", "def class_methods\n @cache[:class_methods]\n end", "def class_instance_variables\n field_mirrors(reflectee_send_from_module(:instance_variables))\n end", "def fields\n [constants, class_variables, class_instance_variables].flatten\n end", "def members\n members = []\n\n attributes.each do |name, value|\n members << Member.new(name, :attr, value)\n end\n\n self.class.reflections.each do |name, reflection|\n case reflection.macro\n when :has_many\n members << Member.new(name, reflection.macro, self.send(name).send(:count))\n when :belongs_to\n member = self.send(name)\n members << Member.new(name, reflection.macro, member.ari_name, member.class, member.id)\n else\n members << Member.new(name, reflection.name, \"foo\")\n end\n end\n\n members\n end", "def static_variables\n vars = {}\n superclasses.each do |cl|\n cl.static_vars.keys.each{|sv| vars[sv] = true }\n end\n vars.keys\n end", "def define_reflection_methods\n\n # *_class_name, *_class, *_table_name methods for all classes\n @config.classes.to_h.each do |class_type,class_name|\n class_type_name = class_type.to_s.gsub(/_class$/,'').singularize\n class_eval do\n \n # def CLASS_TYPE_class_name\n define_method \"#{class_type_name}_class_name\" do\n if @config.send(class_type).is_a?(Class)\n @config.send(class_type).name\n else\n @config.send(class_type).to_s.camelize\n end\n end\n alias_method \"#{class_type_name.pluralize}_class_name\", \"#{class_type_name}_class_name\"\n \n # def CLASS_TYPE_class\n define_method \"#{class_type_name}_class\" do\n \"::#{send(\"#{class_type_name}_class_name\")}\".constantize\n end\n alias_method \"#{class_type_name.pluralize}_class\", \"#{class_type_name}_class\"\n\n # def CLASS_TYPE_table_name\n define_method \"#{class_type_name}_table_name\" do\n send(\"#{class_type_name}_class\").table_name\n end\n alias_method \"#{class_type_name.pluralize}_table_name\", \"#{class_type_name}_table_name\"\n\n # def CLASS_TYPE_singular_key (used primarily for associations)\n define_method \"#{class_type_name}_singular_key\" do\n send(\"#{class_type_name}_class_name\").underscore.split(\"/\").last.singularize.to_sym\n end\n alias_method \"#{class_type_name.pluralize}_singular_key\", \"#{class_type_name}_singular_key\"\n\n # def CLASS_TYPE_plural_key (use primarily for associations)\n define_method \"#{class_type_name}_plural_key\" do\n send(\"#{class_type_name}_class_name\").underscore.split(\"/\").last.pluralize.to_sym\n end\n alias_method \"#{class_type_name.pluralize}_plural_key\", \"#{class_type_name}_plural_key\"\n \n # These define aliases for custom class names, like user_class and user_table_name aliased to subject_class and subject_table_name\n unless class_type.to_s.underscore == \"#{class_name.to_s.underscore}_class\"\n %w(_class_name _class _table_name _singular_key _plural_key).each do |suffix|\n alias_method \"#{class_name.to_s.underscore.singularize}#{suffix}\", \"#{class_type_name}#{suffix}\"\n alias_method \"#{class_name.to_s.underscore.pluralize}#{suffix}\", \"#{class_name.to_s.underscore.singularize}#{suffix}\"\n end\n end\n \n end\n end\n\n # *_foreign_key method for primary classes\n @config.primary_classes.to_h.each do |class_type,class_name|\n class_type_name = class_type.to_s.gsub(/_class$/,'').singularize\n class_eval do\n # def CLASS_TYPE_foreign_key\n define_method \"#{class_type_name}_foreign_key\" do\n # This is hideous, but we need some sort of fallback for cases like Rails 4 Heroku deploys where the environment and\n # database are not available.\n begin\n \"#{send(\"#{class_type_name}_table_name\").singularize}_#{send(\"#{class_type_name}_class\").primary_key}\"\n rescue\n \"#{send(\"#{class_type_name}_table_name\").singularize}_id\"\n end\n end\n alias_method \"#{class_type.to_s.gsub(/_class$/,\"\").pluralize}_foreign_key\", \"#{class_type.to_s.gsub(/_class$/,\"\").singularize}_foreign_key\"\n \n unless class_type.to_s.underscore == \"#{class_name.to_s.underscore}_class\"\n alias_method \"#{class_name.to_s.underscore.singularize}_foreign_key\", \"#{class_type.to_s.gsub(/_class$/,\"\").singularize}_foreign_key\" # CLASS_NAME_foreign_key\n alias_method \"#{class_name.to_s.underscore.pluralize}_foreign_key\", \"#{class_name.to_s.underscore.singularize}_foreign_key\"\n end\n end\n end\n end", "def static_methods\n return if @static_methods.empty?\n @static_methods.uniq.sort\n end", "def get_all_methods\n methods = []\n each_type do | type |\n type.each_method do |meth|\n methods << meth\n end\n end\n methods\n end", "def type_methods\n @type_methods ||= list_type_methods.to_a\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /german_armors GET /german_armors.json
def index @german_armors = GermanArmor.all end
[ "def index\n @armors = Armor.all\n\n render json: @armors\n end", "def index\n @armors = Armor.all\n end", "def armors\r\r\n @battler_ref.armors \r\r\n end", "def index\n @ladders = Ladder.all\n\n render json: @ladders\n end", "def index\n @mentors = Mentor.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mentors }\n end\n end", "def index\n @american_armors = AmericanArmor.all\n end", "def index\n @lugars = Lugar.all\n\n render json: @lugars\n end", "def index\n @manufactors = Manufactor.all\n end", "def index\n @armors = Armor.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @armors }\n end\n end", "def show\n @manufactorer = Manufactorer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manufactorer }\n end\n end", "def index\n @mantenedors = Mantenedor.all\n end", "def index\n @galactic_arms = Galacticarm.all\n end", "def show\n @galactic_arm = Galacticarm.find(params[:id])\n end", "def index\n @reagents = Reagent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reagents }\n end\n end", "def index\n @mentors = Mentor.all\n end", "def index\n @german_aircrafts = GermanAircraft.all\n end", "def index\n @api_v1_mentorings = Api::V1::Mentoring.all\n end", "def index\n @angels = Angel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @angels }\n end\n end", "def index\n @autors = Autor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @autors }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /german_armors POST /german_armors.json
def create @german_armor = GermanArmor.new(german_armor_params) respond_to do |format| if @german_armor.save format.html { redirect_to @german_armor, notice: 'German armor was successfully created.' } format.json { render :show, status: :created, location: @german_armor } else format.html { render :new } format.json { render json: @german_armor.errors, status: :unprocessable_entity } end end end
[ "def create\n @galactic_arm = Galacticarm.new(galactic_arm_params)\n\n respond_to do |format|\n if @galactic_arm.save\n format.html { redirect_to @galactic_arm, notice: 'Galactic arm was successfully created.' }\n format.json { render :show, status: :created, location: @galactic_arm }\n else\n format.html { render :new }\n format.json { render json: @galactic_arm.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @agronomiagalera = Agronomiagalera.new(params[:agronomiagalera])\n\n respond_to do |format|\n if @agronomiagalera.save\n format.html { redirect_to @agronomiagalera, notice: 'Agronomiagalera was successfully created.' }\n format.json { render json: @agronomiagalera, status: :created, location: @agronomiagalera }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agronomiagalera.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ladder = Ladder.new(ladder_params)\n\n if @ladder.save\n render json: @ladder, status: :created, location: @ladder\n else\n render json: @ladder.errors, status: :unprocessable_entity\n end\n end", "def create\n @manufactorer = Manufactorer.new(params[:manufactorer])\n\n respond_to do |format|\n if @manufactorer.save\n format.html { redirect_to @manufactorer, notice: 'Manufactorer was successfully created.' }\n format.json { render json: @manufactorer, status: :created, location: @manufactorer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @manufactorer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lugar = Lugar.new(lugar_params)\n\n if @lugar.save\n render json: @lugar, status: :created, location: @lugar\n else\n render json: @lugar.errors, status: :unprocessable_entity\n end\n end", "def create\n @ordenator = Ordenator.new(ordenator_params)\n\n respond_to do |format|\n if @ordenator.save\n format.html { redirect_to @ordenator, notice: 'Ordenator was successfully created.' }\n format.json { render :show, status: :created, location: @ordenator }\n else\n format.html { render :new }\n format.json { render json: @ordenator.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @armour = Armour.new(armour_params)\n\n respond_to do |format|\n if @armour.save\n format.html { redirect_to @armour, notice: \"Armour was successfully created.\" }\n format.json { render :show, status: :created, location: @armour }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @armour.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @armor_set = ArmorSet.new(params[:armor_set])\n\n respond_to do |format|\n if @armor_set.save\n format.html { redirect_to @armor_set, notice: 'Armor set was successfully created.' }\n format.json { render json: @armor_set, status: :created, location: @armor_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @armor_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @arma_ligera = ArmaLigera.new(arma_ligera_params)\n\n respond_to do |format|\n if @arma_ligera.save\n format.html { redirect_to @arma_ligera, notice: 'Arma ligera was successfully created.' }\n format.json { render action: 'show', status: :created, location: @arma_ligera }\n else\n format.html { render action: 'new' }\n format.json { render json: @arma_ligera.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @armor = Armor.new(armor_params)\n\n respond_to do |format|\n if @armor.save\n format.html { redirect_to @armor, notice: 'Armor was successfully created.' }\n format.json { render :show, status: :created, location: @armor }\n else\n format.html { render :new }\n format.json { render json: @armor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @armamento = Armamento.new(armamento_params)\n\n respond_to do |format|\n if @armamento.save\n format.html { redirect_to @armamento, notice: 'O Armamento foi criado com sucesso!' }\n format.json { render :show, status: :created, location: @armamento }\n else\n format.html { render :new }\n format.json { render json: @armamento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @leasing_agent = LeasingAgent.new(leasing_agent_params)\n respond_to do |format|\n if @leasing_agent.save\n format.html { redirect_to @leasing_agent, notice: \"Leasing agent was successfully created.\" }\n format.json { render :show, status: :created, location: @leasing_agent }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @leasing_agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @german_armors = GermanArmor.all\n end", "def create\n @ramen = Ramen.new(ramen_params)\n @ramen.user_id = current_user.id\n\n p ramen_params\n p @ramen.ramen_tastes\n\n respond_to do |format|\n if @ramen.save\n format.html { redirect_to @ramen, notice: 'Ramen was successfully created.' }\n format.json { render :show, status: :created, location: @ramen }\n else\n format.html { render :new }\n format.json { render json: @ramen.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lightning_arrester = LightningArrester.new(lightning_arrester_params)\n\n respond_to do |format|\n if @lightning_arrester.save\n format.html { redirect_to ['equipment',@lightning_arrester], notice: 'El apartarrayosfue creado exitosamente' }\n format.json { render :show, status: :created, location: @lightning_arrester }\n else\n format.html { render :new }\n format.json { render json: @lightning_arrester.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @german_aircraft = GermanAircraft.new(german_aircraft_params)\n\n respond_to do |format|\n if @german_aircraft.save\n format.html { redirect_to @german_aircraft, notice: 'German aircraft was successfully created.' }\n format.json { render :show, status: :created, location: @german_aircraft }\n else\n format.html { render :new }\n format.json { render json: @german_aircraft.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lager = Lager.new(lager_params)\n\n respond_to do |format|\n if @lager.save\n format.html { redirect_to @lager, notice: 'Lager was successfully created.' }\n format.json { render :show, status: :created, location: @lager }\n else\n format.html { render :new }\n format.json { render json: @lager.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @moral_alignment = MoralAlignment.new(moral_alignment_params)\n\n respond_to do |format|\n if @moral_alignment.save\n format.html { redirect_to @moral_alignment, notice: 'Moral alignment was successfully created.' }\n format.json { render :show, status: :created, location: @moral_alignment }\n else\n format.html { render :new }\n format.json { render json: @moral_alignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @grantmaker = Grantmaker.new(params[:grantmaker])\n\n respond_to do |format|\n if @grantmaker.save\n format.html { redirect_to @grantmaker, :notice => 'Grantmaker was successfully created.' }\n format.json { render :json => @grantmaker, :status => :created, :location => @grantmaker }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @grantmaker.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
not used, check if rank only in one taxonomy
def get_2tax_rank(res, rank_check, taxonomy_name) return true if ((res["classification_path_ranks"].split('|')[-1] == rank_check) && (res["data_source_title"] == taxonomy_name)) end
[ "def is_in? taxon\n r = taxon.ranks.keys.first\n return false if self[ r ].nil?\n self[ r ].downcase == taxon[ r ].downcase\n end", "def in?(taxon)\n r = taxon.ranks.keys.first\n return false if self[r].nil?\n\n self[r].casecmp(taxon[r]).zero?\n end", "def navy_rank; end", "def active_rank(student, rank)\n \treturn student.ranks.include?(rank)\n\tend", "def is?(taxonomy_type)\n self.taxonomy_type == taxonomy_type\n end", "def same_rank?(other)\n if self.wild? || other.wild?\n return true \n end\n self.rank == other.rank\n end", "def is_object_in_taxonomy(object_type, taxonomy)\n taxonomies = get_object_taxonomies(object_type)\n return false if taxonomies.blank?\n taxonomies.include? taxonomy\n end", "def next_rank?(other)\n if self.wild? || other.wild?\n return true \n end\n self.rank.next?(other.rank)\n end", "def first_rank?\n rank.nil? || rank == 1\n end", "def next_rank?(other)\n RANKS.find_index(other.rank) == 1 + RANKS.find_index(rank)\n end", "def species_or_lower?\n return false if rank_level.blank?\n\n rank_level <= SPECIES_LEVEL\n end", "def in_taxon?( taxon )\n # self.lft > taxon.lft && self.rgt < taxon.rgt\n target_id = taxon.is_a?( Taxon ) ? taxon.id : taxon.to_i\n ancestor_ids.include?( target_id )\n end", "def army_rank; end", "def taxable?\n self.taxable\n end", "def higher_rank?(object)\n return false unless signed_in?\n if object.is_a?(User)\n current_user == object || current_user.rank_before_type_cast > object.rank_before_type_cast\n else\n current_user == object.user || current_user.rank_before_type_cast > object.user.rank_before_type_cast\n end\n end", "def already_ranked?(word,user)\n WordFeeling.where(word_id: word.id, user_id: user.id).exists?\n end", "def is_rank_name_taken\n\t\t@ranks=self.alliance.ranks\n\t\t@ranks.each do |r|\n\t\t\tif r.name.downcase==self.name.downcase\n\t\t\t\terrors.add :name,\"already exists in your alliance\"\n\t\t\tend\n\t\tend\t\n\tend", "def rank?(rank=:any, options={}, &block)\n return false if current_user.nil?\n options = {\n :user_id => nil,\n :user => nil,\n :allow => nil,\n }.update options \n #allow rank to be a user object.\n if rank.is_a? User\n options[:user] = rank\n rank = :owner\n end\n options[:user_id] = options[:user].id if options[:user]\n #allow block\n unless options[:allow] == :any\n return false if !options[:allow] == :closed && current_user.closed?\n return false if !options[:allow] == :banned && current_user.banned?\n end\n \n\n \n #test rank\n rank = :user if rank == :any\n rank = User::RANKS[rank][:range].send(:min) if User::RANKS.has_key? rank\n\n permit = if rank == :owner\n (options[:user_id] == current_user.id)\n elsif options[:user_id]\n (options[:user_id] == current_user.id) || (current_user.rank >= rank)\n else\n (current_user.rank >= rank)\n end\n yield if permit && block_given?\n permit\n end", "def fulfills_mundane_rank?(rank) \n ranks = GameRules::Rules.the_rules.character_ranks[:mundane]\n return false if ranks.nil? || ranks.empty? || rank >= ranks.count\n new_rank = ranks[rank]\n \n (self.exp || 0) >= new_rank[:exp] && (self.sacred_rank || 0) >= new_rank[:minimum_sacred_rank]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /hr/config/departments GET /hr/config/departments.json
def index @hr_config_departments = Hr::Config::Department.all end
[ "def departments()\n require_authentication!\n options = make_options(\"getDepartments\")\n response = self.class.post(\"/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}\", options)\n raise response[\"error\"][\"message\"] unless response[\"error\"].nil?\n response[\"result\"]\n end", "def department\n @departments = @company.departments\n respond_to do |format|\n format.json { render json: @departments}\n end\n end", "def query_depts\n { 'respDepartment' => Newspilot.configuration.departments }\n end", "def department\n fetch('the_thick_of_it.departments')\n end", "def index\n @api_departments = Department.all\n render json: @api_departments\n end", "def index\n @departments = @healthcare_provider.departments.all\n respond_with @departments\n end", "def index\r\n @hrms_departments = Hrms::Department.all\r\n end", "def index\n @departments = Department.all\n respond_to do |format|\n format.json{ render json: @departments}\n end\n end", "def index\n @admin_departments = Admin::Department.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_departments }\n end\n end", "def index\n @departamentos = Departamento.all\n\n render json: @departamentos\n end", "def create\n\n request = RestClient.post File.join(API_SERVER,\"rest-api/departments\"), { \n 'name' => params['department']['name'], \n 'description' => params['department']['description'] }.to_json, :content_type => :json, :accept => :json\n redirect_to :action => :index\n end", "def index\n @departaments = Departament.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @departaments }\n end\n end", "def get_faculty_departments(year = CURRENT_YEAR, semester = CURRENT_SEMESTER)\n get \"#{format_year(year)}/#{semester}/facultyDepartments.json\"\n end", "def index\n respond_with (@depts = Dept.all)\n end", "def get_department_categories\n department = Department.find(params[:department_id])\n categories = department.categories\n json_response(categories)\n end", "def index\n @departures = Departure.all\n end", "def index\n @dept = Dept.find((params[:dept_id]))\n @dept_addresses = DeptAddress.where(\"dept_id = ?\", params[:dept_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @dept_addresses }\n end\n end", "def get_departures\n @stop_code = params[:stop_code]\n\n request_url = \"http://services.my511.org/Transit2.0/GetNextDeparturesByStopCode.aspx?token=#{@@token}&stopcode=#{@stop_code}\"\n request_url = request_url.gsub(/ /,\"%20\")\n @departures = search_for_key(parse_request(request_url), \"Route\")\n @departures = [] unless @departures\n @departures = [@departures] unless @departures.kind_of?(Array)\n respond_to do |format|\n format.js {}\n end\n end", "def airport_departures(id, params={})\n perform_get(\"/airports/#{id}/departures.xml\", params)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /hr/config/departments/1 DELETE /hr/config/departments/1.json
def destroy @hr_config_department.destroy respond_to do |format| format.html { redirect_to hr_config_departments_url, notice: 'លុបទទួលបានជោគជ័យ' } format.json { head :no_content } end end
[ "def destroy\n request = RestClient.delete File.join(API_SERVER,\"rest-api/departments\",params['id'])\n redirect_to :action => :index\t\n end", "def destroy\n @department_entry.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @api_department.destroy\n end", "def destroy\n @departure = Departure.find(params[:id])\n @departure.destroy\n\n respond_to do |format|\n format.html { redirect_to departures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @d_department = DDepartment.find(params[:id])\n @d_department.destroy\n\n respond_to do |format|\n format.html { redirect_to d_departments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_department = Admin::Department.find(params[:id])\n @admin_department.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_departments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @department = Department.find(params[:id])\n @department.destroy\n\n \n\n respond_to do |format|\n format.html { redirect_to departments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @b_department = BDepartment.find(params[:id])\n @b_department.destroy\n\n respond_to do |format|\n format.html { redirect_to b_departments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @departments_request_type.destroy\n respond_to do |format|\n format.html { redirect_to departments_request_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @departamento.destroy\n\n head :no_content\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @departamentos = Departamento.find(params[:id])\n @departamentos.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @subdepartment = Subdepartment.find(params[:id])\n @subdepartment.destroy\n\n respond_to do |format|\n format.html { redirect_to subdepartments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @departuretype.destroy\n respond_to do |format|\n format.html { redirect_to departuretypes_url, notice: 'Departuretype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @department.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_departments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @employee_department = EmployeeDepartment.find(params[:id])\n @employee_department.destroy\n\n respond_to do |format|\n format.html { redirect_to employee_departments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @departure = Departure.find(params[:id])\n @departure.destroy\n\n respond_to do |format|\n format.html { redirect_to(departures_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @departments_manager = DepartmentsManager.find(params[:id])\n @departments_manager.destroy\n\n respond_to do |format|\n format.html { redirect_to departments_managers_url }\n format.json { head :ok }\n end\n end", "def destroy\n\t @departmentlist = Departmentlist.find(params[:id])\n @departmentlist.destroy\n respond_to do |format|\n format.html { redirect_to departmentlists_url, notice: 'Departmentlist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
methods for rendering spokes
def render_spokes(cx, cy, type, spoke_length, spoke_direction, color) @app.stroke color u_p1 = spoke_direction[0] u_m1 = spoke_direction[1] @app.stroke color spoke_end_x_up1 = cx + spoke_length[0] * u_p1[0] spoke_end_y_up1 = cy - spoke_length[0] * u_p1[1] @app.line(cx, cy, spoke_end_x_up1, spoke_end_y_up1) spoke_end_x_up2 = cx + spoke_length[1] * u_m1[0] spoke_end_y_up2 = cy - spoke_length[1] * u_m1[1] @app.line(cx, cy, spoke_end_x_up2, spoke_end_y_up2) if type == 'end' u_0 = spoke_direction[2] spoke_end_x_u0 = cx + spoke_length[2] * u_0[0] spoke_end_y_u0 = cy - spoke_length[2] * u_0[1] @app.line(cx, cy, spoke_end_x_u0, spoke_end_y_u0) end end
[ "def render_spokes(cx, cy, type, spoke_length, spoke_direction, color)\n @app.stroke color\n u_p1 = spoke_direction[0]\n u_m1 = spoke_direction[1] \n @app.stroke color\n spoke_end_x_up1 = cx + spoke_length[0] * u_p1[0]\n spoke_end_y_up1 = cy - spoke_length[0] * u_p1[1]\n @app.line(cx, cy, spoke_end_x_up1, spoke_end_y_up1)\n spoke_end_x_up2 = cx + spoke_length[0] * u_m1[0]\n spoke_end_y_up2 = cy - spoke_length[0] * u_m1[1]\n @app.line(cx, cy, spoke_end_x_up2, spoke_end_y_up2)\n if type == 'end'\n u_0 = spoke_direction[2]\n spoke_end_x_u0 = cx + spoke_length[0] * u_0[0]\n spoke_end_y_u0 = cy - spoke_length[0] * u_0[1]\n @app.line(cx, cy, spoke_end_x_u0, spoke_end_y_u0)\n end\n end", "def render_srep(*args)\n srep = args[0]\n shiftx = args[1]\n shifty = args[2]\n scale = args[3]\n show_sphere = args[4]\n show_sphere = false\n srep.atoms.each_with_index do |atom, i|\n render_atom(atom.x + shiftx, atom.y + shifty, atom.color)\n if show_sphere\n center_x = atom.x + shiftx - atom.spoke_length[0]\n center_y = atom.y + shifty - atom.spoke_length[0]\n d = atom.spoke_length[0] * 2\n # if (srep.index != 1 or i != 2)\n\t render_circle(center_x, center_y, d, srep.color)\n # else\n # render_circle(center_x+10, center_y+10, 80, srep.color)\n # end\n end\n if srep.show_extend_disk\n center_x = atom.x + shiftx - atom.expand_spoke_length[0]\n center_y = atom.y + shifty - atom.expand_spoke_length[0]\n d = atom.expand_spoke_length[0] * 2 \n render_circle(center_x, center_y, d, srep.color)\n end \n atom_x = atom.x+shiftx\n atom_y = atom.y+shifty\n #render_spokes(atom_x, atom_y, atom.type, atom.spoke_length, atom.spoke_direction, srep.color)\n end\n\n if srep.interpolated_spokes_begin.length > 0 and srep.show_interpolated_spokes\n spoke_begin = srep.interpolated_spokes_begin\n spoke_end = srep.interpolated_spokes_end\n render_interp_spokes(shiftx, shifty, Color.white, spoke_begin, spoke_end, srep.index)\n end\n\n if srep.show_curve\n # display the interpolated curve points\n render_curve($sreps, srep.index, srep, shiftx, shifty)\n end\n end", "def render_interp_spokes(shiftx, shifty, color, ibegin, iend, srep_index)\n\n ibegin.each_with_index do |p, i|\n if ($colored_spoke_indices.include? i and srep_index == 0)\n @app.stroke Color.blue\n else\n @app.stroke color\n end\n @app.line(p[0]+shiftx, p[1]+shifty, iend[i][0]+shiftx, iend[i][1]+shifty)\n end\n end", "def render\n super \n inc_level\n indent(indentation) do\n # draw item\n draw_item # use draw_item from included Drawer\n # draw text with current pdf_style of list\n with_pdf_style do |pdf_style| \n prawn_command :formatted_text_box, text, pdf_style\n end \n end\n new_line\n end", "def draw_actor_sp(actor, x, y, width = 144, fake = false)\n self.contents.font.size = Scan_Window_Font_Size\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)\n self.contents.font.color = actor.sp == 0 ? knockout_color :\n actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color\n sp_x = x + width - 108\n sp = fake ? '????' : actor.sp.to_s\n self.contents.draw_text(sp_x, y, 48, 32, sp, 2)\n self.contents.font.color = normal_color\n self.contents.draw_text(sp_x + 48, y, 12, 32, '/', 1)\n self.contents.font.bold = true\n maxsp = fake ? '????' : actor.maxsp.to_s\n self.contents.draw_text(sp_x + 60, y, 48, 32, maxsp)\n self.contents.font.bold = false\n end", "def draw_actor_sp(actor, x, y, width = 144)\n # Draw \"SP\" text string\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)\n # Calculate if there is draw space for MaxHP\n if width - 32 >= 108\n sp_x = x + width - 108\n flag = true\n else#if width - 32 >= 48\n sp_x = x + width - 48\n flag = false\n end\n # Draw SP\n self.contents.font.color = actor.sp == 0 ? knockout_color :\n actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color\n self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)\n # Draw MaxSP\n if flag\n self.contents.font.color = normal_color\n self.contents.draw_text(sp_x + 48, y, 12, 32, \"/\", 1)\n self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)\n end\n end", "def draw_actor_sp(actor, x, y, width = 144)\n # Draw \"SP\" text string\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)\n # Calculate if there is draw space for MaxHP\n if width - 32 >= 108\n sp_x = x + width - 108\n flag = true\n elsif width - 32 >= 48\n sp_x = x + width - 48\n flag = false\n end\n # Draw SP\n self.contents.font.color = actor.sp == 0 ? knockout_color :\n actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color\n self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_i.to_s, 2)\n # Draw MaxSP\n if flag\n self.contents.font.color = normal_color\n self.contents.draw_text(sp_x + 48, y, 12, 32, \"/\", 1)\n self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)\n end\n end", "def render_interp_spokes(shiftx, shifty, color, ibegin, iend)\n @app.stroke color\n ibegin.each_with_index do |p, i|\n @app.line(p[0]+shiftx, p[1]+shifty, iend[i][0]+shiftx, iend[i][1]+shifty)\n end\n end", "def draw_content\n with_font do\n @pdf.move_down((@pdf.font.line_gap + @pdf.font.descender)/2)\n with_text_color do\n text_box(:width => spanned_content_width + FPTolerance,\n :height => spanned_content_height + FPTolerance,\n :at => [0, @pdf.cursor]).render\n end\n end\n end", "def draw_sp\n # set current variables\n @sp, @maxsp = actor.sp, actor.maxsp\n # set fill rate\n rate = (@maxsp > 0 ? @sp / @maxsp : 0)\n # draw gradient bar\n self.bitmap.gradient_bar_hud(@sp_x+32, @sp_y+3, 114, rate, 'hud_blue_bar', 2)\n # set font color depending on how many SP left\n self.bitmap.font.color = @sp == 0 ? knockout_color :\n @sp <= @maxsp / 4 ? crisis_color : normal_color\n # draw SP\n self.bitmap.draw_text_full(@sp_x+38, @sp_y, 48, 20, @sp.to_s, 2)\n # set font color\n self.bitmap.font.color = normal_color\n # draw \"/\"\n self.bitmap.draw_text_full(@sp_x+86, @sp_y, 12, 20, '/', 1)\n # draw max SP\n self.bitmap.draw_text_full(@sp_x+98, @sp_y, 48, 20, @maxsp.to_s)\n end", "def draw \n\t\tsuper(\"Lives: #{@lives.to_s}\", X, Y, 5)\n\tend", "def slip\n load_order\n @slip = true\n @template = \"slip\"\n render \"invoice\"\n end", "def render_subset_extend_interp_spokes(shiftx, shifty, color, ibegin, iend, srep_index)\n\n iend.each_with_index do |p, i|\n#\tif p.size >= 4 and (p[3].is_a? Integer) and p[3] >= 0 and p[3] < 3 \n#\t @app.stroke $sreps[p[3]].color\n if srep_index == 0\n if $subset_index.include? i\n \n\t\tif p.size >=3 and (p[2].is_a? Integer) and p[2] >= 0 and p[2] < 3 \n\t\t @app.stroke $sreps[p[2]].color\n\n other_srep_index = p[2]\n other_srep_spoke_index = p[3]\n other_srep_spoke_begin = $sreps[other_srep_index].interpolated_spokes_begin[other_srep_spoke_index]\n @app.line(other_srep_spoke_begin[0]+shiftx, other_srep_spoke_begin[1]+shifty, p[0]+shiftx, p[1]+shifty)\n\t\telse \n\t\t @app.stroke color\n\t\tend\n \n\t\t@app.line(ibegin[i][0]+shiftx, ibegin[i][1]+shifty, p[0]+shiftx, p[1]+shifty)\n\t end\n end\n end\n end", "def display(shoes)\n shoes.flow do\n # seperate stack for the images so they are displayed left\n shoes.stack width: TWEET_PIC_WIDTH, height: 60 do\n shoes.image(image_url)\n end\n shoes.stack width: -TWEET_PIC_WIDTH do\n shoes.para publisher_name, \": \", text, \" \", date_time, \" \",\n shoes.link(\"Go to Tweet\") { Launchy.open(url) }\n end\n end\n end", "def draw\n Termbox.tb_clear\n @views.each {|view| view.draw}\n Termbox.tb_present\n end", "def render()\n\n\t\ti=0\n\t\tfor p in particles\n\t\t\tx = ( p.pos.x - @x0) * @scale\n\t\t\ty = ( p.pos.y - @y0) * @scale\n\t\t\trenderPoint( p.name, x, y, p.mass/3000.0, 1, 1)\n\t\t\ti=i+1\n\t\tend\n\tend", "def render_score; end", "def template()\n # template to position ocr text over the image\n # - logic adapted from readux\n # TODO: pull template out into a separate file?\n %{\n <% for line in self.lines %>\n <div class=\"ocr-line <% if line.word_zones.empty? %>ocrtext<% end %>\" <% if line.id %>id=\"<%= line.id %>\"<% end %>\n <%= line.css_style %>>\n <% for zone in line.word_zones %>\n <div class=\"ocr-zone ocrtext\" <%= zone.css_style %>>\n <%= zone.begin_annotation_data %>{% raw %}<%= zone.annotated_text %>{% endraw %}<%= zone.end_annotation_data %>\n </div>\n <% end %>\n <% if line.word_zones.empty? %>\n <%= line.begin_annotation_data %>{% raw %}<%= line.annotated_text %>{% endraw %}<%= line.end_annotation_data %>\n <% end %>\n </div>\n <% end %>\n <% for img_highlight in self.image_highlight_zones %>\n <span class=\"annotator-hl image-annotation-highlight\"\n data-annotation-id=\"<%= img_highlight.annotation_id %>\"\n <%= img_highlight.css_style %>>\n <a href=\"#<%= img_highlight.annotation_id %>\"\n name=\"hl-<%= img_highlight.annotation_id %>\" class=\"to-annotation\"></a>\n\n </span>\n <% end %>\n }\n end", "def print_products\n\treturn \"\n ____ _ _ \n | _ \\\\ _ __ ___ __| |_ _ ___| |_ ___ \n | |_) | '__/ _ \\\\ / _` | | | |/ __| __/ __|\n | __/| | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\n |_| |_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\\n\\n\"\n\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method for rendering interpolated spokes
def render_interp_spokes(shiftx, shifty, color, ibegin, iend) @app.stroke color ibegin.each_with_index do |p, i| @app.line(p[0]+shiftx, p[1]+shifty, iend[i][0]+shiftx, iend[i][1]+shifty) end end
[ "def render_interp_spokes(shiftx, shifty, color, ibegin, iend, srep_index)\n\n ibegin.each_with_index do |p, i|\n if ($colored_spoke_indices.include? i and srep_index == 0)\n @app.stroke Color.blue\n else\n @app.stroke color\n end\n @app.line(p[0]+shiftx, p[1]+shifty, iend[i][0]+shiftx, iend[i][1]+shifty)\n end\n end", "def render_subset_extend_interp_spokes(shiftx, shifty, color, ibegin, iend, srep_index)\n\n iend.each_with_index do |p, i|\n#\tif p.size >= 4 and (p[3].is_a? Integer) and p[3] >= 0 and p[3] < 3 \n#\t @app.stroke $sreps[p[3]].color\n if srep_index == 0\n if $subset_index.include? i\n \n\t\tif p.size >=3 and (p[2].is_a? Integer) and p[2] >= 0 and p[2] < 3 \n\t\t @app.stroke $sreps[p[2]].color\n\n other_srep_index = p[2]\n other_srep_spoke_index = p[3]\n other_srep_spoke_begin = $sreps[other_srep_index].interpolated_spokes_begin[other_srep_spoke_index]\n @app.line(other_srep_spoke_begin[0]+shiftx, other_srep_spoke_begin[1]+shifty, p[0]+shiftx, p[1]+shifty)\n\t\telse \n\t\t @app.stroke color\n\t\tend\n \n\t\t@app.line(ibegin[i][0]+shiftx, ibegin[i][1]+shifty, p[0]+shiftx, p[1]+shifty)\n\t end\n end\n end\n end", "def render_srep(*args)\n srep = args[0]\n shiftx = args[1]\n shifty = args[2]\n scale = args[3]\n show_sphere = args[4]\n show_sphere = false\n srep.atoms.each_with_index do |atom, i|\n render_atom(atom.x + shiftx, atom.y + shifty, atom.color)\n if show_sphere\n center_x = atom.x + shiftx - atom.spoke_length[0]\n center_y = atom.y + shifty - atom.spoke_length[0]\n d = atom.spoke_length[0] * 2\n # if (srep.index != 1 or i != 2)\n\t render_circle(center_x, center_y, d, srep.color)\n # else\n # render_circle(center_x+10, center_y+10, 80, srep.color)\n # end\n end\n if srep.show_extend_disk\n center_x = atom.x + shiftx - atom.expand_spoke_length[0]\n center_y = atom.y + shifty - atom.expand_spoke_length[0]\n d = atom.expand_spoke_length[0] * 2 \n render_circle(center_x, center_y, d, srep.color)\n end \n atom_x = atom.x+shiftx\n atom_y = atom.y+shifty\n #render_spokes(atom_x, atom_y, atom.type, atom.spoke_length, atom.spoke_direction, srep.color)\n end\n\n if srep.interpolated_spokes_begin.length > 0 and srep.show_interpolated_spokes\n spoke_begin = srep.interpolated_spokes_begin\n spoke_end = srep.interpolated_spokes_end\n render_interp_spokes(shiftx, shifty, Color.white, spoke_begin, spoke_end, srep.index)\n end\n\n if srep.show_curve\n # display the interpolated curve points\n render_curve($sreps, srep.index, srep, shiftx, shifty)\n end\n end", "def interpolated_markup\n visualization.markup.tap do |markup|\n interpolation_values.each do |k,v|\n markup.gsub!(\"__#{k.upcase}__\", v.to_s)\n end\n end\n end", "def interpolation_patterns; end", "def interpolated_markup\n visualization.markup.tap do |markup|\n [\n [ :ready_event, 'tf_ready' ],\n [ :refresh_event, \"tf_refresh_#{visualization.slug}\" ],\n [ :div_id, div_id ]\n ].each do |k, v|\n markup.gsub!(\"__#{k.upcase}__\", v.to_s)\n end\n end\n end", "def print_interpolation_line(value)\n print_times_blank(10)\n print \"#{create_colored_substrings(value)}\"\n print_times_blank(8)\n puts \"(#{value.round(3)})\"\n nil\n end", "def template()\n # template to position ocr text over the image\n # - logic adapted from readux\n # TODO: pull template out into a separate file?\n %{\n <% for line in self.lines %>\n <div class=\"ocr-line <% if line.word_zones.empty? %>ocrtext<% end %>\" <% if line.id %>id=\"<%= line.id %>\"<% end %>\n <%= line.css_style %>>\n <% for zone in line.word_zones %>\n <div class=\"ocr-zone ocrtext\" <%= zone.css_style %>>\n <%= zone.begin_annotation_data %>{% raw %}<%= zone.annotated_text %>{% endraw %}<%= zone.end_annotation_data %>\n </div>\n <% end %>\n <% if line.word_zones.empty? %>\n <%= line.begin_annotation_data %>{% raw %}<%= line.annotated_text %>{% endraw %}<%= line.end_annotation_data %>\n <% end %>\n </div>\n <% end %>\n <% for img_highlight in self.image_highlight_zones %>\n <span class=\"annotator-hl image-annotation-highlight\"\n data-annotation-id=\"<%= img_highlight.annotation_id %>\"\n <%= img_highlight.css_style %>>\n <a href=\"#<%= img_highlight.annotation_id %>\"\n name=\"hl-<%= img_highlight.annotation_id %>\" class=\"to-annotation\"></a>\n\n </span>\n <% end %>\n }\n end", "def render_spokes(cx, cy, type, spoke_length, spoke_direction, color)\n @app.stroke color\n u_p1 = spoke_direction[0]\n u_m1 = spoke_direction[1] \n @app.stroke color\n spoke_end_x_up1 = cx + spoke_length[0] * u_p1[0]\n spoke_end_y_up1 = cy - spoke_length[0] * u_p1[1]\n @app.line(cx, cy, spoke_end_x_up1, spoke_end_y_up1)\n spoke_end_x_up2 = cx + spoke_length[1] * u_m1[0]\n spoke_end_y_up2 = cy - spoke_length[1] * u_m1[1]\n @app.line(cx, cy, spoke_end_x_up2, spoke_end_y_up2)\n if type == 'end'\n u_0 = spoke_direction[2]\n spoke_end_x_u0 = cx + spoke_length[2] * u_0[0]\n spoke_end_y_u0 = cy - spoke_length[2] * u_0[1]\n @app.line(cx, cy, spoke_end_x_u0, spoke_end_y_u0)\n end\n end", "def render_spokes(cx, cy, type, spoke_length, spoke_direction, color)\n @app.stroke color\n u_p1 = spoke_direction[0]\n u_m1 = spoke_direction[1] \n @app.stroke color\n spoke_end_x_up1 = cx + spoke_length[0] * u_p1[0]\n spoke_end_y_up1 = cy - spoke_length[0] * u_p1[1]\n @app.line(cx, cy, spoke_end_x_up1, spoke_end_y_up1)\n spoke_end_x_up2 = cx + spoke_length[0] * u_m1[0]\n spoke_end_y_up2 = cy - spoke_length[0] * u_m1[1]\n @app.line(cx, cy, spoke_end_x_up2, spoke_end_y_up2)\n if type == 'end'\n u_0 = spoke_direction[2]\n spoke_end_x_u0 = cx + spoke_length[0] * u_0[0]\n spoke_end_y_u0 = cy - spoke_length[0] * u_0[1]\n @app.line(cx, cy, spoke_end_x_u0, spoke_end_y_u0)\n end\n end", "def compile_interpolated_plain(node)\n temple = [:multi]\n StringSplitter.compile(node.value[:text]).each do |type, value|\n case type\n when :static\n temple << [:static, value]\n when :dynamic\n temple << [:escape, node.value[:escape_interpolation], [:dynamic, value]]\n end\n end\n temple << [:newline]\n end", "def erb_to_interpolation(text, options)\n # Escape the text...\n text = CGI.escapeHTML(uninterp(text))\n # Unescape our <fortitude_loud> tags.\n %w[<fortitude_loud> </fortitude_loud>].each do |str|\n text.gsub!(CGI.escapeHTML(str), str)\n end\n\n # Find any instances of the escaped form of tags we're not compatible with, and put in the FIXME comments.\n %w[fortitude_silent fortitude_block].each do |fake_tag_name|\n while text =~ %r{^(.*?)&lt;#{fake_tag_name}&gt;(.*?)&lt;/#{fake_tag_name}&gt;(.*)$}mi\n before, middle, after = $1, $2, $3\n text = before +\n %{\n# HTML2FORTITUDE_FIXME_BEGIN: The following code was interpolated into this block using ERb;\n# Fortitude isn't a simple string-manipulation engine, so you will have to find another\n# way of accomplishing the same result here:\n# &lt;%\n} +\n middle.split(/\\n/).map { |l| \"# #{l}\" }.join(\"\\n\") +\n %{\n# %&gt;\n} +\n after\n end\n end\n\n ::Nokogiri::XML.fragment(text).children.inject(\"\") do |str, elem|\n if elem.is_a?(::Nokogiri::XML::Text)\n str + CGI.unescapeHTML(elem.to_s)\n else # <fortitude_loud> element\n data = extract_needs_from!(elem.inner_text.strip, options)\n str + '#{' + CGI.unescapeHTML(data) + '}'\n end\n end\n end", "def interpolate overlay\n result = overlay.keys.inject(pattern.dup) do |result, key|\n if value = overlay[key]\n result.gsub! /:#{key}/, value.to_s\n else\n result.gsub! /:#{key}#{separator}?/, ''\n end\n result\n end\n result.gsub!(/#{separator}$/, '') || result\n end", "def render_score; end", "def to_string_interpolation(node_or_interp); end", "def render(slide)\n send(\"render_#{slide[1]}\", slide[0]) if slide[0] =~ /\\S/\nend", "def do_pp_interpolation(value)\n case value\n when Array\n value.map {|v| do_pp_interpolation(v)}\n when Hash\n result = {}\n value.each_pair {|k,v| result[k] = do_pp_interpolation(v) }\n result\n when String\n call_function('tahu::eval', value)\n else\n value\n end\n end", "def interpolated_content page \n handler = page.handler\n\n until (handler.nil?)\n handler = handler.delegate\n if handler.class == ::Awestruct::Handlers::InterpolationHandler\n return handler.rendered_content page.create_context(page.raw_content)\n end\n end\n page.raw_content\n end", "def render(slide)\n send(\"render_#{slide[:format]}\", slide[:content], *slide[:args])\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method for rendering atoms
def render_atom(x, y, color) render_point_big(x, y, color) end
[ "def render(options = {}, extra_options = {}, &block)\n if atom = options[:atom]\n response.content_type ||= Mime::ATOM\n render_for_text(atom.respond_to?(:to_atom) ? atom.to_atom.to_xml : atom.to_xml, options[:status])\n else\n super\n end\n end", "def render()\n\n\t\ti=0\n\t\tfor p in particles\n\t\t\tx = ( p.pos.x - @x0) * @scale\n\t\t\ty = ( p.pos.y - @y0) * @scale\n\t\t\trenderPoint( p.name, x, y, p.mass/3000.0, 1, 1)\n\t\t\ti=i+1\n\t\tend\n\tend", "def render(xm=Builder::XmlMarkup.new(:indent => 2))\n xm.instruct!\n xm.kml(:xmlns => 'http://earth.google.com/kml/2.1'){\n objects.each { |o| o.render(xm) }\n }\n end", "def render\n self.maze.each do |arr|\n p arr.join(\"\")\n end\n end", "def render(xm=Builder::XmlMarkup.new(:indent => 2))\n xm.instruct!\n xm.kml(:xmlns => 'http://www.opengis.net/kml/2.2'){\n objects.each { |o| o.render(xm) }\n }\n end", "def add_atom( *args )\n super( *args )\n reset_positions_inside\n end", "def prop_atoms\n prop_atom_ids.map{|i| Atom.new @display, i}\n end", "def print_molecule\n puts @name\n @bondmatrix.pretty_print(@atoms)\n end", "def render\n renderer.render(cells)\n end", "def render_linking_structure(shifts)\n shift = shifts[0]\n $linkingPts.each do |pt|\n if pt != []\n render_atom(pt[0]+shift, pt[1]+shift, Color.black)\n end\n end\n end", "def render\r\n if self.has_content?\r\n self.to_a.inject(''){|loop_str, i|\r\n loop_str += i.nodes.inject(''){|nodes_str, j|\r\n nodes_str += j.render\r\n } \r\n }\r\n else\r\n ''\r\n end\r\n end", "def render\n tree.render\n end", "def render_linking_structure(shifts)\n shift = shifts[0]\n if not $refine_linking_structure\n $linkingPts.each do |pt|\n if pt != []\n render_atom(pt[0]+shift, pt[1]+shift, Color.black)\n end\n end\n else \n $refined_linkingPts.each do |pt|\n if pt != []\n render_atom(pt[0]+shift, pt[1]+shift, Color.black)\n end\n end \n end\n end", "def render\n wrap @children.map(&:render).join(\"\\n\")\n end", "def render\r\n if self.has_content?\r\n self.to_a.inject(''){|loop_str, i|\r\n loop_str += i.nodes.inject(''){|nodes_str, j|\r\n nodes_str += j.render\r\n }\r\n }\r\n else\r\n ''\r\n end\r\n end", "def render_srep(*args)\n srep = args[0]\n shiftx = args[1]\n shifty = args[2]\n scale = args[3]\n show_sphere = args[4]\n show_sphere = false\n srep.atoms.each_with_index do |atom, i|\n render_atom(atom.x + shiftx, atom.y + shifty, atom.color)\n if show_sphere\n center_x = atom.x + shiftx - atom.spoke_length[0]\n center_y = atom.y + shifty - atom.spoke_length[0]\n d = atom.spoke_length[0] * 2\n # if (srep.index != 1 or i != 2)\n\t render_circle(center_x, center_y, d, srep.color)\n # else\n # render_circle(center_x+10, center_y+10, 80, srep.color)\n # end\n end\n if srep.show_extend_disk\n center_x = atom.x + shiftx - atom.expand_spoke_length[0]\n center_y = atom.y + shifty - atom.expand_spoke_length[0]\n d = atom.expand_spoke_length[0] * 2 \n render_circle(center_x, center_y, d, srep.color)\n end \n atom_x = atom.x+shiftx\n atom_y = atom.y+shifty\n #render_spokes(atom_x, atom_y, atom.type, atom.spoke_length, atom.spoke_direction, srep.color)\n end\n\n if srep.interpolated_spokes_begin.length > 0 and srep.show_interpolated_spokes\n spoke_begin = srep.interpolated_spokes_begin\n spoke_end = srep.interpolated_spokes_end\n render_interp_spokes(shiftx, shifty, Color.white, spoke_begin, spoke_end, srep.index)\n end\n\n if srep.show_curve\n # display the interpolated curve points\n render_curve($sreps, srep.index, srep, shiftx, shifty)\n end\n end", "def generate_markup\n\t\tordering = get_ordering\n\t\tmarkup_text = \"\"\n\n\t\tordering.each do |obj_place|\n\n\t\t\telement = obj_place.model.constantize.find(obj_place.id) #find the element referred to in the objectplace\t\n\t\t\twhitespace = \"\"\n\t\t\ttype_char = \"\"\n\t\t\tinfo = \"\"\n\n\t\t\t#get the whitespace, which is three spaces for every depth\n\t\t\t(element.depth*3).times do\n\t\t\t\twhitespace << \" \"\n\t\t\tend\n\n\t\t\t#if it's a node, gets its category and title, builds a string with a comma\n\t\t\tif element.is_a?(Node)\n\t\t\t\ttype_char = \".\"\n\t\t\t\tcategory_text = \"\"\n\t\t\t\tif element.category.name != \"\"\n\t\t\t\t\tcategory_text = element.category.name.capitalize + \",\"\n\t\t\t\tend\n\t\t\t\ttitle = element.title\n\t\t\t\tinfo = category_text + title\n\n\t\t\t#if it's a note, gets its body\n\t\t\telsif element.is_a?(Note)\n\t\t\t\ttype_char = \"-\"\n\t\t\t\tbody = element.body\n\t\t\t\tinfo = body\n\n\t\t\t#if it's a LinkCollection, builds the string with the link's child names comma separated\n\t\t\telsif element.is_a?(LinkCollection)\n\t\t\t\ttype_char = \":\"\n\t\t\t\tlinks_text = \"\"\n\t\t\t\telement.links.each do |link|\n\t\t\t\t\tif link.child != nil\n\t\t\t\t\t\tlinks_text << link.child.title + \" , \"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tif links_text != \"\"\n\t\t\t\t\tlinks_text = links_text[0..-4] #removes the trailing spaces and comma\n\t\t\t\tend\n\t\t\t\tinfo = links_text\n\t\t\telsif element.is_a?(PlaceHolder) #it's a place_holder\n\t\t\t\twhitespace = \"\"\n\t\t\t\ttype_char = \"\"\n\t\t\t\tinfo = element.text\n\t\t\tend\n\t\t\tmarkup_text << whitespace + type_char + info + \"\\r\\n\"\n\t\tend\n\t\treturn markup_text\n\tend", "def _normalize_render(*args, &block); end", "def visualize\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method for rendering linking structure
def render_linking_structure(shifts) shift = shifts[0] $linkingPts.each do |pt| if pt != [] render_atom(pt[0]+shift, pt[1]+shift, Color.black) end end end
[ "def render_linking_structure(shifts)\n shift = shifts[0]\n if not $refine_linking_structure\n $linkingPts.each do |pt|\n if pt != []\n render_atom(pt[0]+shift, pt[1]+shift, Color.black)\n end\n end\n else \n $refined_linkingPts.each do |pt|\n if pt != []\n render_atom(pt[0]+shift, pt[1]+shift, Color.black)\n end\n end \n end\n end", "def href_template; end", "def display_all_links_attributes\n # Interface method\n end", "def display_link_attributes(link)\n # Interface method\n end", "def render_display_link args\n label = blacklight_config.display_link[args[:field]][:label]\n links = args[:value]\n #Rails.logger.debug(\"es287_debug #{__FILE__}:#{__LINE__} links = #{links.inspect}\")\n links ||= args[:document].fetch(args[:field], :sep => nil) if args[:document] and args[:field]\n #Rails.logger.debug(\"es287_debug #{__FILE__}:#{__LINE__} links = #{links.inspect}\")\n render_format = args[:format] ? args[:format] : 'default'\n\n value = links.map do |link|\n #Check to see whether there is metadata at the end of the link\n url, *metadata = link.split('|')\n if links.size == 1 && render_format == 'url'\n return url.html_safe\n end\n if metadata.present?\n label = metadata[0]\n end\n link_to(process_online_title(label), url.html_safe, {:class => 'online-access', :onclick => \"javascript:_paq.push(['trackEvent', 'itemView', 'outlink']);\"})\n end\n\n #Rails.logger.debug(\"es287_debug #{__FILE__}:#{__LINE__} field = #{args[:field].inspect}\")\n #Rails.logger.debug(\"es287_debug #{__FILE__}:#{__LINE__} render_format = #{render_format.inspect}\")\n #Rails.logger.debug(\"es287_debug #{__FILE__}:#{__LINE__} value = #{value.inspect}\")\n if render_format == 'raw'\n return value\n else\n case args[:field]\n when'url_findingaid_display'\n return value[0]\n when 'url_bookplate_display'\n Rails.logger.debug(\"es287_debug #{__FILE__}:#{__LINE__} field = #{args[:field].inspect}\")\n return value.uniq.join(',').html_safe\n when 'url_other_display'\n return value.join('<br>').html_safe\n else\n fp = Blacklight::FieldPresenter.new( self, args[:document], blacklight_config.show_fields[args[:field]], :value => label)\n fp.render\n end\n end\n end", "def link_to(links)\n links.map { |link| \"<a href='#{link[:uri]}'>#{link[:name]}</a>\" }.join(\"<br>\")\nend", "def render_physician_links(workgroup, context)\n result = \"\"\n physicians = workgroup.find_physicians\n physicians.each do |phys|\n result += link_to(phys.full_name, { :context=>context}.merge(hash_for_network_profile_path(:id=>phys.load_default_profile(workgroup).id))) + \"<br/>\"\n end\n return result\n end", "def write_step_links(structure)\n # write links between steps\n default_count = 1\n structure.links.each do |link|\n if link.source_id.present?\n label = link.name || link.nice_id\n write_line(\" \\\"#{san(link.source.id)}\\\" -> \\\"#{san(link.sink.id)}\\\" [label=\\\"#{san(label)}\\\"];\")\n elsif link.default_value.present?\n # collect default values\n label = link.name || link.nice_id\n default_label = link.default_value\n write_line(\" \\\"default#{default_count}\\\" -> \\\"#{san(link.sink.id)}\\\" [label=\\\"#{san(label)}\\\"];\")\n write_line(\" \\\"default#{default_count}\\\" [label=\\\"#{san(default_label)}\\\", fillcolor=\\\"#D5AEFC\\\"];\")\n default_count += 1\n end\n end\n\n # Write the links between nodes\n # Write links between outputs and penultimate steps\n structure.outputs.each do |output|\n output.sources.each do |source|\n write_line(\" \\\"#{san(source.id)}\\\" -> \\\"#{san(output.id)}\\\";\")\n end\n end\n end", "def side_column_links\n str = \"<h3 class=\\\"head\\\">#{link_to 'Communications THL', '#nogo', {:hreflang => 'Fathom Communications THL.'}}</h3>\\n<ul>\\n\"\n str += \"<li>#{link_to 'Home', root_path, {:hreflang => 'Home communications.'}}</li>\\n\"\n #str += \"<li>#{link_to 'My Profile', me_path, {:hreflang => 'My Profile.'}}</li>\\n\" if logged_in?\n #str += \"<li>#{link_to 'People', people_path, {:hreflang => 'Manage People'}}</li>\\n\"\n #str += \"<li>#{link_to 'Projects', projects_path, {:hreflang => 'Manage Projects.'}}</li>\\n\"\n #str += \"<li>#{link_to 'Organizations', organizations_path, {:hreflang => 'Manage Organizations.'}}</li>\\n\"\n #str += \"<li>#{link_to 'Tools', tools_path, {:hreflang => 'Manage Tools.'}}</li>\\n\"\n str += \"</ul>\"\n return str\n end", "def create_links!\n @logger.info \"create links page\"\n File.open(File.join(\"#{@options[:output]}\", \"links.html\"), \"w\") do |file|\n file.write(template(binding, :links))\n end\n end", "def parse_link_definition; end", "def links\n { self: rubric_url(object) }\n end", "def prepare_links!\n links_def = self.class.find_links_definition or return\n links_def.rel2block.each do |link|\n links << links_def.sought_type.from_attributes({ # create Hyperlink representer.\n \"rel\" => link[:rel],\n \"href\" => run_link_block(link[:block])})\n end\n end", "def write_hyperlinks #:nodoc:\n return unless @hyperlinks\n hlink_attributes = []\n @hyperlinks.keys.sort.each do |row_num|\n # Sort the hyperlinks into column order.\n col_nums = @hyperlinks[row_num].keys.sort\n # Iterate over the columns.\n col_nums.each do |col_num|\n # Get the link data for this cell.\n link = @hyperlinks[row_num][col_num]\n\n # If the cell isn't a string then we have to add the url as\n # the string to display\n if ptrue?(@cell_data_table) &&\n ptrue?(@cell_data_table[row_num]) &&\n ptrue?(@cell_data_table[row_num][col_num])\n if @cell_data_table[row_num][col_num].display_url_string?\n link.display_on\n end\n end\n\n if link.respond_to?(:external_hyper_link)\n # External link with rel file relationship.\n @rel_count += 1\n # Links for use by the packager.\n @external_hyper_links << link.external_hyper_link\n end\n hlink_attributes << link.attributes(row_num, col_num, @rel_count)\n end\n end\n\n return if hlink_attributes.empty?\n\n # Write the hyperlink elements.\n @writer.tag_elements('hyperlinks') do\n hlink_attributes.each do |attributes|\n @writer.empty_tag('hyperlink', attributes)\n end\n end\n end", "def render\n # link_text = \"<span class='item-icon'>#{render_icon}</span>\"\n # link_text += \"<span class='descriptor-icon'>#{options[:descriptor_icon]}</span>\" if options[:descriptor_icon]\n # link_text += \"<span class='item-text'>#{h @name}</span>\"\n # link_text += \"<span class='item-count'>#{delimit @count}</span>\" if count\n # item = ''\n # item += \"<li>#{s_link_to link_text, @url, @options.selected_if(selected?)}</li>\" if count.nil? || count.positive?\n #\n # s item\n\n link_text = content_tag(:span, render_icon, class: 'item-icon')\n link_text += content_tag(:span, options[:descriptor_icon], class: 'descriptor-icon') if options[:descriptor_icon]\n link_text += content_tag(:span, @name, class: 'item-text')\n link_text += content_tag(:span, delimit(@count), class: 'item-count') if count\n\n content_tag :li do\n link_to link_text, @url, @options.selected_if(selected?)\n end\n\n end", "def links\n links = []\n\n # 1. Related_URL\n if dif.Related_URL?\n\n dif.Related_URL.each do | link |\n\n if link.URL_Content_Type? and link.URL_Content_Type.Type?\n dif_type = link.URL_Content_Type.Type\n else\n dif_type = nil\n end\n\n rel = case dif_type\n when \"GET DATA\" then \"data\"\n when \"VIEW PROJECT HOME PAGE\" then \"project\"\n when \"VIEW EXTENDED METADATA\" then \"metadata\"\n when \"GET SERVICE\" then \"service\"\n when \"VIEW RELATED INFORMATION\", \"\", nil then \"related\"\n else dif_type\n end\n\n link.URL.each do | url |\n\n links << {\n \"rel\" => rel,\n \"href\" => url,\n \"title\" => link.Description,\n \"type\" => \"text/html\",\n }\n end\n end\n end\n\n # 2. Link to parent metadata\n unless object.Parent_DIF.nil?\n dif.Parent_DIF.each do | parent |\n\n links << {\n \"rel\" => \"parent\",\n \"href\" => base+uuid(self.class.uri(parent))+\".json\",\n \"type\" => \"application/json\"\n }\n\n end\n end\n\n # 3. Links to DOI and \"Online Resource\" (metadata)\n # @todo\n\n if dif.Entry_ID =~ /^(org[.|-]polarresearch\\-)/\n links << {\n \"rel\" => \"via\",\n \"href\" => \"http://risapi.data.npolar.no/oai?verb=GetRecord&metadataPrefix=dif&identifier=oai:ris.npolar.no:#{dif.Entry_ID}\",\n \"type\" => \"application/json\"\n }\n end\n\n # Links to GCMD project on api.npolar.no\n #unless dif.Project.nil?\n # projects = Gcmd::Concepts.new.tuples(\"projects\")\n #\n # links += dif.Project.map {|p|\n # id, label = projects.select { |tup | tup[1] == p[\"Short_Name\"]}[0]\n # unless id.nil?\n # link(\"/gcmd/concept/#{id}.json\", \"project\", label, \"application/json\")\n # else\n # [] #link(\"/gcmd/concept/?q=#{label}&title=false&fields=*&format=json\", \"project\", label, \"application/json\")\n # end\n #\n # }\n #end\n\n links\n end", "def links\n _links = parent_link.update({\n self: { href: @controller.polymorphic_url(collection_hierarchy) }\n })\n\n { _links: _links }\n end", "def before_render\n manage_link_stack\n end", "def external_link(link_label, url, options={})\n attributes = options[:attributes] || {}\n children = options[:children] || {}\n image = options[:image] || {}\n\n img =\"\"\n unless image.empty?\n img = self.external_image(image[:url], image, true) \n end\n\n child_elements = self.children_list(children) << img\n link_label = self.tag('label', link_label)\n url = self.tag('url', url)\n link = self.tag('externalLink', url << link_label << child_elements, attributes)\n\n cell = options[:cell] || {}\n row = options[:row] || {}\n self.row_cell(link, cell, row)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this method interates the sreps and let them check the spoke intersection
def checkSrepIntersection (0..$sreps.length-1).each do |j| (0..$sreps.length-1).each do |i| if i != j $sreps[j].checkIntersection($sreps[i]) end end end end
[ "def checkSrepIntersection\n (0..$sreps.length-1).each do |j|\n (0..$sreps.length-1).each do |i|\n if i != j\n $sreps[j].checkIntersection($sreps[i])\n end\n end\n end\n end", "def intersect(s1,s2)\n # no intersect if either segment doesn't existend\n return false if s1.nil? || s2.nil?\n\n # check for consecutive edges in polygon\n e1 = s1.edge\n e2 = s2.edge\n\n # no non-simple intersect since consecutive\n polygon_edges = @polygon.vertices.length-1\n return false if (((e1+1)%polygon_edges === e2) || (e1 === (e2+1)%polygon_edges))\n\n\n #test for existence of an intersect point\n #s2 left point sign\n lsign = s2.left_point.is_left(s1.left_point, s1.right_point)\n #s2 right point sign\n rsign = s2.right_point.is_left(s1.left_point, s1.right_point)\n\n # s2 endpoints have same sign relative to s1 => on same side => no intersect is possible\n return false if (lsign * rsign > 0)\n\n # s1 left point sign\n lsign = s1.left_point.is_left(s2.left_point, s2.right_point)\n #s1 right point sign\n rsign = s1.right_point.is_left(s2.left_point, s2.right_point)\n\n # s1 endpoints have same sign relative to s2 => on same side => no intersect is possible\n return false if (lsign * rsign > 0)\n\n #segments s1 and s2 straddle. Intersect exists.\n return true\n end", "def test_intersection\n s1 = Square.new(5,5,4)\n s2 = Square.new(5,5,6)\n assert_equal(16, s1.intersection(s2))\n assert_equal(16, s2.intersection(s1))\n \n s1 = Square.new(5,5,4)\n s2 = Square.new(2,2,4)\n assert_equal(1, s1.intersection(s2))\n assert_equal(1, s2.intersection(s1))\n \n s1 = Square.new(5,5,6)\n s2 = Square.new(5,9,4)\n assert_equal(4, s1.intersection(s2))\n assert_equal(4, s2.intersection(s1))\n end", "def intersection(s,p=nil,o=nil,r=nil) \n tmp = @result\n if s.instance_of? SemanticExpression \n tmp = s.result \n #Intersection, Intersection and Difference are operation over sets.\n elsif s.instance_of? Array \n tmp = s \n #Intersection, Intersection and Difference are operation over sets. \n elsif Thread.current[:application].is_set?(s)\n #returns all set of resources\n if r != nil && r!= :s\n tmp = SemanticExpression.new.spo(Thread.current[:application].get(s).elements.collect{|s,p,o| eval(r.to_s)}.uniq,:p,:o).result\n else\n tmp = Thread.current[:application].get(s).elements\n end\n #Intersection method, passed as parameter a triple expression\n else\n tmp = query(s,p,o,r)\n end\n #@result = @result & tmp - The intersection is between the subjects and it is not between triples.\n \n a = tmp.collect{|s,p,o| s}\n \n @result = @result.collect { |s,p,o| [s,p,o] if a.include?(s) } \n \n self\n end", "def render_subset_extend_interp_spokes(shiftx, shifty, color, ibegin, iend, srep_index)\n\n iend.each_with_index do |p, i|\n#\tif p.size >= 4 and (p[3].is_a? Integer) and p[3] >= 0 and p[3] < 3 \n#\t @app.stroke $sreps[p[3]].color\n if srep_index == 0\n if $subset_index.include? i\n \n\t\tif p.size >=3 and (p[2].is_a? Integer) and p[2] >= 0 and p[2] < 3 \n\t\t @app.stroke $sreps[p[2]].color\n\n other_srep_index = p[2]\n other_srep_spoke_index = p[3]\n other_srep_spoke_begin = $sreps[other_srep_index].interpolated_spokes_begin[other_srep_spoke_index]\n @app.line(other_srep_spoke_begin[0]+shiftx, other_srep_spoke_begin[1]+shifty, p[0]+shiftx, p[1]+shifty)\n\t\telse \n\t\t @app.stroke color\n\t\tend\n \n\t\t@app.line(ibegin[i][0]+shiftx, ibegin[i][1]+shifty, p[0]+shiftx, p[1]+shifty)\n\t end\n end\n end\n end", "def bisectors\n s = self.sides.map { |side| Line.new(side.p1, side.p2) }\n c = self.incenter\n\n inter1 = Line.new(self.vertices[0], c).intersection(s[1]).first\n inter2 = Line.new(self.vertices[1], c).intersection(s[2]).first\n inter3 = Line.new(self.vertices[2], c).intersection(s[0]).first\n\n {\n self.vertices[0] => Segment.new(self.vertices[0], inter1), \n self.vertices[1] => Segment.new(self.vertices[1], inter2),\n self.vertices[2] => Segment.new(self.vertices[2], inter3),\n }\n end", "def intersect\n use(:__intersect__)\n end", "def find_intersection(the_subway)\n\n the_subway[the_subway.keys[0]].each do | stop |\n found = true\n the_subway.each_value do | line |\n found = false unless line.include?(stop)\n end\n return stop if found\n end\nend", "def intersect!(s)\n setTo(intersect(s))\n end", "def intersect?(other); end", "def intersects(shape)\n p1 = shape.points.length - 1\n for p2 in 0...shape.points.length\n p3 = @points.length - 1\n for p4 in 0...@points.length\n return true if segments_intersection(shape.points[p1], shape.points[p2], @points[p3], @points[p4])\n p3 = p4\n p4 += 1\n end\n p1 = p2\n p2 += 1\n end\n return false\n end", "def set_intersect(*keys)\n timeout_retry(3, 3){\n write \"SINTER #{keys.join(' ')}\\r\\n\"\n Set.new(multi_bulk_reply)\n }\n end", "def intersection(otherset,name)\n #intitializes empty set, and creates new set object to hold intersection set\n setinit =[]\n interset = Set.new(setinit, name)\n\n #two for loops to cycle through each element of both sets and compare them\n i=0\n j=0\n #first loop cycles through the setarray \n for i in 0..@setarray.length-1\n tempid1=@setarray[i].id\n tempname1=@setarray[i].name\n #nested for loop cycles through the other set's setarray\n for j in 0..otherset.setarray.length-1\n tempid2=otherset.setarray[j].id\n tempname2=otherset.setarray[j].name\n \n #compares the current subscriber of setarray with the current subscriber of the other set's setarray\n if (tempid1 == tempid2) && (tempname1 == tempname2)\n #as long as the subscriber isn't already inside the new intersection set, it adds\n unless interset.contains?(@setarray[i],0,interset.length-1)\n interset.setarray.push(otherset.setarray[j])\n end\n end\n\n end\n end\n #sorts the array so it can be manipulated further\n interset.setarray.sort_by!(&:id)\n #returns the new intersection set\n return interset\n end", "def test_intersects()\n results = Array.new()\n \n # INTERSECTS [0][1][2][3][4][5][6][7][8][9][10][11]\n results[0] = [1, 0, 0, 0, 0, 1, X, 0, 0, 0, 0, 0]\n results[1] = [0, 1, 1, 1, 0, 0, X, 1, 1, 1, 1, 0]\n results[2] = [0, 1, 1, 1, 0, 0, X, 0, 0, 0, 0, 0]\n results[3] = [0, 1, 1, 1, 0, 0, X, 1, 1, 1, 1, 0]\n results[4] = [0, 0, 0, 0, 1, 1, X, 0, 0, 0, 0, 0]\n results[5] = [1, 0, 0, 0, 1, 1, X, 0, 0, 0, 0, 0]\n results[6] = [X, X, X, X, X, X, X, X, X, 1, 1, X]\n results[7] = [0, 1, 0, 1, 0, 0, X, 1, 1, 1, 1, 0]\n results[8] = [0, 1, 0, 1, 0, 0, X, 1, 1, 1, 1, 0]\n results[9] = [0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0]\n results[10] = [0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0]\n results[11] = [0, 0, 0, 0, 0, 0, X, 0, 0, 0, 0, 1]\n \n self.run_relational_operation(\"INTERSECTS\", results) do |geom1, geom2|\n geom1.intersects?(geom2)\n end\n end", "def intersection(another) \n self & another \n end", "def intersect\n use(:__intersect__)\n end", "def reciprocate!\n bms1.each.select do |bm|\n bms2[bm.sbj] && bm.qry == bms2[bm.sbj].sbj\n end\n end", "def clip(clip, source_forwards, clip_forwards)\n source_vert = self.first\n clip_vert = clip.first\n\n loop do\n unless source_vert.is_intersection\n loop do\n unless clip_vert.is_intersection\n i = Intersection.new(source_vert, get_next(source_vert.next_node), clip_vert, clip.get_next(clip_vert.next_node))\n\n if i.valid\n source_intersection = Vertex.create_intersection(i.x, i.y, i.to_source)\n clip_intersection = Vertex.create_intersection(i.x, i.y, i.to_clip)\n source_intersection.corresponding = clip_intersection\n clip_intersection.corresponding = source_intersection\n\n insert_vertex(source_intersection, source_vert, get_next(source_vert.next_node))\n clip.insert_vertex(clip_intersection, clip_vert, clip.get_next(clip_vert.next_node))\n end\n end\n clip_vert = clip_vert.next_node\n break if clip_vert == clip.first\n end\n end\n\n source_vert = source_vert.next_node\n break if source_vert == self.first\n end\n\n source_vert = self.first\n clip_vert = clip.first\n\n source_in_clip = source_vert.is_inside(clip)\n clip_in_source = clip_vert.is_inside(self)\n\n source_forwards ^= source_in_clip\n clip_forwards ^= clip_in_source\n\n loop do\n if source_vert.is_intersection\n source_vert.is_entry = source_forwards\n source_forwards = !source_forwards\n end\n source_vert = source_vert.next_node\n break if source_vert == self.first\n end\n\n loop do\n if clip_vert.is_intersection\n clip_vert.is_entry = clip_forwards\n clip_forwards = !clip_forwards\n end\n clip_vert = clip_vert.next_node\n break if clip_vert == clip.first\n end\n\n list = []\n\n while has_unprocessed\n current = get_first_intersect\n clipped = Polygon.new([])\n clipped.add_vertex(Vertex.new(current.x, current.y))\n\n loop do\n current.visit\n if current.is_entry\n loop do\n current = current.next_node\n clipped.add_vertex(Vertex.new(current.x, current.y))\n break if current.is_intersection\n end\n else\n loop do\n current = current.prev_node\n clipped.add_vertex(Vertex.new(current.x, current.y))\n break if current.is_intersection\n end\n end\n current = current.corresponding\n break if current.visited\n end\n\n list << clipped.get_points\n end\n\n if list.length == 0\n list << self.get_points if source_in_clip\n list << clip.get_points if clip_in_source\n list = nil if list.length == 0\n end\n\n list\n end", "def doIntersection(available_set_list)\r\n\t\tselected_sets = getTheTwoSets(available_set_list) #get the two sets from the user\r\n\r\n\t\t#call the Intersection\r\n\t\tset1INTERSECTIONset2 = selected_sets[0].intersection(selected_sets[1])\r\n\t\tset1INTERSECTIONset2.display()\r\n\t\tmainmenu()\r\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
name: a Symbol, String or an Array; nil means hook to the root cascade: true/false; for cascading hook of sub key hook: block which will be called with 2 args, name and value
def add_hook(name = nil, cascade = false, &hook) if name == nil or name == true or name == false cascade = name assign_self_hook(cascade, &hook) else assign_hook(name_to_a(name), cascade, &hook) end end
[ "def trigger name, *args, &block\n if block\n trigger :before, name\n yield\n trigger :after, name\n else\n return unless hooks[name]\n hooks[name][args.shift].each do |proc|\n proc.call *args\n end\n end\n end", "def hooks(name)\n @hooks[name]\n end", "def register_hook(name, block)\n return clear_hooks(name) if block.nil?\n\n @hooks ||= {}\n @hooks[name] ||= []\n\n block = Array(block)\n @hooks[name].concat(block)\n end", "def hook_name; end", "def add( k, clr = nil, &block )\n key = sk( k )\n clr ||= caller.first\n LOCK.synchronize do\n applied.delete( key )\n hooks[ key ] << [ block, clr.to_s ]\n end\n end", "def hook(name)\n @hook_name = name\n Container::Hook.register(name, self)\n end", "def register_hook(name, block)\n return clear_hooks(name) if block.nil?\n\n block = Array(block)\n @hooks[name].concat(block)\n end", "def hook(name, args)\n @hooks ||= {}\n raise(ArgumentError, \"Hook name must be a symbol\") unless name.kind_of?(Symbol)\n @hooks[name.to_sym] = args\n end", "def hooks(name = nil)\n if name\n (@hooks && @hooks[name]) || []\n else\n @hooks || {}\n end\n end", "def name_set_hook &block\n @name_set_hook = block if block\n @name_set_hook ||= -> name, instance, old_name=nil { name }\n end", "def child_pre_set_hook( key, object, parent_hash = nil )\n\n return object\n \n end", "def run_hook!(name)\n return unless hooks[name.to_sym]\n hooks[name.to_sym].each { |blk| config.instance_exec(&blk) }\n end", "def by_name(name)\n name=name.to_s.pluralize\n named_hooks[name.to_sym]\n end", "def register_hook(hook_name, block)\n hooks_for(hook_name).each do |blk|\n # Simple but effective proc compartion\n return nil if blk.source_location == block.source_location\n end\n hooks_for(hook_name) << block\n end", "def attach_lookup_reference_callback name, options\n return if options[:inherit]\n \n set_callback :save, :before do\n maintain_lookup_reference(name)\n true\n end\n end", "def callbacks_for_hook(name)\n _hooks[name]\n end", "def exec_hook(event_name, *args, &block)\n @hooks[event_name] ||= []\n\n # silence warnings to get rid of 1.8's \"warning: multiple values\n # for a block parameter\" warnings\n Pry::Helpers::BaseHelpers.silence_warnings do\n @hooks[event_name].map { |hook_name, callable| callable.call(*args, &block) }.last\n end\n end", "def hook1; end", "def hook_type_name; end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
replace [noreply]\r\n replace store this data, but only if the server does already hold data for this key.
def replace (key,value,exptime="0",flags="0") msj = "replace #{key} #{flags} #{exptime} #{value.length}\r\n#{value}\r\n" @socket.puts(msj) respuesta = @socket.gets.chomp return respuesta end
[ "def replace(key, flags, expiration, length, data)\n if storage.keys? key\n set(key, flags, expiration, data)\n elsif\n 'NOT_STORED'\n end\n end", "def replace(value, hash)\n hash[value[:key]] = { flags: value[:flags], exptime: value[:exptime], value: value[:value], cas_unique: value[:cas_unique] }\n value[:reply] != 'false' ? (self.result = \"\\r\\nSTORED\") : (self.result = '')\n end", "def remove_key\n str = @buffer.line\n str[last_word_start, @key.size] = \"\"\n @buffer.line = str\n end", "def replace(key, data, flags, exp_time)\n if !exists?(key)\n CacheResult.new(false, MESSAGES[:not_stored], nil)\n else\n set(key, data, flags, exp_time)\n end\n end", "def prepend (key,value)\n msj = \"prepend #{key} 0 0 #{value.length}\\r\\n#{value}\\r\\n\"\n @socket.puts(msj)\n respuesta = @socket.gets.chomp\n return respuesta\n end", "def prepend(client, key, flag ,expiration, size, value, no_reply) \r\n \r\n storedData = get_data(key) \r\n \r\n if has_expired?(key)\r\n purge_expired(key)\r\n raise \"NOT_STORED\\r\\n\" \r\n end \r\n \r\n if(storedData == nil)\r\n raise \"NOT_STORED\\r\\n\" \r\n end\r\n\r\n storedData.semaphore.synchronize{\r\n cas_unique = rand(2**32..2**64-1)\r\n new_value = \"#{value}#{storedData.value}\"\r\n data = SavedData.new(new_value, storedData.flag, cas_unique, storedData.size + size)\r\n set_data(key, data) \r\n \r\n if(!no_reply)\r\n client.print(\"STORED\\r\\n\")\r\n end\r\n }\r\n end", "def replace_record(params)\n if storage.key?(params[:key])\n storage[params[:key]].replace_value(params)\n \"STORED\\r\\n\"\n else\n \"NOT_STORED\\r\\n\"\n end\n end", "def rekey_as_needed\n return if algorithms.pending?\n\n socket.if_needs_rekey? { rekey! }\n end", "def rekey_as_needed\n return if algorithms.pending?\n socket.if_needs_rekey? { rekey! }\n end", "def append_data(client, full_data)\n if full_data.gsub(/[\\r\\n]/,\"\") == \".\"\n Store.instance.add(\n get_client_data(client, :from).to_s,\n get_client_data(client, :to).to_s,\n get_client_data(client, :data).to_s\n )\n respond(client, 250)\n $log.info \"Received mail from #{get_client_data(client, :from).to_s} with recipient #{get_client_data(client, :to).to_s}\"\n else\n self.client_data[client.object_id][:data] << full_data\n end\n end", "def write(key, data)\n return false if data.blank?\n return false unless store(key, data)\n @cache.write(key, data)\n end", "def remove_control_characters\n # Don't mess with existing keys (since cannot change key text anyway)\n return if !new_record?\n\n # First -- let the first control char or space stand (to divide key type from key)\n # Really, this is catching a special case in which there is a \\n between type and key.\n # Most common case turns first space back into space....\n self.key = key.sub(/[ \\r\\n\\t]/, ' ')\n\n # Next, if comment divided from key by control char, let that one stand as well\n # We can only tell this if there is an \"=\" in the key. So, won't help 1/3 times.\n self.key = key.sub(/=[ \\r\\n\\t]/, '= ')\n\n # Delete any remaining control characters....\n self.key = key.gsub(/[\\a\\r\\n\\t]/, '').strip\n end", "def add_server(key, data)\n rightscale_deprecated[:server] = Mash.new unless rightscale_deprecated.has_key?(:server)\n server_names = {\n \"RS_sketchy\" => \"sketchy\",\n \"RS_syslog\" => \"syslog\",\n \"RS_lumberjack\" => \"lumberjack\",\n \"RS_server\" => \"core\"\n }\n rightscale_deprecated[:server][server_names[key]] = data unless (server_names[key] == nil)\nend", "def rewrap(key, ciphertext, client = self.client)\n if ciphertext.nil? || ciphertext.empty?\n return ciphertext\n end\n\n key = key.to_s unless key.is_a?(String)\n route = File.join(\"transit\", \"rewrap\", key)\n\n with_retries_and_reauthentication do\n if self.enabled?\n secret = client.logical.write(route,\n ciphertext: ciphertext,\n )\n result = secret.data[:ciphertext]\n else\n result = ciphertext\n end\n return self.force_encoding(result)\n end\n end", "def replaceMessage( msg )\n print ErasePreviousLine\n message( msg )\n end", "def replace_data(new_data)\n @data = new_data\n end", "def remove_control_characters\n # Don't mess with existing keys (since cannot change key text anyway)\n return if !new_record?\n\n # First -- let the first control char or space stand (to divide key type from key)\n # Really, this is catching a special case in which there is a \\n between type and key.\n # Most common case turns first space back into space....\n self.key=key.sub(/[ \\r\\n\\t]/,' ')\n\n # Next, if comment divided from key by control char, let that one stand as well\n # We can only tell this if there is an \"=\" in the key. So, won't help 1/3 times.\n self.key=key.sub(/=[ \\r\\n\\t]/,'= ')\n\n # Delete any remaining control characters....\n self.key=key.gsub(/[\\a\\r\\n\\t]/,'').strip\n end", "def raw_data=(new_data)\n new_data = Mash.new(new_data)\n new_data.delete(SecureDataBag::METADATA_KEY)\n super(decrypt_data!(new_data))\n end", "def replace_data new_data\n @data = new_data\n save\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
prepend [noreply]\r\n prepend add this data to an existing key before existing data.
def prepend (key,value) msj = "prepend #{key} 0 0 #{value.length}\r\n#{value}\r\n" @socket.puts(msj) respuesta = @socket.gets.chomp return respuesta end
[ "def prepend(key, length, data)\n end", "def prepend(key, value)\n perform(:prepend, key, value.to_s)\n end", "def prepend(key, value)\n value.then do |resolved_value|\n @client.perform(:prepend, key, resolved_value.to_s)\n end\n end", "def prepend(*args)\n data = join_data(args)\n @data = data + @data\n\n data\n end", "def prepend(key, cmd, options = {})\n case key\n when 'dummy'\n puts \"CommandModifiers: dummy, modifier: dummy, prepend, cmd: #{cmd}, options: #{options.to_s}\"\n cmd\n end\n end", "def prepend(data)\n node = Node.new(data)\n node.next_node = @head\n @head = node\n end", "def prepend(client, key, flag ,expiration, size, value, no_reply) \r\n \r\n storedData = get_data(key) \r\n \r\n if has_expired?(key)\r\n purge_expired(key)\r\n raise \"NOT_STORED\\r\\n\" \r\n end \r\n \r\n if(storedData == nil)\r\n raise \"NOT_STORED\\r\\n\" \r\n end\r\n\r\n storedData.semaphore.synchronize{\r\n cas_unique = rand(2**32..2**64-1)\r\n new_value = \"#{value}#{storedData.value}\"\r\n data = SavedData.new(new_value, storedData.flag, cas_unique, storedData.size + size)\r\n set_data(key, data) \r\n \r\n if(!no_reply)\r\n client.print(\"STORED\\r\\n\")\r\n end\r\n }\r\n end", "def prepend(input, string); end", "def prepend(entry=SymMap.new)\r\n @list.insert(0, entry)\r\n end", "def prepend(*args)\n update(*args)\n @list.unshift(args[0])\n end", "def prepend(entry)\n node = new_node(entry)\n node.next_node = head\n @head = node\n end", "def prepend(selector, content = nil, &block)\n @commands[:prepend] ||= {}\n content ||= yield\n @commands[:prepend][selector] = content\n end", "def prepend_header(name, value)\n original = tmail[name] || []\n tmail[name] = nil\n tmail[name] = sanitize_header(charset, name, value)\n tmail[name] = tmail[name] + original\n end", "def prepend_key!(prefix)\n return unless self.is_a?(Hash)\n Hash[self.map { |k, v| [\"#{prefix}_#{k}\", v] }]\n end", "def test_prepend_adds_data_to_front_of_list\n linkedlist = Linkedlist.new(\"dep do dee\")\n linkedlist.prepend(\"dee do dee\")\n assert_equal \"dee\", linkedlist.head.data\n end", "def prepend(opts)\n playlist_control :insert, opts\n end", "def prepend(value)\n @data.prepend(value.dup.force_encoding(Encoding::BINARY))\n self\n end", "def payload_prepend(explicit_target = nil)\n explicit_target ||= target\n\n if (explicit_target and explicit_target.payload_prepend)\n p = explicit_target.payload_prepend\n else\n p = payload_info['Prepend'] || ''\n end\n\n stack_adjustment + p\n end", "def payload_prepend\n opts['Payload'] ? opts['Payload']['Prepend'] : nil\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For an array sorted in ascending order, searches for 'value_to_find'. Returns true if found, false otherwise. Complexity assessment: Note: where n = length of the input array Time complexity: O(log n); logarithmic; half of array is eliminated with each search: doubling size of array only increases search count by 1 Space complexity: O(1); constant; does not require new vars aside from begin_ind (int), end_ind (int), and midpoint (int)
def binary_search(array, length, value_to_find) begin_ind = 0 end_ind = length - 1 while begin_ind <= end_ind midpoint = (begin_ind + end_ind) / 2 if array[midpoint] == value_to_find return true elsif array[midpoint] > value_to_find end_ind = midpoint - 1 else begin_ind = midpoint + 1 end end return false # raise NotImplementedError end
[ "def linear_search_sorted(arr, value)\n size = arr.length\n i = 0\n while i < size\n if value == arr[i]\n return true\n elsif value < arr[i] # Stops loop from searching until end of array\n return false\n end\n\n i += 1\n end\n false\nend", "def search_array(array, value)\n if array.include?(value)\n index = 0\n while index < array.length\n if array[index] == value\n value_index = index\n end\n index += 1\n end\n else value_index = nil\n end\n value_index\nend", "def search(array, length, value_to_find)\n\n # edge case\n return false if length == 0\n\n i = 0\n while i < length \n return true if array[i] == value_to_find \n i += 1\n end \n\n return false\nend", "def search(array, length, value_to_find)\n index = 0\n\n while index < length\n if value_to_find == array[index]\n return true\n end\n index += 1\n end\n\n return false\nend", "def linear_search_unsorted(arr, value)\n size = arr.length\n i = 0\n while i < size\n return true if value == arr[i]\n\n i += 1\n end\n false\nend", "def binary_search(array, value, start_index, end_index)\r\n if start_index <= end_index\r\n mid_index = (start_index+end_index)/2\r\n\r\n if value == array[mid_index]\r\n return mid_index\r\n elsif value < array[mid_index]\r\n return binary_search(array, value, start_index, mid_index-1)\r\n elsif value > array[mid_index]\r\n return binary_search(array, value, mid_index+1, end_index)\r\n end\r\n end\r\n\r\n return false\r\nend", "def binary_search(value_were_looking_for, array, beginning_index, end_index)\n if subarray_has_only_one_element(beginning_index, end_index) # base case\n if array[beginning_index] == value_were_looking_for\n return beginning_index \n else\n return nil\n end\n else\n index_of_midpoint = check_midpoint_of_subarray(beginning_index, end_index)\n if array[index_of_midpoint] == value_were_looking_for\n return index_of_midpoint\n elsif array[index_of_midpoint] > value_were_looking_for\n binary_search(value_were_looking_for, array, beginning_index, index_of_midpoint - 1)\n elsif array[index_of_midpoint] < value_were_looking_for\n binary_search(value_were_looking_for, array, index_of_midpoint + 1, end_index)\n end\n end\nend", "def search(array, size, value_to_find)\n i = 0\n result = false\n while i < size\n # binding.pry\n if array[i] == value_to_find\n # binding.pry\n result = true\n end\n # return true if array[i] == value_to_find\n i += 1\n end\n # binding.pry\n return result\nend", "def binary_search(array, value)\n left_boundary = 0\n right_boundary = array.size - 1\n loop do\n midpoint = (left_boundary + right_boundary) / 2\n value_at_midpoint = array[midpoint]\n break midpoint if value_at_midpoint == value\n if value_at_midpoint < value\n left_boundary = midpoint + 1\n else value_at_midpoint > value\n right_boundary = midpoint - 1\n end\n break nil if left_boundary > right_boundary\n end\nend", "def binary_search(sorted_array, value)\n _binary_search(0, sorted_array.length, sorted_array, value)\nend", "def binary_search(array, length, value_to_find)\n mid_point = length/2\n mid = array[mid_point]\n counter = 0\n\n until mid == value_to_find || counter > length\n if mid > value_to_find\n mid_point = mid_point/2\n else \n mid_point = (length - mid_point)/2 + mid_point\n end\n\n mid = array[mid_point]\n counter += 1\n end\n\n mid == value_to_find\nend", "def include?(arr, search_value)\n found = false\n index = 0\n\n while !found && index < arr.size\n found = true if arr[index] == search_value\n index += 1\n end\n\n found\nend", "def find_element_index(array, value_to_find)\n count = 0 \n while count < array.length do \n if array[count] == value_to_find\n return count \n end \n count += 1 \n end \nend", "def find_index_of_value_in_array(value, array)\n index = 0\n while index < array.length do \n if array[index] == value\n return index\n end\n index += 1\n end\n nil\nend", "def binary_search(array, target)\n lower_bound = 0\n upper_bound = array.length - 1\n while lower_bound <= upper_bound\n midpoint = (lower_bound + upper_bound) / 2\n value_at_midpoint = array[midpoint]\n if target = value_at_midpoint\n return midpoint\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n end\n end\n return nil\nend", "def linearSearch(array, value)\n \n array.each do|a|\n if a == value\n return value \n end \n end \n \n end", "def binary_search(arr, target, min_idx, max_idx)\n # Ensure valid arguments\n raise ArgumentError, \"The first argument must be an array.\" unless arr.is_a?(Array)\n raise ArgumentError, \"The array provided must contain all integer values.\" unless arr.all? {|el| el.is_a?(Integer)}\n raise ArgumentError, \"The target must be an integer value.\" unless target.is_a?(Integer)\n\n return nil if arr.size == 0\n return nil if target < arr[min_idx] || target > arr[max_idx]\n\n while min_idx <= max_idx do\n mid_idx = min_idx + (max_idx - min_idx)/2\n\n return mid_idx if arr[mid_idx] == target\n\n if target < arr[mid_idx]\n max_idx = mid_idx - 1\n else\n min_idx = mid_idx + 1\n end\n end\n\n nil\nend", "def search(arr, x)\n (0..arr.count).each do |i|\n return i if arr[i] == x\n end\n -1\nend", "def where_in_array(number)\n high = @size - 1\n low = 0\n\n while low <= high\n mid = (low + high) / 2\n # puts \"low #{low}, high #{high}, mid#{mid}\"\n if number == @array[mid]\n return mid\n elsif number < @array[mid]\n high = mid - 1\n else\n low = mid + 1\n end\n end\n\n -1\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /event_questions/1 GET /event_questions/1.json
def show @event_question = EventQuestion.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @event_question } end end
[ "def new\n @event_question = EventQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_question }\n end\n end", "def questions\n self.class.get('/2.2/questions', @options)\n end", "def getsurveyquestion_app\n response = getsurvey_question(params[:form_id].to_i)\n if response.present?\n puts \"Got all survey questions!\"\n render json: { message: response }, status: 200 \n else\n puts \"Could not get survey questions!\"\n render json: { message: 'Could not get survey questions!'}, status: 403\n end\n end", "def show\n @question = @exam.questions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end", "def get_question\n uri = 'http://jservice.io/api/random?count=1'\n request = HTTParty.get(uri)\n puts \"[LOG] #{request.body}\"\n response = JSON.parse(request.body).first\n # Some questions have no question, some have been marked invalid by the admin\n if response['question'].nil? || response['question'].strip == '' ||\n (!response['invalid_count'].nil? && response['invalid_count'].to_i > 0)\n response = get_question\n end\n response['value'] = 200 if response['value'].nil?\n response['answer'] = Sanitize.fragment(response['answer'].gsub(/\\s+(&nbsp;|&)\\s+/i, ' and '))\n response['expiration'] = params['timestamp'].to_f + ENV['SECONDS_TO_ANSWER'].to_f\n response\nend", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def create\n @event_question = EventQuestion.new(params[:event_question])\n @event_question.event_id = params[:event_id]\n \n @event = Event.find(@event_question.event_id)\n\n respond_to do |format|\n if @event_question.save\n format.html { redirect_to @event, notice: 'Event question was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end", "def index\n render json: @test_module.test_questions, status: :ok\n end", "def show\n @problem_event = ProblemEvent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @problem_event }\n end\n end", "def show\n @interview_question = InterviewQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interview_question }\n end\n end", "def show\n render json: @question\n #@questions = Question.order(\"RANDOM()\").limit(1)\n #render json: @questions\n end", "def show\n \n @dquestion = Dquestion.find(params[:id])\n session[:quest_id] = @dquestion.id\n @danswers = Danswer.where(dquestion_id: @dquestion.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: [@dtest, @dquestion] }\n end\n end", "def show\n @exam_question = ExamQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_question }\n end\n end", "def index\n @api_v1_questions = Api::V1::Question.all\n end", "def show\n @good_question = GoodQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @good_question }\n end\n end", "def show\n @quick_question = QuickQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quick_question }\n end\n end", "def destroy\n @event_question = EventQuestion.find(params[:id])\n @event_question.destroy\n\n respond_to do |format|\n format.html { redirect_to event_questions_url }\n format.json { head :no_content }\n end\n end", "def index\n @my_questions = MyQuestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_questions }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /event_questions/new GET /event_questions/new.json
def new @event_question = EventQuestion.new respond_to do |format| format.html # new.html.erb format.json { render json: @event_question } end end
[ "def new\n @question = Question.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def create\n @event_question = EventQuestion.new(params[:event_question])\n @event_question.event_id = params[:event_id]\n \n @event = Event.find(@event_question.event_id)\n\n respond_to do |format|\n if @event_question.save\n format.html { redirect_to @event, notice: 'Event question was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @time_series_question = @time_series.questions.build\n @datasets = @time_series.datasets.sorted\n # build the dataset questions\n @datasets.each do |dataset|\n @time_series_question.dataset_questions.build(dataset_id: dataset.dataset_id)\n end\n\n # get the list of questions for each dataset in the time series that are not already in the time series\n @questions = {}\n @datasets.each do |ts_dataset|\n @questions[ts_dataset.dataset_id.to_s] = ts_dataset.dataset.questions.for_analysis_not_in_codes(@time_series.questions.codes_for_dataset(ts_dataset.dataset_id))\n end\n\n add_common_options\n\n @is_new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_series_question }\n end\n end", "def new\n @quick_question = QuickQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_question }\n end\n end", "def new\n @test_question = TestQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @test_question }\n end\n end", "def new\n @good_question = GoodQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @good_question }\n end\n end", "def new\n @critical_question = CriticalQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_question }\n end\n end", "def new\n @question_response = QuestionResponse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_response }\n end\n end", "def new\n @enq_question = EnqQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enq_question }\n end\n end", "def new\n @interview_question = InterviewQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interview_question }\n end\n end", "def new\n @problem_event = ProblemEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem_event }\n end\n end", "def new\n @event_req = EventReq.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_req }\n end\n end", "def new\n @select_question = SelectQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @select_question }\n end\n end", "def new\n @question_template = QuestionTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_template }\n end\n end", "def new\n @questions_category = QuestionsCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questions_category }\n end\n end", "def new\n @poll_question = PollQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_question }\n end\n end", "def new\n @quest = Quest.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end", "def new\n @survey_question = SurveyQuestion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @survey_question }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /event_questions POST /event_questions.json
def create @event_question = EventQuestion.new(params[:event_question]) @event_question.event_id = params[:event_id] @event = Event.find(@event_question.event_id) respond_to do |format| if @event_question.save format.html { redirect_to @event, notice: 'Event question was successfully created.' } format.json { render json: @event, status: :created, location: @event } else format.html { render action: "new" } format.json { render json: @event.errors, status: :unprocessable_entity } end end end
[ "def new\n @event_question = EventQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_question }\n end\n end", "def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def for_create_question(questions, answer_options)\n answer_options.each do |op|\n questions.answer_options.create(answer: op)\n end\n response = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }; answers = []\n questions.answer_options.each do |ans_opt|\n answers << { option: ans_opt.answer }\n end\n response[:question] = { id: questions.id, question: questions.question, points: questions.points, correct_option: questions.correct_option, options: answers }\n PushNotification.new(@user.device_token, 'Quiz', \"New quiz is available\").Send_Notification\n render json: response, status => 200\n end", "def create\n @question = Question.new(question_params)\n\n if @question.save\n render json: @question\n else\n render status: 400, nothing: true\n end\n end", "def create\n @question = Question.new(question_params)\n\n if @question.save\n render json: @question, status: :created, location: @question\n else\n render json: @question.errors, status: :unprocessable_entity\n end\n end", "def create\n @time_series_question = @time_series.questions.build(params[:time_series_question])\n\n respond_to do |format|\n if @time_series_question.save\n format.html { redirect_to time_series_question_path(@owner, @time_series, @time_series_question), flash: {success: t('app.msgs.success_created', :obj => t('mongoid.models.time_series_question.one'))} }\n format.json { render json: @time_series_question, status: :created, location: @time_series_question }\n else\n @datasets = @time_series.datasets.sorted\n\n # get the list of questions for each dataset in the time series that are not already in the time series\n @questions = {}\n @datasets.each do |dataset|\n @questions[ts_dataset.dataset_id.to_s] = ts_dataset.dataset.questions.for_analysis_not_in_codes(@time_series.questions.codes_for_dataset(dataset.dataset_id))\n end\n\n add_common_options\n\n @is_new = true\n\n format.html { render action: \"new\" }\n format.json { render json: @time_series_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_question\n form_param = params.require(:form).permit(:id)\n\n render json: Question.add_new_question(form_param)\n end", "def create\n @test_question = TestQuestion.new(params[:test_question])\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, :notice => 'Test question was successfully created.' }\n format.json { render :json => @test_question, :status => :created, :location => @test_question }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @test_question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(params[:question])\n\t\t@exam.questions << @question\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to [:teacher, @course, @exam, @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 create\n @event_answer = EventAnswer.new(event_answer_params)\n\n respond_to do |format|\n if @event_answer.save\n format.html { redirect_to @event_answer, notice: 'Event answer was successfully created.' }\n format.json { render :show, status: :created, location: @event_answer }\n else\n format.html { render :new }\n format.json { render json: @event_answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def question(data)\n xml = xml_root(\"questions\")\n\n arrayed(data).each do |name|\n xml.root << (XML::Node.new(\"question\") << name)\n end\n\n send_and_process('questions/add', 'questions/question', xml)\n end", "def create\n @test_question = TestQuestion.new(test_question_params)\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, notice: 'Test question was successfully created.' }\n format.json { render :show, status: :created, location: @test_question }\n else\n format.html { render :new }\n format.json { render json: @test_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n get_event\n @event_exam = @event.exams.create(params[:event_exam])\n\n respond_to do |format|\n format.html { redirect_to event_event_exam_path(@event, @event_exam), notice: 'Event exam was successfully created.' }\n # format.json { render json: @event_exam, status: :created, location: @event_exam }\n end\n end", "def destroy\n @event_question = EventQuestion.find(params[:id])\n @event_question.destroy\n\n respond_to do |format|\n format.html { redirect_to event_questions_url }\n format.json { head :no_content }\n end\n end", "def manage_question(body)\n upload_questions(JSON.parse(body)['questions'])\n get_questions\nend", "def create\n @enq_question = EnqQuestion.new(params[:enq_question])\n\n respond_to do |format|\n if @enq_question.save\n format.html { redirect_to @enq_question, notice: 'Enq question was successfully created.' }\n format.json { render json: @enq_question, status: :created, location: @enq_question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enq_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @time_series_question = @time_series.questions.build\n @datasets = @time_series.datasets.sorted\n # build the dataset questions\n @datasets.each do |dataset|\n @time_series_question.dataset_questions.build(dataset_id: dataset.dataset_id)\n end\n\n # get the list of questions for each dataset in the time series that are not already in the time series\n @questions = {}\n @datasets.each do |ts_dataset|\n @questions[ts_dataset.dataset_id.to_s] = ts_dataset.dataset.questions.for_analysis_not_in_codes(@time_series.questions.codes_for_dataset(ts_dataset.dataset_id))\n end\n\n add_common_options\n\n @is_new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_series_question }\n end\n end", "def create\n @question = Question.new(question_params)\n\n if @question.save\n respond_to do |format|\n format.json { render json: @question.to_json }\n format.html{redirect_to root_path}\n end\n else\n status 406\n render :index\n end\n\n end", "def show\n @event_question = EventQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_question }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /event_questions/1 DELETE /event_questions/1.json
def destroy @event_question = EventQuestion.find(params[:id]) @event_question.destroy respond_to do |format| format.html { redirect_to event_questions_url } format.json { head :no_content } end end
[ "def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted question successfully'}, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ttest_question.destroy\n respond_to do |format|\n format.html { redirect_to ttest_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_question = TestQuestion.find(params[:id])\n @test_question.destroy\n\n respond_to do |format|\n format.html { redirect_to test_questions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event_req = EventReq.find(params[:id])\n @event_req.destroy\n\n respond_to do |format|\n format.html { redirect_to event_reqs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n get_event\n @event_exam = @event.exams.find(params[:id])\n @event_exam.destroy\n\n respond_to do |format|\n format.html { redirect_to event_exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_interview_question.destroy\n respond_to do |format|\n format.html { redirect_to admin_interview_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_question = V1::Question.find(params[:id])\n @v1_question.destroy\n\n head :no_content\n end", "def destroy\n @api_v1_question.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @examquestion.destroy\n respond_to do |format|\n format.html { redirect_to examquestions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @enq_question = EnqQuestion.find(params[:id])\n @enq_question.destroy\n\n respond_to do |format|\n format.html { redirect_to enq_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_question.destroy\n render json: get_survey_questions\n end", "def destroy\n @exam_question = ExamQuestion.find(params[:id])\n @exam_question.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = @test.questions.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @subtask_question.destroy\n respond_to do |format|\n format.html { redirect_to subtask_questions_url }\n format.json { head :no_content }\n end\n end", "def delete_survey_question(request)\n dashboard_request('DELETE', '/api/survey-questions/' + request[:questionId], request)\n end", "def destroy\n @time_series_question = @time_series.questions.find(params[:id])\n @time_series_question.destroy\n\n respond_to do |format|\n format.html { redirect_to time_series_questions_url(@time_series.owner), flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.time_series_question.one'))} }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_question.destroy\n respond_to do |format|\n format.html { redirect_to my_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @askquestion.destroy\n respond_to do |format|\n format.html { redirect_to askquestions_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an image tag for an image exactly 75x75 djatoka_smallbox_image_tag('info:lanlrepo/ds/5aa182c2c0924596af6ee95d2e263de3')
def djatoka_smallbox_image_tag(rft_id, params={}) url = djatoka_smallbox_image_url(rft_id, params) image_tag url, clean_square_image_tag_params(params) end
[ "def thumbnail_in_box(image, width, height)\n image_tag(image.medium_url, ls_image_options(image, width, height))\n end", "def smaller_img\n return self.step_image.variant(resize: '750X750')\n end", "def image(size)\n\t\t\tsearch_xml(\"//artist/image[@size='#{size}']\").first.inner_html rescue \"\"\n\t\tend", "def small_image\n @images.select { |image| image.image_name == 'SMALL' }.first\n end", "def post_image_large(entity, add_options = {})\n return '' if entity.image.blank?\n\n alt_text = entity.image_alt_text.to_s\n versions = \"#{entity.image.hd.url} 2x\"\n options = { alt: alt_text, srcset: versions }.merge(add_options)\n image_tag(entity.image.big.url, options)\n end", "def image_url\n self.image.try(:box_size_url)\n end", "def summary_image\n account_image = object.image\n return unless account_image\n\n h.content_tag :span, class: 'input-group-addon account-image' do\n h.image_tag account_image, size: '32x32'\n end\n end", "def clubthumbnail_tag(club)\n image_tag(club.clubavatar.thumbnail_url, :border => 0)\n end", "def thumbnail_small\n return nil if @result.nil?\n @result[\"items\"][0][\"volumeInfo\"][\"imageLinks\"][\"smallThumbnail\"]\n end", "def avatar_thumbnail (image)\n return self.images[image].variant(resize_to_fill:[200,200]).processed\n end", "def thumbnail_tag(user)\n image_tag(user.photo.thumbnail_url, :border => 1)\n end", "def large_image_width\n 850\n end", "def display_image\n image.variant(resize_to_limit: [500,500])\n end", "def image_for(property, size)\n \tif property.image.exists?\n image_tag(property.image.url(size))\n else\n image_tag('placeholder.png')\n end\n end", "def display_image\n image.variant(resize_to_limit: [500, 500])\n end", "def square_image_url\n \"#{image_url}?type=square\"\n end", "def image_on_steroids(image, alt:, sizes: [], square: false, html_class: \"\")\n srcset = []\n\n if image.present? && image.variable?\n sizes.each do |size|\n resize_to_fit = [size, (square ? size : nil)]\n srcset << [url_for(image.variant(resize_to_fit: resize_to_fit)), \"#{size}w\"]\n end\n else\n image = \"no-image.jpg\"\n\n sizes.each do |size|\n srcset << [image_url(\"no-image-#{size}.jpg\"), \"#{size}w\"]\n end\n end\n\n image_tag image, alt: alt, class: html_class, srcset: srcset\n end", "def xf_image_tag (src, attrs = {})\n attrs = attrs.symbolize_keys()\n content = \"\"\n caption = attrs.delete(:caption)\n unless caption.nil?\n content += typeWithAttrs(\"caption\", caption, nil, xhtml2prefix)\n end\n width = attrs.delete(:width)\n unless width.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-width\", :value => width}, xhtml2prefix)\n end\n height = attrs.delete(:height)\n unless height.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-height\", :value => height}, xhtml2prefix)\n end\n attrs[:src] = src\n typeWithAttrs(\"object\", content, attrs, xhtml2prefix)\n end", "def thumbnail(size); end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Include djatoka_openlayers_script on any page you need pan and zoom to include the scripts OpenLayers, OpenURL and djatoka. Including those scripts is required for djatoka_init_openlayers to work.
def djatoka_openlayers_script jquery = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>' jquery + javascript_include_tag('OpenLayers','OpenURL', 'djatoka') end
[ "def djatoka_init_openlayers(rft_id, div_identifier, params={})\n resolver = determine_resolver(params)\n metadata_url = resolver.metadata_url(rft_id)\n %Q|<script type=\"text/javascript\">\n jQuery(document).ready(function() {openlayersInit('#{resolver.scheme}://#{resolver.host}',\n '#{metadata_url}',\n '#{rft_id}', '#{div_identifier}');\n });\n </script>\n |\n end", "def gmaps4rails_api_script_tags(options = {})\n if include_gmaps4rails_api_in_header?\n options.merge!({ :scripts => :api }) # request only api scripts, here.\n api_urls = Gmaps4rails::ViewHelper.new(options).js_dependencies_array\n javascript_include_tag *api_urls\n end\n end", "def include_javascript_for_catalog_show\n javascript_includes << ['custom', {:plugin=>\"hydra-head\"}] \n \n # This file contains the page initialization scripts for catalog show views\n javascript_includes << [\"catalog/show\", {:plugin=>\"hydra-head\"}]\n end", "def initializer_function\n %{<script type=\"text/javascript\">\n var map_options = #{options_to_json};\n onload_before_#{name} = typeof window.onload == 'function' ? window.onload : function(){};\n window.onload = function(){\n onload_before_#{name};\n phoenix_cartographer.init_map('#{name}', map_options);\n map_options = null;\n }\n </script>\n }.minified!\n end", "def enable_gmaps\n content_for :scripts do\n javascript_include_tag(\"gmaps4rails/gmaps4rails.base\") <<\n javascript_include_tag(\"gmaps4rails/gmaps4rails.googlemaps\")\n end\n end", "def use_jquerytools\n #use_jquery # required for ie bug?\n javascript_place :js_libs, 'jQuery/jquerytools-1.1.2.min', 'application_jquery'\n #@@jquery_loaded = true\n end", "def init_zoom\n @zoom = PSDK_CONFIG.specific_zoom || ZoomDiv[1]\n @add_z = @zoom\n end", "def header()\n apikey = \"ABQIAAAAmxDIRcelCE7QQOeFeIJlKBTGG_UT9D1o9I64E2gi7TbsJ77h0BRE8mxlSeFh8c_V1P1tW2oE4WQWSg\"\n apikey = \"ABQIAAAAmxDIRcelCE7QQOeFeIJlKBSbofJ6434O1fjLInemwcEZUD5mwBQzVbYptimtJHQhOlybNCur67h9EQ\"\n # TODO disabled fix apikey = ApiKey.get({:with_vml=>true})\n # TODO use this - breaks older toosl: <script src=\"http://www.google.com/jsapi?key=#{apikey}\" type=\"text/javascript\"></script>\n # TODO use this - breaks in latest google maps as well: <link href=\"/dynamapper/opacityWindow.css\" rel=\"stylesheet\" type=\"text/css\" />\n<<ENDING\n<style type=\"text/css\">\n div.markerTooltip, div.markerDetail {\n color: black;\n font-weight: bold;\n background-color: white;\n white-space: nowrap;\n margin: 0;\n padding: 2px 4px;\n border: 1px solid black;\n }\n</style>\n<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=#{apikey}\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\" src=\"/dynamapper/pdmarker.js\"></script>\n<script src=\"/dynamapper/extinfowindow_packed.js\" type=\"text/javascript\"></script>\n<script src=\"/dynamapper/tooltip.js\" type=\"text/javascript\"></script>\n<script>\n// the header declares these stubs which may be overriden by body code\nvar map_marker_chase = false;\nvar use_google_popup = true;\nvar use_pd_popup = false;\nvar use_tooltips = false;\nvar map_div = null;\nvar map = null;\nvar mgr = null;\nvar map_icons = [];\nvar map_markers = [];\nvar map_marker;\nvar lat = 28.000;\nvar lon = -90.500;\nvar zoom = 1;\n</script>\nENDING\n end", "def center_map_js\n if self.zoom\n zoom_js = zoom\n else\n zoom_js = \"#{dom_id}.getBoundsZoomLevel(#{dom_id}_latlng_bounds)\"\n end\n set_center_js = []\n \n if self.center\n set_center_js << \"#{dom_id}.setCenter(new GLatLng(#{center.lat}, #{center.lng}), #{zoom_js});\"\n else\n synch_bounds\n set_center_js << \"var #{dom_id}_latlng_bounds = new GLatLngBounds();\"\n \n bounds.each do |point|\n set_center_js << \"#{dom_id}_latlng_bounds.extend(new GLatLng(#{point.lat}, #{point.lng}));\"\n end \n \n set_center_js << \"#{dom_id}.setCenter(#{dom_id}_latlng_bounds.getCenter(), #{zoom_js});\"\n end\n \n \"function center_#{dom_id}() {\\n #{check_resize_js}\\n #{set_center_js.join \"\\n\"}\\n}\"\n end", "def include_javascript_for_catalog_edit\n # This _would_ include the fluid infusion javascripts, but we don't want them\n # javascript_includes << infusion_javascripts(:default_no_jquery, :extras=>[:inline_editor_integrations], :debug=>true, :render_html=>false)\n \n javascript_includes << [\"jquery.jeditable.mini.js\", {:plugin=>\"hydra-head\"}]\n javascript_includes << [\"jquery.form.js\", {:plugin=>\"hydra-head\"}]\n javascript_includes << ['custom', {:plugin=>\"hydra-head\"}]\n \n javascript_includes << [\"jquery.hydraMetadata.js\", {:plugin=>\"hydra-head\"}]\n javascript_includes << [\"jquery.notice.js\", {:plugin=>\"hydra-head\"}]\n \n javascript_includes << [\"jquery.jeditable.mini.js\", \"date-picker/js/datepicker\", \"jquery.form.js\", 'custom', \"catalog/edit\", \"jquery.hydraMetadata.js\", \"jquery.notice.js\", {:plugin=>\"hydra-head\"}]\n # For DatePicker\n javascript_includes << [\"jquery.ui.widget.js\",\"jquery.ui.datepicker.js\", \"mediashelf.datepicker.js\", {:plugin=>\"hydra-head\" }]\n \n # For Fancybox\n javascript_includes << [\"fancybox/jquery.fancybox-1.3.1.pack.js\", {:plugin=>\"hydra-head\"}] \n stylesheet_links << [\"/javascripts/fancybox/jquery.fancybox-1.3.1.css\", {:plugin=>\"hydra-head\"}] \n\n # For slider controls \n javascript_includes << [\"select_to_ui_slider/selectToUISlider.jQuery.js\", {:plugin=>\"hydra-head\"}] \n stylesheet_links << [\"/javascripts/select_to_ui_slider/css/ui.slider.extras.css\", {:plugin=>\"hydra-head\"}] \n stylesheet_links << [\"slider\", {:plugin=>\"hydra-head\"}] \n \n # This file contains the page initialization scripts for catalog edit views\n javascript_includes << [\"catalog/edit\", {:plugin=>\"hydra-head\"}]\n end", "def center_on_markers_function_js\r\n js = []\r\n js << \"function centerzoom_#{dom_id}(center, zoom) {\"\r\n\r\n # Calculate the bounds of the markers\r\n js << \" if (!center || !zoom) {\"\r\n js << \" var bounds = new GLatLngBounds();\"\r\n js << \" for(marker in #{dom_id}_markers) {\"\r\n js << \" bounds.extend(#{dom_id}_markers[marker].getLatLng());\"\r\n js << \" }\"\r\n js << \" }\"\r\n js << \" if (!center) { center = bounds.getCenter(); }\"\r\n js << \" if (!zoom) {\"\r\n js << \" zoom = #{dom_id}.getBoundsZoomLevel(bounds);\"\r\n js << \" if (zoom < #{min_zoom}) { zoom = #{min_zoom}; }\" if min_zoom\r\n js << \" if (zoom > #{max_zoom}) { zoom = #{max_zoom}; }\" if max_zoom\r\n js << \" }\"\r\n\r\n js << \" #{dom_id}.checkResize();\"\r\n js << \" #{dom_id}.setCenter(center, zoom);\"\r\n js << \"}\"\r\n\r\n return js.join(\"\\n\")\r\n end", "def to_js(include_onload = true)\r\n html = []\r\n html << \"// define the map-holding variable so we can use it from outside the onload event\" if @debug\r\n html << \"var #{@dom_id};\\n\"\r\n html << \"// define the marker variables for your map so they can be accessed from outside the onload event\" if @debug\r\n @markers.collect do |m| \r\n html << \"var #{m.name};\" unless m.info_window_url\r\n html << m.header_js\r\n end\r\n \r\n html << \"// define the map-initializing function for the onload event\" if @debug\r\n html << \"function initialize_gmap_#{@dom_id}() {\r\nif (!GBrowserIsCompatible()) return false;\r\n#{@dom_id} = new GMap2(document.getElementById(\\\"#{@dom_id}\\\"));\"\r\n\r\n html << \" #{@dom_id}.disableDragging();\" if @draggable == false\r\n \r\n if( @zoom == :bound )\r\n sw_ne = self.bounding_points\r\n html << \"#{@dom_id}.setCenter(new GLatLng(0,0),0);\\n\"\r\n html << \"var #{@dom_id}_bounds = new GLatLngBounds(new GLatLng(#{sw_ne[0][0]}, #{sw_ne[0][1]}), new GLatLng(#{sw_ne[1][0]}, #{sw_ne[1][1]}));\\n\"\r\n html << \"#{@dom_id}.setCenter(#{@dom_id}_bounds.getCenter());\\n\"\r\n html << \"#{@dom_id}.setZoom(#{@dom_id}.getBoundsZoomLevel(#{@dom_id}_bounds));\\n\"\r\n else\r\n html << \"#{@dom_id}.setCenter(new GLatLng(#{@center[0]}, #{@center[1]}), #{@zoom});\\n\"\r\n end\r\n\r\n html << \" // set the default map type\" if @debug \r\n html << \" #{@dom_id}.setMapType(G_#{@type.to_s.upcase}_MAP);\\n\"\r\n\r\n html << \" // define which controls the user can use.\" if @debug \r\n @controls.each do |control|\r\n html << \" #{@dom_id}.addControl(new \" + case control\r\n when :large, :small, :overview\r\n \"G#{control.to_s.capitalize}MapControl\"\r\n when :scale\r\n \"GScaleControl\"\r\n when :type\r\n \"GMapTypeControl\"\r\n when :zoom\r\n \"GSmallZoomControl\"\r\n when :overview\r\n \"GOverviewMapControl\"\r\n end + \"());\"\r\n end\r\n\r\n html << \"\\n // create markers from the @markers array\" if @debug\r\n html << \"\\n setupMarkers();\" \r\n\r\n # trigger marker info window is current_marker is defined\r\n (html << \"GEvent.trigger(#{@current_marker}, \\\"click\\\");\\n\") unless @current_marker.nil?\r\n\r\n html << \" // create polylines from the @polylines array\" if @debug\r\n @polylines.each { |pl| html << pl.to_js }\r\n \r\n # ending the gmap_#{name} function\r\n html << \"}\\n\"\r\n \r\n html << \"function setupMarkers(){\"\r\n \r\n # Render the Icons\r\n html << \" // create icons from the @icons array\" if @debug\r\n @icons.each { |i| html << i.to_js }\r\n \r\n html << \"mgr = new MarkerManager(#{@dom_id});\" if @marker_mgr\r\n hmarkers = Hash.new \r\n hmarkers_no_zoom =[]\r\n @markers.each do |m|\r\n if (m.min_zoom.nil?) || (m.min_zoom == '')\r\n hmarkers_no_zoom << m\r\n else\r\n hmarkers[m.min_zoom] = [] unless hmarkers[m.min_zoom]\r\n hmarkers[m.min_zoom] << m\r\n end\r\n end \r\n \r\n hmarkers.each do |zoom, markers|\r\n html << \"var batch#{zoom} = [];\"\r\n markers.each do |m|\r\n html << m.to_js(@marker_mgr)\r\n html << \"batch#{zoom}.push(#{m.name});\"\r\n end \r\n html << \"mgr.addMarkers(batch#{zoom}, #{zoom});\"\r\n end\r\n \r\n if (hmarkers_no_zoom.size > 0)\r\n html << \"var batch = [];\"\r\n hmarkers_no_zoom.each do |m| \r\n html << m.to_js(@marker_mgr)\r\n html << \"batch.push(#{m.name});\" if @marker_mgr\r\n end\r\n html << \"mgr.addMarkers(batch, 0);\" if @marker_mgr\r\n end\r\n html << \"mgr.refresh();\\n\" if @marker_mgr\r\n html << \"}\"\r\n \r\n html << \" // Dynamically attach to the window.onload event while still allowing for your existing onload events.\" if @debug\r\n\r\n # todo: allow for onload to happen before, or after, the existing onload events, like :before or :after\r\n if include_onload\r\n # all these functions need to be added to window.onload due to an IE bug\r\n @@window_onload << \"gmap_#{@dom_id}();\\n\"\r\n\r\n html << \"\r\nif (typeof window.onload != 'function')\r\n window.onload = initialize_gmap_#{@dom_id};\r\nelse {\r\n old_before_cartographer_#{@dom_id} = window.onload;\r\n window.onload = function() { \r\n old_before_cartographer_#{@dom_id}(); \r\n initialize_gmap_#{@dom_id}(); \r\n }\r\n}\" \r\n else #include_onload == false\r\n html << \"initialize_gmap_#{@dom_id}();\"\r\n end\r\n return @debug ? html.join(\"\\n\") : html.join.gsub(/\\s+/, ' ')\r\n end", "def center_map_js\r\n if markers.size == 0\r\n set_center_js = \"#{dom_id}.setCenter(new GLatLng(0, 0), 0);\"\r\n else\r\n\r\n if self.center\r\n max_lat = @center[0] + 0.05\r\n min_lat = @center[0] - 0.05\r\n max_lng = @center[1] + 0.05\r\n min_lng = @center[1] - 0.05\r\n\r\n center_js = \"new GLatLng(#{center[0]}, #{center[1]})\"\r\n else\r\n for marker in markers\r\n min_lat = marker.lat if !min_lat or marker.lat < min_lat\r\n max_lat = marker.lat if !max_lat or marker.lat > max_lat\r\n min_lng = marker.lng if !min_lng or marker.lng < min_lng\r\n max_lng = marker.lng if !max_lng or marker.lng > max_lng\r\n\r\n center_js = \"new GLatLng(#{(min_lat + max_lat) / 2}, #{(min_lng + max_lng) / 2})\"\r\n end\r\n end\r\n \r\n if self.zoom\r\n zoom_js = zoom\r\n else\r\n bounds_js = \"new GLatLngBounds(new GLatLng(#{min_lat}, #{min_lng}), new GLatLng(#{max_lat}, #{max_lng}))\"\r\n zoom_js = \"#{dom_id}.getBoundsZoomLevel(#{bounds_js})\"\r\n end\r\n\r\n set_center_js = \"#{dom_id}.setCenter(#{center_js}, #{zoom_js});\"\r\n end\r\n\r\n return \"function center_#{dom_id}() {\\n #{check_resize_js}\\n #{set_center_js}\\n}\"\r\n\r\n end", "def include_zoomify?\n # check is we are on the source controller and have a valid source stored\n return %{\n <!-- Zoomify swfobject registration BEGIN -->\n <script type=\"text/javascript\">\n swfobject.registerObject(\"zoomify_swf\", \"10.0.0\", \"/flash/expressInstall.swf\");\n </script>\n <!-- Zoomify swfobject registration END -->\n } unless @source.nil?\n end", "def google_map_delay_load\n content_for :javascripts do\n %Q^\n var google_map;\n \n function initialize_google_map(){\n #{@google_map_scripts}\n }\n function load_google_map() {\n var script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n script.src = \"http://maps.google.com/maps/api/js?sensor=false&callback=initialize_google_map\";\n document.body.appendChild(script);\n } \n ^.html_safe\n end\n \n content_for :javascript_ready do\n %Q^\n load_google_map();\n ^.html_safe\n end\n \n nil\n end", "def get_vendor_scripts\n case map_provider\n when \"yandex\" then @js_array << YANDEX\n when \"openlayers\" then @js_array << OPENLAYERS\n when \"mapquest\" then @js_array << \"#{MAPQUEST}?key=#{provider_key}\"\n when \"bing\" then @js_array << BING\n else #case googlemaps which is the default\n @js_array << \"#{GOOGLE}&sensor=false&client=#{client}&key=#{provider_key}&libraries=geometry#{google_libraries}&#{google_map_i18n}\"\n @js_array << \"#{GOOGLE_EXT}tags/infobox/1.1.9/src/infobox_packed.js\" if custom_infowindow_class\n @js_array << \"#{GOOGLE_EXT}tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js\" if do_clustering\n @js_array << \"#{GOOGLE_EXT}trunk/richmarker/src/richmarker-compiled.js\" if rich_marker\n end\n end", "def google_load_maps\n return '' if defined?(@google_load_maps_included)\n @google_load_maps_included = true\n (google_ajax_api_scripts + '<script type=\"text/javascript\">google.load(\"maps\", \"2\");</script>').html_safe\n end", "def to_html\n\n default_center = options[:default_center] || [42.90887521920127, 12.303765624999983]\n center = default_center\n\n height = options[:height] || '300px'\n fields = options[:fields] || [:lat, :lng]\n zoom_level = options[:zoom_level] || 5\n\n if zoom_level.is_a?(Proc)\n zoom_level = zoom_level.call(object)\n end\n\n raise ZoomInvalid unless zoom_level.is_a?(Integer)\n\n\n bootstrap_wrapping do\n content_tag(:div) do\n\n id = SecureRandom.hex\n\n callback_name = \"initMap#{id}\"\n\n buff = ActiveSupport::SafeBuffer.new\n\n buff<< content_tag(:div, :class => \"container_google_maps clearfix\", :style => 'width:100%;') do\n content_tag(:div, nil, id: id, style: \"height:#{height}\")\n end\n\n id_hidden_lat = SecureRandom.hex\n buff<< builder.hidden_field(fields[0], form_control_input_html_options.merge(:id => id_hidden_lat))\n id_hidden_lng = SecureRandom.hex\n buff<< builder.hidden_field(fields[1], form_control_input_html_options.merge(:id => id_hidden_lng))\n\n unless object.send(fields[0]).blank? or object.send(fields[1]).blank?\n center = [object.send(fields[0]), object.send(fields[1])]\n end\n\n buff<< content_tag(:script, :type => \"text/javascript\") do\n raw \"function #{callback_name}(){\n $('##{id}').kono_util_location_picker({\n center:{lat:#{center[0]},lng:#{center[1]}},\n zoom_level:#{zoom_level},\n selector_field_lat:'##{id_hidden_lat}',\n selector_field_lng:'##{id_hidden_lng}'\n });\n }\"\n end\n\n buff<< content_tag(:script, nil,\n src: \"https://maps.googleapis.com/maps/api/js?key=#{KonoUtils.configuration.google_api_key}&callback=#{callback_name}\",\n :type => \"text/javascript\", async: '', defer: '')\n\n buff\n\n end\n end\n end", "def load_map_js\n @db_check_delay = @@database_query_delay_seconds\n \n respond_to do |format|\n format.js\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
View helper to include a bit of jQuery on the page which waits for document load and then initializes the Ajax, OpenLayers viewer. Since this works via Ajax, Djatoka will need to be running or proxied at the same domain as the application to avoid crossdomain restrictions.
def djatoka_init_openlayers(rft_id, div_identifier, params={}) resolver = determine_resolver(params) metadata_url = resolver.metadata_url(rft_id) %Q|<script type="text/javascript"> jQuery(document).ready(function() {openlayersInit('#{resolver.scheme}://#{resolver.host}', '#{metadata_url}', '#{rft_id}', '#{div_identifier}'); }); </script> | end
[ "def djatoka_openlayers_script\n jquery = '<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"></script>'\n jquery + javascript_include_tag('OpenLayers','OpenURL', 'djatoka')\n end", "def load_page\n mount\n end", "def load_map_js\n @db_check_delay = @@database_query_delay_seconds\n \n respond_to do |format|\n format.js\n end\n end", "def show\n @mw_modeler_page = Embeddable::MwModelerPage.find(params[:id])\n if request.xhr?\n render :partial => 'show', :locals => { :mw_modeler_page => @mw_modeler_page }\n else\n respond_to do |format|\n format.html # show.html.haml\n format.otml { render :layout => \"layouts/embeddable/mw_modeler_page\" } # mw_modeler_page.otml.haml\n format.jnlp { render :partial => 'shared/installer', :locals => { :runnable => @mw_modeler_page } }\n format.config { render :partial => 'shared/show', :locals => { :runnable => @mw_modeler_page, :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]) } }\n format.dynamic_otml { render :partial => 'shared/show', :locals => {:runnable => @mw_modeler_page} }\n format.xml { render :mw_modeler_page => @mw_modeler_page }\n end\n end\n end", "def fetch_and_render_oembed(url)\n begin\n response = OEmbed::Providers.get(url.to_str)\n rescue\n response = nil\n end\n\n render(\n :partial => \"auto_oembed/#{response.type}\",\n :locals => {:oembed => response}\n ) unless response.nil?\n end", "def jquery\n page.jQuery\n end", "def render_page\n respond_to do |format|\n format.html do\n render action: :show, layout: !request.xhr?\n end\n end\n end", "def on_page_load; end", "def show\n @biologica_breed_offspring = Embeddable::Biologica::BreedOffspring.find(params[:id])\n if request.xhr?\n render :partial => 'show', :locals => { :biologica_breed_offspring=> @biologica_breed_offspring }\n else\n respond_to do |format|\n format.html # show.html.haml\n format.otml { render :layout => \"layouts/embeddable/biologica/breed_offspring\" } # biologica_breed_offspring.otml.haml\n format.jnlp { render :partial => 'shared/installer', :locals => { :runnable => @biologica_breed_offspring }}\n format.config { render :partial => 'shared/show', :locals => { :runnable => @biologica_breed_offspring, :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]) } }\n format.dynamic_otml { render :partial => 'shared/show', :locals => {:runnable => @biologica_breed_offspring} }\n format.xml { render :biologica_breed_offspring=> @biologica_breed_offspring }\n end\n end\n end", "def render_document_ready_scripts( lib = 'jQuery')\n return nil unless content_for? :document_ready_scripts\n javascript_tag <<-SCRIPTS\n (function($){ $(document).ready( function(){\n #{ content_for :document_ready_scripts }\n });})(#{lib});\n SCRIPTS\n end", "def load_page\n respond_to do |format|\n format.html do\n load_artists_page\n render '_artist_rows' , layout: false\n end\n end\n end", "def google_map_delay_load\n content_for :javascripts do\n %Q^\n var google_map;\n \n function initialize_google_map(){\n #{@google_map_scripts}\n }\n function load_google_map() {\n var script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n script.src = \"http://maps.google.com/maps/api/js?sensor=false&callback=initialize_google_map\";\n document.body.appendChild(script);\n } \n ^.html_safe\n end\n \n content_for :javascript_ready do\n %Q^\n load_google_map();\n ^.html_safe\n end\n \n nil\n end", "def show\n @open_response = Embeddable::OpenResponse.find(params[:id])\n if request.xhr?\n render :partial => 'show', :locals => { :open_response => @open_response }\n else\n respond_to do |format|\n format.html # show.html.haml\n format.jnlp { render :partial => 'shared/installer', :locals => { :runnable => @open_response } }\n format.config { render :partial => 'shared/show', :locals => { :runnable => @open_response, :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]) } }\n format.xml { render :xml => @open_response }\n end\n end\n end", "def ajax_markers_event\n js = <<-JS\n // get the markers for the area shown in the map (the bounds) on load\n CM.Event.addListener(map, 'load', function() {\n getMapPoints(map.getBounds());\n });\n JS\n \n return js\n end", "def inject_js; end", "def load_page\n logger.info 'Loading UCJEPS homepage'\n get ConfigUCJEPS.base_url\n when_exists(page_heading, Config.medium_wait)\n end", "def edit_page\n self.back_to_top\n edit_page_button\n wait_for_ajax\n self.class.class_eval { include DocumentWidget }\n end", "def show\n @drawing_tool = Embeddable::DrawingTool.find(params[:id])\n if request.xhr?\n render :partial => 'show', :locals => { :drawing_tool => @drawing_tool }\n else\n respond_to do |format|\n format.html # show.html.erb\n format.otml { render :layout => \"layouts/embeddable/drawing_tool\" } # drawing_tool.otml.haml\n format.jnlp { render :partial => 'shared/installer', :locals => { :runnable => @drawing_tool } }\n format.config { render :partial => 'shared/show', :locals => { :runnable => @drawing_tool, :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]) } }\n format.dynamic_otml { render :partial => 'shared/show', :locals => {:runnable => @drawing_tool} }\n format.xml { render :xml => @drawing_tool }\n end\n end\n end", "def ajax_view\n\t\t\n\t\t@project = Project.find(params[:id])\n\t\t\n\t\trespond_to do |f|\n\t\t\tf.js { render :layout => false }\n\t\tend\n\t\t\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
calculate datetime when retrieval_status should be updated, adding random interval sources that are not queueable use a fixed date
def stale_at unless source.queueable cron_parser = CronParser.new(source.cron_line) return cron_parser.next(Time.zone.now) end age_in_days = Time.zone.now.to_date - work.published_on if (0..7).include?(age_in_days) random_time(source.staleness[0]) elsif (8..31).include?(age_in_days) random_time(source.staleness[1]) elsif (32..365).include?(age_in_days) random_time(source.staleness[2]) else random_time(source.staleness.last) end end
[ "def refresh_interval\n x = self.entries.where('published > ?', 6.hours.ago).where('published < ?', 1.hour.ago).count / 5.0\n \n if x <= 0.001\n time = 120.minutes\n else\n time = ((-20 * x) + 120).to_i.minutes\n end\n \n time = [time, 30.minutes].max \n time\n end", "def punt_polling!\n if last_request_at > 5.minutes.ago.utc\n update_attribute(:next_poll_at, 30.seconds.from_now.utc)\n elsif last_request_at > 30.minutes.ago.utc\n update_attribute(:next_poll_at, 2.minutes.from_now.utc)\n elsif last_request_at > 2.hours.ago.utc\n update_attribute(:next_poll_at, 5.minutes.from_now.utc)\n else\n update_attribute(:next_poll_at, 1.hour.from_now.utc)\n end\n end", "def sync_rate\n room_type = self.room_type\n property = self.room_type.property\n channel = self.channel\n pool = PropertyChannel.find_by_channel_id_and_property_id(self.channel.id, property.id).pool\n\n master_rate_channel_mapping = RoomTypeMasterRateChannelMapping.pool_id(pool.id).find_by_room_type_id_and_channel_id(room_type.id, channel.id)\n\n if !master_rate_channel_mapping.blank?\n logs = Array.new\n master_rate = master_rate_channel_mapping.master_rate_mapping\n loop_date = DateTime.now.in_time_zone.beginning_of_day\n\n # loop until 400th day\n while loop_date <= Constant.maximum_end_date\n existing_rate = MasterRate.find_by_date_and_property_id_and_pool_id_and_room_type_id(loop_date, master_rate.room_type.property.id, master_rate.pool_id, master_rate.room_type_id)\n if !existing_rate.blank?\n logs << MasterRateNewRoomLog.create_master_rate_new_room_log(existing_rate)\n end\n loop_date = loop_date + 1.day\n end\n\n MasterRateNewRoomChangeSet.create_job(logs, master_rate.pool, self.channel, self)\n\n else\n logs = Array.new\n loop_date = DateTime.now.in_time_zone.beginning_of_day\n\n # loop until 400th day\n while loop_date <= Constant.maximum_end_date\n channel_rate = ChannelRate.find_by_date_and_property_id_and_pool_id_and_room_type_id_and_channel_id(loop_date, property.id, pool.id, room_type.id, channel.id)\n\n if !channel_rate.blank?\n logs << ChannelRateLog.create(:channel_rate_id => channel_rate.id, :amount => channel_rate.amount)\n end\n\n loop_date = loop_date + 1.day\n end\n ChannelRateChangeSet.create_job(logs, pool, channel)\n end\n end", "def schedule_updates\n schedule_update_in(48.hours)\n end", "def perform(metadata)\n scheduled_at = Time.at(metadata[\"scheduled_at\"])\n minutes = scheduled_at.min\n hours = scheduled_at.hour\n\n # 20 requests / minute\n if (minutes % 2 == 0) # Top 0-19; every 2 minutes\n perform_update(1)\n else # Top 20-99; every 2 minutes, full cycle of 6 minutes\n sub_index = (minutes / 2) % 3\n perform_update(2, sub_index)\n end\n\n # 20 requests / minute\n if minutes % 3 == 0 # Top 100-199; every 3 minutes, full cycle of 15 minutes\n sub_index = (minutes / 3) % 5\n perform_update(3, sub_index)\n elsif minutes % 6 == 1 # Top 200-299; every 6 minutes, full cycle of 30 minutes\n sub_index = (minutes / 6) % 5\n perform_update(4, sub_index)\n elsif minutes % 6 == 2 # Top 300-499; every 6 minutes, full cycle of 60 minutes\n sub_index = (minutes / 6) % 10\n perform_update(5, sub_index)\n end\n\n # 25-30 requests / minute\n if minutes % 12 == 0 # Top 500-749; every 12 minutes, full cycle of 1 hour\n sub_index = (minutes / 12) % 5\n perform_update(6, sub_index)\n end\n two_hour_cycle = hours % 2 * 60 + minutes\n if two_hour_cycle % 12 == 1 # Top 750-999; every 12 minutes, full cycle of 2 hours\n sub_index = (two_hour_cycle / 12) % 10\n perform_update(7, sub_index)\n end\n four_hour_cycle = hours % 4 * 60 + minutes\n if four_hour_cycle % 12 == 2 # Top 1000-1499; every 12 minutes, full cycle of 4 hours\n sub_index = (four_hour_cycle / 12) % 20\n perform_update(8, sub_index)\n end\n # 25 requests / 3 minutes with blank periods due to unknown coin limit\n six_hour_cycle = hours % 6 * 60 + minutes\n if six_hour_cycle % 3 == 1 # Top 1500-4499; every 3 minutes, full cycle of 6 hours\n sub_index = (six_hour_cycle / 3) % 120\n perform_update(9, sub_index)\n end\n end", "def calculate_next_update\n #ActiveRecord::Base.logger = Logger.new(STDOUT)\n\n active_subscriber_count = 1\n update_interval = FEED_MAX_UPDATE_INTERVAL\n begin\n # If the feed has any subscribers, then we want to calculate a more precise update interval\n if active_subscriber_count > 0\n current_sum = 0\n current_count = 0\n historic_sum = 0\n historic_count = 0\n\n time_since_last_post = -1\n\n last_time = DateTime.now.utc\n\n last_ten = posts.last_ten.map { |c| c.published_at.to_datetime }\n last_ten.each do |time|\n #puts \"Time: #{time} / Interval #{(last_time.to_i - time.to_i).abs}\"\n if current_count > 0\n historic_sum += (last_time.to_i - time.to_i).abs\n historic_count += 1\n else\n time_since_last_post = (last_time.to_i - time.to_i).abs\n end\n current_sum += (last_time.to_i - time.to_i).abs\n current_count += 1\n last_time = time\n end\n\n current_update_interval = FEED_MAX_UPDATE_INTERVAL\n historic_update_interval = FEED_MAX_UPDATE_INTERVAL\n \n # If time since last post is less than 10 days, calculate the current interval\n if time_since_last_post > 0 and time_since_last_post < 864000\n # Calculate the current (current time and last 10 posts) update interval\n if current_count > 0 and current_sum > 0\n current_update_interval = (current_sum / current_count) / 240\n end\n\n # Calculate the historic (last 10 posts only) update interval\n if historic_count > 0 and historic_sum > 0\n historic_update_interval = (historic_sum / historic_count) / 240\n end\n\n update_interval = [current_update_interval,historic_update_interval].min\n end\n\n puts \"[#{self.id}] TSLP: #{time_since_last_post/60} Historic: #{historic_update_interval} Current: #{current_update_interval}\"\n\n end\n rescue\n #puts \"here\"\n end\n\n if (update_interval < FEED_MIN_UPDATE_INTERVAL)\n update_interval = FEED_MIN_UPDATE_INTERVAL\n elsif (update_interval > FEED_MAX_UPDATE_INTERVAL)\n update_interval = FEED_MAX_UPDATE_INTERVAL\n end\n\n # Multiply by a noise factor between 0.9 and 1.1\n update_interval *= (90.0+rand(21))/100.0\n\n next_update_time = (update_interval.minutes.since DateTime.now).to_s(:db)\n\n puts \"[#{self.id}] Interval: #{update_interval} Next Update: #{next_update_time}\"\n #puts \"[#{self.id}] Sub Count: #{self.users.count}\"\n\n self.next_update_at = next_update_time\n next_update_at\n end", "def refresh_boundary\n Time.new - refresh_interval\n end", "def set_scheduled_at\n first_unpublished_status = self.user.unpublished_statuses.first\n start_time = if first_unpublished_status.present? and first_unpublished_status.scheduled_at > Time.now\n first_unpublished_status.scheduled_at\n else\n Time.now\n end\n\n self.scheduled_at = start_time + self.user.setting.interval\n check_scheduled_range\n end", "def schedule_updates\n end", "def refresh_boundary\n Time.now - refresh_interval\n end", "def current_sched_ahead_time\n #This is a stub, used for indexing\nend", "def fetch_time; end", "def status\n\n # Get times\n src_time = @source.last_item[@entity_config[:src][:updated_at_field]]\n dst_time = @destination.last_item[@entity_config[:dst][:updated_at_field]]\n\n unless src_time.instance_of? Time\n src_time = Time.parse(src_time)\n end\n\n unless dst_time.instance_of? Time\n dst_time = Time.parse(dst_time)\n end\n\n # Calculate lag\n lag = (src_time - dst_time).to_i\n\n {\n pool: self.to_s,\n src_time: src_time,\n dst_time: dst_time,\n lag: lag\n }\n\n end", "def refresh_boundary\n Time.new - refresh_interval\n end", "def last_enqueue_time; end", "def calculate_next_update!(fetched_ok=true)\n # Work out when next to poll.\n # TODO: Allow author to provide TTL data in the content.\n vals={ :update_again_at => Time.now + 1.week }\n vals[:last_updated_at] = Time.now.utc if fetched_ok\n \n self.update_attributes( vals )\n end", "def create_stats_since_last_status_change(current_timestamp)\n return unless @last_stats_refresh < current_timestamp\n @last_stats_refresh = current_timestamp\n elapsed_time = current_timestamp - @last_status_change\n @time_in_current_status = elapsed_time\n @logger.debug \"#{current_timestamp} - time_in_current_status: #{@time_in_current_status} \\\n\t(#{@current_status}) - elapsed: #{elapsed_time} - last_change: #{last_status_change}\"\n\n # Averages shouldn't be updated before the status is changed to avoid inconsistencies.\n # Only time they get values is before any transition has happened\n if (@current_status == Constants::HostStatus::FREE)\n @max_time_free = (@time_in_current_status > @max_time_free) ? @time_in_current_status : @max_time_free\n @min_time_free = @time_in_current_status unless @min_time_free > 0\n @avg_time_free = (@avg_time_free > 0) ? @avg_time_free : @time_in_current_status\n @total_time_free = @time_in_current_status + @past_free_time\n else\n @max_time_busy = (@time_in_current_status > @max_time_busy) ? @time_in_current_status : @max_time_busy\n @min_time_busy = @time_in_current_status unless @min_time_busy > 0\n @avg_time_busy = (@avg_time_busy > 0) ? @avg_time_busy : @time_in_current_status\n @total_time_busy = @time_in_current_status + @past_busy_time\n end\n end", "def set_remind_once_fields\n\t\n\t\n case (self.freq_type)\n \n\t\twhen 0,12 #Not Scheduled\n\t\t\t\tself.start_dt_tm = TzTime.at(Date.parse(\"1970-01-01\")).at_beginning_of_day.utc\n\t\t\t\tself.freq_interval = 0\n\t\t\t\tself.end_dt_tm = self.start_dt_tm\n\t\t\t\t\n\t\twhen 1 #Later Today\n\t\t\t\tself.start_dt_tm = TzTime.now.at_beginning_of_day.utc #00:00\n\t\t\t\tself.freq_interval = 1\n\t\t\t\tself.end_dt_tm = TzTime.now.at_beginning_of_day.tomorrow.ago(60).utc #23:59\n\t\t\n\t\twhen 11 #Pick a date\n self.start_dt_tm = TzTime.at(start_dt_tm).at_beginning_of_day.utc\n\t\t\t\tself.freq_interval = 1\n\t\t\t\tself.end_dt_tm = TzTime.at(start_dt_tm).at_beginning_of_day.tomorrow.ago(60).utc #23:59\n\t\t\t\t\n\t\twhen 2 #Tomorrow\n\t\t\t\tself.start_dt_tm = TzTime.now.tomorrow.at_beginning_of_day.utc\n\t\t\t\tself.freq_interval = 1\n\t\t\t\tself.end_dt_tm = TzTime.now.tomorrow.at_beginning_of_day.tomorrow.ago(60).utc #23:59\n\t\t\t\t\n\t\twhen 3 #This Friday\n\t\t\t\t \n\t\t\t\tstart_dt = TzTime.now.to_date\n\t\t\t\tdiff = 5 - start_dt.wday\n case diff\n when 0 #On a friday - Move to next friday\n start_dt = TzTime.now.to_date + 7\n when -1 # on a Saturday\n start_dt = TzTime.now.to_date + 6\n when 1,2,3,4,5\n start_dt = TzTime.now.to_date + diff\n end \n self.start_dt_tm = TzTime.at(start_dt).at_beginning_of_day.utc\n\t\t\t\tself.end_dt_tm = TzTime.at(start_dt).at_beginning_of_day.tomorrow.ago(60).utc #23:59\n\t\t\t\t\n\t\twhen 4 #This Weekend - Schedule it for this Saturday\n\t\t\t\t \n\t\t\t\tstart_dt = TzTime.now.to_date\n\t\t\t\tdiff = 6 - start_dt.wday\n case diff\n when 0 #On a Sat - Move to next Sat\n start_dt = TzTime.now.to_date + 7\n \n when 1,2,3,4,5,6\n start_dt = TzTime.now.to_date + diff\n end \n\n\t\t\t\tself.start_dt_tm = TzTime.at(start_dt).at_beginning_of_day.utc\n\t\t\t\tself.end_dt_tm = TzTime.at(start_dt).at_beginning_of_day.tomorrow.ago(60).utc #23:59\n\t\twhen 5 #Next Week - Move to Monday of next week\n\t\t\t\t \n\t\t\t\tstart_dt = TzTime.now.to_date\n\t\t\t\tdiff = 1 - start_dt.wday\n start_dt = TzTime.now.to_date + diff + 7\n \n self.start_dt_tm = TzTime.at(start_dt).at_beginning_of_day.utc\n\t\t\t\tself.end_dt_tm = TzTime.at(start_dt).at_beginning_of_day.tomorrow.ago(60).utc #23:59\n \n end\n end", "def time_refresh\r\n @events.each_value { |event| event.refresh if event.time_event }\r\n @common_events.each_value { |event| event.refresh if event.time_event }\r\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
'With this hack, files that require this file, will have access to configatron store by using: settings.
def settings() configatron end
[ "def script_settings_files_def\nend", "def config_file\n CONFIG_FILE\n end", "def settings\n load_settings unless @config_loaded\n @settings\n end", "def remote_settings; end", "def configuration_file_path; end", "def require_config_file\n RGovData::Config.require_config_file\n end", "def config_hook\n end", "def settings\n @settings ||= {}\n end", "def load_settings\n begin\n open(@@FN_CREDENTIALS, \"rb\") { |fd| @credentials = YAML::load(fd.read) \n } if File.exists? @@FN_CREDENTIALS\n appEM.broker.login(@credentials[:broker_user], @credentials[:broker_pass])\n appEM.quotes.login(@credentials[:datafeed_user], @credentials[:datafeed_pass])\n \n open(@@FN_CONFIG, \"rb\") { |fd| @configuration = YAML::load(fd.read) \n } if File.exists? @@FN_CONFIG\n open(@@FN_SETTINGS, \"rb\") { |fd| @settings = YAML::load(fd.read) \n } if File.exists? @@FN_SETTINGS\n rescue BrokerException => be\n print \"load_settings() failed: #{be}\"\n end\n end", "def read_settings\n @settings = YAML::load_file \"#{@gem_root}/settings.yml\"\n end", "def setup_config\n # To be Extended\n end", "def config\n @config ||= begin\n config = YAML::load(File.open('config/settings.yaml'))\n config['synchronizer']\n end\n end", "def load_settings\n @settings = component.settings\n end", "def rubocop_config_store; end", "def settings\n Buildr.application.settings\n end", "def settings\n @settings ||= Smeagol::Settings.load(wiki_dir)\n end", "def load!\n create_constant load_settings\n end", "def initialize\n loadConfig\n end", "def config_file\n @config_file\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }