query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
Use this method in DSL methods to add a file pattern to config | def add_file_pattern(name, pattern_string)
if name.to_s !~ FILE_PATTERN_NAME_REGEX
raise ArgumentError.new("A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }")
end
@file_patterns[name.to_sym] = pattern_string.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_pattern( pattern )\n self.class_eval { @file_pattern = pattern }\n end",
"def file_pattern(name)\n if name.to_s !~ FILE_PATTERN_NAME_REGEX\n raise ArgumentError.new(\"A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }\")\n end\n get_config_val(@file_patterns, name)\n end",
"def add_pattern(pattern)\n @patterns << pattern\n end",
"def config_file(val)\n @config_files << val\n end",
"def test_files_pattern=(pattern)\n warn 'test_files_pattern= is deprecated in QUnited rake task config, use test_files= with a pattern'\n @test_files = pattern\n end",
"def patterns_for_file( file )\n Hash(config_file(file)[:patterns]).keys + \\\n Hash(defaults[:patterns]).keys\n end",
"def config_files(override); end",
"def add(glob, options)\n definition << options.merge(:glob => glob)\n end",
"def source_files_pattern=(pattern)\n warn 'source_files_pattern= is deprecated in QUnited rake task config, use source_files= with a pattern'\n @source_files = pattern\n end",
"def add(*files)\n # due to the multi passing of splat args, we can get Array-in-Array situations here\n files.flatten.each do |fn|\n @files.push(fn)\n if ! File.exists?(fn)\n next if self.class.skipmissing\n raise ArgumentError, \"file #{fn} does not exist\"\n end\n begin\n data = YAML.load(File.open(fn))\n if ! data.instance_of?(Hash)\n raise ArgumentError, \"file #{fn} does not contain a Hash\"\n end\n @cfg.deep_merge!(data.deep_symbolize_keys).deep_symbolize_keys\n rescue\n if ! self.class.skipbad\n raise\n end\n end\n end\n\n # resolve templates\n if self.class.templates\n resolve_templates\n end\n end",
"def add_matching(pattern)\n Dir[pattern].each do |fn|\n\tself << fn unless exclude?(fn)\n end\n end",
"def ignore_files=(patterns)\n @finder.add_patterns(patterns)\n end",
"def validate_file_patterns\n attributes = DSL.attributes.values.select(&:file_patterns?)\n attributes.each do |attrb|\n patterns = consumer.send(attrb.name)\n if patterns.is_a?(Hash)\n patterns = patterns.values.flatten(1)\n end\n patterns.each do |pattern|\n if pattern.start_with?('/')\n error \"File patterns must be relative and cannot start with a \" \\\n \"slash (#{attrb.name}).\"\n end\n end\n end\n end",
"def validate_file_patterns\n attributes = DSL.attributes.values.select(&:file_patterns?)\n attributes.each do |attrb|\n patterns = consumer.send(attrb.name)\n if patterns.is_a?(Hash)\n patterns = patterns.values.flatten(1)\n end\n patterns.each do |pattern|\n if pattern.start_with?('/')\n error '[File Patterns] File patterns must be relative ' \\\n \"and cannot start with a slash (#{attrb.name}).\"\n end\n end\n end\n end",
"def add_pattern( pattern )\n type_check( pattern, Elements::Pattern )\n assert( !name_defined?(name), \"name [#{name}] is already in use\" )\n \n @patterns[pattern.name] = pattern\n end",
"def add_config_folder\n directory 'templates/dry/config', \"#{name}/config\", recursive: true\n end",
"def register_config_files\n [Dir.home, Dir.pwd].each do |dir|\n option_parser.config_files.class.supported_extensions.each do |ext|\n option_parser.config_files << Pathname.new(dir).join(\".#{NS.app_name}\", \"scan.#{ext}\").to_s\n end\n end\n end",
"def load_config(filename)\n yml = YAML.load_file(filename)\n yml.each do |key, value| \n next if key == 'Templates'\n\n if key == 'PackageDirs'\n # PackageDirs.register value\n elsif key == 'AppDirs' \n # ApplicationDirMatcher.register value\n else\n app_matcher.register value\n end \n end\n end",
"def add_matching(pattern)\n Dir[ pattern ].each do |fn|\n self << fn unless exclude?(fn)\n end\n end",
"def add_matching(pattern)\n self.class.glob(pattern).each do |fn|\n self << fn unless excluded_from_list?(fn)\n end\n end",
"def input_files_pattern\n @args.options[:input_files_pattern]\n end",
"def configure_local(pattern, properties)\n log.header 'Configure'\n Solutions.each(pattern) do |solution|\n log.puts \"saving configuration for #{solution.name}\"\n Configuration.new(solution).set(properties)\n end\n end",
"def add_instrumentation(file_pattern)\n record_api_supportability_metric(:add_instrumentation)\n NewRelic::Control.instance.add_instrumentation(file_pattern)\n end",
"def create_file_config\n # template \"config/express_translate.yml\", \"config/express_translate.yml\"\n end",
"def append filename, config\n @config << ({\n file: filename,\n config: config\n })\n end",
"def create_file_appender\n pattern = @config_manager['logging.file.pattern']\n date_pattern = @config_manager['logging.file.date_pattern']\n layout = Logging::Layouts::Pattern.new(pattern: pattern, date_pattern: date_pattern)\n #\n run_result_directory = @config_manager['run.result.directory']\n log_file = \"#{run_result_directory}/#{log_file_name}.log\"\n @appender = Logging::Appenders::File.new('file', filename: log_file, layout: layout)\n #\n Logging::Logger.root.add_appenders(@appender)\n end",
"def add_instrumentation(pattern)\n if @instrumented\n load_instrumentation_files(pattern)\n else\n @instrumentation_files << pattern\n end\n end",
"def <<(pattern)\n @patterns << pattern\n end",
"def find_config(file); end",
"def configure!(config)\n @logger = config[:logger]\n @pattern = config[:pattern] || DEFAULT_PATTERN\n find_plugins\n end",
"def initialize(pattern, options = {})\n raise ArgumentError, 'pattern cannot be nil' unless pattern\n raise ArgumentError, 'pattern cannot be empty' if pattern.empty?\n @pattern = pattern\n @options = {\n :glob => :all\n }.merge(options)\n @paths = []\n end",
"def file(path, simple_templating=true)\n if simple_templating\n caller_file = caller.first\n end\n add Config::Patterns::File do |p|\n p.path = path\n if block_given?\n if simple_templating\n yield FileTemplate.new(p, self, caller_file)\n else\n yield p\n end\n end\n end\n end",
"def append(pattern, file, where=:bottom)\n was = sftp.file.open(file, \"r\") { |f| f.read }\n\n if was.include?(pattern)\n log \"'%s' already match your pattern\" % file\n return false\n else\n pattern += \"\\n\" unless pattern[-1] == ?\\n\n replacement = case where\n when :top, :start then pattern+was\n when :bottom, :end then was+pattern\n else raise \"%s is not a valid, available values are (:top, :start, :bottom, :end)\" % where.inspect\n end\n end\n\n log \"append to '%s' in '%s'\" % [where, file]\n sftp.file.open(file, \"w\") { |f| f.write(replacement) }\n end",
"def config_files=(files)\n @config_files = files\n end",
"def initialize(dir)\n # Create a new patterns hash\n @patterns = Hash.new\n\n # Get the pattern files in the directory\n dir += '/' if(!dir.end_with?('/'))\n files = Dir.glob(dir + \"*.pattern\")\n\n # Create a DesignPattern for each file\n files.each do |f|\n pattern = DesignPattern.new(f)\n @patterns[pattern.name] = pattern\n end\n end",
"def update!(**args)\n @file_pattern = args[:file_pattern] if args.key?(:file_pattern)\n @file_type = args[:file_type] if args.key?(:file_type)\n end",
"def recursive_file_set(file_expression, label=:default)\n file_set(\"*/**/#{file_expression}\", label) do |style|\n yield style if block_given?\n end\n end",
"def config_file(val)\n config_files << val\n config_files.dup\n end",
"def config_file(val)\n config_files << val\n config_files.dup\n end",
"def declare_chefignore_patterns\n @flavor.class.do_declare_resources do\n chefignore_patterns << 'Guardfile' if snippet?('standard_ignore')\n end\n end",
"def setup_files(config_generator)\n raise NotImplementedError\n end",
"def add_file conf_pathname\n conf_pathname = Pathname conf_pathname\n err = Fiddle::Pointer[0]\n rv = Wrapper.msc_rules_add_file rules_ptr, (strptr conf_pathname.realpath.to_s), err.ref\n\n raise Error, [conf_pathname, err.to_s] if rv < 0\n @rule_count += rv\n self\n end",
"def generate_pattern(pattern)\n plist.dict do\n append_single('begin', pattern.begin)\n append_dictionary('beginCaptures', pattern.begin_captures)\n append_dictionary('captures', pattern.captures)\n append_single('comment', pattern.comment)\n append_single('contentName', pattern.content_name)\n append_single('disabled', 1) if pattern.disabled\n append_single('end', pattern.end)\n append_dictionary('endCaptures', pattern.end_captures)\n append_single('include', pattern.include)\n append_single('match', pattern.match)\n append_single('name', pattern.name)\n append_array('patterns', pattern.patterns)\n end\n end",
"def add_extra_files(*files); end",
"def file_set(file_expression, label=:default, &block)\n @file_sets << [file_expression, label, block]\n end",
"def pattern\n \"#{@gem}/spec{,/*/**}/*_spec.rb\"\n end",
"def add(*args)\n helper.glob_to_index(args) do |index, relative_path|\n index.add(relative_path.to_s)\n end\n\n self\n end",
"def add_files filearray, config={}\n filearray.each do |e| add_content(e, config.dup); end\n end",
"def config_file_path=(path)\n self.config_file_paths = [path]\n end",
"def containing_dir(source, dir)\n File.join(source, dir, '_patterns')\n end",
"def each_existing_readable pattern, guessed_format = nil, &block # :yields: path, parsed_content\n each_existing_path(pattern, :readable?) do |path|\n guess_ext = guessed_format || path.extname.sub(\".\", \"\").downcase.to_sym\n content = read_file path, guess_ext\n yield path, content if content\n end\n end",
"def apply_to(pattern)\n @pattern = pattern\n end",
"def named_configuration_file\n super\n end",
"def add(path); end",
"def getFilePattern(filePattern)\n return if filePattern.nil?\n File.split(filePattern).inject do |memo, obj| \n File.join(memo, obj.split(/\\./).join('*.'))\n end\nend",
"def glob=(pattern)\n @glob = pattern\n if pattern.kind_of?(Regexp)\n @pattern = pattern\n else\n @pattern = scan_string\n end\n end",
"def add_file(file)\n setup_file_tailer file\n self\n end",
"def edit_matched_files(*match, &block)\n match.each do |m|\n if Pathname.new(m).absolute?\n path = m\n else\n path = File.join(File.expand_path(TARGET_PATH), m)\n end\n puts \"path: #{path}\"\n\n Dir.glob(path).each do |file|\n block.call(Content.create(file))\n end\n end\nend",
"def add_files(*files)\n @source_paths &= files\n end",
"def post_configure\n super\n @path = File.expand_path(path)\n end",
"def configuration_file_for(target_dir); end",
"def file_set(file_expression='lib/**/*.rb', label=:default)\n log \"file sets before: #{@file_sets}\"\n log \"file set label #{label}\"\n new_style = Style.new\n\n yield new_style if block_given?\n\n @file_sets[label] = FileSet.new(file_expression, new_style)\n log \"file sets after: #{@file_sets}\"\n end",
"def add_pattern(features, identifier = '')\n\t\t@patterns << create_pattern(features, identifier)\n\tend",
"def config(value)\n # require value if File.exists?(value)\n if File.exists?(value)\n fc = File.read(value)\n self.instance_eval(fc)\n end\n end",
"def addFileDataSource(filePath)\n addSequenceSource(Sequence::File.new(File.new(filePath)))\n end",
"def set_config_paths\n @config_file_path = \"config/dissect/\"\n end",
"def add_file_filter(file_filter)\n @filter_file = file_filter\n end",
"def add_file_filter(file_filter)\n @filter_file = file_filter\n end",
"def file(*args)\r\n args.each do |arg|\r\n add_formatted arg\r\n end\r\n self\r\n end",
"def generate_intended_filename_regex conf\n prefix = \"#{ conf['local_hostname'] }-\\\\d{4}_\\\\d{2}_\\\\d{2}\"\n case conf['type']\n when /dir/\n dir_part = conf['path'].sub(/\\//,'').gsub(/\\//,\"-\")\n return \"#{ prefix }-#{ dir_part }\\\\.tar\\\\.gz\"\n when /mys/\n db_part = conf['database']\n return \"#{ prefix }-#{ db_part }\\\\.sql\\\\.gz\"\n end\nend",
"def handle(pattern, &block)\n @routes << [pattern, block]\n end",
"def recursive_file_set(file_expression, label=:default, &block)\n @recursive_file_sets << [file_expression, label, block]\n end",
"def initialize_config_yaml(filename, files = Dry::Files.new, template: config_template)\n files.write(filename, template)\n end",
"def add_admin_routes\n ['sidebar','users','pages','documents','settings'].each do |file|\n template \"config/admin/#{file}.yml\", \"config/admin/#{file}.yml\"\n end\n end",
"def configure(conf)\n super\n fieldsToMaskFilePath = conf['fieldsToMaskFilePath']\n fieldsToExcludeJSONPaths = conf['fieldsToExcludeJSONPaths']\n handleSpecialCases = conf['handleSpecialEscapedJsonCases']\n\n if fieldsToExcludeJSONPaths != nil && fieldsToExcludeJSONPaths.size() > 0 \n fieldsToExcludeJSONPaths.split(\",\").each do | field |\n # To save splits we'll save the path as an array\n splitArray = field.split(\".\")\n symArray = []\n splitArray.each do | pathPortion |\n symArray.push(pathPortion.to_sym)\n end\n @fieldsToExcludeJSONPathsArray.push(symArray)\n end\n end\n\n File.open(fieldsToMaskFilePath, \"r\") do |f|\n f.each_line do |line|\n value = line.to_s # make sure it's string\n value = value.gsub(/\\s+/, \"\") # remove spaces\n value = value.gsub('\\n', '') # remove line breakers\n\n if value.end_with? \"/i\"\n # case insensitive\n value = value.delete_suffix('/i')\n hashObjectRegex = Regexp.new(/(?::#{value}=>\")(.*?)(?:\")/mi) # mask element in hash object\n innerJSONStringRegex = Regexp.new(/(\\\\+)\"#{value}\\\\+\":\\\\+.+?((?=(})|,( *|)(\\s|\\\\+)\\\")|(?=}\"$))/mi) # mask element in json string using capture groups that count the level of escaping inside the json string\n else\n # case sensitive\n hashObjectRegex = Regexp.new(/(?::#{value}=>\")(.*?)(?:\")/m) # mask element in hash object\n innerJSONStringRegex = Regexp.new(/(\\\\+)\"#{value}\\\\+\":\\\\+.+?((?=(})|,( *|)(\\s|\\\\+)\\\")|(?=}\"$))/m) # mask element in json string using capture groups that count the level of escaping inside the json string\n end\n\n @fields_to_mask.push(value)\n\n hashObjectRegexStringReplacement = \":#{value}=>\\\"#{MASK_STRING}\\\"\"\n @fields_to_mask_regex[hashObjectRegex] = hashObjectRegexStringReplacement\n @fields_to_mask_keys[hashObjectRegex] = value\n\n innerJSONStringRegexStringReplacement = \"\\\\1\\\"#{value}\\\\1\\\":\\\\1\\\"#{MASK_STRING}\\\\1\\\"\"\n @fields_to_mask_regex[innerJSONStringRegex] = innerJSONStringRegexStringReplacement\n @fields_to_mask_keys[innerJSONStringRegex] = value\n end\n end\n\n # if true, each record (a json record), will be checked for a special escaped json cases\n # any found case will be 'gsub' with the right solution \n @handleSpecialEscapedJsonCases = handleSpecialCases != nil && handleSpecialCases.casecmp(\"true\") == 0\n\n puts \"black list fields:\"\n puts @fields_to_mask\n end",
"def add_asset_files(options)\n select_assets(options).each do |name, assets|\n next if name == 'config-file'\n assets.each {|file| file.add unless file.disabled? }\n end\n end",
"def check_file_patterns\n FILE_PATTERNS.each do |attr_name|\n if respond_to?(\"_validate_#{attr_name}\", true)\n send(\"_validate_#{attr_name}\")\n else\n validate_nonempty_patterns(attr_name, :error)\n end\n end\n\n _validate_header_mappings_dir\n if consumer.spec.root?\n _validate_license\n _validate_module_map\n end\n end",
"def add_file(glob, tags, error_mode = :error)\n\t\t\ttags = tags.split\n\t\t\tfiles = Dir[glob.to_s]\n\t\t\tif files.empty?\n\t\t\t\tmsg = \"No files found for pattern '#{glob}'.\"\n\t\t\t\tif error_mode == :error\n\t\t\t\t\traise LaceError.new(msg)\n\t\t\t\telsif error_mode != :ignore_missing\n\t\t\t\t\tHelpers.trace_error Helpers.callstack, \"Warning: %s\", msg\n\t\t\t\tend\n\t\t\tend\n\t\t\tfiles.each do |filename|\n\t\t\t\tpath = to_path(filename)\n\t\t\t\tfile_tags = tags.to_set\n\t\t\t\text = /\\.[^.]+$/.match(path.to_s)\n\t\t\t\tfile_tags << ext[0] if ext\n\t\t\t\tfile_tags = @current_context.evaluate_auto_tags(file_tags)\n\t\t\t\t@project.add_file(InputFile.new(path, file_tags, @current_context))\n\t\t\tend\n\t\tend",
"def watchers_for_source_files_in pattern\n \n project_name, target_name, config_name = pattern.split(\"//\")\n \n # @todo assuming the project has the 'Debug' config when the project should likely be asked.\n \n config_name ||= \"Debug\"\n \n targets_for(project_name,target_name).map do |target|\n \n build_action = lambda { \"#{target.project.name}//#{target.name}//#{config_name}\" }\n \n project_root_dir = File.join(File.dirname(target.project.path), target.name)\n \n # Create a watcher for all source build files specified within the target\n \n new_guards = target.sources_build_phase.build_files.map do |file|\n full_source_path = File.join(project_root_dir,file.path)\n puts \"Source Path: #{full_source_path}\"\n create_guard_for full_source_path, build_action\n end\n \n # Create a watcher for the pch if one has been specified.\n \n if target.config(config_name).prefix_header\n prefix_header_path = File.join(File.dirname(target.project.path), target.config(config_name).prefix_header)\n puts prefix_header_path\n new_guards << create_guard_for(prefix_header_path, build_action)\n end\n\n new_guards\n \n end.flatten.compact\n \n end",
"def match(glob, &block)\n yield @filename\n end",
"def insert index, filename, config\n @config.insert(index, {\n file: filename,\n config: config\n })\n end",
"def read_config_files(files); end",
"def file(glob, target, options = nil)\n end",
"def add_config(name, config)\n\t\tend",
"def require_each(*file_patterns)\n file_patterns.each do |file_pattern|\n if file_pattern.include?('*')\n Dir[file_pattern].each do |file_name|\n Kernel.require file_name\n end\n else\n Kernel.require file_pattern\n end\n end\n end",
"def create_file_config\n template \"config/smart_editor.yml\", \"config/smart_editor.yml\"\n end",
"def pattern=(pattern)\n @pattern = pattern\n substitute_variables! # TODO: Remove this call\n end",
"def add(matcher, value)\n @configurations[parse_matcher(matcher)] = value\n end",
"def load_pattern(pattern_name, pattern_group = \"default\", parent_binding = nil)\n load_from_file_in_template(pattern_name, parent_binding, pattern_group, :pattern)\n end",
"def load_pattern(pattern_name, pattern_group = \"default\", parent_binding = nil)\n load_from_file_in_template(pattern_name, parent_binding, pattern_group, :pattern)\n end",
"def process_config src, file_name\n ConfigProcessor.new(@tracker).process_config src, file_name\n end",
"def _FILESDIR; Config._FILES; end",
"def _each_specification_file(config, apply_filter = true)\n folder = config.folder\n world = config.folder/\"world\"\n fs = folder.glob(\"**/*.{yml, yaml}\").reject{|f|\n f.to_s.start_with?(world.to_s) || f.to_s =~ /openapi.base.yml/\n }\n fs = fs.sort\n fs = fs.select(&to_filter_proc(config.file_filter)) if apply_filter\n fs.each do |file|\n yield file, folder\n end\n end",
"def patterns\n @patterns ||=\n [\n {\n :type => :erb,\n :rx => /\\.erb\\Z/,\n :rep => '',\n },\n {\n :type => :none,\n :rx => /\\Z/,\n :rep => '',\n },\n ]\n end",
"def add_file (file)\n @files[file.path] = file\n end",
"def append_to_file(path, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n config[:before] = /\\z/\n insert_into_file(path, *(args << config), &block)\n end",
"def add_convenience_method(name_, pattern_, indexes_)\n @mutex.synchronize do\n raise ConfigurationLockedError if @locked\n name_ = name_.to_sym\n if @methods.has_key?(name_)\n raise IllegalConfigurationError, \"Factory method already exists\"\n end\n @methods[name_] = [pattern_, indexes_]\n end\n self\n end",
"def set_files(args)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # Need at least one file in args\n if args.length <= 0\n debug_print \"No args passed, exiting\\n\"\n return false\n end\n\n # Set config flag for CL entryset in config\n @config.cl_entry_set = true\n debug_print \"Updated cl_entry_set flag: #{ @config.cl_entry_set }\\n\"\n\n # For each argument passed, make sure valid, then add to @config.file_list\n args.each do | _file |\n # Error check on input\n if !Watson::FS.check_file(_file)\n print \"Unable to open #{ _file }\\n\"\n else\n debug_print \"Adding #{ _file } to config file_list\\n\"\n @config.file_list.push(_file)\n end\n end\n\n debug_print \"Updated files: #{ @config.file_list }\\n\"\n return true\n end",
"def add_extension(path); end",
"def include(pattern)\n includes << pattern\n end"
] | [
"0.743196",
"0.6343401",
"0.6074771",
"0.60525686",
"0.60164654",
"0.60104054",
"0.59868294",
"0.5922678",
"0.5912519",
"0.58953154",
"0.5893319",
"0.5879828",
"0.5864538",
"0.58395886",
"0.581435",
"0.58139163",
"0.57998145",
"0.57668275",
"0.5756211",
"0.57376087",
"0.5672083",
"0.5652223",
"0.5652138",
"0.56501716",
"0.56458926",
"0.56233335",
"0.56151736",
"0.5597049",
"0.55765516",
"0.5575441",
"0.55628175",
"0.5531941",
"0.5526099",
"0.5503432",
"0.55001533",
"0.5476728",
"0.54636246",
"0.54480416",
"0.54480416",
"0.54415625",
"0.54219586",
"0.5399296",
"0.53943646",
"0.5385734",
"0.53530264",
"0.5335066",
"0.52976894",
"0.5264257",
"0.5257286",
"0.52495646",
"0.523981",
"0.5236585",
"0.52191305",
"0.5218778",
"0.5207419",
"0.520547",
"0.52052957",
"0.5203624",
"0.5198628",
"0.51940894",
"0.5176897",
"0.51750356",
"0.5163657",
"0.51511043",
"0.5147699",
"0.51474494",
"0.5144819",
"0.5144819",
"0.51410276",
"0.51332134",
"0.5132523",
"0.51240927",
"0.5116151",
"0.5115193",
"0.5113523",
"0.5108293",
"0.51052207",
"0.507729",
"0.5076495",
"0.5072286",
"0.50607955",
"0.5058818",
"0.50538945",
"0.50475687",
"0.50472295",
"0.504401",
"0.5035222",
"0.50344074",
"0.50338656",
"0.50338656",
"0.5033458",
"0.5028444",
"0.5026717",
"0.50221896",
"0.5021155",
"0.50148416",
"0.50124824",
"0.50111693",
"0.5010192",
"0.5010111"
] | 0.65437317 | 1 |
Use this method in DSL methods to add a kramdown converter method to config | def add_kramdown_converter_method(name, method_name)
@kramdown_converter_methods[name.to_sym] = method_name.to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kramdown_converter_method(name)\n get_config_val(@kramdown_converter_methods, name)\n end",
"def kramdown_conversion_method_name\n :to_kramdown_repositext\n end",
"def add_kramdown_parser(name, class_name)\n @kramdown_parsers[name.to_sym] = Object.const_get(class_name)\n end",
"def converter\n end",
"def html_converter_class\n ::Kramdown::Converter::Html\n end",
"def converter\n\n end",
"def kramdown_parser(name)\n get_config_val(@kramdown_parsers, name)\n end",
"def converter; end",
"def converter_for(method_name, *converters, &default)\n # puts \"[converter for #{self}, #{method_name}]\"\n sheep = lambda do |direct, this, *values|\n converter = converters.find { |e| e.length == values.length }\n converter = Array.new(values.length, default) unless converter\n\n # FIXME: Better error reporting on many things which can fail\n i = 0\n values = values.inject([]) do |s, value|\n conv = converter[i]\n if conv.kind_of? Proc\n s << conv.call(value)\n else\n s << CONVERTERS[converter[i]].call(value)\n end\n i += 1\n s\n end\n if direct\n return this.method(\"set_\" + method_name.to_s).call(*values)\n else\n return values\n end\n end\n # define a setter for normal usage\n unless method_name == :new\n self.__send__(:define_method, method_name.to_s + \"=\") do |*values|\n sheep.call(true, self, *values)\n end\n end\n # define a build/with usage\n self.__send__(:define_method, method_name.to_s + ARG_CONVERTER_SUFFIX) do |*values|\n sheep.call(false, self, *values)\n end\n end",
"def register_style_converter(ast_node, prop_name, converter); end",
"def add_config(converter, config)\n converter.instance_exec(:\"@config\") do |var|\n instance_variable_set(var, config)\n end\n converter\n end",
"def initialize(call=DefaultConverterPath)\n self.converter_call = call\n end",
"def convert _node, _name = nil, _opts = {}\n \"Well done: You plugged in a converter backend named 'backend_tpl'\"\n end",
"def setup\n @config[\"syntax_highlighter\"] ||= highlighter\n @config[\"syntax_highlighter_opts\"] ||= {}\n @config[\"syntax_highlighter_opts\"][\"default_lang\"] ||= \"plaintext\"\n @config[\"syntax_highlighter_opts\"][\"guess_lang\"] = @config[\"guess_lang\"]\n @config[\"coderay\"] ||= {} # XXX: Legacy.\n modernize_coderay_config\n make_accessible\n end",
"def setup_markup_transform(&block)\n self.send :define_method, :markup, block\n end",
"def katex_conv(converter)\n config = converter.options[:math_engine_opts]\n # Could .reject { |key, _| [:verbose, :debug].include?(key.to_sym) }\n # because the JS engine setup can be reused for different logging settings.\n # But then the +math_engine_opts+ dict would be essentially dup'ed every time,\n # and late activation of logging would miss the initialization if the engine is reused.\n KTXC[config] ||= ::SsKaTeX.new(config)\n end",
"def conversion(&block)\n self.converter = block\n end",
"def register_transformer(from, to, proc)\n mutate_hash_config(:transformers, from) do |transformers|\n transformers.merge(to => proc)\n end\n mutate_hash_config(:inverted_transformers, to) do |transformers|\n transformers.merge(from => proc)\n end\n end",
"def __convert(key); end",
"def converters; end",
"def converters; end",
"def converters; end",
"def get_processor\n case @config[\"markdown\"].downcase\n when \"kramdown\" then KramdownParser.new(@config)\n else\n custom_processor\n end\n end",
"def method_missing(*args)\n path = args.first.to_s\n if args.length == 1 && path.end_with?('.md')\n convert(path)\n else\n return super(*args)\n end\n end",
"def add_ruby_converter(converter)\n @ruby_converters ||= []\n @ruby_converters << converter\n end",
"def add_converter(var_name, const, name = nil, &converter)\n if name.nil? # custom converter\n instance_variable_get(var_name) << converter\n else # named converter\n combo = const[name]\n case combo\n when Array # combo converter\n combo.each do |converter_name|\n add_converter(var_name, const, converter_name)\n end\n else # individual named converter\n instance_variable_get(var_name) << combo\n end\n end\n end",
"def register(converter)\n @converters.add converter\n end",
"def converter\n @converter ||= self.site.converters.find { |c| c.matches(self.ext) }\n end",
"def method_missing(method, *args, &block)\n custom_tmls = Origen.interface.send(:custom_tmls)\n if custom_tmls[method]\n tml = CustomTml.new(self, custom_tmls[method])\n instance_variable_set \"@#{method}\", tml\n define_singleton_method method do\n instance_variable_get(\"@#{method}\")\n end\n send(method)\n else\n super\n end\n end",
"def rubyize!\n\n self.definition = Ruote::Reader.to_ruby(tree).strip\n end",
"def configure_parser; end",
"def initialize_defaults(method_name)\r\n super\r\n @template = \"#{I18n.locale}_#{method_name}\"\r\n end",
"def configure!(parser); end",
"def get_converter\n eval(\"RedmineCharts::#{get_type.to_s.camelize}DataConverter\")\n end",
"def initialize_defaults(method_name)\r\n super\r\n @template = \"#{I18n.locale}_#{method_name}\"\r\n end",
"def initialize_defaults(method_name)\r\n super\r\n @template = \"#{I18n.locale}_#{method_name}\"\r\n end",
"def parse_kramdown(content)\n ::Kramdown::Document.new content, :input => 'QuickStartParser' \n end",
"def initialize_defaults(method_name)\n super\n @template = \"#{I18n.locale}_#{method_name}\"\n end",
"def call\n result = Kramdown::Document.new(@text, self.class.options.deep_merge(context[:kramdown_options] || {})).to_html\n result.rstrip!\n result\n end",
"def configure_markdown\n Tilt.register Spirit::Tilt::Template, *%w(markdown mkd md)\n set :markdown, layout: :layout, layout_engine: :haml\n set :haml, escape_html: true, format: :html5\n end",
"def config_step_method(options, step)\n if @config['custom_methods'][step].class == String\n options['method'] = @config['custom_methods'][step]\n elsif @config['custom_methods'][step] == true\n options['method'] = [@config['study_procedure'], step.capitalize].join(\"_\").dot_camelize\n end\n end",
"def added_to_bibliography(bibliography)\n super\n\n @key = register(key)\n\n [:parse_names, :parse_months].each do |parser|\n send(parser) if bibliography.options[parser]\n end\n\n if bibliography.options.has_key?(:filter)\n [*bibliography.options[:filter]].each do |filter|\n convert!(filter)\n end\n end\n\n self\n end",
"def configure(&block)\n block.call @locale\n end",
"def to_kilogram(**options) = convert_to('kilogram', **options)",
"def assign_highlighter_options!\n payload[\"highlighter_prefix\"] = converters.first.highlighter_prefix\n payload[\"highlighter_suffix\"] = converters.first.highlighter_suffix\n end",
"def keppler\n end",
"def call(converter, el, opts)\n display_mode = el.options[:category]\n ans = katex_conv(converter).call(el.value, display_mode == :block, &logger(converter))\n attr = el.attr.dup\n attr.delete('xmlns')\n attr.delete('display')\n ans.insert(ans =~ /[[:space:]>]/, converter.html_attributes(attr))\n ans = ' ' * opts[:indent] << ans << \"\\n\" if display_mode == :block\n ans\n end",
"def define_locale_helpers(name, helper)\n %w(url path).each do |method|\n helper.send :define_method, \"#{name}_#{method}\" do |*args|\n send(\"#{name}_#{I18n.locale}_#{method}\", *args)\n end\n end\n end",
"def configure(options = {})\n options = options.map do |key, value|\n if self.respond_to?(\"transform_#{key}\")\n value = self.__send__(\"transform_#{key}\", value)\n end\n [key, value]\n end\n @configuration = configuration.merge(options)\n end",
"def config_for(key, val)\n case val\n when TrueClass, FalseClass then key.to_s.tr('_', '-') if val\n when String, Fixnum then \"#{key.to_s.tr('_', '-')}=#{val}\"\n when Array then val.map { |v| config_for(key, v) }.join(\"\\n\")\n when Hash then config_for(key, val.keys.select { |k| val[k] })\n else raise(Exceptions::ValidationFailed,\n \"Invalid: '#{key}' => '#{val}'\")\n end\n end",
"def run_transforms(method_binding)\n default( method_binding ) if value.blank?\n\n override( method_binding )\n\n substitute( method_binding )\n\n prefix( method_binding )\n\n postfix( method_binding )\n\n # TODO: - enable clients to register their own transformation methods and call them here\n end",
"def apply_ruby_converters(rexp)\n apply_converters(Engine.ruby_converters, rexp)\n end",
"def create_file_config\n # template \"config/express_translate.yml\", \"config/express_translate.yml\"\n end",
"def initialize(app, options_hash={}, &block)\n # Call super to build options from the options_hash\n super\n\n # Require libraries only when activated\n # require 'necessary/library'\n require 'execjs'\n require 'middleman-katex/redcarpet_katex_renderer'\n\n # app.config[:autoload_sprockets] = true\n\n # set up your extension\n # puts options.my_option\n # root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))\n # app.precompile << /\\.(?:svg|eot|woff|ttf)$/\n\n if app.config[:markdown_engine] == :redcarpet\n require 'middleman-core/renderers/redcarpet'\n Middleman::Renderers::MiddlemanRedcarpetHTML.send :include, RedcarpetKatexRenderer\n elsif app.config[:markdown_engine] == :kramdown\n require 'kramdown'\n Kramdown::Converter::Html.class_eval do\n def convert_codeblock(el, indent)\n attr = el.attr.dup\n language = extract_code_language!(attr)\n # Middleman::Syntax::Highlighter.highlight(el.value, language)\n end\n end\n end\n end",
"def deprecated_yaml_erb_backend=(_arg0); end",
"def deprecated_yaml_erb_backend=(_arg0); end",
"def converter=(object)\n if object.is_a?(Symbol)\n @converter = HoneyFormat.converter_registry[object]\n return\n end\n\n if object.is_a?(Hash)\n @converter = hash_converter(object)\n return\n end\n\n @converter = object\n end",
"def convert_symbols_to(formula = nil, &block)\n XMLKey.symbol_converter = formula ? formula : block\n end",
"def to_kelvin(**options) = convert_to('kelvin', **options)",
"def convert\n end",
"def convert\n end",
"def parse_kramdown(file)\n ::Kramdown::Document.new File.readlines(file).join, :input => 'QuickStartParser' \n end",
"def transform_method(transform = nil)\n @transform ||= transform || :\"to_#{@format}\"\n @transform\n end",
"def internal_convert(\n input, convert_logger, backend, standalone, extra_attributes\n )\n attributes = { 'docdir' => File.dirname(__FILE__) }\n attributes.merge! extra_attributes\n args = internal_convert_args convert_logger, backend, standalone, attributes\n Asciidoctor.convert input, args\nend",
"def method_missing(sym, *args, &block)\n if configuration.respond_to?(sym)\n configuration.send(sym, *args, &block)\n else\n super\n end\n end",
"def initialize(conversion_method)\n @conversion_method = conversion_method\n end",
"def def_transform sym, &block\n sym = \"transform_#{sym}\".to_sym\n if block_given?\n define_method sym,&block\n else\n define_method(sym) {|v|v} # just return self if no transform defined\n end\n module_function sym\n end",
"def def_transform sym, &block\n sym = \"transform_#{sym}\".to_sym\n if block_given?\n define_method sym,&block\n else\n define_method(sym) {|v|v} # just return self if no transform defined\n end\n module_function sym\n end",
"def apply_custom_transformation\n end",
"def converters=(_arg0); end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def translate!(key, **options); end",
"def attr_converter(hash)\n jiak.data.attr_converter(hash)\n end",
"def to_yml\n \"generate_to: '#{generate_to}'\\n\" <<\n \"builders_matcher: '#{builders_matcher}'\\n\" <<\n \"factories_matcher: '#{factories_matcher}'\"\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def enable_language_autodetect\n put \"languages/enable_autodetect\", nil\n end",
"def translate(settings); end",
"def add_r_converter(converter)\n @r_converters ||= []\n @r_converters << converter\n end",
"def add_key_lookup_method(key_value, value)\n key_lookup_method_name = sanitize(\"#{value}_#{@key_name}\")\n @modyule::ClassMethods.instance_exec(key_lookup_method_name, key_value, value) do |method_name, key_value|\n define_method method_name do\n key_value\n end\n end\n end",
"def keygen(&block)\n jiak.data.class_eval <<-EOS\n define_method(:keygen,&block)\n EOS\n end",
"def method_missing(m, *args, &block)\n if m == :static_transform || m == :dynamic_transform || m == :frames\n return Orocos.transformer.manager.conf.send(m, *args, &block)\n end\n super\n end",
"def config(name)\n ::JSON::SchemaTemplates.configuration.public_send(name)\n end",
"def transformer\n convert unless @options.empty?\n end",
"def emit(key)\n yaml = YAML.load_file(file)\n yaml ||= {}\n yaml[language] ||= {}\n\n value = key.to_s\n\n key = normalize_key(value)\n\n # TODO: handle duplicate keys somehow?\n puts \"Dup: #{key}\" if yaml[language][key]\n\n yaml[language][key] = unescape(value)\n File.write(file, YAML.dump(yaml))\n end",
"def create_format_method\n end",
"def method_missing(method, *_args, &_block)\n @config.send(method)\n end",
"def register_convertor(convertor_name, convertor_class)\n @registered_convertors[convertor_name] = convertor_class\n end",
"def to_toml\n conf = {}.merge config\n conf[:type] = type\n Heka::Filter::OPTIONS.each_pair { |k, _| conf[k] = send(k) }\n Heka::Restart::OPTIONS.each_pair { |k, _| conf[k] = send(k) }\n if conf[:use_buffering]\n conf[:buffering] = {}\n Heka::Buffering::OPTIONS.each_pair do |k, _|\n conf[:buffering][k] = send(k) unless send(k).nil?\n end\n end\n if type =~ /^Sandbox(Input|Decoder|Filter|Encoder|Output)/\n Heka::Sandbox::OPTIONS.each_pair { |k, _| conf[k] = send(k) }\n conf[:config] = conf.delete(:sandbox_config)\n end\n conf.delete_if { |_, v| v.nil? }\n TOML::Generator.new(name => conf).body\n end",
"def after_configuration\n markdown_exts = %w(markdown mdown md mkd mkdn)\n\n begin\n # Look for the user's preferred engine\n if app.config[:markdown_engine] == :redcarpet\n require 'middleman-core/renderers/redcarpet'\n ::Tilt.prefer(::Middleman::Renderers::RedcarpetTemplate, *markdown_exts)\n elsif app.config[:markdown_engine] == :kramdown\n require 'middleman-core/renderers/kramdown'\n ::Tilt.prefer(::Middleman::Renderers::KramdownTemplate, *markdown_exts)\n elsif app.config[:markdown_engine]\n # Map symbols to classes\n markdown_engine_klass = if app.config[:markdown_engine].is_a? Symbol\n engine = app.config[:markdown_engine].to_s\n engine = engine == 'rdiscount' ? 'RDiscount' : engine.camelize\n app.config[:markdown_engine_prefix].const_get(\"#{engine}Template\")\n else\n app.config[:markdown_engine_prefix]\n end\n\n # Tell tilt to use that engine\n ::Tilt.prefer(markdown_engine_klass, *markdown_exts)\n end\n rescue LoadError\n # If they just left it at the default engine and don't happen to have it,\n # then they're using middleman-core bare and we shouldn't bother them.\n if app.config.setting(:markdown_engine).value_set?\n logger.warn \"Requested Markdown engine (#{app.config[:markdown_engine]}) not found. Maybe the gem needs to be installed and required?\"\n end\n end\n end",
"def before_validation_rewrite_suggestion_handler\n generate_valid_rewrite\n end",
"def key(*args)\n key = super \n if converter_name = key.options[:as_string]\n key_name = key.name.to_sym \n available_as_string key_name, converter_name\n attr_protected \"#{key_name}_as_string\".to_sym if key.options[:protected] \n end\n key\n end",
"def to_knot(**options) = convert_to('knot', **options)"
] | [
"0.73307276",
"0.6454526",
"0.59406716",
"0.5802251",
"0.57538885",
"0.5658694",
"0.55258095",
"0.55220056",
"0.52579296",
"0.52572477",
"0.5236103",
"0.521867",
"0.5200783",
"0.5179824",
"0.5065934",
"0.50557727",
"0.50371003",
"0.50331336",
"0.49899033",
"0.49649683",
"0.49649683",
"0.49649683",
"0.49360472",
"0.4930849",
"0.49285343",
"0.4925636",
"0.48623818",
"0.4795143",
"0.4784265",
"0.47409612",
"0.47262764",
"0.4721668",
"0.47158232",
"0.47152904",
"0.471336",
"0.471336",
"0.46874362",
"0.4682781",
"0.467401",
"0.46721035",
"0.46669093",
"0.46507633",
"0.46464804",
"0.4623247",
"0.46109846",
"0.4609176",
"0.46083754",
"0.46045986",
"0.4586395",
"0.45859745",
"0.456812",
"0.4540444",
"0.45389166",
"0.45372656",
"0.45368552",
"0.45368552",
"0.45304435",
"0.45302615",
"0.45254493",
"0.45196968",
"0.45196968",
"0.45107278",
"0.45079893",
"0.45001096",
"0.44890642",
"0.44883025",
"0.44804296",
"0.44804296",
"0.44754973",
"0.44667155",
"0.4462935",
"0.4462935",
"0.44574317",
"0.44509503",
"0.44503888",
"0.44418883",
"0.44418883",
"0.44418883",
"0.44418883",
"0.44418883",
"0.44418883",
"0.44418883",
"0.44418883",
"0.44402087",
"0.44398904",
"0.4431709",
"0.44307992",
"0.44262627",
"0.4410966",
"0.4410397",
"0.4409767",
"0.44083002",
"0.44062263",
"0.4402253",
"0.44010195",
"0.43902388",
"0.4389813",
"0.4389179",
"0.43745947",
"0.43744898"
] | 0.7367091 | 0 |
Use this method in DSL methods to add a parser to config | def add_kramdown_parser(name, class_name)
@kramdown_parsers[name.to_sym] = Object.const_get(class_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_parser; end",
"def configure!(parser); end",
"def register(parser)\n parsers.push parser\n end",
"def configure_parser\n @parsers = {}\n (@block_parsers + @span_parsers).each do |name|\n if self.class.has_parser?(name)\n @parsers[name] = self.class.parser(name)\n else\n raise Kramdown::Error, \"Unknown parser: #{name}\"\n end\n end\n @span_start, @span_start_re = span_parser_regexps\n end",
"def add_parser(klass)\n @ex_parsers.insert(0, klass)\n end",
"def parser=(parser)\n @parser = parser_from(parser)\n end",
"def define_on_parser(name, used_parser, *args)\n @parsers[name] = Proc.new { @parsers[used_parser].call(*args) }\n end",
"def configure_cli_parser( parser, hooks )\n hooks.each do |b|\n instance_exec parser, &b\n end\n end",
"def parser(v)\n @options[:parser] = v\n end",
"def initialize parser\n @parser = parser\n end",
"def pluggable_parser; end",
"def parser( &block )\n nested_class( 'Parser', Yacl::Define::Cli::Parser, &block )\n end",
"def parsing(parser)\n yield\n resolve parser\n self\n end",
"def set_parser\n @parser = Parser.find(params[:id])\n end",
"def set_parser\n @parser = Parser.find(params[:id])\n end",
"def parser=(p)\n @@parser = choose_parser(p)\n end",
"def set_parser\n @parser = Parser.find(params[:id])\n end",
"def parser\n dsl.parser\n end",
"def parser\n create_option_parser if @parser.nil?\n @parser\n end",
"def method_missing(method_name, *args, &block)\n name = args.shift\n add_to_hash(name, options: [method_name] + args)\n\n new_parser = self.class.new\n add_to_hash(name, content: new_parser.instance_exec(&block)) if block\n add_to_hash(name, content: new_parser.hash)\n new_parser\n end",
"def parser(value = nil)\n setget(:@parser, value)\n end",
"def has_parser?(name); end",
"def expand(parser)\n Parser.parsers_for(parser.preparsers).push(parser)\n end",
"def parser\n attributes.fetch(:parser)\n end",
"def process(parser)\n end",
"def configure_base!(parser)\n parser.banner = \"Usage: advent_2019 #{self.class::NAME} [options]\"\n parser.on('-i INPUT', '--input INPUT', 'the input file')\n parser.on_tail('-h', '--help', 'show this help message') do\n Advent2019.show_help(parser)\n end\n configure!(parser)\n end",
"def parser\n @parser ||= parser_klass.new(job_folder)\n end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def register_parse_handler(key, &block)\n ArgParser::OnParseHandlers[key] = block\n end",
"def parser\n if !defined?(@parser) || !@parser\n DEFAULT_PARSER\n else\n @parser || DEFAULT_PARSER\n end\n end",
"def parser; end",
"def parser; end",
"def parser; end",
"def parser; end",
"def options_parse(_options_parser)\n @calls << [:options_parse]\n end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def add(data)\n @parser << data\n end",
"def initialize\n @option_parser = OptionParser.new do |opt|\n opt.banner = banner\n opt.summary_indent = Shebang::Config[:indent]\n\n # Process each help topic\n help_topics.each do |title, text|\n opt.separator \"#{Shebang::Config[:heading]}#{\n Shebang::Config[:indent]}#{text}\" % title\n end\n\n opt.separator \"#{Shebang::Config[:heading]}\" % 'Options'\n\n # Add all the options\n options.each do |option|\n opt.on(*option.option_parser) do |value|\n option.value = value\n\n # Run a method?\n if !option.options[:method].nil? \\\n and respond_to?(option.options[:method])\n # Pass the value to the method?\n if self.class.instance_method(option.options[:method]).arity != 0\n send(option.options[:method], value)\n else\n send(option.options[:method])\n end\n end\n end\n end\n end\n end",
"def uses(parser_type)\n @source.parser_type = parser_type\n end",
"def parse\n parse_command\n load_config\n finalize_setup\n end",
"def as_config\n Configureasy::Config.new self.parse\n end",
"def options_parser\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: #{File.basename($0)} [options...]\"\n\n opts.on '-d', '--dir DIR',\n 'directory of yml files to process' do |dirname|\n @options[:dir] = dirname\n end\n\n opts.on '-f', '--file FILE',\n 'single file to process' do |filename|\n @options[:file] = filename\n end\n\n opts.on '--db DATABASE_NAME',\n 'sqlite3 database to push data to' do |dbname|\n @options[:db] = dbname\n end\n\n opts.on '-h', '--help' do\n @options[:help] = true\n end\n end\n optparse\nend",
"def register(name, klass)\n @@parsers ||= {}\n @@parsers[:default] = klass if @@parsers.empty?\n @@parsers[name] = klass\n end",
"def parser\n @parser ||= (\n parser = ::OptionParser.new\n parser.on_tail('--quiet', 'Turn on $QUIET mode.') do\n $QUIET = true\n end\n parser.on_tail('--debug', 'Turn on $DEBUG mode.') do\n $DEBUG = true\n end\n parser.on_tail('-v', '--version', 'Display current version.') do\n puts \"Smeagol #{Smeagol::VERSION}\"\n exit 0\n end\n parser.on_tail('-h', '-?', '--help', 'Display this help screen.') do\n puts parser\n exit 0\n end\n parser\n )\n end",
"def option_parser\n @option_parser ||= OptionParser.new(banner, 25) do |opts|\n opts.banner = banner\n\n OptionSetter.new(self, opts).setup\n end\n end",
"def kramdown_parser(name)\n get_config_val(@kramdown_parsers, name)\n end",
"def parser=(_arg0); end",
"def parser\n Parser.new(self, :mode=>mode)\n end",
"def register_parser_type(type, parser_klass, extensions = T.unsafe(nil)); end",
"def parse_config\r\n exec 'parse_config(true);'\r\n self.config_parsed = true\r\n end",
"def parse_config \n path = \"#{Rails.root}/config/mebla.yml\"\n return unless File.exists?(path)\n \n conf = YAML::load(ERB.new(IO.read(path)).result)[Rails.env]\n \n conf.each do |key,value|\n self.send(\"#{key}=\", value) if self.respond_to?(\"#{key}=\")\n end unless conf.nil?\n end",
"def initialize\n utility_parsers\n operator_parsers\n integer_parsers\n term_and_expr_parsers\n end",
"def parser_params\n params[:parser]\n end",
"def register_parser_type(type, parser_klass, extensions = nil)\n unless Base > parser_klass\n raise ArgumentError, \"expecting parser_klass to be a subclass of YARD::Parser::Base\"\n end\n parser_type_extensions[type.to_sym] = extensions if extensions\n parser_types[type.to_sym] = parser_klass\n end",
"def init_parser\n @parser = OptionParser.new do |opts|\n opts.on('-j', '--show-json', 'Show the raw JSON response') do |json|\n @options[:show_json] = json\n end\n opts.summary_width = 50\n end\n end",
"def configure_loader(loader, system)\n loader.tag = system.config.name || system.name unless loader.tag\n loader.inflector = CompatInflector.new(system.config)\n loader.logger = method(:puts) if debug\n end",
"def initialize block_parser\n @block_parser = block_parser\nend",
"def load(optparse, &block)\n return if block.nil? && !File.exists?(Config::CONFIG_FILE)\n config = @config\n config.optparse = optparse\n environment = Class.new do\n define_method(:set) { |opt,val| config.set(opt,val) }\n define_method(:use) { |plugin,*args,&b| config.use(plugin,*args,&b) }\n define_method(:before) { |*args,&block| config.before(*args,&block) }\n define_method(:after) { |*args,&block| config.after(*args,&block) }\n define_method(:tick) { |&block| config.tick(&block) }\n define_method(:option) { |sh,lo,desc,&b| config.option(sh,lo,desc,&b) }\n end.new\n\n if block # for test environment\n environment.instance_eval(&block)\n else\n environment.instance_eval(File.read(Config::CONFIG_FILE), Config::CONFIG_FILE)\n end\n end",
"def add(matcher, value)\n @configurations[parse_matcher(matcher)] = value\n end",
"def initialize(file_parser)\n @file_parser = file_parser\n @sub_commands = @file_parser.runnable_methods.map { |m| m.name.to_s }\n @sub_commands_text = @file_parser.runnable_methods.map do |m|\n [\n m.name.to_s,\n FileParser.select_runnable_tags(m).map(&:text).join(\"\\n\")\n ]\n end.to_h\n @parser = Optimist::Parser.new\n @parser.opt(:debug, 'Run in debug mode.', type: :flag)\n @parser.stop_on @sub_commands\n @initialize_method = nil\n end",
"def parser_params\n params.require(:parser).permit(:name, :xpath, :domain)\n end",
"def parsers(rules = @rules)\n @parser = {}\n begin\n if rules.commands.has_key? :global\n global = rules.commands[:global]\n rules.parser[:global] = ::OptionParser::new do |o|\n o.banner = \"\\tscript [global options] [subcommand] [options]\"\n o.separator ''\n o.separator \"\\tGlobal Options:\"\n o.separator \"\\t===============\"\n o.separator ''\n global.inputs.each_pair do |name, input|\n o.on(input.options.short, input.options.long, input.description) do |x|\n validate_input input, x\n end\n end\n if rules.commands.size > 1\n o.separator ''\n o.separator \"\\tSubcommands: script subcommand [options]\"\n o.separator \"\\t========================================\"\n o.separator ''\n end\n o.on('-h', '--help', 'display the help usage menu') do\n puts rules.parser[:global]\n rules.commands.each_pair do |name, command|\n next if command.name == :global\n puts rules.parser[command.name]\n end\n exit 0\n end\n end\n end\n rules.commands.values.each do |c|\n next if c.name == :global\n rules.parser[c.name] = ::OptionParser::new do |o|\n o.banner = ''\n o.separator \"\\tcommand: [%s]: %s\\n\" % [c.name, c.description]\n o.separator ''\n c.inputs.each_pair do |name, input|\n o.on(input.options.short, input.options.long, input.description) do |x|\n validate_input input, x if defined? x\n end\n o.on('-h', '--help', 'display the help usage menu') do\n puts rules.parser[c.name]\n exit 0\n end\n end\n end\n end\n rescue SystemExit => e\n raise SystemExit\n rescue ArgumentError => e\n Logger.error 'load_option_parser: argument error: %s' % [e.message]\n raise ArgumentError, e.message\n rescue Exception => e\n Logger.error 'load_option_parser: unable to generate the parsers, error: %s' % [e.message]\n raise Exception, e.message\n end\n end",
"def <<(data)\n @parser << data\n end",
"def config(tool, loader)\n tool_class = tool.tool_class\n DSL::Internal.prepare(tool_class, tool.full_name, tool.priority, nil, @source_info,\n loader) do\n tool_class.class_eval(&@block)\n end\n yield\n end",
"def option_parser\n @parser ||= OptionParser.new do |opts|\n opts.banner = \"Usage: ./tools [#{AVAILABLE_COMMANDS.join('|')}] <options>\"\n\n # Allow user to choose a different configuration file\n opts.on('-c', '--config [path]', 'Change configuration file from default.') do |path|\n options.configuration_path = path\n end\n\n # View program help\n opts.on_tail('-h', '--help', 'See program help.') do\n puts opts\n exit\n end\n end\n end",
"def parse_config(config); end",
"def parser\n Trollop::Parser.new do\n banner USAGE\n opt :file, 'The file that will store the tags',\n type: :string, default: '/etc/facter/facts.d/ec2_tags.json'\n opt :all, 'Collect all tags'\n stop_on_unknown\n end\n end",
"def ruby_parser\n @ruby_parser ||= parser_for_version ruby_version\n end",
"def open_parser(this_file)\n\t\t@file = this_file\n\t\t@parser = PbfParser.new(file)\n\tend",
"def parser_listener\n # create on demand. not always used\n @parser_listener = NvdFsParserListener.new(self,@enable_xml_save) if @parser_listener.nil?\n @parser_listener\n end",
"def create_parser(command_name)\n OptionParser.new do |parser|\n parser.banner = \"Usage: ./project.rb #{command_name} [options]\"\n parser\n end\nend",
"def config(name = nil, &block)\n if name.nil?\n name = self.plugin_name\n else\n self.plugin_name = name\n end\n\n if block_given?\n opts = {}\n opts[:after] ||= configs.last.name unless configs.empty?\n ::Loquacious::Configuration.defaults_for plugin_name, &Proc.new(&block)\n initializer = Initializer.new(plugin_name, self, opts) do\n ::Loquacious.configuration_for plugin_name, &block\n end\n Adhearsion::Plugin.configs << initializer\n else\n ::Loquacious.configuration_for plugin_name\n end\n end",
"def push(data)\n @parser << data\n end",
"def push(data)\n @parser << data\n end",
"def create_parser(options)\n parser = OptionParser.new\n\n parser.on \"-o DIR\", \"--output-dir DIR\", \"Specify custom output directory\" do |value|\n options.custom_output_dir_set = true\n options.custom_output_dir_value = value\n end\n parser.on \"-s FILENAME\", \"--single-file FILENAME\", \"Output all quotes in a single file\" do |name|\n options.single_file = true\n options.single_file_name = name\n end\n parser.on \"-l\", \"--list-categories\", \"List all available categories\" do\n options.list_only = true\n end\n\n parser.on \"-h\", \"--help\", \"Print this help text\" do\n puts parser\n exit\n end\n\n parser.on \"-v\", \"--version\", \"Print program version\" do\n puts \"gnomikologikon-fortune #{Gnomika::Ruby::VERSION}\"\n exit\n end\n end",
"def add(plugin); end",
"def resolve(parser)\n end",
"def parser_params\n params.require(:parser).permit(:name, :expression, :blacklist, :source_group)\n end",
"def configure\n yield config\n end",
"def configure\n yield config\n end",
"def configure\n yield config\n end",
"def option_parser\n options = {}\n option_parser = OptionParser.new do |opts|\n self.class.setup_accepts(opts,@accepts)\n self.class.setup_options(opts,@switches,options)\n self.class.setup_options(opts,@flags,options)\n end\n [option_parser,options]\n end",
"def parse(doc)\n parser = parser_class.new\n parser.run(doc)\n end",
"def optParse\n OptionParser.new do |o|\n o.on('-v', 'Be more verbose.') { |i|\n self[:verbose] += 1\n }\n o.on('-V', '--version', 'Show version & exit.') { |i|\n puts Meta::VERSION\n exit EX_OK\n }\n o.on('--config NAME',\n \"Set a config name or file\",\n \"(default is #{@conf[:config_name]}).\") {|arg|\n @conf[:config_name] = arg\n }\n o.on('--config-dirs', 'Show possible config locations.') {\n mark = false\n @conf[:config_dirs].each { |idx|\n f = Pathname(idx) + @conf[:config_name]\n if File.file?(f) && !mark\n puts \"* #{f}\"\n mark = true\n else\n puts \" #{f}\"\n end\n }\n exit EX_OK\n }\n\n yield o if block_given?\n o.banner = @conf[:banner]\n\n env = nil\n env = ENV[@conf[:config_env]].shellsplit if ENV.key?(@conf[:config_env])\n\n begin\n [env, ARGV].each { |i| o.parse!(i) if i }\n rescue\n CliUtils.errx EX_USAGE, $!.to_s\n end\n end\n end",
"def initialize(app)\n super app\n @parser = nil\n end",
"def parse\n options = {}\n options.merge(parse_config_file(CONFIG_LOCATION))\n\n argv = parse_argv\n if argv[:config_file].kind_of?(String)\n options.merge(parse_config_file(argv[:config_file]))\n end\n\n options.merge(argv)\n end",
"def parse_config\n %w(/etc/steel/steel.yml steel.yml).each do |cfg|\n if File.exist?(cfg)\n begin\n y = YAML.load_file(cfg)\n rescue Psych::SyntaxError => e\n error \"[#{e.class}] Failed to parse '#{cfg}'!!\"\n error e.message\n exit 1\n end\n # Merge the contents of the config into @config.\n config.merge!(y)\n end\n end\n end",
"def initialize configuration\n @queue=Queue.new\n @parser=instantiate_class(configuration.parser,configuration) if configuration.parser\n if configuration.runner\n if configuration.runner[:class]\n @runner=configuration.runner[:class].new(configuration.context,@queue)\n else\n raise RutemaError,\"Runner settting overriden, but missing :class\"\n end\n else\n @runner=Rutema::Runners::Default.new(configuration.context,@queue)\n end\n raise RutemaError,\"Could not instantiate parser\" unless @parser\n @dispatcher=Dispatcher.new(@queue,configuration)\n @configuration=configuration\n end",
"def run_option_parser\n @run_option_parser ||= begin\n require 'optparse'\n OptionParser.new do |op|\n op.on('-x') { set :lock, true }\n op.on('-e env') { |val| set :environment, val.to_sym }\n op.on('-s server') { |val| set :server, val }\n op.on('-p port') { |val| set :port, val.to_i }\n end \n end\n end",
"def initialize(parsers: {}, filters: [])\n @filters = filters\n @parsers = parsers\n end",
"def configure\n yield config if block_given?\n end",
"def initialize(name, parser, &block)\n @name = name\n @parser = parser\n @modules = []\n @wrapped_functions = []\n @wrapped_classes = []\n @wrapped_structs = []\n\n block.call(self) if block\n end",
"def config\n yield self\n end",
"def config\n yield self\n end",
"def config\n yield self\n end",
"def post_parse=(block)\n meta_def(:post_parse, &block)\n end",
"def config(&block)\n yield(self)\n end",
"def register_parsing_thread\n @parser_thread = Thread.new { parser.parse }\n end",
"def setup\n @config[\"syntax_highlighter\"] ||= highlighter\n @config[\"syntax_highlighter_opts\"] ||= {}\n @config[\"syntax_highlighter_opts\"][\"default_lang\"] ||= \"plaintext\"\n @config[\"syntax_highlighter_opts\"][\"guess_lang\"] = @config[\"guess_lang\"]\n @config[\"coderay\"] ||= {} # XXX: Legacy.\n modernize_coderay_config\n make_accessible\n end"
] | [
"0.74966013",
"0.7271308",
"0.71893173",
"0.6958163",
"0.682901",
"0.681609",
"0.68063974",
"0.6682747",
"0.66206163",
"0.6335149",
"0.63130647",
"0.63072616",
"0.6296398",
"0.62479156",
"0.62479156",
"0.606188",
"0.6056076",
"0.6037529",
"0.5955688",
"0.5954962",
"0.5939584",
"0.58973897",
"0.5880955",
"0.5859579",
"0.58219606",
"0.5699712",
"0.5682463",
"0.56519306",
"0.56519306",
"0.5635223",
"0.5569865",
"0.5564026",
"0.5564026",
"0.5564026",
"0.5564026",
"0.5544966",
"0.55421424",
"0.5534973",
"0.5527069",
"0.5500638",
"0.5483013",
"0.54814833",
"0.54555565",
"0.5418094",
"0.537645",
"0.536403",
"0.53527033",
"0.53526795",
"0.53238684",
"0.5321481",
"0.5297522",
"0.52555984",
"0.52375984",
"0.5222381",
"0.5222317",
"0.5200678",
"0.5190354",
"0.51876456",
"0.5178297",
"0.5165927",
"0.5159996",
"0.5154049",
"0.51518655",
"0.5143466",
"0.51384795",
"0.51315457",
"0.5127094",
"0.51231986",
"0.5112406",
"0.51080745",
"0.5105216",
"0.5105152",
"0.51001185",
"0.5078817",
"0.5078817",
"0.5076508",
"0.5055331",
"0.50398767",
"0.50398433",
"0.500747",
"0.500747",
"0.500747",
"0.50030106",
"0.49973038",
"0.498879",
"0.49850205",
"0.49849537",
"0.49738008",
"0.49681807",
"0.49638802",
"0.4961461",
"0.49569625",
"0.4943431",
"0.49335682",
"0.49335682",
"0.49335682",
"0.49264815",
"0.49091205",
"0.49081108",
"0.49058497"
] | 0.5971253 | 18 |
Use this method in DSL methods to add a setting. | def add_setting(setting_key, setting_val)
@settings[setting_key.to_sym] = setting_val
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setting( name, **options, &block )\n\t\tself.log.debug \" adding %s setting to %p\" % [ name, self.target ]\n\t\tself.add_setting_accessors( name, options, &block )\n\t\tself.add_default( name, options )\n\tend",
"def call\n setting_item = build_setting_item(name, type, default)\n register_setting setting_item\n define_setting setting_item\n setting_item\n end",
"def set_setting\n end",
"def setting(*args, **options, &block)\n setting = __config_dsl__.setting(*args, **options, &block)\n\n _settings << setting\n\n __config_reader__.define(setting.name) if setting.reader?\n\n self\n end",
"def method_missing setting, *args, &block\n return target.public_send(setting, *args, &block) if target_respond_to? setting\n\n @setting_path << setting\n\n return target(*args) if @setting_path.question_action_or_setter?\n\n self\n end",
"def setting=(value)\n @setting = value\n end",
"def add_setting_writer(item)\n self.send(:define_method, \"#{item.name}=\") do |newvalue|\n old = send(item.name)\n retval = settings[item.name] = canonicalize(item.name, newvalue)\n self.settings_changed << item.name unless old == retval\n unless new_record?\n self.settings_will_change!\n end\n retval\n end\n end",
"def create_setting\n if setting_options.is_a?(Hash)\n setting_options[:options][:validations] = setting_options[:validations]\n setting = Supports::Settingable::Models::Setting.new name: setting_options[:name]\n setting.options = setting_options[:options]\n setting.settingable= self\n setting.save\n end\n end",
"def setting; end",
"def add_setting_accessor(item)\n add_setting_reader(item)\n add_setting_writer(item)\n end",
"def config_set_app_setting(document, settingName, settingValue)\n\t config_set_attribute(document, '//configuration/appSettings/add', 'key', settingName, 'value', settingValue)\n\tend",
"def set_setting\n ap @setting = Setting.first\n end",
"def setting(setting_name, setting_value)\n setting_specs << {:name => setting_name.to_s, :value => setting_value.to_s, :config_line => get_config_line(caller)}\n end",
"def set(key, value)\n settings.send :\"#{key}=\", value\n end",
"def add(config = {})\n config.each do |key, value|\n define_setting key.to_sym, value\n end\n end",
"def setting(name, type=:object, default=nil)\n item = Item.new\n item.name, item.ruby_type, item.default = name.to_s, type, default\n fields[name.to_s] = item\n add_setting_accessor(item)\n end",
"def set(setting, value)\n setting = setting.to_sym\n if setting == :estream\n self.estream = value\n elsif setting == :ostream\n self.ostream = value\n else\n @settings[setting.to_sym] = value\n end\n end",
"def e_set_setting(key, value)\n set_option(key, value, '_setting_ecommerce')\n end",
"def setting(nested_key, value)\n settings.set(nested_key, value)\n save_settings!\n end",
"def set_setting\n @setting = Setting.first\n end",
"def add_setting(header, name, value)\n raise DuplicateSetting if setting_exists?(header, name)\n\n new_setting = %Q{[#{ header }]\\n#{ name } = #{ value }\\n}\n write do\n if contents.nil?\n new_setting\n elsif contents.scan(header_regexp(header)).empty?\n contents << \"\\n\\n#{ new_setting }\"\n else\n contents.gsub(header_regexp(header), new_setting)\n end\n end\n end",
"def set(setting, value=setting)\n case setting.class.to_s\n when 'Hash'\n settings.merge!(value)\n when 'String', 'Symbol'\n settings[setting.to_sym] = value\n else\n raise ArgumentError, \"setting must be a symbol, string or hash\"\n end\n end",
"def setter(section, setting, value)\n method = \"#{setting}=\"\n section.send(method, value) if section.respond_to?(method)\n end",
"def setting(name, options = {}, &block)\n settings[name] = InputField.new(name, options, &block)\n end",
"def set(setting, value = nil)\n if value\n command \"set #{setting}=#{value}\"\n else\n command \"set #{setting}\"\n end\n self\n end",
"def add_setting_reader(item)\n self.send(:define_method, item.name) do\n raw_value = settings[item.name]\n raw_value.nil? ? item.default : raw_value\n end\n if item.ruby_type == :boolean\n self.send(:define_method, item.name + \"?\") do\n raw_value = settings[item.name]\n raw_value.nil? ? item.default : raw_value\n end\n end\n end",
"def add_preference(name, value); end",
"def add_preference(name, value); end",
"def []=(key, value)\n @settings[@key] << \"#{key}=#{value}\"\n end",
"def setting(property, value)\n\t\tproperty + ':' + value + ';'\n\tend",
"def set_add(key, value)\n perform_update(:set_add, key, value.to_s)\n end",
"def setup(&block)\n settings.instance_eval(&block) if block_given?\n end",
"def create_setting(setting, opts = {})\n create_setting_with_http_info(setting, opts)\n nil\n end",
"def define_setting(key, default=nil, description=nil, options={})\n raise \"Setting #{key} doesn't exist\" if @finalized\n raise \"Setting #{key} already defined\" if @settings.key?(key)\n raise 'Setting key must be a Symbol' unless key.is_a? Symbol\n\n @settings[key] = ConfigSetting.new(key, default, description, options)\n end",
"def update_setting!(setting: nil)\n existing = find_setting(setting_key: setting.key)\n existing.value = setting.value\n self.settings = settings\n end",
"def []=(key, val)\n setting_obj = setting(key) || define_setting(key)\n setting_obj.value = val\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_project_setting(key,value)\n is_ok = true\n if block_given?\n is_ok = yield key\n end\n\n if is_ok\n config_list = @project.build_configuration_list\n config_list.set_setting key ,value\n end\n end",
"def set(k, v)\n settings[k.to_sym] = v\n end",
"def method_missing method, *args, &block\n if args.length == 1\n args = args.first\n end\n @settings[method] = args\n return self\n end",
"def set(k, v)\n settings[k.to_sym] = v\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def add(key, *value)\n run { conf.add(key, value, config_params) }\n end",
"def add_configuration(value)\n @children['configuration'][:value] << value\n end",
"def store_in_buffer_setting(key, value)\n if key == \"OPTIONS\"\n\n # Options are stored in a hash. Special-case.\n value.scan(/([^ ]*):((((\\(.*\\))))|([^ ])*)/) do |o, v|\n @options[o] = v\n end\n elsif key =~ /^(TODO|SEQ_TODO|TYP_TODO)$/\n # Handle todo keywords specially.\n value.split.each do |keyword|\n keyword.gsub!(/\\(.*\\)/, \"\") # Get rid of any parenthetical notes\n keyword = Regexp.escape(keyword)\n next if keyword == \"\\\\|\" # Special character in the todo format, not really a keyword\n @custom_keywords << keyword\n end\n else\n @in_buffer_settings[key] = value\n end\n end",
"def set!(path, value)\n setProperty path, value\n save if respond_to? :save # Only Configuration can save\n value\n end",
"def config=(value); end",
"def save_setting(key, val)\r\n # Check for nil, since unchecked checkboxes don't send a value.\r\n # Check for whether a boolean, since .blank? returns true for false.\r\n # Check for a blank string.\r\n if val == nil || !!val == val || !val.blank?\r\n setting = Setting.where(key: key).first_or_create\r\n setting.value = val\r\n setting.save\r\n end\r\n end",
"def set_setting\n @setting = Setting.for_user(current_user).find(params[:id])\n end",
"def []=(setting, value)\n value = nil if value.is_a?(String) && value.empty?\n \n if setting.to_s == \"dependencies\"\n self.dependencies = []\n value.each do |dep|\n name, *reqs = dep.split(\",\").map { |x| x.strip }\n add_runtime_dependency(name, *reqs)\n end\n else\n send(\"#{setting}=\", value) if respond_to?(\"#{setting}=\")\n end\n end",
"def app_settings=(value)\n @children['app-settings'][:value] = value\n end",
"def app_settings=(value)\n @children['app-settings'][:value] = value\n end",
"def method_missing(method, *args, &blk)\n if settings.respond_to? method, true\n settings.__send__(method, *args, &blk)\n else\n super\n end\n end",
"def create\n\n @setting = Setting.new(\n :tenant => Tenant.current,\n :user => current_user,\n :name => params[:name],\n :value => params[:value])\n\n respond_to do |format|\n if @setting.save\n format.html { redirect_to \"/settings/#{@setting.id}\", notice: 'Setting was successfully created.' }\n format.json { render json: @setting, status: :created, location: @setting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cfg_set(key, value)\n hr_config.set_for_url(url.to_s, key, value)\n end",
"def set(option, value)\n define_method(option) { value }\n end",
"def set_setting\n @o_single = Setting.find(params[:id])\n end",
"def settings=(value)\n @settings = value\n end",
"def settings=(value)\n @settings = value\n end",
"def initialize(setting = Setting.find_or_create)\n self.setting = setting\n end",
"def set(token, **definition)\n store[token] = Justdi::Definition.new(**definition)\n end",
"def set_settings(new_settings, options = {}, request_options = {})\n client.put(Protocol.settings_uri(name, options), new_settings.to_json, :write, request_options)\n end",
"def set_resource\n @setting = Setting.first!\n end",
"def setconfig(str)\n add_cmd str\n end",
"def setting(name, default_value=nil, default_proc: nil, &block)\n if block_given?\n # Create a nested setting\n setting_config = @settings[name]&.value || ConfigStruct.new(\"#{@name}.#{name}\")\n setting = ConfigValue.new\n setting.value = setting_config\n @settings[name] = setting\n setting_config.instance_eval(&block)\n else\n setting = ConfigValue.new\n setting.default_proc = default_proc\n setting.default_value = default_value\n setting.reset!\n @settings[name] = setting\n end\n end",
"def setting_params\n params.require(:setting).permit(:name, :value)\n end",
"def setting_params\n params.permit(:setting, :key, :value, :location) #, :key, :value, :location, #:system_node_id )\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def set_setting\n @setting = Setting.find(params[:id])\n end",
"def add(name, value)\n build(name, value).tap do |hook|\n hook.save\n end\n end",
"def set_target_setting(target,key,value)\n is_ok = true\n if block_given?\n is_ok = yield target, key\n end\n\n if is_ok\n target_config_list = target.build_configuration_list\n target_config_list.set_setting(key, value)\n end \n end",
"def setting_params\n params.require(:setting).permit(:var, :value)\n end",
"def add(matcher, value)\n @configurations[parse_matcher(matcher)] = value\n end",
"def set(domain, key, value, type = nil)\n command = ['defaults', 'write', domain, key]\n command << \"-#{type}\" unless type.nil?\n command << value.to_s\n log command.join(' ')\n shell!(*command)\n end",
"def register_setting(key, default_value)\n self.class.validate_value(default_value)\n\n @defaults[key] = default_value\n\n # update cache\n @settings[key] = @records[key] || default_value\n end",
"def settings=(setting_options = [])\n # for arrays, set in raw form \n @settings = if setting_options.is_a?(Array)\n setting_options\n # set optional shortcuts for settings\n # :keyword_match_setting => { :opt_in => false } # =>\n # { :xsi_type => 'KeywordMatchSetting', :opt_in => false }\n elsif setting_options.is_a?(Hash)\n setting_options.map do |key, values|\n { :xsi_type => key.to_s.camelcase }.merge(values).symbolize_keys\n end\n end\n end",
"def configure_setting(name, value)\n configure do |settings|\n settings.unset!(name)\n settings[name] = parse_setting(settings.setting(name), value)\n end\n end",
"def update_setting!(setting:)\n key = setting.key\n\n if setting_data_source.find_setting(setting_key: key).nil?\n raise SettingServiceKeyNotFound\n end\n\n setting_data_source.update_setting!(setting: setting)\n end",
"def configure\n yield settings\n end",
"def setting(key)\n @settings[key]\n end",
"def set_setting\n @setting = @org.setting\n raise ActiveRecord::RecordNotFound unless @org.setting.id.to_s == params[:id].to_s\n end",
"def add_preference(name, value)\n @options[:prefs][name] = value\n end",
"def add_option(rule, key, value)\n return unless include?(rule)\n @rules[rule].options[key] = value\n end",
"def setting_params\n params.require(:setting).permit(:namespace, :value)\n end",
"def setting_name=(value)\n @setting_name = value\n end",
"def settings(&block)\n if block\n @settings_block = block\n elsif @settings_block\n @settings = Settings::DSL.new(identifier, &@settings_block).call\n else\n @settings\n end\n end",
"def set_app_setting\n @app_setting = AppSetting.settings\n end",
"def method_missing(name,*args,&block)\n options = args.extract_options!\n options.assert_valid_keys(@meta::VALID_KEYS)\n options = check_and_maintain_options(options)\n\n\t\tcheck_reserved_words(name)\n\n options[:klass] = @klass # option should know class\n options[:parent] = @parent.name.to_sym if @parent\n options[:name] = name\n \n new_meta_option = SettingsLord::MetaSetting.new(options)\n @meta_collection.add(new_meta_option)\n end",
"def client_setting(name, default = nil, opts = {})\n setting(name, default, opts)\n client_settings << name.to_sym\n end"
] | [
"0.70662206",
"0.69325036",
"0.68566453",
"0.66347617",
"0.6503639",
"0.6453362",
"0.63327265",
"0.6226986",
"0.61455745",
"0.6099344",
"0.6091122",
"0.6054648",
"0.60166407",
"0.6010771",
"0.59484315",
"0.594761",
"0.5946499",
"0.59159046",
"0.5907157",
"0.5868665",
"0.5863365",
"0.58048165",
"0.57983404",
"0.5753178",
"0.57083845",
"0.5652662",
"0.56344175",
"0.56344175",
"0.5630268",
"0.55851066",
"0.5581495",
"0.55546665",
"0.5547414",
"0.5527012",
"0.5522289",
"0.5499142",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5498779",
"0.5493327",
"0.5470125",
"0.5468884",
"0.5468196",
"0.54663825",
"0.54471093",
"0.5432743",
"0.54248625",
"0.54189354",
"0.5415898",
"0.5414997",
"0.5391165",
"0.53711075",
"0.53522307",
"0.53522307",
"0.5347577",
"0.53410864",
"0.5306912",
"0.5303255",
"0.53010476",
"0.53005403",
"0.53005403",
"0.5298462",
"0.52849054",
"0.52771586",
"0.52760035",
"0.52737594",
"0.52675927",
"0.52569747",
"0.5245147",
"0.5235061",
"0.5235061",
"0.5235061",
"0.5235061",
"0.52339077",
"0.523188",
"0.52282244",
"0.52188665",
"0.5214539",
"0.5208275",
"0.5206865",
"0.520524",
"0.5198753",
"0.51982266",
"0.5183546",
"0.5175974",
"0.5175744",
"0.5164858",
"0.51645887",
"0.51406515",
"0.5140339",
"0.51396734",
"0.5131597",
"0.5128942"
] | 0.69175285 | 2 |
Retrieve a base dir | def base_dir(name)
if name.to_s !~ BASE_DIR_NAME_REGEX
raise ArgumentError.new("A base dir name must match this regex: #{ BASE_DIR_NAME_REGEX.inspect }")
end
get_config_val(@base_dirs, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_base\n # See if we need to extend the base_dir\n if @config['base']\n extended_base = File.expand_path(File.join(@real_base, @config['base']))\n if File.directory? extended_base\n @base_dir = extended_base\n else\n puts \"Your base directory doesn't exist: #{extended_base}\"\n exit 1\n end\n end\n end",
"def base_dir(dir_name)\n File.expand_path(dir_name)\n end",
"def base_directory\n @base_directory\n end",
"def base_path\n @base_path ||= Dir.pwd\n end",
"def basedir\n self.class._basedir\n end",
"def dir_base\n File.expand_path(File.dirname(__FILE__)+\"/../..\")\n end",
"def base_dir\n return Gem.dir unless loaded_from\n @base_dir ||= if default_gem? then\n File.dirname File.dirname File.dirname loaded_from\n else\n File.dirname File.dirname loaded_from\n end\n end",
"def base_path\n Dir.pwd + \"/\"\n end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_relative_dir\n \t\t@dir.gsub(/^\\//,\"\")\n \tend",
"def base_path\n @base_path ||= server_path(File.expand_path(Dir.pwd))\n end",
"def base_dir\n raise NotImplementedError\n end",
"def base_path\n @base_path || self.class.base_path\n end",
"def path\n @base\n end",
"def base_dir_for_path_parameters; end",
"def basedir\n return nil if !file\n File.dirname File.absolute_path @file\n end",
"def base_directory\n File.expand_path(File.join(File.dirname(__FILE__), '..'))\n end",
"def base_dir\n options.fetch('base_dir', '')\n end",
"def basepath; end",
"def root\n settings[:basedir]\n end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir_for_path_parameters\n @base_dir_for_path_parameters ||=\n if File.basename(loaded_path).start_with?('.rubocop') &&\n loaded_path != File.join(Dir.home, ConfigLoader::DOTFILE)\n File.expand_path(File.dirname(loaded_path))\n else\n Dir.pwd\n end\n end",
"def base_dir_for_path_parameters\n @base_dir_for_path_parameters ||=\n if File.basename(loaded_path).start_with?('.rubocop') &&\n loaded_path != File.join(Dir.home, ConfigLoader::DOTFILE)\n File.expand_path(File.dirname(loaded_path))\n else\n Dir.pwd\n end\n end",
"def base_path\n @base_path ||= self.class.respond_to?(:base_path) ? self.class.base_path : Merb.dir_for(:public)\n end",
"def base_dir # :nodoc:\n File.join @root_dir, 'bundler'\n end",
"def base_path\n self.class.base_path\n end",
"def basedir\n File.dirname File.absolute_path options[:file]\n end",
"def base_dir\n AYTests.base_dir\n end",
"def base_dir\r\n datastore['WritableDir']\r\n end",
"def calc_dir(page_base)\n page_full_path = File.join(GIT_REPO, unwiki(page_base))\n end",
"def dir\n calc_dir(@basename)\n end",
"def base\n find_base\n end",
"def root; Pathname(__dir__).parent; end",
"def primary_repo_base_dir\n File.expand_path(\n setting(:relative_path_to_primary_repo),\n base_dir(:rtfile_dir)\n ).sub(/\\/?\\z/, '') + '/'\n end",
"def base_path(val=nil)\n if val\n @base_path = val\n else\n @base_path || default_base_path_name\n end\n end",
"def base_directories\n @base_dirs ||= names.map { |name| ::Gem::Specification.find_by_name(name).gem_dir }\n end",
"def basedir\n \"tyrant\"\n end",
"def root\n File.dirname __dir__\n end",
"def base_paths\n @base_paths ||= find_base_paths\n end",
"def root\n File.dirname __dir__\n end",
"def root\n File.dirname __dir__\n end",
"def base\n return @config[\"base\"]\n end",
"def base()\n sub_ext('').basename.to_s\n end",
"def base_path(type = 'import')\n ENV['HYKU_MULTITENANT'] ? File.join(Bulkrax.send(\"#{type}_path\"), Site.instance.account.name) : Bulkrax.send(\"#{type}_path\")\n end",
"def base\n @info[:base]\n end",
"def parent_directory\n File.dirname(@full_path).split('/').last\n end",
"def parent_directory\n File.dirname(@full_path).split('/').last\n end",
"def sub_dir_of(file, base = base_directory)\n file = Pathname.new(file) unless file.respond_to?(:relative_path_from)\n base = Pathname.new(base) unless base.respond_to?(:relative_path_from)\n rel = file.relative_path_from(base)\n if file.directory?\n rel\n else\n rel.dirname\n end\n end",
"def base_path path=nil\n if path\n @base_path = path\n end\n @base_path || default_base_path\n end",
"def root\n Pathname.new(File.dirname(__dir__))\n end",
"def get_base_path()\n return TembooSession.get_base_path + \"/choreos\"\n end",
"def dir\n @dir ||= File.dirname(fullpath)\n end",
"def dir\n File.dirname(self.path)\n end",
"def root\n find_single_directory || @app_dir\n end",
"def a_dir\n self.path.split('/')[0...-1]\n end",
"def base_path\n wiki.base_path\n end",
"def find_repository_and_basepath\n # zuerst lesen wir den Startpfad aus der Datei ein\n unless File.exists?(PATH_TMP_FILE) and (@basepath=IO.read(PATH_TMP_FILE).strip)\n NSRunInformationalAlertPanel('Invalid start directory!',\n \"No directory information could be found in the configuration file '#{PATH_TMP_FILE}'!\",\n 'OK',nil,nil)\n NSApp.stop(self)\n end\n\n # jetzt gehen wir max. 5 Ebenen nach oben und suchen\n # nach einem Rakefile im Verzeichnis\n path=@basepath\n (0..5).each do |step|\n Dir.entries(path).each do |entry|\n return path if entry=~/^(.git|.hg)$/\n end\n path+=\"/..\"\n end\n\n # no reasonable rakefile was found, let's just use\n # the current directory for the files\n @basepath # Dir.pwd\n end",
"def dir\n url[-1, 1] == '/' ? url : File.dirname(url)\n end",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def get_directory(prefix='')\n File.expand_path(prefix, File.dirname(__FILE__))\n end",
"def curr_srcdir\n \"#{srcdir_root()}/#{relpath()}\"\n end",
"def curr_srcdir\n \"#{srcdir_root()}/#{relpath()}\"\n end",
"def doc_base(base)\n # find if the document has a base element\n base_el = @doc.at_css(\"html>head>base\") \n base = base_el.attribute(\"href\").to_s.split(\"#\").first if base_el\n base\n end",
"def base_path\n instance.options[:base_path]\n end",
"def base_uri\n url = URI.parse( @config[\"portal_url\"] )\n if url.path === \"/\"\n return \"\"\n else\n return url.path\n end\n end",
"def relative_directory; end",
"def getBaseURL\r\n\t\t \t\t\treturn @@baseURL+\"portal/\"+String(portalId)+\"/\";\r\n\t\t \t\tend",
"def find_base\n if contents and (found = tag(\"base\", {:href => /.*/}, contents))\n ensure_uri(found[:href])\n else\n extract_base(location)\n end\n end",
"def subdir\n if core_project? or 'profile' == proj_type\n return @local_path.parent.relative_path_from(@platform.local_path + (proj_type + 's'))\n else\n return @local_path.parent.relative_path_from(@platform.local_path + @platform.contrib_path + (proj_type + 's'))\n end\n end",
"def curr_srcdir\n \"#{srcdir_root()}/#{relpath()}\"\n end",
"def dir\n url.end_with?(\"/\") ? url : url_dir\n end",
"def base_path\n if debug\n \"/#{debug_prefix}/\"\n else\n \"/#{digest_prefix}/\"\n end\n end",
"def retrieve_dirs(_base, dir, dot_dirs); end",
"def current_dir; end",
"def base\n result = sphere.cache_path.join('chef')\n result.mkpath\n result\n end",
"def base_name\n File.basename @relative_name\n end",
"def chrb_repo_dir\n if defined? @chrb_repo_dir\n @chrb_repo_dir\n else\n superclass.respond_to?(:chrb_repo_dir) ? superclass.chrb_repo_dir : '.'\n end\n end",
"def dir\n Rails.root.join(ROOT, type, name).to_s\n end",
"def directory\r\n \t@directory.path\r\n end",
"def base\n @base = if doc\n href = doc.search('//head/base/@href')\n URI(href.to_s) unless href.nil? rescue nil\n end unless @base\n\n return nil if @base && @base.to_s().empty?\n @base\n end",
"def directory\n File.dirname @path\n end",
"def root_dir\n superblock.root_dir\n end",
"def base\n @base\n end",
"def get_root_directory\n return @@root_directory\n end",
"def get_root_directory\n return @@root_directory\n end",
"def normalisedDir(baseDir)\n return baseDir.end_with?(\"/\") ? baseDir : baseDir + \"/\"\n end",
"def dir\n self.a_dir.join '/'\n end"
] | [
"0.8489582",
"0.8058562",
"0.8003713",
"0.78825825",
"0.7850955",
"0.7819864",
"0.78078544",
"0.77831304",
"0.76998025",
"0.76998025",
"0.76998025",
"0.76998025",
"0.76998025",
"0.76998025",
"0.76998025",
"0.7691979",
"0.7611461",
"0.74767613",
"0.74043685",
"0.73923194",
"0.73861283",
"0.73525506",
"0.73440427",
"0.73110884",
"0.7291623",
"0.72590405",
"0.7251484",
"0.7251484",
"0.7251484",
"0.7251484",
"0.7251484",
"0.7251484",
"0.7251484",
"0.7251484",
"0.72508615",
"0.72508615",
"0.7232292",
"0.72011817",
"0.7168691",
"0.7099909",
"0.7002179",
"0.69846",
"0.69545263",
"0.6942991",
"0.6911184",
"0.6884024",
"0.68730116",
"0.68294513",
"0.68293965",
"0.6827371",
"0.6769415",
"0.67325354",
"0.6728145",
"0.6728145",
"0.6710036",
"0.66836417",
"0.6679562",
"0.6659595",
"0.663192",
"0.663192",
"0.66236746",
"0.6616283",
"0.65693456",
"0.65437424",
"0.6543491",
"0.6541935",
"0.65153795",
"0.6513891",
"0.6513529",
"0.6509751",
"0.6506258",
"0.64855504",
"0.6463864",
"0.6462977",
"0.6462977",
"0.646024",
"0.64540434",
"0.644907",
"0.64480466",
"0.64456874",
"0.6442133",
"0.6437086",
"0.64359903",
"0.6412531",
"0.6410563",
"0.64081836",
"0.63969505",
"0.6394112",
"0.6392416",
"0.6388984",
"0.6388674",
"0.63702816",
"0.63636106",
"0.63611054",
"0.6357769",
"0.6355527",
"0.6343487",
"0.6343487",
"0.63350254",
"0.6333092"
] | 0.7120885 | 39 |
Retrieve a file pattern | def file_pattern(name)
if name.to_s !~ FILE_PATTERN_NAME_REGEX
raise ArgumentError.new("A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }")
end
get_config_val(@file_patterns, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFilePattern(filePattern)\n return if filePattern.nil?\n File.split(filePattern).inject do |memo, obj| \n File.join(memo, obj.split(/\\./).join('*.'))\n end\nend",
"def path_string\n pattern\n end",
"def file_pattern( pattern )\n self.class_eval { @file_pattern = pattern }\n end",
"def glob pattern\n Dir[File.join(@originals,pattern)].collect do |f|\n File.basename(f)\n end\n end",
"def pattern\n @pattern\n end",
"def pattern\n @pattern ||= Pattern.patterns[pattern_name]\n end",
"def read_to(pattern); end",
"def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end",
"def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end",
"def compute_glob_pattern(file_spec)\n segments = file_spec.split(Repositext::Cli::FILE_SPEC_DELIMITER)\n r = ''\n if segments.all? { |e| e =~ BASE_DIR_NAME_REGEX || e =~ FILE_PATTERN_NAME_REGEX }\n # file_spec consists of named base_dir and/or file_pattern\n bd = segments.detect { |e| e =~ BASE_DIR_NAME_REGEX } # e.g., 'content_dir'\n fp = segments.detect { |e| e =~ FILE_PATTERN_NAME_REGEX } # e.g., 'at_files'\n r << base_dir(bd) if bd\n r << file_pattern(fp) if fp\n else\n # interpret file_spec as glob pattern, either an absolute path, or\n # a relative path, based on current working directory.\n # NOTE: this doesn't necessarily have to contain '*'. It could be the\n # path to a single file.\n if '/' == file_spec[0]\n # absolute path, use as is\n r = file_spec\n else\n # relative path, based on current working directory\n # Note: we could use just the file_spec since relative paths are\n # based on pwd by default. I just wanted to make the behavior obvious.\n r = File.expand_path(file_spec, Dir.pwd)\n end\n end\n r\n end",
"def input_files_pattern\n @args.options[:input_files_pattern]\n end",
"def pattern(default = '')\n return get(:pattern, default)\n end",
"def fnmatch(pattern, *args) File.fnmatch(pattern, @path, *args) end",
"def fnmatch(pattern, *args) File.fnmatch(pattern, path, *args) end",
"def pattern_match(file, pattern)\n case\n when pattern.is_a?(Regexp)\n return file.match(pattern)\n when pattern.is_a?(String)\n return File.fnmatch(pattern, file)\n when pattern.is_a?(Proc)\n return pattern.call(file)\n when pattern.is_a?(Rake::FileTask)\n return pattern.to_s.match(file)\n else\n raise \"Cannot interpret pattern #{pattern}\"\n end\n end",
"def fnmatch( pattern, *args ) File.fnmatch( pattern, self, *args ) end",
"def [](path, pattern)\n glob(path, pattern, 0)\n end",
"def pattern\n attributes.fetch(:pattern)\n end",
"def pattern\n attributes.fetch(:pattern)\n end",
"def pattern\n attributes.fetch(:pattern)\n end",
"def glob(pat, path='/')\n # FIXME : implement\n raise('not implemented')\n # FIXME: verify and update\n # FIXME: test\n #regex = /^#{pat.gsub('*','.*').gsub('?','.?')}$/ \n #find(path) { |fname| fname =~ regex }\n end",
"def glob(pattern = '**/*', **_opts)\n Enumerator.new do |y|\n walk(pattern) do |path, entry|\n y << file_info(path, entry) if File.fnmatch?(pattern, path, File::FNM_PATHNAME)\n end\n end\n end",
"def glob(pattern)\n root = self.root\n Pathname.glob(root.join(pattern)).map do |match|\n match.relative_path_from(root).to_s\n end\n end",
"def pattern_template\n pattern\n end",
"def pattern_template\n pattern\n end",
"def glob(pattern, flags = T.unsafe(nil)); end",
"def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend",
"def file_match(file)\n end",
"def match(pattern, flags = 0)\n\t\t\t\tpath = pattern.start_with?('/') ? full_path : relative_path\n\t\t\t\t\n\t\t\t\treturn File.fnmatch(pattern, path, flags)\n\t\t\tend",
"def get_file(line)\n line.match(/-w (.+) -p/)[1]\n end",
"def query\n dir, _, file = @pattern.gsub(/[_\\-\\*]+/, '').rpartition '/'\n dir.gsub(%r{/(\\w{,2})[^/]+}, '\\1') + # map 2 chars per folder\n file.gsub(/\\.\\w+/, '') # remove extension\n end",
"def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend",
"def find(pattern)\n patterns= [pattern].flatten\n contents=[]\n self.each_pair do |path, content|\n patterns.each do |pattern|\n contents << content if Content.path_match? path, pattern\n end\n end\n contents\n end",
"def pattern; end",
"def pattern; end",
"def pattern; end",
"def glob(pattern)\n Glob.new(@shell, pattern)\n end",
"def generate_pattern(pattern)\n plist.dict do\n append_single('begin', pattern.begin)\n append_dictionary('beginCaptures', pattern.begin_captures)\n append_dictionary('captures', pattern.captures)\n append_single('comment', pattern.comment)\n append_single('contentName', pattern.content_name)\n append_single('disabled', 1) if pattern.disabled\n append_single('end', pattern.end)\n append_dictionary('endCaptures', pattern.end_captures)\n append_single('include', pattern.include)\n append_single('match', pattern.match)\n append_single('name', pattern.name)\n append_array('patterns', pattern.patterns)\n end\n end",
"def pattern_template\n \"*\"\n end",
"def extract(pattern); end",
"def extract_annotations_from(file, pattern); end",
"def pattern_params\n params[:pattern]\n end",
"def match(pattern); end",
"def patterns; end",
"def find(*patterns)\n selection = nil\n patterns.each do |pattern|\n selection = Dir.glob(File.join(path, pattern)).first\n break if selection\n end\n FileObject[selection] if selection\n end",
"def search_file(pattern, file)\n node = ast_from_file(file)\n search node, pattern\n end",
"def pattern\n \"#{@gem}/spec{,/*/**}/*_spec.rb\"\n end",
"def get_file_list(path_pattern)\n return Dir[path_pattern].sort\n end",
"def glob(*pat, &blk)\n regexes = pat.flatten.map {|pat| Bun.convert_glob(pat) }\n enum = self.class.new(@collection) do |yielder|\n self.each do |fname|\n # TODO Refactor with any?\n matched = false\n regexes.each do |regex|\n if fname =~ regex\n matched = true\n break\n end\n end\n yielder << fname if matched\n end\n end\n if block_given?\n enum.each(&blk)\n else\n enum\n end\n end",
"def path_regex\n Regexp.new path_pattern, 'i'\n end",
"def file_pattern\n return 'US_OR_*.geojson'\n end",
"def filepath_pattern(filepaths)\n return \"\" if filepaths.nil?\n\n filepaths.map! { |path| '^' + path + '$' }\n filepaths.join('|')\n end",
"def dir(pattern, base=FOUNDATION_BOARD)\n Dir[File.join(base, pattern)].map {|name| File.basename name}\nend",
"def find_file_by_text (start_dir, file_mask=\"*.*\", text_pattern='')\n match_files = Dir[ File.join(start_dir.split(/\\\\/), \"**\", file_mask)]\n if match_files.length > 0\n file_path = nil\n match_files.each do |file|\n matching_text = File.read(file).include?(text_pattern) rescue false\n if matching_text\n file_path = file\n break\n end\n end\n p \"#{file_path ? 'First searching file is: '+file_path : 'No files found'}\"\n else\n \"No files with mask '#{file_mask}' in directory '#{start_dir}'\"\n end\n end",
"def file_patterns\n [@file_patterns].flatten.compact.uniq\n end",
"def match_against filename\n @regexp.match(filename)\n end",
"def grep_file(file_path, grep_pattern)\n logc(\"method: #{__method__}, params: #{file_path}, #{grep_pattern}\")\n\n # with File.open(file_path, 'r').each.grep(grep_pattern) possible invalid byte sequence in UTF-8 (ArgumentError)\n # so we use \"match\" to check if line match pattern and 'scrub' to skip bad encoding symbols\n res = []\n File.open(file_path, 'r').each {|line| res << line if line.scrub.match(grep_pattern)}\n return res\nend",
"def file_paths\n Dir.glob(@filepath_pattern).sort\n end",
"def glob=(pattern)\n @glob = pattern\n if pattern.kind_of?(Regexp)\n @pattern = pattern\n else\n @pattern = scan_string\n end\n end",
"def filter_files(pattern)\n regexp=Regexp.new(pattern || '.*')\n @filtered_files=@files.inject([]) do |matches,file| \n file_without_basepath=file[@basepath.length .. -1]\n matches << file if file_without_basepath=~regexp\n matches\n end\n @table.reloadData\n end",
"def glob(pattern)\n Dir.chdir(@output_dir) do\n Dir[pattern]\n end\n end",
"def find_files(pattern)\n Dir[File.join(folder, pattern, \"*.#{pattern}\")].sort{|f1, f2|\n File.basename(f1) <=> File.basename(f2)\n }.collect{|f|\n File.join(pattern, File.basename(f))\n }\n end",
"def files() = files_path.glob('**/*')",
"def file(glob)\n \"**/#{glob}\"\n end",
"def matching_file_regex\n file_regex ? file_regex : /\\.js$/\n end",
"def egrep(pattern)\n Dir['**/*'].\n find_all { |fn| FileTest.file?(fn) }.\n reject { |fn| File.basename(fn) =~ /^\\./ }.\n reject { |fn| fn =~ /^hosting\\// }.\n each do |fn|\n line_count = 0\n open(fn) do |f|\n while line = f.gets\n line_count += 1\n if line =~ pattern\n puts \"#{fn}:#{line_count}:#{line.strip}\"\n end\n end\n end\n end\nend",
"def pattern\n self.known_options.first\n end",
"def pattern\n self.known_options.first\n end",
"def get_local_files regexp\n Dir[File.join(dir, '*')].select do |path|\n name = File.basename path\n File.file?(path) and name =~ regexp\n end\n end",
"def file_pattern\n return 'US_CO_*.geojson'\n end",
"def match(glob, &block)\n yield @filename\n end",
"def glob_match(filenames, pattern)\n pattern = pattern.gsub(/[\\*\\?\\.]/, '*' => '.*', '.' => '\\.', '?' => '.')\n regex = Regexp.new(pattern)\n filenames.select do |filename|\n filename =~ regex\n end\nend",
"def pattern(value_=nil)\n if value_\n @pattern = value_\n else\n @pattern\n end\n end",
"def for(file)\n matching = @conversion.select { |m, _o| m.matches? file }\n\n return '' if matching.empty?\n\n matching.max_by { |(pathname_matcher, _oa)| pathname_matcher }[1]\n end",
"def capture_file(pattern, file)\n node = ast_from_file(file)\n capture node, pattern\n end",
"def select(*patterns)\n selection = []\n patterns.each do |pattern|\n selection.concat(Dir.glob(File.join(path, pattern))) \n end\n selection.map{ |s| FileObject[s] }\n end",
"def read_content(dir, magic_dir, matcher); end",
"def file\n if glob = file_map['vclog']\n Dir.glob(glob).first\n else\n Dir.glob(DEFAULT_GLOB).first\n end\n end",
"def find_file_matching_pattern(search_dirs, pattern)\n search_dirs = [search_dirs] unless search_dirs.is_a?(Array)\n\n search_dirs.each do |d|\n matches = Dir.glob(File.join(d, pattern))\n return matches.first if matches.size > 0\n end\n return nil\n end",
"def patterns_for_file( file )\n Hash(config_file(file)[:patterns]).keys + \\\n Hash(defaults[:patterns]).keys\n end",
"def glob; end",
"def read patterns\n Dir[*patterns].uniq.map do |f|\n filename = File.join(Dir.pwd, f)\n\n @files ||= []; @files << filename\n STDERR.puts filename\n\n case File.extname(filename)\n when '.erb'\n Dir.chdir File.dirname(filename) do\n ERB.new(File.read(File.basename(filename))).result(binding)\n end\n else\n File.read filename\n end\n end.join(\"\\n\")\nend",
"def glob(pattern, flags: GLOB_OPERATION_FLAGS)\n @sftp.dir.glob(@path.to_s, pattern, flags) { |entry| yield entry.name }\n end",
"def glob(pattern = '**/*', **_opts)\n Enumerator.new do |acc|\n walk(pattern, with_stat: true) {|info| acc << info }\n end\n end",
"def create_source_files(pattern)\n source_files = []\n if pattern[:cn]\n names = pattern[:cn].scan(/(^[a-zA-Z]*)[^a-zA-Z]*([a-zA-Z]*)/).flatten\n names[0] = '*' if names[0].empty?\n names[1] = '*' if names[1].empty?\n names.permutation do |names|\n file = File.join(URL, \"#{names.join('_').downcase}.contact\")\n Dir.glob(file).each { |file| source_files << file }\n end\n elsif pattern[:sn] or pattern[:gn]\n sn = pattern[:sn] ? pattern[:sn].strip.downcase : '*'\n gn = pattern[:gn] ? pattern[:gn].strip.downcase : '*'\n Dir.glob(File.join(URL, \"#{gn}_#{sn}.contact\")).each do |file|\n source_files << file\n end\n else\n Dir.glob(File.join(URL, \"*_*.contact\")).each do |file|\n source_files << file\n end\n end\n source_files\n end",
"def ruby_grep(filename, pattern)\n regexp = Regexp.new(pattern)\n File.open(filename, 'r') do |file|\n file.each_line {|line| puts line if regexp =~ line}\n end\nend",
"def pattern2regex(pattern); end",
"def occurGrep(pattern, filename)\n\tregexp = Regexp.new(pattern)\n\tFile.foreach(filename).with_index { |line, line_num| \n\t\tputs \"#{line_num}: #{line}\" if regexp =~ line }\nend",
"def pattern_names\n # This removes the path and extensions\n patterns.map { |pat| pat.name.gsub(/.*[\\\\\\/]/, '').gsub(/\\..*/, '') }\n end",
"def ls(pattern='**/*', _opts={})\n Enumerator.new do |y|\n @files.each_key do |key|\n y << key if File.fnmatch?(pattern, key, File::FNM_PATHNAME)\n end\n end\n end",
"def file_glob\n if file_types.nil?\n '*'\n else\n \"*{#{file_types.join(',')}}\"\n end\n end",
"def glob(path, pattern, flags=0)\n flags |= ::File::FNM_PATHNAME\n path = path.chop if path[-1,1] == \"/\"\n\n results = [] unless block_given?\n queue = entries(path).reject { |e| e.name == \".\" || e.name == \"..\" }\n while queue.any?\n entry = queue.shift\n\n if entry.directory? && !%w(. ..).include?(::File.basename(entry.name))\n queue += entries(\"#{path}/#{entry.name}\").map do |e|\n e.name.replace(\"#{entry.name}/#{e.name}\")\n e\n end\n end\n\n if ::File.fnmatch(pattern, entry.name, flags)\n if block_given?\n yield entry\n else\n results << entry\n end\n end\n end\n\n return results unless block_given?\n end",
"def pattern\n Regexp.union(pattern_classifiers.map(&:pattern))\n end",
"def load_pattern(pattern_name, pattern_group = \"default\", parent_binding = nil)\n load_from_file_in_template(pattern_name, parent_binding, pattern_group, :pattern)\n end",
"def load_pattern(pattern_name, pattern_group = \"default\", parent_binding = nil)\n load_from_file_in_template(pattern_name, parent_binding, pattern_group, :pattern)\n end",
"def find_files dir = test_dir\n glob file_pattern(dir)\n end",
"def consume_pattern(pattern)\n m = @stream.match pattern\n return if m.nil?\n\n debug \"Consuming n=#{m.end(0)} chars after matching #{m[0]} from #{@stream}...\", :verbose\n consume m.end(0)\n m[0]\n end",
"def paths\n f = File.open(@path)\n f.grep(FILE_NAME_PATTERN) { $1 }\n end",
"def pattern\n segs = @tags.map { |tagged_segment| build_segment(tagged_segment) }\n segs.last.gsub!(/\\.$/, '')\n segs.unshift \"^\"\n segs.push \"\\\\.?$\"\n Regexp.new(segs.join)\n end",
"def find_apf( path_and_file = self.file_name_and_contents.path_and_file)\n match_apf = []\n regexp = /^t([^ \\#]+)( *$| )/\n File_name_and_contents.new( path_and_file ).contents.each do |line|\n if line.match(regexp) != nil\n if line.match(regexp)[1] != nil \n match_apf << ( self.file_name_and_contents.path_and_file.sub(/\\/.+/, '') + '/' + line.match(regexp)[1].chomp + '.apf' ) \n end\n end\n end\n match_apf\n end"
] | [
"0.719839",
"0.7163418",
"0.7132732",
"0.69784707",
"0.6878548",
"0.6826527",
"0.68226665",
"0.6787364",
"0.6787364",
"0.674601",
"0.66648155",
"0.6624798",
"0.6620429",
"0.66068107",
"0.6529265",
"0.6515542",
"0.6511495",
"0.6439983",
"0.6439983",
"0.6439983",
"0.6415678",
"0.6402411",
"0.63884014",
"0.63450116",
"0.63450116",
"0.63384384",
"0.63340724",
"0.632745",
"0.62738246",
"0.6262061",
"0.62510395",
"0.6220078",
"0.62043065",
"0.6186563",
"0.6186563",
"0.6186563",
"0.6176069",
"0.6143933",
"0.61357564",
"0.6093655",
"0.606712",
"0.6049497",
"0.6046394",
"0.6030777",
"0.6027863",
"0.60243887",
"0.60066396",
"0.60033363",
"0.59969693",
"0.5992673",
"0.5992582",
"0.5986246",
"0.5981112",
"0.598034",
"0.5966358",
"0.5959184",
"0.59573865",
"0.5956828",
"0.5937045",
"0.5924541",
"0.5918088",
"0.59133404",
"0.5907327",
"0.58984673",
"0.5890101",
"0.58795047",
"0.5866514",
"0.5866514",
"0.5864897",
"0.58596045",
"0.5856051",
"0.5850381",
"0.5843793",
"0.5843182",
"0.5826832",
"0.58255506",
"0.5805691",
"0.5795431",
"0.57895803",
"0.57834655",
"0.5772769",
"0.57644594",
"0.57586855",
"0.5750643",
"0.5747125",
"0.57383955",
"0.5733725",
"0.57276016",
"0.5723541",
"0.57170135",
"0.5716563",
"0.57111496",
"0.5703402",
"0.5681236",
"0.5681236",
"0.56725687",
"0.566992",
"0.56583947",
"0.56578153",
"0.5653584"
] | 0.70174617 | 3 |
Retrieve a kramdown converter method | def kramdown_converter_method(name)
get_config_val(@kramdown_converter_methods, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kramdown_conversion_method_name\n :to_kramdown_repositext\n end",
"def add_kramdown_converter_method(name, method_name)\n @kramdown_converter_methods[name.to_sym] = method_name.to_sym\n end",
"def html_converter_class\n ::Kramdown::Converter::Html\n end",
"def converter\n end",
"def converter; end",
"def converter\n\n end",
"def get_converter\n eval(\"RedmineCharts::#{get_type.to_s.camelize}DataConverter\")\n end",
"def __convert(key); end",
"def toeuc; Kconv.toeuc(self) end",
"def genability_method_name_converter(method_name)\n method_name.to_s.gsub(/(?:^|_)(.)/){ $1.upcase }.gsub(/^[A-Z]/){ $&.downcase }.to_sym\n end",
"def converter\n @converter ||= self.site.converters.find { |c| c.matches(self.ext) }\n end",
"def key_converter(key)\n if Atoa::Keyboard_Type\n case key\n when A then return 'A'\n when B then return 'B'\n when C then return 'C'\n when X then return 'X'\n when Y then return 'Y'\n when Z then return 'Z'\n when L then return 'R'\n when R then return 'L'\n end\n else\n case key\n when A then return 'Z'\n when B then return 'X'\n when C then return 'C'\n when X then return 'D'\n when Y then return 'S'\n when Z then return 'A'\n when L then return 'Q'\n when R then return 'W'\n end\n end\n case key\n when UP then return '↑'\n when DOWN then return '↓'\n when LEFT then return '←'\n when RIGHT then return '→'\n end\n end",
"def to_kilogram(**options) = convert_to('kilogram', **options)",
"def converters; end",
"def converters; end",
"def converters; end",
"def convert\n end",
"def convert\n end",
"def kramdown_parser(name)\n get_config_val(@kramdown_parsers, name)\n end",
"def toeuc(str)\n ::NKF::nkf('-em', str)\n end",
"def kcode() end",
"def extract_code_language(attr); end",
"def get_processor\n case @config[\"markdown\"].downcase\n when \"kramdown\" then KramdownParser.new(@config)\n else\n custom_processor\n end\n end",
"def extract_code_language!(attr); end",
"def decode\n transform :decode\n end",
"def parse_kramdown(content)\n ::Kramdown::Document.new content, :input => 'QuickStartParser' \n end",
"def convert\n match('term', 'name')\n\n # API-specific parameters.\n equal('key', 'open_duka_api_key')\n\n output\n end",
"def find_converter_instance(klass); end",
"def word2\n return ($en_cz == 'Y') ? @czech : @english\n end",
"def add_kramdown_parser(name, class_name)\n @kramdown_parsers[name.to_sym] = Object.const_get(class_name)\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def method2str()\n \"Hidden Markov Model\" \n end",
"def converters\n renderer.converters\n end",
"def to_english(string)\nend",
"def html5_converter\n converter.converters[-1]\n end",
"def normalizer; end",
"def val(name)\n Converter.new(name)\n end",
"def __convert(key)\n case key\n when Symbol then key.to_s\n when String then key.to_sym\n else key\n end\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def converters\n @converters.map do |converter|\n name = Converters.rassoc(converter)\n name ? name.first : converter\n end\n end",
"def to_french(string)\nend",
"def processed_content\n self.letters.downcase\nend",
"def k_conversion!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 31 )\n\n\n\n type = K_CONVERSION\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 377:4: ( 'STRING' | 'INT' | 'FLOAT' | 'VAR' | 'TIME' | 'DATE' )\n # at line 377:4: ( 'STRING' | 'INT' | 'FLOAT' | 'VAR' | 'TIME' | 'DATE' )\n alt_6 = 6\n case look_6 = @input.peek( 1 )\n when 0x53 then alt_6 = 1\n when 0x49 then alt_6 = 2\n when 0x46 then alt_6 = 3\n when 0x56 then alt_6 = 4\n when 0x54 then alt_6 = 5\n when 0x44 then alt_6 = 6\n else\n raise NoViableAlternative( \"\", 6, 0 )\n\n end\n case alt_6\n when 1\n # at line 377:5: 'STRING'\n match( \"STRING\" )\n\n\n when 2\n # at line 377:14: 'INT'\n match( \"INT\" )\n\n\n when 3\n # at line 377:20: 'FLOAT'\n match( \"FLOAT\" )\n\n\n when 4\n # at line 377:28: 'VAR'\n match( \"VAR\" )\n\n\n when 5\n # at line 377:34: 'TIME'\n match( \"TIME\" )\n\n\n when 6\n # at line 377:41: 'DATE'\n match( \"DATE\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 31 )\n\n\n end",
"def convert!; end",
"def to_color(letter)\n case letter\n when \"r\"\n return :red\n when \"g\"\n return :green\n when \"b\"\n return :blue\n when \"c\"\n return :cyan\n when \"m\"\n return :magenta\n when \"y\"\n return :yellow\n else\n return letter\n end\nend",
"def processed_content\n self.to_s.letters.downcase\n end",
"def tuc(arg)\n h = Hash.[](\".\"=>\"་\", \"/\"=>\"།\", \";\"=>\"༔\", \"\"=>\"\",\n \"ka\"=>\"ཀ\", \"kha\"=>\"ཁ\", \"ga\"=>\"ག\", \"nga\"=>\"ང\",\n \"ca\"=>\"ཅ\", \"cha\"=>\"ཆ\", \"ja\"=>\"ཇ\", \"nya\"=>\"ཉ\",\n \"ta\"=>\"ཏ\", \"tha\"=>\"ཐ\", \"da\"=>\"ད\", \"na\"=>\"ན\",\n \"pa\"=>\"པ\", \"pha\"=>\"ཕ\", \"ba\"=>\"བ\", \"ma\"=>\"མ\",\n \"tsa\"=>\"ཙ\", \"tsha\"=>\"ཚ\", \"dza\"=>\"ཛ\", \"wa\"=>\"ཝ\",\n \"zha\"=>\"ཞ\", \"za\"=>\"ཟ\", \"'a\"=>\"འ\", \"ya\"=>\"ཡ\",\n \"ra\"=>\"ར\", \"la\"=>\"ལ\", \"sha\"=>\"ཤ\", \"sa\"=>\"ས\",\n \"ha\"=>\"ཧ\", \"a\"=>\"ཨ\",\n # numbers !!! better include number_generator\n \"0\"=>\"༠\", \"1\"=>\"༡\", \"2\"=>\"༢\", \"3\"=>\"༣\",\n \"4\"=>\"༤\", \"5\"=>\"༥\", \"6\"=>\"༦\", \"7\"=>\"༧\",\n \"8\"=>\"༨\", \"9\"=>\"༩\",\n # vowel signs\n \".e\"=>\"ེ\", \".i\"=>\"ི\", \".o\"=>\"ོ\", \".u\"=>\"ུ\",\n # double vowel signs\n \"E\" => \"ཻ\", \"O\" => \"ཽ\",\n # subscribed characters\n \"x_ka\"=>\"ྐ\", \"x_kha\"=>\"ྑ\", \"x_ga\"=>\"ྒ\", \"x_nga\"=>\"ྔ\",\n \"x_ca\"=>\"ྕ\", \"x_cha\"=>\"ྖ\", \"x_ja\"=>\"ྗ\", \"x_nya\"=>\"ྙ\",\n \"x_ta\"=>\"ྟ\", \"x_tha\"=>\"ྐ\", \"x_da\"=>\"ྡ\", \"x_na\"=>\"ྣ\",\n \"x_pa\"=>\"ྤ\", \"x_pha\"=>\"ྥ\", \"x_ba\"=>\"ྦ\", \"x_ma\"=>\"ྨ\",\n \"x_tsa\"=>\"ྩ\", \"x_tsha\"=>\"ྪ\", \"x_dza\"=>\"ྫ\", \"x_wa\"=>\"ྭ\",\n \"x_zha\"=>\"ྮ\", \"x_za\"=>\"ྯ\", \"x_'a\"=>\"ཱ\", \"x_ya\"=>\"ྱ\",\n \"x_ra\"=>\"ྲ\", \"x_la\"=>\"ླ\", \"x_sha\"=>\"ྴ\", \"x_sa\"=>\"ྶ\",\n \"x_ha\"=>\"ྷ\", \"x_a\"=>\"ྸ\",\n # superscribed character\n \"ra_x\"=>\"ར\",\n # revered letters\n \"Ta\"=>\"ཊ\", \"Tha\" => \"ཋ\", \"Da\" => \"ཌ\", \"Na\" => \"ཎ\",\n \"Sha\" => \"ཥ\")\n\n result = h[arg]\n if result != nil\n erg = result\n else\n erg = \"\"\n end\n return erg\n end",
"def parse_kramdown(file)\n ::Kramdown::Document.new File.readlines(file).join, :input => 'QuickStartParser' \n end",
"def camelizer\n OliveBranch::Transformations.method(:camelize)\n end",
"def camelize(term); end",
"def he_decode(text); self.class.he_decode text; end",
"def to_gram(**options) = convert_to('gram', **options)",
"def decode; end",
"def decode; end",
"def tojis; Kconv.tojis(self) end",
"def get_word\r\n return_word\r\n end",
"def key_lang\n if @is_result\n @lang[0, @lang.length - RESULT_SUFFIX_LENGTH]\n else\n @lang\n end\n end",
"def rubyify(sentence)\r\n\r\nend",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def converters=(_arg0); end",
"def call\n result = Kramdown::Document.new(@text, self.class.options.deep_merge(context[:kramdown_options] || {})).to_html\n result.rstrip!\n result\n end",
"def convert_key(key); end",
"def convert_key(key); end",
"def convert_key(key); end",
"def result\n 'Paper'\n end",
"def processChar(c)\n if @target == 'utf8'\n return LATEX_TO_UTF8[c]\n end\n if @target == 'html'\n return LATEX_TO_HTML_ENTITIES[c]\n end\n if @target == \"mc\"\n return LATEX_TO_MACRONS_CHARACTERS[c]\n end\n end",
"def gluck_french; end",
"def hecho_en\n 'china'\n end",
"def output_word\n end",
"def to_class_name\n self.to_method_name.gsub(/\\/(.?)/) { \"#{$1.upcase}\" }.gsub(/(?:^|_)(.)/) { $1.upcase }\n end",
"def transformation\n end",
"def iconv() end",
"def disemvowel\nend",
"def [](name)\n conv_name = name.to_s.downcase.to_sym\n conversions.fetch(conv_name) { raise_unsupported_error(conv_name) }\n end",
"def to_sym() end",
"def to_sym() end",
"def to_sym() end",
"def getKey; argSetTextual.to_sym end",
"def to_proc\n to_sym.to_proc\n end",
"def return_result(res, method)\n unless method == :lexer_name_for || method == :highlight || method == :css\n res = Yajl.load(res, :symbolize_keys => true)\n end\n res.strip\n end",
"def transform_method(transform = nil)\n @transform ||= transform || :\"to_#{@format}\"\n @transform\n end",
"def attr_converter(hash)\n jiak.data.attr_converter(hash)\n end",
"def to_english\n name\n end",
"def num_to_word(number)\n\n\n\n\n# Refactored Solution\n\n\n\n\n\n\n# Reflection",
"def to_key( t )\n t.to_s.downcase\n end",
"def get_alpha\n@alphabet\nend",
"def to_method_sym(name)\n name.to_s.pluralize.underscore.to_sym\n end",
"def method_missing(meth, *args, &blk)\n if meth.to_s =~ /^from_([a-z]+)_to_([a-z]+)$/\n from, to = $1, $2\n return translate(args.first, from, to)\n end\n super\n end",
"def transform string\n result = nil\n syntax.each_pair { |k,func| result = instance_exec(string, &func) if string.match(k) }\n return result\n end",
"def çς\n \"Magnitude\"\n end"
] | [
"0.7986022",
"0.67469233",
"0.6563834",
"0.6379176",
"0.6267418",
"0.6179751",
"0.5775949",
"0.5773782",
"0.575055",
"0.5741612",
"0.5649745",
"0.55886316",
"0.55401486",
"0.5426026",
"0.5426026",
"0.5426026",
"0.53737456",
"0.53737456",
"0.533407",
"0.53124577",
"0.5285807",
"0.52667844",
"0.52579856",
"0.52562255",
"0.5248223",
"0.5246795",
"0.523348",
"0.5223832",
"0.52176607",
"0.5216273",
"0.52128464",
"0.52066255",
"0.5193727",
"0.51730394",
"0.51399726",
"0.51337826",
"0.5128544",
"0.5100521",
"0.50998706",
"0.50998706",
"0.50998706",
"0.50998706",
"0.50998706",
"0.50998706",
"0.50998706",
"0.50998706",
"0.5097232",
"0.5091375",
"0.50886834",
"0.5071579",
"0.50633657",
"0.50352794",
"0.5031848",
"0.50281703",
"0.5018403",
"0.50124043",
"0.50084454",
"0.49903584",
"0.49766958",
"0.4969152",
"0.4969152",
"0.4960073",
"0.49518937",
"0.49488783",
"0.49466074",
"0.4945523",
"0.4945523",
"0.4945523",
"0.4945523",
"0.49333954",
"0.492762",
"0.49206114",
"0.49206114",
"0.49206114",
"0.49108824",
"0.49051413",
"0.4903127",
"0.48994052",
"0.48964542",
"0.4893892",
"0.48865756",
"0.48828968",
"0.4879796",
"0.48787352",
"0.48768085",
"0.48768085",
"0.48768085",
"0.48704493",
"0.48632702",
"0.48596182",
"0.4856497",
"0.48550454",
"0.48467734",
"0.48458144",
"0.48455927",
"0.483441",
"0.4833728",
"0.48285794",
"0.4828116",
"0.48217487"
] | 0.7484731 | 1 |
Retrieve a kramdown parser | def kramdown_parser(name)
get_config_val(@kramdown_parsers, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_kramdown(content)\n ::Kramdown::Document.new content, :input => 'QuickStartParser' \n end",
"def parse_kramdown(file)\n ::Kramdown::Document.new File.readlines(file).join, :input => 'QuickStartParser' \n end",
"def add_kramdown_parser(name, class_name)\n @kramdown_parsers[name.to_sym] = Object.const_get(class_name)\n end",
"def call\n result = Kramdown::Document.new(@text, self.class.options.deep_merge(context[:kramdown_options] || {})).to_html\n result.rstrip!\n result\n end",
"def parser\n attributes.fetch(:parser)\n end",
"def html_parser; end",
"def pluggable_parser; end",
"def parser; end",
"def parser; end",
"def parser; end",
"def parser; end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def parse(html)\n Parser.new(self.lex(html)).parse()\n end",
"def get_processor\n case @config[\"markdown\"].downcase\n when \"kramdown\" then KramdownParser.new(@config)\n else\n custom_processor\n end\n end",
"def parser\n Parser.new(self, :mode=>mode)\n end",
"def parse\n kramdown_doc = parse_to_kramdown_document\n\n # Prepare return value\n kramdown_string = kramdown_doc.send(kramdown_conversion_method_name)\n json_state = JSON::State.new(array_nl: \"\\n\") # to format json output\n {\n 'folio.at' => kramdown_string,\n 'folio.data.json' => @data_output.to_json(json_state) + \"\\n\",\n 'folio.deleted_text.json' => @deleted_text_output.to_json(json_state) + \"\\n\",\n 'folio.notes.json' => @notes_output.to_json(json_state) + \"\\n\",\n 'folio.warnings.json' => @warnings_output.to_json(json_state) + \"\\n\",\n }\n end",
"def get_parse(s);end",
"def parse_to_kramdown_document\n # Initialize processing i_vars\n @data_output = {}\n @deleted_text_output = []\n @notes_output = []\n @warnings_output = []\n # Parse\n @ke_context = Folio::KeContext.new(\n { 'root' => Kramdown::ElementRt.new(:root, nil, nil, :encoding => 'UTF-8') },\n self\n )\n @xml_document = Nokogiri::XML(@folio_xml) # Can't do { |config| config.noblanks }, it breaks parsing\n\n # Transform the XML tree\n @xml_document.css('record').each do |record_xn|\n process_xml_node(record_xn)\n end\n kramdown_doc = Kramdown::Document.new('', @kramdown_options)\n kramdown_doc.root = @ke_context.get('root', nil)\n post_process_kramdown_tree!(kramdown_doc.root)\n kramdown_doc\n end",
"def parser\n if !defined?(@parser) || !@parser\n DEFAULT_PARSER\n else\n @parser || DEFAULT_PARSER\n end\n end",
"def parser\n dsl.parser\n end",
"def parse!\n md = File.read(filename)\n doc = Kramdown::Document.new(md, input: 'GFM')\n\n # extract toc\n toc_start, toc_end = Danger::Toc::Extractor.convert(doc.root).first\n @has_toc = toc_start && toc_end\n @toc = md.split(\"\\n\")[toc_start, toc_end - toc_start - 1].reject(&:empty?) if @has_toc\n\n # construct toc\n @headers = Danger::Toc::Constructors.current.convert(doc.root).first\n end",
"def parse\n case node.name\n when 'document'\n Plex::Parser.new(parent, node.root).parse\n when 'MediaContainer'\n parse_media_container\n when 'Video'\n parse_video\n when 'Directory'\n parse_directory\n when 'text'\n nil\n else\n end\n end",
"def parsed_tree; end",
"def parse text\n raise \"No parser defined for #{self.class}\"\n end",
"def parse(text); end",
"def html_converter_class\n ::Kramdown::Converter::Html\n end",
"def find_parser(text)\n text = text.strip.downcase\n return nil if text.empty?\n parsers.find { |klass| klass.matches?(text) }\n end",
"def parser\n @parser ||= parser_klass.new(job_folder)\n end",
"def inner_parse text # :nodoc:\n parser = clone\n\n parser.setup_parser text, @debug\n\n parser.peg_parse\n\n doc = parser.result\n\n doc.accept @formatter\n\n doc.parts\n end",
"def parse(doc)\n parser = parser_class.new\n parser.run(doc)\n end",
"def parsed; end",
"def parsed; end",
"def instance\n @instance ||= LanguageParser.new\n end",
"def parser( &block )\n nested_class( 'Parser', Yacl::Define::Cli::Parser, &block )\n end",
"def get_tk\n tk = nil\n\n if @tokens.empty? then\n if @scanner_point >= @scanner.size\n return nil\n else\n tk = @scanner[@scanner_point]\n @scanner_point += 1\n @read.push tk[:text]\n end\n else\n @read.push @unget_read.shift\n tk = @tokens.shift\n end\n\n if tk == nil || :on___end__ == tk[:kind]\n tk = nil\n end\n\n return nil unless tk\n\n # inform any listeners of our shiny new token\n @token_listeners.each do |obj|\n obj.add_token(tk)\n end if @token_listeners\n\n tk\n end",
"def parse!(markup)\n doc(markup)\n end",
"def parse text, format = 'rdoc'\n return text if RDoc::Markup::Document === text\n return text.parse if RDoc::Comment === text\n\n text = normalize_comment text # TODO remove, should not be necessary\n\n return RDoc::Markup::Document.new if text =~ /\\A\\n*\\z/\n\n MARKUP_FORMAT[format].parse text\n end",
"def render\n erb_page = ERB.new(content).result(binding)\n Kramdown::Document.new(erb_page).to_html.html_safe\n end",
"def parser(value = nil)\n setget(:@parser, value)\n end",
"def parse\n end",
"def parse(path_to_file)\n file = self.class.get_file(path_to_file)\n\n parser = Parser.new(file)\n @title = parser.get_title\n @authors = parser.get_authors\n @abstract = parser.get_abstract\n @content = parser.get_content\n @references = parser.get_references.map do |r|\n Reference.new(r[:html_id], r[:entry])\n end\n\n # TODO remove after we've switched to online\n file.close\n end",
"def parse_paragraph; end",
"def html_parser=(_arg0); end",
"def html_parser=(_arg0); end",
"def parse(program)\n return read_the_tokens(tokenize(program))\nend",
"def parse(source, width: TTY::Screen.width, theme: THEME, indent: 2,\n colors: TTY::Color.mode, symbols: {}, **doc_opts)\n convert_options = { width: width, indent: indent, theme: theme,\n colors: colors, symbols: build_symbols(symbols),\n input: \"KramdownExt\" }\n doc = Kramdown::Document.new(source, convert_options.merge(doc_opts))\n Converter.convert(doc.root, doc.options).join\n end",
"def initialize parser\n @parser = parser\n end",
"def parse(content)\n TOMLP::Parser.new(content).parse\n end",
"def parse; end",
"def parse; end",
"def parse; end",
"def parse(klass)\n Parser.new(self, klass).result\n end",
"def parser(dst_encoding = 'utf-8', src_encoding = nil)\r\n return @cache[:parser] unless @cache[:parser].nil?\r\n\r\n if dst_encoding\r\n # Converts the page's body to UTF-8.\r\n return @cache[:parser] = Nokogiri::HTML(body.encode(dst_encoding, src_encoding))\r\n\r\n elsif (@cache[:parser] = page.try(:parser))\r\n # If no source encoding is given, does no conversion.\r\n return @cache[:parser]\r\n end\r\n\r\n '' # Default return.\r\n end",
"def parser\n @parser ||= Sawtooth::Parser.new(:rules => self.rules)\n end",
"def to_parser\n parser = Racc::GrammarFileParser.new\n result = parser.parse to_yacc\n nfa = Racc::States.new(result.grammar).nfa\n parsegen = Racc::ParserFileGenerator.new nfa.dfa, result.params\n parser_src = parsegen.generate_parser\n\n if $DEBUG\n puts \"############# PARSED GRAMMAR\"\n puts parser_src\n puts \"############# END PARSED GRAMMAR\"\n end\n\n Module.new { class_eval parser_src }.const_get('GeneratedGrammar')\n end",
"def description\n parser.description\n end",
"def get_parse(sentence)\n return [[], nil] if sentence.nil? || sentence.strip.empty?\n sentence = sentence.strip\n\n response = @enju.get :params => {:sentence=>sentence, :format=>'conll'}\n case response.code\n when 200 # 200 means success\n raise EnjuAccess::EnjuError, \"Empty input.\" if response.body =~/^Empty line/\n raise EnjuAccess::EnjuError, 'Enju CGI server returns html instead of tsv' if response.headers[:content_type] === 'text/html'\n\n tokens = []\n\n # response is a parsing result in CONLL format.\n response.body.split(/\\r?\\n/).each_with_index do |t, i| # for each token analysis\n dat = t.split(/\\t/, 7)\n token = Hash.new\n token[:idx] = i - 1 # use 0-oriented index\n token[:lex] = dat[1].force_encoding('UTF-8')\n token[:base] = dat[2]\n token[:pos] = dat[3]\n token[:cat] = dat[4]\n token[:type] = dat[5]\n token[:args] = dat[6].split.collect{|a| type, ref = a.split(':'); [type, ref.to_i - 1]} if dat[6]\n tokens << token # '<<' is push operation\n end\n\n root = tokens.shift[:args][0][1]\n\n # get span offsets\n i = 0\n tokens.each do |t|\n i += 1 until sentence[i] !~ /[ \\t\\n]/\n t[:beg] = i\n t[:end] = i + t[:lex].length\n i = t[:end]\n end\n\n [tokens, root]\n else\n raise EnjuAccess::EnjuError, \"Enju CGI server dose not respond.\"\n end\n end",
"def parse(tags); end",
"def build_parser( descriptor, file = nil )\n return RCC::Scanner::Interpreter::Parser.new( @parser_plan, open_source(descriptor, file) )\n end",
"def build_parser( descriptor, file = nil )\n return RCC::Scanner::Interpreter::Parser.new( @parser_plan, open_source(descriptor, file) )\n end",
"def parsed_description\n @parsed_description ||= Nokogiri::HTML(description) \n end",
"def parsed\n return @parsed if instance_variable_defined? :@parsed\n\n if source =~ /^(---\\s*\\n.*?\\n?)^(---\\s*$\\n?)/m\n { metadata: YAML.load($1), content: $' }\n else\n { metadata: {}, content: source }\n end\n end",
"def markdown( text )\n Kramdown::Document.new( text ).to_html\n end",
"def parse(doc)\n return nil if (! PlanR::Application::JRuby.running?) \n begin\n h = tika_parse(doc.contents)\n\n pdoc = PlanR::ParsedDocument.new(name, doc)\n pdoc.add_text_block (h[:content] || '')\n pdoc.properties[:language] = h[:language]\n (h[:metadata] || {}).each { |k,v| pdoc.properties[k] = v }\n pdoc\n end\n end",
"def parse(eml:, options: nil, callback: nil)\n # sub_data = eml.gsub!(/\\r\\n?/, \"\")\n lines = eml\n # lines = File.readlines('sample.eml')\n result = {}\n parse_recursively(lines, 0, result, options)\n\n result\n rescue StandardError => e\n print e\n ensure\n print 'Done !'\n end",
"def parse_tag_to_tree(html_str)\n node = Struct.new(:type, :classes, :id, :name, :text_content, :children, :parents)\n parser = node.new\n parser.type = html_str.scan(/<[a-z0-9]+/)[0][1..-1] if html_str[0] != \" \"\n parser.classes = html_str.scan(/class='(.*?)'/).join.split(\" \")\n parser.id = html_str.scan(/id='(.*?)'/).join\n parser.name = html_str.scan(/name='(.*?)'/).join\n parser.children = []\n parser.parents = nil\n parser\nend",
"def parse\n @parsed\n end",
"def has_parser?(name); end",
"def parse_markup\n @html = PARSER.parse(@markup, :base_heading_level => 1)\n end",
"def parser\n return nil if self.evaluation_file.nil?\n VivoParser.new(self.evaluation_file.path)\n end",
"def get_tag\n puts profile_parser(options.pattern, 0).last\n end",
"def parsed\n @parsed ||= Nokogiri::HTML(@document.to_s)\n end",
"def parsed_resume\n build_resume('ParsedDocument')\n end",
"def parse text\n return text if RDoc::Markup::Document === text\n\n text = normalize_comment text\n\n return RDoc::Markup::Document.new if text =~ /\\A\\n*\\z/\n\n RDoc::Markup::Parser.parse text\n rescue RDoc::Markup::Parser::Error => e\n $stderr.puts <<-EOF\nWhile parsing markup, RDoc encountered a #{e.class}:\n\n#{e}\n\\tfrom #{e.backtrace.join \"\\n\\tfrom \"}\n\n---8<---\n#{text}\n---8<---\n\nRDoc #{RDoc::VERSION}\n\nRuby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} #{RUBY_RELEASE_DATE}\n\nPlease file a bug report with the above information at:\n\nhttp://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse\n\n EOF\n raise\n end",
"def parser(name = T.unsafe(nil)); end",
"def parser_for_version(version)\n require \"parser/#{version}\"\n Parser.const_get version.capitalize\n end",
"def to_html(content)\n case @parser\n when :kramdown, 'kramdown'\n require 'kramdown'\n Kramdown::Document.new(content).to_html\n when :redcarpet, 'redcarpet'\n require 'redcarpet'\n markdown = Redcarpet::Markdown.new(\n Redcarpet::Render::HTML,\n smart: true,\n no_intra_emphasis: true,\n fenced_code_blocks: true,\n autolink: true,\n tables: true,\n with_toc_data: true\n )\n\n # add smartypants support\n Redcarpet::Render::SmartyPants.render markdown.render(content)\n when :rdiscount, 'rdiscount'\n require 'rdiscount'\n RDiscount.new(content).to_html\n when :gfm, :github, :github_markdown, 'gfm', 'github_markdown'\n require 'github/markdown'\n GitHub::Markdown.render(content)\n end\n end",
"def parser_params\n params[:parser]\n end",
"def parse(text)\n text = pre_proccess(text)\n text = pre_normalize(text)\n puts text.inspect if Chronic.debug\n\n tokens = Tokenizer::tokenize(' ' + text + ' ')\n tag(tokens, options)\n\n puts \"+#{'-' * 51}\\n| #{tokens}\\n+#{'-' * 51}\" if Chronic.debug\n\n token_group = TokenGroup.new(tokens, definitions(options), @now, options)\n span = token_group.to_span\n\n guess(span, options[:guess]) if span\n end",
"def parsed\n raise NotImplementedError\n end",
"def test_it_can_get_instance_of_parser\n parser = Rubasteme.parser\n refute_nil parser\n end",
"def configure_parser\n @parsers = {}\n (@block_parsers + @span_parsers).each do |name|\n if self.class.has_parser?(name)\n @parsers[name] = self.class.parser(name)\n else\n raise Kramdown::Error, \"Unknown parser: #{name}\"\n end\n end\n @span_start, @span_start_re = span_parser_regexps\n end",
"def initialize(filename)\n if filename == '-'\n @filename = 'stdin'\n text = STDIN.read\n else\n @filename = filename\n text = File.read(filename)\n end\n\n @document = Kramdown::Document.new(text, input: 'GFM')\n end",
"def parse(text)\n Rdoc.parser.convert(text).force_encoding(\"UTF-8\")\n end",
"def step\n start_group :normal, matched if scan( /\\s+/ )\n if @in_tag\n case\n when scan( /([-\\w]+):([-\\w]+)/ )\n start_group :namespace, subgroup(1)\n start_group :punct, \":\"\n start_group :attribute, subgroup(2)\n when scan( /\\d+/ )\n start_group :number, matched\n when scan( /[-\\w]+/ )\n start_group :attribute, matched\n when scan( %r{[/?]?>} )\n @in_tag = false\n start_group :punct, matched\n when scan( /=/ )\n start_group :punct, matched\n when scan( /[\"']/ )\n scan_string matched\n else\n append getch\n end\n elsif ( text = scan_until( /(?=[<&])/ ) )\n start_group :normal, text unless text.empty?\n if scan(/<!--.*?(-->|\\Z)/m)\n start_group :comment, matched\n else\n case peek(1)\n when \"<\"\n start_group :punct, getch\n case peek(1)\n when \"?\"\n append getch\n when \"/\"\n append getch\n when \"!\"\n append getch\n end\n start_group :normal, matched if scan( /\\s+/ )\n if scan( /([-\\w]+):([-\\w]+)/ )\n start_group :namespace, subgroup(1)\n start_group :punct, \":\"\n start_group :tag, subgroup(2)\n elsif scan( /[-\\w]+/ )\n start_group :tag, matched\n end\n @in_tag = true\n when \"&\"\n if scan( /&\\S{1,10};/ )\n start_group :entity, matched\n else\n start_group :normal, scan( /&/ )\n end\n end\n end\n else\n append scan_until( /\\Z/ )\n end\n end",
"def create_parser(grammar_paths)\n @search_parser ||= grammar_paths.inject(nil) do |parser,lucene_grammar|\n begin\n break parser unless parser.nil?\n # don't instantiate custom nodes\n Treetop.load_from_string(\n IO.read(lucene_grammar).gsub(/<[^>]+>/, ''))\n LuceneParser.new\n rescue\n # silently swallow and try the next grammar\n end\n end\n end",
"def parse_context; end",
"def parse_context; end",
"def retrieveYFM(text)\n yfm = \"\"\n text.match(/^(---\\s*\\n.*?\\n?)^(---\\s*$\\n?)/m) do |md|\n yfm = md.to_s\n text = md.post_match\n end\n return yfm, text\n end",
"def parse_tag(html_str)\n node = Struct.new(:type, :classes, :id, :name)\n parser = node.new\n parser.type = html_str.scan(/<[a-z0-9]+/).join[1..-1]\n parser.classes = html_str.scan(/class='(.*?)'/).join.split(\" \")\n parser.id = html_str.scan(/id='(.*?)'/).join\n parser.name = html_str.scan(/name='(.*?)'/).join\n parser\nend",
"def parser\n @parser ||= ::Puppet::Pops::Parser::EvaluatingParser.new\n end",
"def parser\n @parser ||= ::Puppet::Pops::Parser::EvaluatingParser.new\n end",
"def parser_class\n case @url\n when 'post.html' then HackerNews::Parser ## example case\n when @url then HackerNews::Parser\n # when @url =~ /.*reddit.*/ then HackerNews::Reddit\n else\n raise MissingParserError\n end\n end",
"def configure_parser; end",
"def ruby_parser\n @ruby_parser ||= parser_for_version ruby_version\n end",
"def create_parser(grammar_paths)\n @search_parser ||=\n grammar_paths.inject(nil) do |parser, lucene_grammar|\n begin\n break parser unless parser.nil?\n # Don't instantiate custom nodes\n Treetop.load_from_string(\n IO.read(lucene_grammar).gsub(/<[^>]+>/, ''))\n LuceneParser.new\n rescue\n # Silently swallow and try the next grammar\n end\n end\n end",
"def parse_codeblocks(html); end",
"def parse(html, options = {})\n # clean html\n clean_html = cleaner.clean(html, options)\n\n # fix html\n pdf_model = fixer.fix(clean_html, options)\n end"
] | [
"0.7837217",
"0.71642923",
"0.64176196",
"0.63126767",
"0.6300437",
"0.6168566",
"0.60934526",
"0.60860515",
"0.60860515",
"0.60860515",
"0.60860515",
"0.59642935",
"0.59642935",
"0.59109116",
"0.5871536",
"0.5861769",
"0.5845905",
"0.5800201",
"0.5770351",
"0.5768634",
"0.5715795",
"0.56201243",
"0.5613092",
"0.55960274",
"0.55621034",
"0.55163395",
"0.5448282",
"0.5441366",
"0.54350764",
"0.5416163",
"0.537559",
"0.5348084",
"0.53470093",
"0.53470093",
"0.53211516",
"0.5309838",
"0.52744234",
"0.5273988",
"0.52682954",
"0.5260187",
"0.5255349",
"0.524758",
"0.5240936",
"0.52326715",
"0.5226675",
"0.5226675",
"0.5223387",
"0.521182",
"0.51962453",
"0.5194566",
"0.51651245",
"0.51651245",
"0.51651245",
"0.5150449",
"0.5135184",
"0.51290655",
"0.5121994",
"0.5110167",
"0.5108062",
"0.5103381",
"0.5094912",
"0.5094912",
"0.5065994",
"0.5054802",
"0.50507265",
"0.5035586",
"0.5033862",
"0.5017029",
"0.5016893",
"0.50116557",
"0.49976054",
"0.49941984",
"0.498798",
"0.4969077",
"0.49666741",
"0.4965796",
"0.49645308",
"0.49628255",
"0.49581647",
"0.4957404",
"0.4951651",
"0.4936496",
"0.49322763",
"0.49257457",
"0.492566",
"0.49250662",
"0.49232307",
"0.49172994",
"0.49161652",
"0.49161652",
"0.4915132",
"0.4911505",
"0.48988432",
"0.48988432",
"0.48921168",
"0.48819056",
"0.48674834",
"0.48637128",
"0.4863403",
"0.4851647"
] | 0.6997973 | 2 |
Computes a glob pattern from file spec | def compute_glob_pattern(file_spec)
segments = file_spec.split(Repositext::Cli::FILE_SPEC_DELIMITER)
r = ''
if segments.all? { |e| e =~ BASE_DIR_NAME_REGEX || e =~ FILE_PATTERN_NAME_REGEX }
# file_spec consists of named base_dir and/or file_pattern
bd = segments.detect { |e| e =~ BASE_DIR_NAME_REGEX } # e.g., 'content_dir'
fp = segments.detect { |e| e =~ FILE_PATTERN_NAME_REGEX } # e.g., 'at_files'
r << base_dir(bd) if bd
r << file_pattern(fp) if fp
else
# interpret file_spec as glob pattern, either an absolute path, or
# a relative path, based on current working directory.
# NOTE: this doesn't necessarily have to contain '*'. It could be the
# path to a single file.
if '/' == file_spec[0]
# absolute path, use as is
r = file_spec
else
# relative path, based on current working directory
# Note: we could use just the file_spec since relative paths are
# based on pwd by default. I just wanted to make the behavior obvious.
r = File.expand_path(file_spec, Dir.pwd)
end
end
r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def glob pattern\n Dir[File.join(@originals,pattern)].collect do |f|\n File.basename(f)\n end\n end",
"def glob(*pat, &blk)\n regexes = pat.flatten.map {|pat| Bun.convert_glob(pat) }\n enum = self.class.new(@collection) do |yielder|\n self.each do |fname|\n # TODO Refactor with any?\n matched = false\n regexes.each do |regex|\n if fname =~ regex\n matched = true\n break\n end\n end\n yielder << fname if matched\n end\n end\n if block_given?\n enum.each(&blk)\n else\n enum\n end\n end",
"def glob(pattern)\n Glob.new(@shell, pattern)\n end",
"def glob(pattern, flags = T.unsafe(nil)); end",
"def file(glob)\n \"**/#{glob}\"\n end",
"def pattern\n \"#{@gem}/spec{,/*/**}/*_spec.rb\"\n end",
"def glob(pat, path='/')\n # FIXME : implement\n raise('not implemented')\n # FIXME: verify and update\n # FIXME: test\n #regex = /^#{pat.gsub('*','.*').gsub('?','.?')}$/ \n #find(path) { |fname| fname =~ regex }\n end",
"def regexify(glob)\n glob.gsub! '.', '\\\\.'\n rx = glob.split '*'\n rs = '^' + rx[0]\n rs << '.*'\n rs << rx[-1] if rx.length == 2\n rs << '$'\n Regexp.new rs\nend",
"def generate_glob_filter(glob)\n # Negative glob starts with '!'\n negative = glob.start_with?('!')\n # Strip leading '!' then\n glob.remove_prefix!('!') if negative\n lambda do |path|\n matches = File.fnmatch(glob, path, GLOB_MATCH_MODE)\n # inverse match if glob is negative\n matches = !matches if negative\n matches\n end\n end",
"def glob(pattern)\n root = self.root\n Pathname.glob(root.join(pattern)).map do |match|\n match.relative_path_from(root).to_s\n end\n end",
"def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend",
"def file_glob\n if file_types.nil?\n '*'\n else\n \"*{#{file_types.join(',')}}\"\n end\n end",
"def process_globs(globs); end",
"def glob(pattern = '**/*', **_opts)\n Enumerator.new do |y|\n walk(pattern) do |path, entry|\n y << file_info(path, entry) if File.fnmatch?(pattern, path, File::FNM_PATHNAME)\n end\n end\n end",
"def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend",
"def glob_to_regexp(glob)\n is_glob_pattern = glob.include?('*')\n\n regexp = if is_glob_pattern\n glob.\n gsub(%r{/\\*\\*$}, '<<to_eol_wildcards>>').\n gsub('**', '<<to_wildcards>>').\n gsub('*', '[^/]*').\n gsub('.', '\\.').\n gsub('<<to_eol_wildcards>>', '.*').\n gsub('<<to_wildcards>>', '.*')\n else\n \"#{glob}.*\"\n end\n\n Regexp.new(\"^#{regexp}$\", Regexp::IGNORECASE)\n end",
"def glob(pattern, &block)\n result = @lock.with_read_lock { @paths.flat_map { |path| path.glob(pattern, &block) }}\n result unless block\n end",
"def glob(*args)\n Glob.new(self, *args)\n end",
"def glob(*args)\n Glob.new(self, *args)\n end",
"def glob\n \"**/*\"\n end",
"def rel_glob(pattern, expand: false)\n\t\t\t\tg=[]\n\t\t\t\tself.cd { g=Dir.glob(pattern) }\n\t\t\t\tif expand\n\t\t\t\t\tg.map {|f| self+f} \n\t\t\t\telse\n\t\t\t\t\tg.map {|f| Pathname.new(f)}\n\t\t\t\tend\n\t\t\tend",
"def glob(pattern)\n Dir.chdir(@output_dir) do\n Dir[pattern]\n end\n end",
"def getFilePattern(filePattern)\n return if filePattern.nil?\n File.split(filePattern).inject do |memo, obj| \n File.join(memo, obj.split(/\\./).join('*.'))\n end\nend",
"def glob(pattern, *args)\n Dir.glob(pattern, *args).sort\n end",
"def glob; end",
"def glob=(_arg0); end",
"def glob(*patterns)\n require \"pathname\"\n patterns.reduce([]) do |result, pattern|\n if pattern.end_with?(\"/**\")\n pattern += \"/\"\n end\n result += Dir.glob(pattern).map do |path|\n Pathname.new(path.gsub(\"\\\\\", \"/\")).cleanpath.to_s\n end\n end.sort\n end",
"def glob=(pattern)\n @glob = pattern\n if pattern.kind_of?(Regexp)\n @pattern = pattern\n else\n @pattern = scan_string\n end\n end",
"def glob_match(filenames, pattern)\n pattern = pattern.gsub(/[\\*\\?\\.]/, '*' => '.*', '.' => '\\.', '?' => '.')\n regex = Regexp.new(pattern)\n filenames.select do |filename|\n filename =~ regex\n end\nend",
"def ovl_glob(rel_pattern)\n gem_files = Dir.glob(File.join(GEM_ROOT, rel_pattern)).map do |path|\n path.sub(GEM_ROOT+\"/\", \"\")\n end\n\n (gem_files + Dir.glob(rel_pattern)).uniq\n end",
"def ovl_glob(rel_pattern)\n gem_files = Dir.glob(File.join(GEM_ROOT, rel_pattern)).map do |path|\n path.sub(GEM_ROOT+\"/\", \"\")\n end\n\n (gem_files + Dir.glob(rel_pattern)).uniq\n end",
"def glob(match)\n paths = Array.new(match) # Force array-ness\n\n paths.map! do |spec|\n if spec.include?('*')\n files.select do |file, _|\n # Dir#glob like source matching\n File.fnmatch?(spec, file, File::FNM_PATHNAME | File::FNM_DOTMATCH)\n end.sort\n else\n [spec, files[spec]]\n end\n end\n\n Hash[*paths.flatten]\n end",
"def directory_glob\n glob = File.join(directory_path, \"#{globular_file_parts}.*\")\n Dir.glob(glob)\n end",
"def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end",
"def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end",
"def glob(match, options={})\n $LEDGER.glob(match, options)\n end",
"def unglobify(glob)\n chars = glob.split(\"\")\n\n chars = smoosh(chars)\n\n curlies = 0\n escaping = false\n string = chars.map do |char|\n if escaping\n escaping = false\n char\n else\n case char\n when \"**\"\n \"([^/]+/)*\"\n when '*'\n \".*\"\n when \"?\"\n \".\"\n when \".\"\n \"\\.\"\n\n when \"{\"\n curlies += 1\n \"(\"\n when \"}\"\n if curlies > 0\n curlies -= 1\n \")\"\n else\n char\n end\n when \",\"\n if curlies > 0\n \"|\"\n else\n char\n end\n when \"\\\\\"\n escaping = true\n \"\\\\\"\n else\n char\n end\n end\n end\n\n '(\\A|\\/)' + string.join + '\\Z'\n end",
"def glob(pattern = '**/*', **_opts)\n Enumerator.new do |acc|\n walk(pattern, with_stat: true) {|info| acc << info }\n end\n end",
"def [](path, pattern)\n glob(path, pattern, 0)\n end",
"def file_pattern(name)\n if name.to_s !~ FILE_PATTERN_NAME_REGEX\n raise ArgumentError.new(\"A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }\")\n end\n get_config_val(@file_patterns, name)\n end",
"def path_as_r_glob\n path.map {|p| \"#{p}/**/#{self.base_as_r}\"}\n end",
"def _glob(path, rex)\n base_dir = nil\n if path.to_s[0] == ?/\n base_dir = @obj[\"dirs\"][0][\"path\"]\n base_dir = base_dir.join(path[1..-1])\n else\n base_dir = @obj[\"dirs\"].last[\"path\"]\n base_dir = base_dir.join(path)\n end\n\n entries = Dir.glob(\"#{base_dir}/**/*\")\n\n result = []\n entries.each do |entry|\n result << entry if entry.to_s =~ rex\n end\n return result.sort\n end",
"def glob(*args, &block); end",
"def glob(*globs)\n files.find_all do |path|\n globs.any? { |pattern| File.fnmatch(pattern, path, File::FNM_EXTGLOB) }\n end\n end",
"def file_pattern( pattern )\n self.class_eval { @file_pattern = pattern }\n end",
"def dest_glob\n Dir.glob File.join(PictureTag.dest_dir, name_left + '?' * 6 + name_right)\n end",
"def files() = files_path.glob('**/*')",
"def extension(glob)\n \"*.#{glob}\"\n end",
"def glob\n case @raw_image_files.first.filename\n when /^E.*dcm$/\n return 'E*.dcm'\n when /\\.dcm$/\n return '*.dcm'\n when /^I\\./\n return 'I.*'\n when /^I/\n return 'I*.dcm'\n when /.*\\.\\d{3,4}/\n return '*.[0-9]*'\n when /\\.0/\n return '*.0*'\n else\n return nil\n end\n # Note - To exclude just yaml files we could also just use the bash glob\n # '!(*.yaml), but we would have to list all exclusions. This may turn\n # out easier in the long run.\n end",
"def spec_files\n glob_files(@root_dir, 'spec', '**/*_spec.rb')\n end",
"def all_specs\n files_matching %r%^spec/.*_spec\\.rb$%\n end",
"def safe_glob(dir, patterns, flags = T.unsafe(nil)); end",
"def process_globs globs\n result = globs.flat_map do |glob|\n Dir[File.join directory, glob]\n .map{ |f| f.gsub(/\\\\/, '/') }\n .select { |f| File.file?(f) }\n end\n result\n end",
"def glob_to_directory glob\n glob.gsub(/(\\/\\*|\\/\\*\\*\\/\\*\\*?)$/, '')\n end",
"def match(glob, &block)\n yield @filename\n end",
"def glob(*patterns)\n selection = []\n patterns.each do |pattern|\n selection.concat(Dir.glob(File.join(path, pattern))) \n end\n selection\n end",
"def template_name_and_format_glob(name, format, opts)\n \"#{template_name_and_format(name,format,opts)}.*\"\n end",
"def resolve_glob(context, glob, base_path)\n base_path = Pathname.new(base_path)\n path_with_glob = base_path.dirname.join(glob).to_s\n\n Pathname.glob(path_with_glob).sort.select do |path|\n asset_requirable = asset_requirable?(context, path)\n path != context.pathname && asset_requirable\n end\n end",
"def resolve_glob(context, glob, base_path)\n base_path = Pathname.new(base_path)\n path_with_glob = base_path.dirname.join(glob).to_s\n\n Pathname.glob(path_with_glob).sort.select do |path|\n path != context.pathname && context.asset_requirable?(path)\n end\n end",
"def glob(path)\n path = path.tr('\\\\', '/') if windows?\n if block_given?\n Dir.glob(path) {|f| yield(f)}\n else\n Dir.glob(path)\n end\n end",
"def all_specs\n files_matching %r%^spec/.*_spec\\.rb$%\n end",
"def glob(pattern = '**/*', **opts)\n Enumerator.new do |acc|\n walk(pattern, **opts) do |path, obj|\n info = BFS::FileInfo.new(path: path, size: obj.size, mtime: obj.last_modified)\n acc << info\n end\n end\n end",
"def glob(*args, &block)\n @entry_set.glob(*args, &block)\n end",
"def glob(pattern, flags: GLOB_OPERATION_FLAGS)\n @sftp.dir.glob(@path.to_s, pattern, flags) { |entry| yield entry.name }\n end",
"def appendGlobs(arr, patterns); patterns.each { |p| arr << Dir.glob(p) }; arr.flatten end",
"def glob(path, glob)\n\t\t@connection.glob(path, glob)\n\tend",
"def input_files_pattern\n @args.options[:input_files_pattern]\n end",
"def convert_glob_to_absolute(glob); end",
"def to_glob(glob)\n return Fileset.new if glob.nil?\n return Fileset.new(glob.map { |g| to_glob(g) }) if glob.is_a? Array\n return Fileset.from_glob(@workdir + glob) if @workdir\n Fileset.from_glob(glob)\n end",
"def glob(path, pattern, flags=0)\n flags |= ::File::FNM_PATHNAME\n path = path.chop if path[-1,1] == \"/\"\n\n results = [] unless block_given?\n queue = entries(path).reject { |e| e.name == \".\" || e.name == \"..\" }\n while queue.any?\n entry = queue.shift\n\n if entry.directory? && !%w(. ..).include?(::File.basename(entry.name))\n queue += entries(\"#{path}/#{entry.name}\").map do |e|\n e.name.replace(\"#{entry.name}/#{e.name}\")\n e\n end\n end\n\n if ::File.fnmatch(pattern, entry.name, flags)\n if block_given?\n yield entry\n else\n results << entry\n end\n end\n end\n\n return results unless block_given?\n end",
"def spec_for(match, kind)\n File.join(\"spec\", kind + 's', \"#{match}_spec.rb\")\n end",
"def template_glob\n Templates.path_for(self.class.template_dir_name) / \"#{filename}.*\"\n end",
"def glob!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 7 )\n\n type = GLOB\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 42:5: ( '?' | '*' )+\n # at file 42:5: ( '?' | '*' )+\n match_count_12 = 0\n while true\n alt_12 = 2\n look_12_0 = @input.peek( 1 )\n\n if ( look_12_0 == 0x2a || look_12_0 == 0x3f )\n alt_12 = 1\n\n end\n case alt_12\n when 1\n # at line \n if @input.peek(1) == 0x2a || @input.peek(1) == 0x3f\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n else\n match_count_12 > 0 and break\n eee = EarlyExit(12)\n\n\n raise eee\n end\n match_count_12 += 1\n end\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 7 )\n\n end",
"def glob_data_paths(pattern,&block)\n return enum_for(:glob_data_paths,pattern).to_a unless block_given?\n\n DataPaths.paths.each do |path|\n Dir.glob(File.join(path,pattern),&block)\n end\n end",
"def filepath_pattern(filepaths)\n return \"\" if filepaths.nil?\n\n filepaths.map! { |path| '^' + path + '$' }\n filepaths.join('|')\n end",
"def array_decide\n @parameter['a'] ? Dir.glob('*', File::FNM_DOTMATCH) : Dir.glob('*')\nend",
"def glob_mp3_files_from_filespec(filespec)\n files = Dir[filespec]\n files.reject! { |fn| File.directory?(fn) }\n files.reject! { |fn| !(can_parse_id3?(fn)) } \n return files\nend",
"def exact_glob?(glob)\n !glob.include?('*') && !glob.include?('?') && !glob.include?('[') && !glob.include?('{')\n end",
"def file_pattern\n return 'US_CO_*.geojson'\n end",
"def file_pattern\n return 'US_OR_*.geojson'\n end",
"def test_glob\n return @test_glob ||= File.join(path, test, '**', '?*Test.as')\n end",
"def file_patterns\n [@file_patterns].flatten.compact.uniq\n end",
"def translate_glob iss_glob\n raise \"Can't expand path #{iss_glob}\" if iss_glob.include?('**')\n prefix = flags.include?('recursesubdirs') ? \"**/\" : \"\"\n \"#{prefix}#{iss_glob}\"\n end",
"def find_files dir = test_dir\n glob file_pattern(dir)\n end",
"def glob(*args)\n return super(*args) { yield subpath(_1) } if block_given?\n super(*args).map { subpath(_1) }\n end",
"def dirglob(dir='')\n pattern = dir.sub(/\\/+$/, ?/) + ?*\n files = []\n dirs = []\n Dir[pattern].flat_map do |f|\n if File.directory?(f)\n f = f.sub(/\\/*$/, ?/)\n dirs += ['', f] + dirglob(f)\n else\n files << f\n end\n end\n files + dirs\nend",
"def glob(flags = 0)\n if block_given?\n Pathname.glob(@pathname, flags) do |file|\n yield filtered_pathname(file) if visible file\n end\n else\n result = Pathname.glob(@pathname, flags)\n convert_result_if_necessary(result)\n end\n end",
"def file_paths\n Dir.glob(@filepath_pattern).sort\n end",
"def filter_files(pattern)\n regexp=Regexp.new(pattern || '.*')\n @filtered_files=@files.inject([]) do |matches,file| \n file_without_basepath=file[@basepath.length .. -1]\n matches << file if file_without_basepath=~regexp\n matches\n end\n @table.reloadData\n end",
"def check_globs(filename)\r\n basename = File.basename(filename)\r\n found = @globs.each_key.select { |pattern| File.fnmatch pattern, basename }\r\n\r\n if found.empty?\r\n downcase_basename = basename.downcase\r\n found = @globs.each_key.select { |pattern|\r\n File.fnmatch pattern, downcase_basename\r\n }\r\n end\r\n\r\n @globs[found.max]\r\n end",
"def matches_for_glob(glob) # TODO: rename?\n glob = File.join(self.lib_dirs_glob, glob)\n\n Dir[glob].map {|f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1\n end",
"def file_list(pattern)\n FileList[pattern].tap do |list|\n list.exclude 'vendor/**/*', # bundler\n 'pkg/**/*', # gem build process\n 'spec/fixtures/**/*' # puppetlabs fixtures\n list.reject! { |f| File.directory? f }\n end\n end",
"def ls(pattern='**/*', _opts={})\n root = pattern[%r{^[^\\*\\?\\{\\}\\[\\]]+/}]\n root.chomp!('/') if root\n Enumerator.new do |y|\n glob(root) do |path|\n y << path if File.fnmatch?(pattern, path, File::FNM_PATHNAME)\n end\n end\n end",
"def get_file_list(path_pattern)\n return Dir[path_pattern].sort\n end",
"def paths(glob, root_depth: default_root_depth)\n builder = ModuleBuilder.new(root_depth: root_depth, root_module: root_module)\n blank_str = ''\n Dir.glob(File.join root_path.to_s, *glob).each do |full_path|\n next if all_files.include? full_path\n all_files << full_path\n\n rel_path = full_path.sub root_path.to_s, blank_str\n dir_path, file_name = File.split rel_path\n const_name = Utils.camelize file_name[0, file_name.size - 3]\n builder.module(dir_path).autoload const_name, full_path\n end\n self\n end",
"def pattern_template\n \"*\"\n end",
"def escape_glob\n self.class.new(escape_glob_string)\n end",
"def get_local_files regexp\n Dir[File.join(dir, '*')].select do |path|\n name = File.basename path\n File.file?(path) and name =~ regexp\n end\n end",
"def glob_to_directory(glob); end",
"def create_source_files(pattern)\n source_files = []\n if pattern[:cn]\n names = pattern[:cn].scan(/(^[a-zA-Z]*)[^a-zA-Z]*([a-zA-Z]*)/).flatten\n names[0] = '*' if names[0].empty?\n names[1] = '*' if names[1].empty?\n names.permutation do |names|\n file = File.join(URL, \"#{names.join('_').downcase}.contact\")\n Dir.glob(file).each { |file| source_files << file }\n end\n elsif pattern[:sn] or pattern[:gn]\n sn = pattern[:sn] ? pattern[:sn].strip.downcase : '*'\n gn = pattern[:gn] ? pattern[:gn].strip.downcase : '*'\n Dir.glob(File.join(URL, \"#{gn}_#{sn}.contact\")).each do |file|\n source_files << file\n end\n else\n Dir.glob(File.join(URL, \"*_*.contact\")).each do |file|\n source_files << file\n end\n end\n source_files\n end"
] | [
"0.73991126",
"0.73890775",
"0.73805094",
"0.73424846",
"0.7341463",
"0.7321767",
"0.7315161",
"0.71776307",
"0.7175369",
"0.71287674",
"0.7073747",
"0.7070709",
"0.6996914",
"0.69651437",
"0.69538486",
"0.69528484",
"0.6923822",
"0.6908099",
"0.6908099",
"0.6870214",
"0.6870081",
"0.6862957",
"0.68416214",
"0.68163836",
"0.68150204",
"0.67633456",
"0.67413956",
"0.67219573",
"0.6696353",
"0.66735315",
"0.66735315",
"0.6638197",
"0.6637302",
"0.66210014",
"0.66210014",
"0.6613179",
"0.65987855",
"0.6592706",
"0.65769196",
"0.65413386",
"0.6523414",
"0.6519622",
"0.65061194",
"0.6504451",
"0.6483501",
"0.64653075",
"0.6459568",
"0.64553154",
"0.64544207",
"0.6450476",
"0.6442962",
"0.6411321",
"0.64071846",
"0.6373708",
"0.6360218",
"0.63351506",
"0.63348585",
"0.63251287",
"0.6324415",
"0.63004065",
"0.6295287",
"0.6292206",
"0.62870884",
"0.62766516",
"0.626443",
"0.62502366",
"0.62001425",
"0.6178296",
"0.61761165",
"0.617372",
"0.6160954",
"0.6158931",
"0.61580426",
"0.61416614",
"0.60802644",
"0.6071879",
"0.6068806",
"0.60574645",
"0.60294086",
"0.6026664",
"0.6024058",
"0.60191715",
"0.6014611",
"0.6005144",
"0.59917307",
"0.5987912",
"0.59661245",
"0.5949371",
"0.59425944",
"0.5940608",
"0.5938077",
"0.5934599",
"0.5930323",
"0.5930013",
"0.5893691",
"0.58922195",
"0.58919024",
"0.58912104",
"0.5868144",
"0.58610886"
] | 0.84700894 | 0 |
Computes a hash with validation file specs from input_file_specs | def compute_validation_file_specs(input_file_specs)
input_file_specs.inject({}) { |m,(fs_name, fs_string)|
base_dir, file_pattern = fs_string.split(Repositext::Cli::FILE_SPEC_DELIMITER).compact
if base_dir.nil? || file_pattern.nil?
raise ArgumentError.new("file_spec requires both base_dir and file_pattern: #{ fs_string.inspect } in #{ input_file_specs.inspect }")
end
if base_dir !~ BASE_DIR_NAME_REGEX
raise ArgumentError.new("base_dir is not valid: #{ base_dir.inspect }")
end
if file_pattern !~ FILE_PATTERN_NAME_REGEX
raise ArgumentError.new("file_pattern is not valid: #{ file_pattern.inspect }")
end
m[fs_name] = [base_dir(base_dir), file_pattern(file_pattern)]
m
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_digest_byte_tests\n FILES.each do |path, hashlen|\n name = File.basename(path).split('.')[0]\n\n f = File.new(\"sha3_digest_#{hashlen}_spec.rb\", 'w')\n f.puts(REQUIRED)\n f.puts(\n SPEC\n .gsub(/HASH_LEN/, hashlen.to_s)\n .gsub(/NAME/, name)\n )\n\n contents = File.read(path).split('Len = ')\n contents.each do |test|\n lines = test.split(\"\\n\")\n next unless !lines.empty? && lines[0] !~ /^#/\n\n length = lines[0].to_i\n next unless (length % 8).zero? && length != 0\n\n msg_raw = lines[1].split(' = ').last\n digest = lines[2].split(' = ').last.downcase\n\n f.puts(\n EXPECT\n .gsub(/HASHLEN/, hashlen.to_s)\n .gsub(/MSG/, msg_raw)\n .gsub(/DIGEST/, digest)\n )\n end\n\n f.puts(ENDING)\n f.close\n end\nend",
"def file_hashes\n @file_hashes ||= file_field_sets.map do |file_field_set|\n instantiation_fields, file_fields = file_field_set.partition do |field|\n instantiation_header?(field.header)\n end\n\n file_hash = fields_to_hash(file_fields)\n file_hash['files'] = [fields_to_hash(instantiation_fields)]\n\n file_hash\n end\n end",
"def simsat_create_file_hash(fm_dir_file)\n \n file_hash = {}\n \n dir_file = File.open(fm_dir_file,'r')\n \n file_hdr = dir_file.read(CfeFile::HDR_LEN)\n\n if file_hdr[0..3] == CfeFile::CONTENT_ID\n \n fm_hdr = dir_file.read(FswConfigParam::FM_DIR_FILE_HDR_LEN)\n \n if fm_hdr[0..SimSat::FLT_REC_DIR.length-1] == SimSat::FLT_REC_DIR\n \n num_files = fm_hdr[68..71].to_s.unpack('l')\n \n files = []\n num_files[0].times do\n file_rec = dir_file.read(FswConfigParam::FM_DIR_FILE_REC_LEN)\n file_ext_index = file_rec[0..63].index('.')\n file_name = file_rec[0..file_ext_index+3].to_s\n files << file_name\n end\n \n file_hash[:event] = files.grep /^#{SimSat::EVENT_FILENAME_BASE}/\n file_hash[:sci_aux] = files.grep /^#{SimSat::SCI_AUX_FILENAME_BASE}/\n file_hash[:isim] = files.grep /^#{SimSat::ISIM_FILENAME_BASE}/\n\n else\n\n message_box(\"FM file header does not contain the expected directory #{SimSat::FLT_REC_DIR}\",false)\n \n end\n \n else\n \n message_box(\"File header does not contain cFE file identifier #{CfeFile::CONTENT_ID}\",false)\n\n end\n \n return file_hash\n \nend",
"def hash(pathname)\n ext = pathname.extname\n ext = ('' == ext || nil == ext) ? :none : ext.to_sym\n digest = Digest::MD5.hexdigest(File.read(pathname.to_s))\n @scanned[ext] ||= {}\n @scanned[ext][digest] ||= []\n @scanned[ext][digest] << pathname\n end",
"def validate_file(file_list, timestamp, prev_hash)\n acc_balances = {}\n acc_balances.default = 0\n prepared_hashes = PreHash.new\n file_list.each_with_index do |line, line_no|\n parsed_lines = split_line line, line_no\n check_block_number parsed_lines[0], line_no\n verify_previous_hash prev_hash, parsed_lines[1], line_no\n timestamp = verify_and_return_datetime timestamp, parsed_lines[3], line_no\n verify_transactions parsed_lines[2], line_no, acc_balances\n hash_string = \"#{parsed_lines[0]}|#{parsed_lines[1]}|#{parsed_lines[2]}|#{parsed_lines[3]}\"\n prev_hash = verify_current_hash hash_string, parsed_lines[4], line_no, prepared_hashes\n end\n print_balances acc_balances\n true\nend",
"def buildCodeFilesHashFromFiles()\n\t\tdir = @cacheDirPath \n\t\tfilesList = Dir.glob(dir + \"**/*\").select{|e| File.file? e}\n\t\tfilesList.map.with_index{|file,index|\n\t\t\t#p \"cacheFile: \" + index.to_s if index % 1000 == 0\n\t\t\tp \"cacheFile: \" + index.to_s \n\t\t\tfilePath = dir + index.to_s + \".yaml\"\n\t\t\tfile = File.read(filePath)\n\t\t\tYAML.load(file)\n\t\t}.to_h\n\tend",
"def hash\r\n # TODO what if file is empty?\r\n @hash ||= Digest::SHA1.file(File.join(@directory, @filename)).hexdigest\r\n end",
"def hash_file(filename)\n file = File.read(filename)\n tlsh_hash(file.bytes)\n end",
"def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end",
"def to_hash(files)\n data = \"\"\n h = {}\n\n # Load files \n files.each {|fn| data << File.open(fn).read }\n\n # Gets the key values\n data.scan(/^([F3|R3]\\w+): ([,\\w]+)$/).each do |m| \n key, value = m\n unless KEYS_PER_TAG.include?(key.gsub(/R3|F3/, \"XX\"))\n return \"Invalid key found while processing stats\"\n end\n h[key] = value\n end\n\n (h.size == 4 or h.size == 8) ?\n h :\n \"Not the expected # of key/values: #{h.size}. Bailing out.\"\nend",
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n .to_s(16) # convert to hex\n # rubocop:enable GitHub/InsecureHashAlgorithm\n end",
"def compare_hashes_handler(hash_, file_, hash_class, _bit_size)\n # noinspection RubyStringKeysInHashInspection,RubyResolve\n hash_class_reference = {1 => Digest::SHA1, 2 => Digest::SHA2, 5 => Digest::MD5}\n # Check if hash_ is a raw hash or a csv db\n if File.file? hash_\n # hash_ is a csv database with hashes to check\n # Handler for databse\n file_object = File.open hash_, 'r'\n # All the lines of the db\n lines = file_object.readlines\n # Close the file because we don't need it anymore\n file_object.close\n # Fist line of this file is the configuration line that is the function and its bit size (if is sha2)\n hash_class, _bit_size = lines[0].strip.split('-')\n # Has_class can be transformed to int corresponding to its number\n hash_class = {\"SHA1\" => 1, \"SHA2\" => 2, \"MD5\" => 5}[hash_class]\n # When a bit size was specified transform it to int\n if _bit_size.is_a? String\n _bit_size = _bit_size.to_i\n end\n # Parameters for the setup of the hash_function\n hash_class = hash_class_reference[hash_class]\n\n #puts hash_class, chunk_size\n lines = lines[1..]\n lines.each do |line|\n file_path, hash = line.strip.split(',')\n compare file_path, hash_class, _bit_size, hash\n end\n else\n # hash_ variable is a raw hash\n # Get the hash class from the string provided\n hash_class = hash_class_reference[hash_class]\n # Compare the raw hash (hash_) with the file provided\n compare file_,hash_class, _bit_size, hash_\n end\nend",
"def hash\n return (path + file_id.to_s).hash\n end",
"def file_ids_hash\n if @file_ids_hash.blank?\n # load the file sha's from cache if possible\n cache_file = File.join(self.path,'.loopoff')\n if File.exists?(cache_file)\n @file_ids_hash = YAML.load(File.read(cache_file))\n else\n # build it\n @file_ids_hash = {}\n self.loopoff_file_names.each do |f|\n @file_ids_hash[File.basename(f)] = Grit::GitRuby::Internal::LooseStorage.calculate_sha(File.read(f),'blob')\n end\n # write the cache\n File.open(cache_file,'w') do |f|\n f.puts YAML.dump(@file_ids_hash) \n end\n end \n end\n @file_ids_hash\n end",
"def merge_data(input_files)\n for filename in input_files\n merge_into_hash(filename)\n end\n sanitize_hash\n end",
"def constructHashFromFile(input)\n\t\t\tresult = Hash.new()\n\t\t\tsize = input.size/6\n\t\t\tfor i in 0..size-1\n\t\t\t\talimento = Alimento.new(input[6*i], input[6*i+1].to_f, input[6*i+2].to_f, input[6*i+3].to_f, input[6*i+4].to_f, input[6*i+5].to_f)\n\t\t\t\tresult.store(input[6*i] , alimento )\n\t\t\tend\n\t\t\treturn result\n\t\tend",
"def findSmallHash(f)\r\n return Digest::SHA1.file(f).hexdigest()\r\nend",
"def file_sha256_hash(file_path)\n file = File.read(file_path)\n Digest::SHA256.hexdigest(file) if file\n end",
"def hash_file(name, length)\n pieces = String.new\n file = ::File.open(name, 'r')\n pieces << Digest::SHA1.digest(file.read(length)) until file.eof?\n file.close\n pieces\n end",
"def digest\n assert_file!\n Digest::SHA256.hexdigest(@name + Digest::SHA256.file(@path).to_s)\n end",
"def create_chksum_manifest\n chksum_manifest = {}\n files = Dir['*'].select{ |f| File.file? f }\n files.each do |file|\n chksum_manifest[file] = Digest::MD5.file(file).hexdigest\n end\n chksum_manifest\n end",
"def hash\n Digest::MD5.hexdigest(abs_filepath)[0..5]\n end",
"def hash_file path, hash_store\r\n\thexdigest = HASH_DIGEST.hexdigest(open(path, 'rb') { |io| io.read })\r\n\thash_store[hexdigest] << path\r\nend",
"def hash\n [clean_result, contains_executable, contains_invalid_file, contains_script, contains_password_protected_file, contains_restricted_file_format, contains_macros, contains_xml_external_entities, contains_insecure_deserialization, contains_html, contains_unsafe_archive, verified_file_format, found_viruses, content_information].hash\n end",
"def hashed_input\n\t\tmd5_hex = Digest::MD5.hexdigest(@term)\n\t\tmd5_hex.scan(/../).map { |s| s.to_i(16) }\n\tend",
"def dev_pod_hashes_map\n @dev_pod_hashes_map ||=\n dev_pod_sources.map { |name, attribs| [name, FolderChecksum.git_checksum(attribs[:path])] }.to_h\n end",
"def hash\n [file_info, output_path, encoding, recognize_lists, leading_spaces, trailing_spaces, enable_pagination].hash\n end",
"def file_digest(file)\n # Get the actual file by #tempfile if the file is an `ActionDispatch::Http::UploadedFile`.\n Digest::SHA256.file(file.try(:tempfile) || file).hexdigest\n end",
"def filehash(filepath)\n sha1 = Digest::SHA1.new\n File.open(filepath) do|file|\n buffer = ''\n # Read the file 512 bytes at a time\n while not file.eof\n file.read(512, buffer)\n sha1.update(buffer)\n end\n end\n return sha1.to_s\n end",
"def sha256\n # get all dependency checksums\n deps = Hash[locked_dependencies.list.map { |k, v| [k, v.profile.sha256] }]\n\n res = OpenSSL::Digest::SHA256.new\n files = source_reader.tests.to_a + source_reader.libraries.to_a +\n source_reader.data_files.to_a +\n [[\"inspec.yml\", source_reader.metadata.content]] +\n [[\"inspec.lock.deps\", YAML.dump(deps)]]\n\n files.sort_by { |a| a[0] }\n .map { |f| res << f[0] << \"\\0\" << f[1] << \"\\0\" }\n\n res.digest.unpack(\"H*\")[0]\n end",
"def file_sha256\n Digest::SHA256.file(self).hexdigest\n end",
"def get_file_hash(fullPath)\n contents = File.read(fullPath)\n fileHash = Digest::MD5.hexdigest(contents)\n return fileHash\nend",
"def getHash element\n\tfile = File.new(element)\n\thash = Digest::SHA256.file file\n\tfile.close\n\treturn hash.hexdigest \n\tend",
"def verify_sha256_hash(filename, hash)\n require 'digest/sha2'\n compare_hash(filename, Digest::SHA2, hash)\n end",
"def [] files\n # This stores all our matches\n match_hash = {}\n\n # Go through each file, check if the file basename matches the regexp.\n files.each do |f|\n path, file = File.split(f)\n\n if (m = match_against(file))\n replacement = populate_based_on(m)\n match_hash[f] = if path == '.'\n replacement\n else\n File.join(path, replacement)\n end\n end\n end\n match_hash\n end",
"def digest\n OpenSSL::Digest::SHA256.file(path).hexdigest\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def dirHash(directory, regexp)\n directory = Pathname.new(directory)\n contents = \"\"\n Dir.foreach(directory) {\n | entry |\n if entry =~ regexp\n contents += IO::read(directory + entry)\n end\n }\n return Digest::SHA1.hexdigest(contents)\nend",
"def diff_files\n hsh = {}\n @base.git.diff_files.split(\"\\n\").each do |line|\n (info, file) = line.split(\"\\t\")\n (mode_src, mode_dest, sha_src, sha_dest, type) = info.split\n hsh[file] = {:path => file, :mode_file => mode_src.to_s[1, 7], :mode_index => mode_dest,\n :sha_file => sha_src, :sha_index => sha_dest, :type => type}\n end\n hsh\n end",
"def hashFromFile(file, auth, algo)\n u = URI::NI.buildFromFile(auth, file, nil, algo)\n type=`file --mime-type #{file}`.split[1]\n u.contentType!(type)\n u\nend",
"def filehash(filename, algorithm = DEFAULT_ALGORITHM)\n algo_class = Digest.const_get(algorithm.to_s.upcase)\n\n # Safety check\n unless algo_class.class == Class and algo_class.respond_to?(:new)\n raise \"Unknown filehash provider #{algo_class}\"\n end\n\n hash = algo_class.new()\n File.open(filename,'r') do |f|\n until f.eof?\n hash.update(f.read(READ_SIZE))\n end\n end\n\n return hash.hexdigest\n end",
"def compute_changed_and_risk_files(params)\n commit_hash, file_arr = commit_info(params)\n changed_file_freq = file_arr.flatten!.each_with_object(Hash.new(0)) {|file, freq_acc| freq_acc[file] += 1}\n changed_g2_files = []\n changed_file_freq.select {|file, freq| changed_g2_files << file if freq > 2}\n risk_files = changed_g2_files.dup\n rf = risk_files.each_with_object({}) do |file, acc|\n author_set = Set.new\n commit_hash.each do |file_arr, author|\n acc[file] = (author_set << author ) if file_arr.include? (file)\n end\n end\n rf.delete_if {|_file, author_arr| author_arr.length < 2}\n {\n \"changed_files\" => changed_g2_files,\n \"risk_files\" => rf\n }\n end",
"def hash\n raise NotImplementedError.new(\"hash() must be implemented by subclasses of AbstractVersionedFile.\")\n end",
"def integrity(path)\n \"sha256-#{Base64.encode64(Digest::SHA256.digest(File.read(path))).chomp}\"\n end",
"def files_digest(paths)\n self.digest(paths.map { |path| self.file_digest(path) })\n end",
"def digest_sha2(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA2.hexdigest(File.read(file)) : nil\n }\n end",
"def generate_hexdigest_indexed_list(size_indexed_list, head_size = nil)\n result = {}\n size_indexed_list.each_pair{|old_key, filename_arr|\n filename_arr.each{|filename|\n if head_size == nil\n $stdout.puts \"SHA512 hash calculation: #{filename}\"\n else\n $stdout.puts \"Header (#{head_size}) SHA512 hash calculation: #{filename}\"\n end\n\n hexdigest = get_file_header_sha512(filename, head_size)\n\n if result.has_key?(hexdigest) == false\n result[hexdigest] = []\n end\n result[hexdigest].push(filename)\n }\n }\n return result\nend",
"def hash\n [specs, platform, requires_frameworks].hash\n end",
"def files_digest(paths)\n digest(paths.map { |path| file_digest(path) })\n end",
"def initialize_input_hash(filename)\n input = {}\n File.open(filename, 'r') do |file|\n while line = file.gets\n input[line.to_i] = true\n end\n end\n input\nend",
"def initialize input_files\n @input_files = input_files\n @input_data = Hash.new\n @output_data = Array.new\n end",
"def fingerprint(filename)\n \"SHA256: \" + X509.fingerprint(\"SHA256\", Path.named_path(filename))\n end",
"def verify_checksum(filename)\n if options[:sha256]\n verify_sha256_hash(filename, options[:sha256])\n elsif options[:sha1]\n verify_sha1_hash(filename, options[:sha1])\n end\n end",
"def files_hashs\n @files.map do |file|\n hash = case file\n when String\n { url: file }\n when Hash\n file.dup\n else\n raise ArgumentError, 'files must be an Array of Stings or Hashs'\n end\n\n hash[:local_path] = local_path\n hash\n end\n end",
"def file_hash\n return @file_hash\n end",
"def initialize(hash)\n @file = hash.fetch(:file) { fail InvalidFile }\n @major = hash.fetch(:major) { fail InvalidFile }\n @minor = hash.fetch(:minor) { fail InvalidFile }\n @patch = hash.fetch(:patch) { fail InvalidFile }\n @special = hash.fetch(:special) { fail InvalidFile }\n @metadata = hash.fetch(:metadata) { fail InvalidFile }\n validate\n end",
"def hashNQS()\n @hash_nqs={}\n nqsReader=File.open(@nqsFile,\"r\")\n nqsReader.each do |line|\n cols=line.split(/\\s+/)\n \n name=cols[0]\n next if name==\"readName\"\n length=cols[1]\n dist=cols[2]\n qual=cols[3].to_i\n pass=cols[4]\n \n str_result=length+'.'+pass\n str=name+'.'+dist\n if @hash_nqs[str]==nil\n @hash_nqs[str]=str_result\n end\n end\n nqsReader.close\n $stderr.puts @hash_nqs.size\nend",
"def calculate_hash(input, prep_hashes)\n result = 0\n input.unpack('U*').each do |x|\n result += prep_hashes.hash(x)\n end\n (result % MOD_VALUE).to_s(HEX)\nend",
"def digests_data\n {\n '1' => '7a8a3dad389031160f79817c14bb5f3adf058335',\n '2' => '8d4fc3e19f141135ca59f0ba5d9e8b634f04840e',\n '3' => '88f879b8aa22eb340019449955accdca62886f64',\n '4' => 'dba9f7cc5b15cc2eee74a288e6c04431d2f5e509',\n '5' => 'febf0d5b94e4dd2cd23f3a9cd515641885a50980',\n '6' => '2628bf51107c4c5cd581179df5d1148821f8a7a8',\n '7' => '83f929fdce5dfe931f9ccc6af49e2cfd436740f4',\n '8' => '5f9e781563ab48e7a67ec4500321b1ebe553f3fc',\n '9' => '8b14bf8dfa2bc7d74443cd9c4a0d836f1341becb',\n '10' => '5442273b216f7c843de10acc57c33638f7848f74',\n '11' => '3871068443e406fbff7ad6f91bd395bf9482a259',\n '12' => '9e52c47b63dd968ba2349779a86986eff2f2b860',\n '13' => '658ba6008127dc4e61eb5bbe70ec69be5524b845'\n }\n end",
"def generate_verification_map\n verification_map = {}\n for i in 1..@num_configs\n defname = get_defname(i)\n submap = {}\n for field in 1..@num_fields\n name = get_fieldname(defname, field)\n submap[name] = name\n end\n verification_map[defname] = submap\n end\n verification_map\n end",
"def digest_sha1(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA1.hexdigest(File.read(file)) : nil\n }\n end",
"def files_hash\n @files_hash\n end",
"def file_digest_key(stat)\n \"file_digest:#{compressed_path}:#{stat}\"\n end",
"def generate_sha(file)\n\n sha1 = Digest::SHA1.file file\n return sha1\n\nend",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def hash(handle, offset, length, block_size=0)\n if block_size != 0 && block_size < 255\n block_size = 256\n end\n send_request(FXP_EXTENDED, :string, \"check-file-handle\", :string, handle, :string, \"md5,sha256,sha384,sha512\", :int64, offset, :int64, length, :long, block_size)\n end",
"def digest_file( x)\n path = requested_file( x[:request] )\n if File.exist?(path) && !File.directory?(path)\n Digest::MD5.hexdigest(File.read(path))\n else\n nil\n end\n end",
"def ret_indexed_input_files(input_type)\n input_type_hash(input_type)[:input_files].inject({}) { |h, (k, v) | h.merge(k => input_files_class.new(v[:regexps])) }\n end",
"def hash\n [file_id, output_version, image_quality, recompress_images, enable_color_detection, pack_document, pack_fonts, downscale_images, downscale_resolution, fast_web_view, remove_form_fields, remove_annotations, remove_bookmarks, remove_hyperlinks, remove_embedded_files, remove_blank_pages, remove_java_script, enable_jpeg2000, enable_jbig2, enable_char_repair, enable_mrc, preserve_smoothing, downscale_resolution_mrc, remove_metadata, remove_page_thumbnails, remove_page_piece_info, jbig2_pms_threshold].hash\n end",
"def check_input_files(inputfiles)\n inputfiles.each_key do | type |\n inputfiles[type].flatten!\n check = 0\n inputfiles[type].each do | symbol |\n if @options[symbol] == nil or @options[symbol] == ''\n if type == :required\n raise CheripicArgError.new \"Options #{inputfiles}, all must be specified. Try --help for further help.\"\n end\n else\n file = @options[symbol]\n if symbol == :bg_bulk or symbol == :bg_bulk_vcf\n if file.include? ','\n @options[symbol] = []\n file.split(',').each do | infile |\n @options[symbol] << File.expand_path(infile)\n file_exist?(symbol, infile)\n end\n end\n else\n @options[symbol] = File.expand_path(file)\n file_exist?(symbol, file)\n end\n check = 1\n end\n end\n if type == :either and check == 0\n raise CheripicArgError.new \"One of the options #{inputfiles}, must be specified. \" +\n 'Try --help for further help.'\n end\n end\n end",
"def genhash(absolute_filename)\n HDB.debug and puts \"Absolute filename #{absolute_filename}\"\n if File.file?(absolute_filename)\n HDB.debug and puts \"Digesting\"\n hash = Digest::SHA512.new\n # Save atime\n PRESERVE_ATIME and atime = File.stat(absolute_filename).atime\n File.open(absolute_filename, 'r') do |fh|\n while buffer = fh.read(BUFSIZE)\n hash << buffer\n end\n end\n # Reset atime, preserve mtime\n PRESERVE_ATIME and File.utime(atime, File.stat(absolute_filename).mtime, absolute_filename)\n return hash.to_s\n else\n HDB.debug and puts \"Not a file\"\n return NAHASH\n end\n end",
"def checksum(file_path, hash_class, _bit_size)\n # Size of each chunk\n chunk_size = 2048\n # Hash that is the checksum function\n # when a bitsize was specified\n if _bit_size\n hash = hash_class.new(_bit_size)\n else\n hash = hash_class.new\n end\n # File handler\n file_object = File.open(file_path, 'r')\n # loop to update the hash\n while true\n content = file_object.read chunk_size\n # Break the loop if we don't get any byte\n unless content\n return hash.hexdigest\n end\n # Update the hash\n hash.update content\n end\nend",
"def id(source_file)\n Digest::SHA1.hexdigest(source_file.filename)\n end",
"def checksum_file(digest_class, path)\n digester = digest_class.new\n digester.file(path)\n digester.hexdigest\n end",
"def manifested_files\n manifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n decode_filename(path)\n end\n }\n\n (acc + files).uniq\n end\n end",
"def hash # :nodoc:\n identifier.hash ^ requirement.hash\n end",
"def file_checksum(file_path)\n Digest::SHA256.file(file_path).hexdigest\n end",
"def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end",
"def id(source_file)\n Digest::SHA1.hexdigest(filename(source_file))\n end",
"def diff_files\n hsh = {}\n @base.git.diff_files.split(\"\\n\").each do |line|\n (info, file) = line.split(\"\\t\")\n (mode_src, mode_dest, sha_src, sha_dest, status) = info.split\n hsh[file] = {:path => file, :mode_repo => mode_src.to_s[1, 7], :mode_index => mode_dest,\n :sha_repo => sha_src, :sha_index => sha_dest, :status => status}\n end\n hsh\n end",
"def version_input_path_keys\n @version_input_path_keys ||= Hash[ version_formats.map{ |v, _| [ v, :\"#{v}\" ] } ]\n end",
"def hash_function_and_value\n return if hash_value.nil?\n if hash_function.nil? then\n return if errors.include?( :hash_value )\n errors.add( :hash_value, I18n.t( 'cfr_records.msg.hash_wo_fct' ))\n else\n case hash_function\n when 0 # MD5\n hash_size = 32\n when 1 # SHA-256\n hash_size = 64\n else\n return if errors.includes( :hash_function )\n errors.add( :hash_function, I18n.t( 'cfr_records.msg.unknown_fct' ))\n return\n end\n if hash_value.length != hash_size then\n return if errors.include?( :hash_value )\n errors.add( :hash_value, :wrong_length, count: hash_size )\n end\n end\n end",
"def checksums; end",
"def checksum\n Digest::SHA256.file(sample_dmg).hexdigest\nend",
"def file_to_expectation(file_name)\n a = CSV.parse(File.read(\"spec/#{file_name}.csv\"))\n i = 1\n h = a.map do |x| \n _a = [i,{:principal => x[0].to_f, :interest => x[1].to_f}]\n i += 1\n _a\n end\n Hash[*h.flatten]\nend",
"def test_hash_correct\n\t\n\t\tString test_array1 = '2|abb2|George>Amina(16):Henry>James(4):Henry>Cyrus(17):Henry>Kublai(4):George>Rana(1):SYSTEM>Wu(100)|1518892051.753197000|c72d'.split('|').map(&:chomp)\n\n\t\tx = test_array1[0].unpack('U*') + test_array1[1].unpack('U*') + test_array1[2].unpack('U*') + test_array1[3].unpack('U*')\n\t\tsum = 0\n\t\t# x.each { |i| puts x[i] }\n\t\t# x.delete(\"\")\n\t\tx.each { |i| sum += ((x[i].to_i ** 2000) * ((x[i].to_i + 2) ** 21) - ((x[i].to_i + 5) ** 3)) }\n\t\thash = (sum % 65536)\n\t\tputs hash.to_s(16)\n\t\t\n\t\ttest_array2 = '3|c72d|SYSTEM>Henry(100)|1518892051.764563000|7419'.split('|').map(&:chomp)\n\t\t\n\t\t# assert_equal test_str[2,2], '0|'\t\n\tend",
"def process_lines\n\t#file_string is a string array,\n\t#extendable_hash is a hash that is created through this method\n\t\tneeded_lines = []\n\t\t@lines.each do |line|\n\t\t\tunless line.strip.length == 0 || line[0] == '#' #filters empty lines and comments\n\t\t\t\tneeded_lines << line\n\t\t\tend\n\t\tend\n\n\t\t@hash = {}\n\t\tneeded_lines.map do |line| #splits every line at empty spaces\n\t\t\tline = line.split(\" \")\n\t\t\t@hash[line[0]] = line.drop(1) #line.drop(1) returns line without the first (0th) entry\n\t\tend\n\n\n\t\t# needed_lines.map do |line|\n\t\t# \thash[line[0]] = line.drop(1) #line.drop(1) returns line without the first (0th) entry\n\t\t# end\n\n\t\treturn @hash\n\tend",
"def generate_hash(input)\n @freq = analyze_raw(input)\n # Reduce returning unnecessarily large hash be stripping away frequencies < min\n @freq.delete_if {|key, value| value < @@MinWordFrequency}\n end",
"def euler079\n inputs = []\n File.open_euler('keylog.txt').each_line do |line|\n inputs.push(line.chomp)\n end\n inputs.uniq!.sort!\n\n # create hash of all the numbers that exist\n proceeded_freq = inputs.join.split('').uniq.sort.reduce({}) { |a,n| a[n] = []; a }\n\n # populate the hash, for each key, the value is the numbers that follow it\n inputs.each do |n|\n proceeded_freq[n[0].chr].push(n[1].chr)\n proceeded_freq[n[0].chr].push(n[2].chr)\n proceeded_freq[n[1].chr].push(n[2].chr)\n end\n\n proceeded_freq.map { |k,v| v = v.uniq! }\n proceeded_freq = proceeded_freq.sort_by { |k,v| v.length }.reverse\n\n answer = proceeded_freq.reduce(\"\") { |a, n| a << n[0] }.to_i\nend",
"def listFileHashes(baseDir)\n #N Un-normalised, an off-by-one error would occur when 'subtracting' the base dir off the full paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this, we would have nowhere to accumulate the file hash objects\n fileHashes = []\n #N Without this, we would not be executing and parsing the results of the file-listing command\n listFileHashLines(baseDir) do |fileHashLine|\n #N Without this, we would not be parsing the result line containing this file and its hash value\n fileHash = self.hashCommand.parseFileHashLine(baseDir, fileHashLine)\n #N Without this check we would be accumulating spurious nil values returned from listFileHashLines (even though listFileHashLines doesn't actually do that)\n if fileHash != nil\n #N Without this, we would fail to include this file & hash in the list of file hashes.\n fileHashes << fileHash\n end\n end\n return fileHashes\n end",
"def verify_sha1_hash(filename, hash)\n require 'digest/sha1'\n compare_hash(filename, Digest::SHA1, hash)\n end",
"def expected_digest\n hash = {\n 'class' => 'CourseDataUpdateWorker',\n 'queue' => queue_for(@course),\n 'unique_args' => [@course_id]\n }.to_json\n digest = OpenSSL::Digest::MD5.hexdigest hash\n \"uniquejobs:#{digest}\"\n end",
"def manifested_files\n\n manifest_files.inject([]) do |acc, mf|\n\n files = open(mf) do |io|\n\n io.readlines.map do |line|\n digest, path = line.chomp.split /\\s+/, 2\n path\n end\n\n end\n\n (acc + files).uniq\n end\n\n end",
"def requirement_hash(spec = self)\n result = {}\n if String === spec\n parts = spec.split(/\\s*->\\s*/, 3).map(&:strip)\n case parts.size\n when 1\n result[:spec] = ArtifactNamespace.to_hash(parts.first)\n when 2\n if /^\\w+$/ === parts.first\n result[:name] = parts.first\n result[:spec] = ArtifactNamespace.to_hash(parts.last)\n else\n result[:spec] = ArtifactNamespace.to_hash(parts.first)\n result[:requirement] = VersionRequirement.create(parts.last)\n end\n when 3\n result[:name] = parts.first\n result[:spec] = ArtifactNamespace.to_hash(parts[1])\n result[:requirement] = VersionRequirement.create(parts.last)\n end\n else\n result[:spec] = ArtifactNamespace.to_hash(spec)\n end\n result[:name] ||= result[:spec][:id].to_s.to_sym\n result[:requirement] ||= VersionRequirement.create(result[:spec][:version])\n result\n end"
] | [
"0.6164329",
"0.61465913",
"0.6007509",
"0.5970157",
"0.5961918",
"0.592387",
"0.5775693",
"0.5747631",
"0.57236147",
"0.5667557",
"0.5638504",
"0.5620693",
"0.56157726",
"0.5602275",
"0.5580187",
"0.55777556",
"0.557338",
"0.55539995",
"0.5546367",
"0.5531555",
"0.5529126",
"0.5507179",
"0.5502648",
"0.54709125",
"0.5456503",
"0.54307365",
"0.5428001",
"0.5412523",
"0.5366492",
"0.53660697",
"0.53501844",
"0.53456616",
"0.53250086",
"0.5321248",
"0.5319162",
"0.53010225",
"0.52899367",
"0.52899367",
"0.52899367",
"0.52899367",
"0.52899367",
"0.52899367",
"0.52899367",
"0.52897125",
"0.52754956",
"0.5274648",
"0.52732396",
"0.52665716",
"0.52622813",
"0.5256295",
"0.5253928",
"0.52451515",
"0.5240928",
"0.52371895",
"0.52260613",
"0.5215128",
"0.5212119",
"0.5206122",
"0.52045",
"0.5182297",
"0.51680523",
"0.5142884",
"0.5132234",
"0.5126985",
"0.5115805",
"0.51073396",
"0.5102193",
"0.5098146",
"0.5084077",
"0.5081639",
"0.50722516",
"0.5067054",
"0.506511",
"0.5064782",
"0.5058894",
"0.50549525",
"0.5052386",
"0.5040573",
"0.50399506",
"0.50379914",
"0.5027844",
"0.5024958",
"0.5021025",
"0.5018734",
"0.5000986",
"0.5000076",
"0.4992292",
"0.49900007",
"0.4984877",
"0.49816722",
"0.49816602",
"0.49716896",
"0.49699932",
"0.4968532",
"0.49654207",
"0.49599782",
"0.49532965",
"0.4947816",
"0.49453336",
"0.49443528"
] | 0.7514599 | 0 |
Returns the absolute path of primary_repo with a guaranteed trailing slash at the end | def primary_repo_base_dir
File.expand_path(
setting(:relative_path_to_primary_repo),
base_dir(:rtfile_dir)
).sub(/\/?\z/, '') + '/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repo_path\n @config.get_value('GIT_REPO_ROOT')\n end",
"def abspath\n \"#{repo_base_path}/#{self.git_repo_path}\"\n end",
"def repository_root\n File.expand_path(@repo.path + \"/../\")\n end",
"def absolute_repository_path\n File.join(\n OpenProject::Revisions::Git::GitoliteWrapper.gitolite_global_storage_path,\n git_path\n )\n end",
"def repo_path\n @path\n end",
"def repo_name\n # the repo is the last part of the path\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n end",
"def gitolite_repository_name\n if (parent_path = get_full_parent_path).empty?\n project.identifier\n else\n File.join(parent_path, project.identifier)\n end\n end",
"def gitolite_repository_name\n if (parent_path = get_full_parent_path).empty?\n project.identifier\n else\n File.join(parent_path, project.identifier)\n end\n end",
"def repo_path(path)\n File.join(File.expand_path('../../..', $0), path)\n end",
"def repo_path\n if !self.cmd_opt.empty?\n self.fake_path = repo_name\n # real path is something like /jupiler_home/repositories/username/repo_name\n self.real_path = Settings.jup_sh.home + '/' +\n self.username_from_cmd + \"/\" +\n self.fake_path\n return self.real_path\n end\n end",
"def repo_path\n DeliveryGolang::Helpers.repo_path(node)\n end",
"def repo_path\n @repo_path ||= Pathname.new(Dir.pwd).descend { |p| break p if (p + '.git').directory? }\n end",
"def repo_root; end",
"def repository_root\n return unless available?\n root = Licensed::Shell.execute(\"git\", \"rev-parse\", \"--show-toplevel\", allow_failure: true)\n return nil if root.empty?\n root\n end",
"def relative_path\n File.join(@repo, @bundle)\n end",
"def repo_path\n if !self.cmd_opt.empty?\n if self.is_git?\n self.fake_path = self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1]\n self.real_path = Settings.aq_sh.user_home + \"/\" +\n Settings.aq_sh.user_name + \"/\" +\n Settings.git.repo_path + \"/\" +\n self.username_from_cmd + \"/\" +\n self.fake_path\n return self.real_path\n elsif self.is_hg?\n self.fake_path = self.cmd_opt.split(\" \")[1]\n self.real_path = Settings.aq_sh.user_home + \"/\" +\n Settings.aq_sh.user_name + \"/\" +\n Settings.hg.repo_path + \"/\" +\n self.fake_path\n return self.real_path\n end\n end\n end",
"def primary_repo_transforms\n primary_repo_base_dir = File.expand_path(\n File.join(\n config.base_dir(:rtfile_dir),\n config.setting(:relative_path_to_primary_repo)\n )\n )\n\n {\n :base_dir => {\n :from => config.base_dir(:rtfile_dir),\n :to => primary_repo_base_dir + '/',\n },\n :language_code => {\n :from => config.setting(:language_code_3_chars),\n :to => config.setting(:primary_repo_lang_code),\n }\n }\n end",
"def path\n \"repos/#{@user}/#{name}\"\n end",
"def source\n return BASE_SOURCE_URL + '/' + repo_id unless path_extension\n BASE_SOURCE_URL + '/' + repo_id + '/' + path_extension.sub(%r{^\\s*/}, '').sub(%r{/\\s*$}, '')\n end",
"def repo_path\n @repo_path ||= \"/tmp/extension-repo-#{id}\"\n end",
"def corresponding_primary_content_type_base_dir\n # OPTIMIZE: Can we replace this method with #corresponding_content_type_base_dir_in_other_repo ?\n File.expand_path(\n config_setting(:relative_path_to_primary_content_type),\n config_base_dir(:content_type_dir)\n ) + '/'\n end",
"def custom_repo_path(org_label, environment_label, product_label, repo_label)\n prefix = [org_label, environment_label].map { |x| x.gsub(/[^-\\w]/, \"_\") }.join(\"/\")\n prefix + custom_content_path(product_label, repo_label)\n end",
"def repo_path\n current_user = User.current\n # root dir is the system home folder, need to exist prior to app launch\n # e.g. /home\n root_dir = Pathname(Settings.repos.root_dir)\n\n # base dir is aq_git user home folder, need to exist prior to app launch\n # e.g. /home/aq_git\n\n base_dir = root_dir + Settings.repos.repo_user\n\n if self.kind == \"git\"\n repo_path = Settings.git.repo_path\n end\n\n # git dir is where the repositories are gonna be stored, creating if needed\n # e.g. /home/aq_git/git or /home/aq_git/hg\n scm_dir = base_dir + repo_path\n scm_dir.mkdir if base_dir.exist? && !scm_dir.exist?\n\n # repo dir is the repository own path\n # e.g. /home/aq_git/git/username\n if self.owner\n repo_dir = scm_dir + self.owner.login\n elsif current_user\n repo_dir = scm_dir + current_user.login\n end\n repo_dir.mkdir if !repo_dir.exist?\n\n # the dot dir is the .git (or .hg) located in the repository\n # e.g. /home/aq_git/git/username/some_repo.git\n if self.is_git?\n dot_dir = repo_dir + (self.name + \".#{self.kind}\")\n dot_dir.mkdir if !dot_dir.exist?\n end\n\n self.path = dot_dir.to_s\n end",
"def repo_path\n # root dir is system home folder, need to exist prior to app launch\n # /home\n root_dir = Pathname(Settings.application.root_dir)\n\n # base dir is aq_git user home folder, need to exist prior to app launch\n # /home/aq_git\n base_dir = root_dir + Settings.application.repo_user\n\n if self.kind == \"git\"\n repo_path = Settings.application.repo_git_path\n end\n\n # git_dir is where the repositories are gonna be stored, creating if needed\n # /home/aq_git/git or /home/aq_git/hg\n scm_dir = base_dir + repo_path\n scm_dir.mkdir if base_dir.exist? && !scm_dir.exist?\n\n # repo dir is the repository own path\n # /home/aq_git/git/username\n if self.owner\n repo_dir = scm_dir + self.owner.login\n elsif current_user\n repo_dir = scm_dir + current_user.login\n end\n repo_dir.mkdir if !repo_dir.exist?\n\n # the dot dir is the .git (or .hg) located in the repository\n # /home/aq_git/git/username/reposit.git\n if self.is_git?\n dot_dir = repo_dir + (self.name + \".#{self.kind}\")\n dot_dir.mkdir if !dot_dir.exist?\n end\n\n self.path = dot_dir.to_s\n end",
"def full_path_to_remote_dir\n (remote_dir[0] == ?/ ? remote_dir : \"$(pwd)/#{remote_dir}\").chomp('/')\n end",
"def repoSlug()\n return ENV['HOMEBREW_PIPELINE_FORMULA_REPO'].split('/')\n end",
"def full_name repo\n \"#{repo.owner.login}/#{repo.name}\"\n end",
"def repo_path\n @repo.dirstate.copy_map[@path] || @path\n end",
"def repos_path\n ::File.expand_path(@repos_path)\n end",
"def source_repo\n \"#{@user}/#{@repo}\"\n end",
"def path\n return github_url if github_url.is_local_dir?\n\n path_to_name = File.join( @@strategies_location, username, name )\n File.join path_to_name, get_github_repo_name(github_url)\n end",
"def git_path\n if bare\n \"#{path}\"\n else\n \"#{path}/.git\"\n end\n end",
"def get_repo_url\n repo_url = ENV['MXNET_GLUON_REPO'] || DEFAULT_REPO\n repo_url += '/' if repo_url[-1] != '/'\n repo_url\n end",
"def root_path(*args)\n relative = File.join(*args)\n return relative if relative.expand_path == relative\n root.expand_path / relative\n end",
"def root_path(*args)\n relative = File.join(*args)\n return relative if relative.expand_path == relative\n root.expand_path / relative\n end",
"def repo_store_root\n Pathname(Razor.config['repo_store_root'])\n end",
"def repository_display\n if ENV['EAD'].present?\n if File.directory?(Rails.root.join(ENV['EAD']))\n return ENV['EAD'].split(\"\\/\")[-1]\n else\n return ENV['EAD'].split(\"\\/\")[-2]\n end\n end\n end",
"def gitpath\n %x{git config --get remote.origin.url | sed \"s;^.*root/;;\" | sed \"s;\\.git$;;\"}.squish\n end",
"def hg_repo_path\n path = `hg root 2>/dev/null`.strip\n @hg_repo_path ||= path + '/.hg' unless path == ''\nend",
"def full_path\n container.root.join(path)\n end",
"def full_path\n container.root.join(path)\n end",
"def absolute_prefix\n out = \"\"\n out = NATIVE_DIRECTORY_SEPARATOR if ABSOLUTE_GETS_NATIVE_DIRECTORY_SEPARATOR_PREFIX && absolute?\n out\n end",
"def get_svn_path( dir='.' )\n\troot = get_svn_repo_root( dir )\n\turl = get_svn_url( dir )\n\t\n\treturn url.sub( root + '/', '' )\nend",
"def repo_dir; end",
"def repo_path(node)\n node['delivery_builder']['repo'] || File.expand_path('..', __dir__)\n end",
"def repository_base_url(result)\n if result['slug'] && AppConfig[:use_human_readable_urls]\n url = \"repositories/\" + result['slug']\n else\n url = result['uri']\n end\n\n return url\n end",
"def git_path\n File.join(\n user.storage_path,\n 'repositories',\n 'scratchpad')\n end",
"def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end",
"def root_path\n @root_path ||= `git rev-parse --show-toplevel`.chomp\n end",
"def get_path(commit)\n repos_path = File.expand_path('repos')\n File.join(repos_path, commit)\n end",
"def canonical_repository_url\n \"https://#{@settings.host}/scm/#{attributes[:repository_namespace]}/#{attributes[:repository_name]}.git\"\n end",
"def raw_gitdir\n\t\t\twith_dir do\n\t\t\t\treturn Pathname.new(%x/git rev-parse --git-dir/.chomp)\n\t\t\tend\n\t\tend",
"def local\n return Global.git_repository_directory + @address_digest\n end",
"def canonicalize_repo(repo)\n # if they fully-qualified it, we're good\n return repo if repo.start_with?('http', 'git@')\n\n # otherwise, ti's a shortname\n cr = \"git@#{@ghhost || 'github.com'}:#{repo}.git\"\n SugarJar::Log.debug(\"canonicalized #{repo} to #{cr}\")\n cr\n end",
"def repo_url(path = \"\")\n if @repo.url\n url = URI::parse(@repo.url)\n url.path = (url.path + \"/\" + path).gsub(%r'//+', '/')\n url.to_s\n else\n compose_url \"/svc/repo\", @repo.name, path\n end\n end",
"def subdir\n if core_project? or 'profile' == proj_type\n return @local_path.parent.relative_path_from(@platform.local_path + (proj_type + 's'))\n else\n return @local_path.parent.relative_path_from(@platform.local_path + @platform.contrib_path + (proj_type + 's'))\n end\n end",
"def relativize_path(path)\n path.to_s.gsub(/^\\/?#{Regexp.escape(root_path.to_s)}\\/?/, '')\n end",
"def remote_repository\n url = \"#{configuration[:user]}@#{configuration[:domain]}:\"\n @remote_repository ||= if configuration[:repository].include?(url)\n tmp = configuration[:repository].sub(url, \"file://\")\n if tmp.include?(\"~\")\n tmp.sub!(\"~\", \"/home/#{configuration[:user]}\")\n end\n tmp\n else\n configuration[:repository]\n end\n @remote_repository\n end",
"def get_full_parent_path\n parent_parts = []\n p = project\n while p.parent\n parent_id = p.parent.identifier.to_s\n parent_parts.unshift(parent_id)\n p = p.parent\n end\n\n File.join(*parent_parts)\n end",
"def repo\n read_attribute(:repo).presence || self.original_repo\n end",
"def repo_name\n if self.is_git?\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n elsif self.is_hg?\n return self.cmd_opt.split(\" \")[1].split(\"/\")[-1] if !self.cmd_opt.empty?\n end\n end",
"def repo_root\n @repo_root ||=\n begin\n result = execute(%w[git rev-parse --show-toplevel])\n unless result.success?\n raise Overcommit::Exceptions::InvalidGitRepo,\n 'Unable to determine location of GIT_DIR. ' \\\n 'Not a recognizable Git repository!'\n end\n result.stdout.chomp(\"\\n\")\n end\n end",
"def github_repo\n # GitHub allows underscores, hyphens and dots in repo names\n # but only hyphens in user/organisation names (as well as alphanumeric).\n repository_url.scan(/:([A-Za-z0-9-]+\\/[\\w.-]+)\\.git$/).join\n end",
"def relativize_root_path(path)\n path.to_s.sub(/^#{Regexp.escape(@root)}/, '$root')\n end",
"def root_path\n RUBYCOCOA_ROOT.to_s\n end",
"def repo_dir(repo)\n RightScraper::Retrievers::Base.repo_dir(@options[:basedir], repo)\n end",
"def working_dir\n return nil if !repo || !user\n return \"#{Bini.data_dir}/repos/#{user}/#{repo}\"\n end",
"def final_path_component(path)\n path.split(PATH_SEPARATOR)[-1].split[0]\n end",
"def get_svn_repo_root( dir='.' )\n\tinfo = get_svn_info( dir )\n\treturn info['Repository Root']\nend",
"def getRepositoryPath\n return @REPOSITORYPATHORSELECT\n end",
"def git_root_till_home\n Pathname.new(Dir.pwd).ascend do |dir_pathname|\n return dir_pathname if File.directory?(\"#{dir_pathname}/.git\")\n return nil if dir_pathname.to_s == home_dir\n end\n end",
"def repository_identifier\n \"#{gitolite_repository_name}.git\"\n end",
"def uri\n \"file://\" + self.repos_path\n end",
"def find_repo_dir(here=Pathname.pwd)\n if (here + '.git').exist?\n return here\n else\n find_repo_dir(here.dirname) unless '/' == here.to_s\n end\nend",
"def path(key = '')\n @path ||= File.join(File.expand_path(@options[:repo]), key)\n end",
"def path(key = '')\n @path ||= File.join(File.expand_path(@options[:repo]), key)\n end",
"def repo\n if @repo == NRSER::NO_ARG\n @repo = QB::Repo.from_path root_path\n end\n \n @repo\n end",
"def relative_path\n @relative_path ||= absolute_path.sub(/^#{Bookshelf::remote_folder}\\/?/,'')\n end",
"def maven_repository_path\n command = \"#{package_management_command} help:evaluate -Dexpression=settings.localRepository -q -DforceStdout\"\n command += \" #{@maven_options}\" unless @maven_options.nil?\n stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }\n raise \"Command '#{command}' failed to execute: #{stderr}\" unless status.success?\n\n Pathname(stdout)\n end",
"def dir\n # config.repos_dir + @name\n end",
"def repo_slug_from_url(url)\n url[%r{github.com[/:]([^/]*/(?:(?!\\.git)[^/])*)\\.*}, 1]\nend",
"def path(ident=:default)\n tail = identifying_path_part(ident)\n if tail.empty?\n base_path\n else\n File.join base_path, tail\n end\n end",
"def rpath\n if (parent.nil? and domain) or (parent and parent.domain != domain)\n return ''\n else\n if parent\n rp = parent.rpath\n unless rp.blank?\n rp + '/' + path\n else\n path\n end\n else\n path\n end\n end\n end",
"def canonical_path\n p = path.gsub(/\\/+/,'/')\n p.length > 1 ? p.chomp('/') : p\n end",
"def gitreponame\n g = Git.open(Dir.pwd)\n control_repo = g.config('remote.origin.url').to_s\n control_repo = control_repo.split('/')\n control_repo = control_repo[-1].chomp.split('.')\n control_repo = control_repo[0]\n output = \"\\\"control_repo\\\": \" + '\"' + control_repo + '\",'\n puts output\nend",
"def subauthorities_path\n if config[:local_path].starts_with?(File::Separator)\n config[:local_path]\n else\n Rails.root.join(config[:local_path]).to_s # TODO: Rails.root.join returns class Pathname, which may be ok. Added to_s because of failing regression test.\n end\n end",
"def humanish(uri)\n uri.path.split('/').last.gsub('.git', '')\n end",
"def repository\n return options[:repository] if options.has_key? :repository\n return IO.read(skeleton_dir).strip if skeleton_dir and test(?f, skeleton_dir)\n nil\n end",
"def calc_dir(page_base)\n page_full_path = File.join(GIT_REPO, unwiki(page_base))\n end",
"def id_for_repo(repo)\n \"#{repo.url}##{repo.version}\"\n end",
"def master_path\n @master_path ||= (user_configuration_from_key('master_solr', 'path') || path)\n end",
"def relative_path\n return self.avatar.match(/http[^|]*/)[0].to_s\n end",
"def groupon_path(repo)\n github = \"github.groupondev.com\"\n ENV[\"INTERNAL_GEMS_OVER_SSH\"] ? \"git@#{github}:#{repo}.git\" : \"https://#{github}/#{repo}.git\"\nend",
"def get_replica_path(replica_base_path)\n return File.join(replica_base_path, @loc_key)\n end",
"def relroot\n Pathname.new(File.expand_path(path)).\n relative_path_from(Pathname.new(File.expand_path(root))).to_s\n end",
"def home(subcomponent = \"\")\n File.expand_path(\"#{@basepath}/#{subcomponent}\")\n end",
"def get_repository_identifier\n repo_namespace = get_repository_namespace\n repo_name = get_repository_name || get_project_identifier\n identifier = repo_namespace.present? ? \"#{repo_namespace}_#{repo_name}\" : repo_name\n return identifier\n end",
"def repo_root(directory = nil)\n directory = File.expand_path('.') if directory.nil?\n return nil unless repository?(directory)\n\n previous_dir = File.expand_path('.')\n Dir.chdir(directory)\n output = command_stdout('git root')\n Dir.chdir(previous_dir)\n output\n end",
"def git_repo_name\n path = File.expand_path(File.dirname(__FILE__))\n # the path looks like /repos/bender.git/hooks\n path.split(%r{/})[-2]\nend",
"def repository_value(item)\n unless item.nil? || item.is_a?(String) || item.is_a?(Symbol)\n (repo = get_value(item, :repository)) and return repo\n (repo = get_value(item, :emma_repository)) and return repo\n (repo = get_value(item, :repo)) and return repo\n item = get_value(item, :emma_recordId)\n end\n item.to_s.strip.split('-').first.presence if item.present?\n end"
] | [
"0.6840974",
"0.68346095",
"0.6793713",
"0.6643713",
"0.65871274",
"0.6514559",
"0.65050054",
"0.6468484",
"0.63940626",
"0.6347272",
"0.6298935",
"0.6293408",
"0.62834775",
"0.626672",
"0.6258216",
"0.625578",
"0.6234172",
"0.6213185",
"0.61406183",
"0.61352944",
"0.612355",
"0.60894144",
"0.60797524",
"0.6059304",
"0.6040366",
"0.6031172",
"0.60265434",
"0.5962265",
"0.5959208",
"0.59342766",
"0.59340954",
"0.5934052",
"0.5920631",
"0.5916537",
"0.5916537",
"0.5899173",
"0.5895922",
"0.58859336",
"0.5879619",
"0.58721226",
"0.58721226",
"0.58488667",
"0.584101",
"0.5840075",
"0.5836193",
"0.58351153",
"0.58274496",
"0.5825336",
"0.58044386",
"0.5800181",
"0.57798827",
"0.57764924",
"0.57688224",
"0.57440615",
"0.5730779",
"0.57231873",
"0.5722671",
"0.57114744",
"0.5696659",
"0.56962913",
"0.56902987",
"0.5687696",
"0.565952",
"0.5655324",
"0.5652208",
"0.5632649",
"0.5627504",
"0.56028646",
"0.55973727",
"0.5593346",
"0.55869156",
"0.5586355",
"0.5583159",
"0.55827916",
"0.55815125",
"0.55815125",
"0.55658597",
"0.5563068",
"0.5555729",
"0.55457777",
"0.5544175",
"0.55413425",
"0.55355865",
"0.553089",
"0.5525574",
"0.552438",
"0.5523977",
"0.5520779",
"0.55198956",
"0.549567",
"0.54882395",
"0.54836625",
"0.54814404",
"0.5464382",
"0.5463292",
"0.545722",
"0.5455939",
"0.54556847",
"0.54549956",
"0.5454338"
] | 0.7727887 | 0 |
Returns a key's value from container. Raises if an unknown key is requested. | def get_config_val(container, key, raise_on_unknown_key = true)
key = key.to_sym
if raise_on_unknown_key && !container.keys.include?(key)
raise RtfileError.new("You requested an unknown key: #{ key.inspect }")
end
container[key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(key)\n position = find(key)\n if position != nil\n @values[position]\n else\n nil\n end\n end",
"def get_value(key)\n self[key]\n end",
"def [](key)\n find_value(key)\n end",
"def get_value(collection, key)\n @data[collection][key]\n end",
"def get(key)\n position = search(key)\n return nil if (key <=> @keys[position]) != 0\n @values[position]\n end",
"def get_item(key)\n self[key]\n end",
"def get(key)\n index = key_index(key)\n if( index )\n @i_values.get(index)\n else\n nil\n end\n end",
"def get(key)\n get_all(key).first\n end",
"def get_value (key)\r\n @redis.get key\r\n end",
"def get_key_value(key)\n if v = storage.get(key.object_id)\n return key.object_id, v\n end\n storage.get_candidates(key.hash).find do |k,v|\n candidate_key = get_object(k) or next\n candidate_key.eql? key\n end\n end",
"def get(key)\n index = key_index(key)\n if( index )\n self.values.get(index)\n else\n nil\n end\n end",
"def fetch_value( oid, key )\n\t\toid = normalize_oid( oid )\n\t\tkey = normalize_key( key )\n\t\tdata = @storage[ oid ] or return nil\n\n\t\treturn data[ key ]\n\tend",
"def getValue(key)\r\n \r\n return @aHash[key]\r\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def get(key)\n end",
"def value(key)\n @hash[key]\n end",
"def find(key)\n # TODO(himanshujaju) - possible improvement by not checking for contains.\n if contains?(key)\n return @key_data[key].value\n end\n\n return nil\n end",
"def get(key)\n @hash.get(key)\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def get(key)\n @hash[key]\n end",
"def get(key)\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def [](key = nil)\n return @collection unless key\n\n result = @collection.find { |f| f.name == key }\n return result.value if result\n\n nil\n end",
"def generic_get(key)\n data[key]\n end",
"def get_key_value_\n @redis.hget @url, 'key'\n end",
"def get(key)\n \n end",
"def get(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key \n return ele[1]\n end\n end\n end",
"def [](key)\n return nil if @collection.nil?\n return_item_value key\n end",
"def value_of(key)\n @root.value_of(key)\n end",
"def fetch(key, value = nil)\n if read = self[key]\n return read\n end\n block_given? ? yield(key) : value\n end",
"def lookup(key)\n if key_pair = pair(key, hash(key))\n key_pair[1]\n end\n end",
"def value\n v = connection.get(key)\n rescue Memcached::NotFound\n if block\n value = block.call\n value\n end\n end",
"def get(key)\n @map[key]\n end",
"def get(key)\n return nil unless @items.key?(key)\n @items[key].call\n end",
"def [](key)\n fetch(key)\n end",
"def get(key)\n @first.get(key)\n end",
"def [](key)\n entry = find_entry(key)\n return(entry.nil? ? nil : entry[1])\n end",
"def [](key)\n result = default(key)\n result ? result.value : nil\n end",
"def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end",
"def get(key)\n return do_get(key, false)\n end",
"def get(key)\n node = get_rec(@root, key, 0)\n return nil if node.nil?\n return node.value\n end",
"def get(key, default=nil)\n find = KeyValue.find_by_key(key)\n find ? find.value : default\n end",
"def [](key)\n @monitor.synchronize do\n _, value = get(key)\n value\n end\n end",
"def get(key)\n self.map_var.each do |pair|\n return pair[1] if pair[0] == key\n end\n nil\n end",
"def get(key)\n node = _get(@root, key)\n return nil unless node\n node.value\n end",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def get(key)\n raise NotImplementedError\n end",
"def obtain!(key)\n raise \"Missing key #{key}\" unless @hash.key?(key)\n @hash[key]\n end",
"def [](key)\n\n lookup(key.to_s)\n end",
"def find(key)\n raise UnknownEntity unless key?(key)\n\n collection[ukey(key)]\n end",
"def get(key)\r\n\t\treturn nil if !key\r\n\t\t# Get the hash of our key\r\n\t\tindex = key.hash % @size\r\n\t\t# If location in array is empty then return nil otherwise find the \r\n\t\t# key and return associated value from the list\r\n\t\treturn nil if !@arr[index]\r\n\t\treturn @arr[index].find(key)\r\n\tend",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def get(key)\n _get_from_params(key) || _get_from_values(key)\n end",
"def [](key)\n dummy = Pair.new(key,nil)\n pair = @tree.get(dummy)\n return nil unless pair\n return pair.value\n end",
"def [](key)\n\t\t\traise_on_undeclared(key)\n\t\t\treturn @storage[key]\n\t\tend",
"def get(key)\n bucket = @map[key.hash % @size]\n pair = bucket.find {|k, v| k == key}\n if pair \n pair[1]\n else\n -1\n end\n end",
"def [](key)\n\t\t\t\treturn(lookup(key))\n\t\t\tend",
"def [](key)\n\t\t\t\treturn(lookup(key))\n\t\t\tend",
"def [](key)\n self.get(key)\n end",
"def fetch(key)\n if key.empty?\n return @value\n end\n child = @children[key.shift]\n if child\n child.fetch(key)\n else\n return nil\n end\n end",
"def get(key)\n node_for(key).get(key)\n end",
"def get key\n deserialize backend.get key.to_s rescue nil\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def value_for_data(key, item, value_key = :value)\n if item and item[:data] and item[:data][key]\n return item[:data][key][value_key]\n end\n return nil\n end",
"def get_value(item, key, default: nil, **)\n return if key.blank?\n if key.is_a?(Array)\n key.find { |k| (v = get_value(item, k)) and break v }\n elsif item.respond_to?(key)\n item.send(key)\n elsif item.respond_to?(:emma_metadata) # Upload, etc.\n item.emma_metadata&.dig(key.to_sym)\n elsif item.is_a?(Hash)\n item[key.to_sym] || item[key.to_s]\n end.presence || default\n end",
"def fetch(key)\n result.fetch(key)\n end",
"def get key; call key; end",
"def get_by_key(key)\n @store_[key] || YakvdConstants.key_not_found\n end",
"def get_single_key(key)\n key = @size+key if key < 0\n r = @results[key]\n unless r.nil? && key < @size\n r\n else\n retrieve_for_index(key)\n @results[key]\n end\n end",
"def get!(key)\n get(key) || raise(Cooler::KeyNotFound)\n end",
"def [](key)\n entry = @data.find { |d| d[:key] == key && d[:operation] != :remove }\n return entry[:value] if entry\n\n nil\n end",
"def get(key)\n value = @data[key]\n validate!(key, value)\n end",
"def get_value(section, key)\n if section.nil?\n raise TypeError.new('nil not allowed')\n end\n section = 'default' if section.empty?\n get_key_string(section, key)\n end",
"def find(key)\n if !contains?(key)\n return nil\n end\n\n @semaphore.synchronize {\n @internal_clock += 1\n previous_data = @key_data[key]\n update_access_time_locked(key, @internal_clock, previous_data.access_time)\n\n return previous_data.value\n }\n end",
"def get(vault, key)\n @redis.get value_key(vault, key)\n end",
"def lookup(key)\n @map.each { |k, v| return v if key == k }\n nil\n end",
"def fetch_value(key)\n val = fetch_nested(key)\n return val if self[:no_pruning].include?(key)\n Prunable::VALUES.include?(val) ? Prunable::Value : val\n end",
"def get(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n return @a[row][column][1] \n else\n return -1\n end\n end",
"def get(key, value = nil, *)\n if head && blob = head.commit.tree / key_for(key)\n decode(blob.data)\n end\n end",
"def get(key, value = nil, *)\n if head && blob = head.commit.tree / key_for(key)\n decode(blob.data)\n end\n end",
"def [](key)\n current_node = @buckets[index(key, size)].head\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n while current_node.key != key\n current_node = current_node.next\n break unless current_node\n end\n\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n\n return current_node.value\n end",
"def lookup(key, container_lookup=false)\n\n Ruote.lookup(h.fields, key, container_lookup)\n end",
"def [](key)\n index = self.index(key, @items.length)\n if !@items[index].nil?\n current = @items[index].head\n until current.nil?\n if current.key === key\n return current.value\n else\n current = current.next\n end\n end\n end\n end",
"def get(key)\n response = request(:get, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n if data.is_a?(Array)\n data.each_with_object({}) do |e, acc|\n acc[e[S_KEY]] = e[S_VALUE]\n end\n else\n data[S_VALUE]\n end\n else\n nil\n end\n end",
"def [](key)\n resolve(key)\n end",
"def get(key)\n v = Nvmkv::kv_get(@kv_id, @pool_id, key)\n return (v != nil ? NVMKVValue.new(v) : nil)\n end",
"def get(key)\n @content[key]\n end",
"def get(key)\n @content[key]\n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def get_value_for_key(opts = {})\n data, _status_code, _headers = get_value_for_key_with_http_info(opts)\n data\n end"
] | [
"0.73172235",
"0.7229446",
"0.7085598",
"0.7029533",
"0.6913697",
"0.69006",
"0.68984866",
"0.68797725",
"0.68726885",
"0.68641365",
"0.6853405",
"0.6795311",
"0.6770131",
"0.6765758",
"0.6765758",
"0.6765758",
"0.6765758",
"0.67622083",
"0.6749583",
"0.6721235",
"0.6697227",
"0.6693805",
"0.66770357",
"0.66532874",
"0.6642622",
"0.6638169",
"0.6619975",
"0.659644",
"0.65797406",
"0.65673804",
"0.6564909",
"0.6552626",
"0.65445346",
"0.65439653",
"0.65384424",
"0.6517252",
"0.65101796",
"0.6475573",
"0.64741594",
"0.64637166",
"0.64611715",
"0.64500594",
"0.6423316",
"0.6420775",
"0.6410838",
"0.64017767",
"0.63962185",
"0.6395175",
"0.6381996",
"0.6381917",
"0.6381917",
"0.6381567",
"0.63758534",
"0.6374363",
"0.63743055",
"0.63668",
"0.63664454",
"0.636555",
"0.635979",
"0.6329412",
"0.63245696",
"0.631914",
"0.631914",
"0.6312379",
"0.63082606",
"0.6282773",
"0.6282503",
"0.62802535",
"0.62802535",
"0.62763876",
"0.62763876",
"0.62763876",
"0.62763876",
"0.62666625",
"0.6250345",
"0.6243419",
"0.6240574",
"0.6235318",
"0.6223945",
"0.6223924",
"0.6221415",
"0.6218559",
"0.6217396",
"0.6211039",
"0.62086105",
"0.62082434",
"0.62081915",
"0.6202715",
"0.62003666",
"0.62003666",
"0.61917835",
"0.61843574",
"0.61826384",
"0.6178066",
"0.6177991",
"0.61754656",
"0.617109",
"0.617109",
"0.61680925",
"0.61525357"
] | 0.74965435 | 0 |
An interesting number is one with at least 3 digits, in which the digits are either incrementing or decrementing. Examples: interesting_number(789) => true interesting_number(321) => true interesting_number(798) => false interesting_number(6) => false interesting_number(23) => false When the digits are incrementing, 0 comes after 9: interesting_number(7890) => true When the digits are decrementing, 0 comes after 1: interesting_number(3210) => true | def interesting_number(number)
numbers = number.digits.reverse
puts false if numbers.length < 3
i = 0
# Descending
if numbers[0] > numbers[1]
numbers.each - 1 do |num|
numbers[i] == numbers[i+1] - 1 ? i+1 : false
end
puts true
# Ascending
elsif numbers[0] < numbers[1]
numbers.each do |num|
numbers[i] == numbers[i+1] + 1 ? i+1 : false
end
puts true
else
puts false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interesting_number(number)\n #check if the length is greater than 3 digits\n number_in_array = number.digits.reverse\n return false if number_in_array.length < 3\n increasing_numbers?(number_in_array)\n decreasing_numbers?(number_in_array)\nend",
"def interesting_number(number)\n return false if number.to_s.split(\"\").length < 3 \n number.to_s.split(\"\").sort[0] == \"0\" ? number.to_s.split(\"\").delete_at(0) && number.to_s.split(\"\").push(\"0\") : x = x\n return number.to_s.split(\"\")[0] < number.to_s.split(\"\")[-1] ? number.to_s.split(\"\").sort == number.to_s.split(\"\") || false : number.to_s.split(\"\").sort.reverse == number.to_s.split(\"\") || false\nend",
"def by_three?(number)\n if number % 3 == 0\n return true\n else\n return false\n end\nend",
"def featured_num?(num)\n return false unless num.odd?\n return false unless num % 7 == 0\n return false unless num.digits.size == num.digits.uniq.size\n true\nend",
"def featured_num?(num)\n num.odd? && num % 7 == 0 && num.digits.uniq == num.digits\nend",
"def by_three?(number)\n if number%3 == 0\n return true\n else\n return false\n end\nend",
"def featured?(num)\n num.odd? && num % 7 == 0 && num.digits.uniq.size == num.digits.size\nend",
"def valid_number?\n /\\d{3}/ =~ self.number ? true : false\n end",
"def testNumber(number)\n\n doubleFound = false\n previous = nil\n inARow = 0\n\n # Loop through each digit.\n for digit in number.split('')\n\n if previous == nil\n previous = digit.to_i\n elsif digit.to_i == previous\n inARow += 1\n next # Skip re-initialization at the bottom of the loop.\n elsif digit.to_i < previous\n return false # Short-circuit if this number is greater than the previous.\n end\n\n # A double was only found if the number of identical numbers in\n # a row is two.\n doubleFound = true if inARow == 2\n\n # Re-initialize variables to account for the new number that was reached.\n previous = digit.to_i\n inARow = 1\n end\n\n \n return doubleFound || inARow == 2\nend",
"def valid?\n digits = ''\n # double every other number starting with the next to last\n # and working backwards\n @number.split('').reverse.each_with_index do |d,i|\n digits += d if i%2 == 0\n digits += (d.to_i*2).to_s if i%2 == 1\n end\n\n # sum the resulting digits, mod with ten, check against 0\n digits.split('').inject(0){|sum,d| sum+d.to_i}%10 == 0\n end",
"def number_is_valid_2?(number)\n str = number.to_s\n str.scan(/(\\d)\\1+/).length - str.scan(/(\\d)\\1\\1+/).length > 0\nend",
"def sequential(number)\r\n # number.digits.reverse.each_with_index do |num, idx|\r\n # if idx + 1 == num\r\n # return true\r\n # end\r\n # end\r\n \r\n number.digits.reverse.all? {|num| num.index + 1 == num }\r\nend",
"def by_three?(n)\n return n % 3 == 0\nend",
"def valid(number)\n puts '---------------------------valid?'\n digits = ''\n # double every other number starting with the next to last\n # and working backwards\n number.split('').reverse.each_with_index do |d,i|\n digits += d if i%2 == 0\n digits += (d.to_i*2).to_s if i%2 == 1\n end\n\n # sum the resulting digits, mod with ten, check against 0\n digits.split('').inject(0){|sum,d| sum+d.to_i}%10 == 0\n\n # puts '=============== !!!!valid always returning true for testing !!!!==========='\n # return true #just for testing\n end",
"def featured?(num)\n chars = num.to_s.chars\n num % 7 == 0 && num.odd? && chars.none? { |char| chars.count(char) > 1 }\nend",
"def colorful?(number)\n if number.class == Integer\n colorful_check = []\n individual_digits = number.digits.reverse\n colorful_check << individual_digits\n colorful_check << advancing_mult(individual_digits) if individual_digits.size > 1\n colorful_check << full_mult(individual_digits) if individual_digits.size > 2\n return colorful_check.flatten.size == colorful_check.flatten.uniq.size\n end\n false\nend",
"def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend",
"def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number > 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend",
"def digits_repeat?(number)\n number.to_s.chars.any? { |s| number.to_s.count(s) > 1 }\nend",
"def num_valid?\r\n number = ''\r\n # (1)need to split the number down first to handle it digit by digit\r\n # (2)because number length can change, better to reverse it and go front to back\r\n # (3)put through an each block to loop through the digits, adding with_index to help the modulo\r\n # (4)using a modulo to apply *2 if remainder is not 0 (i.e. every other number starting at position 1, using the index)\r\n # (5)building up the number string with << (could use += but no need to create a new object every time)\r\n @num.split('').reverse.each_with_index do |digit, index|\r\n number << digit if index%2 == 0\r\n number << (digit.to_i*2).to_s if index%2 != 0\r\n end\r\n\r\n # lastly have to check the result added together modulo's to zero\r\n # consulted http://blog.jayfields.com/2008/03/ruby-inject.html for inject syntax refresher\r\n # (1)need to split the number down into an array so inject() can turn them to_i and give us the sum\r\n # (2)using a modulo to ensure the final sum is a multiple of 10\r\n number.split('').inject { |r,e| r.to_i + e.to_i } % 10 == 0\r\n end",
"def one_followed_by_zeros?(number)\n digits = number.to_s.split(\"\")\n first_digit = digits.shift\n first_digit.to_i == 1 && digits.size > 0 && digits.map(&:to_i).all?(&:zero?)\n end",
"def featured?(num)\n chars = num.to_s.split(//)\n num.odd? && (num % 7).zero? && chars.size == chars.uniq.size\nend",
"def digits_repeat?(number)\n !(number.to_s.chars.eql? number.to_s.chars.uniq)\nend",
"def featured2(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend",
"def by_three?(x)\n if x % 3 == 0 \n return true\n else \n return false \n end\nend",
"def featured(int)\n int += 1\n int += 1 until int % 7 == 0 && int.odd?\n \n loop do\n double_check = int.to_s.split(\"\")\n if double_check.uniq == double_check\n return int\n else\n int += 14\n end \n break if int >= 9_876_543_210 \n end\n \"There is no possible number that fulfills those requirements\"\nend",
"def num_check(number)\nputs /^(1\\s?)?(\\(\\d{3}\\)|\\d{3})[\\s\\-]?\\d{3}[\\s\\-]?\\d{4}$/.match?(number)\nend",
"def either_only(number)\n if (number % 3 ==0 || number % 5 ==0) && !(number % 3 == 00 && number % 5 == 0)\n return true\n else\n return false\n end\nend",
"def featured(integer)\n return \"There is no possible number that fulfills those requirements\" if \n integer >= 9_876_543_210\n integer += 1\n until integer % 7 == 0 && integer.odd? && integer.digits.uniq! == nil\n integer += 1\n end\n integer\nend",
"def valid?(num)\n odd = false\n num.to_s.gsub(/\\D/,'').reverse.split('').map(&:to_i).collect { |d|\n d *= 2 if odd = !odd\n d > 9 ? d - 9 : d\n }.inject(:+) % 10 == 0\n end",
"def magic_number?(n)\n n.to_s.split('').each.map {|ch| ch.to_i}.reduce(:+) == 7 \nend",
"def number_is_valid_1?(number)\n number.to_s =~ /(\\d)\\1/\nend",
"def quick_num_checker(num)\n num = num.to_s\n if num == \"5\"\n return true\n elsif num == \"1\"\n return false\n elsif num == \"2\"\n return true\n elsif num == \"3\"\n return true\n elsif num == \"7\"\n return true \n elsif num.include?(\"0\") || num.include?(\"2\") || num.include?(\"4\") || num.include?(\"5\") || num.include?(\"6\") || num.include?(\"8\")\n return false\n # elsif num[-1]==\"2\"\n # return false\n # elsif num[-1]==\"4\"\n # return false\n # elsif num[-1]==\"5\"\n # return false\n # elsif num[-1]==\"6\"\n # return false\n # elsif num[-1]==\"8\"\n # return false\n else\n return true\n end\nend",
"def divisible_by_three(number)\n if number % 3 == 0 \n return true\n else \n return false \n end\nend",
"def divisible_thrice(number)\n return (number % 3 == 0)\nend",
"def can_be_divided_by_three(number)\n is_divisible_by_3 = number % 3\n is_divisible_by_3 == 0\nend",
"def featured(number)\n number += 1\n\n until number % 7 == 0 && number.odd?\n number += 1\n end\n\n loop do\n if number.digits.uniq == number.digits\n return number\n else\n number += 14\n end\n break if number.digits.size > 10\n end\n\n \"Error\"\nend",
"def featured(int)\n for num in (int + 1...9_999_999_999) \n return num if num.odd? && num % 7 == 0 && num.digits == num.digits.uniq\n end\n \"There is no possible number that fulfills those requirements\"\nend",
"def divisible_by_three?(number)\n number % 3 == 0\nend",
"def featured(int)\n loop do \n int += 1\n if int.odd? && int % 7 == 0\n return int if int.to_s.chars.uniq == int.to_s.chars\n end\n break if int == 9_999_999\n end\n \"There is no possible number that fulfils those requirements\"\nend",
"def number_is_valid? number\n true if number.join('').to_i.to_s == number.join('')\nend",
"def cheat number\n if number > 0 && number < 7\n @numberShowing = number\n return true\n end\n return false\n end",
"def isValidNumber(number)\t\t\n\t\t@sum = 0\n\t\t(0..8).each do |position| \n\t\t\t@digit = number.to_s[position].to_i\n\t\t\t@sum += @digit * (9 - position)\n\t\tend\n\t\t@sum % 11 == 0\n\tend",
"def featured(integer)\n return \"Error: There is no possible number that fulfills those requirements\" if integer >= 9_876_543_210\n counter = integer + 1\n counter += 1 until counter % 7 == 0 && counter.odd?\n \n loop do\n return counter if counter.digits.uniq.size == counter.digits.size\n counter += 14\n end\nend",
"def multipleOfThree(n)\n\tn = n.to_i\n\tn % 3 == 0 ? \"True\" : \"False\"\nend",
"def should_we_sail?(number)\n if number == 1 || number == 2 || number == 3\n true\n else\n false\n end\nend",
"def featured(i) # found digits method but only works > v2.4 so...\n i = i - i % 7\n loop do\n i += 7\n list = []\n x = i\n while x > 0 do\n list.unshift(x % 10)\n x /= 10\n end\n if list.length > 9; return \"There is no possible number that fulfills those requirements\" end\n if list == list.uniq; break end\n end \n i\nend",
"def is_featured?(num)\n if !num.odd?\n return false\n elsif num % 7 != 0\n return false\n elsif num.to_s.chars.uniq.length != num.to_s.length\n return false\n else\n true\n end\nend",
"def validate_num(number)\n number.to_i.to_s == number && number.to_i > 0\nend",
"def meets_qualifications?(num_string)\n num_string[1, 3].to_i % 2 == 0 &&\n num_string[2, 3].to_i % 3 == 0 &&\n num_string[3, 3].to_i % 5 == 0 &&\n num_string[4, 3].to_i % 7 == 0 &&\n num_string[5, 3].to_i % 11 == 0 &&\n num_string[6, 3].to_i % 13 == 0 &&\n num_string[7, 3].to_i % 17 == 0\nend",
"def is_divisible_by_three?(number)\n return true if number % 3 == 0\nend",
"def no_repeat?(number)\n digits = number.to_s.chars\n seen = []\n digits.each do |digit|\n return false if seen.include?(digit)\n seen << digit\n end\n true\nend",
"def tired?(digits=nil) \n # ignore the arg, go with your guts\n (rand * 10 < 3)\n end",
"def three_numbers(str)\n digits = str.split.map { |word| word.scan(/\\d+/).sort_by(&:size) }\n digits.each do |set|\n if set.size == 2 && set.first.size == 1 && set.last.size == 2\n set[1], set[2] = set.last[0], set.last[1]\n end\n set.map!(&:to_i).uniq!\n return false unless set.size == 3\n end\n true\nend",
"def featured(number)\n featured = 0\n loop do \n number += 1\n if number % 7 == 0 &&\n number.odd? &&\n number.to_s.length == number.to_s.chars.uniq.length\n featured = number\n break\n end\n if number.to_s.length > 10\n puts \"Invalid\"\n featured = 0\n break\n end\n end\n featured\nend",
"def is_odd3?(int)\n if int.remainder(2) == 0\n return false\n else\n return true\n end\nend",
"def check_numbers(data)\n hash = {}\n\n data.each do |number|\n integer = number.to_i\n\n if integer > 0 && integer < 10\n if hash[integer]\n return false\n else\n hash[integer] = 1\n end\n end\n end\n\n return true\nend",
"def featured(num)\n num += 1\n num += 1 until num.odd? && (num % 7).zero?\n loop do\n return num if num.to_s.chars.size == num.to_s.chars.uniq.size\n num += 14\n break if num > 9_876_543_210\n end\n 'There is no possible number that fulfills those requirements'\nend",
"def double_number?(number)\n numstring = number.to_s\n if numstring.length.even?\n midpoint = numstring.length/2\n if numstring.slice(0, midpoint) == numstring.slice(-midpoint, midpoint)\n return true\n end\n end\n\n return false\nend",
"def featured?(num)\n num.odd? && num.to_s.chars.uniq.size == num.to_s.chars.size\nend",
"def valid_number?(num)\n num.to_i.to_s == num && num.to_i > 0 && !num.empty?\nend",
"def can_be_divided_by_three_and_five(number)\n is_divisible_by_3 = number % 3\n is_divisible_by_5 = number % 5\n is_divisible_by_3 == 0 && is_divisible_by_5 == 0\nend",
"def all_digits_odd?(number)\n number.to_s.split(//).each_with_index do |digit,index|\n if index == 0 && digit.to_i == 2\n #Don't return false if first digit is 2\n elsif digit.to_i%2==0\n return false\n end\n end\n return true\nend",
"def only_odd_digits?(number)\n digits = number.to_s.split(//)\n return true if number == 2\n digits.each do |digit|\n return false if digit.to_i%2==0\n end\n return true\nend",
"def either_only(number)\r\n if (number % 3 == 0 || number % 5 == 0) && !(number % 3 == 0 && number % 5 == 0)\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def check_digit(number: 0)\n sum = 0\n number.to_s.chars.each_with_index do |digit, idx|\n position = idx + 1\n sum += (digit.to_i * (11 - position))\n end\n result = 11 - (sum % 11)\n\n # A value of 11 is considered the same as 0\n # See https://en.wikipedia.org/wiki/NHS_number\n return 0 if result == 11\n\n result\n end",
"def digits_condition\n @number.scan(/\\D/).empty?\n end",
"def featured(num)\n loop do\n num += num % 7 == 0 ? 7 : 1\n num_str = num.to_s.chars\n return num if num.odd? && num % 7 == 0 && num_str.uniq == num_str\n break if num >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend",
"def narcissistic?(value)\n digit_count = value.digits.length\n return value == value.digits.map! { |d| d**digit_count }.reduce(:+)\nend",
"def divisible_by_three(num)\n num%3 == 0 ? true : false\nend",
"def isvalid(n)\n\tcars = n.chars.reduce(0) { |sum, c| sum + $digits[c] }\n\t#puts \"n #{n} cars #{cars}\"\n\treturn n.to_i == cars\nend",
"def checkdigit(number)\n\t\t\tdigits = number.to_s.reverse.scan(/\\d/).map { |x| x.to_i }\n\t\t\tdigits = digits.each_with_index.map { |d, i|\n\t\t\t d *= 2 if i.even?\n\t\t\t d > 9 ? d - 9 : d\n\t\t\t}\n\t\t\tsum = digits.inject(0) { |m, x| m + x }\n\t\t\tmod = 10 - sum % 10\n\t\t\tmod==10 ? 0 : mod\n \tend",
"def calculate_check_digit\n sum = digits.first(12).each_with_index.sum do |digit, index|\n index.even? ? digit : (digit * 3)\n end\n remainder = sum % 10\n remainder.zero? ? remainder : (10 - remainder)\n end",
"def narcissistic?(num)\n digits = num.to_s.chars.map(&:to_i)\n pwrs = digits.map! { |digit| digit**digits.size }\n pwrs.reduce(:+) == num\nend",
"def last_digit_odd?(int)\n # your code goes here\n puts int.digits.first.odd?\nend",
"def contains_number?(item) #analyse chaque login pour détecter la présence d'au moins un chiffre#\n i=0\n (item.length-1).times do\n if (item[i] == \"0\"||item[i] == \"1\"||item[i] == \"2\"||item[i] == \"3\"||item[i] == \"4\"||item[i] == \"5\"||item[i] == \"6\"||item[i] == \"7\"||item[i] == \"8\"||item[i] == \"9\")\n return true\n end\n i+=1\n end\n return false\nend",
"def valid_number?(n_s)\n n_s.to_i.to_s == n_s && n_s.to_i != 0\nend",
"def featured(number)\n loop do\n number +=1\n characters = number.to_s.split('')\n if (number.odd?) && (number % 7 == 0) && (characters.uniq == characters) \n p number\n break\n end \n end \nend",
"def divisible_by_ten?(number)\n number % 10 === 0\nend",
"def valid_num?(number)\n number == number.to_i.to_s\nend",
"def not_divisible_10(number)\n\tif(number%10)\n\t\treturn false\n\telse\n\t\treturn true\n\tend\nend",
"def has_multiple_of_three?(numbers)\n numbers.any?{ |element| element % 3 == 0 }\nend",
"def valid_number?(num)\n num.to_i.to_s == num\nend",
"def all_same_digits?(number)\n ary_of_chars = number.to_s.chars\n ary_of_chars.all? { |digit| digit == ary_of_chars[0] }\n end",
"def double_number?(num)\n str_num = num.to_s\n middle_index = (str_num.size - 1) / 2\n str_num.size.even? && str_num[0..middle_index] == str_num[(middle_index + 1)..-1]\nend",
"def number? (number)\r\n \r\n if number.to_i == 0\r\n if number == \"0\"\r\n # puts \"number 0\"\r\n return number.to_i\r\n else\r\n \r\n return false\r\n end\r\n else\r\n # puts \"number #{number}\"\r\n return number.to_i\r\n end\r\n \r\nend",
"def featured(int)\n next_num = 0\n loop do\n next_num = int.succ\n break if next_num.odd? && next_num % 7 == 0\n int = next_num\n end\n loop do\n break if next_num >= 9_876_543_210\n if next_num.to_s.chars.uniq == next_num.to_s.chars\n return next_num\n else next_num += 14\n end\n end\n \"There is no possible number that fulfills those requirements.\"\nend",
"def featured(int)\n if int >= 9_876_543_210\n return 'There is no possible number that fulfills those requirements.'\n end\n \n featured_num = 0\n until featured_num > int\n loop do\n featured_num += 7\n next if featured_num.even?\n next if featured_num.digits != featured_num.digits.uniq\n break\n end\n end\n featured_num\nend",
"def no_repeat?(year)\n digits = year.to_s.split(\"\")\n counter = Array.new(10, 0) \n \n digits.each do |digit|\n counter[digit.to_i] += 1\n return false if counter[digit.to_i] > 1\n end\n \n true\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string != 0\nend",
"def featured(number)\n sum = 7\n loop do \n return \"There is no possible number that fulfills those requirements\" if number >= 9_876_543_210\n if sum <= number\n sum += 7\n elsif sum.even?\n sum += 7\n elsif sum.digits.uniq != sum.digits\n sum += 7\n else\n break\n end\n end\n sum\nend",
"def always_three_again(number)\n\tnumber = (((number + 5) * 2 - 4) / 2 - number).to_s\n\t\nend",
"def luhn_check\n numbers = number.split('').reverse.each_with_index.map do |n, i|\n (i !=0 and i%2 != 0) ? n.to_i * 2 : n\n end\n total = numbers.join().split('').map{ |n| n.to_i }.inject(:+)\n (total % 10 == 0)\n end",
"def boolIsBouncyInt i\n numDigits = i.to_s.length\n return false if numDigits < 3 # any number 0-99 is non-bouncy\n sortedNumber = i.to_s.each_char.sort.join.to_i\n sortedNumberReverse = i.to_s.each_char.sort.reverse.join.to_i\n return false if sortedNumber % 10 == sortedNumber / 10**(numDigits - 1)\n if i % 10 == sortedNumber % 10 # this means it's an ascending number\n return (not sortedNumber == i)\n elsif i % 10 == sortedNumberReverse % 10 # this means it's a descending number\n return (not sortedNumberReverse == i)\n end\n true\nend",
"def either_only(number)\n if number % 3 == 0 && number % 5 != 0\n return \"true\"\n elsif number % 3 != 0 && number % 5 == 0\n return \"true\"\n else\n return \"false\"\n end\nend",
"def is_curious?(number)\n digits = number.to_s.split(\"\")\n digits.each do |digit|\n number -= factorial( digit.to_i )\n end\n return number == 0 ? true : false\nend",
"def elevenish?(n)\n\treturn (n.abs % 11 == 0) || (n.abs % 11 == 1)\nend",
"def valid?\n n >= 3\n end",
"def featured(num)\n return 'Error! No featured numbers exist over 10 digits!' if num >= 9876543210\n loop do\n num += 1\n break if num.odd? && (num % 7).zero? && num.digits.uniq! == nil\n end\n num\nend"
] | [
"0.81279975",
"0.7818596",
"0.7320155",
"0.72942543",
"0.72748494",
"0.7254767",
"0.71150404",
"0.7036127",
"0.7027086",
"0.69152486",
"0.68839055",
"0.68709856",
"0.68706834",
"0.6832939",
"0.6827781",
"0.6803171",
"0.67964226",
"0.6785351",
"0.6769284",
"0.67564064",
"0.6746639",
"0.67425543",
"0.6717495",
"0.6712791",
"0.67100346",
"0.66882193",
"0.6672332",
"0.66466653",
"0.66373354",
"0.66218585",
"0.6621051",
"0.6616614",
"0.66164124",
"0.6609611",
"0.6609471",
"0.6604557",
"0.6601958",
"0.6578032",
"0.6575584",
"0.6540537",
"0.6533835",
"0.65101624",
"0.6477746",
"0.64763665",
"0.6452207",
"0.644345",
"0.64286953",
"0.6428071",
"0.6417778",
"0.64079785",
"0.640778",
"0.64047384",
"0.63981724",
"0.6386748",
"0.6358307",
"0.63523483",
"0.6342514",
"0.63392067",
"0.6332511",
"0.6331603",
"0.63142306",
"0.63138896",
"0.6313204",
"0.6301533",
"0.63007754",
"0.62914956",
"0.62827075",
"0.62824595",
"0.62823653",
"0.6279182",
"0.62620986",
"0.6255728",
"0.6240791",
"0.62376094",
"0.623321",
"0.6233042",
"0.62314606",
"0.622648",
"0.6223265",
"0.62193185",
"0.6218079",
"0.6211916",
"0.6211073",
"0.6209319",
"0.6209265",
"0.62088186",
"0.62063116",
"0.6197236",
"0.6189357",
"0.61844707",
"0.61844707",
"0.6182544",
"0.6181875",
"0.61812335",
"0.61750615",
"0.6174589",
"0.6174491",
"0.6172317",
"0.6172091",
"0.6165307"
] | 0.6809825 | 15 |
Update function in the future letting users add text ingredients and directions for nonparsable recipes | def destroy
@recipe.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\n #@recipe.ingredients = params[:recipe_ingredients].map {|k, v|\n #ingredient = @recipe.ingredients.find(k) || @recipe.ingredients.build\n #ingredient.update_attributes(:item => Food.find(v[:item_id]), :quantity => v[:quantity]) unless v[:item_id].blank?\n #ingredient\n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe.ingredients.clear\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n\n @recipe.update(recipe_params)\n redirect_to @recipe\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n count = 1\n complete_directions = \"\"\n params[\"directions\"].each do |direction|\n complete_directions += direction + \"\\n\"\n count += 1\n end\n @ingredientnames = []\n @recipe.ingredients.each do |ingredient|\n @ingredientnames << ingredient.name\n end\n params[\"ingredients\"].each_with_index do |ingredient, index|\n if !@ingredientnames.include? ingredient and ingredient != \"\"\n found = false\n Ingredient.all.each do |db_ingredient|\n if db_ingredient.name == ingredient\n @ingredient = db_ingredient\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n found = true\n end\n end\n if found == false\n @ingredient = Ingredient.create({:name => ingredient})\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n end\n else\n if ingredient != \"\"\n @ingredient = Ingredient.find_by_name(ingredient)\n @recipe.recipeingredients.each do |recipeingredient|\n if recipeingredient.ingredient_id == @ingredient.id\n recipeingredient.update({:amount =>params[\"amounts\"][index]})\n recipeingredient.save\n end\n end\n end\n end\n end\n @ingredientnames.each do |ingredient|\n if !params[\"ingredients\"].include?(ingredient)\n @ingredient = Ingredient.find_by_name(ingredient)\n @recipe.recipeingredients.each do |recipeingredient|\n if recipeingredient.ingredient_id == @ingredient.id\n recipeingredient.destroy\n if @ingredient.recipeingredients == nil\n @ingredient.destroy\n end\n end\n end\n end\n end\n tags = []\n if params[\"tags\"] != nil\n params[\"tags\"].each do |tag|\n a = Tag.find_by_name(tag)\n tags << a\n if !@recipe.tags.include? a\n Recipetag.create({:recipe_id => @recipe.id, :tag_id => a.id })\n end\n end\n end\n @recipe.tags.each do |tag|\n if !tags.include? tag\n @recipe.recipetags.each do |recipetag|\n if recipetag.tag_id == tag.id\n recipetag.destroy\n end\n end\n end\n end\n @recipe.serves = params[\"serves\"]\n @recipe.name =params[\"name\"]\n @recipe.directions = params[\"directions\"].join(\"\\n\")\n @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_ingredient_list\n return if @ingredient_list.blank?\n\n # if this recipe was just created, save original_ingredient_list\n if original_ingredient_list.blank?\n self.original_ingredient_list = @ingredient_list\n end\n \n if @ingredient_list.is_a?(String)\n ingr_array = @ingredient_list.split(/\\n/)\n else\n ingr_array = @ingredient_list\n end\n\n # Usually Rails just sets the key to null. To really delete the record, the following two lines are needed\n ingredients_recipes.each {|ir| ir.delete}\n ingredients_recipes.reload\n \n ingr_array.each_with_index do |line, index|\n line.strip!\n next if line.empty?\n \n # check for groups first, then ingredients. Groups are deliminated with stars like this: *Group*\n attrs = {}\n if line =~ /^\\*(.*)\\*$/\n attrs[:description] = $1\n attrs[:group] = true\n else\n # If a comma, assume everything past is a comment so only parse the first part but then \n # add it back in before processing the description\n line.downcase!\n comma_index = line.index(\",\")\n desc_part = ''\n unless comma_index.blank?\n desc_part = line.slice!(comma_index .. -1)\n end\n attrs[:ingredient] = Ingredient.find_name_and_create(line)\n attrs[:weight] = Ingredient.find_num(line)\n attrs[:unit] = Ingredient.find_unit(line)\n line.slice!(desc_part) # Make sure desc_part is not included twice\n \n # if using the whole_unit, take it out here so it doesn't get repeated in the description\n if attrs[:unit] == 'whole' && !attrs[:ingredient].whole_unit.blank?\n line.slice!(attrs[:ingredient].whole_unit)\n end\n attrs[:description] = Ingredient.find_description(line + desc_part) \n end\n attrs[:line_num] = index\n attrs[:recipe_id] = self.id\n \n ingredient_recipe = IngredientsRecipe.create!(attrs)\n ingredients_recipes << ingredient_recipe\n Ingredient.standardize_unit(ingredient_recipe)\n end\n @ingredient_list = nil\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def parse_ingredients ingredient_line, recipe \n Rails.logger.debug \"== Blender::parse_ingredients\"\n \n # Removes hifen \"-\"\n ingredient_line.gsub!(\"-\",\"\") \n # Removes Complementary Words\n ingredient_line.gsub!(/\\b(#{STOP_WORDS.join('|')})\\b/mi, ' ')\n \n # Given a ingredient line, extracts the: measure, quantity, ingredient name\n measure, quantity, ingredient = get_measure_quantity_and_ingredient ingredient_line.downcase\n \n Rails.logger.debug \"* Extracted Ingredient: Quant:(#{quantity}) Meas:(#{measure}) Name:(#{ingredient})\"\n \n add_ingredient_to_recipe quantity, measure, ingredient, recipe \n # Returns true if could understand and extract the measure and quantity\n return !measure.nil? && !quantity.nil?\n end",
"def update\n @recipe = current_user.recipes.find(params[:id])\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n \n unless params[:instructions].nil?\n @recipe.instructions.delete_all\n Instruction.multi_save(params[:instructions], @recipe)\n end\n \n unless params[:ingredients].nil?\n @recipe.ingredients.delete_all\n Ingredient.multi_save(params[:ingredients], @recipe)\n end\n\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render json: {:recipe => @recipe, :tags => @recipe.tag_list} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_params\n #mess with ingredients eventually\n params.require(:recipe).permit(:name, :directions, :cooking_time, :image)\nend",
"def update(attributes: {})\n attributes = attributes.with_indifferent_access\n clean_attributes(attributes)\n titleize(attributes)\n sync_tags(attributes)\n parse_ingredients(attributes)\n recipe.update(attributes)\n recipe_response\n rescue StandardError => e\n error_response(e)\n end",
"def recipe_params\n params.require(:recipe).permit(:title, :description, :user_id, :note, :image, ingredients_attributes: [:id, :position, :value, :_destroy], directions_attributes: [:id, :position, :step, :_destroy])\n end",
"def ingredient_add_helper(recipe_id)\n added_ingredient = prompt.ask(\"What ingredient would you like to add\")\n new_recipe_ingredient_arr = user.recipes.where(id: recipe_id)[0].ingredient.split(\", \") << added_ingredient\n ingredient_change_helper(recipe_id, new_recipe_ingredient_arr)\n end",
"def edit_ingredients\n @prompt.select(\"Do you want to add or delete ingredients?\") do |menu|\n menu.choice \"Add ingredient(s)\", -> {add_ingredients}\n menu.choice \"Delete ingredient(s)\", -> {delete_ingredients}\n menu.choice \"Back to menu\", -> {nav_menu}\n end\n end",
"def update\n @beverage = Beverage.find(params[:id])\n @beverage.ingredients.clear\n params[:ingredient].each{|ingr|\n @beverage.ingredients << Ingredient.find_by_name(ingr)\n } unless params[:ingredient].blank?\n\n respond_to do |format|\n if @beverage.update_attributes(params[:beverage])\n format.html { redirect_to @beverage, notice: 'Beverage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beverage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def recipe_ingredients(recipe_id)\n recipe_status_helper(recipe_id)\n @recipe_ingredient_arr = recipe_ingredient.split(\", \")\n puts \" \"\n p user.recipes.where(id: recipe_id)[0].ingredient\n prompt.select(\"Options\") do |menu|\n puts \" \"\n menu.choice \"Choose New Protein\", -> {choose_protein}\n menu.choice \"Update Recipe Rating\", -> {update_recipe_rating(recipe_id)}\n menu.choice \"Add Ingredient\", -> {ingredient_add_helper(recipe_id)}\n menu.choice \"Remove Ingredient\", -> {ingredient_remove_helper(recipe_id)}\n menu.choice \"Exit\", -> {exit_helper}\n end\n end",
"def enter_ingredients\n puts \"\\nPlease input your ingredients below. Separate each ingredient with a comma.\\n\"\n\n ingredients = gets.strip\n recipes = EverythingButTheKitchenSink::SpoonacularApi.get_recipes(ingredients)\n EverythingButTheKitchenSink::TransformData.get_id_and_title(recipes)\n end",
"def edit_ingredient(r,i)\n ingredient_select = prompt_list_of_ingredients(r,i)\n new_ingredient_pair = gets_new_ingredient_pair\n # iteration over ingredients array with index and deletes and inserts hashes at index when ingredient names match.\n i.each_with_index do |ingredient_pair,index|\n ingredient_pair.each do |ing,p|\n if ingredient_select == ing \n i.delete_at(index)\n i.insert(index, new_ingredient_pair)\n end\n end\n end\nend",
"def start_recipe\n @recipe.delete_recipes\n puts File.foreach(\"ingredient_list.txt\") { |line| puts line }\n puts \"What Ingredients do you have?\".colorize(:yellow)\n user_input = gets.chomp\n @recipe.search(user_input)\n self.print_recipe\n self.recipe_ask_for_options()\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n p = 0\n @recipe.directions.each do |direction|\n direction.position = p\n direction.save!\n p += 1\n end\n\n if @recipe.author.nil? && @current_user\n @recipe.author = @current_user\n @recipe.save\n end\n\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @active_ingredients = args[:active_ingredients] if args.key?(:active_ingredients)\n @alcohol_by_volume = args[:alcohol_by_volume] if args.key?(:alcohol_by_volume)\n @allergens = args[:allergens] if args.key?(:allergens)\n @derived_nutrition_claim = args[:derived_nutrition_claim] if args.key?(:derived_nutrition_claim)\n @directions = args[:directions] if args.key?(:directions)\n @indications = args[:indications] if args.key?(:indications)\n @ingredients = args[:ingredients] if args.key?(:ingredients)\n @nutrition_claim = args[:nutrition_claim] if args.key?(:nutrition_claim)\n @storage_instructions = args[:storage_instructions] if args.key?(:storage_instructions)\n end",
"def recipe_params\n params.require(:recipe).permit(:title,\n :description,\n :notes,\n :acknowledgements,\n :preparation_time,\n :featured_image,\n :user_id,\n :jewel_id,\n :color_scheme_id,\n :cuisine_ids => [],\n :meal_type_ids => [],\n :diet_ids => [],\n :season_ids => [],\n :occasion_ids => [],\n :pairing_ids => [],\n :box_ids => [],\n steps_attributes: [:id, :_destroy, :position, :description],\n ingredients_attributes: [:id, :_destroy, :position, :title, :amount],)\n end",
"def update\n params[:recipe][:ingredient_ids] ||= []\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_help\n @help_window.set_item(recipe)\n @ingredient_window.recipe = recipe\n end",
"def recipe_params\n params.require(:recipe).permit(:title, :description, :image, :remove_image, ingredients_attributes:[:id, :content, :_destroy], steps_attributes:[:id, :direction, :_destroy]) \n end",
"def update\n respond_to do |format|\n save_relations\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fillRecipeAssoc(a_recipe)\n # Setup for more automation w/faker gem later\n ingredients_name = \"A thing to put in it\"\n direction_step = \"Do this thing...\"\n # Do the thing\n a_recipe.ingredients.build(name: ingredients_name).save(validate: false)\n a_recipe.directions.build(step: direction_step).save(validate: false)\nend",
"def translate_recipe\n @translated_recipe = {}\n # google trad call\n translate = Google::Cloud::Translate::V2.new(\n project_id: ENV[\"CLOUD_PROJECT_ID:\"],\n credentials: ENV[\"GOOGLE_APPLICATION_CREDENTIALS\"],\n )\n translated_ingredients = @recipe_hash[:ingredients_list].map do |ingredient|\n translation = translate.translate ingredient, to: \"en\"\n translation.text.inspect\n end\n # new hash with translated infos\n @translated_recipe[:ingredients_list] = translated_ingredients.join(\"\\n\").gsub! /\"/, \"|\"\n end",
"def ingredient_logic(ingredient)\n if all_ingredients.include?(ingredient)\n new_recipe_ingredient = ingredient_instance(ingredient)\n Recipe.last.ingredients << new_recipe_ingredient\n else\n new_recipe_ingredient = Ingredient.create(name: ingredient)\n Recipe.last.ingredients << new_recipe_ingredient\n end\n end",
"def with_ingredients(ingredients = nil)\n unless ingredients.nil?\n self.recipe_data.ingredients = ingredients\n self\n end\n end",
"def recipe_params\n params.require(:recipe).permit(:title, :description, :image, tag_ids:[], ingredients_attributes:[:id, :name, :amount, :_destroy], directions_attributes:[:id, :step, :_destroy])\n end",
"def newRecipe( foodDB )\n puts \"Enter the name of the recipe entry.\"\n name = STDIN.gets.chomp!.strip\n \n puts \"Enter the name of the ingredients (\\\"Okay\\\" to finish)\"\n ingredients = Array.new\n item = STDIN.gets.chomp!.strip\n while item.casecmp( \"Okay\" ) != 0\n ingredients << item\n\titem = STDIN.gets.chomp!.strip\n end\n puts \"\\n\" + foodDB.addRecipe( name, ingredients )\nend",
"def ingredient_change_helper(recipe_id, new_recipe_ingredient_arr)\n puts \" \"\n p \"Ingredient(s) successfully updated!\"\n sleep(1.3)\n user.recipes.where(id: recipe_id).update(ingredient: new_recipe_ingredient_arr.join(\", \"))\n recipe_ingredients(recipe_id)\n end",
"def update\n @recipe = Recipe.find(params[:id])\n @recipe.ingrediences = Ingredience.find(params[:ingredience_ids]) if params[:ingredience_ids] \n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n flash[:notice] = 'Recipe was successfully updated.'\n format.html { redirect_to(@recipe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @recipe.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t\t\trecipe = Recipe.find(params[:id])\n\t\t\t\tingredients = params[:ingredients]\n\t\t\t\ttags = params[:tags]\n\n\t\t\t\tif recipe.update_attributes(recipe_params)\n\t\t\t\t\tif !ingredients.blank?\n\t\t\t\t\t\tcreate_ingredient(recipe.id, ingredients)\n\t\t\t\t\tend\n\n\t\t\t\t\tif !tags.blank?\n\t\t\t\t\t\tcreate_tag(recipe.id, tags)\n\t\t\t\t\tend\n\n\t\t\t\t\trender json: {status: 'SUCCESS', message: 'Updated recipe', data: get_recipe_by_id(recipe.id)}, status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'ERROR', message: 'Recipe not updated', data: recipe.errors}, status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend",
"def update\n authorize @ingredient.recipe\n respond_to do |format|\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient}\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_ingredient_to_recipe quantity, measure, food_item_name, recipe \n food_item = FoodItem.new(:name => food_item_name, :price => nil)\n ingredient = Ingredient.new(:food_item => food_item, :quantity => quantity, :measure => measure, :recipe_id => recipe.id)\n recipe.ingredients << ingredient\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n count = 1\n complete_directions = \"\"\n params[\"directions\"].each do |direction|\n complete_directions += direction + \"\\n\"\n count += 1\n end\n @recipe.directions = complete_directions\n params[\"ingredients\"].each_with_index do |ingredient, index|\n found = false\n Ingredient.all.each do |db_ingredient|\n if db_ingredient.name == ingredient\n @ingredient = db_ingredient\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n found = true\n end\n end\n if found == false\n @ingredient = Ingredient.create({:name => ingredient})\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n end\n end\n Userrecipe.create({:contribution_id => @recipe.id, :user_id => current_user.id})\n if params[\"tags\"] != nil\n params[\"tags\"].each do |tag|\n @tag = Tag.find_by_name(tag)\n Recipetag.create({:recipe_id => @recipe.id,:tag_id => @tag.id})\n end\n end\n @recipe.serves = params[\"serves\"]\n @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if recipe_ingredient_params[:ingredients_list]\n fill_form_from_ingredients_list\n elsif recipe_params[:url] && !ingredient_params[:product_name]\n fill_form_from_url\n else\n @recipe = Recipe.new(recipe_params)\n @recipe.country_consumption = Country.find_or_create(recipe_name_params[:country_consumption_name])\n @recipe.user = current_user\n \n if ingredient_params[:product_name]\n ingredients = ingredient_params.values.transpose.map { |s| Hash[ingredient_params.keys.zip(s)] }\n ingredients.each do |ingredient|\n weight, item_name = Ingredient.parse(ingredient[\"item_name\"])\n if ingredient[\"product_name\"].length > 0 and not ingredient[\"product_name\"] == \"None\"\n @ingredient = Ingredient.new({:weight => ingredient[\"weight\"]})\n @ingredient.description = ingredient[\"item_name\"]\n @ingredient.product = Product.find_or_create(ingredient[\"product_name\"])\n @ingredient.country_origin = Country.find_or_create(ingredient[\"country_origin_name\"])\n @recipe.ingredients << @ingredient\n \n @product_alias = ProductAlias.find_or_create(item_name)\n @product_alias.country = @recipe.country_consumption\n @product_alias.product = @ingredient.product\n if not @product_alias.save\n render :html => \"Could not save product alias\"\n return\n end\n elsif item_name.length > 0\n @product_alias = ProductAlias.find_or_create(item_name)\n @product_alias.country = @recipe.country_consumption\n @product_alias.product = Product.find_by(name: \"None\")\n if not @product_alias.save\n render :html => \"Could not save product alias\"\n return\n end\n end\n end\n end\n \n save\n end\n end",
"def update\n respond_to do |format|\n update_recipe_line_items\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meal = @meal_recipe.meal\n @meal_plan = @meal.day.meal_plan\n @leftover = Leftover.meal_recipe(@meal_recipe).first\n @meal_ingredient = MealIngredient.new\n\n respond_to do |format|\n if params[:meal_recipe][:multiply].present?\n multiply_portions_and_ingredients(params[:meal_recipe][:multiply].to_d)\n end\n\n if params[:meal_recipe][:add].present?\n # @meal_recipe = MealRecipe.find(params[:id])\n @portions = @meal_recipe.portions\n ratio_increase = 1 + 1/@portions\n multiply_portions_and_ingredients(ratio_increase)\n end\n\n \n if @meal_recipe.update(meal_recipe_params)\n format.turbo_stream\n format.html { redirect_to @meal_recipe, notice: \"Meal recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @meal_recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @meal_recipe.errors, status: :unprocessable_entity }\n end\n \n end\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :user_id, :vegetarian, :soy, :gluten, :dairy, :vegan, :ingredients=>{}, :gadgets=>{})\n end",
"def update\n @recipe = Recipe.find(params[:id])\n @recipe.update(recipe_params)\n redirect_to new_ingredient_path\n end",
"def add_ingredient_to_mixing_bowl\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n value = nil\n add_ingredient_to_mixing_bowl_start_index = @input.index\n text25 = nil\n ordinal26 = nil\n text27 = nil\n ordinal28 = nil\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return value\n end\n # at line 172:3: ( add WS text WS into ( WS ordinal )? WS mixing WS bowl EOF | add WS text WS into WS the ( WS ordinal )? WS mixing WS bowl EOF )\n alt_21 = 2\n alt_21 = @dfa21.predict( @input )\n case alt_21\n when 1\n # at line 172:5: add WS text WS into ( WS ordinal )? WS mixing WS bowl EOF\n @state.following.push( TOKENS_FOLLOWING_add_IN_add_ingredient_to_mixing_bowl_616 )\n add\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_618 )\n @state.following.push( TOKENS_FOLLOWING_text_IN_add_ingredient_to_mixing_bowl_620 )\n text25 = text\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_622 )\n @state.following.push( TOKENS_FOLLOWING_into_IN_add_ingredient_to_mixing_bowl_624 )\n into\n @state.following.pop\n # at line 172:25: ( WS ordinal )?\n alt_19 = 2\n look_19_0 = @input.peek( 1 )\n\n if ( look_19_0 == WS )\n look_19_1 = @input.peek( 2 )\n\n if ( look_19_1.between?( ST, TH ) )\n alt_19 = 1\n end\n end\n case alt_19\n when 1\n # at line 172:26: WS ordinal\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_627 )\n @state.following.push( TOKENS_FOLLOWING_ordinal_IN_add_ingredient_to_mixing_bowl_629 )\n ordinal26 = ordinal\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_633 )\n @state.following.push( TOKENS_FOLLOWING_mixing_IN_add_ingredient_to_mixing_bowl_635 )\n mixing\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_637 )\n @state.following.push( TOKENS_FOLLOWING_bowl_IN_add_ingredient_to_mixing_bowl_639 )\n bowl\n @state.following.pop\n match( EOF, TOKENS_FOLLOWING_EOF_IN_add_ingredient_to_mixing_bowl_641 )\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = {\n :cmd => :add_ingredient_to_mixing_bowl,\n :args => {:ingredient => ( text25 && @input.to_s( text25.start, text25.stop ) ), :mixing_bowl => ordinal26.to_i}\n }\n \n # <-- action\n end\n\n when 2\n # at line 178:5: add WS text WS into WS the ( WS ordinal )? WS mixing WS bowl EOF\n @state.following.push( TOKENS_FOLLOWING_add_IN_add_ingredient_to_mixing_bowl_649 )\n add\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_651 )\n @state.following.push( TOKENS_FOLLOWING_text_IN_add_ingredient_to_mixing_bowl_653 )\n text27 = text\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_655 )\n @state.following.push( TOKENS_FOLLOWING_into_IN_add_ingredient_to_mixing_bowl_657 )\n into\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_659 )\n @state.following.push( TOKENS_FOLLOWING_the_IN_add_ingredient_to_mixing_bowl_661 )\n the\n @state.following.pop\n # at line 178:32: ( WS ordinal )?\n alt_20 = 2\n look_20_0 = @input.peek( 1 )\n\n if ( look_20_0 == WS )\n look_20_1 = @input.peek( 2 )\n\n if ( look_20_1.between?( ST, TH ) )\n alt_20 = 1\n end\n end\n case alt_20\n when 1\n # at line 178:33: WS ordinal\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_664 )\n @state.following.push( TOKENS_FOLLOWING_ordinal_IN_add_ingredient_to_mixing_bowl_666 )\n ordinal28 = ordinal\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_670 )\n @state.following.push( TOKENS_FOLLOWING_mixing_IN_add_ingredient_to_mixing_bowl_672 )\n mixing\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_ingredient_to_mixing_bowl_674 )\n @state.following.push( TOKENS_FOLLOWING_bowl_IN_add_ingredient_to_mixing_bowl_676 )\n bowl\n @state.following.pop\n match( EOF, TOKENS_FOLLOWING_EOF_IN_add_ingredient_to_mixing_bowl_678 )\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = {\n :cmd => :add_ingredient_to_mixing_bowl,\n :args => {:ingredient => ( text27 && @input.to_s( text27.start, text27.stop ) ), :mixing_bowl => ordinal28.to_i}\n }\n \n # <-- action\n end\n\n end\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 10 )\n memoize( __method__, add_ingredient_to_mixing_bowl_start_index, success ) if @state.backtracking > 0\n\n end\n \n return value\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n\n if params[:lista].present?\n params[:lista].each do |(c,ingrediente)|\n Ingredient.create(name: ingrediente, recipe_id:@recipe.id) if ingrediente != \"\"\n end\n end\n\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n format.js {flash.now[:notice] = 'La receta se ha actualizado de forma exitosa.'} \n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al actuar la receta.'} \n end\n end\n end",
"def update\n @measurs = Array.new\n @ingrs = Array.new\n @tgs = Array.new\n #unisti prijasnje mjere(veze medu receptima i sastojcima)!\n @recipe.measurements.destroy\n @recipe.recipe_tags.destroy\n #ovo bi trebalo unutar sebe prikupiti sastojke i mjere\n parse_ingredients\n parse_tags\n @recipe.ingredients = @ingrs\n @recipe.measurements = @measurs\n @recipe.recipe_tags = @tgs\n\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def command_newRecipe(name, ingredients)\n bool = @database.add_recipe(name, ingredients)\n if bool == false\n puts \"Recipe already in database or ingredients not in database\"\n end\n @dbChanged = true\n end",
"def update_recipe(db,id,description)\n # your code here\nend",
"def recipe_params\n params.require(:recipe).permit(:user_id, :title, :image_url, :description, :cuisine_id, :category_id, :cook_time, :serving_num, :instruction, :ingredients_attributes => [:id, :recipe_id, :quantity, :unit, :item_id, :_destroy, :item_attributes => [:name]])\n end",
"def update!(**args)\n @allergen_absent = args[:allergen_absent] if args.key?(:allergen_absent)\n @allergen_present = args[:allergen_present] if args.key?(:allergen_present)\n @calories = args[:calories] if args.key?(:calories)\n @ingredients = args[:ingredients] if args.key?(:ingredients)\n @media = args[:media] if args.key?(:media)\n @name_info = args[:name_info] if args.key?(:name_info)\n @nutrition_facts = args[:nutrition_facts] if args.key?(:nutrition_facts)\n @portion_size = args[:portion_size] if args.key?(:portion_size)\n @preparation_methods = args[:preparation_methods] if args.key?(:preparation_methods)\n @price = args[:price] if args.key?(:price)\n @restriction = args[:restriction] if args.key?(:restriction)\n @serves_num_people = args[:serves_num_people] if args.key?(:serves_num_people)\n @spiciness = args[:spiciness] if args.key?(:spiciness)\n end",
"def add_recipe(recipe)\n if database.has_key? recipe[0]\n puts('Recipe already in Database.')\n else\n ingredients_list = []\n recipe[1..-1].each do |ingredient|\n if database.has_key? ingredient\n temp = database[ingredient]\n ingredients_list.push(temp)\n else\n puts('Missing ingredient(s)')\n break\n end\n end\n temp = Recipe.new(recipe[0], ingredients_list)\n database[temp.name] = temp\n end\n end",
"def add_ingredients(ingredients)\n RecipeIngredient.new(ingredients, self)\nend",
"def update(text); end",
"def recipe_params\n params.require(:recipe).permit(\n :name,\n :user_id,\n :component,\n :picture,\n :remove_picture,\n :picture_cache,\n ingredients_attributes: [:id, :value, :_destroy],\n steps_attributes: [:id, :description, :picture, :remove_picture, :picture_cache, :_destroy],\n references_attributes: [:id, :url, :_destroy], component_ids: []\n )\n end",
"def update(recipe)\n return false unless recipe.valid?\n\n @service.update(recipe)\n end",
"def ingredient_attributes=(ingredient_attribute)\n self.ingredient = Ingredient.find_or_create_by(name: ingredient_attribute)\n self.ingredient.update(ingredient_attribute) \n end",
"def recipe_params\n params.require(:recipe).permit(:name, :slug, :short_description, :serving, :preparation_time, :cooking_time, :waiting_time, :original_recipie_author, :original_recipie_url, :photos_from, :photos_from_url, :image_url, :square_image_url, :public, :cuisine, :keywords, :new_recipe_email_sent, :ingredients_image_url, :ingredients_text_image_url, :video_url,\n descriptions_attributes: [:id, :description, :image_url, :_destroy],\n parts_attributes: [:id, :name, :_destroy,\n ingredients_attributes: [:id, :name, :weight, :weight_unit, :weight_optional, :weight_optional_unit, :_destroy],\n instructions_attributes: [:id, :instruction, :_destroy]],\n notes_attributes: [:id, :note, :_destroy])\n\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :description, :intructions, :ingredients, :image, :prep, :cooking, \n\t\t\t\t\t\t\t\t\t :level, :serves, :tips, :additional_info, :meta_title, :meta_description, :meta_keywords)\n end",
"def edit_recipe_options(r,i)\n edit_options = [\n {name: \"Add a new ingredient to the recipe\", value: 1},\n {name: \"select an ingredient to re-enter\", value: 2},\n {name: \"select an ingredient to Delete\", value: 3},\n {name: \"Delete Recipe\", value: 4},\n {name: \"back to recipe select\", value: 5}\n ] \n recipe_edit_options = $prompt.select(\"What would you like to do with this recipe\", edit_options)\n case recipe_edit_options\n when 1\n # clear and ascii heading format and cleanup window.\n clear\n ascii_heading(\"Edit Recipe\")\n add_ingredient(r,i)\n when 2\n clear\n ascii_heading(\"Edit Recipe\")\n edit_ingredient(r,i)\n when 3 \n clear\n ascii_heading(\"Edit Recipe\")\n delete_ingredient(r,i)\n when 4\n clear\n ascii_heading(\"Edit Recipe\")\n delete_recipe(r,i)\n system \"clear\"\n main_menu(3) # returns to edit recipe options selection screen.\n when 5\n clear\n main_menu(3)\n end\nend",
"def addRecipe(name, ingredients)\n calories = 0\n keys = @BasicHash.keys\n ingredients.each do |ingredient|\n ingredient.chomp!\n # if the ingredient is in the basicFood\n if @BasicHash.has_key? ingredient\n calories += @BasicHash[ingredient].calories.to_i\n else\n puts \"Can't find the ingredient\"\n puts \"#{ingredient}\"\n end\n #Making recipe object and adding it to the hash\n myrecipes = Recipe.new(name, ingredients, calories)\n @RecipeHash[name] = myrecipes\n end\n end",
"def recipe_params\n params.require(:recipe).permit(:similar_recipe_tokens, :ingredient_tokens, :category_tokens, :garnish_tokens, :alcoholic, :drinkid, :edited, :favorite, :issuggested, :glass_id, :information, :instructions, :name, :notes,recipe_steps_attributes: [:id, :stepindex, :steptitle, :stepamount, :_destroy],\n )\n end",
"def recipe_params\n params.require(:recipe). \\\n permit(:dish_name, :instructions, :prep_time, :cook_time, :yield,\n :picture, :tag_list, :user_id,\n ingredients_attributes: [:id, :amount, :measure, :name, :_destroy],\n potluck_ids: [] )\n end",
"def update\n respond_to do |format|\n if @ingredient_recipe.update(ingredient_recipe_params)\n format.html { redirect_to @ingredient_recipe, notice: 'Ingredient recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient_recipe }\n else\n format.html { render :edit }\n format.json { render json: @ingredient_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_ingredient(r,i)\n new_ingredient_pair = gets_new_ingredient_pair\n i << new_ingredient_pair\nend",
"def recipe_params\n params.require(:recipe).permit(:name, :body, :foto, ingredients_attributes: Ingredient.attribute_names.map(&:to_sym).push(:_destroy))\n end",
"def update\n authorize @direction.recipe\n respond_to do |format|\n if @direction.update(direction_params)\n format.html { redirect_to @direction }\n format.json { render :show, status: :ok, location: @direction }\n else\n format.html { render :edit }\n format.json { render json: @direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bruschettum = Bruschettum.find(params[:id])\n @bruschettum.ingredients.clear\n params[:ingredient].each{|ingr|\n @bruschettum.ingredients << Ingredient.find_by_name(ingr)\n }\n\n respond_to do |format|\n if @bruschettum.update_attributes(params[:bruschettum])\n format.html { redirect_to @bruschettum, notice: 'Bruschettum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bruschettum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # recipe_params[:ingredient_lists_attributes].each do |list|\n # list.each do |item|\n # item[:ingredient_attributes] = Ingredient.where(name: item[:ingredient_attributes].name).first_or_create\n # end\n # end\n \n # category_ids = params[:recipe][:categories_attributes].map { |k,v| v[:id] }\n # #pry.debugger\n \n # recipe_params.merge({ category_ids: category_ids })\n \n\n respond_to do |format|\n \n if @recipe.update(recipe_params)\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n if params['ingredients']\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n end\n\n @recipe.save \n redirect_to recipes_path\n end",
"def update\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n if @recipe_ingredient.update_attributes(params[:recipe_ingredient])\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe_ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n db_quantities = @recipe.quantities.where(\"recipe_id = :this_id\", {this_id: @recipe.id})\n\n params[:recipe][:quantities_attributes].each do |quantity_raw|\n quantity = quantity_raw.to_a.last\n if quantity[:item_id].blank?\n next\n end\n #Look to see if the item name is already there and if it is, replace the new amount\n if db_quantities.map{|q| q.item_id}.include?(quantity[:item_id].to_i)\n (db_quantities.detect{|q| q.item_id == quantity[:item_id].to_i})\n .update(amount: quantity[:amount].to_i)\n else\n @recipe.add_item(quantity[:item_id], quantity[:amount])\n end\n\n end\n\n @recipe.attributes = recipe_params\n if @recipe.update_attributes(recipe_params)\n redirect_to edit_recipe_url, id: @recipe.id\n else\n render edit\n end\n end",
"def update\n respond_to do |format|\n save_relations\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal ? @meal.recipes.create(params[:recipe]) : Recipe.new(params[:recipe])\n\n #@recipe.ingredients = params[:ingredients].map {|i| \n #Ingredient.new(:item => Food.find(i.delete(:item_id)), :quantity => i[:quantity]) unless i[:item_id].blank? \n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe}\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :url, :instructions, :picture_url, :menu_type, allergy_ids: [], ingredient_ids: [])\n end",
"def recipe_params\n params.require(:recipe).permit(\n :title, \n :description, \n :instructions, \n :ingredient_count, \n ingredient_ids: [],\n ingredients_attributes: [\n :name, \n :description, \n recipe_ingredients_attributes: [\n :quantity\n ]\n ]\n \n )\n end",
"def update!(**args)\n @is_highlighted = args[:is_highlighted] if args.key?(:is_highlighted)\n @is_optional = args[:is_optional] if args.key?(:is_optional)\n @is_original = args[:is_original] if args.key?(:is_original)\n @items = args[:items] if args.key?(:items)\n @text = args[:text] if args.key?(:text)\n @weight = args[:weight] if args.key?(:weight)\n end",
"def update\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n if @recipe_ingredient.update_attributes(params[:recipe_ingredient])\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_to_database(recipe)\n\t\t# Parsing the recipe line\n\t\trecipe_db = Recipe.new(\n\t\t\ttitle: recipe[\"recipe\"][\"label\"].to_s,\n\t\t\timage: recipe[\"recipe\"][\"image\"].to_s,\n\t\t\tdescription: recipe[\"recipe\"][\"source\"].to_s,\n\t\t\tuser_id: 1\n\t\t\t)\n\t\trecipe_db.save\n\t\tputs recipe_db.errors.messages\n\t\tputs \"ID: #{recipe_db.id}\"\n\t\tputs \"TITLE: #{recipe_db.title}\"\n\t\tputs \"IMAGE: #{recipe_db.image}\"\n\t\t# Parsing the ingredients line\n\t\trecipe[\"recipe\"][\"ingredientLines\"].each do |ingredient|\n\t\t\t# Retrieving the ingredient\n\t\t\tingredient_db = Ingredient.create(\n\t\t\t\tname: ingredient,\n\t\t\t\trecipe_id: recipe_db.id\n\t\t\t\t)\n\t\t\trecipe_db.ingredients << ingredient_db\n\t\tend\n\n\t\trecipe_db\n\tend",
"def recipe_params\n params.require(:recipe).permit(:user_id, :title, :description, :cook_time, :recipe_img, :tag_list,\n ingredients_attributes: [:id, :recipe_id, :name, :quantity, :_destroy],\n steps_attributes: [:id, :recipe_id, :step_number, :description, :step_img, :_destroy])\n end",
"def update_recipe(db,id,description)\n q = \"UPDATE recipes SET description=#{name} WHERE id=#{id};\"\n return db.execute(q)\nend",
"def recipe_params\n params.require(:recipe).permit(:user_id, :name, :method, :style, :views, :style_id, :batch_volume,\n :OG, :FG, :colour, :efficiency, :ingredient_type, :ingredient_id, :IBU,\n :recipe_malts_attributes => [:id, :malt, :quantity, :_destroy],\n :recipe_hops_attributes => [:id, :hop, :quantity, :boil_time, :_destroy],\n :recipe_yeasts_attributes => [:id, :yeast, :_destroy])\n end",
"def update\n respond_to do |format|\n if @recipe_ingredient.update(recipe_ingredient_params)\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_ingredients(ingredients_array)\n\t\tRecipeIngredient.new(ingredients_array, self)\n\tend",
"def update\n respond_to do |format|\n if @recipeingredient.update(recipeingredient_params)\n format.html { redirect_to @recipeingredient, notice: 'Recipeingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipeingredient }\n else\n format.html { render :edit }\n format.json { render json: @recipeingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def prepared_attributes_for_essence\n attributes = {\n ingredient: default_text(description['default'])\n }\n attributes\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :serves, :cooking_time, :difficulty, :ingredients, :procedure, :food_preference_id, :food_type_id, :cuisine_id, :photo)\n end",
"def update_raw_text(item); end",
"def update_raw_text(item); end",
"def update\n @ingredient = Ingredient.find(params[:id])\n @amount = Amount.find(@ingredient)\n\n respond_to do |format|\n if @ingredient.update_attributes(params[:ingredient]) and @amount.update_attributes(params[\"amount\"].merge(:ingredient_id => @ingredient.id, :recipe_id => @recipe.id ))\n flash[:notice] = 'Ingredient was successfully updated.'\n format.html { redirect_to(@recipe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n load_recipe(@current_user)\n# new_recipe = @current_user.recipes.build(params[:recipe])\n if params[:recipe][:privacy].nil?\n params[:recipe][:privacy] = @recipe.privacy\n end\n # for love recipes\n current_roles = @recipe.roles || ''\n if (params[:recipe][:privacy] == '10' && params[:recipe][:from_type] == '1' && @recipe.is_draft == '0' && time_iso_format(@recipe.published_at) >= '2009-08-01 00:00:00')\n unless(current_roles.include?('21'))\n params[:recipe][:roles] = '21 ' + current_roles\n#### begin\n#### CACHE.delete('overview_love_recipes_set')\n#### CACHE.delete('overview_love_users_set')\n#### rescue Memcached::NotFound\n#### end\n end\n else\n if(current_roles.include?('21'))\n params[:recipe][:roles] = current_roles.gsub('21', '')\n#### begin\n#### CACHE.delete('overview_love_recipes_set')\n#### CACHE.delete('overview_love_users_set')\n#### rescue Memcached::NotFound\n#### end\n end\n end\n # end\n \n new_recipe = @recipe.user.recipes.build(params[:recipe])\n # new_recipe.cover_photo_id = @recipe.cover_photo_id\n # new_recipe.published_at = @recipe.published_at\n # new_recipe.status = new_recipe.get_status\n # new_recipe.is_draft = new_recipe.get_is_draft\n # new_recipe.published_at = new_recipe.get_published_at\n \n # params[:recipe][:status] = new_recipe.status\n # params[:recipe][:is_draft] = new_recipe.is_draft\n # params[:recipe][:published_at] = new_recipe.published_at\n params[:recipe][:original_updated_at] = Time.now if @recipe.user == @current_user\n params[:recipe][:status] = new_recipe.get_status\n\t\t\n\t\tset_tag_list\n \n ActiveRecord::Base.transaction do\n\t\t if @recipe.update_attributes(params[:recipe])\n\t\t \t# @recipe.tag_list = params[:tags].strip if params[:tags] && params[:tags].strip != @recipe.tag_list\n\t\t\t\treg_homepage(@recipe, 'update')\n#### begin\n#### CACHE.delete('overview_recipes_set')\n#### CACHE.delete('overview_tags_set')\n#### rescue Memcached::NotFound\n#### end\n\t\t\t\tafter_update_ok\n\t\t else\n\t\t\t\tafter_update_error\n\t\t end\n\t end\n end",
"def update\n #before action\n #Also in update we need to include the whitelisted fields\n if @recipe.update(recipe_params)\n flash[:success] = \"Your recipe was updated successfully\"\n #We want to redirect the user to the updated recipe. So we have to provide the object @recipe in the path method\n redirect_to recipe_path(@recipe)\n else\n render :edit\n end\n end",
"def set_ingredient_recipe\n @ingredient_recipe = IngredientRecipe.find(params[:id])\n end",
"def set_recipe_ingredient\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n calculate_nutrients \n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @clean_text = args[:clean_text] if args.key?(:clean_text)\n @info_string = args[:info_string] if args.key?(:info_string)\n @snippet = args[:snippet] if args.key?(:snippet)\n @text = args[:text] if args.key?(:text)\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :instructions, :prep_time, :meal_type)\n end",
"def recipe_params\n params.require(:recipe).permit(:ingredient_id,:title, :description, :ingredients, :directions, :preptime, :cooktime, :servings, :cuisine_id, :cookcategory_id, :user_id, :picture, ingredient_recipes_attributes: [:id,:amount, :measurement_unit])\n end",
"def add_dry_ingredients\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 14 )\n return_value = AddDryIngredientsReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n add_dry_ingredients_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return return_value\n end\n # at line 210:5: add WS dry WS ingredients ( WS the )? ( WS ordinal )? WS mixing WS bowl EOF\n @state.following.push( TOKENS_FOLLOWING_add_IN_add_dry_ingredients_789 )\n add\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_dry_ingredients_791 )\n @state.following.push( TOKENS_FOLLOWING_dry_IN_add_dry_ingredients_793 )\n dry\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_dry_ingredients_795 )\n @state.following.push( TOKENS_FOLLOWING_ingredients_IN_add_dry_ingredients_797 )\n ingredients\n @state.following.pop\n # at line 210:31: ( WS the )?\n alt_25 = 2\n look_25_0 = @input.peek( 1 )\n\n if ( look_25_0 == WS )\n look_25_1 = @input.peek( 2 )\n\n if ( look_25_1.between?( T__16, T__17 ) )\n alt_25 = 1\n end\n end\n case alt_25\n when 1\n # at line 210:32: WS the\n match( WS, TOKENS_FOLLOWING_WS_IN_add_dry_ingredients_800 )\n @state.following.push( TOKENS_FOLLOWING_the_IN_add_dry_ingredients_802 )\n the\n @state.following.pop\n\n end\n # at line 210:41: ( WS ordinal )?\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == WS )\n look_26_1 = @input.peek( 2 )\n\n if ( look_26_1.between?( ST, TH ) )\n alt_26 = 1\n end\n end\n case alt_26\n when 1\n # at line 210:42: WS ordinal\n match( WS, TOKENS_FOLLOWING_WS_IN_add_dry_ingredients_807 )\n @state.following.push( TOKENS_FOLLOWING_ordinal_IN_add_dry_ingredients_809 )\n ordinal\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_add_dry_ingredients_813 )\n @state.following.push( TOKENS_FOLLOWING_mixing_IN_add_dry_ingredients_815 )\n mixing\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_add_dry_ingredients_817 )\n @state.following.push( TOKENS_FOLLOWING_bowl_IN_add_dry_ingredients_819 )\n bowl\n @state.following.pop\n match( EOF, TOKENS_FOLLOWING_EOF_IN_add_dry_ingredients_821 )\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n return_value.value = {\n :cmd => :liquefy_ingredient,\n :args => {:ingredient => @input.to_s( return_value.start, @input.look( -1 ) ).text}\n }\n \n # <-- action\n end\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 14 )\n memoize( __method__, add_dry_ingredients_start_index, success ) if @state.backtracking > 0\n\n end\n \n return return_value\n end",
"def setup_recipe(servings = nil)\n @prepsteps_list = []\n unless prepsteps.nil?\n @prepsteps_list = Skill.add_skill_links(prepsteps).split(\"\\n\").map {|line| line.chomp}\n end\n \n @cooksteps_list = []\n unless cooksteps.nil?\n @cooksteps_list = Skill.add_skill_links(cooksteps).split(\"\\n\").map {|line| line.chomp}\n end\n \n @new_servings = servings\n end",
"def recipe_params\n params.require(:recipe).permit(:name, {:category_ids => []}, :description, :picture, :times, :quantity, \n :ingredients, {:main_ingredient_ids => []}, :directions, {:source_ids => []}, :wine, :difficulty, :cost)\n end",
"def set_recipes(fridge)\r\n # put recipes you want to puts manumally\r\n recipe_ingredients = {\"Teriyaki\" =>[\"chicken\",\"sugar\",\"mirin\",\"soy sauce\"],\r\n \"Curry rice\" => [\"rice\",\"curry mix\",\"potato\",\"onion\",\"beef\",\"carrot\"],\r\n \"Oyakodon\" => [\"chicken\",\"sugar\",\"mirin\",\"soy sauce\",\"rice\",\"egg\",\"onion\"],\r\n \"Takoyaki\" => [\"flour\",\"octopus\",\"ginger\",\"dashi\"],\r\n \"Nikujyaga\" => [\"beef\",\"sugar\",\"mirin\",\"soy sauce\",\"carrot\",\"onion\",\"potato\"],\r\n \"Octopus Sashimi\" => [\"octopus\",\"soy sauce\"],\r\n \"Miso soup\" => [\"miso\",\"dashi\"]}\r\n\r\n # set recipes_array to make new instence of Recipe\r\n recipes_array = {\"Teriyaki\" => [\"http://natashaskitchen.com/2015/12/11/easy-teriyaki-chicken/\",15],\r\n \"Curry rice\" => [\"http://www.japanesecooking101.com/curry-and-rice-recipe/\",40],\r\n \"Oyakodon\" => [\"http://www.justonecookbook.com/oyakodon/\",30],\r\n \"Takoyaki\" => [\"http://www.justonecookbook.com/takoyaki-recipe/\",20],\r\n \"Nikujyaga\" => [\"http://www.justonecookbook.com/nikujaga/\",30],\r\n \"Octopus Sashimi\" => [\"http://www.makesushi.com/sashimi/\",5],\r\n \"Miso soup\" =>[ \"http://steamykitchen.com/106-simple-10-minute-miso-soup.html\",5]}\r\n\r\n # make new instance and put to fridge.recipes\r\n recipes_array.each do |key,value|\r\n new_recipe = Recipe.new(key,value[0],value[1])\r\n new_recipe.ingredients = recipe_ingredients[\"#{key}\"]\r\n fridge.recipes << new_recipe\r\nend # recipes_array each end\r\nend",
"def recipeingredient_params\n params.require(:recipeingredient).permit(:recipe, :ingredient)\n end",
"def create\n\n @recipe = Recipe.new(recipe_params)\n @recipe.recipe_creator_id = current_user.id\n @recipe.allergies = get_allergies_from_params\n @recipe.ingredients = get_selected_ingredients\n\n #Shows an example on how to automatically check whether a recipe is suitable for a person with an intolerance\n laktoseintoleranz = Allergy.where(name: 'Laktoseintoleranz').first\n unless @recipe.allergies.include?(laktoseintoleranz)\n neo = Neography::Rest.new({:username => \"user\", :password => \"user\"})\n includes_laktose_ingredient = false\n\n @recipe.ingredients.each do |ingredient|\n node = neo.execute_query(\"MATCH (n)-[]->(i) WHERE n.name = 'Laktoseintoleranz' AND i.name = '#{ingredient.name}' RETURN i\")\n if node[\"data\"].present?\n includes_laktose_ingredient = true\n end\n end\n unless includes_laktose_ingredient\n @recipe.allergies << laktoseintoleranz\n end\n end\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6748412",
"0.6662905",
"0.6610343",
"0.64455575",
"0.6413762",
"0.62204766",
"0.6166567",
"0.61380947",
"0.60759425",
"0.60725015",
"0.6050936",
"0.60441715",
"0.5994077",
"0.5986222",
"0.59794575",
"0.5963098",
"0.59533465",
"0.59493",
"0.59084475",
"0.58980036",
"0.58615476",
"0.5854495",
"0.5838782",
"0.583406",
"0.58285105",
"0.58014345",
"0.5785793",
"0.5778697",
"0.57785064",
"0.57711506",
"0.5767953",
"0.57645744",
"0.57607687",
"0.57538414",
"0.57501805",
"0.5743358",
"0.57345986",
"0.5712916",
"0.570802",
"0.570793",
"0.5707172",
"0.5695448",
"0.567633",
"0.5660687",
"0.5652376",
"0.56516063",
"0.56342363",
"0.56298125",
"0.56210124",
"0.5611459",
"0.56037873",
"0.56028765",
"0.55928123",
"0.55917424",
"0.5589453",
"0.55827224",
"0.5575185",
"0.5564548",
"0.5561737",
"0.5554994",
"0.5551357",
"0.5540433",
"0.5538489",
"0.55342364",
"0.55321115",
"0.5526199",
"0.5523203",
"0.550963",
"0.5503568",
"0.55009925",
"0.5485694",
"0.5475191",
"0.54728186",
"0.54724467",
"0.5469902",
"0.54669785",
"0.54646856",
"0.54577404",
"0.5455209",
"0.5453784",
"0.5451212",
"0.5445945",
"0.5439445",
"0.543719",
"0.54331094",
"0.54331094",
"0.5432943",
"0.5432055",
"0.543016",
"0.5422818",
"0.54218733",
"0.54188925",
"0.5416558",
"0.54160273",
"0.5411327",
"0.54076",
"0.53971267",
"0.5393907",
"0.53868854",
"0.5385122",
"0.5384865"
] | 0.0 | -1 |
name of fields that must be present, e.g. %(name description) | def test_invalid_with_blank_attributes
offer = Offer.new
assert !offer.valid?
assert !offer.errors.invalid?(:saleman_id)
assert offer.errors.invalid?(:name)
assert !offer.errors.invalid?(:name_normalized)
assert offer.errors.invalid?(:amount)
assert offer.errors.invalid?(:deal_date)
assert offer.errors.invalid?(:customer_id)
assert !offer.errors.invalid?(:description)
assert offer.errors.invalid?(:status_id)
assert !offer.errors.invalid?(:weight)
assert !offer.errors.invalid?(:description_normalized)
assert !offer.errors.invalid?(:delta)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_fields\n fields = %w{ipaper_id ipaper_access_key}.inject([]){|stack, f| stack << \"#{name}##{f}\" unless column_names.include?(f); stack}\n raise ScribdFuError, \"These fields are missing: #{fields.to_sentence}\" if fields.size > 0\n end",
"def validate_fields\n # TODO: Define other fields that are required for projects\n %w[name].all? do |field|\n value = send(field)\n if value.nil? || value.size.zero?\n add_error \"Projects requires a '#{field}' field\"\n else\n true\n end\n end\n end",
"def required_fields\n required_fields = []\n ignore_fields = [:id, :date_entered, :date_modified]\n self.fields.each_value do |field|\n next if ignore_fields.include? field[\"name\"].to_sym\n required_fields << field[\"name\"].to_sym if field[\"required\"] == 1\n end \n required_fields\n end",
"def required_fields\n required_fields = []\n ignore_fields = [:id, :date_entered, :date_modified]\n self.fields.each_value do |field|\n next if ignore_fields.include? field[\"name\"].to_sym\n required_fields << field[\"name\"].to_sym if field[\"required\"] == 1\n end \n required_fields\n end",
"def has_field?(name)\n fields.key?(name.to_sym)\n end",
"def description\n \"validate the presence of any of these attributes: #{attributes.join(', ')}\"\n end",
"def test_mandatory_field(field, fieldname)\n if field.nil?\n show_usage\n ui.fatal(\"You must specify a #{fieldname}\")\n exit 1\n end\n end",
"def has_required_fields\n return unless format.is_a?(LocalPostal::Format)\n\n format.required_fields.each do |field|\n field_name = self.class.formatting_variables_lookup_table[field.to_sym]\n value = public_send(field_name)\n errors.add(field_name, 'is required') if \"#{value}\".empty?\n end\n end",
"def required_fields\n []\n end",
"def display_name(opts)\n opts = check_params(opts,[:field_names])\n super(opts)\n end",
"def check_fields\n columns= resource.model.column_names - AutoRest::AR_MAGIC_COLUMNS\n\n default_columns= columns.select { |attr| attr !~ /.*_count$/ }.map do |elem|\n [elem.intern, elem.titleize]\n end\n\n # For storing columns, I use an array and not a hash --i.e.: (:column => 'Title') -- \n # to ensure the order of the columns. I convert the params from linear array to \n # grouped array to alivianate user's data entry:\n # [[:col0, \"name0\"], [:col1, \"name1\"]] becomes [:col0, \"name0\", :col1, \"name1\"]\n \n # *TODO* This should be cleaned a little, because right now is a bit difficult\n # to remember the way the attributes for each view work.\n\n [:for_index, :for_new, :for_edit, :for_show].each do |key|\n arr= fields.send(key)\n exc= exclude_fields.send(key)\n\n if !arr # User has not supplied columns.\n arr= default_columns\n else\n # enum_for creates an enum from array, therefore protecting the original array contents.\n # each slice returns an array of specified elements: [1,2,3,4] => 1..4 => [[1,2],[3,4]]\n arr= arr.enum_for(:each_slice, 2).to_a\n end\n \n # Remove excluded fields.\n arr= arr.reject { |e| exc.map{|elem|elem.to_s}.include?(e[0].to_s) } if exc\n fields.send(\"#{key}=\", arr)\n end\n end",
"def check_required_fields(data)\r\n @field_names[1..-1].each do |f|\r\n raise(ArgumentError,\r\n 'A value for this field is required: %s' % f) if \\\r\n @field_requireds[@field_names.index(f)] and data[f].nil? \r\n end\r\n end",
"def required_fields\n # \"cid\" is not required\n [\n \"byr\",\n \"ecl\",\n \"eyr\",\n \"hcl\",\n \"hgt\",\n \"iyr\",\n \"pid\",\n ]\nend",
"def has_invalid_fields?\n if invalids = invalid_fields(fields)\n say 'Invalid field name:', :red\n say \" #{invalids.join(\", \")}\"\n end\n end",
"def has_field?(field_name); end",
"def field(name); end",
"def required_csv_fields\n [:email, :name]\n end",
"def validate_fields\n %w[email author].each do |field|\n value = self.send(field)\n abort \"Hoe #{field} value not set. aborting\" if value.nil? or value.empty?\n end\n end",
"def field_exists?(name)\n @fields.key?(name.to_s) || @fields.key?(name.to_sym)\n end",
"def names\n NAME_FIELDS.map { |k| has_field?(k) ? @fields[k].tokens : nil }.flatten.compact\n end",
"def field_required(member, template)\n member ? \"\\n\" + '%span.error This field is required' : ''\n end",
"def all_required(data, fields)\t\t\n\t\tif fields.nil? == true\n\t\t\treturn true\n\t\tend\n\t\t@api_errmsg = Array.new\n\t\tfields = fields.split(',')\n\t\tflag = true\n\t\tfields.each do |name|\n\t\t\tif data[name].nil?\n\t\t\t @api_errmsg.push(name)\n\t\t\t flag = false\n\t\t\tend\n\t\tend\n\t\tif flag == true\n\t\t return true\n\t\tend\n\t\treturn false\n\tend",
"def get_field_names(template); end",
"def validated_attribute_names(params); end",
"def method_missing name, *args, &block\n if name.to_s =~ /^(.+)_fields$/\n self.fields.select {|f| f.data_type.to_s.parameterize.underscore == $1 } || super\n else \n super\n end\n end",
"def required?(name); end",
"def validate_required(posted, fields)\n errors = {}\n fields.each do |key|\n if (!(posted.include?(key) && !posted[key].nil? && posted[key].length > 0))\n errors[key] = \"#{key.capitalize} is required.\"\n end\n end\n\n errors\n end",
"def fields(names)\r\n names.each { |name| @template.concat(field(name)) }\r\n ''\r\n end",
"def required_fields\n if self.controller_name == \"registrations\"\n param_name = \"user\"\n elsif self.controller_name == \"merchants\"\n param_name = \"merchant\"\n else\n return\n end\n empty_fields = Array.new\n empty = false\n params[param_name].each_pair do |k, v|\n if v == \"\"\n empty_fields << k.gsub(\"_\", \" \")\n empty = true\n end\n end\n if empty == true\n (0..empty_fields.length - 3).each do |i|\n empty_fields[i] << \",\"\n end\n empty_fields.insert(-2, \"and\") unless empty_fields.length < 2\n field_list = empty_fields.join(\" \")\n message = \"You cannot leave empty fields. The field\" \n if empty_fields.length > 1\n message << \"s \"\n else\n message << \" \"\n end\n message << field_list \n if empty_fields.length > 1\n message << \" were left blank.\"\n else\n message << \" was left blank.\"\n end\n flash[:notice] = message\n redirect_to request.referrer\n else\n return\n end\n end",
"def required_custom_params\n custom.select{|param| param[\"required\"]}.map{|param| param[\"name\"]}\n end",
"def field_name\r\n @field_name ||= begin\r\n %r/(\\w+)Field$/.match(name)[1]\r\n rescue\r\n %r/(\\w+)$/.match(name)[1]\r\n end\r\n end",
"def fields\n %i[ position_title employee_type request_type\n contractor_name number_of_months annual_base_pay\n nonop_funds nonop_source justification organization__name unit__name\n review_status__name review_comment user__name created_at updated_at ]\n end",
"def fields; end",
"def fields; end",
"def fields; end",
"def field_names\n fields.keys\n end",
"def missing_param_errors\n\t\treturn self.missing.collect do |field|\n\t\t\tconstraint = self.constraints[ field.to_sym ] or\n\t\t\t\traise NameError, \"no such field %p!\" % [ field ]\n\t\t\t\"Missing value for '%s'\" % [ constraint.description ]\n\t\tend\n\tend",
"def has_field(field_name)\n\t\tend",
"def field_requireds\r\n return @field_requireds\r\n end",
"def validate_name\n errors.add(:abstract, \"person_name or company_name must be present\") unless (person_name || company_name)\n end",
"def fields?; @fields; end",
"def attributes_that_should_not_be_in_database_field_names\n [\"id\", \"errors\"]\n end",
"def field?(name)\n ! self[name].nil?\n end",
"def has_field?(name)\n aliased_fields.has_key?(name) || fields.has_key?(name)\n end",
"def check_fields(parsed, paper_path)\n if paper_path.include?('.tex')\n expected_fields = EXPECTED_LATEX_FIELDS\n else\n expected_fields = EXPECTED_MARKDOWN_FIELDS\n end\n fields = expected_fields - parsed.keys\n raise \"Paper YAML header is missing expected fields: #{fields.join(', ')}\" if !fields.empty?\n end",
"def type_information(opts)\n opts = check_params(opts,[:field_names])\n super(opts)\n end",
"def validate_name_parts\n name_part_types.each do |type|\n next if send \"valid_#{type}?\"\n errors.add type, \"valid #{type} required\"\n end\nend",
"def get_field_names(template)\n read(template).fields.map{|f| f.name}\n end",
"def contact_fields\n if contact_type == 'contact'\n validates_length_of :first_name, minimum: 2, maximum: 20 if validates_presence_of :first_name\n validates_length_of :last_name, minimum: 2, maximum: 20 if validates_presence_of :last_name\n end\n end",
"def check_name_description_fields\n within(\"#name_description_form\") do |form|\n if source_type_field_state == :disabled\n assert(form.has_field?(\"description_source_type\", disabled: true))\n else\n assert(form.has_no_field?(\"description_source_type\", disabled: true))\n end\n if permission_fields_state == :disabled\n assert(form.has_field?(\"description_public_write\", disabled: true))\n assert(form.has_field?(\"description_public\", disabled: true))\n else\n assert(form.has_no_field?(\"description_public_write\", disabled: true))\n assert(form.has_no_field?(\"description_public\", disabled: true))\n end\n end\n end",
"def fields\n %i[ request_model_type position_title employee_type request_type\n contractor_name employee_name annual_cost_or_base_pay\n nonop_source justification organization__name unit__name\n review_status__name review_comment user__name created_at updated_at ]\n end",
"def process_field(field_name)\n if ['id', 'name', 'first_name', 'node_id'].include?(field_name)\n \"#{table}.#{field_name}\"\n else\n super # raises\n end\n end",
"def method_missing(name, *args, &block)\n #:nodoc:\n # Only take the structured fields, as we could take _anything_ really\n # as it could become an optional field... \"but therin lies the dark side\"\n field_name = underscoreize(name).chomp(\"=\")\n if Mail::Field::KNOWN_FIELDS.include?(field_name)\n if args.empty?\n header[field_name]\n else\n header[field_name] = args.first\n end\n else\n super # otherwise pass it on\n end\n #:startdoc:\n end",
"def field_names\n (text_fields + html_fields + atom_fields + datetime_fields +\n number_fields + geo_fields).uniq\n end",
"def name_present\n if name.blank?\n errors.add(:name, \"Can't be empty\")\n end\n end",
"def validate_required_fields\n user = new_record? ? author : current_journal.try(:user)\n\n required_attribute_names(user).each do |attribute|\n if /^\\d+$/.match?(attribute)\n attribute = attribute.to_i\n v = custom_field_values.detect {|v| v.custom_field_id == attribute}\n if v && Array(v.value).detect(&:present?).nil?\n errors.add(v.custom_field.name, l('activerecord.errors.messages.blank'))\n end\n else\n if respond_to?(attribute) && send(attribute).blank? && !disabled_core_fields.include?(attribute)\n next if attribute == 'category_id' && project.try(:issue_categories).blank?\n next if attribute == 'fixed_version_id' && assignable_versions.blank?\n\n #####\n # START PATCH\n next if attribute == 'typology_id' && !project.module_enabled?('typologies')\n next if attribute == 'typology_id' && project.typologies.blank?\n # END PATCH\n #####\n\n errors.add attribute, :blank\n end\n end\n end\n end",
"def field?(name)\n @attributes.key?(name)\n end",
"def check_fields\n raise NotImplementedException\n end",
"def fields\n missing_method :fields\n end",
"def get_field_name\n\t\tend",
"def required_keywords; end",
"def text_field?(field_name); end",
"def field_name\n self.well_info.field_name\n end",
"def get_field_errors(actual, object_name, create_object)\n # Check that actual is a ruby dict\n unless actual.is_a? Hash\n return format('%s object: must be ruby hash', object_name)\n end\n\n # missing_list contains a list of all the required parameters that were\n # not passed. It is initialized to all required parameters.\n missing_list = @required_params[object_name].clone\n\n # For each key, if it is not required or optional, it is not allowed\n # If it is requried, remove that parameter from the missing_list, since\n # it is no longer missing\n # actual.each do |key, value|\n\n actual.each do |key, _value|\n if !@required_params[object_name].include?(key.to_s) && !@optional_params[object_name].include?(key.to_s)\n return format('%s object: invalid field: %s', object_name, key)\n end\n\n # Remove field from copied list if the field is in required\n if @required_params[object_name].include? key.to_s\n # missing_list.delete(key.to_s)\n missing_list.delete_at(missing_list.index(key.to_s))\n end\n end\n\n # If there is anything in missing_list, it is an absent required field\n # This only needs to be checked if the create_object flag is passed\n if create_object && !missing_list.empty?\n return format('%s object: missing required field(s): %s',\n object_name, missing_list.join(', '))\n end\n # No errors if we made it this far\n nil\n end",
"def any_present?\n if name.blank? and phone.blank? and license_plate.blank?\n errors.add :base, \"You must fill in at least one field\"\n end\n end",
"def name_valid_format\n if name.present? and not name.match(/[\\w]+([\\s]+[\\w]+){1}+/)\n errors.add :name , \"must be seperated by space and should not contain any special characters.\"\n end\n end",
"def partial?; @unbound_fields.any?; end",
"def required_fields\n %w[protocol_version username id version network_type address_type\n unicast_address name start_time stop_time]\n end",
"def required_you_track_fields_defined?(project)\n you_track_fields = []\n issues = []\n\n response = @connection.get(\"#{@path_prefix}rest/admin/project/#{project}/customfield\", { 'Cookie' => @cookie, 'Content-Type' => 'text/plain; charset=utf-8' })\n response_xml = REXML::Document.new(response.body)\n\n response_xml.elements.each('projectCustomFieldRefs/projectCustomField') do |element|\n you_track_fields << element.attributes[\"name\"]\n end\n\n YOU_TRACK_REQUIRED.each do |required_field|\n unless you_track_fields.include?(required_field)\n issues << \"Validation Error: Required field '#{required_field}' not found in YouTrack project\"\n end\n end\n\n issues\n end",
"def empty_name_error(type, what)\n validation_error(type, what, 'name is empty')\n end",
"def is_placeholder?(fieldname)\n self.class.placeholders.include?(fieldname.to_sym)\n end",
"def person_name_fields\n \"\".tap do |result|\n fields_for(:person_name) do |f|\n result << f.text_field(:name_prefix)\n result << f.text_field(:first_name)\n result << f.text_field(:middle_name)\n result << f.text_field(:last_name)\n result << f.text_field(:name_suffix)\n end\n end\n end",
"def fields\n %i[ position_title employee_type request_type contractor_name\n number_of_positions hourly_rate hours_per_week number_of_weeks annual_cost\n nonop_funds nonop_source justification organization__name unit__name\n review_status__name review_comment user__name created_at updated_at ]\n end",
"def requirements_for(model, field)\n return '' unless model.respond_to?(:requirements) && model.requirements\n case model.requirements[field]\n when :required\n content_tag :span, 'Required',\n :class => 'validation_for required'\n when :nhin_required\n content_tag :span, 'Required (NHIN)',\n :class => 'validation_for required'\n when :hitsp_required\n content_tag :span, 'Required (HITSP R)',\n :class => 'validation_for required'\n when :hitsp_r2_required\n content_tag :span, 'Required (HITSP R2)',\n :class => 'validation_for required'\n when :hitsp_optional\n content_tag :span, 'Optional (HITSP R)',\n :class => 'validation_for'\n when :hitsp_r2_optional\n content_tag :span, 'Optional (HITSP R2)',\n :class => 'validation_for'\n else\n ''\n end\n end",
"def field_definition_params\n params.permit(:field_definition,:name, :field_type, :validationRegex, :required, :step_definition_id, :errorMessage, :order)\n end",
"def validate_config_fields\n config_fields.each do |field|\n\n # Some fields can be blank\n next if name == \"crossref\" && [:username, :password].include?(field)\n next if name == \"pmc\" && [:journals, :username, :password].include?(field)\n next if name == \"mendeley\" && field == :access_token\n next if name == \"twitter_search\" && field == :access_token\n next if name == \"scopus\" && field == :insttoken\n\n errors.add(field, \"can't be blank\") if send(field).blank?\n end\n end",
"def validates_wholesomeness_of(*attr_names)\n configuration = { :message => \"is already taken\" }\n configuration.merge!(attr_names.pop) if attr_names.last.is_a?(Hash)\n \n validates_each(attr_names) do |record, attr_names|\n unless !configuration[:if].nil? and not configuration[:if].call(record)\n record.errors.add( attr_names, configuration[:message] ) if bad_name? record.send(attr_names)\n end\n end\n end",
"def required_fields\n [:recipe, :ingredient]\n end",
"def hint_hint\n \"(<span class=\\\"required\\\">*</span> indicates a required field)\"\n end",
"def required_field(name, options = {})\n field(name, options.merge(:required => true))\n end",
"def field_supplied( field )\n return false if field.blank?\n return false if BLANK_PLACEHOLDERS.include?( field )\n return true\n end",
"def name_not_blank\n if self.name.blank?\n self.errors.add(:name, I18n.t('stage.errors.blank_name'))\n end\n end",
"def fields_by_name(name)\n @fields.select{|f|f.name==name}\n end",
"def search_fields\n [ 'name', 'email', 'description' ]\n end",
"def validate_on_save(fields)\n raise ActsAsIcontact::ValidationError, \"privateName cannot contain spaces, quotes, slashes or brackets\" if fields[\"privateName\"] =~ /[\\s\\\"\\'\\/\\\\\\[\\]]/\n raise ActsAsIcontact::ValidationError, \"fieldType must be 'text' or 'checkbox'\" unless fields[\"fieldType\"] =~ /^(text|checkbox)$/\n end",
"def fields_missing_errors(*fields)\n !fields_have_errors(*fields)\n end",
"def has_required_keys?(instance, required_keys, ignore_keys, indent: 3)\n success = true\n\n required_keys[\"name\"] = {\n \"type\" => \"String\",\n \"required\" => true\n }\n\n required_keys.each do |key, data|\n next if ignore_keys.include?(key)\n\n if !instance.key?(key)\n bad \"#{key} is missing\", indent: indent\n success = false\n end\n end\n\n success\n end",
"def add_check_fields\n @check_fields = []\n if @signature.require_full_address?\n new_fields = %w[\n person_street\n person_city\n person_street_number\n person_postalcode]\n @check_fields.push(*new_fields)\n end\n @check_fields.push('person_country') if @signature.require_person_country?\n @check_fields.push('person_born_at\\(3i\\)') if @signature.require_born_at?\n @check_fields.push('person_born_at\\(2i\\)') if @signature.require_born_at?\n @check_fields.push('person_born_at\\(1i\\)') if @signature.require_born_at?\n end",
"def named_arg_required(name, obj)\n named_arg_required('name', name) unless name.eql?('name')\n raise ArgumentError, \"Argument \\\"#{name}\\\" cannot be nil\" if obj.nil?\n end",
"def required_properties; end",
"def ensure_par(req, msg = '%<name>s is mandatory: please provide %<flag>s')\n req.each do |k, v|\n raise (msg % { name: k, flag: v }) if self[k].nil?\n end\n end",
"def required_state(opts)\n opts = check_params(opts,[:field_names])\n super(opts)\n end",
"def is_none_fields\n\t\tunless self.designation!=\"none\" && self.department!=\"none\"\n\t\t\tself.errors[:none] << \"=> You can't create none role\"\n\t\tend\n\tend",
"def validate_presence_of(field_name, type)\n type || raise(::ArgumentError, \"Type is required for #{field_name}.\")\n end",
"def validate_presence_of(field_name, type)\n type || raise(::ArgumentError, \"Type is required for #{field_name}.\")\n end",
"def fields!\n @validators.keys.find_all { |key| @validators[key].is_a? ::Proc }\n end",
"def validate_required\n [\n :project_name,\n :status,\n :requester_id,\n :subject_expert_id,\n :sponsor_id,\n :vision,\n :goal,\n :description,\n :scope,\n :advice_required,\n :program_id,\n :train_id,\n :funding_method,\n :cost_center,\n :funding_status,\n :budget_allocated,\n :priority,\n :start_date,\n :end_date,\n :risk_rating,\n :risks,\n :projected_revenue,\n ].each do |field|\n if self.attributes[field.to_s].nil? || self.attributes[field.to_s].blank?\n # intentionally vague!\n add_validation 'All fields are required to perform further validations'\n return false\n end\n end\n true\n end",
"def assert_valid_fields(fields, unique)\n assert_kind_of 'options[:fields]', fields, Array\n\n if fields.empty? && unique == false\n raise ArgumentError, '+options[:fields]+ should not be empty if +options[:unique]+ is false'\n end\n\n fields.each do |field|\n case field\n when Symbol, String\n unless @properties.named?(field)\n raise ArgumentError, \"+options[:fields]+ entry #{field.inspect} does not map to a property in #{model}\"\n end\n\n when Property\n unless field.model == model && @properties.include?(field)\n raise ArgumentError, \"+options[:field]+ entry #{field.name.inspect} does not map to a property in #{model}\"\n end\n\n else\n raise ArgumentError, \"+options[:fields]+ entry #{field.inspect} of an unsupported object #{field.class}\"\n end\n end\n end",
"def document_has_required_fields?\n [value_field, reverse_shelfkey_field, shelfkey_field, combined_key_field].each do |field|\n return false if @original_document[field].blank?\n end\n true\n end",
"def pulp_special_fields(*fields)\n [*fields].each{|f| pulp_special_field(f) }\n end",
"def errors\n \"Missing value for <#{name}> field\" if required && !@value\n end"
] | [
"0.71336955",
"0.66586727",
"0.66270304",
"0.66270304",
"0.65094274",
"0.6503744",
"0.64102864",
"0.6398512",
"0.63885766",
"0.6387416",
"0.631098",
"0.6305874",
"0.62998",
"0.62989205",
"0.6263291",
"0.62580913",
"0.62535125",
"0.6251391",
"0.62501246",
"0.6244178",
"0.6236564",
"0.6199431",
"0.6192842",
"0.61647683",
"0.61584115",
"0.6121182",
"0.6086069",
"0.6071383",
"0.60530895",
"0.6052417",
"0.60435605",
"0.604344",
"0.60159093",
"0.60159093",
"0.60159093",
"0.599959",
"0.5996948",
"0.59571075",
"0.59541285",
"0.5945833",
"0.59384423",
"0.5938276",
"0.5922578",
"0.5904861",
"0.5889476",
"0.5855042",
"0.5847894",
"0.58460236",
"0.5835204",
"0.58297133",
"0.5828843",
"0.5823819",
"0.58167493",
"0.5815795",
"0.58112246",
"0.5791468",
"0.57739323",
"0.5761711",
"0.57565844",
"0.5756465",
"0.57317",
"0.57308257",
"0.57268107",
"0.57245904",
"0.5724011",
"0.5721564",
"0.571743",
"0.5697149",
"0.56966865",
"0.5693931",
"0.5686409",
"0.5679506",
"0.56766385",
"0.5672888",
"0.5670389",
"0.56702876",
"0.5668789",
"0.5663717",
"0.56602275",
"0.5659926",
"0.56397426",
"0.56311417",
"0.5630939",
"0.56302863",
"0.56293845",
"0.56262624",
"0.5624872",
"0.5612402",
"0.56087565",
"0.560297",
"0.5599469",
"0.5598513",
"0.5597444",
"0.55948067",
"0.55948067",
"0.5591502",
"0.55911064",
"0.5590125",
"0.5589164",
"0.55884904",
"0.5582765"
] | 0.0 | -1 |
overriding the superclass instance method | def print_reservations
puts "We do not share our clients info!"
puts "At least for free...."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overrides; end",
"def super_method; end",
"def superclass() end",
"def inherited(base); end",
"def proxy\n super\n end",
"def super_class; end",
"def super_class; end",
"def special\n override\n end",
"def base; self; end",
"def tag; raise 'Override this method'; end",
"def private; end",
"def inherited(klass); end",
"def inherited(klass); end",
"def custom; end",
"def custom; end",
"def type; super; end",
"def virtual; end",
"def initialize()\n # override parent\n end",
"def inherited(subclass); end",
"def invoke\n raise NotImplementedError, \"Author of subclass forgot to implement #invoke\"\n end",
"def invoke\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n raise 'must be implemented in subclasses'\r\n end",
"def call\n # implement in subclasses\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def public_instance_methods(include_super=true) end",
"def call\n raise \"Must subclass and implement call\"\n end",
"def initialize\n super \n end",
"def member\n super\n end",
"def member\n super\n end",
"def modify\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize *args\n super\n end",
"def name; super; end",
"def name; super; end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end",
"def implementation; end",
"def implementation; end",
"def source(override); end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end"
] | [
"0.75096357",
"0.7497163",
"0.7304779",
"0.72871774",
"0.72701025",
"0.72106117",
"0.72106117",
"0.71107566",
"0.7070498",
"0.7052114",
"0.7013441",
"0.69445276",
"0.69445276",
"0.69426984",
"0.69426984",
"0.6940613",
"0.69190264",
"0.69080067",
"0.6890726",
"0.6879407",
"0.6797575",
"0.67865056",
"0.67775106",
"0.67775106",
"0.6774234",
"0.67702323",
"0.6750972",
"0.6727145",
"0.6727145",
"0.6724932",
"0.67212325",
"0.67212325",
"0.67212325",
"0.67159325",
"0.67099035",
"0.67099035",
"0.6697666",
"0.6697666",
"0.6697666",
"0.66935945",
"0.66674304",
"0.66674304",
"0.6664333",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766",
"0.66505766"
] | 0.0 | -1 |
Receive and process user input | def receive_input
input = ''
controls = %w(a s d w)
until controls.include?(input)
input = STDIN.getch
abort 'escaped' if input == "\e"
end
input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_input\n STDIN.gets.strip\n end",
"def user_input_capture\n print \">>: \"\n response = gets.chomp\n response\n end",
"def input_handler\n STDIN.read.split(\"\\n\").each do |line|\n process_line(line)\n end\n end",
"def user_input\n\tgets\nend",
"def read_input\n end",
"def process_input\n\n while movement = connection.gets.chomp\n begin\n parse movement\n end\n end\n end",
"def read_input; end",
"def get_user_input(message)\n puts message\n gets.chomp\n end",
"def process_user_input\n command = get_user_input\n while command != \"quit\"\n perform_command(command)\n command = get_user_input\n end\n puts \"Good bye!\"\nend",
"def receive_line data\n # check if user asks help, call help,\n # or other commands. also check for params\n puts \"I received the following data from the keyboard: #{data}\"\n if data == \"help\"\n help\n return\n end\n \n @queue.push(data)\n end",
"def handle_input\n # Takes user input\n input = STDIN.gets.chomp\n system('clear')\n\n # Single word commands\n # QUIT\n if input == 'quit'\n @run_game = false\n puts \"Thanks for playing!\"\n sleep(3)\n system('clear')\n\n # BACKPACK\n elsif input == 'backpack'\n @player.print_backpack\n\n # HELP\n elsif input == 'help'\n puts \"Use the commands to move around the AirBnB and use items to help you escape.\"\n\n else\n # Double word commands \n input_arr = input.split(\" \")\n # User has only entered one word\n if input_arr.size > 1\n command1 = input_arr[0]\n command2 = input_arr[1]\n # TAKE ITEM\n if command1 == \"take\"\n take_item(command2)\n # USE ITEM\n elsif command1 == \"use\"\n use_item(command2)\n # GO ROOM\n elsif command1 == \"go\"\n go_room(command2)\n else\n # User doesn't specify second command\n puts \"I'll need more information than that!\"\n end\n else\n # User enters invalid command word\n puts \"That isn't a valid command\"\n end\n end\n end",
"def get_input\n #Get input from the user\nend",
"def user_input\n\tuser_selection = gets.strip.to_i\n\tinput_logic(user_selection)\nend",
"def read\n Vedeu.log(type: :input, message: \"Waiting for user input...\\n\")\n\n if raw_mode?\n Vedeu.trigger(:_keypress_, keypress)\n\n elsif fake_mode?\n @key ||= keypress\n\n if @key.nil?\n nil\n\n elsif click?(@key)\n Vedeu.trigger(:_mouse_event_, @key)\n\n elsif Vedeu::Input::Mapper.registered?(@key, name)\n Vedeu.trigger(:_keypress_, @key, name)\n\n elsif interface.editable?\n Vedeu.trigger(:_editor_, @key)\n\n else\n Vedeu.trigger(:key, @key)\n\n end\n\n elsif cooked_mode?\n Vedeu.trigger(:_command_, command)\n\n end\n end",
"def input_listener\n print \"'Ctrl-C' to quit...\\n\"\n while true do\n input = gets.chomp.to_s.downcase\n if ['v','version'].include?(input)\n puts \"Netservate #{@version}\"\n else\n puts \"\\nNot a valid input.\"\n end\n end\n end",
"def get_user_input\n user_input_valid gets.chomp\n end",
"def get_user_input\n print \">> \"\n input = gets.chomp\n begin\n parse_user_input(input)\n rescue StandardError\n invalid_command\n end\n end",
"def listen_for_input\n @log.info \"start listening\"\n while true\n line = @client.gets.chop\n break if !line\n \n msg = JSON.parse(line, :create_additions => true)\n\n case msg.type.to_sym\n when :update_direction\n @lastInput = msg.msg.to_sym\n end\n end\n end",
"def handle_user_input(user_input)\n clean_input = clean_user_input(user_input)\n\n if system_message?(clean_input)\n handle_system_message(clean_input)\n\n # If action exists:\n elsif aprox_trigger?(clean_input)\n action = aprox_trigger?(clean_input)\n handle_action(action)\n\n else\n state_id = session[:state_id]\n update_state_log('system', 'Sorry I don\\'t know what that means')\n end\n\n if not performed?\n redirect_to \"/games/#{session[:game_id]}\"\n end\n end",
"def process_input( user, *input_strings )\n\t\tinput_strings.each do |str|\n\t\t\tcase str\n\n\t\t\twhen %r{^/(\\w+)\\s*(.*)}\n\t\t\t\tself.handle_command( user, $1, $2 )\n\n\t\t\telse\n\t\t\t\tuser.add_output( \"You>> #{str}\" )\n\t\t\t\tself.broadcast_msg_from( user, str )\n\t\t\tend\n\t\tend\n\n\t\tuser.prompt if user.connected?\n\tend",
"def read_input(message, default = '')\n message.split(\"\\n\").each { |e| print \"#{e} \" }\n response = STDIN.gets.chomp\n response.blank? ? default : response\nend",
"def handle_input(input)\n return \"Invalid input\" unless self.respond_to? input\n self.send input\n end",
"def getInput ( question )\n puts question\n response = STDIN.gets.strip\n puts\n response\nend",
"def handle_input(message)\n user = extract_user message\n id = message[:data][:id]\n request = message[:data][:args]\n if (term = TTY[user, id])\n term.write << request.join\n else\n message[:error] = 'Terminal does not exist.'\n end\n end",
"def gets\n @input.gets\n end",
"def get_user_input\n input = gets.chomp\n #input\nend",
"def user_input_command_line_menu\n\tcommand_line_input = gets.strip.to_i\n\tcommand_line_input_logic(command_line_input)\nend",
"def captureInput\n return gets.chomp\n end",
"def read_input\n $stdin.gets.strip\n rescue NoMethodError\n abort \"\\nInput aborted at user request.\"\n end",
"def get_input\n @input = gets.strip\n end",
"def get_user_input\n gets.chomp\nend",
"def get_user_input\n gets.chomp\nend",
"def processInput( user, *inputStrings )\n\t\tinputStrings.each {|str|\n\t\t\tcase str\n\n\t\t\twhen %r{^/(\\w+)\\s*(.*)}\n\t\t\t\thandleCommand( user, $1, $2 )\n\n\t\t\telse\n\t\t\t\tuser.addOutput( \"You>> #{str}\" )\n\t\t\t\tbroadcastMsgFrom( user, str )\n\t\t\tend\n\t\t}\n\n\t\tuser.prompt if user.connected?\n\tend",
"def ask message\n print message\n STDIN.gets.chomp\nend",
"def ask message\n print message\n STDIN.gets.chomp\nend",
"def ask message\n print message\n STDIN.gets.chomp\nend",
"def prompt_and_get_input_from_user\n prompt_user\n input = $stdin.readline.strip\nend",
"def fetch_input(question_to_user)\n print question_to_user\n gets.chomp # return not needed\nend",
"def read_input()\n print \"> \"\n $stdout.flush\n gets\n end",
"def ask(&parser)\n until input = get_input(parser)\n puts @notify_invalid if @notify_invalid\n end\n puts\n input\n end",
"def get_input(*msg)\n print *msg\n return gets.strip\n end",
"def get_input\n gets.chomp\n end",
"def ask_for(detail)\n puts \"Enter #{detail}\"\n STDIN.gets.chomp \nend",
"def ask message\nprint message\nSTDIN.gets.chomp\nend",
"def process_input(raw_input)\n @engine.inject_command(normalized_input(raw_input), self)\n @engine.execute_pending_commands\n end",
"def get_input\n @input = gets.chomp\n end",
"def get_user_input\n\t\tputs \"enter json data, enter __END__ when complete\"\n\n\t\tfinal_user_input = \"\"\n\t\tuser_input = \"\"\n\t until user_input == \"__END__\" \n\t\t final_user_input += user_input\t\n\t\t user_input = gets.chomp\n\t\tend\n\t\treturn final_user_input\n\tend",
"def user_input\n gets.chomp\nend",
"def user_input\n gets.chomp\nend",
"def listen\n\t\t# Before starting we need to get the users name from the user.\n\t\tputs \"Enter your username:\"\n\t\t# Start a new thread that will wait for user input and then\n\t\t# send it onto the server.\n\t\t@response = Thread.new do\n\t\t\tmsg = $stdin.gets.chomp\n\t\t\t@server.puts( msg )\n\t\t\tloop {\n\t\t\t\t# Gets input from the user.\n\t\t\t\tprint \"> \"\n\t\t\t\tmsg = $stdin.gets.chomp\n\t\t\t\t# Check if the message is a server control message crafted by the user.\n\t\t\t\t# Send error message to the user if it is. \n\t\t\t\t# Else send the message to the server for processing.\n\t\t\t\tif (msg =~ @server_message_regex )\n\t\t\t\t\tputs \"Server messages are not permitted on the client!\"\n\t\t\t\telse\n\t\t\t\t\t@server.puts( msg )\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\tend",
"def answer(msg)\n puts Time.now\n puts msg\n STDIN.gets.chomp\nend",
"def input msg\n puts msg\n print \" \"\n return STDIN.gets.chomp\nend",
"def interactive_mode\n\t\tparse_user_input while recv_user_input\n\tend",
"def drb_input!\n Vedeu.bind(:_drb_input_) do |data, type|\n Vedeu.log(type: :drb, message: \"Sending input (#{type})\")\n\n case type\n when :command then Vedeu.trigger(:_command_, data)\n when :keypress then Vedeu.trigger(:_keypress_, data)\n else Vedeu.trigger(:_keypress_, data)\n end\n end\n end",
"def call(input)\n process(input)\n end",
"def process_input(line)\n case line\n when /^:((.+?)(?:!.+?)?) INVITE \\S+ :(\\S+)/i\n handle :incoming_invite, $1, $2, $3\n when /^:((.+?)(?:!.+?)?) PRIVMSG (\\S+) :?\\001ACTION (.+?)\\001$/i\n handle :incoming_act, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) PRIVMSG (\\S+?) :?\\001(.+?)\\001$/i\n handle :incoming_ctcp, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) PRIVMSG (\\S+?) :?(.+?)$/i\n handle :incoming_msg, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) NOTICE (\\S+?) :?\\001(.+?)\\001$/i\n handle :incoming_ctcpreply, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) NOTICE (\\S+?) :?(.+?)$/i\n handle :incoming_notice, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) MODE (\\S+?) :?(\\S+?)(?: (.+?))?$/i\n handle :incoming_mode, $1, $2, $3, $4, $5\n when /^:((.+?)(?:!.+?)?) JOIN :?(\\S+?)$/i\n handle :incoming_join, $1, $2, $3\n when /^:((.+?)(?:!.+?)?) PART (\\S+?)(?: :?(\\S+?)?)?$/i\n handle :incoming_part, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) KICK (\\S+?) (\\S+?) :?(.+?)$/i\n handle :incoming_kick, $1, $2, $3, $4, $5\n when /^:((.+?)(?:!.+?)?) QUIT :?(.+?)$/i\n handle :incoming_quit, $1, $2, $3\n when /^:((.+?)(?:!.+?)?) NICK :?(\\S+?)$/i\n handle :incoming_nick, $1, $2, $3\n when /^PING :?(.+?)$/i\n handle :incoming_ping, $1\n when /^:((.+?)(?:!.+?)?) (\\d{3})\\s+(\\S+?) (.+?)$/i\n handle_numeric($3.to_i, $1, $2, $4, $5)\n else\n handle :incoming_miscellany, line\n end\n end",
"def process(input)\n if input == \"q\"\n puts \"Goodbye\"\n elsif input == \"tweet\"\n puts \"tweeting\"\n elsif input == \"dm\"\n puts \"direct messaging\"\n elsif input == \"help\"\n puts \"helping\"\n end\nend",
"def get_input\n\t#Get input from the user.\n return gets.chomp\nend",
"def get_user_input\n gets.strip\nend",
"def process_input\n if state.user_input == :star\n input_star\n elsif state.user_input == :star2\n input_star2\n elsif state.user_input == :target\n input_target\n elsif state.user_input == :target2\n input_target2\n elsif state.user_input == :remove_wall\n input_remove_wall\n elsif state.user_input == :remove_wall2\n input_remove_wall2\n elsif state.user_input == :add_hill\n input_add_hill\n elsif state.user_input == :add_hill2\n input_add_hill2\n elsif state.user_input == :add_wall\n input_add_wall\n elsif state.user_input == :add_wall2\n input_add_wall2\n end\n end",
"def handleRequest\n loop{\n puts \"User Session Listening\"\n clientMessage = @SocketHandle.gets\n clientMessage.chomp!\n \n case clientMessage\n \n when /viewall/i \n viewAllEvents\n \n when /bookevent/i\n spl = clientMessage.split\n eventid = spl[1] \n qty = spl[2] \n bookEvent @UserID, eventid, qty\n\n when /help/i\n helpCommand\n\n else \n errorCommand\n \n end \n }\n end",
"def get_input\n gets.chomp \nend",
"def read_from_console\n puts 'Enter URL, please:'\n @url = STDIN.gets.chomp\n\n puts 'Enter the name to this link, please:'\n @text = STDIN.gets.chomp\n end",
"def handle_input(input)\n result = eval(input)\n puts(\" => #{result}\")\nend",
"def handle_input(input)\n result = eval(input)\n puts(\" => #{result}\")\nend",
"def get_input\n gets.strip #chomp was also used..\nend",
"def user_input\n user_input = gets.chomp\nend",
"def user_input\n input = gets.chomp\n end",
"def read_user_input(message, default = \"\", show_input = true)\n print interpolate_message(message, default)\n show_input ? gets : silent_command { gets }\n ($_.chomp.empty?) ? default.chomp : $_.chomp\n end",
"def run()\n loop do\n s = @sock.gets\n break if s.nil?\n @mutex.synchronize { handle_server_input(s) }\n end\n end",
"def capture_name\n # puts \"Please type in your first name\" => add outside of testing\n name = $stdin.gets.chomp\n \"Hello, #{name}\"\nend",
"def process_incoming_socket(socket, address)\n input = socket.gets\n server.log.debug(\"Got input: #{input.strip}\")\n run_command(socket, *self.class.parse_command(input))\n socket.close\n end",
"def input( message )\n selection = nil\n\n print message\n until yield(selection = gets.strip)\n print message\n end\n\n selection\n end",
"def client_input(client)\n client.gets.chomp\n end",
"def get_input\n input = gets\n return input\nend",
"def process_user_input(user_input)\n continue_program = true\n\n case user_input\n when 'h'\n Classifieds::CLI.display_help\n when 'i'\n select_item_type\n when 'p'\n tmp_page_size = Classifieds::CLI.prompt('Enter new page size: ').to_i\n @page_size = tmp_page_size if 0 < tmp_page_size\n when 'q'\n continue_program = false\n# when 's'\n# # list sellers instead of items\n when ''\n # display next summary rows\n else\n if (item_number = user_input.to_i).between?(1, Classifieds::Listing.all.size)\n Classifieds::Listing.all[item_number-1].print_detail(item_number)\n else\n STDERR.puts Classifieds::CLI.red('Invalid selection')\n end\n Classifieds::CLI.prompt 'Press Enter to continue...'\n end\n continue_program\n end",
"def stdin; end",
"def input_stdin!\n\t\tif input = STDIN.gets\n\t\t\tunless input.match(/^PRIVMSG(.*)$/)\n\t\t\t\tsay input\n\t\t\t\tprint(\"--> \")\n\t\t\tend\n\t\tend\n\tend",
"def fetch_input(prompt)\n\tprint prompt\n\tgets.chomp #implicit return again\nend",
"def gets_input\n\tgets.strip\nend",
"def get_input message\n\n puts message\n input = gets.chomp.downcase\n\nend",
"def process_input\n if state.current_input == :star\n input_star\n elsif state.current_input == :target\n input_target\n elsif state.current_input == :remove_wall\n input_remove_wall\n elsif state.current_input == :add_wall\n input_add_wall\n end\n end",
"def interactive_menu\n\n loop do\n # 1. print the menu and ask the user what to do\n\tprint_menu \n\n # 2. read the input and save it into a variable\n process(STDIN.gets.chomp)\n \n # 3. do what the user has asked\n\tend\n\t \nend",
"def user_input\n print '>> '.yellow\n case raw_input = gets.chomp\n when 'c', 'cancel' then tell_user \"\\n\";raise ProgramExceptions::Cancel.new\n else\n tell_user \"\\n\"\n return raw_input\n end\n rescue => error\n raise ProgramExceptions::Exit.new if\\\n error.class == ProgramExceptions::Exit ||\n (defined?(IRB) && error.class == IRB::Abort)\n raise error\n end",
"def handle_tcp_input\n while line = @ref_client.gets\n input = self.parse_command(line)\n #Match on command and perform actions\n case input[:command]\n when \"round\"\n #Add a new round to the rounds array when a round starts\n if input[:value][0] == \"start\"\n @rounds.push({\n \"results\": {},\n \"moves\": [],\n \"info\": input[:value][1]\n })\n end\n when \"roundresult\"\n @rounds.last[:results][input[:value][0]] = {\n \"result\": input[:value][1],\n \"score\": input[:value][2]\n }\n when \"matchresult\"\n @match[input[:value][0]] = {\n \"result\": input[:value][1],\n \"score\": input[:value][2]\n }\n when \"move\"\n # Add move to current round\n @rounds.last[:moves].push({\n \"description\": input[:value][0],\n \"data\": input[:value][1]\n })\n when \"gamestate\"\n #Ignore game state \n lastmove = @rounds.last[:moves].last\n #Ignore game state if there aren't any moves\n if lastmove.nil?\n break\n end\n lastmove[:gamestate] = input[:value]\n end\n end\n @status[:error] = false\n end",
"def get_user_input\n puts\n puts \"Type your question below or select from the following:\"\n puts\n puts \"1) Type Q to exit program\"\n puts\n puts \"2) Type P to print all answers\"\n puts\n puts \"3) Type R to reset answers to originals\"\n puts\n puts \"4) Type A to add your own answers to the originals\"\n puts\n question = gets.strip.to_s.downcase\n puts\n handle_user_input(question)\n end",
"def handle_tcp_input\n while line = @ref_client.gets\n input = self.parse_command(line)\n #Match on command and perform actions\n case input[:command]\n when \"round\"\n #Add a new round to the rounds array when a round starts\n if input[:value][0] == \"start\"\n @rounds.push({\n \"results\": {},\n \"moves\": [],\n \"info\": input[:value][1],\n })\n end\n when \"roundresult\"\n @rounds.last[:results][input[:value][0]] = {\n \"result\": input[:value][1],\n \"score\": input[:value][2],\n }\n when \"matchresult\"\n @match[input[:value][0]] = {\n \"result\": input[:value][1],\n \"score\": input[:value][2],\n }\n when \"move\"\n # Add move to current round\n @rounds.last[:moves].push({\n \"description\": input[:value][0],\n \"data\": input[:value][1],\n })\n when \"gamestate\"\n #Ignore game state\n lastmove = @rounds.last[:moves].last\n #Ignore game state if there aren't any moves\n if lastmove.nil?\n break\n end\n lastmove[:gamestate] = input[:value]\n end\n end\n @status[:error] = false\n end",
"def handle_server_input(s)\n s.chomp!(\"\\n\")\n s.chomp!(\"\\r\")\n\n case s\n when /^PING :(.+)$/i\n # Respond to a server ping\n source = Source.new($1)\n message = Message.new(source, nil, 'PING', [ ])\n @callbacks.call('PING', message)\n\n when /^:(.+?)\\s+PRIVMSG\\s+(.+?)\\s+:?[\\001](.+?)(\\s+.+)?[\\001]$/i\n # CTCP message\n source = Source.new($1)\n dest = $2\n msg = $3.upcase\n arg = $4 ? $4.strip : nil\n message = Message.new(source, dest, msg, [ arg ])\n @ctcp_callbacks.call(msg, message)\n\n when /^:(.+?)\\s+(.+?)\\s+(.*)/\n # Server message\n source = Source.new($1)\n msg = $2.upcase\n args = parse_args($3)\n dest = args[0]\n message = Message.new(source, dest, msg, args)\n @callbacks.call(msg, message)\n end\n end",
"def get_user_input(prompt)\n print \"#{prompt}: \"\n gets.chomp\nend",
"def listen()\r\n STDIN.gets.chomp().downcase.gsub(/[^a-z\\s]/, '')\r\nend",
"def interactive_menu\n\n loop do\n # 1. print the menu and ask the user what to do\n print_menu\n # 2. read the input and save it into a variable\n # 3. do what the user has asked\n process(STDIN.gets.chomp)\n end\nend",
"def do_input\n prompted, item = input_prompt\n print '? ' unless prompted\n val = $stdin.gets.chomp\n\n # All digits (and decimal point)\n val = (val.include?('.') ? val.to_f : val.to_i) if val =~ NUMBER_REGEX\n\n @variables[item.value] = val\n end",
"def nlu_handle_input\n # Wit processing will take a while, so we want to show activity\n @message.mark_seen\n @message.typing_on\n return if acted_on_non_questions?\n # Non-questions ruled out, we can\n # save a question to correct later, if needed\n @user.session[:needs_correction] = @message.text\n # Act on a type of question\n act_on_question_types\n # We're done replying\n @message.typing_off\n end",
"def run_input_thread; end",
"def call(input)\r\n process(*input)\r\n end",
"def interactive_menu\n loop do\n #print the menu and ask the user what to do\n print_menu\n #read the input and save it into a variable\n selection = STDIN.gets.chomp\n #do what the user has asked\n process(selection)\n end\n end",
"def handle_input(*input)\n while ch = next_ch(input)\n quit = QUIT_CONTROLS.include?(ch)\n enter = ENTER_CONTROLS.include?(ch)\n inc = INC_CONTROLS.include?(ch)\n dec = DEC_CONTROLS.include?(ch)\n\n break if shutdown? ||\n (quit && (!enter || quit_on_enter?))\n\n if enter\n on_enter\n\n elsif inc\n on_inc\n\n elsif dec\n on_dec\n end\n\n if key_bound?(ch)\n invoke_key_bindings(ch)\n end\n\n on_key(ch)\n end\n\n ch\n end",
"def run\r\n while true do\r\n begin\r\n msg = $stdin.gets\r\n if msg.to_s.include? \"exit\"\r\n break\r\n else\r\n set_socket() #must do it in every run\r\n send_data(msg)\r\n com = msg.to_s.split\r\n if (com[0] == \"add\" or com[0] == \"set\" or com[0] == \"cas\" or com[0] == \"append\" or com[0] == \"prepend\") #must send value\r\n value = read_msg(com[4].to_i) #com[4] -> size of the value to read\r\n send_data(value)\r\n end\r\n retrieve_data()#prints data\r\n #while next_line_readable?(@socket)\r\n # puts @socket.gets.chop #puts every line that the socket sends as response\r\n #end\r\n end\r\n rescue => exception\r\n puts exception.message\r\n puts \"A server failure has been encountered\"\r\n puts \"Closing...\"\r\n sleep(2)\r\n break\r\n end\r\n end\r\n end",
"def process_stdin\n process_file_handle($stdin)\n end",
"def user_choice (text)\n\tputs text\n\tresponse = gets.strip.to_i\n\treturn response\nend"
] | [
"0.7497733",
"0.7290198",
"0.72226727",
"0.7126107",
"0.70062643",
"0.69866526",
"0.6969855",
"0.69353086",
"0.6918222",
"0.690071",
"0.6894507",
"0.68760574",
"0.683526",
"0.6815398",
"0.68057424",
"0.6783606",
"0.67599434",
"0.67415124",
"0.6709307",
"0.6697223",
"0.6680646",
"0.66562814",
"0.66519856",
"0.6639287",
"0.66363424",
"0.6633099",
"0.66317135",
"0.6628014",
"0.6618774",
"0.66152334",
"0.660873",
"0.660873",
"0.66039485",
"0.6597704",
"0.6597704",
"0.6597704",
"0.65832984",
"0.65828943",
"0.65540904",
"0.65426075",
"0.6542325",
"0.6535718",
"0.65274054",
"0.6512565",
"0.6508532",
"0.6498398",
"0.6495992",
"0.64956045",
"0.64956045",
"0.64940137",
"0.64837945",
"0.64727104",
"0.6472007",
"0.64671403",
"0.64656776",
"0.6451167",
"0.64376616",
"0.6427171",
"0.6425164",
"0.64227253",
"0.6421446",
"0.64110875",
"0.6403913",
"0.63969725",
"0.63969725",
"0.63964134",
"0.6390364",
"0.63821816",
"0.6358259",
"0.6352685",
"0.63441634",
"0.634408",
"0.6332501",
"0.6326153",
"0.63168913",
"0.63125306",
"0.6310879",
"0.63085705",
"0.63068837",
"0.6296704",
"0.6294692",
"0.6293907",
"0.628327",
"0.62832254",
"0.6275316",
"0.6274811",
"0.6264208",
"0.62579685",
"0.6250281",
"0.6247433",
"0.6241681",
"0.6227443",
"0.6224899",
"0.62225527",
"0.6220611",
"0.6219705",
"0.62095606",
"0.6190412",
"0.6182095",
"0.61735964"
] | 0.7004477 | 5 |
Creates a new line after the user enters a direction | def shift_left(line)
new_line = []
line.each { |line| new_line << line unless line.zero? }
new_line << 0 until new_line.size == 4
new_line
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_from_entrance\n prompt = TTY::Prompt.new\n @direction = prompt.select(\"You look around the room and you see a chest to your left, an enchantment table in front, and a bookcase to your right.\", %w(Move_to_locked_chest))\n line_break\n end",
"def drive_north(direction)\n if direction == 'N'\n @new_vertical_position = take_input[3].to_i\n @new_vertical_position += 1\n @current_position = \"#{take_input[2].to_i},#{@new_vertical_position}\"\n end\n end",
"def opening_lines \n puts \"What would you like to do?\"\n puts \"(C)reate, (L)ist, (U)pdate, (D)elete, (Q)uit\"\n end",
"def directions\n puts(\"\\tThe Rules: \\n\")\n print(\"\\tPlaying this game is very simple. The game will first display a\\n\")\n print(\"\\trandomly selected word replaced with underscores and a hint to\\n\")\n print(\"\\twhat the word is. The player (you) will then be prompted to enter\\n\")\n print(\"\\teither a vowel or a consonant. The game will then print out anoter\\n\")\n print(\"\\tscreen with any spaces filled in the hidden word if you entered\\n\")\n print(\"\\ta correct guess. The player will than have the option to enter\\n\")\n print(\"\\tthe entire word or keep guessing single letters. WARNING if you\\n\")\n print(\"\\ttry to guess the hidden word and turnout to be incorrect than\\n\")\n print(\"\\tyou lose the game. The wheel is spun for every guess. When\\n\")\n print(\"\\ta player enters a vowel 250 points is deducted, but if a \\n\")\n print(\"\\tplayer enters a correct consonant they win the point for the\\n\")\n print(\"\\tround, Good Luck!\\n\\n\")\n puts (\"Press Enter to continue.\")\n end",
"def direction_same_line( line, route )\n journey = route.join(\", \")\n stop_off = route.last\n stop_on = route.first\n\n route.shift\n stops = route.length\n route.pop\n\n if stops >= 1\n puts `clear`\n puts \"-------------------------------------------------------------\"\n puts\n puts \"Your route #{ journey }\"\n puts\n puts \"Take the: #{ line }\" \n puts \"Get on at: #{stop_on}\"\n puts \"Pass through: #{ route.join(\", \") } \"\n puts \"Get off at: #{ stop_off } \"\n puts\n puts \"There are: #{ stops } stops to your destination\"\n puts\n puts \"-------------------------------------------------------------\"\n \n else\n puts \"Your being a dick\"\n puts \"You are getting on at #{stop_off} and getting off at #{stop_off}\"\n end\nend",
"def new_line(command)\n if command[1] == command[3]\n if command[2].to_i > @canvas.width - 2 || command[4].to_i > @canvas.width - 2\n puts 'you can not create the line because it is larger than the canvas'\n return\n else\n line_shape = :horizontal\n end\n elsif command [2] == command[4]\n if command[1].to_i > @canvas.height - 2 || command[3].to_i > @canvas.height - 2\n puts 'you can not create the line because it is larger than the canvas'\n return\n else\n line_shape = :vertical\n end\n else\n puts 'The line you are trying to create is not horizontal or vertical'\n return\n end\n @canvas.commands.new_line(command[1], command[2], command[3], command[4], line_shape)\n end",
"def update_direction!\n direction.place!(command.arguments[:direction])\n end",
"def new_line\n puts \"\\n\"\nend",
"def new_line\n puts \"\\n\"\nend",
"def newline\n incr_y\n end",
"def put_a_line\n puts \"\\n\"\n puts \"/\\\\\" * 40\n puts \"\\n\"\n end",
"def straight\n @line_type = '--'\n self\n end",
"def cursor_to_input_line\n setpos(input_line, 0)\n end",
"def nextline(distance = 1)\n ConsoleGlitter.escape(\"#{distance}E\")\n end",
"def draw_horizontal(line, start_char, end_char)\n start_char.upto(end_char) { |char_idx| @lines[line][char_idx] = PATH_CHAR } \n end",
"def to_next_line\n @history.save_line(line || \"\")\n\n if @history.to_next_line and line = @history.current_line\n replace_line line\n end\n end",
"def create_in_direction dir\n new_room = Room.create({:created_at=>Time.now, :x=>self.x, :y=>self.y, :z=>self.z})\n \n case dir\n when \"north\",:north, 0\n new_room.y += 1\n when \"east\", :east, 1\n new_room.x += 1\n when \"south\",:south, 2\n new_room.y -= 1\n when \"west\",:west, 3\n new_room.x -= 1\n when \"up\",:up, 4\n new_room.y += 1\n when \"down\",:down, 5\n new_room.y -= 1\n end\n \n create_exit(dir, new_room, true) # two way exit\n return new_room\n end",
"def line_choices \n\tputs \"N\"\n\tputs \"L\"\n\tputs \"SIX\"\nend",
"def new_direction(dir)\n @direction = dir unless @turned\n @turned = true\n end",
"def lineListing\n\tputs \"Enter either: N Line, L Line, Six Line\"\nend",
"def begin_of_line\n write_raw \"\\r\"\n end",
"def onUserText(text, view)\n # We only accept input when the state is 1 (i.e. getting the second point)\n # This could be enhanced to also modify the last line created if a length\n # is entered after creating a line.\n # return if not @state == 1\n # return if not @ip2.valid?\n UI.messagebox(\"#{@state}\")\n\n # The user may type in something that we can't parse as a length\n # so we set up some exception handling to trap that\n begin\n value = text.to_l\n rescue\n # Error parsing the text\n UI.beep\n puts \"Cannot convert #{text} to a Length\"\n value = nil\n Sketchup::set_status_text \"\", SB_VCB_VALUE\n end\n return if !value\n\n # Compute the direction and the second point\n pt1 = @ip1.position\n vec = @ip2.position - pt1\n if( vec.length == 0.0 )\n UI.beep\n return\n end\n vec.length = value\n pt2 = pt1 + vec\n\n # Create a line\n self.create_geometry(pt1, pt2, view)\n end",
"def next_line\n prompt = TTY::Prompt.new\n prompt.keypress\n # puts \" \\r\"\n end",
"def line (distance, direction=nil)\n x1, y1 = position\n move distance, direction\n x2, y2 = position\n canvas.line(x1, y1, x2, y2, color)\n end",
"def prevline(distance = 1)\n ConsoleGlitter.escape(\"#{distance}F\")\n end",
"def add_new_dest_dirline(dir_name)\n new_widget = @gui_factory.new_widget('DirLine')\n new_widget.set_dir_name(dir_name)\n @main_widget.add_dest_dirline(new_widget)\n # Update the dirline based on our data\n update_dirline(new_widget)\n end",
"def rl_on_new_line()\r\n if (@visible_line)\r\n @visible_line[0,1] = 0.chr\r\n end\r\n @_rl_last_c_pos = @_rl_last_v_pos = 0\r\n @_rl_vis_botlin = @last_lmargin = 0\r\n if (@vis_lbreaks)\r\n @vis_lbreaks[0] = @vis_lbreaks[1] = 0\r\n end\r\n @visible_wrap_offset = 0\r\n 0\r\n end",
"def put_to_new_next_line(txt)\n l = current_line_range()\n insert_txt_at(txt, l.end + 1)\n set_pos(l.end + 1)\n end",
"def print_horizontal_line(length)\n print '+'\n (length - 2).times do |index|\n print '-'\n end\n print '+'\n print \"\\n\"\n end",
"def draw_vertical(start_line, end_line, start_char)\n start_line.upto(end_line) do |line_idx| \n @lines[line_idx][start_char] = PATH_CHAR \n end\n end",
"def from_line\n position.new_line\n end",
"def onUserText(text, view)\n # We only accept input when the state is 1 (i.e. getting the second point)\n # This could be enhanced to also modify the last line created if a length\n # is entered after creating a line.\n return if not @state == 1\n return if not @ip2.valid?\n \n # The user may type in something that we can't parse as a length\n # so we set up some exception handling to trap that\n begin\n value = text.to_l\n rescue\n # Error parsing the text\n UI.beep\n puts \"Cannot convert #{text} to a Length\"\n value = nil\n Sketchup::set_status_text \"\", SB_VCB_VALUE\n end\n return if !value\n\n # Compute the direction and the second point\n pt1 = @ip1.position\n vec = @ip2.position - pt1\n if( vec.length == 0.0 )\n UI.beep\n return\n end\n vec.length = value\n pt2 = pt1 + vec\n\n # Create a line\n self.create_geometry(pt1, pt2, view)\n self.reset(view)\nend",
"def winsertln\n Ncurses.winsertln(pointer)\n end",
"def prompt(sentence)\n puts \">> #{sentence}\"\nend",
"def command direction\n ny, nx, nangle = near_xy(direction)\n if @labirint[ny][nx] == 0 || @labirint[ny][nx] == 2\n @x = nx\n @y = ny\n print\n @angle = nangle % 4\n end\n end",
"def move_foward(n); print \"\\e[#{n}C\" end",
"def space()\n # pocitanie riadkov\n self.line.push position if /\\n/ === data[position]\n /\\s/ === data[position]\n\n end",
"def add_line(s=nil)\n @string << \"\\n#{@@indenation * @indentation_level}#{s}\"\n end",
"def get_valid_dep_line\n # Get input for departure line\n @dep_line = prompt {\"departure train line (n, l, s): \"}\nend",
"def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end",
"def enter_line(line)\n handle_fiber(line.chomp)\n end",
"def create_direction(direction_text,question_bank_id,tenant_id)\n direction = Direction.find_by_direction_text_and_question_bank_id(direction_text,question_bank_id)\n if direction.nil? or direction.blank?\n direction = Direction.new\n direction.direction_text = direction_text\n direction.question_bank_id = question_bank_id\n direction.tenant_id = tenant_id\n direction.save\n end\n return direction\n end",
"def insert_line\n\t\t@first = params[:placement]['first'].to_f\n\t\t@second = params[:placement]['second'].to_f\n\t\t@new_order_number = @first + ( @second - @first ) / 2\n\t\t@lyric_id = params[:lyric_id]\n\t\t@lyric_line = LyricLine.new lyric_id: @lyric_id, order_number: @new_order_number\n\t\t@new = true\n\tend",
"def prompt\n print \">> \"\nend",
"def display_path path\r\n\tif path.length <= 1\r\n\t\tputs \"You are already at your destination :-)\"\r\n return\r\n end\r\n\tputs \"You made it in #{path.length - 1} move#{path.length > 2 ? \"s\" : \"\"}! Here's your path:\"\r\n path_string = \"\"\r\n\tpath.each { |position| path_string += position.to_s + \"-->\" }\r\n\tpath_string[-3..-1] = \"\"\r\n\tputs path_string\r\nend",
"def draw_text_field\n setpos(divider_line, 0)\n attron(color_pair(COLOR_WHITE) | A_NORMAL) {\n addstr(\"Current Room:#{@currentRoom} #{(@joinedRooms.delete(@currentRoom)).to_a}\" + \" \" * cols)\n }\n cursor_to_input_line\n clrtoeol\n end",
"def insert_next\n @text.scan(@regex) {|match|\n question = match.join(\" \");\n # check the mapping:\n if(@map.has_key?(question))\n insert_answer(@map[question])\n else\n if(question.include?(\":\"))\n question = question.split(\":\")[1]\n end\n # request an input and specify which method to use for processing the input\n return [\"Please enter #{question}.\", :insert_answer]\n end\n }\n # using the # will cause the bot to start a new line, the nil says we're done\n return [@text, nil]\nend",
"def insert_after\r\n @lines.insert(@line_num, TextLineBuffer.new(\"\"))\r\n @line_num = @line_num + 1\r\n end",
"def new_line(times = 1)\n times.times do\n print \"\\n\"\n end\n\n end",
"def submit_line\n line = self.line\n return unless line\n\n self.read_only = true\n\n change_cursor do |c|\n c.move_position Qt::TextCursor::End\n c.merge_char_format ANSIToQt::Styles[:clear]\n c.insert_text \"\\n\"\n end\n\n enter_line(line)\n end",
"def print_new_line\n puts ''\nend",
"def next_move\n puts \"What do you want to do next? Type any key to restart or type 'exit' to leave\"\n @choice = gets.strip\n end",
"def move\n ##incrementing or decrementing eg. current_direction W,\n ##position_x decrementing by 1 (-=1)\n if @current_direction == \"N\"\n @position_y += 1\n puts \"#{@position_y}\"\n elsif @current_direction == \"E\"\n @position_x += 1\n elsif @current_direction == \"W\"\n @position_x -= 1\n elsif @current_direction == \"S\"\n @position_y -= 1\n end\n\n end",
"def display_path path\n\tif path.length <= 1\n\t\tputs \"You are already at your destination :-)\"\n return\n end\n\tputs \"You made it in #{path.length - 1} move#{path.length > 2 ? \"s\" : \"\"}! Here's your path:\"\n path_string = \"\"\n\tpath.each { |position| path_string += position.to_s + \"-->\" }\n\tpath_string[-3..-1] = \"\"\n\tputs path_string\nend",
"def print_in_box(text)\n horizontal = \"+\" + \"-\" * (text.length + 2) + \"+\"\n text_line = \"| \" + text + \" |\"\n vertical = \"|\" + \" \" * (text.length + 2) + \"|\"\n\n puts horizontal\n puts vertical\n puts text_line\n puts vertical\n puts horizontal\nend",
"def process_new_line\n @status.line += 1\n\n @skip_next = true if ((@cur_char == \"\\n\" && @next_char == \"\\r\") ||\n (@cur_char == \"\\r\" && @next_char == \"\\n\"))\n end",
"def determine_heading(new_position)\n case $track[[new_position[0], new_position[1]]]\n when \"\\\\\"\n if @direction == :right || @direction == :left\n turn_right\n else\n turn_left\n end\n when \"/\"\n if @direction == :right || @direction == :left\n turn_left\n else\n turn_right\n end\n when \"+\"\n # turn order goes left -> straight -> right\n if @last_turn_direction == :right\n @last_turn_direction = :left\n turn_left\n elsif @last_turn_direction == :left\n @last_turn_direction = :straight\n # no turn necessary\n else # last turn was straight\n @last_turn_direction = :right\n turn_right\n end\n end\n end",
"def move_backward(n); print \"\\e[#{n}D\" end",
"def prompt(text)\n puts \">> \" + text\nend",
"def line_feed\n write_raw \"\\n\"\n end",
"def input_handler(input)\n case input\n when \"w\"\n update_direction(\"N\")\n when \"s\"\n update_direction(\"S\")\n when \"a\"\n update_direction(\"O\")\n when \"d\"\n update_direction(\"W\")\n end\nend",
"def prompt(text)\n print \">> \" + text\nend",
"def l_line\n puts `clear`\n\n puts \"--------------L Line-------------------\"\n puts\n puts \"[6] - 8th\"\n puts \"[7] - 6th\"\n puts \"[5] - Union Square\"\n puts \"[8] - 3rd\"\n puts \"[9] - 1st\"\n puts \n puts \"---------------------------------------\"\n\n\n user_choice = fetch_input \"Please enter your selection [#]: \"\n \n case user_choice\n when \"6\",\"7\",\"5\",\"8\",\"9\"\n return station(user_choice)\n else\n puts \"not a valid number try again\"\n gets\n l_line \n end\n\nend",
"def normal_line(text)\n end",
"def turn(direction)\n\t\t\tcase @heading\n\t\t\t\twhen 'N' then @heading = (direction == 'L') ? 'W' : 'E'\n\t\t\t\twhen 'E' then @heading = (direction == 'L') ? 'N' : 'S'\n\t\t\t\twhen 'S' then @heading = (direction == 'L') ? 'E' : 'W'\n\t\t\t\twhen 'W' then @heading = (direction == 'L') ? 'S' : 'N'\n\t\t\t\telse return\n\t\t\tend\n\t\tend",
"def l_command\n @heading = case @heading\n when \"N\" then \"W\"\n when \"E\" then \"N\"\n when \"S\" then \"E\"\n when \"W\" then \"S\"\n end\n end",
"def print_help\n\n puts\n puts \"You can type a direction to move: 'north', 'south', 'east' and 'west'.\".colorize(:red).indent(10)\n puts\n puts \"You can type 'exits' to see which way you can go.\".colorize(:red).indent(10)\n puts\n puts \"You can type 'quit' to save your character and quit.\".colorize(:red).indent(10)\n puts\n\nend",
"def prompt\n print \">> \"\nend",
"def mark_position\n \t@game_board.print_board\n\t\tprintf \"Make your move: \"\n\t\tinput = gets.chomp\n\t\tfrom = input[0..1]\n\t\tto = input[2..3]\n\n\t\tuntil input.length == 4 && @game_board.update_board(from, to, @color)\n\t\t\tputs \"#{input} is either not a valid input or unavailable. Please try again.\"\n\t\t\tprintf \"Make your move: \"\n\t\t\tinput = gets.chomp\n\t\t\tfrom = input[0..1]\n\t\t\tto = input[2..3]\n\t\tend\n end",
"def create_line(num)\n '-' * num\nend",
"def enter(line)\n @standard_output.advance\n @standard_error.advance\n @stdin.puts line\n end",
"def line(text, length=20)\n puts \"-\" * length\n puts text \nend",
"def start()\n puts <<END\nYou are in a dark room.\nThere is a door to your right and left.\nWhich one do you take?\nEND\n\n next_move = prompt\n\n if next_move == \"left\"\n bear_room()\n elsif next_move == \"right\"\n cthulu_room()\n else\n dead(\"You stumble around the room until you starve.\")\n end\nend",
"def menu\n puts \"Welcome to your local shelter\"\n puts \"(A)\\tTo add a new client\\n(B)\\tTo abandon an animal\\n(C)\\tTo adopt an animal\\n(Z)\\tFor admin features\\n(Q)\\tTo quit\"\n gets.chomp\nend",
"def bug_segment(win, default=0)\n reward = win - default\n reward.times do\n puts extend_bug_line_1 = \" ---- \"\n puts extend_bug_line_2 = \"/ \\\\\"\n puts extend_bug_line_3 = \"l====l\"\n end\nend",
"def new_method\n new(:pos_text => \"\\n\")\n #new\n end",
"def draw_line\n print H_SEP * columns\n end",
"def rl_on_new_line_with_prompt()\r\n # Initialize visible_line and invisible_line to ensure that they can hold\r\n # the already-displayed prompt.\r\n prompt_size = @rl_prompt.length + 1\r\n init_line_structures(prompt_size)\r\n\r\n # Make sure the line structures hold the already-displayed prompt for\r\n # redisplay.\r\n lprompt = @local_prompt ? @local_prompt : @rl_prompt\r\n @visible_line[0,lprompt.length] = lprompt\r\n @invisible_line[0,lprompt.length] = lprompt\r\n\r\n # If the prompt contains newlines, take the last tail.\r\n prompt_last_line = rl_prompt.rindex(\"\\n\")\r\n if prompt_last_line.nil?\r\n prompt_last_line = @rl_prompt\r\n else\r\n prompt_last_line = @rl_prompt[prompt_last_line..-1]\r\n end\r\n l = prompt_last_line.length\r\n if !@rl_byte_oriented\r\n @_rl_last_c_pos = _rl_col_width(prompt_last_line, 0, l)\r\n else\r\n @_rl_last_c_pos = l\r\n end\r\n\r\n # Dissect prompt_last_line into screen lines. Note that here we have\r\n # to use the real screenwidth. Readline's notion of screenwidth might be\r\n # one less, see terminal.c.\r\n real_screenwidth = @_rl_screenwidth + (@_rl_term_autowrap ? 0 : 1)\r\n @_rl_last_v_pos = l / real_screenwidth\r\n # If the prompt length is a multiple of real_screenwidth, we don't know\r\n # whether the cursor is at the end of the last line, or already at the\r\n # beginning of the next line. Output a newline just to be safe.\r\n if (l > 0 && (l % real_screenwidth) == 0)\r\n _rl_output_some_chars(\"\\n\",0,1)\r\n end\r\n @last_lmargin = 0\r\n\r\n newlines = 0\r\n i = 0\r\n while (i <= l)\r\n @_rl_vis_botlin = newlines\r\n @vis_lbreaks[newlines] = i\r\n newlines += 1\r\n i += real_screenwidth\r\n end\r\n @vis_lbreaks[newlines] = l\r\n @visible_wrap_offset = 0\r\n\r\n @rl_display_prompt = @rl_prompt # XXX - make sure it's set\r\n\r\n return 0\r\n end",
"def type(input)\n return close_input if input == \"\\u0004\"\n\n last_command_started.write(input << \"\\n\")\n end",
"def go(direction)\n puts \"You go \".red + direction.to_s.red\n @player.location = find_room_in_direction(direction)\n show_current_description\n end",
"def menu\n draw_line\n puts \" _______________________________________________________ \"\n puts \" | |\"\n puts \" | ~~THE QUEST~~ |\"\n puts \" | |\"\n puts \" | >>>>>>>>>>> 1. Thebes |\"\n puts \" | >>> | 2. Troy |\"\n puts \" | | = | 3. Hades |\"\n puts \" | | __| 4. GO HOME |\"\n puts \" | | -| |\"\n puts \" | |______| |\"\n puts \" | |\"\n puts \" |_______________________________________________________|\"\nend",
"def command(path, p, coords)\n p = whitespace(path, p)\n line_to(path, p, coords) ||\n horizontal(path, p, coords) ||\n vertical(path, p, coords)\nend",
"def turn(direction_wanted)\n if direction_wanted == \"right\"\n puts \"The #{@color} #{@model} turned right.\"\n else direction_wanted == \"left\"\n puts \"The #{@color} #{@model} turned left.\"\n end\n end",
"def generate(title=nil)\n if title.present?\n line_destination = \"#{title.parameterize}\"\n yaml_destination = \"#{line_destination}/line.yml\"\n FileUtils.rm_rf(line_destination, :verbose => true) if options.force? && File.exist?(line_destination)\n if File.exist?(line_destination)\n say \"Skipping #{yaml_destination} because it already exists.\\nUse the -f flag to force it to overwrite or check and delete it manually.\", :red\n else\n say \"Generating #{yaml_destination}\", :green\n Cf::Newline.start([title, yaml_destination])\n say \"A new line named #{line_destination} generated.\", :green\n say \"Modify the #{yaml_destination} file and you can create this line with: cf line create\", :yellow\n end\n else\n say \"Title for the line is required.\", :red\n end\n end",
"def display_menu\n\t\n\tputs \" \"\n\tputs \"Would you like to (a)dd a new apartment, (c)reate a new person?, or (q)uit?\"\n\tputs \" \"\n\tgets.chomp.downcase\nend",
"def nl\n @linebreak = true\n end",
"def read_line(*args)\n options = args.last.respond_to?(:to_hash) ? args.pop : {}\n prompt = args.empty? ? '' : args.pop\n opts = { echo: true, raw: true }.merge(options)\n line = Line.new('')\n ctrls = console.keys.keys.grep(/ctrl/)\n clear_line = \"\\e[2K\\e[1G\"\n\n while (codes = unbufferred { get_codes(opts) }) && (code = codes[0])\n char = codes.pack('U*')\n trigger_key_event(char)\n\n if console.keys[:backspace] == char || BACKSPACE == code\n next if line.start?\n line.left\n line.delete\n elsif console.keys[:delete] == char || DELETE == code\n line.delete\n elsif [console.keys[:ctrl_d],\n console.keys[:ctrl_z]].include?(char)\n break\n elsif ctrls.include?(console.keys.key(char))\n # skip\n elsif console.keys[:up] == char\n next unless history_previous?\n line.replace(history_previous)\n elsif console.keys[:down] == char\n line.replace(history_next? ? history_next : '')\n elsif console.keys[:left] == char\n line.left\n elsif console.keys[:right] == char\n line.right\n else\n if opts[:raw] && code == CARRIAGE_RETURN\n char = \"\\n\"\n line.move_to_end\n end\n line.insert(char)\n end\n\n if opts[:raw] && opts[:echo]\n output.print(clear_line)\n output.print(prompt + line.to_s)\n if char == \"\\n\"\n line.move_to_start\n elsif !line.end?\n output.print(\"\\e[#{line.size - line.cursor}D\")\n end\n end\n\n break if (code == CARRIAGE_RETURN || code == NEWLINE)\n\n if (console.keys[:backspace] == char || BACKSPACE == code) && opts[:echo]\n if opts[:raw]\n output.print(\"\\e[1X\") unless line.start?\n else\n output.print(?\\s + (line.start? ? '' : ?\\b))\n end\n end\n end\n add_to_history(line.to_s.rstrip) if track_history?\n line.to_s\n end",
"def display_footer(message)\n puts \"\\n\\n\"\n message.each {|line| puts \" \" * $sp[:l] + line}\n print \" \" * $sp[:l] + \"Press any key to continue... \"\n STDIN.getch\n puts \"\"\nend",
"def create_route\n puts 'Введите число для выбора операции:'\n puts ' 1 - создать маршрут'\n puts ' 2 - редактировать маршрут'\n puts ' 0 - ОТМЕНА'\n\n entered_number = gets.chomp.to_i\n\n case entered_number\n when 1\n create_new_route\n when 2\n edit_route\n when 0\n puts 'Редактирование маршрута отменено'\n #else\n #puts \"'#{entered_number}' - операция несуществует!\"\n end\n end",
"def up\n @level -= 1\n add_newline\n end",
"def forward(distance = 1)\n ConsoleGlitter.escape(\"#{distance}C\")\n end",
"def insert_line lineno=@current_index\n prompt = \"Insert: \"\n maxlen = 80\n #config={}; \n #config[:default] = line\n #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)\n ret, str = input_string prompt\n #ret, str = rb_getstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)\n $log.debug \" rb_getstr returned #{ret} , #{str} \"\n return if ret != 0\n\n # pad based expect @content not list\n # remove list after a while FIXME\n @list ||= @content\n @list.insert lineno, str\n ## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb\n fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)\n fire_dimension_changed\n end",
"def move(direction)\n\t\tnorth = [\"n\", \"up\", \"north\"]\n\t\teast = [\"e\", \"right\", \"east\"]\n\t\twest = [\"w\", \"left\", \"west\"]\n\t\tsouth = [\"s\", \"down\", \"south\"]\n\t\tif north.include?(direction)\n\t\t\tdirection == \"north\"\n\t\telsif east.include?(direction)\n\t\t\tdirection == \"east\"\n\t\telsif west.include?(direction)\n\t\t\tdirection == \"west\"\n\t\telsif south.include?(direction)\n\t\t\tdirection == south\n\t\tend\n\t\tif $hero.location.exits.has_key?(direction)\n\t\t\tnewroom = $hero.location.exits[direction]\n\t\t\t$hero.location = newroom\n\t\t\t$hero.xy = newroom.xy\n\t\telse\n\t\t\tputs \"You cannot travel #{direction}. The path does not lead there.\"\n\t\tend\n\tend",
"def new_line\n biggest = @biggest_text_height > WLH ? @biggest_text_height : WLH\n @contents_x = 0 \n @contents_y += biggest\n @biggest_text_height = WLH\n end",
"def print_separator_line\nline = \"\"\n3.times do\n3.times { line << SEPARATOR[:horizontal] }\nline << SEPARATOR[:cross]\nend\nputs line[0...line.length - 1]\nprint \"\\t\"\nend",
"def edit_verse()\n\n credential_length = Random.new().rand( LENGTH_RANGE )\n credential_stream = %x[ #{GENERATE_CMD} ]\n credential_string = credential_stream.chomp()[ 0 .. ( credential_length - 1 ) ]\n \n @verse.store( \"#{@line}-#{TimeStamp.yyjjj_hhmm_sst()}\", @verse[ @line ] ) if @verse.has_key?( @line )\n @verse.store( @line, credential_string )\n\n end",
"def move(direction)\n \n end",
"def next_line(input=[])\r\n @tokens = input\r\n @column = -1\r\n @line += 1\r\n end",
"def addline(line, order)\n\t\t#steps.create(installation_id: self, line_id: line.id, order: order)\n\t\tactive_steps.create(line_id: line.id, order: order)\n\tend",
"def enter\n $movement = \"take path\"\n puts \"This room opens up into a somewhat large cavernous room that mostly contains \"\\\n \"a dark and foul looking body of... something. It most likely used to be water, but the lack \"\\\n \"of a current and the fact that the denezins of this place have used it as a latrine for \"\\\n \"what seems like centuries has turned the body into a foul smelling disease ridden pool.\"\\\n \"A path runs along side of the pool leading to other parts of the dungeon.\"\n if @monster\n puts \"An evil #{@monster.monster} is doing its business here.\"\n else\n puts \"Except for an occasional bubbling from the pool, the room is eerily quite.\"\n end\n end",
"def insert_new_line(str, length)\n str.split(/\\r\\n|\\n/).map do |line|\n line.strip!\n if line.display_width < 1\n line\n else\n display_length = pastel.strip(line).display_width\n split_length = (line.length * length / display_length).to_i\n line.scan(/.{1,#{split_length}}/).join(\"\\n\") rescue line\n end\n end.join(\"\\n\")\n end"
] | [
"0.6246486",
"0.59883565",
"0.5887853",
"0.58739907",
"0.58614314",
"0.5860599",
"0.5846479",
"0.574541",
"0.574541",
"0.5697722",
"0.5667974",
"0.5637402",
"0.5620091",
"0.56145984",
"0.56060076",
"0.5598454",
"0.5581754",
"0.5549809",
"0.55481017",
"0.55470496",
"0.5472775",
"0.54465675",
"0.54364693",
"0.542031",
"0.5420063",
"0.54197943",
"0.54016364",
"0.539136",
"0.5370546",
"0.53555685",
"0.53384495",
"0.53291786",
"0.53173244",
"0.53151524",
"0.5304195",
"0.52922",
"0.52866894",
"0.52679455",
"0.5258087",
"0.52512395",
"0.523193",
"0.5230054",
"0.5217604",
"0.5214203",
"0.5201526",
"0.5169673",
"0.51561135",
"0.5150768",
"0.5145345",
"0.51447916",
"0.5144158",
"0.5133394",
"0.5132774",
"0.51250064",
"0.5124408",
"0.5114194",
"0.51102483",
"0.51034284",
"0.5095981",
"0.50931466",
"0.5082888",
"0.5081957",
"0.5078037",
"0.5072994",
"0.5070831",
"0.50693405",
"0.5062453",
"0.5061711",
"0.5059634",
"0.50560266",
"0.5052866",
"0.50447357",
"0.5042552",
"0.50380224",
"0.50343835",
"0.50305235",
"0.50278133",
"0.50197226",
"0.5013591",
"0.5012042",
"0.500502",
"0.50034857",
"0.5000462",
"0.4997977",
"0.49942917",
"0.4991224",
"0.498983",
"0.49872276",
"0.4983892",
"0.49821058",
"0.4980942",
"0.49720117",
"0.49699384",
"0.49697873",
"0.49682862",
"0.49679238",
"0.4963159",
"0.4962085",
"0.49613047",
"0.49607068",
"0.49595693"
] | 0.0 | -1 |
Moves tiles to the left | def move_left
new_board = Marshal.load(Marshal.dump(@board))
(0..3).each do |i|
(0..3).each do |j|
(j..2).each do |k|
if @board[i][k + 1] == 0
next
elsif @board[i][j] == @board[i][k + 1]
@board[i][j] = @board[i][j] * 2
@board[i][k + 1] = 0
end
break
end
end
@board[i] = shift_left(@board[i])
end
@board == new_board ? false : true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_left\n left_tile = C[@location.first, @location.second - 1]\n move_to(left_tile)\n end",
"def move_left\n left_tile = Couple.new(@location.first, @location.second - 1)\n move_to(left_tile)\n end",
"def move_left\n\t\tmove([-1,0])\n\tend",
"def move_left\n @memory_position -= 1\n @memory_position = 0xfffffe if @memory_position < 0\n end",
"def move_left\n # @dx = -8\n @x -= 8\n end",
"def left!(position_of_empty_tile)\n @state_array[position_of_empty_tile]=@state_array[position_of_empty_tile - 1]\n @state_array[position_of_empty_tile - 1] = @@empty\n @path += \"R\"\n self\n end",
"def move_left(environment)\n @previous_action = 'moved left'\n location[:x] -= 1 if can_move_right?(environment)\n\n environment.state\n end",
"def turn_left\n turn(:left)\n end",
"def left\n direction.move_left!\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def moveLeft\n if @x > 1\n call Screen.setColor(false)\n call Screen.drawRectangle((@x + @size) - 1, @y, @x + @size, @y + @size)\n let @x = @x - 2\n call Screen.setColor(true)\n call Screen.drawRectangle(@x, @y, @x + 1, @y + @size)\n end\n end",
"def move_down_left\n i = 1\n until false\n x, y = @pos\n x += i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def moveLeft(distance)\n @x = @x - distance\n @image.x = @x\n end",
"def moveLeft(distance)\n @x = @x - distance\n @image.x = @x\n end",
"def turnLeft\n case @currentDir\n when :north\n @currentDir = :west\n when :south\n @currentDir = :east\n when :east\n @currentDir = :north\n when :west\n @currentDir = :south\n end\n end",
"def turn_left\n # a kind of matrix multiplication\n new_row_diff = 0 - @col_diff\n new_col_diff = @row_diff + 0\n @row_diff = new_row_diff\n @col_diff = new_col_diff\n end",
"def move_to_left_of(node)\n self.move_to node, :left\n end",
"def castle_left(a, b, x, y)\n\t\t@board[x][y].piece = @board[a][b].piece\n\t\t@board[a][b].piece = nil\n\t\t@board[x + 1][y].piece = @board[x - 1][y].piece\n\t\t@board[x - 1][y].piece = nil\n\tend",
"def move_to_left_of(node)\n self.move_to node, :left\n end",
"def move_up_left\n i = 1\n until false\n x, y = @pos\n x -= i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def move_to_left_of(node)\n self.move_to(node, :left)\n end",
"def move_left(mat, y, x)\n return if (x - 1) < 0\n\n zero_el = mat[y][x]\n other_el = mat[y][x - 1]\n mat[y][x - 1] = zero_el\n mat[y][x] = other_el\n\n { m: mat, zero: update_coordinates(zero_el, other_el), move: :left }\nend",
"def move_left(turn_enabled = true)\n @x -= 1 if passable?(@x, @y, 4)\n turn_left if turn_enabled\n add_move_update('move_left')\n end",
"def move_left(array)\r\n set_current_row_col(array)\r\n new_col = (@current_col == 0) ? array.first.length - 1 : @current_col - 1 # This logic will decide the new co-ordinated of space\r\n current_ele = array[@current_row][new_col]\r\n array[@current_row][new_col] = ' '\r\n replace_existing_element(array,current_ele, @current_row, @current_col)\r\n array\r\n end",
"def move_left\n\t\t# if the horse isn;t yet at the left of of the screne move it left 20\n\t\tif @x > 0\n\t\t\t\t@x = @x -20\n\t\tend\n\tend",
"def move_left \r\n if @x - @vel_x > GAME_PRESET[\"player_move_left\"]\r\n @x -= @vel_x\r\n end\r\n end",
"def piece_left\n return unless @falling_piece\n\n @falling_piece.x -= @block_size\n @falling_piece.grid_position.x -= 1\n\n piece_right if collides?\n end",
"def turn_left(direction, times)\n return direction if times.zero?\n\n after = { 'N' => 'W', 'E' => 'N', 'S' => 'E', 'W' => 'S' }.fetch(direction)\n\n turn_left(after, times - 1)\n end",
"def from_left(cur)\n\t\tmove(cur, 0, -1)\n\tend",
"def left\n cursor.left\n\n refresh\n end",
"def turn_left\n case @direction\n when :up\n @direction = :left\n when :right\n @direction = :up\n when :down\n @direction = :right\n when :left\n @direction = :down\n end\n end",
"def move_left\n move_to_left_of left_sibling\n end",
"def turn_left\n @direction = DIRECTIONS[DIRECTIONS.index(@direction) - 1]\n end",
"def move_right\n\t\tmove([1,0])\n\tend",
"def turn_left\n index = DIRECTIONS.index(direction) - 1\n index = DIRECTIONS.length-1 if index < 0\n change_direction(DIRECTIONS[index])\n end",
"def turn_left\n index = DIRECTIONS.index(direction) - 1\n index = DIRECTIONS.length-1 if index < 0\n change_direction(DIRECTIONS[index])\n end",
"def shift_left\n self.push(self.shift)\n end",
"def turn_left\n @orientation = CompassPoints::LEFT_TURNS[@orientation] if placed?\n end",
"def move_left\n\t\t@x_speed -= @speed_inc_step\n\t\tif @x_speed < -@max_speed\n\t\t\t@x_speed = -@max_speed\n\t\tend\n\n\t\tupdate_x(@x_speed)\n\n\t\tif !face_left?\n\t\t\tupdate_angle(calculate_angle(180))\n\t\tend\n\n\t\t@has_moved = @player_moved = true\n\tend",
"def move_west\n @x -= 1\n end",
"def go_left(the_maze, floor, position, steps)\r\n if can_go_left?(the_maze, floor, position)\r\n the_maze = the_maze.set(floor, the_maze[floor].set(position, \"m\"))\r\n walk_maze(the_maze, floor, position - 1, steps.push([floor, position]))\r\n else\r\n return Hamster.vector\r\n end\r\nend",
"def move_object_left(object)\n object.location_move_left unless is_wall?(object.location_left)\n end",
"def turn_left\n if @@compass.index(@direction) == 0\n @direction = @@compass[-1]\n else\n current_index = @@compass.index(@direction)\n @direction = @@compass[current_index - 1]\n end\n end",
"def move_left\n self.move_to_left_of(self.left_sibling)\n end",
"def turn_left\n @shape.body.t -= 300.0\n end",
"def left\n check_placed\n @facing = next_facing(-1)\n end",
"def moveLeft(dist)\n @body.p.x -= dist\n end",
"def rotate_left\n placed?\n @direction = case @direction\n when \"NORTH\" then \"WEST\"\n when \"EAST\" then \"NORTH\"\n when \"SOUTH\" then \"EAST\"\n when \"WEST\" then \"SOUTH\"\n end\n end",
"def move_one begTile\n @maze.get_adjacent_tiles(begTile).each do |tile|\n if (tile.is_floor) && (!@tiles.include? tile)\n @tiles.push tile\n self.move_one tile\n end\n end\n end",
"def walk\n if @headed_left\n move_left\n else\n move_right\n end\n end",
"def go_left(length)\r\n go_to(@location.x - length, @location.y)\r\n end",
"def move_player_left(grid, player)\n return if player.grid_x.zero?\n return if player.left_wall\n\n return grid[player.grid_y][player.grid_x - 1]\nend",
"def move_left\n for i in 0...@array.size\n if i % XSIZE == 0\n v = @array.delete_at(i)\n yield v if block_given?\n @array.insert(i + XSIZE - 1, v)\n end\n end\n end",
"def left(robot, robot_positions)\n move_horizontally(robot, robot_positions, :left)\n end",
"def stair_move_left\n # unless @through\n if front_system_tag == StairsL\n return true unless $game_map.system_tag(@x - 1, @y - 1) == StairsL\n move_upper_left\n return true\n elsif system_tag == StairsR\n move_lower_left\n return true\n end\n # end\n return false\n end",
"def move_left\n tenacious_transaction do\n move_to_left_of left_sibling.try(:lock!)\n end\n end",
"def turn_left\n case @direction\n when \"n\"\n then \"w\"\n when \"w\"\n then \"s\"\n when \"s\"\n then \"e\"\n when \"e\"\n then \"n\"\n end\n end",
"def swap_left\n # Creates new state matrix\n new_state = current_state_dup\n\n # Swap values\n new_state[blank_y][blank_x] = new_state[blank_y][blank_x + 1]\n new_state[blank_y][blank_x + 1] = 0\n\n # Returns new matrix\n new_state\n end",
"def move_left(turn_enabled = true)\n\n @move_angle = 0\n\n # Turn left\n if turn_enabled\n # If facing right, turn down for just second\n turn_left\n end\n # If passable\n if passable?(@x, @y, 4)\n # Turn left\n turn_left\n\n # Remove from cache\n $scene.map.cache_clear(@x,@y,self)\n\n # Update coordinates\n @x -= 1\n\n $scene.map.cache_push(@x,@y,self)\n\n # Increase steps\n increase_steps\n\n if self == $player && $party.leader != 'ship'\n tt = terrain_tag\n $audio.queue(\"steps/foot#{rand(8)}\",12,0.4) if tt != 3\n $audio.queue('steps/foot5',12,0.6) if tt == 2\n end\n else\n # Determine if touch event is triggered\n check_event_trigger_touch(@x-1, @y)\n end\n end",
"def move_lower_left\n unless @direction_fix\n @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)\n end\n if (passable?(@x, @y, 2) && passable?(@x, @y + 1, 4)) ||\n (passable?(@x, @y, 4) && passable?(@x - 1, @y, 2)) # 8 a la place de 2 sur les deux lignes\n move_follower_to_character\n @x -= 1\n @y += 1\n if @follower && $game_variables[Yuki::Var::FM_Sel_Foll] == 0\n @memorized_move = :move_lower_left\n @follower.direction = @direction\n end\n movement_process_end(true)\n increase_steps\n end\n end",
"def move_toward_beeper()\n if front_is_clear?()\n move()\n else\n turn_left()\n end\n end",
"def move_right\n right_tile = Couple.new(@location.first, @location.second + 1)\n move_to(right_tile)\n end",
"def left(robot)\n extend Placed\n\n return robot unless placed? robot\n robot.f = Navigation::ALL[\n Navigation::ALL.index(robot.f) - 1\n ]\n robot\n end",
"def turn_left\n\t\tif @direction == \"N\"\n\t\t\t@direction = \"W\"\n\t\telsif @direction == \"W\"\n\t\t\t@direction = \"S\"\n\t\telsif @direction == \"S\"\n\t\t\t@direction = \"E\"\n\t\telsif @direction == \"E\"\n\t\t\t@direction = \"N\"\n\t\tend\n\tend",
"def turn_left\n index = DIRECTIONS.index(@facing)-1\n @facing = DIRECTIONS[index]\n end",
"def turn_left\n @orientation == -4 ? @orientation = -1 : @orientation -= 1\n end",
"def shift_left\n @left, @value1, @mid = @mid, @value2, @right\n end",
"def left(j)\n\t\tnew_loc = @location.dup\n\t\tnew_loc[:x] -= j\n\t\tGridPoint3D.new(x: new_loc[:x], y: new_loc[:y], z: new_loc[:z])\n\tend",
"def scroll_left(distance)\n if loop_horizontal?\n @display_x += @map.width * 256 - distance\n @display_x %= @map.width * 256\n @parallax_x -= distance\n else\n last_x = @display_x\n @display_x = [@display_x - distance, 0].max\n @parallax_x += @display_x - last_x\n end\n end",
"def turnLeft\n if @placed\n @face = @face.turnLeft\n end\n end",
"def left\n position.x\n end",
"def move_right\n right_tile = C[@location.first, @location.second + 1]\n move_to(right_tile)\n end",
"def walk_left_for(ms)\n behavior = MovementBehavior.create { move_left }\n behavior.at_end { stop_totally }\n behavior.completed_after(ms)\n record_behavior(behavior)\n end",
"def move_right\n @board.each(&:reverse!)\n action = move_left\n @board.each(&:reverse!)\n action\n end",
"def set_left_start_point\n @leading_x = 0\n @leading_y = find_left_entry\n end",
"def cursor_left(wrap)\n if @index % 10 > 0\n @index -= 1\n elsif wrap\n @index += 9\n end\n end",
"def cursor_move_left\n @cursor_position -= 1 if self.cursor_can_move_left?\n self.reset_cursor_blinking\n end",
"def left(degrees)\n turn(degrees)\n end",
"def rotate_left\n dup.rotate_left!\n end",
"def move(left, top)\n # no-op\n end",
"def paddle_left_up\n @paddles[0].move_up\n end",
"def look_left_for(ms)\n behavior = MovementBehavior.create { @facing = :left }\n behavior.completed_after(ms)\n record_behavior(behavior)\n end",
"def move_lower\n movement { self.position += 1 }\n end",
"def collision_left\n return unless state.dx < 0 # return unless player is moving left\n player_rect = [next_x, state.y, state.tile_size, state.tile_size]\n\n # Runs through all the sprites on the field and finds all intersections between the player's left side\n # and the right side of a rect.\n left_side_collisions = state.world_collision_rects\n .find_all { |r| r[:left_right].intersect_rect?(player_rect, state.collision_tolerance) }\n .first\n\n return unless left_side_collisions # return unless collision occurred\n state.x = left_side_collisions[:left_right].right # sets player's x to the x of the colliding rect's right side\n state.dx = 0 # no change in x because the player's path is blocked\n end",
"def move_if_needed\n positions.each {|dir, pos|\n t = tile_at(pos)\n if t\n @direction, @position = directions.invert[dir], pos\n # Update the image so that the user actually sees the bug\n # turning if it did.\n update_image\n t.on\n return true\n end\n }\n return false\n end",
"def right!(position_of_empty_tile)\n @state_array[position_of_empty_tile] = @state_array[position_of_empty_tile + 1]\n @state_array[position_of_empty_tile + 1] = @@empty\n @path += \"L\"\n self\n end",
"def left\n check_placement\n\n super\n end",
"def go_to_next_row()\n turn_left()\n move()\n turn_left()\n end",
"def paddle_left_down\n @paddles[0].move_down\n end",
"def leftClickedDraged\n\t\treturn unless clickdefined?\n\t\treturn leftClicked unless draged?\n\t\tsameStateCoords = []\n\t\tsameState = cellsFromFirstToEnd.select { |cell|\n\t\t\tcell.sameState?(@first)\n\t\t}\n\t\tcase sameState.length\n\t\t\twhen 1\n\t\t\t\t@first.leftClicked\n\t\t\t\tcell=@first\n\t\t\t\t@game.addmove([[cell.coords],\"unLeftClicked\"])\n\t\t\telse\n\t\t\t\tsameState.each { |cell|\n\t\t\t\t\tcell.dragLeftClicked\n\t\t\t\t\tsameStateCoords << cell.coords\n\t\t\t\t}\n\t\t\t\t@game.addmove([sameStateCoords,\"dragLeftClicked\"])\n\t\tend\n\tend",
"def lower_position!(amount = 2)\n if position > 0\n update!(position: position - amount)\n end\n dashboard.reposition_cells\n position\n end",
"def interpret_left(command)\n ensure_placed\n @robot.rotate_left\n end",
"def move_right\n @memory_position += 1\n @memory_position = 0 if @memory_position > 0xfffffe\n end",
"def rebalance_for_left_insert\n\t\t\t# move 1 black from the left to the right by single/double rotation\n\t\t\tif @left.right.red?\n\t\t\t\twith_left(@left.rotate_left)\n\t\t\telse\n\t\t\t\tself\n\t\t\tend.rotate_right\n\t\tend",
"def left\n self.y = ((y-1)+10)%10\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def left\n self.position[:x]\n end",
"def left!\n # TODO: Refactor. Can be less explicit\n case @facing\n when Direction::NORTH\n @facing = Direction::WEST\n when Direction::EAST\n @facing = Direction::NORTH\n when Direction::SOUTH\n @facing = Direction::EAST\n when Direction::WEST\n @facing = Direction::SOUTH\n else\n raise %q{Cannot rotate left}\n end\n end"
] | [
"0.8088165",
"0.80409986",
"0.7658829",
"0.72163093",
"0.71768",
"0.70870376",
"0.7029332",
"0.7027329",
"0.7026737",
"0.69884384",
"0.69884384",
"0.69884384",
"0.6923451",
"0.691203",
"0.6904729",
"0.6904729",
"0.6894849",
"0.688175",
"0.6867787",
"0.68534744",
"0.68352103",
"0.68025887",
"0.6787335",
"0.678458",
"0.6754618",
"0.6750019",
"0.67348206",
"0.6732392",
"0.6684649",
"0.66159916",
"0.65540725",
"0.65367484",
"0.65317166",
"0.65263444",
"0.6517296",
"0.6510283",
"0.65070665",
"0.65070665",
"0.6501641",
"0.6455605",
"0.6444583",
"0.64423734",
"0.64402604",
"0.6439971",
"0.64204216",
"0.64031047",
"0.6400741",
"0.6391327",
"0.6369731",
"0.63695246",
"0.63651067",
"0.6364689",
"0.63632125",
"0.63466763",
"0.63431805",
"0.633027",
"0.63198835",
"0.6319424",
"0.6316832",
"0.6295309",
"0.6280549",
"0.6277545",
"0.62741023",
"0.62659484",
"0.6263006",
"0.6244319",
"0.6231294",
"0.6226303",
"0.6212328",
"0.6203034",
"0.6190421",
"0.61783665",
"0.6152573",
"0.61312145",
"0.6117025",
"0.611186",
"0.6102529",
"0.61002153",
"0.60892713",
"0.60799986",
"0.60649395",
"0.602872",
"0.602623",
"0.6019935",
"0.60181975",
"0.6012112",
"0.6008954",
"0.60026217",
"0.60007674",
"0.59985644",
"0.597881",
"0.5966713",
"0.5946637",
"0.5944867",
"0.5943892",
"0.5935821",
"0.5929717",
"0.59295666",
"0.5927806",
"0.5926008"
] | 0.7405657 | 3 |
Move tiles to the right | def move_right
@board.each(&:reverse!)
action = move_left
@board.each(&:reverse!)
action
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_right\n right_tile = Couple.new(@location.first, @location.second + 1)\n move_to(right_tile)\n end",
"def move_right\n right_tile = C[@location.first, @location.second + 1]\n move_to(right_tile)\n end",
"def move_right\n\t\tmove([1,0])\n\tend",
"def moveRight\n if (@x + @size) < 510\n call Screen.setColor(false)\n call Screen.drawRectangle(@x, @y, @x + 1, @y + @size)\n let @x = @x + 2\n call Screen.setColor(true)\n call Screen.drawRectangle((@x + @size) - 1, @y, @x + @size, @y + @size)\n end\n end",
"def moveRight(distance)\n @x = @x + distance\n @image.x = @x\n end",
"def move_right\n @memory_position += 1\n @memory_position = 0 if @memory_position > 0xfffffe\n end",
"def turn_right\n new_row_diff = @col_diff + 0\n new_col_diff = 0 - @row_diff\n @row_diff = new_row_diff\n @col_diff = new_col_diff\n end",
"def move_down_right\n i = 1\n until false\n x, y = @pos\n x += i\n y += i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def right!(position_of_empty_tile)\n @state_array[position_of_empty_tile] = @state_array[position_of_empty_tile + 1]\n @state_array[position_of_empty_tile + 1] = @@empty\n @path += \"L\"\n self\n end",
"def move_west\n @x -= 1\n end",
"def move_right(window)\n\t\t# if the horse isn't yet at the right edge move it right 20\n\t\tif @x < window.width - @image.width\n\t\t\t@x = @x +20\n\t\tend\n\tend",
"def move_right(mat, y, x)\n return if (x + 1) > (mat.size - 1)\n\n zero_el = mat[y][x]\n other_el = mat[y][x + 1]\n mat[y][x + 1] = zero_el\n mat[y][x] = other_el\n\n { m: mat, zero: update_coordinates(zero_el, other_el), move: :right }\nend",
"def right\n direction.move_right!\n end",
"def move_right\r\n if @x + @vel_x < SCREEN_WIDTH - GAME_PRESET[\"player_move_right\"]\r\n @x += @vel_x\r\n end\r\n end",
"def move_up_right\n i = 1\n until false\n x, y = @pos\n x -= i\n y += i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def move_right(turn_enabled = true)\n @x += 1 if passable?(@x, @y, 6)\n turn_right if turn_enabled\n add_move_update('move_right')\n end",
"def move_right(array)\r\n set_current_row_col(array)\r\n new_col = (@current_col == array.first.length - 1) ? 0 : @current_col + 1 # This logic will decide the new co-ordinated of space\r\n current_ele = array[@current_row][new_col]\r\n array[@current_row][new_col] = ' '\r\n replace_existing_element(array,current_ele, @current_row, @current_col)\r\n array\r\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def move_right(environment)\n @previous_action = 'moved right'\n location[:x] += 1 if can_move_left?(environment)\n environment.state\n end",
"def castle_right(a, b, x, y)\n\t\t@board[x][y].piece = @board[a][b].piece\n\t\t@board[a][b].piece = nil\n\t\t@board[x - 1][y].piece = @board[x + 2][y].piece\n\t\t@board[x + 2][y].piece = nil\n\tend",
"def turn_right\n @shape.body.t += 300.0\n end",
"def move_left\n left_tile = Couple.new(@location.first, @location.second - 1)\n move_to(left_tile)\n end",
"def piece_right\n return unless @falling_piece\n\n @falling_piece.x += @block_size\n @falling_piece.grid_position.x += 1\n\n piece_left if collides?\n end",
"def move_to_right_of(node)\n move_to node, :right\n end",
"def move_to_right_of(node)\n move_to node, :right\n end",
"def move_to_right_of(node)\n move_to node, :right\n end",
"def turnRight\n case @currentDir\n when :north\n @currentDir = :east\n when :south\n @currentDir = :west\n when :east\n @currentDir = :south\n when :west\n @currentDir = :north\n end\n end",
"def shift_right\n self.unshift(self.pop)\n end",
"def move_to_right_of(node)\n self.move_to node, :right\n end",
"def move_rover()\n puts \"DEBUG: moving: #{@orientation}\" if DEBUG\n case @orientation\n when DIRECTION_EAST\n @position[:x] += 1 if @position[:x] < @map.width\n when DIRECTION_WEST\n @position[:x] -= 1 if @position[:x] > 0\n when DIRECTION_NORTH\n @position[:y] += 1 if @position[:y] < @map.height\n when DIRECTION_SOUTH\n @position[:y] -= 1 if @position[:y] > 0\n end\n puts \"DEBUG: position after move: #{@position}\" if DEBUG\n end",
"def move_to_right_of(node)\n self.move_to node, :right\n end",
"def process_right\n set_left_start_point\n while leading_x < maze.length-1 do\n move_to_first_open_position\n puts \"\\e[H\\e[2J\"\n print_board\n sleep 0.1\n end\n @maze[leading_x][leading_y] = mouse_face\n puts \"\\e[H\\e[2J\"\n print_board\n sleep 0.1\n end",
"def move_east\n @x += 1\n end",
"def move_left\n left_tile = C[@location.first, @location.second - 1]\n move_to(left_tile)\n end",
"def move_left\n\t\tmove([-1,0])\n\tend",
"def move_to_right_of(node)\n self.move_to(node, :right)\n end",
"def move_right\n\t\t@x_speed += @speed_inc_step\n\t\tif @x_speed > @max_speed\n\t\t\t@x_speed = @max_speed\n\t\tend\n\n\t\tupdate_x(@x_speed)\n\n\t\tif face_left?\n\t\t\tupdate_angle(calculate_angle(180))\n\t\tend\n\n\t\t@has_moved = @player_moved = true\n\tend",
"def move_right\n for i in 0...@array.size\n if (i + 1) % XSIZE == 0\n v = @array.delete_at(i)\n yield v if block_given?\n @array.insert(i - XSIZE + 1, v)\n end\n end\n end",
"def left!(position_of_empty_tile)\n @state_array[position_of_empty_tile]=@state_array[position_of_empty_tile - 1]\n @state_array[position_of_empty_tile - 1] = @@empty\n @path += \"R\"\n self\n end",
"def rotate_right!\n new_pixels = []\n 0.upto(width - 1) { |i| new_pixels += column(i).reverse }\n replace_canvas!(height, width, new_pixels)\n end",
"def scroll_right(distance)\n if loop_horizontal?\n @display_x += distance\n @display_x %= @map.width * 256\n @parallax_x += distance\n else\n last_x = @display_x\n @display_x = [@display_x + distance, (width - 17) * 256].min\n @parallax_x += @display_x - last_x\n end\n end",
"def move_left\n # @dx = -8\n @x -= 8\n end",
"def move_if_needed\n positions.each {|dir, pos|\n t = tile_at(pos)\n if t\n @direction, @position = directions.invert[dir], pos\n # Update the image so that the user actually sees the bug\n # turning if it did.\n update_image\n t.on\n return true\n end\n }\n return false\n end",
"def move()\n case @mov_dir\n when :right\n if @coord_x == @max_x\n @max_x += 1 # Moving out of bounds. No need to do anything because Ruby rocks! :P\n end\n @coord_x += 1\n \n when :up\n if @coord_y == 0\n @map.unshift [] # Moving out of bounds. Adds a new line to the top\n @max_y += 1\n else\n @coord_y -= 1\n end\n \n when :down\n if @coord_y == @max_y\n @max_y += 1\n @map.push [] # Moving out of bounds. Adds a new line to the bottom\n end\n @coord_y += 1\n \n when :left\n if @coord_x == 0\n @map.each do |a| # Moving out of bounds. Adds a new line to the left\n a.unshift ' ' \n end\n @max_x += 1\n else\n @coord_x -= 1\n end\n end\n end",
"def move_south\n @y -= 1\n end",
"def move_right\n move_to_right_of right_sibling\n end",
"def move_right\n move_to_right_of right_sibling\n end",
"def move_object_right(object)\n object.location_move_right unless is_wall?(object.location_right)\n end",
"def turnRight\n if @placed\n @face = @face.turnRight\n end\n end",
"def move_down\n down_tile = Couple.new(@location.first + 1, @location.second)\n move_to(down_tile)\n end",
"def slide_move!(end_pos)\n board[end_pos] = self\n board.set_to_empty(self.pos)\n self.pos = end_pos\n end",
"def move_by(right_by = 0, down_by = 0)\n action.move_by(right_by, down_by).perform\n end",
"def turn_right\n # p \"old bearing == #{bearing}\"\n # ndx = BEARINGS.index(bearing)\n # p \"old ndx == #{ndx}\"\n # ndx = (ndx + 1) % 4\n # p \"new ndx == #{ndx}\"\n # new_bearing = BEARINGS[ndx]\n # p \"new bearing == #{new_bearing}\"\n # self.bearing = new_bearing\n self.bearing = BEARINGS[(BEARINGS.index(bearing) + 1) % 4]\n end",
"def shiftrow\n #mover la fila 1\n #puts \"\\n ANTES DE SHIFTROW: #{@m_addround}\"\n @m_addround[1][0],@m_addround[1][1],@m_addround[1][2],@m_addround[1][3]=@m_addround[1][1],@m_addround[1][2],@m_addround[1][3],@m_addround[1][0]\n @m_addround[2][0],@m_addround[2][1],@m_addround[2][2],@m_addround[2][3]=@m_addround[2][2],@m_addround[2][3],@m_addround[2][0],@m_addround[2][1]\n @m_addround[3][0],@m_addround[3][1],@m_addround[3][2],@m_addround[3][3]=@m_addround[3][3],@m_addround[3][0],@m_addround[3][1],@m_addround[3][2]\n #puts \"\\n DESPUES DE SHIFTROW: #{@m_addround}\"\n @m_addround\n end",
"def turn_right\n if @@compass.index(@direction) == @@compass.length - 1\n @direction = @@compass[0]\n else\n current_index = @@compass.index(@direction)\n @direction = @@compass[current_index + 1]\n end\n end",
"def move_one begTile\n @maze.get_adjacent_tiles(begTile).each do |tile|\n if (tile.is_floor) && (!@tiles.include? tile)\n @tiles.push tile\n self.move_one tile\n end\n end\n end",
"def move_right(turn_enabled = true)\n\n @move_angle = 0\n\n # Turn right\n if turn_enabled\n turn_right\n end\n # If passable\n if passable?(@x, @y, 6)\n # Turn right\n turn_right\n\n # Remove from cache\n $scene.map.cache_clear(@x,@y,self)\n\n # Update coordinates\n @x += 1\n\n $scene.map.cache_push(@x,@y,self)\n\n # Increase steps\n increase_steps\n\n if self == $player && $party.leader != 'ship'\n tt = terrain_tag\n $audio.queue(\"steps/foot#{rand(8)}\",12,0.4) if tt != 3\n $audio.queue('steps/foot5',12,0.6) if tt == 2\n end\n\n else\n # Determine if touch event is triggered\n check_event_trigger_touch(@x+1, @y)\n end\n end",
"def move_down\n\t\tmove([0,1])\n\tend",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def turn_right\n @orientation = CompassPoints::RIGHT_TURNS[@orientation] if placed?\n end",
"def move_toward_beeper()\n if front_is_clear?()\n move()\n else\n turn_left()\n end\n end",
"def turn_right\n index = DIRECTIONS.index(direction) + 1\n index = 0 if index >= DIRECTIONS.length\n change_direction(DIRECTIONS[index])\n end",
"def turn_right\n index = DIRECTIONS.index(direction) + 1\n index = 0 if index >= DIRECTIONS.length\n change_direction(DIRECTIONS[index])\n end",
"def go_right(the_maze, floor, position, steps)\r\n if can_go_right?(the_maze, floor, position)\r\n the_maze = the_maze.set(floor, the_maze[floor].set(position, \"m\"))\r\n walk_maze(the_maze, floor, position + 1, steps.push([floor, position]))\r\n else\r\n return Hamster.vector\r\n end\r\nend",
"def turnRight\n return EAST\n end",
"def move_piece_back\n @chess_board.board[@row][@col] = @chess_board.board[@row_new][@col_new]\n end",
"def move_down\n down_tile = C[@location.first + 1, @location.second]\n move_to(down_tile)\n end",
"def right\n rotate(1)\n end",
"def move_east\n # Each time we move_east we move the Robot 1 space to the left\n @east += 1\n end",
"def cursor_right(wrap)\n if @index % 10 < 9\n @index += 1\n elsif wrap\n @index -= 9\n end\n end",
"def move_down_left\n i = 1\n until false\n x, y = @pos\n x += i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def pile(w)\n w.drag_to(@current)\n w.set_default_refresh_loc('tl')\n @current.x += PILE_OFFSET\n end",
"def move_right\n self.move_to_right_of(self.right_sibling)\n end",
"def turn_right\n case @direction\n when \"n\"\n then \"e\"\n when \"e\"\n then \"s\"\n when \"s\"\n then \"w\"\n when \"w\"\n then \"n\"\n end\n end",
"def walk\n if @headed_left\n move_left\n else\n move_right\n end\n end",
"def swap_right\n # Creates new state matrix\n new_state = current_state_dup\n\n # Swap values\n new_state[blank_y][blank_x] = new_state[blank_y][blank_x - 1]\n new_state[blank_y][blank_x - 1] = 0\n\n # Returns new matrix\n new_state\n end",
"def stair_move_right\n # unless @through\n if system_tag == StairsL\n move_lower_right\n return true\n elsif front_system_tag == StairsR\n return true unless $game_map.system_tag(@x + 1, @y - 1) == StairsR\n move_upper_right\n return true\n end\n # end\n return false\n end",
"def from_right(cur)\n\t\tmove(cur, 0, 1)\n\tend",
"def turn_left\n @shape.body.t -= 300.0\n end",
"def move_player_right(grid, player)\n return if player.grid_x == grid[player.grid_y].length - 1\n return if player.right_wall\n\n return grid[player.grid_y][player.grid_x + 1]\nend",
"def rotate_right\n dup.rotate_right!\n end",
"def commit_move!(start_pos, end_pos, count = true)\n self.turn_count = 1 + turn_count.to_i if count\n current_piece = self[start_pos]\n self[end_pos].move_to([10,10]) if self[end_pos].is_a?(Piece)\n swap_positions(start_pos, end_pos, current_piece, EmptySquare.new, true)\n promote_last_lines\n end",
"def right(robot, robot_positions)\n move_horizontally(robot, robot_positions, :right)\n end",
"def move_right\n if @contenido.right_sibling\n @contenido.move_right\n flash[:notice] = \"Moví #{@contenido} hacia abajo\"\n else\n flash[:error] = \"LLegué al tope\"\n end\n redirect_to documento_contenidos_path(@contenido.documento)\n end",
"def move_ears(left, right)\n message.posleft = left if left\n message.posright = right if right\n nil\n end",
"def turn_right\n @orientation == 3 ? @orientation = 0 : @orientation += 1\n end",
"def move_by(row_delta, col_delta)\n @row, @col = wrap(@row + row_delta, @col + col_delta)\n end",
"def move_up_left\n i = 1\n until false\n x, y = @pos\n x -= i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def rotate_right\n placed?\n @direction = case @direction\n when \"NORTH\" then \"EAST\"\n when \"EAST\" then \"SOUTH\"\n when \"SOUTH\" then \"WEST\"\n when \"WEST\" then \"NORTH\"\n end\n end",
"def move\n case self.direction\n when 'NORTH'\n self.y += 1 unless self.y == @table.y\n when 'EAST'\n self.x += 1 unless self.x == @table.x\n when 'SOUTH'\n self.y -= 1 unless self.y == 0\n when 'WEST'\n self.x -= 1 unless self.x == 0\n end\n end",
"def move_left\n @memory_position -= 1\n @memory_position = 0xfffffe if @memory_position < 0\n end",
"def paddle_right_down\n @paddles[1].move_down\n end",
"def paddle_right_up\n @paddles[1].move_up\n end",
"def move; end",
"def move; end",
"def redo\n\t\t@moves.redo\n\tend",
"def turn_left\n # a kind of matrix multiplication\n new_row_diff = 0 - @col_diff\n new_col_diff = @row_diff + 0\n @row_diff = new_row_diff\n @col_diff = new_col_diff\n end",
"def turn_right\n\t\tif @direction == \"N\"\n\t\t\t@direction = \"E\"\n\t\telsif @direction == \"E\"\n\t\t\t@direction = \"S\"\n\t\telsif @direction == \"S\"\n\t\t\t@direction = \"W\"\n\t\telsif @direction == \"W\"\n\t\t\t@direction = \"N\"\n\t\tend\n\tend",
"def right\n cursor.right\n\n refresh\n end"
] | [
"0.78697455",
"0.78144246",
"0.7533906",
"0.698691",
"0.6902781",
"0.6862442",
"0.6805925",
"0.67873347",
"0.66700876",
"0.6650515",
"0.6629897",
"0.66275644",
"0.661956",
"0.6593448",
"0.6579017",
"0.65310425",
"0.6487519",
"0.64660144",
"0.64547515",
"0.63985586",
"0.6394601",
"0.63845116",
"0.63828087",
"0.63755655",
"0.63755655",
"0.63755655",
"0.6353371",
"0.6322186",
"0.63184667",
"0.6304764",
"0.62792194",
"0.627775",
"0.623866",
"0.62344134",
"0.6230983",
"0.6227454",
"0.62076116",
"0.6198474",
"0.61795586",
"0.6175203",
"0.616299",
"0.6161157",
"0.6157803",
"0.6130768",
"0.61295503",
"0.61283517",
"0.61283517",
"0.61059433",
"0.6095482",
"0.60781515",
"0.6077835",
"0.6071712",
"0.60533345",
"0.602346",
"0.601742",
"0.6004453",
"0.5994838",
"0.599086",
"0.5985971",
"0.5982101",
"0.59773105",
"0.5974461",
"0.5974461",
"0.5924977",
"0.59247017",
"0.59161854",
"0.58845985",
"0.5878238",
"0.5877872",
"0.5874849",
"0.58742386",
"0.58725184",
"0.58719456",
"0.5854131",
"0.58515304",
"0.5843142",
"0.5842396",
"0.5834753",
"0.582868",
"0.58283794",
"0.58273625",
"0.58175284",
"0.58151984",
"0.5812248",
"0.5809829",
"0.58011436",
"0.579997",
"0.5799625",
"0.57985",
"0.57957184",
"0.57933944",
"0.5783291",
"0.57741374",
"0.5766654",
"0.57585645",
"0.57585645",
"0.5757223",
"0.5749312",
"0.57488227",
"0.5745425"
] | 0.7543078 | 2 |
If a player reaches the final tile, 16384, they win | def win_checker
@board.flatten.max == 16_384
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def over?\n self.player.points == self.board.total_points\n end",
"def check_for_win(player)\n\tif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"tc\"] == player) && ($grid_hash[\"tr\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"cl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"cr\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"bl\"] == player) && ($grid_hash[\"bc\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"cl\"] == player) && ($grid_hash[\"bl\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tc\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"bc\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tr\"] == player) && ($grid_hash[\"cr\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"bl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"tr\"] == player)\n\t\twin(player)\n\telse\n\t\tcheck_for_tie\n\tend\nend",
"def easy_win(player)\n win if player.points == 4 && player.opponent.points < 3\n end",
"def winning_shot\n @computer.board.hits == 5\n end",
"def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end",
"def result\n if (hand.player_points <= LIMIT_POINTS && hand.player_points > hand.points_dealer) ||\n (hand.player_points <= LIMIT_POINTS && hand.points_dealer > LIMIT_POINTS)\n :player_win\n elsif (hand.points_dealer <= LIMIT_POINTS && hand.points_dealer > hand.player_points) ||\n (hand.points_dealer <= LIMIT_POINTS && hand.player_points > LIMIT_POINTS)\n puts 'Dealer win.'\n :dealer_win\n else\n :draw\n end\n end",
"def determining_winner\n if @player_hand_points = 21 && @dealer_hand_points < 21 || 21 > @player_hand_points > @dealer_hand_points || @dealer_hand_points > 21\n @player_win\n elsif @player_hand_points > 21 && @dealer_hand_points > 21 || @player_hand_points = @dealer_hand_points\n @player_tie\n else @dealer_hand_points = 21 && @player_hand_points < 21 || 21 > @dealer_hand_points > @player_hand_points || @player_hand_points > 21\n @player_loss\n end\n end",
"def update_player_map\n @map.tiles[@location.first][location.second].seen = true\n #corners\n @map.tiles[@location.first + 1][@location.second - 1].seen = true\n @map.tiles[@location.first - 1][@location.second - 1].seen = true\n @map.tiles[@location.first + 1][@location.second + 1].seen = true\n @map.tiles[@location.first - 1][@location.second + 1].seen = true\n #cardinal directions\n @map.tiles[@location.first][@location.second + 1].seen = true\n @map.tiles[@location.first][@location.second - 1].seen = true\n @map.tiles[@location.first - 1][@location.second].seen = true\n @map.tiles[@location.first + 1][@location.second].seen = true\n\n #TODO Uncomment\n if !(@map.tiles[@location.first][location.second].monsters.empty?)\n here = @map.tiles[@location.first][location.second]\n #20% chance of monster appearing\n monster_outcome = Random.rand(here.monsters.size * 5)\n if (monster_outcome < here.monsters.size)\n system(\"clear\")\n battle(self, here.monsters[monster_outcome])\n end\n end\n end",
"def checkVictory\n if @player.x > @exitDoor.x - @exitDoor.width / 2 and @player.x < @exitDoor.x + @exitDoor.width / 2 and @player.y >\n @exitDoor.y - @exitDoor.height / 2 and @player.y < @exitDoor.y + @exitDoor.height / 2\n winGame\n end\n end",
"def must_hit\n return true if @hand.point != \"Blackjack\" && @hand.point <= 16\n return false\n end",
"def won_set(player)\n if player.games_won >= 6 and player.opponent.games_won < 5\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n elsif player.games_won == 7\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n end\n end",
"def game_started?\n !@score.nil? # count_tiles(WALL) >= 45 + 23 + 23\n end",
"def winning?(cells, player)\r\n status = false\r\n if (cells[0] == player && cells[1] == player && cells[2] == player) ||\r\n (cells[3] == player && cells[4] == player && cells[5] == player) ||\r\n (cells[6] == player && cells[7] == player && cells[8] == player) ||\r\n (cells[0] == player && cells[3] == player && cells[6] == player) ||\r\n (cells[1] == player && cells[4] == player && cells[7] == player) ||\r\n (cells[2] == player && cells[5] == player && cells[8] == player) ||\r\n (cells[0] == player && cells[4] == player && cells[8] == player) ||\r\n (cells[2] == player && cells[4] == player && cells[6] == player)\r\n status = true\r\n end\r\n status\r\n end",
"def finished?\n if @player_positions [\"b\"] > 80 \n return winner(@player[1])\n elsif @player_positions[\"a\"] > 80\n return winner(@player[0])\n end\n end",
"def move_knight\n #there is no more than eight moves\nend",
"def game_over\n remaining_player.count == 1\n end",
"def win_or_bust(player)\n total = player.calculate_total\n \n if total == 21\n player_wins(player)\n elsif total > 21\n player_busts(player)\n end\nend",
"def won_match(player)\n if player.sets_won > 1 and player.opponent.sets_won < 1\n player.matches_won += 1\n start_new_match\n end\n end",
"def check_win\n win = true\n # For each ship check if none of the hit key values is 0(is not sunk). If false game isn't over.\n ships.each do |s|\n sink = s.position.detect { |p| p[:hit] == 0 }\n if !sink.nil?\n win = false\n break\n end\n end\n if win\n puts 'Whoop Whoop!!'\n end\n win\n\n end",
"def regular_turn?(turn)\n min_turn = @players_count * 2 + 1\n turn >= min_turn\n end",
"def did_player_win\n (@purses[@current_player] != 6)\n end",
"def game_over?\n remaining_players == 1\n end",
"def player_won?\n victory = false\n @board.each do |key, value|\n victory = calculate_possible_lines(key).any? do |line|\n \tline.all? do |location|\n next if @board[location] == nil\n @board[location].color == @current_player\n \tend\n end\n return true if victory == true\n end\n false\n end",
"def won?\n #won?: If the player has over 100 points, returns true, otherwise returns false\n if total_score > 100\n return true\n else\n return false\n end\n end",
"def player_turn\n # if the board has more x's then it is the computer's turn\n if @board.count(@symbol) > @board.count(@computer_symbol)\n computer_turn\n else\n users_turn\n end\n end",
"def verticalWin? (player)\n (0..6).any? {|c| (0..2).any? {|r| fourFromTowards?(player, r, c, 1, 0)}}\n end",
"def player_win?(n)\n self.wins.each do |win| \n return true if (player_moves(\"#{n}\") & win).count == self.win_length\n end\n return false\n end",
"def count_evaluate(player) # true for white player, false for black\n if player\n RState.hamming(@white_positions) - RState.hamming(@black_positions)\n else\n RState.hamming(@black_positions) - RState.hamming(@white_positions)\n end\n end",
"def full?\n turn_count == 9\n end",
"def is_win(x, y, player)\n create_pivot_vectors(x, y)\n\n # TODO: parameter key not used (fix)\n @moves.each do |key, array|\n win3 = 0\n array.each do |key, val|\n if val == player\n win3 += 1\n return true if win3 == @win_with\n else\n win3 = 0\n end\n end\n end\n false\n end",
"def win_or_block(board) \n if reach?(board, self.token)\n reach?(board, self.token).find {|cell| !board.taken?(cell+1)}\n elsif reach?(board, self.opponent_token)\n reach?(board, self.opponent_token).find {|cell| !board.taken?(cell+1)}\n end\n end",
"def sorrounded?\n enemies_around > 2\n end",
"def is_over?\n ((winning_move?) || (spots_filled == 9)) ? (return true) : (return false)\n end",
"def win\r\n\t\tfor i in 1..@mines do\r\n\t\t\tx=@mine[i].x\r\n\t\t\ty=@mine[i].y\r\n\t\t\t\r\n\t\t\tremove_pic(@field[x][y])\r\n\t\t\tadd_pic(@field[x][y],F_flag)\r\n\t\tend\r\n\t\t\r\n\t\t@start_button.remove(@actual_face)\r\n\t\t@actual_face=@image[Win]\r\n\t\t@start_button.add(@actual_face)\r\n\t\t\r\n\t\t@game_status=FINISHED\r\n\t\t\r\n\t\t@fenster.show_all\n\t\tif @closed_fields==@mines and !@endless_time #won\r\n\t\t\tprozent=(@progress_bar.fraction * 100) / @time_multiplicator\r\n\t\t\t\r\n\t\t\tnew_highscore(@max_time - (@actual_time - @start_time),prozent)\r\n\t\tend\r\n\tend",
"def won_game?\n @points > @opponent.points + 1 && @points >= 3\n end",
"def won?\n longest_row(@player) >= 5\n end",
"def collision_players(player)\n @age>(60*5) && local && Gosu::distance(@x, @y, player.x, player.y) < (7+player.r) \n end",
"def min_player\n return 0\n end",
"def won_game?\n if @points > @opponent.points + 1 && @points > 3\n @points = 0\n opponent.points = 0\n return true\n end\n end",
"def canfight?()\n\n d = 2 if @x == $player.x and @y == $player.y - 1\n d = 8 if @x == $player.x and @y == $player.y + 1\n d = 4 if @y == $player.y and @x == $player.x + 1\n d = 6 if @y == $player.y and @x == $player.x - 1\n \n return passable?(x,y,d)\n\n end",
"def game_over(player)\n #combinaisons gagnantes\n vic_combi = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6]]\n #verifie si les cases occupées le sont par le meme joueur\n vic_combi.each do |victorious_case|\n if @board.board[victorious_case[0]].case_value + @board.board[victorious_case[1]].case_value+ @board.board[victorious_case[2]].case_value == player.symbol * 3\n return player\n end\n end\n return false\n end",
"def win_pts\n self.score += 1\n end",
"def game_over \n # all the grid's cells are full and different numbers \n end",
"def collidesWithPlayer\n for x in @x.round..(@x + @width).round\n for y in (@y - @height).round..@y.round\n if @map.player.containsPoint?(x, y)\n @map.player.loseHealth\n end\n end\n end\n end",
"def calc_edge_collision\n # Ensures that player doesn't fall below the map\n if next_y < 0 && state.dy < 0 # if player is moving down and is about to fall (next_y) below the map's scope\n state.y = 0 # 0 is the lowest the player can be while staying on the screen\n state.dy = 0\n # Ensures player doesn't go insanely high\n elsif next_y > 720 - state.tile_size && state.dy > 0 # if player is moving up, about to exceed map's scope\n state.y = 720 - state.tile_size # if we don't subtract tile_size, we won't be able to see the player on the screen\n state.dy = 0\n end\n\n # Ensures that player remains in the horizontal range its supposed to\n if state.x >= 1280 - state.tile_size && state.dx > 0 # if the player is moving too far right\n state.x = 1280 - state.tile_size # farthest right the player can be while remaining in the screen's scope\n state.dx = 0\n elsif state.x <= 0 && state.dx < 0 # if the player is moving too far left\n state.x = 0 # farthest left the player can be while remaining in the screen's scope\n state.dx = 0\n end\n end",
"def win(board, marker)\r\n\t\t#horizontal top\r\n\t\tif board[0] && board[1] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telsif board[0] && board[2] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\telsif board[1] && board[2] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#horiz middle\r\n\t\telsif board[3] && board[4] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[3] && board[5] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[5] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#horiz bottom\r\n\t\telsif board[6] && board[7] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[6] && board[8] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[7] && board[8] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\t#vertical left\r\n\t\telsif board[0] && board[3] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[3] && board[6] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\telsif board[0] && board[6] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#vert middle\r\n\t\telsif board[1] && board[4] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[1] && board[7] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[7] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\t#vert right\r\n\t\telsif board[2] && board[5] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[2] && board[8] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[5] && board[8] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\t#diagonal top left \r\n\t\telsif board[0] && board[4] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[0] && board[8] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[8] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#diag bottom left\r\n\t\telsif board[2] && board[4] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[2] && board[6] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[6] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telse\r\n\r\n\t\tend\r\n\tend",
"def win(board, marker)\n\t\t#horizontal top\n\t\tif board[0] && board[1] == marker\n\t\t\tboard[2] == perfect_move\n\t\telsif board[0] && board[2] == marker\n\t\t\tboard[1] == perfect_move\n\t\telsif board[1] && board[2] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#horiz middle\n\t\telsif board[3] && board[4] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[3] && board[5] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[5] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#horiz bottom\n\t\telsif board[6] && board[7] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[6] && board[8] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[7] && board[8] == marker\n\t\t\tboard[6] == perfect_move\n\t\t#vertical left\n\t\telsif board[0] && board[3] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[3] && board[6] == marker\n\t\t\tboard[0] == perfect_move\n\t\telsif board[0] && board[6] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#vert middle\n\t\telsif board[1] && board[4] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[1] && board[7] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[7] == marker\n\t\t\tboard[1] == perfect_move\n\t\t#vert right\n\t\telsif board[2] && board[5] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[2] && board[8] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[5] && board[8] == marker\n\t\t\tboard[2] == perfect_move\n\t\t#diaginal top left \n\t\telsif board[0] && board[4] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[0] && board[8] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[8] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#diag bottom left\n\t\telsif board[2] && board[4] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[2] && board[6] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[6] == marker\n\t\t\tboard[2] == perfect_move\n\t\telse\n\n\t\tend\n\tend",
"def check_win(player)\n\t\tif (@table.table[0][0] == player.value && @table.table[0][1] == player.value && @table.table[0][2] == player.value) ||\n\t\t (@table.table[1][0] == player.value && @table.table[1][1] == player.value && @table.table[1][2] == player.value) ||\n\t\t (@table.table[2][0] == player.value && @table.table[2][1] == player.value && @table.table[2][2] == player.value) ||\n\t\t (@table.table[0][0] == player.value && @table.table[1][0] == player.value && @table.table[2][0] == player.value) ||\n\t\t (@table.table[0][0] == player.value && @table.table[1][0] == player.value && @table.table[2][0] == player.value) ||\n\t\t (@table.table[0][1] == player.value && @table.table[1][1] == player.value && @table.table[2][1] == player.value) ||\n\t\t (@table.table[0][2] == player.value && @table.table[1][2] == player.value && @table.table[2][2] == player.value) ||\n\t\t (@table.table[0][0] == player.value && @table.table[1][1] == player.value && @table.table[2][2] == player.value) ||\n\t\t (@table.table[2][0] == player.value && @table.table[1][1] == player.value && @table.table[0][2] == player.value) \n\t\t\t@win_val = player.value\n\t\t\tgame_end\n\t\tend\n\tend",
"def check_out_of_world # swap size\n # y\n if @y < 0\n die\n elsif @y > WINDOW_SIZE_Y\n die\n end\n # x ( comment me out to add the glitch feature agian )\n if @x < 0\n @x = WINDOW_SIZE_X - TILE_SIZE - 2\n elsif @x > WINDOW_SIZE_X - TILE_SIZE - 1\n @x = 0\n end\n end",
"def big_shoe_rebounds\n big_shoes_player = 0\n rebounds = 0\n game_hash.each do |team_key, team_value|\n team_value[:players].each do |stats|\n if stats[:shoe] > big_shoes_player #if the shoe stats for the current player being compared is bigger than the current \"big_shoes_player\" then continue to next lines of code that cause \"big_shoes_player\" to turn into the current player and reflect his rebounds.\n big_shoes_player = stats[:shoe]\n rebounds = stats[:rebounds]\n end\n end\n end\n rebounds\nend",
"def game_over?\n game_over = false\n safe_hotel_count = 0\n self.game_hotels.each do |hotel|\n if hotel.chain_size >= 41\n game_over = true\n elsif hotel.chain_size >= 11\n safe_hotel_count = safe_hotel_count + 1\n end\n end\n if safe_hotel_count == 7 || game_over == true\n winner = end_game_scoring\n return winner\n else\n return false\n end\n end",
"def collidesWithPlayer\n for x in @x.round..(@x + @width).round\n for y in (@y - @height).round..@y.round\n if @map.player.containsPoint?(x, y)\n @map.player.loseHealth\n death\n return\n end\n end\n end\n end",
"def surrounding_mines?\n mine_count > 0\n end",
"def won?\n win = false\n win = true if total_score >= 100\n return win\n end",
"def set_won?\n if @games_won == 6 && @opponent.games_won < 5\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n if @games_won == 7 && @opponent.games_won < 7\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n end",
"def win_condition_met?(player)\n # Horizontal\n for row in (0..5) do\n counter = 0\n \n @board[row].each do |disc|\n if(disc == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Vertical\n for col in (0..6) do\n counter = 0\n \n for row in (0..5) do\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Right diagonal\n starting_points = [[0, 0], [1, 0], [2, 0], [0, 1], [0, 2], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col < 7)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col += 1\n end\n end\n \n # Left diagonal\n starting_points = [[0, 6], [1, 6], [2, 6], [0, 5], [0, 4], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col >= 0)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col -= 1\n end\n end\n \n return false\n end",
"def solid?(game_map, x, y)\r\n # puts \"X: \" + x.to_s + \" Y: \" + y.to_s # for debuging\r\n if(x < 0 || x > 240) # dosen't allow player to go out of side walls\r\n return true\r\n end\r\n\r\n if(y<0 ||game_map.tiles[y / 20][x / 20]==0)\r\n return false\r\n else \r\n return true\r\n end\r\n\r\nend",
"def player_win\n @player_win += 1\n end",
"def check_win\n if @game_board.return_count == 5 and @timer.return_time >= 0\n @win = true\n end\n if @game_board.return_count < 5 and @timer.return_time == 0\n @lose = true\n end\n end",
"def check_encompassed_area\n @set_upper_area_sprite = false\n top_left, bot_right = get_edge_corner_dis\n last_x, last_y, copy_region = nil, nil, 0\n map_xd, map_yd = $game_map.display_x * 32, $game_map.display_y * 32\n ##total_height = (self.height + @character.jump_height).round\n total_height = (self.oy).round\n self.width.times do |x|\n xp = map_xd.to_i + top_left[0] + x\n unless xp / 32 == last_x\n last_x = xp / 32\n last_y, copy_region = nil, 0\n total_height.times do |y|\n yp = map_yd.to_i + bot_right[1] + @character.jump_height - y\n next if yp.to_i / 32 == last_y\n last_y = yp.to_i / 32\n if last_y == (@character.screen_y + map_yd).to_i / 32\n#~ if last_y == (@character.screen_y + @character.jump_height +\n#~ map_yd).to_i / 32\n break if $game_map.terrain_tag(last_x, last_y) == UpperTerrain\n next\n end\n next if $game_map.terrain_tag(last_x, last_y) != UpperTerrain\n copy_region = [self.height, total_height - y + 1].min\n set_upper_sprite\n break\n end\n end\n next if copy_region == 0\n rect = Rect.new(src_rect.x + x, src_rect.y, 1, copy_region)\n @upper_area_sprite.bitmap.blt(x, 0, self.bitmap, rect)\n self.bitmap.clear_rect(rect)\n end\n if !@set_upper_area_sprite && @upper_area_sprite\n @upper_area_sprite.visible = false\n end\n end",
"def game_over?\n shots_remaining <= 0 || board.boats.all?(&:sunk?)\n end",
"def check_for_winner\n\t\tdid_player_win = false\n\t\tx = 1\n\t\twhile x < 8\n\t\t\ty = 1\n\t\t\twhile y < 7\n\t\t\t\tcurrent_key = \"#{x}-#{y}\"\n\t\t\t\tcurrent_hole = game_board[current_key]\n\t\t\t\t@x_to_check = x\n\t\t\t\t@y_to_check = y\n\t\t\t\tif current_hole.owned_by_player == @current_player\n\t\t\t\t\tdid_player_win = check_for_line(x, y)\n\t\t\t\t\tif did_player_win\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\ty += 1\n\t\t\tend\n\t\t\tx += 1\n\t\tend\n\t\treturn false\n\tend",
"def cheats\n win if @gilbert.x > 2995 && @gilbert.y == 846.5\n end",
"def won?\n player_marker = @players[@current_player_idx].marker\n WINNING_LOCATIONS.each do |winning_triple|\n return true if winning_triple.map { |loc| @board[loc].fill_char == player_marker }.all?\n end\n false\n end",
"def won_trick(player)\n update_in(:tricks, player) {|n| n + 1 }\n end",
"def out\n score_point(other_player)\n return false\n end",
"def make_move\n\n\n candidates = []\n surface_level.each do |pos|\n\n row, col = pos\n\n # if placing this tile leads the ai to win then thats good\n score = evaluate_position_as @ai, row, col, @ai.win_conditions[0], 2\n\n # if placing tile, enables the player to place a tile above us and win, then bad\n score += evaluate_position_as @player, row + 1, col, @player.win_conditions[0], -1\n @board.data[row][col] = nil\n\n if row + 1 != @row\n @board.data[row + 1][col] = nil\n end\n\n # if player places this position and enables him to win, dont let him.\n score += evaluate_position_as @player, row, col, @player.win_conditions[0], 0.8\n @board.data[row][col] = nil\n\n\n # if ai places at this tile and causes player to win, dont palce it there\n score += evaluate_position_as @ai, row, col, @player.win_conditions[0], -2\n\n # if player plays it there and causes him to get close to win conditon, dont palce it there\n score += evaluate_position_as @player, row, col, @player.win_conditions[0][1..-1], 0.3\n @board.data[row][col] = nil\n\n\n score += evaluate_position_as @player, row, col, @player.win_conditions[0][0..-2], 0.3\n @board.data[row][col] = nil\n\n candidates << [row, col, score]\n\n end\n\n # signals that it cannot make a move, the ai\n if candidates == []\n return -1\n end\n\n # sort by best candidate\n sorted = candidates.sort {|a,b| b[2] <=> a[2]}\n\n return select_candidate sorted\n\n end",
"def dealer_turns\n while (dealer.hand_total < 16)\n self.hit(dealer)\n hand_check(dealer)\n end\n winner\n end",
"def hit_wall?(other_player)\n @position.pop\n @position += [other_player.head]\n crash?\n end",
"def round_over? \n\t\tplayers.one?{ |player| !player.folded? }\n\tend",
"def npc_shot\n grid_space = @remaining_npc_shot_spaces.shuffle!.pop\n npc_hits_ship(grid_space)\n board.player_map[grid_space].guess\n end",
"def check_win\n @win_vecs.each {|vec| return vec.winner if vec.winner != 0}\n return 0\n end",
"def victory(player) # Recense toutes les conditions de victoire (8 au total)\n\n if @cells[0].value == @cells[1].value && @cells[1].value == @cells[2].value\n return true\n\n elsif @cells[3].value == @cells[4].value && @cells[4].value == @cells[5].value\n return true\n\n elsif @cells[6].value == @cells[7].value && @cells[7].value == @cells[8].value\n return true\n\n elsif @cells[0].value == @cells[3].value && @cells[3].value == @cells[6].value\n return true\n\n elsif @cells[1].value == @cells[4].value && @cells[4].value == @cells[7].value\n return true\n\n elsif @cells[2].value == @cells[5].value && @cells[5].value == @cells[8].value\n return true\n\n elsif @cells[2].value == @cells[4].value && @cells[4].value == @cells[6].value\n return true\n\n elsif @cells[0].value == @cells[4].value && @cells[4].value == @cells[8].value\n return true\n\n end\n end",
"def evaluate_winner\n\t\treturn 100 if win?(\"x\")\n\t\treturn -100 if win?(\"o\")\n\t\treturn 0 if blocked?\n\tend",
"def game_over?\n return true if victory? || (@turns == 12)\n false\n end",
"def winning?(board, triplet)\n winner = triplet.all? {|spot| board[spot]==\"X\"}\n if winner\n return winner\n end\n winner = triplet.all? {|spot| board[spot]==\"O\"}\n if winner\n return winner\n end\n return false\nend",
"def winning?(board, triplet)\n winner = triplet.all? {|spot| board[spot]==\"X\"}\n if winner\n return winner\n end\n winner = triplet.all? {|spot| board[spot]==\"O\"}\n if winner\n return winner\n end\n return false\nend",
"def check_win\n\tp = tokenize($current_player)\n\tvert1 = $row1[0] + $row2[0] + $row3[0]\n\tvert2 = $row1[2] + $row2[2] + $row3[2]\n\tvert3 = $row1[4] + $row2[4] + $row3[4]\n\n\thorz1 = vert1[0] + vert2[0] + vert3[0]\n\thorz2 = vert1[1] + vert2[1] + vert3[1]\n\thorz3 = vert1[2] + vert2[2] + vert3[2]\n\n\tdiag1 = $row1[0] + $row2[2] + $row3[4]\n\tdiag2 = $row3[0] + $row2[2] + $row1[4]\n\n\twinning_options = [vert1, vert2, vert3, horz1, horz2, horz3, diag1, diag2]\n\tif winning_options.any? {|x| (x.count p) >= 3}\n\t\treturn true\n\tend \nend",
"def player_turn\n hit_loop(@player)\n end",
"def check_win(player,grid,coordinates)\n win = false\n win_array = []\n play_row = coordinates[0]\n play_col = coordinates[1]\n\n # horizontal checking\n grid[play_row].each_index do | col |\n if win_array.length != 4\n if grid[play_row][col] == player\n win_array.push([play_row,col])\n else\n win_array = []\n end\n end\n end\n\n if win_array.length == 4\n win = true\n end\n\n # vertical checking\n if win == false\n\n win_array = []\n\n grid.each_index do | row |\n if win_array.length != 4\n if grid[row][play_col] == player\n win_array.push([row,play_col])\n else\n win_array = []\n end\n end\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # diagonal checking SW to NE\n if win == false\n\n win_array = []\n row = play_row\n col = play_col\n\n # finds SW-most position in same diagonal line as most recently played piece\n # this is the starting point we check from\n until col == 0 || row == 7\n row += 1\n col -= 1\n end\n\n until col > 7 || row < 0\n if win_array.length != 4\n if grid[row][col] == player\n win_array.push([row,col])\n else\n win_array = []\n end\n end\n row -= 1\n col += 1\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # diagonal checking NW to SE\n if win == false\n\n win_array = []\n row = play_row\n col = play_col\n\n # finds NW-most position in same diagonal line as most recently played piece\n # this is the starting point we check from\n until col == 0 || row == 0\n row -= 1\n col -= 1\n end\n\n until col > 7 || row > 7\n if win_array.length != 4\n if grid[row][col] == player\n win_array.push([row,col])\n else\n win_array = []\n end\n end\n row += 1\n col += 1\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # winning four-in-a-row briefly \"flashes\" to show where it is\n if win == true\n flash_count = 0\n while flash_count < 4\n #flashing animation\n win_array.each do | element |\n grid[element[0]][element[1]] = \"@\"\n end\n print_board(grid)\n sleep(0.2)\n win_array.each do | element |\n grid[element[0]][element[1]] = player\n end\n print_board(grid)\n sleep(0.2)\n flash_count += 1\n end\n end\n\n return win\nend",
"def find_winner\n\t\t@counter = 0\n\t\t@players.each do |player|\n\t\t\tif player.points > @winning\n\t\t\t\t@winner = @counter + 1\n\t\t\tend\n\t\t\t@counter += 1\n\t\tend\n\t\treturn @winner\n\tend",
"def player_x_has_won_H?\n if @board[0] == 'X' && @board[1] == 'X' && @board[2] == 'X' || @board[3] == 'X' && @board[4] == 'X' && @board[5] == 'X' || @board[6] == 'X' && @board[7] == 'X' && @board[8] == 'X'\n true\n end\n end",
"def full?\n without_locking { players.size >= technology.max_players }\n end",
"def player_o_has_won_H?\n if @board[0] == 'O' && @board[1] == 'O' && @board[2] == 'O' || @board[3] == 'O' && @board[4] == 'O' && @board[5] == 'O' || @board[6] == 'O' && @board[7] == 'O' && @board[8] == 'O'\n true\n end\n end",
"def win\n winning_move(@computer_mark)\n end",
"def busted?(total)\n total > GAME_HIGH\nend",
"def pbEndSurf(xOffset,yOffset)\n return false if !$PokemonGlobal.surfing\n x=$game_player.x\n y=$game_player.y\n currentTag=$game_map.terrain_tag(x,y)\n facingTag=Kernel.pbFacingTerrainTag\n if pbIsSurfableTag?(currentTag)&&!pbIsSurfableTag?(facingTag)\n if Kernel.pbJumpToward\n Kernel.pbCancelVehicles\n $game_map.autoplayAsCue\n $game_player.increase_steps\n result=$game_player.check_event_trigger_here([1,2])\n Kernel.pbOnStepTaken(result)\n $FollowingFinishedSurfing = true\n end\n return true\n end\n return false\nend",
"def wall?(tile)\n tile.flatten.count {|t| t == WALL} > 4\n end",
"def over?\n if won? || draw? || full?\n true\n end\n end",
"def match_won?\n if @sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n if @opponent.sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n end",
"def dealerMustMeetPointMinimum()\n #================================================\n notDone = true\n continueToPlay = true\n while (notDone == true) do\n if (@dealer.points < 17)\n handleOneCard(@dealer)\n continueToPlay = mayGameContinue(@dealer)\n else\n notDone = false\n end # else, if\n end # while\n return continueToPlay\n\n end",
"def check_for_winner(marker, player)\n Game::WINNING_LINES.each do |the_line|\n if board.squares[the_line[0]] == marker && board.squares[the_line[1]] == marker && board.squares[the_line[2]] == marker\n puts \"#{player} wins\"\n sleep 0.5\n exit\n end\n end\n Game::WINNING_LINES.each do |the_line|\n if @board.available_squares.any? == false\n puts \"It's a tie!\"\n sleep 0.5\n exit\n end \n end\n end",
"def runner\n welcome\n total = initial_round\n while(total <= 21) do\n total = hit?(total)\n end\n end_game(total)\nend",
"def calc_edge_collision\n\n #Ensures that the player doesn't fall below the map.\n if state.y < 0\n state.y = 0\n state.dy = 0\n\n #Ensures that the player doesn't go too high.\n # Position of player is denoted by bottom left hand corner, which is why we have to subtract the\n # size of the player's box (so it remains visible on the screen)\n elsif state.y > 720 - state.tile_size # if the player's y position exceeds the height of screen\n state.y = 720 - state.tile_size # the player will remain as high as possible while staying on screen\n state.dy = 0\n end\n\n # Ensures that the player remains in the horizontal range that it is supposed to.\n if state.x >= 1280 - state.tile_size && state.dx > 0 # if player moves too far right\n state.x = 1280 - state.tile_size # player will remain as right as possible while staying on screen\n state.dx = 0\n elsif state.x <= 0 && state.dx < 0 # if player moves too far left\n state.x = 0 # player will remain as left as possible while remaining on screen\n state.dx = 0\n end\n end",
"def find_winner\n if @player_1.life == 0\n return 2\n end\n return 1\n end",
"def mineTile(col, row)\r\n\r\n @endGame && return #Returns if the games has already been lost.\r\n @tile[col][row].revealed && return #Returns if the tile is already revealed.\r\n\r\n #Checks if the tile is not an ore.\r\n if (@tile[col][row].tier == 0)\r\n adjacent = @tile[col][row].adjacent\r\n\r\n if (adjacent == 0)\r\n floodFill(col,row) #If the tile has an adjacent value of 0, performs a flood fill to uncover the surrounding tiles.\r\n else\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hiddenCount-=1\r\n\r\n #Re-renders the button so it displays the new text.\r\n old = @tile[col][row].btn\r\n newStyle = old.style.dup\r\n old.parent.before(old) do\r\n @tile[col][row].btn = button adjacent.to_s, newStyle###\r\n end\r\n old.remove\r\n end\r\n else #Tile is an ore.\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hiddenCount -= 1\r\n tileTier = @tile[col][row].tier\r\n\r\n #Updates the experience\r\n @experienceInt += 2**(tileTier-1)\r\n @experience.clear { para(\"EXP: \" + @experienceInt.to_s, @style_stats) }\r\n\r\n #Gets the amount of experience needed to reach the next tier.\r\n if (@tierInt < @tiers)\r\n if (@tierInt == @tiers - 1)\r\n required = 1 #If the player is on the penultimate tier then 100% of previous ores need to be uncovered.\r\n else\r\n #Interpolates the upper and lower bound to get the required percentage for the next tier.\r\n required = @expLowerBound + (@tierInt * ((@expUpperBound - @expLowerBound) / @tiers))\r\n end\r\n\r\n\r\n #Gets the total amount of available experience for the player's current tier.\r\n expCount = 0\r\n (0..@tierInt-1).each do |tier|\r\n expCount += @tierExp[tier]\r\n end\r\n requiredExperience = (required * expCount).to_i\r\n\r\n #f the player's experience is greaster or equal to the required experience for the next tier, then the player advances a tier.\r\n if (@experienceInt >= requiredExperience)\r\n @tierInt+=1\r\n @tier.clear{ para(\"TIER: \" + @tierInt.to_s, @style_stats) }\r\n end\r\n\r\n end\r\n\r\n #If the ore is a higher tier than the player's tier then the durability decreases depending on the difference in tier values.\r\n if (tileTier > @tierInt)\r\n @durabilityInt -= 2 * (tileTier - @tierInt)\r\n #If the durability is 0 or less then the player loses.\r\n if (@durabilityInt <= 0)\r\n @durabilityInt = 0\r\n @endState.clear { subtitle(\"You Lose!\", @style_endgame) }\r\n @endGame = true\r\n end\r\n @durability.clear { para(\"DUR: \" + @durabilityInt.to_s, @style_stats) }\r\n end\r\n\r\n #Updates the ore count for the mined ore.\r\n reduceOreCount(tileTier-1)\r\n\r\n #Re-renders the button to displays the ore.\r\n old = @tile[col][row].btn\r\n newStyle = old.style.dup\r\n old.parent.before(old) do\r\n @tile[col][row].btn = button(@ore[tileTier-1].to_s, newStyle)###\r\n end\r\n old.remove\r\n\r\n end\r\n\r\n #Checks if all tiles have been uncovered. If so gthe game was been won.\r\n if (@hiddenCount <= 0)\r\n @endState.clear { subtitle(\"You Win!\", @style_endgame) }\r\n @endGame = true\r\n end\r\n\r\nend",
"def tile_check(x, y, d)\n # get pixel movement rate and set bit\n pix, bit = $BlizzABS.pixel, (1 << (d / 2 - 1)) & 0x0F\n # passable if virtual passability works\n return true if ($game_map.virtual_passability[x / pix, y / pix] & bit != 0x00)\n # get x and y of next tile\n case d\n when 2 then nx, ny = x / pix, (y + 1) / pix\n when 4 then nx, ny = (x - 1) / pix, y / pix\n when 6 then nx, ny = (x + 1) / pix, y / pix\n when 8 then nx, ny = x / pix, (y - 1) / pix\n else\n nx = ny = nil\n end\n # passable if still on the same tile\n return (x / pix == nx && y / pix == ny)\n end",
"def map_tile_in_rock(tile)\n (-1..1).all? { |dx| (-1..1).all? { |dy|\n t = tile.offset(dx, dy) and t.shape_basic == :Wall and tm = t.tilemat and (tm == :STONE or tm == :MINERAL or tm == :SOIL)\n } }\n end",
"def winning_move\n simulate_move(@player_num)\n end",
"def won_set\n if @opponent.games_won == 6 && @games_won == 7\n @games_won = 0\n @sets_won += 1\n elsif @games_won > 4 && @games_won > @opponent.games_won + 1\n @games_won = 0\n @sets_won += 1\n end\n\n @matches_won += 1 if won_match?\n end"
] | [
"0.6755356",
"0.66747755",
"0.66217077",
"0.6621283",
"0.6563",
"0.655895",
"0.6528054",
"0.64842206",
"0.6444673",
"0.6426896",
"0.6423936",
"0.6421323",
"0.6419945",
"0.63718295",
"0.6364941",
"0.6361717",
"0.63540435",
"0.6348064",
"0.63429266",
"0.6327487",
"0.63223755",
"0.6320524",
"0.63124555",
"0.6308665",
"0.62955344",
"0.62642354",
"0.62531394",
"0.62375355",
"0.6226316",
"0.6222596",
"0.6218938",
"0.62055284",
"0.619623",
"0.61901647",
"0.61849505",
"0.61847824",
"0.61775213",
"0.617402",
"0.6168001",
"0.6165717",
"0.614953",
"0.6145102",
"0.61413693",
"0.6122483",
"0.61174756",
"0.6115256",
"0.61129135",
"0.61127555",
"0.6104798",
"0.6098794",
"0.6095367",
"0.6093723",
"0.6092589",
"0.6087276",
"0.6084384",
"0.60841775",
"0.60807806",
"0.60637146",
"0.6063308",
"0.6062237",
"0.6060214",
"0.6059545",
"0.6055859",
"0.60525393",
"0.60520124",
"0.60511285",
"0.6045278",
"0.6036911",
"0.60352266",
"0.6024288",
"0.60227525",
"0.6018529",
"0.601806",
"0.60116124",
"0.6011211",
"0.601104",
"0.601104",
"0.60087574",
"0.6005696",
"0.59970355",
"0.59950763",
"0.5993995",
"0.59926033",
"0.5990595",
"0.59882706",
"0.59872085",
"0.5985784",
"0.59845763",
"0.59837276",
"0.5979269",
"0.59692687",
"0.59646165",
"0.596233",
"0.59615964",
"0.5961278",
"0.5960379",
"0.5959722",
"0.59577924",
"0.59571046",
"0.5954383"
] | 0.64569956 | 8 |
Checks which direction the player can move | def loss_checker
new_board = Marshal.load(Marshal.dump(@board))
option = move_right || move_left || move_up || move_down
unless option
@board = Marshal.load(Marshal.dump(new_board))
return true
end
@board = Marshal.load(Marshal.dump(new_board))
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrong_direction?(player_number)\n case player_number\n when 1\n distance_for_player(player_number) < 0\n when 2\n distance_for_player(player_number) > 0\n else\n true\n end\n end",
"def check_move(direction)\n\n if direction == 0 #up\n if @y < 1\n \n return false\n end\n elsif direction == 1 #down\n if @y > @boundry\n \n return false\n end\n elsif direction == 2 #left\n if @x < 1\n \n return false\n end\n else #right\n\n if @x > @boundry\n \n return false\n end\n\n end\n\n return true\n end",
"def movable_direction?\n\t\tif(@location.x == 0 && @direction == :WEST)\n\t\t\tthen false\n\t\telsif(@location.x == @grid-1 && @direction == :EAST)\n\t\t\tthen false\n\t\telsif(@location.y == 0 && @direction == :SOUTH)\n\t\t\tthen false\n\t\telsif(@location.y == @grid-1 && @direction == :NORTH)\n\t\t\tthen false\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend",
"def can_move?\n @max_movement > 0\n end",
"def can_change_direction_to?(new_direction)\n case @direction\n when 'up' then new_direction != 'down'\n when 'down' then new_direction != 'up'\n when 'left' then new_direction != 'right'\n when 'right' then new_direction != 'left'\n end\n end",
"def can_move?(direction)\n m = @pusher[:pos_m]\n n = @pusher[:pos_n]\n\n direction = direction.downcase\n\n # Following of the direction, test 2 cells\n if direction == 'u'\n move1 = read_pos(m-1, n)\n move2 = read_pos(m-2, n)\n elsif direction == 'd'\n move1 = read_pos(m+1, n)\n move2 = read_pos(m+2, n)\n elsif direction == 'l'\n move1 = read_pos(m, n-1)\n move2 = read_pos(m, n-2)\n elsif direction == 'r'\n move1 = read_pos(m, n+1)\n move2 = read_pos(m, n+2)\n end\n\n # Check that's not a wall, or two boxes, or one boxes and a wall\n !(move1 == '#' || ((move1 == '*' || move1 == '$') && (move2 == '*' || move2 == '$' || move2 == '#')))\n end",
"def is_valid_move x,y\n return false unless (0..3) === x\n return false unless (0..3) === y\n return @field[x][y].player == 0\n end",
"def can_move?( level, x, y )\n return true\n end",
"def movable?\n return false if (@type == 2 and @altitude < MAX_ALTITUDE)\n return (not moving?)\n end",
"def moving?\n if tdd_use_fme?\n Input.dir8 > 0\n else\n @real_x != @x || @real_y != @y\n end\n end",
"def no_player_can_move?\n !valid_move?(:black) && !valid_move?(:red)\n end",
"def legal_move?(x_destination, y_destination)\n x_movement_difference = (x_destination - self.x_pos).abs\n y_movement_difference = (y_destination - self.y_pos).abs\n\n x_movement_difference.between?(0, 1) && y_movement_difference.between?(0, 1)\n end",
"def direction_valid?(x, y)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # checks if coordinates are valid\n return (x >= 0 && x < width * pix && y >= 0 && y < height * pix)\n end",
"def is_move_available?\n self.robot.world.is_move_available?(self.x, self.y)\n end",
"def valid_move?\n\t\t@table.stays_on_table?(@robot_direction, @x, @y)\n\tend",
"def valid_move?(x, y)\n return false if is_obstructed?(x, y)\n diagonal_move_left?(x, y) || diagonal_move_right?(x,y)\n \n end",
"def can_move?(*args)\n index,dir = process_move_args(*args)\n self[index].travels?(dir) && self[index + MOVE[dir]].empty?\n end",
"def valid_move?(x_des, y_des)\n ( no_x_move?(x_des) && standard_move?(x_des, y_des) ) ||\n ( promotion_move?(x_des, y_des) || pawn_capture_move?(x_des, y_des) )\n end",
"def valid_move_vect?\n valid_passive_move_vect? || valid_aggressive_move_vect?\n end",
"def valid_move?(robot)\n x_pos = robot.x_position\n y_pos = robot.y_position\n dir = robot.direction\n invalid_east_move = (x_pos == @dimension) && (dir == 'EAST')\n invalid_west_move = x_pos.zero? && (dir == 'WEST')\n invalid_north_move = (y_pos == @dimension) && (dir == 'NORTH')\n invalid_south_move = y_pos.zero? && (dir == 'SOUTH')\n !(invalid_east_move || invalid_west_move || invalid_north_move || invalid_south_move)\n end",
"def valid_move?\n\t\tvalid_1 = (0..2).include? (@take_from)\n\t\tvalid_2 = (0..2).include? (@move_to)\n\t\tif valid_1 == false || valid_2 == false\n\t\t\tputs \"I'm sorry, please input your move in a 'x,y' format, ensuring that you are selecting numbers between 1 and 3!\"\n\t\t\tmove_input\n\t\telsif @pegs[@take_from][0] == nil\n\t\t\tputs \"I'm sorry, I'm not in the mood for a philosophical debate so let's just agree that you cannot move nothing and you can try again.\"\n\t\t\tmove_input\n\t\tend\n\tend",
"def direction_passable?(x, y, d)\n # impassable if coordinates not valid\n return false unless direction_valid?(x, y)\n # return event check and tile check result\n return (event_check(x, y, d) && tile_check(x, y, d))\n end",
"def move(dir)\n return case (player.restriction == 3 ? 10 - dir : dir)\n when 1 then player.move_lower_left\n when 2 then player.move_down\n when 3 then player.move_lower_right\n when 4 then player.move_left\n when 6 then player.move_right\n when 7 then player.move_upper_left\n when 8 then player.move_up\n when 9 then player.move_upper_right\n end\n end",
"def turn_to_player\n diffx = @x - $game.player.x\n diffy = @y - $game.player.y\n down = diffy < 0\n left = diffx > 0\n right = diffx < 0\n up = diffy > 0\n if down\n @direction = 2\n elsif up\n @direction = 8\n elsif left\n @direction = 4\n elsif right\n @direction = 6\n end\n end",
"def valid_move?( player_input )\n player_input.to_i >= 1 && player_input.to_i <= 9 && !taken?( player_input )\n end",
"def di(x); $game_player.directionalInput == x; end",
"def walking_toward?\n return Direction::Down if (@current_tile_indx >= 0 and @current_tile_indx <= 2)\n return Direction::Up if (@current_tile_indx >= 9 and @current_tile_indx <= 11)\n return Direction::Left if (@current_tile_indx >= 3 and @current_tile_indx <= 5)\n return Direction::Right if (@current_tile_indx >= 6 and @current_tile_indx <= 8)\n end",
"def valid_move?(destination)\n occupant = @board[destination]\n result = false\n if occupant.nil? || (enemy? occupant)\n result = movement_rule(destination)\n end\n\n result\n end",
"def from_right?\n dir1 = get_character(-1).direction\n dir2 = get_character(@event_id).prelock_direction\n return (dir1 * 2) % 10 == dir2\n end",
"def from_side?\n dir1 = get_character(-1).direction\n dir2 = get_character(@event_id).prelock_direction\n diff = (dir1 - dir2).abs\n return diff == 2 || diff == 4\n end",
"def move\n return false if @position.nil?\n \n movements = { north: { x: 0, y: 1 }, east: { x: 1, y: 0 }, south: { x: 0, y: -1 }, west: { x: -1, y: 0 } }\n position, movement = @position, movements[@direction]\n\n return false unless valid_position?(position[:x] + movement[:x], position[:y] + movement[:y])\n \n @position = { x: position[:x] + movement[:x], y: position[:y] + movement[:y] }\n true\n end",
"def move_possible?(target)\n self != target && # Can't target self\n same_scope?(target) && # can't be in different scopes\n # !(left..right).include?(target.left..target.right) # this needs tested more\n # detect impossible move\n !((left <= target.left && right >= target.left) or (left <= target.right && right >= target.right))\n end",
"def direction?(new_direction)\n case @direction\n when direction = 'up' then new_direction != 'down'\n when direction = 'down' then new_direction != 'up'\n when direction = 'left' then new_direction != 'right'\n when direction = 'right' then new_direction != 'left'\n end\n end",
"def detect_player(nb_pas, direction)\n return false if $game_switches[Yuki::Sw::Env_Detection]\n c = $game_map.events[@event_id]\n dx = $game_player.x - c.x\n dy = $game_player.y - c.y\n case direction\n when :right, 6\n return (dy == 0 && dx >= 0 && dx <= nb_pas)\n when :down, 2\n return (dx == 0 && dy >= 0 && dy <= nb_pas)\n when :left, 4\n return (dy == 0 && dx <= 0 && dx >= -nb_pas)\n else\n return (dx == 0 && dy <= 0 && dy >= -nb_pas)\n end\n end",
"def need_update(member)\n return false if (member.x == @x and member.y == @y) \n return false if player_distance(member) and not @start_moving\n return false if @move_update.empty?\n @start_moving = true\n if @move_update[0] == 'move_left'\n return false if (member.x + 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_right'\n return false if (member.x - 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_up'\n return false if (member.y + 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_down'\n return false if (member.y - 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_upper_left'\n return false if (member.x + 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_upper_right'\n return false if (member.x - 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_lower_left'\n return false if (member.x + 1 == @x and member.y - 1 == @y)\n elsif @move_update[0] == 'move_lower_right'\n return false if (member.x - 1 == @x and member.y - 1 == @y)\n end\n return true\n end",
"def player_spotted_directional?(up: nil, down: nil, left: nil, right: nil)\n case $game_map.events[@event_id].direction\n when 2\n return player_spotted?(down || up || left || right || 1)\n when 8\n return player_spotted?(up || down || left || right || 1)\n when 4\n return player_spotted?(left || right || up || down || 1)\n when 6\n return player_spotted?(right || left || up || down || 1)\n end\n return false\n end",
"def allowed_move?(vector, starting_rank=nil)\n self.class.allowed_move?(vector, starting_rank)\n end",
"def has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move? && !mower.is_going_outside?(lawn_x, lawn_y)\n\t \tend\n \t\treturn false\n \tend",
"def decideDirection()\n if @@invaderDirection == :right\n if !insideScreen(@speed)\n @@invaderDirection = :left\n end\n\n elsif @@invaderDirection == :left\n if !insideScreen(@speed)\n @@invaderDirection = :right\n end \n end\n end",
"def initial_direction_valid?(rover_attr)\n case rover_attr.last\n when \"n\", \"s\", \"e\", \"w\"\n true\n else\n false\n end\n end",
"def turn_away_from_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # If coordinates are equal\n if sx == 0 and sy == 0\n return\n end\n # If horizontal distance is longer\n if sx.abs > sy.abs\n # Turn to the right or left away from player\n sx > 0 ? turn_right : turn_left\n # If vertical distance is longer\n else\n # Turn up or down away from player\n sy > 0 ? turn_down : turn_up\n end\n end",
"def validate_command\n if requester != player\n errors.add(:allowed, I18n.t(\"errors.not_authorized\"))\n end\n unless airlift?\n if game.actions_taken == 4\n errors.add(:allowed, I18n.t(\"player_actions.no_actions_left\"))\n end\n if proposal.turn_nr != game.turn_nr\n errors.add(:allowed, I18n.t(\"movement_proposals.expired\"))\n end\n if destination_is_not_a_neighbor? && another_player_is_not_at_destination?\n errors.add(:allowed, I18n.t(\"movement_proposals.not_allowed\"))\n end\n end\n end",
"def can_move?\n return false if @tb_event.nil?\n @tb_event.tb_unit.can_move?\n end",
"def move_possible?(ordinates)\n if @x + ordinates[0] > @plateau.x || @x + ordinates[0] < 0 || @y + ordinates[1] > @plateau.y || @y + ordinates[1] < 0\n raise Exception, 'On the edge of plateau. Not possible to move forward.'\n end\n end",
"def valid_move?(position)\n position.between?(0,8) && !position_taken?(position)\n end",
"def can_see_wizard?(direction)\n return false unless @warrior.respond_to?(:look)\n look(direction).each{|location|\n return true if contains_enemy?(location)\n return false unless location.empty? \n }\n return false \n end",
"def update_position(direction)\n ox, oy = @x, @y\n nx, ny = @x, @y\n case direction\n when :left\n nx -= 1\n when :right\n nx += 1\n when :up\n return unless @current_cell.ladder? && !@current_cell.sky?\n ny -= 1\n when :down\n ny += 1\n end\n \n # If the would-be destination isn't valid, just return without doing anything\n return if @map.cells_at[nx][ny].rock\n return unless ((0..MAP_SIZE - 1).include?(nx) && (0..MAP_SIZE - 1).include?(ny))\n \n # If we've made it this far, the move is valid. Update player's cell coords now.\n @x, @y = nx, ny\n set_center\n set_current_cell\n \n # Fire some events at the map, so it knows how to redraw things the next time around\n @map.handle(CellDugEvent.new([nx, ny])) unless @map.cells_at[nx][ny].dug? or @map.cells_at[nx][ny].sky?\n @map.handle(PlayerMovedEvent.new([ox, oy]))\n\n # Decide whether this move put the player in gravitational jeopardy\n @falling = true if @map.cells_at[nx][ny + 1].dug? && !@map.cells_at[nx][ny + 1].ladder?\n end",
"def standard_move?(x_des, y_des)\n y_chg = (y_des.to_i - y_position).abs\n x_chg = (x_des.to_i - x_position).abs\n x_chg == 0 && ( y_chg == 1 ||\n ( first_move_pawn? && move_forward_two?(x_des, y_des) ) )\n end",
"def move?\n @moving\n end",
"def move\n return false unless on_the_table?\n\n next_x, next_y = facing.next_move_position(x, y)\n unless falls_off?(next_x, next_y)\n self.x = next_x\n self.y = next_y\n true\n else\n false\n end\n end",
"def does_it_land?\n if self.robot.moves.count < 1 \n errors.add(:base, :landing_error) if !self.is_move_available?\n end\n end",
"def valid_move?(input)\n (0..8).include?(input) && !position_taken?(input)\n end",
"def check_direction(origin_arr,destination_arr)\n\t\t horizontal_direction(origin_arr,destination_arr) || diagonal_direction(origin_arr,destination_arr)\n\tend",
"def check_direction(origin_arr,destination_arr)\n\t\t horizontal_direction(origin_arr,destination_arr) || diagonal_direction(origin_arr,destination_arr)\n\tend",
"def valid_movement?(m)\n if m.length > 0\n m.each do |i|\n if not Navigation.DIRECTION.include?(i)\n return false\n end\n end\n else\n return false\n end\n true\n end",
"def valid_move?(new_x, new_y)\n true\n end",
"def moves_available?(player)\n !@board.moves(player).empty?\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def move_valid_for?(player_id)\n return false if last_player_id == player_id\n\n true\n end",
"def movable_moving?\n\n @movable_delta_x&.nonzero? || @movable_delta_y&.nonzero?\n\n end",
"def snake_can_change_direction?(key)\n value = false\n @move_patterns.each do |move|\n if move.include?(key)\n unless move.include?(key) && move.include?(@direction)\n value = true\n end\n end\n end\n value\n end",
"def move?\n return @moving\n end",
"def is_move_allowed(to_x,to_y) #Checks to see if the move is allowed based on the pieces 'rule'\n allowed=false\n \n x_diff=(to_x-@x).abs\n y_diff=(to_y-@y).abs\n \n if x_diff <=1 && y_diff <=1\n allowed= true\n end\n if x==to_x && y==to_y\n allowed = false\n end\n\n return allowed\n end",
"def move? (x_destination, y_destination)\n\t\t# 2 options\n\t\t# When is does it return true?\n\t\tif x_destination == @x_coordinate && y_destination != @y_coordinate\n\t\t\t# vertical\n\t\t\t\t# x stays the same\n\t\t\t\t# y changes\n\t\t\ttrue \n\t\telsif y_destination == @y_coordinate && x_destination != @x_coordinate\n\t\t\t# horizontal\n\t\t\t\t# y stays the same\n\t\t\t\t# x changes\n\t\t\ttrue\n\n\t\t# When is does it return false?\n\t\telse\n\t\t\t# any other movemente\t\t\t\n\t\t\tfalse\n\t\tend\n\tend",
"def valid_moves\n @pad.cells.select { |c| self.can_move?(*c.pos) }\n end",
"def turn\n player_1.move(input)\n # if valid_move?(input) != true; \n # puts \"invalid move\"\n # player_2.move(input)\n # if valid_move?(input) != true; \n # puts \"invalid move\"\n # end\n end",
"def dir_ok(direction, dir_hop) \n\t\t@board.in_bounds?(dir_hop) && \n\t\t@board.get_piece(dir_hop).nil? && \n\t\t!@board.get_piece(direction).nil? && \n\t\t@board.get_piece(direction).color != @color\n\tend",
"def has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move?(lawn_mowers_positions)\n\t \tend\n \t\treturn false\n \tend",
"def moving?\n !@start_move\n end",
"def can_i_move?(x, y)\n x, y = x.to_i, y.to_i\n ( x >= 0 && x <= dimension.width ) && ( y >= 0 && y <= dimension.height )\n end",
"def valid_move\n display_current_turn\n \tcol = prompt_legal_move\n \treturn col, @turn%2\n end",
"def validate_move(input)\n if [1,2,3,4,5,6,7,8,9].include?(input) && !player1.include?(input) && !player2.include?(input) \n true\n else\n false\n end\n end",
"def legal_move?(board,from,to)\n\t\treturn false unless super(board,to)\n\t\tfrom_y = from[1]\n\t\tfrom_x = from[0]\n\t\tto_y = to[1]\n\t\tto_x = to[0]\n\t\t#when trying to move diagonally\n\t\tif from_x != to_x\n\t\t\t#checks colour of pawn\n\t\t\tif colour == \"white\"\n\t\t\t\t#checks only 1 vertical move away\n\t\t\t\tif (from_y-to_y) == 1\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"No enemy pawn there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif (to_y-from_y) == 1\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"No enemy pawn there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#when trying to move straight\n\t\tif colour == \"white\"\n\t\t\tif from_y == 6\n\t\t\t\tif (from_y-to_y) <= 2 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 or 2 spaces from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\t\t\t\t\t\n\t\t\telse\n\t\t\t\tif (from_y-to_y) == 1 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 space from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tif from_y == 1\n\t\t\t\tif (to_y-from_y) <= 2 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 or 2 spaces from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif (to_y-from_y) == 1 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 space from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def valid_move?(position)\n !taken?(position) && position.to_i >0 && position.to_i <=9\n end",
"def tryMove\n #Resets the angle continuously to provide accurate data.\n @angle = Math.atan2(@y - @map.player.y, @x - @map.player.x) - Math::PI / 2\n #Sets axis of acceleration with relation to the direction.\n if @direction == 1\n @aceY = Math.sin(@angle - Math::PI / 2) / 4\n else\n @aceX = Math.cos(@angle - Math::PI / 2) / 4\n end\n #Adds acceleration to velocity.\n @velX += @aceX\n @velY += @aceY\n #Terminal velocity is 3.\n if @velX > 3\n velX = 3\n elsif @velX < -3\n velX = -3\n end\n #Checks for collision and moves the missile.\n collidesWithPlayer\n detectCollision\n end",
"def valid_move?(input_position)\n num = self.convert_to_i(input_position)\n num.between?(1, 9) && !self.taken?(num)\n end",
"def check_player\n if self.moves == nil or self.moves.length % 2 == 0\n @current_player = 1\n else\n @current_player = 2\n end \n end",
"def valid_move?(index)\n puts \"Turn #{turn_count}\"\n index.between?(0,8) && !position_taken?(index)\n end",
"def valid_move?(location)\n location.to_i.between?(1,9) && !position_taken?(location.to_i-1)\n end",
"def update_player_movement\r\n # Move player in the direction the directional button is being pressed\r\n case Input.dir4\r\n when 2\r\n move_down\r\n when 4\r\n move_left\r\n when 6\r\n move_right\r\n when 8\r\n move_up\r\n end\r\n end",
"def move_valid?\n @board.first_disk = 0\n\n #determine disk piece to be moved\n @board.board.each do |row, arr|\n if arr[@player.from] != 0\n @board.first_disk = arr[@player.from]\n break\n end\n end\n\n #determine the highest disk available in that column\n @board.board.each do |row, arr|\n if arr[@player.to] != 0\n @board.second_disk = arr[@player.to]\n break\n else\n @board.second_disk = arr[@player.to]\n end\n end\n\n #conditional test to see if move is valid\n if @board.first_disk == 0\n puts \"No disks in this column, try again\"\n get_input\n elsif @board.second_disk == 0 || @board.first_disk < @board.second_disk\n move_disk\n else\n puts \"Move is invalid\"\n puts \"Please check the rules and input a new move\"\n get_input\n end\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n\n # What if they follow more aggressively on harder difficulty?\n\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n\n end",
"def check_valid_move to_move\r\n\t\t\r\n\t\tif to_move == 0\r\n\t\t\tif driver.location.west_road == nil\r\n\t\t\t\treturn false\r\n\t\t\telse\r\n\t\t\t\treturn true\r\n\t\t\tend\r\n\t\t\r\n\t\telsif to_move == 1\r\n\t\t\tif driver.location.north_road == nil\r\n\t\t\t\treturn false\r\n\t\t\telse\r\n\t\t\t\treturn true\r\n\t\t\tend\r\n\t\t\r\n\t\telsif to_move == 2\r\n\t\t\tif driver.location.east_road == nil\r\n\t\t\t\treturn false\r\n\t\t\telse\r\n\t\t\t\treturn true\r\n\t\t\tend\r\n\t\t\r\n\t\telsif to_move == 3\r\n\t\t\tif driver.location.south_road == nil\r\n\t\t\t\treturn false\r\n\t\t\telse\r\n\t\t\t\treturn true\r\n\t\t\tend\r\n\t\telse\r\n\t\t\traise \"The location does not exist. Error\"\r\n\t\t\r\n\t\tend\r\n\t\treturn false\r\n\tend",
"def check_legal_move(y,x)\n\t\tif y > 7 || y < 0\n\t\t\treturn false\n\t\telsif x > 7 || x < 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def move(forward)\n if @direction == \"N\"\n if @y + 1 < @@ymax\n @y += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"S\"\n if @y - 1 > @@ymin\n @y -= 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction ==\"E\"\n if @x + 1 < @@xmax\n @x += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"W\"\n if @x - 1 > @@xmin\n @x -= 1\n else\n puts \"Nice try sucker\"\n end\n else\n puts \"Where in the world are you?\"\n end\nend",
"def can_pass_to? target_player\n\t\treturn false unless target_player.is_a? Player\n\t\tres = can_move?\n\t\tres &= @has_ball\n\t\tres &= !@team.pass?\n\t\tres &= target_player\n\t\tres &= target_player != self\n\t\tres &= target_player.team == @team\n\t\tres &= target_player.health == Health::OK\n\t\tres &= dist(self, target_player) <= 10.5\n\tend",
"def check_move(start_pos, end_pos)\n # p start_pos\n # puts end_pos\n\n if self[[start_pos[0], start_pos[1]]].valid_move?(start_pos, end_pos, self)\n self[[start_pos[0], start_pos[1]]].move(start_pos, end_pos, self)\n end\n end",
"def next_move_correct?(ary,attacking = false)\n diff1 = ary[0] - current_position[0]\n diff2 = ary[1] - current_position[1]\n if diff1 == 0 || diff2 == 0\n true\n else\n false\n end\n end",
"def standard_move?(x,y)\n return (x_diff(x) == 0) && (y_diff(y) == 1)\n end",
"def isValidMove(pos)\n\tif pos < 0 || pos > 8\n\t\tprint \"Invalid move. Try again human. \\n\"\n\t\treturn false\n\telsif @bo[pos] == '-' then\n\t\treturn true\n\telse \n\t\treturn false\n\tend\n end",
"def check_if_valid(player_move)\n [\"rock\", \"paper\", \"scissors\", \"spock\", \"lizard\"].include?(player_move.downcase)\n end",
"def check_direction(origin_arr,destination_arr)\n\t\t horizontal_direction(origin_arr,destination_arr)\n\tend",
"def move()\n if @direction == \"up\"\n move_up()\n elsif @direction == \"down\"\n move_down()\n else\n #check if anyone is on current floor- which way do majority want to go from here?\n @direction = people_on_current_floor()\n if @direction == \"up\" #were more ppl on this floor wanting to go up\n move_up()\n elsif @direction == \"down\"\n move_down()\n else #no one on this floor, decide direction based on pending rqsts above and below...\n decide_direction()\n end\n end\n end",
"def move\n return false if @position.nil?\n\n position = @position\n movement = nil\n\n case @direction\n when :north\n movement = { x: 0, y: 1}\n when :east\n movement = { x: 1, y: 0}\n when :south\n movement = { x: 0, y: -1}\n when :west\n movement = { x: -1, y: 0}\n end\n\n moved = true\n\n if valid_position?(position[:x] + movement[:x], position[:y] + movement[:y])\n @position = { x: position[:x] + movement[:x], y: position[:y] + movement[:y] }\n else\n moved = false\n end\n\n moved\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n end",
"def move(args)\n return if !@is_robot_availabe\n case @direction\n when \"NORTH\"\n if @pos_y + STEP <= TABLE_Y\n @pos_y += STEP\n return\n end\n \n when \"EAST\"\n if @pos_x + STEP <= TABLE_X\n @pos_x += STEP\n return\n end\n \n when \"SOUTH\"\n if @pos_y - STEP >= 0\n @pos_y -= STEP\n return\n end\n \n when \"WEST\"\n if @pos_x - STEP >= 0\n @pos_x -= STEP\n return\n end\n \n end\n puts \"Warning: Robot cannot move towards #{@direction} anymore. \"\n # return \"MOVE\" #for test\n end",
"def valid_move?(position)\n if !position_taken?(position) && position.between?(0,8)\n true\n else\n false\n end\n end",
"def can_move?(cordx, cordy , x_dest, y_dest)\n\t\t\n\t\tif @pieces == nil \n\t\t\tputs \"No piece at.\"\n\t\telsif x_dest == cordx && y_dest == cordy\n\t\t\tputs \"no change\"\n\t\telsif x_dest > 8 || y_dest > 8\n\t\t\t puts \"Offboard.\"\n\t\telse \n\t\t\t@pieces[cordx][cordy].can_move?(x_dest, y_dest)\n\t\tend\n\tend",
"def prompt_legal_move\n col = current_player.move\n while @board.col_full?(col)\n display_invalid_move_error\n col = current_player.move\n end\n return col\n end",
"def move\n return false if @position.nil?\n\n position = @position\n movement = nil\n\n case @direction\n when :north\n movement = { x: 0, y: 1 }\n when :east\n movement = { x: 1, y: 0 }\n when :south\n movement = { x: 0, y: -1 }\n when :west\n movement = { x: -1, y: 0 }\n end\n\n moved = true\n\n if valid_position?(position[:x] + movement[:x], position[:y] + movement[:y])\n @position = { x: position[:x] + movement[:x], y: position[:y] + movement[:y] }\n else\n moved = false\n end\n\n moved\n end",
"def valid_move?(fir, sec)\n if (sec < 0) || (sec > 8)\n return false\n elsif position_taken?(fir,sec)\n return false\n else\n return true\n end\nend"
] | [
"0.74024445",
"0.7332658",
"0.724085",
"0.71682894",
"0.7045401",
"0.6987203",
"0.6961299",
"0.68895847",
"0.6882734",
"0.6856465",
"0.68360025",
"0.67973495",
"0.6769293",
"0.6747672",
"0.67243177",
"0.6720989",
"0.66853917",
"0.66672814",
"0.66530913",
"0.6631125",
"0.6580701",
"0.65633416",
"0.65582234",
"0.65353763",
"0.65291303",
"0.6512086",
"0.6493901",
"0.64853597",
"0.64537305",
"0.6438507",
"0.64255667",
"0.6412912",
"0.6412111",
"0.64015585",
"0.6399856",
"0.63824725",
"0.6372103",
"0.63538086",
"0.63496846",
"0.63401115",
"0.6334869",
"0.6334234",
"0.63314724",
"0.6329542",
"0.6327354",
"0.63108057",
"0.63089377",
"0.6307546",
"0.62990135",
"0.62836874",
"0.6280959",
"0.62632483",
"0.62629014",
"0.62629014",
"0.62467414",
"0.62439805",
"0.6241161",
"0.62407935",
"0.6240145",
"0.6236779",
"0.62325734",
"0.6231134",
"0.6229944",
"0.62257",
"0.62155354",
"0.62135136",
"0.6212342",
"0.6212198",
"0.6211428",
"0.62094283",
"0.62080514",
"0.6195347",
"0.6191687",
"0.61823165",
"0.6179708",
"0.6177754",
"0.6175111",
"0.6174974",
"0.6170049",
"0.61697924",
"0.61580646",
"0.6144469",
"0.61364883",
"0.61359113",
"0.61231714",
"0.61140555",
"0.6099849",
"0.60932136",
"0.60924494",
"0.60848296",
"0.6081557",
"0.60814553",
"0.60787517",
"0.607857",
"0.60727984",
"0.60713303",
"0.60691595",
"0.6065162",
"0.606285",
"0.60618883",
"0.60579246"
] | 0.0 | -1 |
Event Sequence for every game | def play
greeting
get_tiles
move_sequence
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_loop\n end",
"def game_loop\n end",
"def gameflow\n \n end",
"def game_setup\n end",
"def perform\n\tgame_menu\n\tgameplay\nend",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def pbCommonEvent(id)\n return false if id<0\n ce = $data_common_events[id]\n return false if !ce\n celist = ce.list\n interp = Interpreter.new\n interp.setup(celist,0)\n begin\n Graphics.update\n Input.update\n interp.update\n pbUpdateSceneMap\n end while interp.running?\n return true\nend",
"def setup_starting_event\r\n # Refresh the event page when switch/variable was changed\r\n $game_map.refresh if $game_map.need_refresh\r\n # Start common event if required\r\n if $game_temp.common_event_id > 0\r\n setup($data_common_events[$game_temp.common_event_id].list, 0)\r\n $game_temp.common_event_id = 0\r\n return\r\n end\r\n # Try to start an event\r\n $game_map.events.each_value do |event|\r\n next unless event.starting\r\n if event.trigger < 3\r\n event.clear_starting\r\n event.lock\r\n end\r\n return setup(event.list, event.id)\r\n end\r\n # Try to start a common event\r\n $data_common_events.each do |common_event|\r\n next unless common_event&.trigger == 1 && $game_switches[common_event.switch_id]\r\n return setup(common_event.list, 0)\r\n end\r\n end",
"def run\n start_game\n game_loop\n end_game\n end",
"def play\n #calls to all the methods that produce game!\n end",
"def events\n end",
"def pbCommonEvent(id)\n return false if id<0\n ce=$data_common_events[id]\n return false if !ce\n celist=ce.list\n interp=Interpreter.new\n interp.setup(celist,0)\n begin\n Graphics.update\n Input.update\n interp.update\n pbUpdateSceneMap\n end while interp.running?\n return true\nend",
"def initialize_events\n @arpeggiators.each do |arpeggiator|\n arpeggiator.sequencer.event.stop << proc { @clock.stop }\n end\n @clock.event.tick << proc do\n @arpeggiators.map do |arpeggiator|\n arpeggiator.sequencer.exec(arpeggiator.sequence)\n arpeggiator\n end\n end\n true\n end",
"def send_events; end",
"def execute_sequence\n case @acts[0]\n when SEQUENCE_POSE; setup_pose\n when SEQUENCE_MOVE; setup_move\n when SEQUENCE_SLIDE; setup_slide\n when SEQUENCE_RESET; setup_reset\n when SEQUENCE_MOVE_TO_TARGET; setup_move_to_target\n when SEQUENCE_SCRIPT; setup_eval_script\n when SEQUENCE_WAIT; @acts[1].times { method_wait }\n when SEQUENCE_DAMAGE; setup_damage\n when SEQUENCE_CAST; setup_cast\n when SEQUENCE_VISIBLE; @visible = @acts[1]\n when SEQUENCE_SHOW_ANIMATION; setup_anim\n when SEQUENCE_AFTERIMAGE; @afterimage = @acts[1]\n when SEQUENCE_FLIP; setup_flip\n when SEQUENCE_ACTION; setup_action\n when SEQUENCE_PROJECTILE_SETUP; setup_projectile\n when SEQUENCE_PROJECTILE; show_projectile\n when SEQUENCE_LOCK_Z; @lock_z = @acts[1]\n when SEQUENCE_ICON; setup_icon\n when SEQUENCE_SOUND; setup_sound\n when SEQUENCE_IF; setup_branch\n when SEQUENCE_TIMED_HIT; setup_timed_hit\n when SEQUENCE_SCREEN; setup_screen\n when SEQUENCE_ADD_STATE; setup_add_state\n when SEQUENCE_REM_STATE; setup_rem_state \n when SEQUENCE_CHANGE_TARGET; setup_change_target\n when SEQUENCE_TARGET_MOVE; setup_target_move\n when SEQUENCE_TARGET_SLIDE; setup_target_slide\n when SEQUENCE_TARGET_RESET; setup_target_reset\n when SEQUENCE_BLEND; @blend = @acts[1]\n when SEQUENCE_FOCUS; setup_focus\n when SEQUENCE_UNFOCUS; setup_unfocus\n when SEQUENCE_TARGET_LOCK_Z; setup_target_z\n # New update list v1.1\n when SEQUENCE_ANIMTOP; setup_anim_top\n when SEQUENCE_FREEZE; $game_temp.global_freeze = @acts[1]\n when SEQUENCE_CSTART; setup_cutin\n when SEQUENCE_CFADE; setup_cutin_fade\n when SEQUENCE_CMOVE; setup_cutin_slide\n when SEQUENCE_TARGET_FLIP; setup_targets_flip\n when SEQUENCE_PLANE_ADD; setup_add_plane\n when SEQUENCE_PLANE_DEL; setup_del_plane\n when SEQUENCE_BOOMERANG; @proj_setup[PROJ_BOOMERANG] = true\n when SEQUENCE_PROJ_AFTERIMAGE; @proj_setup[PROJ_AFTERIMAGE] = true\n when SEQUENCE_BALLOON; setup_balloon_icon\n # New update list v1.2\n when SEQUENCE_LOGWINDOW; setup_log_message\n when SEQUENCE_LOGCLEAR; get_scene.log_window.clear\n when SEQUENCE_AFTINFO; setup_aftinfo\n when SEQUENCE_SMMOVE; setup_smooth_move\n when SEQUENCE_SMSLIDE; setup_smooth_slide\n when SEQUENCE_SMTARGET; setup_smooth_move_target\n when SEQUENCE_SMRETURN; setup_smooth_return\n # New update list v1.3 + v1.3b + v1.3c\n when SEQUENCE_LOOP; setup_loop\n when SEQUENCE_WHILE; setup_while\n when SEQUENCE_COLLAPSE; tsbs_perform_collapse_effect\n when SEQUENCE_FORCED; setup_force_act\n when SEQUENCE_ANIMBOTTOM; setup_anim_bottom\n when SEQUENCE_CASE; setup_switch_case\n when SEQUENCE_INSTANT_RESET; setup_instant_reset\n when SEQUENCE_ANIMFOLLOW; setup_anim_follow\n when SEQUENCE_CHANGE_SKILL; setup_change_skill\n when SEQUENCE_CHECKCOLLAPSE; setup_check_collapse\n when SEQUENCE_RESETCOUNTER; get_scene.damage.reset_value\n when SEQUENCE_FORCEHIT; @force_hit = default_true\n when SEQUENCE_SLOWMOTION; setup_slow_motion\n when SEQUENCE_TIMESTOP; setup_timestop\n when SEQUENCE_ONEANIM; $game_temp.one_animation_flag = true\n when SEQUENCE_PROJ_SCALE; setup_proj_scale\n when SEQUENCE_COMMON_EVENT; setup_tsbs_common_event\n when SEQUENCE_GRAPHICS_FREEZE; Graphics.freeze\n when SEQUENCE_GRAPHICS_TRANS; setup_transition\n # New update list v1.4\n when SEQUENCE_FORCEDODGE; @force_evade = default_true\n when SEQUENCE_FORCEREFLECT; @force_reflect = default_true\n when SEQUENCE_FORCECOUNTER; @force_counter = default_true\n when SEQUENCE_FORCECRITICAL; @force_critical = default_true\n when SEQUENCE_FORCEMISS; @force_miss = default_true\n when SEQUENCE_BACKDROP; setup_backdrop\n when SEQUENCE_BACKTRANS; setup_backdrop_transition\n when SEQUENCE_REVERT_BACKDROP; $game_temp.backdrop.revert;Fiber.yield\n when SEQUENCE_TARGET_FOCUS; @focus_target = @acts[1]\n when SEQUENCE_SCREEN_FADEOUT; setup_screen_fadeout\n when SEQUENCE_SCREEN_FADEIN; setup_screen_fadein\n when SEQUENCE_CHECK_COVER; setup_check_cover\n when SEQUENCE_STOP_MOVEMENT; stop_all_movements\n when SEQUENCE_ROTATION; setup_rotation\n when SEQUENCE_FADEIN; setup_fadein\n when SEQUENCE_FADEOUT; setup_fadeout\n when SEQUENCE_IMMORTALING; setup_immortaling\n when SEQUENCE_END_ACTION; setup_end_action\n when SEQUENCE_SHADOW_VISIBLE; $game_temp.shadow_visible = default_true\n when SEQUENCE_AUTOPOSE; setup_autopose\n when SEQUENCE_ICONFILE; @icon_file = @acts[1] || ''\n when SEQUENCE_IGNOREFLIP; @ignore_flip_point = default_true\n # Interesting on addons?\n else; custom_sequence_handler\n end\n end",
"def event; end",
"def event; end",
"def event; end",
"def tick events\r\n turn_radar 35 if time ==0\r\n turn_gun 25 if time <3\r\n accelaterate 2\r\n turn 2\r\n fire 4 unless events ['robot_scanned'].empty?\r\n end",
"def process\n finish_games\n level_up\n warn_level_up\n start_games\n end",
"def go_game\n #RPG::BGM.fade(30)\n #Graphics.fadeout(30)\n #Graphics.frame_count = 0\n DataManager.autosave(true, false)\n SceneManager.goto(Scene_Map)\n #$game_system.on_after_load\n end",
"def setup\n @turn_order_delegate = self\n @end_game_delegate = self\n #a = self.players.length if self.players\n #puts \"first player id: #{@players.first.id}\"\n #broadcast_event Game::GAME_INITIALIZED, {}\nend",
"def play\n\t\tgame_loop\n\tend",
"def do_event\n=begin\n\n event = Events.new(@resources[:luck])\n # starts an event\n event.start\n decision = gets.chomp\n\n until event.accepts? decision # Requires valid input\n UiHandler.print_error(event.valid_range)\n decision = gets.chomp\n end\n\n # event.dispatch accepts player decision and affects the world\n # returning new number of resources\n @resources = event.dispatch(decision)\n\n=end\n end",
"def tick events\n if events['robot_scanned'].empty?\n turn 1\n else\n fire 3\n end\n end",
"def start_phase4\n @a_remaining_pk.visible = false\n @e_remaining_pk.visible = false if $game_temp.trainer_battle\n @phase = 4\n $game_temp.battle_turn += 1\n for index in 0...$data_troops[@troop_id].pages.size\n page = $data_troops[@troop_id].pages[index]\n if page.span == 1\n $game_temp.battle_event_flags[index] = false\n end\n end\n @enemy_actions.clear\n @actor_actions.clear\n #Test IA\n @seed = @magneto.get_action\n @actor_actions += @magneto.get_action\n @enemy_actions += @magneto.get_action\n pc \"New seed : #{@seed}\"\n srand(@seed)\n #>Sécurité\n BattleEngine::set_actors(@actors)\n BattleEngine::set_enemies(@enemies)\n @actions = BattleEngine::_make_action_order(@actor_actions, @enemy_actions, @actors, @enemies)\n @phase4_step = 0\n launch_phase_event(4,true)\n end",
"def update\n # Refresh map if necessary\n if $game_map.need_refresh\n # Refresh the Game Map - CRITICAL for changing Event Pages\n refresh\n end\n # If scrolling \n\t if @scroll_rest > 0\n\t distance = 2 ** @scroll_speed\n\t case @scroll_direction\n\t when 2\n\t\t scroll_down(distance)\n\t when 4 \n\t\t scroll_left(distance)\n\t when 6 \n\t\t scroll_right(distance)\n\t when 8 \n\t\t scroll_up(distance)\n\t end\n \t @scroll_rest -= distance\n end\n\n \n \n # This is the Event Anti Lag Code\n\t for event in @events.values\n # If Event is In Range, Auto, Parallel, Set Move Route, or Cat Actor\n\t if event.trigger == 3 or event.trigger == 4 or event.lag_include or\n in_range?(event) \n # Update the Event\n\t\t event.update\n # If you have other code to run, allow this part to run first, then\n # run other parts of scripts here inside of the conditional branch.\n\t end\n\t end\n # End Event Anti Lag Code\n \n \n \n\t for common_event in @common_events.values\n\t common_event.update\n\t end\n\t @fog_ox -= @fog_sx / 8.0\n\t @fog_oy -= @fog_sy / 8.0\n\t if @fog_tone_duration >= 1\n\t d = @fog_tone_duration\n\t target = @fog_tone_target\n\t @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d\n\t @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d\n\t @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d\n\t @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d\n\t @fog_tone_duration -= 1\n\t end\n\t if @fog_opacity_duration >= 1\n\t d = @fog_opacity_duration\n\t @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d\n\t @fog_opacity_duration -= 1\n\t end\n end",
"def setup_tsbs_common_event\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n @acts[1] = 0 unless @acts[1].is_a?(Numeric)\n $game_temp.tsbs_event = @acts[1]\n Fiber.yield\n end",
"def step\n @queue << UndrawSprites.new( @screen, @background )\n @queue.fetch_sdl_events\n @queue << $game.clock.tick\n @queue << DrawSprites.new( @screen )\n @queue.each do |event|\n handle( event )\n end\n end",
"def play_cycle\n play\n earn_achievements\n end_game\n end",
"def call_common_event(id)\n if $imported[\"TH_SceneInterpreter\"] == true\n @interpreter.setup($data_common_events[id].list)\n @phone_command.activate\n else\n dispose_phone_background\n @phone_command.dispose\n $game_temp.reserve_common_event(id)\n SceneManager.return\n end\n end",
"def start_falling(event)\n event.obfalling = 1\n event.move_speed = 4.5\n event.through = true\n event.fallbyjump.nil? ? event.move_away_from_player : event.fallbyjump = nil\n RPG::SE.new(FallSe,80).play \n @eve_fall.push(event) unless @eve_fall.include?(event)\n @eve_fall = @eve_fall.uniq \n @player_busy = event.picked = false if event.picked\n end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def do_turn_end_evs\n @wait_on_turn_end_evs = true\n ev_ids = TM.ev_turn_start[TM.turn_no]\n print \"do_turn_end_evs, ev_ids = #{ev_ids} turn_no = #{TM.turn_no}\\n\"\n if ev_ids\n ev_ids.each{|id| Era::AI.start_event(id)}\n end\n end",
"def update_global_common_events\n end",
"def start_a_game\n jeopardy_board\n play_game\nend",
"def game_start\n opening\n first_menu\n end",
"def run\n @running = true\n clock = Rubygame::Clock.new()\n queue = Rubygame::EventQueue.new()\n queue.enable_new_style_events\n rl = ResourceLocator.instance\n \n clock.tick\n while @running and self.current\n pre_transition = self.current # All events in the queue are applied to the\n # current state\n mouseUps = []\n queue.each do |event|\n pre_transition.raw(event) if pre_transition.respond_to?(:raw)\n case(event)\n when QuitRequested\n @running = false\n when KeyPressed\n result = @hooks[event.key]\n result.call(self) if result\n #puts event.key\n pre_transition.keyEvent(event,true)\n when KeyReleased\n pre_transition.keyEvent(event, false)\n when MouseMoved\n pre_transition.mouseMove(event)\n when MousePressed\n pre_transition.mouseDown(event)\n when MouseReleased\n mouseUps << event\n end\n end\n \n # This is done outside of the event-handling loop, because otherwise\n # the when the continuations it causes (i.e. pressing the 'done' button)\n # return, they bring back the old state of the event queue with them,\n # and the mouse events are re-played.\n mouseUps.each do | event |\n pre_transition.mouseUp(event)\n end\n \n rl.screen.fill([0,0,0])\n current.draw(rl.screen) if current\n rl.screen.flip\n elapsed = clock.tick / 1000.0\n current.update(elapsed) if current\n\n Rubygame::Clock.wait(50)\n \n end\n Rubygame::quit\n end",
"def periodic\n SND.log.debug 'Periodic actions start'\n SND::Game.game_operations\n SND::Game.start_games\n SND.log.debug 'Periodic actions end'\n end",
"def process_events\n while e = get_event\n begin\n # pre triggers\n obj = Engine.instance.db.get(e.to)\n obj2 = Engine.instance.db.get(e.from)\n sid = obj.get_trigger(\"pre_\"+e.kind.to_s)\n if sid\n script = Engine.instance.db.get(sid)\n if script\n if script.execute(e)\n # success\n if obj2.class == Character\n s,o = obj.msgsucc.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n else\n # failure\n if obj2.class == Character\n s,o = obj.msgfail.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n next\n end\n else\n log.error \"Script not found: #{sid} for Event: #{e}\"\n # We fail the action slently\n next\n end\n end\n\n # action receiver\n obj.send(e.kind,e)\n\n # post triggers\n sid = obj.get_trigger(e.kind)\n if sid\n script = Engine.instance.db.get(sid)\n if script\n if script.execute(e)\n # success\n if obj2.class == Character\n s,o = obj.msgsucc.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n else\n # failure\n if obj2.class == Character\n s,o = obj.msgfail.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n end\n else\n log.error \"Script not found: #{sid} for Event: #{e.inspect}\"\n # We fail the action slently\n end\n end\n rescue\n log.error \"Event failed: #{e.inspect}\"\n log.error $!\n end\n end\n end",
"def update_battle_event \n $game_troop.interpreter.update\n #$game_map.interpreter.update\n #check system battle events\n if $game_troop.interpreter.running?\n # Update interpreter\n $game_troop.interpreter.update\n unless $game_troop.interpreter.update\n # Rerun battle event set up if battle continues\n $game_troop.setup_battle_event\n end\n else\n #check map battle events\n if !$game_troop.interpreter.running?#$game_map.interpreter.running?\n for event in $game_system.battle_events.values\n event.update \n end\n end\n end\n end",
"def exec_event(ce)\r\n if ce.event\r\n @direction, @completed, @message = ce.event.happens(@pc)\r\n ce.update_attribute(:completed, @completed)\r\n @pc.reload\r\n else\r\n Rails.logger.warn \"!!! No event found for current event; #{ce.inspect}\"\r\n ce.update_attribute(:completed, @completed)\r\n @pc.reload\r\n end\r\n\r\n if @direction\r\n flash[:notice] = @message\r\n redirect_to @direction\r\n else\r\n render :file => 'game/complete', :layout => true\r\n end\r\n end",
"def game_engine\n\t\tif @ai_on == true\n\t\t\tgame_with_ai\n\t\telse\n\t\t\t@player_two = 'black'\n\t\t\tgame_with_two_players\n\t\tend\n\t\tannounce_winner\n\t\tend_of_game\n\tend",
"def setup_event_hooks\n hooks = {\n :escape => :quit,\n :q => :quit,\n :s => :toggle_smooth,\n\n QuitRequested => :quit,\n\n # Tell the user where they clicked.\n MousePressed => proc { |owner, event|\n puts \"click: [%d,%d]\"%event.pos\n },\n\n # These help to ensure everything is refreshed after the\n # Rubygame window has been covered up by a different window.\n InputFocusGained => :update_screen,\n WindowUnminimized => :update_screen,\n WindowExposed => :update_screen,\n\n # Refresh the window title.\n :tick => :update_framerate\n }\n\n make_magic_hooks( hooks )\n end",
"def check_common_event\r\n SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?\r\n end",
"def start\r\n initialize_game\r\n until @game.over?\r\n take_turn\r\n end\r\n print_outcome\r\n end",
"def handle_event event \n case event[:name]\n when 'sleep'\n puts 'sleep'\n sleep 4\n \n when 'change_state'\n puts 'change_state'\n \n when 'tick'\n puts 'tick'\n \n end\n end",
"def game_state\n end",
"def game_over\n end",
"def onTimeoutAlgorithmHaveToPlay\r\n alg_make_move\r\n # restore event process\r\n @core_game.continue_process_events if @core_game\r\n end",
"def on_input\n @movement.each do |entity|\n entity[:movement]= nil\n end\n\n @player[:action]= case @window.active_input\n when \"h\" then [:move, Vector[-1, 0]]\n when \"j\" then [:move, Vector[ 0, 1]]\n when \"k\" then [:move, Vector[ 0, -1]]\n when \"l\" then [:move, Vector[ 1, 0]]\n when \"y\" then [:move, Vector[-1, -1]]\n when \"b\" then [:move, Vector[-1, 1]]\n when \"u\" then [:move, Vector[ 1, -1]]\n when \"n\" then [:move, Vector[ 1, 1]]\n when \"g\" then [:draw_card]\n when \"f\" then [:play_weapon]\n when \"d\" then [:play_spell]\n when \"s\" then [:play_item]\n when \"a\" then [:replace_item]\n when \"q\" then throw(:game_end)\n else\n return\n end\n\n @ai_method.each do |entity|\n entity[:action] = self.send(entity[:ai_method], entity)\n end\n\n @action.each do |entity|\n action, *args = entity[:action]\n next if action.nil?\n\n self.send(action, entity, *args)\n entity[:action]= nil\n end\n\n @movement.each do |entity|\n next if entity[:movement].nil?\n\n oldpos = entity[:position]\n newpos = entity[:position] + entity[:movement]\n\n next if out_of_bounds?(newpos)\n\n entities_at_pos = @map[:index][newpos]\n obstructed = entities_at_pos.any? do |entity|\n entity[:obstructing] == true\n end\n next if obstructed\n\n b = entity[:position]\n m = entity[:movement] / 5.0\n points = 6.times.map { |t| (b + (m*t)) }\n\n entity[:position]= newpos\n entity[:movement]= nil\n entity[:tween_points]= points\n @map[:index][oldpos].delete(entity)\n @map[:index][newpos].push(entity)\n end\n\n @animating = true\n end",
"def end_game\n end",
"def tick(events)\n end",
"def human_event; end",
"def actions_when_game_is_lost\n puts \"\"\n puts \"GAME OVER\".red\n self.quit_game = true\n end",
"def finalize_game\n\n end",
"def game_over\n #some end game conditions\nend",
"def use_default_gamecall\n event = Event.find_by(id: self.event_id)\n title = self.title\n\n #----------Openers----------\n openers = event.plays.where('situation1 = ?', true)\n openersLeft = openers.where('hash_mark = ?', 'Left')\n openersRight = openers.where('hash_mark = ?', 'Right')\n\n #Openers Left Hash\n unless openersLeft[0].nil? \n openl1 = openersLeft[0].fullname \n end\n unless openersLeft[1].nil? \n openl2 = openersLeft[1].fullname \n end\n unless openersLeft[2].nil? \n openl3 = openersLeft[2].fullname \n end\n unless openersLeft[3].nil? \n openl4 = openersLeft[3].fullname \n end\n unless openersLeft[4].nil? \n openl5 = openersLeft[4].fullname \n end\n unless openersLeft[5].nil? \n openl6 = openersLeft[5].fullname \n end\n unless openersLeft[6].nil? \n openl7 = openersLeft[6].fullname \n end\n unless openersLeft[7].nil? \n openl8 = openersLeft[7].fullname \n end\n unless openersLeft[8].nil? \n openl9 = openersLeft[8].fullname \n end\n unless openersLeft[9].nil? \n openl10 = openersLeft[9].fullname \n end\n unless openersLeft[10].nil? \n openl11 = openersLeft[10].fullname \n end\n unless openersLeft[11].nil? \n openl12 = openersLeft[11].fullname \n end\n unless openersLeft[12].nil? \n openl13 = openersLeft[12].fullname \n end\n unless openersLeft[13].nil? \n openl14 = openersLeft[13].fullname \n end \n unless openersLeft[14].nil? \n openl15 = openersLeft[14].fullname \n end \n\n #Openers Right Hash\n unless openersRight[0].nil? \n openr1 = openersRight[0].fullname \n end\n unless openersRight[1].nil? \n openr2 = openersRight[1].fullname \n end\n unless openersRight[2].nil? \n openr3 = openersRight[2].fullname \n end\n unless openersRight[3].nil? \n openr4 = openersRight[3].fullname \n end\n unless openersRight[4].nil? \n openr5 = openersRight[4].fullname \n end\n unless openersRight[5].nil? \n openr6 = openersRight[5].fullname \n end\n unless openersRight[6].nil? \n openr7 = openersRight[6].fullname \n end\n unless openersRight[7].nil? \n openr8 = openersRight[7].fullname \n end\n unless openersRight[8].nil? \n openr9 = openersRight[8].fullname \n end\n unless openersRight[9].nil? \n openr10 = openersRight[9].fullname \n end\n unless openersRight[10].nil? \n openr11 = openersRight[10].fullname \n end\n unless openersRight[11].nil? \n openr12 = openersRight[11].fullname \n end\n unless openersRight[12].nil? \n openr13 = openersRight[12].fullname \n end\n unless openersRight[13].nil? \n openr14 = openersRight[13].fullname \n end \n unless openersRight[14].nil? \n openr15 = openersRight[14].fullname \n end \n #----------End Openers----------\n\n #----------1st/2nd & 10----------\n firstTens = event.plays.where('situation2 = ?', true)\n \n runFirstTens = firstTens.where('play_type = ?', 'Run')\n runFirstTensLeft = runFirstTens.where('hash_mark = ?', 'Left')\n runFirstTensRight = runFirstTens.where('hash_mark = ?', 'Right')\n \n passFirstTens = firstTens.where('play_type = ?', 'Pass')\n passFirstTensLeft = passFirstTens.where('hash_mark = ?', 'Left')\n passFirstTensRight = passFirstTens.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runFirstTensLeft[0].nil? \n rftl1 = runFirstTensLeft[0].fullname \n end\n unless runFirstTensLeft[1].nil? \n rftl2 = runFirstTensLeft[1].fullname \n end\n unless runFirstTensLeft[2].nil? \n rftl3 = runFirstTensLeft[2].fullname \n end\n unless runFirstTensLeft[3].nil? \n rftl4 = runFirstTensLeft[3].fullname \n end\n unless runFirstTensLeft[4].nil? \n rftl5 = runFirstTensLeft[4].fullname \n end\n unless runFirstTensLeft[5].nil? \n rftl6 = runFirstTensLeft[5].fullname \n end\n unless runFirstTensLeft[6].nil? \n rftl7 = runFirstTensLeft[6].fullname \n end\n unless runFirstTensLeft[7].nil? \n rftl8 = runFirstTensLeft[7].fullname \n end\n unless runFirstTensLeft[8].nil? \n rftl9 = runFirstTensLeft[8].fullname \n end\n unless runFirstTensLeft[9].nil? \n rftl10 = runFirstTensLeft[9].fullname \n end\n unless runFirstTensLeft[10].nil? \n rftl11 = runFirstTensLeft[10].fullname \n end\n unless runFirstTensLeft[11].nil? \n rftl12 = runFirstTensLeft[11].fullname \n end\n unless runFirstTensLeft[12].nil? \n rftl13 = runFirstTensLeft[12].fullname \n end\n unless runFirstTensLeft[13].nil? \n rftl14 = runFirstTensLeft[13].fullname \n end \n unless runFirstTensLeft[14].nil? \n rftl15 = runFirstTensLeft[14].fullname \n end \n\n #Run Right Hash\n unless runFirstTensRight[0].nil? \n rftr1 = runFirstTensRight[0].fullname \n end\n unless runFirstTensRight[1].nil? \n rftr2 = runFirstTensRight[1].fullname \n end\n unless runFirstTensRight[2].nil? \n rftr3 = runFirstTensRight[2].fullname \n end\n unless runFirstTensRight[3].nil? \n rftr4 = runFirstTensRight[3].fullname \n end\n unless runFirstTensRight[4].nil? \n rftr5 = runFirstTensRight[4].fullname \n end\n unless runFirstTensRight[5].nil? \n rftr6 = runFirstTensRight[5].fullname \n end\n unless runFirstTensRight[6].nil? \n rftr7 = runFirstTensRight[6].fullname \n end\n unless runFirstTensRight[7].nil? \n rftr8 = runFirstTensRight[7].fullname \n end\n unless runFirstTensRight[8].nil? \n rftr9 = runFirstTensRight[8].fullname \n end\n unless runFirstTensRight[9].nil? \n rftr10 = runFirstTensRight[9].fullname \n end\n unless runFirstTensRight[10].nil? \n rftr11 = runFirstTensRight[10].fullname \n end\n unless runFirstTensRight[11].nil? \n rftr12 = runFirstTensRight[11].fullname \n end\n unless runFirstTensRight[12].nil? \n rftr13 = runFirstTensRight[12].fullname \n end\n unless runFirstTensRight[13].nil? \n rftr14 = runFirstTensRight[13].fullname \n end\n unless runFirstTensRight[14].nil? \n rftr15 = runFirstTensRight[14].fullname \n end \n\n #Pass Left Hash\n unless passFirstTensLeft[0].nil? \n pftl1 = passFirstTensLeft[0].fullname \n end\n unless passFirstTensLeft[1].nil? \n pftl2 = passFirstTensLeft[1].fullname \n end\n unless passFirstTensLeft[2].nil? \n pftl3 = passFirstTensLeft[2].fullname \n end\n unless passFirstTensLeft[3].nil? \n pftl4 = passFirstTensLeft[3].fullname \n end\n unless passFirstTensLeft[4].nil? \n pftl5 = passFirstTensLeft[4].fullname \n end\n unless passFirstTensLeft[5].nil? \n pftl6 = passFirstTensLeft[5].fullname \n end\n unless passFirstTensLeft[6].nil? \n pftl7 = passFirstTensLeft[6].fullname \n end\n unless passFirstTensLeft[7].nil? \n pftl8 = passFirstTensLeft[7].fullname \n end\n unless passFirstTensLeft[8].nil? \n pftl9 = passFirstTensLeft[8].fullname \n end\n unless passFirstTensLeft[9].nil? \n pftl10 = passFirstTensLeft[9].fullname \n end\n unless passFirstTensLeft[10].nil? \n pftl11 = passFirstTensLeft[10].fullname \n end\n unless passFirstTensLeft[11].nil? \n pftl12 = passFirstTensLeft[11].fullname \n end\n unless passFirstTensLeft[12].nil? \n pftl13 = passFirstTensLeft[12].fullname \n end\n unless passFirstTensLeft[13].nil? \n pftl14 = passFirstTensLeft[13].fullname \n end \n unless passFirstTensLeft[14].nil? \n pftl15 = passFirstTensLeft[14].fullname \n end \n\n #Pass Right Hash\n unless passFirstTensRight[0].nil? \n pftr1 = passFirstTensRight[0].fullname \n end\n unless passFirstTensRight[1].nil? \n pftr2 = passFirstTensRight[1].fullname \n end\n unless passFirstTensRight[2].nil? \n pftr3 = passFirstTensRight[2].fullname \n end\n unless passFirstTensRight[3].nil? \n pftr4 = passFirstTensRight[3].fullname \n end\n unless passFirstTensRight[4].nil? \n pftr5 = passFirstTensRight[4].fullname \n end\n unless passFirstTensRight[5].nil? \n pftr6 = passFirstTensRight[5].fullname \n end\n unless passFirstTensRight[6].nil? \n pftr7 = passFirstTensRight[6].fullname \n end \n unless passFirstTensRight[7].nil? \n pftr8 = passFirstTensRight[7].fullname \n end\n unless passFirstTensRight[8].nil? \n pftr9 = passFirstTensRight[8].fullname \n end \n unless passFirstTensRight[9].nil? \n pftr10 = passFirstTensRight[9].fullname \n end\n unless passFirstTensRight[10].nil? \n pftr11 = passFirstTensRight[10].fullname \n end\n unless passFirstTensRight[11].nil? \n pftr12 = passFirstTensRight[11].fullname \n end\n unless passFirstTensRight[12].nil? \n pftr13 = passFirstTensRight[12].fullname \n end\n unless passFirstTensRight[13].nil? \n pftr14 = passFirstTensRight[13].fullname \n end\n unless passFirstTensRight[14].nil? \n pftr15 = passFirstTensRight[14].fullname \n end\n\n\n #Number of user's run plays in situation 2\n num_ftr = self.user.s_name2_num_run\n\n #Left Hash\n # ftl_s0 \n if num_ftr > 0\n ftl_s0 = self.user.s_name2 + ' - Run'\n else\n ftl_s0 = self.user.s_name2 + ' - Pass'\n end\n\n #ftl_s1 \n if num_ftr > 0\n ftl_s1 = rftl1\n else\n ftl_s1 = pftl1\n end\n\n #ftl_s2\n if num_ftr == 0\n ftl_s2 = pftl2\n elsif num_ftr == 1\n ftl_s2 = self.user.s_name2 + ' - Pass'\n else num_ftr > 1\n ftl_s2 = rftl2\n end\n\n #ftl_s3\n case num_ftr\n when 0 then ftl_s3 = pftl3 \n when 1 then ftl_s3 = pftl1\n when 2 then ftl_s3 = self.user.s_name2 + ' - Pass'\n when 3..100 then ftl_s3 = rftl3\n end\n\n #ftl_s4\n case num_ftr\n when 0 then ftl_s4 = pftl4 \n when 1 then ftl_s4 = pftl2\n when 2 then ftl_s4 = pftl1\n when 3 then ftl_s4 = self.user.s_name2 + ' - Pass'\n when 4..100 then ftl_s4 = rftl4\n end\n\n #ftl_s5\n case num_ftr\n when 0 then ftl_s5 = pftl5 \n when 1 then ftl_s5 = pftl3\n when 2 then ftl_s5 = pftl2\n when 3 then ftl_s5 = pftl1\n when 4 then ftl_s5 = self.user.s_name2 + ' - Pass'\n when 5..100 then ftl_s5 = rftl5\n end\n\n #ftl_s6\n case num_ftr\n when 0 then ftl_s6 = pftl6 \n when 1 then ftl_s6 = pftl4\n when 2 then ftl_s6 = pftl3\n when 3 then ftl_s6 = pftl2\n when 4 then ftl_s6 = pftl1\n when 5 then ftl_s6 = self.user.s_name2 + ' - Pass'\n when 6..100 then ftl_s6 = rftl6\n end\n\n #ftl_s7\n case num_ftr\n when 0 then ftl_s7 = pftl7 \n when 1 then ftl_s7 = pftl5\n when 2 then ftl_s7 = pftl4\n when 3 then ftl_s7 = pftl3\n when 4 then ftl_s7 = pftl2\n when 5 then ftl_s7 = pftl1\n when 6 then ftl_s7 = self.user.s_name2 + ' - Pass'\n when 7..100 then ftl_s7 = rftl7\n end\n\n #ftl_s8\n case num_ftr\n when 0 then ftl_s8 = pftl8 \n when 1 then ftl_s8 = pftl6\n when 2 then ftl_s8 = pftl5\n when 3 then ftl_s8 = pftl4\n when 4 then ftl_s8 = pftl3\n when 5 then ftl_s8 = pftl2\n when 6 then ftl_s8 = pftl1\n when 7 then ftl_s8 = self.user.s_name2 + ' - Pass'\n when 8..100 then ftl_s8 = rftl8\n end\n\n #ftl_s9\n case num_ftr\n when 0 then ftl_s9 = pftl9 \n when 1 then ftl_s9 = pftl7\n when 2 then ftl_s9 = pftl6\n when 3 then ftl_s9 = pftl5\n when 4 then ftl_s9 = pftl4\n when 5 then ftl_s9 = pftl3\n when 6 then ftl_s9 = pftl2\n when 7 then ftl_s9 = pftl1\n when 8 then ftl_s9 = self.user.s_name2 + ' - Pass'\n when 9..100 then ftl_s9 = rftl9\n end\n\n #ftl_s10\n case num_ftr\n when 0 then ftl_s10 = pftl10 \n when 1 then ftl_s10 = pftl8\n when 2 then ftl_s10 = pftl7\n when 3 then ftl_s10 = pftl6\n when 4 then ftl_s10 = pftl5\n when 5 then ftl_s10 = pftl4\n when 6 then ftl_s10 = pftl3\n when 7 then ftl_s10 = pftl2\n when 8 then ftl_s10 = pftl1\n when 9 then ftl_s10 = self.user.s_name2 + ' - Pass'\n when 10..100 then ftl_s10 = rftl10\n end\n\n #ftl_s11\n case num_ftr\n when 0 then ftl_s11 = pftl11 \n when 1 then ftl_s11 = pftl9\n when 2 then ftl_s11 = pftl8\n when 3 then ftl_s11 = pftl7\n when 4 then ftl_s11 = pftl6\n when 5 then ftl_s11 = pftl5\n when 6 then ftl_s11 = pftl4\n when 7 then ftl_s11 = pftl3\n when 8 then ftl_s11 = pftl2\n when 9 then ftl_s11 = pftl1\n when 10 then ftl_s11 = self.user.s_name2 + ' - Pass'\n when 11..100 then ftl_s11 = rftl11\n end\n\n #ftl_s12\n case num_ftr\n when 0 then ftl_s12 = pftl12 \n when 1 then ftl_s12 = pftl10\n when 2 then ftl_s12 = pftl9\n when 3 then ftl_s12 = pftl8\n when 4 then ftl_s12 = pftl7\n when 5 then ftl_s12 = pftl6\n when 6 then ftl_s12 = pftl5\n when 7 then ftl_s12 = pftl4\n when 8 then ftl_s12 = pftl3\n when 9 then ftl_s12 = pftl2\n when 10 then ftl_s12 = pftl1\n when 11 then ftl_s12 = self.user.s_name2 + ' - Pass'\n when 12..100 then ftl_s12 = rftl12\n end\n\n #ftl_s13\n case num_ftr\n when 0 then ftl_s13 = pftl13 \n when 1 then ftl_s13 = pftl11\n when 2 then ftl_s13 = pftl10\n when 3 then ftl_s13 = pftl9\n when 4 then ftl_s13 = pftl8\n when 5 then ftl_s13 = pftl7\n when 6 then ftl_s13 = pftl6\n when 7 then ftl_s13 = pftl5\n when 8 then ftl_s13 = pftl4\n when 9 then ftl_s13 = pftl3\n when 10 then ftl_s13 = pftl2\n when 11 then ftl_s13 = pftl1\n when 12 then ftl_s13 = self.user.s_name2 + ' - Pass'\n when 13..100 then ftl_s13 = rftl13\n end\n\n #ftl_s14\n case num_ftr\n when 0 then ftl_s14 = pftl14 \n when 1 then ftl_s14 = pftl12\n when 2 then ftl_s14 = pftl11\n when 3 then ftl_s14 = pftl10\n when 4 then ftl_s14 = pftl9\n when 5 then ftl_s14 = pftl8\n when 6 then ftl_s14 = pftl7\n when 7 then ftl_s14 = pftl6\n when 8 then ftl_s14 = pftl5\n when 9 then ftl_s14 = pftl4\n when 10 then ftl_s14 = pftl3\n when 11 then ftl_s14 = pftl2\n when 12 then ftl_s14 = pftl1 \n when 13 then ftl_s14 = self.user.s_name2 + ' - Pass'\n when 14..100 then ftl_s14 = rftl14\n end\n\n #ftl_s15\n case num_ftr\n when 0 then ftl_s15 = pftl15 \n when 1 then ftl_s15 = pftl13\n when 2 then ftl_s15 = pftl12\n when 3 then ftl_s15 = pftl11\n when 4 then ftl_s15 = pftl10\n when 5 then ftl_s15 = pftl9\n when 6 then ftl_s15 = pftl8\n when 7 then ftl_s15 = pftl7\n when 8 then ftl_s15 = pftl6\n when 9 then ftl_s15 = pftl5\n when 10 then ftl_s15 = pftl4\n when 11 then ftl_s15 = pftl3\n when 12 then ftl_s15 = pftl2\n when 13 then ftl_s15 = pftl1 \n when 14..100 then ftl_s15 = rftl15\n end \n\n\n #Right Hash\n # ftr_s0 would always be blank\n\n #ftr_s1 \n if num_ftr > 0\n ftr_s1 = rftr1\n else\n ftr_s1 = pftr1\n end\n\n #ftr_s2\n if num_ftr == 0\n ftr_s2 = pftr2\n elsif num_ftr == 1\n ftr_s2 = ''\n else num_ftr > 1\n ftr_s2 = rftr2\n end\n\n #ftr_s3\n case num_ftr\n when 0 then ftr_s3 = pftr3 \n when 1 then ftr_s3 = pftr1\n when 2 then ftr_s3 = ''\n when 3..100 then ftr_s3 = rftr3\n end\n\n #ftr_s4\n case num_ftr\n when 0 then ftr_s4 = pftr4 \n when 1 then ftr_s4 = pftr2\n when 2 then ftr_s4 = pftr1\n when 3 then ''\n when 4..100 then ftr_s4 = rftr4\n end\n\n #ftr_s5\n case num_ftr\n when 0 then ftr_s5 = pftr5 \n when 1 then ftr_s5 = pftr3\n when 2 then ftr_s5 = pftr2\n when 3 then ftr_s5 = pftr1\n when 4 then ftr_s5 = ''\n when 5..100 then ftr_s5 = rftr5\n end\n\n #ftr_s6\n case num_ftr\n when 0 then ftr_s6 = pftr6 \n when 1 then ftr_s6 = pftr4\n when 2 then ftr_s6 = pftr3\n when 3 then ftr_s6 = pftr2\n when 4 then ftr_s6 = pftr1\n when 5 then ftr_s6 = ''\n when 6..100 then ftr_s6 = rftr6\n end\n\n #ftr_s7\n case num_ftr\n when 0 then ftr_s7 = pftr7 \n when 1 then ftr_s7 = pftr5\n when 2 then ftr_s7 = pftr4\n when 3 then ftr_s7 = pftr3\n when 4 then ftr_s7 = pftr2\n when 5 then ftr_s7 = pftr1\n when 6 then ftr_s7 = ''\n when 7..100 then ftr_s7 = rftr7\n end\n\n #ftr_s8\n case num_ftr\n when 0 then ftr_s8 = pftr8 \n when 1 then ftr_s8 = pftr6\n when 2 then ftr_s8 = pftr5\n when 3 then ftr_s8 = pftr4\n when 4 then ftr_s8 = pftr3\n when 5 then ftr_s8 = pftr2\n when 6 then ftr_s8 = pftr1\n when 7 then ftr_s8 = ''\n when 8..100 then ftr_s8 = rftr8\n end\n\n #ftr_s9\n case num_ftr\n when 0 then ftr_s9 = pftr9 \n when 1 then ftr_s9 = pftr7\n when 2 then ftr_s9 = pftr6\n when 3 then ftr_s9 = pftr5\n when 4 then ftr_s9 = pftr4\n when 5 then ftr_s9 = pftr3\n when 6 then ftr_s9 = pftr2\n when 7 then ftr_s9 = pftr1\n when 8 then ftr_s9 = ''\n when 9..100 then ftr_s9 = rftr9\n end\n\n #ftr_s10\n case num_ftr\n when 0 then ftr_s10 = pftr10 \n when 1 then ftr_s10 = pftr8\n when 2 then ftr_s10 = pftr7\n when 3 then ftr_s10 = pftr6\n when 4 then ftr_s10 = pftr5\n when 5 then ftr_s10 = pftr4\n when 6 then ftr_s10 = pftr3\n when 7 then ftr_s10 = pftr2\n when 8 then ftr_s10 = pftr1\n when 9 then ftr_s10 = ''\n when 10..100 then ftr_s10 = rftr10\n end\n\n #ftr_s11\n case num_ftr\n when 0 then ftr_s11 = pftr11 \n when 1 then ftr_s11 = pftr9\n when 2 then ftr_s11 = pftr8\n when 3 then ftr_s11 = pftr7\n when 4 then ftr_s11 = pftr6\n when 5 then ftr_s11 = pftr5\n when 6 then ftr_s11 = pftr4\n when 7 then ftr_s11 = pftr3\n when 8 then ftr_s11 = pftr2\n when 9 then ftr_s11 = pftr1\n when 10 then ftr_s11 = ''\n when 11..100 then ftr_s11 = rftr11\n end\n\n #ftr_s12\n case num_ftr\n when 0 then ftr_s12 = pftr12 \n when 1 then ftr_s12 = pftr10\n when 2 then ftr_s12 = pftr9\n when 3 then ftr_s12 = pftr8\n when 4 then ftr_s12 = pftr7\n when 5 then ftr_s12 = pftr6\n when 6 then ftr_s12 = pftr5\n when 7 then ftr_s12 = pftr4\n when 8 then ftr_s12 = pftr3\n when 9 then ftr_s12 = pftr2\n when 10 then ftr_s12 = pftr1\n when 11 then ftr_s12 = ''\n when 12..100 then ftr_s12 = rftr12\n end\n\n #ftr_s13\n case num_ftr\n when 0 then ftr_s13 = pftr13 \n when 1 then ftr_s13 = pftr11\n when 2 then ftr_s13 = pftr10\n when 3 then ftr_s13 = pftr9\n when 4 then ftr_s13 = pftr8\n when 5 then ftr_s13 = pftr7\n when 6 then ftr_s13 = pftr6\n when 7 then ftr_s13 = pftr5\n when 8 then ftr_s13 = pftr4\n when 9 then ftr_s13 = pftr3\n when 10 then ftr_s13 = pftr2\n when 11 then ftr_s13 = pftr1\n when 12 then ftr_s13 = ''\n when 13..100 then ftr_s13 = rftr13\n end\n\n #ftr_s14\n case num_ftr\n when 0 then ftr_s14 = pftr14 \n when 1 then ftr_s14 = pftr12\n when 2 then ftr_s14 = pftr11\n when 3 then ftr_s14 = pftr10\n when 4 then ftr_s14 = pftr9\n when 5 then ftr_s14 = pftr8\n when 6 then ftr_s14 = pftr7\n when 7 then ftr_s14 = pftr6\n when 8 then ftr_s14 = pftr5\n when 9 then ftr_s14 = pftr4\n when 10 then ftr_s14 = pftr3\n when 11 then ftr_s14 = pftr2\n when 12 then ftr_s14 = pftr1 \n when 13 then ftr_s14 = ''\n when 14..100 then ftr_s14 = rftr14\n end\n\n #ftr_s15\n case num_ftr\n when 0 then ftr_s15 = pftr15 \n when 1 then ftr_s15 = pftr13\n when 2 then ftr_s15 = pftr12\n when 3 then ftr_s15 = pftr11\n when 4 then ftr_s15 = pftr10\n when 5 then ftr_s15 = pftr9\n when 6 then ftr_s15 = pftr8\n when 7 then ftr_s15 = pftr7\n when 8 then ftr_s15 = pftr6\n when 9 then ftr_s15 = pftr5\n when 10 then ftr_s15 = pftr4\n when 11 then ftr_s15 = pftr3\n when 12 then ftr_s15 = pftr2\n when 13 then ftr_s15 = pftr1 \n when 14..100 then ftr_s15 = rftr15\n end\n\n #----------End 1st/2nd & 10----------\n\n #----------2nd & Long----------\n secondLongs = event.plays.where('situation3 = ?', true)\n \n runSecondLongs = secondLongs.where('play_type = ?', 'Run')\n runSecondLongsLeft = runSecondLongs.where('hash_mark = ?', 'Left')\n runSecondLongsRight = runSecondLongs.where('hash_mark = ?', 'Right')\n \n passSecondLongs = secondLongs.where('play_type = ?', 'Pass')\n passSecondLongsLeft = passSecondLongs.where('hash_mark = ?', 'Left')\n passSecondLongsRight = passSecondLongs.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runSecondLongsLeft[0].nil? \n rsll1 = runSecondLongsLeft[0].fullname \n end\n unless runSecondLongsLeft[1].nil? \n rsll2 = runSecondLongsLeft[1].fullname \n end\n unless runSecondLongsLeft[2].nil? \n rsll3 = runSecondLongsLeft[2].fullname \n end\n unless runSecondLongsLeft[3].nil? \n rsll4 = runSecondLongsLeft[3].fullname \n end\n unless runSecondLongsLeft[4].nil? \n rsll5 = runSecondLongsLeft[4].fullname \n end\n unless runSecondLongsLeft[5].nil? \n rsll6 = runSecondLongsLeft[5].fullname \n end\n unless runSecondLongsLeft[6].nil? \n rsll7 = runSecondLongsLeft[6].fullname \n end\n unless runSecondLongsLeft[7].nil? \n rsll8 = runSecondLongsLeft[7].fullname \n end\n unless runSecondLongsLeft[8].nil? \n rsll9 = runSecondLongsLeft[8].fullname \n end\n unless runSecondLongsLeft[9].nil? \n rsll10 = runSecondLongsLeft[9].fullname \n end\n unless runSecondLongsLeft[10].nil? \n rsll11 = runSecondLongsLeft[10].fullname \n end\n unless runSecondLongsLeft[11].nil? \n rsll12 = runSecondLongsLeft[11].fullname \n end\n\n #Run Right Hash\n unless runSecondLongsRight[0].nil? \n rslr1 = runSecondLongsRight[0].fullname \n end\n unless runSecondLongsRight[1].nil? \n rslr2 = runSecondLongsRight[1].fullname \n end\n unless runSecondLongsRight[2].nil? \n rslr3 = runSecondLongsRight[2].fullname \n end\n unless runSecondLongsRight[3].nil? \n rslr4 = runSecondLongsRight[3].fullname \n end\n unless runSecondLongsRight[4].nil? \n rslr5 = runSecondLongsRight[4].fullname \n end\n unless runSecondLongsRight[5].nil? \n rslr6 = runSecondLongsRight[5].fullname \n end\n unless runSecondLongsRight[6].nil? \n rslr7 = runSecondLongsRight[6].fullname \n end\n unless runSecondLongsRight[7].nil? \n rslr8 = runSecondLongsRight[7].fullname \n end\n unless runSecondLongsRight[8].nil? \n rslr9 = runSecondLongsRight[8].fullname \n end\n unless runSecondLongsRight[9].nil? \n rslr10 = runSecondLongsRight[9].fullname \n end \n unless runSecondLongsRight[10].nil? \n rslr11 = runSecondLongsRight[10].fullname \n end\n unless runSecondLongsRight[11].nil? \n rslr12 = runSecondLongsRight[11].fullname \n end \n\n #Pass Left Hash\n unless passSecondLongsLeft[0].nil? \n psll1 = passSecondLongsLeft[0].fullname \n end\n unless passSecondLongsLeft[1].nil? \n psll2 = passSecondLongsLeft[1].fullname \n end\n unless passSecondLongsLeft[2].nil? \n psll3 = passSecondLongsLeft[2].fullname \n end\n unless passSecondLongsLeft[3].nil? \n psll4 = passSecondLongsLeft[3].fullname \n end\n unless passSecondLongsLeft[4].nil? \n psll5 = passSecondLongsLeft[4].fullname \n end \n unless passSecondLongsLeft[5].nil? \n psll6 = passSecondLongsLeft[5].fullname \n end\n unless passSecondLongsLeft[6].nil? \n psll7 = passSecondLongsLeft[6].fullname \n end\n unless passSecondLongsLeft[7].nil? \n psll8 = passSecondLongsLeft[7].fullname \n end\n unless passSecondLongsLeft[8].nil? \n psll9 = passSecondLongsLeft[8].fullname \n end\n unless passSecondLongsLeft[9].nil? \n psll10 = passSecondLongsLeft[9].fullname \n end\n unless passSecondLongsLeft[10].nil? \n psll11 = passSecondLongsLeft[10].fullname \n end \n unless passSecondLongsLeft[11].nil? \n psll12 = passSecondLongsLeft[11].fullname \n end \n\n #Pass Right Hash\n unless passSecondLongsRight[0].nil? \n pslr1 = passSecondLongsRight[0].fullname \n end\n unless passSecondLongsRight[1].nil? \n pslr2 = passSecondLongsRight[1].fullname \n end\n unless passSecondLongsRight[2].nil? \n pslr3 = passSecondLongsRight[2].fullname \n end\n unless passSecondLongsRight[3].nil? \n pslr4 = passSecondLongsRight[3].fullname \n end\n unless passSecondLongsRight[4].nil? \n pslr5 = passSecondLongsRight[4].fullname \n end \n unless passSecondLongsRight[5].nil? \n pslr6 = passSecondLongsRight[5].fullname \n end \n unless passSecondLongsRight[6].nil? \n pslr7 = passSecondLongsRight[6].fullname \n end\n unless passSecondLongsRight[7].nil? \n pslr8 = passSecondLongsRight[7].fullname \n end\n unless passSecondLongsRight[8].nil? \n pslr9 = passSecondLongsRight[8].fullname \n end\n unless passSecondLongsRight[9].nil? \n pslr10 = passSecondLongsRight[9].fullname \n end\n unless passSecondLongsRight[10].nil? \n pslr11 = passSecondLongsRight[10].fullname \n end \n unless passSecondLongsRight[11].nil? \n pslr12 = passSecondLongsRight[11].fullname \n end \n\n\n #Number of user's run plays in situation 3\n num_slr = self.user.s_name3_num_run\n\n #Left Hash\n # sll_s0 \n if num_slr > 0\n sll_s0 = self.user.s_name3 + ' - Run'\n else\n sll_s0 = self.user.s_name3 + ' - Pass'\n end\n\n #sll_s1 \n if num_slr > 0\n sll_s1 = rsll1\n else\n sll_s1 = psll1\n end\n\n #sll_s2\n if num_slr == 0\n sll_s2 = psll2\n elsif num_slr == 1\n sll_s2 = self.user.s_name3 + ' - Pass'\n else num_slr > 1\n sll_s2 = rsll2\n end\n\n #sll_s3\n case num_slr\n when 0 then sll_s3 = psll3 \n when 1 then sll_s3 = psll1\n when 2 then sll_s3 = self.user.s_name3 + ' - Pass'\n when 3..100 then sll_s3 = rsll3\n end\n\n #sll_s4\n case num_slr\n when 0 then sll_s4 = psll4 \n when 1 then sll_s4 = psll2\n when 2 then sll_s4 = psll1\n when 3 then sll_s4 = self.user.s_name3 + ' - Pass'\n when 4..100 then sll_s4 = rsll4\n end\n\n #sll_s5\n case num_slr\n when 0 then sll_s5 = psll5 \n when 1 then sll_s5 = psll3\n when 2 then sll_s5 = psll2\n when 3 then sll_s5 = psll1\n when 4 then sll_s5 = self.user.s_name3 + ' - Pass'\n when 5..100 then sll_s5 = rsll5\n end\n\n #sll_s6\n case num_slr\n when 0 then sll_s6 = psll6 \n when 1 then sll_s6 = psll4\n when 2 then sll_s6 = psll3\n when 3 then sll_s6 = psll2\n when 4 then sll_s6 = psll1\n when 5 then sll_s6 = self.user.s_name3 + ' - Pass'\n when 6..100 then sll_s6 = rsll6\n end\n\n #sll_s7\n case num_slr\n when 0 then sll_s7 = psll7 \n when 1 then sll_s7 = psll5\n when 2 then sll_s7 = psll4\n when 3 then sll_s7 = psll3\n when 4 then sll_s7 = psll2\n when 5 then sll_s7 = psll1\n when 6 then sll_s7 = self.user.s_name3 + ' - Pass'\n when 7..100 then sll_s7 = rsll7\n end\n\n #sll_s8\n case num_slr\n when 0 then sll_s8 = psll8 \n when 1 then sll_s8 = psll6\n when 2 then sll_s8 = psll5\n when 3 then sll_s8 = psll4\n when 4 then sll_s8 = psll3\n when 5 then sll_s8 = psll2\n when 6 then sll_s8 = psll1\n when 7 then sll_s8 = self.user.s_name3 + ' - Pass'\n when 8..100 then sll_s8 = rsll8\n end\n\n #sll_s9\n case num_slr\n when 0 then sll_s9 = psll9 \n when 1 then sll_s9 = psll7\n when 2 then sll_s9 = psll6\n when 3 then sll_s9 = psll5\n when 4 then sll_s9 = psll4\n when 5 then sll_s9 = psll3\n when 6 then sll_s9 = psll2\n when 7 then sll_s9 = psll1\n when 8 then sll_s9 = self.user.s_name3 + ' - Pass'\n when 9..100 then sll_s9 = rsll9\n end\n\n #sll_s10\n case num_slr\n when 0 then sll_s10 = psll10 \n when 1 then sll_s10 = psll8\n when 2 then sll_s10 = psll7\n when 3 then sll_s10 = psll6\n when 4 then sll_s10 = psll5\n when 5 then sll_s10 = psll4\n when 6 then sll_s10 = psll3\n when 7 then sll_s10 = psll2\n when 8 then sll_s10 = psll1\n when 9 then sll_s10 = self.user.s_name3 + ' - Pass'\n when 10..100 then sll_s10 = rsll10\n end\n\n #sll_s11\n case num_slr\n when 0 then sll_s11 = psll11 \n when 1 then sll_s11 = psll9\n when 2 then sll_s11 = psll8\n when 3 then sll_s11 = psll7\n when 4 then sll_s11 = psll6\n when 5 then sll_s11 = psll5\n when 6 then sll_s11 = psll4\n when 7 then sll_s11 = psll3\n when 8 then sll_s11 = psll2\n when 9 then sll_s11 = psll1\n when 10 then sll_s11 = self.user.s_name3 + ' - Pass'\n when 11..100 then sll_s11 = rsll11\n end\n\n #sll_s12\n case num_slr\n when 0 then sll_s12 = psll12 \n when 1 then sll_s12 = psll10\n when 2 then sll_s12 = psll9\n when 3 then sll_s12 = psll8\n when 4 then sll_s12 = psll7\n when 5 then sll_s12 = psll6\n when 6 then sll_s12 = psll5\n when 7 then sll_s12 = psll4\n when 8 then sll_s12 = psll3\n when 9 then sll_s12 = psll2\n when 10 then sll_s12 = psll1\n when 11..100 then sll_s12 = rsll12\n end\n\n \n #Right Hash\n # slr_s0 would always be blank\n\n #slr_s1 \n if num_slr > 0\n slr_s1 = rslr1\n else\n slr_s1 = pslr1\n end\n\n #slr_s2\n if num_slr == 0\n slr_s2 = pslr2\n elsif num_slr == 1\n slr_s2 = ''\n else num_slr > 1\n slr_s2 = rslr2\n end\n\n #slr_s3\n case num_slr\n when 0 then slr_s3 = pslr3 \n when 1 then slr_s3 = pslr1\n when 2 then slr_s3 = ''\n when 3..100 then slr_s3 = rslr3\n end\n\n #slr_s4\n case num_slr\n when 0 then slr_s4 = pslr4 \n when 1 then slr_s4 = pslr2\n when 2 then slr_s4 = pslr1\n when 3 then ''\n when 4..100 then slr_s4 = rslr4\n end\n\n #slr_s5\n case num_slr\n when 0 then slr_s5 = pslr5 \n when 1 then slr_s5 = pslr3\n when 2 then slr_s5 = pslr2\n when 3 then slr_s5 = pslr1\n when 4 then slr_s5 = ''\n when 5..100 then slr_s5 = rslr5\n end\n\n #slr_s6\n case num_slr\n when 0 then slr_s6 = pslr6 \n when 1 then slr_s6 = pslr4\n when 2 then slr_s6 = pslr3\n when 3 then slr_s6 = pslr2\n when 4 then slr_s6 = pslr1\n when 5 then slr_s6 = ''\n when 6..100 then slr_s6 = rslr6\n end\n\n #slr_s7\n case num_slr\n when 0 then slr_s7 = pslr7 \n when 1 then slr_s7 = pslr5\n when 2 then slr_s7 = pslr4\n when 3 then slr_s7 = pslr3\n when 4 then slr_s7 = pslr2\n when 5 then slr_s7 = pslr1\n when 6 then slr_s7 = ''\n when 7..100 then slr_s7 = rslr7\n end\n\n #slr_s8\n case num_slr\n when 0 then slr_s8 = pslr8 \n when 1 then slr_s8 = pslr6\n when 2 then slr_s8 = pslr5\n when 3 then slr_s8 = pslr4\n when 4 then slr_s8 = pslr3\n when 5 then slr_s8 = pslr2\n when 6 then slr_s8 = pslr1\n when 7 then slr_s8 = ''\n when 8..100 then slr_s8 = rslr8\n end\n\n #slr_s9\n case num_slr\n when 0 then slr_s9 = pslr9 \n when 1 then slr_s9 = pslr7\n when 2 then slr_s9 = pslr6\n when 3 then slr_s9 = pslr5\n when 4 then slr_s9 = pslr4\n when 5 then slr_s9 = pslr3\n when 6 then slr_s9 = pslr2\n when 7 then slr_s9 = pslr1\n when 8 then slr_s9 = ''\n when 9..100 then slr_s9 = rslr9\n end\n\n #slr_s10\n case num_slr\n when 0 then slr_s10 = pslr10 \n when 1 then slr_s10 = pslr8\n when 2 then slr_s10 = pslr7\n when 3 then slr_s10 = pslr6\n when 4 then slr_s10 = pslr5\n when 5 then slr_s10 = pslr4\n when 6 then slr_s10 = pslr3\n when 7 then slr_s10 = pslr2\n when 8 then slr_s10 = pslr1\n when 9 then slr_s10 = ''\n when 10..100 then slr_s10 = rslr10\n end\n\n #slr_s11\n case num_slr\n when 0 then slr_s11 = pslr11 \n when 1 then slr_s11 = pslr9\n when 2 then slr_s11 = pslr8\n when 3 then slr_s11 = pslr7\n when 4 then slr_s11 = pslr6\n when 5 then slr_s11 = pslr5\n when 6 then slr_s11 = pslr4\n when 7 then slr_s11 = pslr3\n when 8 then slr_s11 = pslr2\n when 9 then slr_s11 = pslr1\n when 10 then slr_s11 = ''\n when 11..100 then slr_s11 = rslr11\n end\n\n #slr_s12\n case num_slr\n when 0 then slr_s12 = pslr12 \n when 1 then slr_s12 = pslr10\n when 2 then slr_s12 = pslr9\n when 3 then slr_s12 = pslr8\n when 4 then slr_s12 = pslr7\n when 5 then slr_s12 = pslr6\n when 6 then slr_s12 = pslr5\n when 7 then slr_s12 = pslr4\n when 8 then slr_s12 = pslr3\n when 9 then slr_s12 = pslr2\n when 10 then slr_s12 = pslr1\n when 11..100 then slr_s12 = rslr12\n end\n\n #----------End 2nd & Long ----------\n\n #----------3rd & Long ----------\n thirdLongs = event.plays.where('situation6 = ?', true)\n \n runThirdLongs = thirdLongs.where('play_type = ?', 'Run')\n runThirdLongsLeft = runThirdLongs.where('hash_mark = ?', 'Left')\n runThirdLongsRight = runThirdLongs.where('hash_mark = ?', 'Right')\n \n passThirdLongs = thirdLongs.where('play_type = ?', 'Pass')\n passThirdLongsLeft = passThirdLongs.where('hash_mark = ?', 'Left')\n passThirdLongsRight = passThirdLongs.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runThirdLongsLeft[0].nil? \n rtll1 = runThirdLongsLeft[0].fullname \n end\n unless runThirdLongsLeft[1].nil? \n rtll2 = runThirdLongsLeft[1].fullname \n end\n unless runThirdLongsLeft[2].nil? \n rtll3 = runThirdLongsLeft[2].fullname \n end\n unless runThirdLongsLeft[3].nil? \n rtll4 = runThirdLongsLeft[3].fullname \n end\n unless runThirdLongsLeft[4].nil? \n rtll5 = runThirdLongsLeft[4].fullname \n end\n unless runThirdLongsLeft[5].nil? \n rtll6 = runThirdLongsLeft[5].fullname \n end\n unless runThirdLongsLeft[6].nil? \n rtll7 = runThirdLongsLeft[6].fullname \n end\n unless runThirdLongsLeft[7].nil? \n rtll8 = runThirdLongsLeft[7].fullname \n end\n unless runThirdLongsLeft[8].nil? \n rtll9 = runThirdLongsLeft[8].fullname \n end\n unless runThirdLongsLeft[9].nil? \n rtll10 = runThirdLongsLeft[9].fullname \n end\n unless runThirdLongsLeft[10].nil? \n rtll11 = runThirdLongsLeft[10].fullname \n end\n unless runThirdLongsLeft[11].nil? \n rtll12 = runThirdLongsLeft[11].fullname \n end\n\n #Run Right Hash\n unless runThirdLongsRight[0].nil? \n rtlr1 = runThirdLongsRight[0].fullname \n end\n unless runThirdLongsRight[1].nil? \n rtlr2 = runThirdLongsRight[1].fullname \n end\n unless runThirdLongsRight[2].nil? \n rtlr3 = runThirdLongsRight[2].fullname \n end\n unless runThirdLongsRight[3].nil? \n rtlr4 = runThirdLongsRight[3].fullname \n end\n unless runThirdLongsRight[4].nil? \n rtlr5 = runThirdLongsRight[4].fullname \n end\n unless runThirdLongsRight[5].nil? \n rtlr6 = runThirdLongsRight[5].fullname \n end\n unless runThirdLongsRight[6].nil? \n rtlr7 = runThirdLongsRight[6].fullname \n end\n unless runThirdLongsRight[7].nil? \n rtlr8 = runThirdLongsRight[7].fullname \n end\n unless runThirdLongsRight[8].nil? \n rtlr9 = runThirdLongsRight[8].fullname \n end\n unless runThirdLongsRight[9].nil? \n rtlr10 = runThirdLongsRight[9].fullname \n end\n unless runThirdLongsRight[10].nil? \n rtlr11 = runThirdLongsRight[10].fullname \n end\n unless runThirdLongsRight[11].nil? \n rtlr12 = runThirdLongsRight[11].fullname \n end\n\n #Pass Left Hash\n unless passThirdLongsLeft[0].nil? \n ptll1 = passThirdLongsLeft[0].fullname \n end\n unless passThirdLongsLeft[1].nil? \n ptll2 = passThirdLongsLeft[1].fullname \n end\n unless passThirdLongsLeft[2].nil? \n ptll3 = passThirdLongsLeft[2].fullname \n end\n unless passThirdLongsLeft[3].nil? \n ptll4 = passThirdLongsLeft[3].fullname \n end\n unless passThirdLongsLeft[4].nil? \n ptll5 = passThirdLongsLeft[4].fullname \n end\n unless passThirdLongsLeft[5].nil? \n ptll6 = passThirdLongsLeft[5].fullname \n end\n unless passThirdLongsLeft[6].nil? \n ptll7 = passThirdLongsLeft[6].fullname \n end\n unless passThirdLongsLeft[7].nil? \n ptll8 = passThirdLongsLeft[7].fullname \n end \n unless passThirdLongsLeft[8].nil? \n ptll9 = passThirdLongsLeft[8].fullname \n end\n unless passThirdLongsLeft[9].nil? \n ptll10 = passThirdLongsLeft[9].fullname \n end\n unless passThirdLongsLeft[10].nil? \n ptll11 = passThirdLongsLeft[10].fullname \n end\n unless passThirdLongsLeft[11].nil? \n ptll12 = passThirdLongsLeft[11].fullname \n end \n\n #Pass Right Hash\n unless passThirdLongsRight[0].nil? \n ptlr1 = passThirdLongsRight[0].fullname \n end\n unless passThirdLongsRight[1].nil? \n ptlr2 = passThirdLongsRight[1].fullname \n end\n unless passThirdLongsRight[2].nil? \n ptlr3 = passThirdLongsRight[2].fullname \n end\n unless passThirdLongsRight[3].nil? \n ptlr4 = passThirdLongsRight[3].fullname \n end\n unless passThirdLongsRight[4].nil? \n ptlr5 = passThirdLongsRight[4].fullname \n end\n unless passThirdLongsRight[5].nil? \n ptlr6 = passThirdLongsRight[5].fullname \n end\n unless passThirdLongsRight[6].nil? \n ptlr7 = passThirdLongsRight[6].fullname \n end\n unless passThirdLongsRight[7].nil? \n ptlr8 = passThirdLongsRight[7].fullname \n end \n unless passThirdLongsRight[8].nil? \n ptlr9 = passThirdLongsRight[8].fullname \n end\n unless passThirdLongsRight[9].nil? \n ptlr10 = passThirdLongsRight[9].fullname \n end\n unless passThirdLongsRight[10].nil? \n ptlr11 = passThirdLongsRight[10].fullname \n end\n unless passThirdLongsRight[11].nil? \n ptlr12 = passThirdLongsRight[11].fullname \n end \n\n #Number of user's run plays in situation 6\n num_thirdlg = self.user.s_name6_num_run\n\n #Left Hash\n # tll_s0 \n if num_thirdlg > 0\n tll_s0 = self.user.s_name6 + ' - Run'\n else\n tll_s0 = self.user.s_name6 + ' - Pass'\n end\n\n #tll_s1 \n if num_thirdlg > 0\n tll_s1 = rtll1\n else\n tll_s1 = ptll1\n end\n\n #tll_s2\n if num_thirdlg == 0\n tll_s2 = ptll2\n elsif num_thirdlg == 1\n tll_s2 = self.user.s_name6 + ' - Pass'\n else num_thirdlg > 1\n tll_s2 = rtll2\n end\n\n #tll_s3\n case num_thirdlg\n when 0 then tll_s3 = ptll3 \n when 1 then tll_s3 = ptll1\n when 2 then tll_s3 = self.user.s_name6 + ' - Pass'\n when 3..100 then tll_s3 = rtll3\n end\n\n #tll_s4\n case num_thirdlg\n when 0 then tll_s4 = ptll4 \n when 1 then tll_s4 = ptll2\n when 2 then tll_s4 = ptll1\n when 3 then tll_s4 = self.user.s_name6 + ' - Pass'\n when 4..100 then tll_s4 = rtll4\n end\n\n #tll_s5\n case num_thirdlg\n when 0 then tll_s5 = ptll5 \n when 1 then tll_s5 = ptll3\n when 2 then tll_s5 = ptll2\n when 3 then tll_s5 = ptll1\n when 4 then tll_s5 = self.user.s_name6 + ' - Pass'\n when 5..100 then tll_s5 = rtll5\n end\n\n #tll_s6\n case num_thirdlg\n when 0 then tll_s6 = ptll6 \n when 1 then tll_s6 = ptll4\n when 2 then tll_s6 = ptll3\n when 3 then tll_s6 = ptll2\n when 4 then tll_s6 = ptll1\n when 5 then tll_s6 = self.user.s_name6 + ' - Pass'\n when 6..100 then tll_s6 = rtll6\n end\n\n #tll_s7\n case num_thirdlg\n when 0 then tll_s7 = ptll7 \n when 1 then tll_s7 = ptll5\n when 2 then tll_s7 = ptll4\n when 3 then tll_s7 = ptll3\n when 4 then tll_s7 = ptll2\n when 5 then tll_s7 = ptll1\n when 6 then tll_s7 = self.user.s_name6 + ' - Pass'\n when 7..100 then tll_s7 = rtll7\n end\n\n #tll_s8\n case num_thirdlg\n when 0 then tll_s8 = ptll8 \n when 1 then tll_s8 = ptll6\n when 2 then tll_s8 = ptll5\n when 3 then tll_s8 = ptll4\n when 4 then tll_s8 = ptll3\n when 5 then tll_s8 = ptll2\n when 6 then tll_s8 = ptll1\n when 7 then tll_s8 = self.user.s_name6 + ' - Pass'\n when 8..100 then tll_s8 = rtll8\n end\n\n #tll_s9\n case num_thirdlg\n when 0 then tll_s9 = ptll9 \n when 1 then tll_s9 = ptll7\n when 2 then tll_s9 = ptll6\n when 3 then tll_s9 = ptll5\n when 4 then tll_s9 = ptll4\n when 5 then tll_s9 = ptll3\n when 6 then tll_s9 = ptll2\n when 7 then tll_s9 = ptll1\n when 8 then tll_s9 = self.user.s_name6 + ' - Pass'\n when 9..100 then tll_s9 = rtll9\n end\n\n #tll_s10\n case num_thirdlg\n when 0 then tll_s10 = ptll10 \n when 1 then tll_s10 = ptll8\n when 2 then tll_s10 = ptll7\n when 3 then tll_s10 = ptll6\n when 4 then tll_s10 = ptll5\n when 5 then tll_s10 = ptll4\n when 6 then tll_s10 = ptll3\n when 7 then tll_s10 = ptll2\n when 8 then tll_s10 = ptll1\n when 9 then tll_s10 = self.user.s_name6 + ' - Pass'\n when 10..100 then tll_s10 = rtll10\n end\n\n #tll_s11\n case num_thirdlg\n when 0 then tll_s11 = ptll11 \n when 1 then tll_s11 = ptll9\n when 2 then tll_s11 = ptll8\n when 3 then tll_s11 = ptll7\n when 4 then tll_s11 = ptll6\n when 5 then tll_s11 = ptll5\n when 6 then tll_s11 = ptll4\n when 7 then tll_s11 = ptll3\n when 8 then tll_s11 = ptll2\n when 9 then tll_s11 = ptll1\n when 10 then tll_s11 = self.user.s_name6 + ' - Pass'\n when 11..100 then tll_s11 = rtll11\n end\n\n #tll_s12\n case num_thirdlg\n when 0 then tll_s12 = ptll12 \n when 1 then tll_s12 = ptll10\n when 2 then tll_s12 = ptll9\n when 3 then tll_s12 = ptll8\n when 4 then tll_s12 = ptll7\n when 5 then tll_s12 = ptll6\n when 6 then tll_s12 = ptll5\n when 7 then tll_s12 = ptll4\n when 8 then tll_s12 = ptll3\n when 9 then tll_s12 = ptll2\n when 10 then tll_s12 = ptll1\n when 11..100 then tll_s12 = rtll12\n end\n\n \n #Right Hash\n # tlr_s0 would always be blank\n\n #tlr_s1 \n if num_thirdlg > 0\n tlr_s1 = rtlr1\n else\n tlr_s1 = ptlr1\n end\n\n #tlr_s2\n if num_thirdlg == 0\n tlr_s2 = ptlr2\n elsif num_thirdlg == 1\n tlr_s2 = ''\n else num_thirdlg > 1\n tlr_s2 = rtlr2\n end\n\n #tlr_s3\n case num_thirdlg\n when 0 then tlr_s3 = ptlr3 \n when 1 then tlr_s3 = ptlr1\n when 2 then tlr_s3 = ''\n when 3..100 then tlr_s3 = rtlr3\n end\n\n #tlr_s4\n case num_thirdlg\n when 0 then tlr_s4 = ptlr4 \n when 1 then tlr_s4 = ptlr2\n when 2 then tlr_s4 = ptlr1\n when 3 then ''\n when 4..100 then tlr_s4 = rtlr4\n end\n\n #tlr_s5\n case num_thirdlg\n when 0 then tlr_s5 = ptlr5 \n when 1 then tlr_s5 = ptlr3\n when 2 then tlr_s5 = ptlr2\n when 3 then tlr_s5 = ptlr1\n when 4 then tlr_s5 = ''\n when 5..100 then tlr_s5 = rtlr5\n end\n\n #tlr_s6\n case num_thirdlg\n when 0 then tlr_s6 = ptlr6 \n when 1 then tlr_s6 = ptlr4\n when 2 then tlr_s6 = ptlr3\n when 3 then tlr_s6 = ptlr2\n when 4 then tlr_s6 = ptlr1\n when 5 then tlr_s6 = ''\n when 6..100 then tlr_s6 = rtlr6\n end\n\n #tlr_s7\n case num_thirdlg\n when 0 then tlr_s7 = ptlr7 \n when 1 then tlr_s7 = ptlr5\n when 2 then tlr_s7 = ptlr4\n when 3 then tlr_s7 = ptlr3\n when 4 then tlr_s7 = ptlr2\n when 5 then tlr_s7 = ptlr1\n when 6 then tlr_s7 = ''\n when 7..100 then tlr_s7 = rtlr7\n end\n\n #tlr_s8\n case num_thirdlg\n when 0 then tlr_s8 = ptlr8 \n when 1 then tlr_s8 = ptlr6\n when 2 then tlr_s8 = ptlr5\n when 3 then tlr_s8 = ptlr4\n when 4 then tlr_s8 = ptlr3\n when 5 then tlr_s8 = ptlr2\n when 6 then tlr_s8 = ptlr1\n when 7 then tlr_s8 = ''\n when 8..100 then tlr_s8 = rtlr8\n end\n\n #tlr_s9\n case num_thirdlg\n when 0 then tlr_s9 = ptlr9 \n when 1 then tlr_s9 = ptlr7\n when 2 then tlr_s9 = ptlr6\n when 3 then tlr_s9 = ptlr5\n when 4 then tlr_s9 = ptlr4\n when 5 then tlr_s9 = ptlr3\n when 6 then tlr_s9 = ptlr2\n when 7 then tlr_s9 = ptlr1\n when 8 then tlr_s9 = ''\n when 9..100 then tlr_s9 = rtlr9\n end\n\n #tlr_s10\n case num_thirdlg\n when 0 then tlr_s10 = ptlr10 \n when 1 then tlr_s10 = ptlr8\n when 2 then tlr_s10 = ptlr7\n when 3 then tlr_s10 = ptlr6\n when 4 then tlr_s10 = ptlr5\n when 5 then tlr_s10 = ptlr4\n when 6 then tlr_s10 = ptlr3\n when 7 then tlr_s10 = ptlr2\n when 8 then tlr_s10 = ptlr1\n when 9 then tlr_s10 = ''\n when 10..100 then tlr_s10 = rtlr10\n end\n\n #tlr_s11\n case num_thirdlg\n when 0 then tlr_s11 = ptlr11 \n when 1 then tlr_s11 = ptlr9\n when 2 then tlr_s11 = ptlr8\n when 3 then tlr_s11 = ptlr7\n when 4 then tlr_s11 = ptlr6\n when 5 then tlr_s11 = ptlr5\n when 6 then tlr_s11 = ptlr4\n when 7 then tlr_s11 = ptlr3\n when 8 then tlr_s11 = ptlr2\n when 9 then tlr_s11 = ptlr1\n when 10 then tlr_s11 = ''\n when 11..100 then tlr_s11 = rtlr11\n end\n\n #tlr_s12\n case num_thirdlg\n when 0 then tlr_s12 = ptlr12 \n when 1 then tlr_s12 = ptlr10\n when 2 then tlr_s12 = ptlr9\n when 3 then tlr_s12 = ptlr8\n when 4 then tlr_s12 = ptlr7\n when 5 then tlr_s12 = ptlr6\n when 6 then tlr_s12 = ptlr5\n when 7 then tlr_s12 = ptlr4\n when 8 then tlr_s12 = ptlr3\n when 9 then tlr_s12 = ptlr2\n when 10 then tlr_s12 = ptlr1\n when 11..100 then tlr_s12 = rtlr12\n end \n #----------End 3rd & Long---------- \n\n #----------2nd & Medium----------\n secondMediums = event.plays.where('situation4 = ?', true)\n \n runSecondMediums = secondMediums.where('play_type = ?', 'Run')\n runSecondMediumsLeft = runSecondMediums.where('hash_mark = ?', 'Left')\n runSecondMediumsRight = runSecondMediums.where('hash_mark = ?', 'Right')\n \n passSecondMediums = secondMediums.where('play_type = ?', 'Pass')\n passSecondMediumsLeft = passSecondMediums.where('hash_mark = ?', 'Left')\n passSecondMediumsRight = passSecondMediums.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runSecondMediumsLeft[0].nil? \n rsml1 = runSecondMediumsLeft[0].fullname \n end\n unless runSecondMediumsLeft[1].nil? \n rsml2 = runSecondMediumsLeft[1].fullname \n end\n unless runSecondMediumsLeft[2].nil? \n rsml3 = runSecondMediumsLeft[2].fullname \n end\n unless runSecondMediumsLeft[3].nil? \n rsml4 = runSecondMediumsLeft[3].fullname \n end\n unless runSecondMediumsLeft[4].nil? \n rsml5 = runSecondMediumsLeft[4].fullname\n end\n unless runSecondMediumsLeft[5].nil? \n rsml6 = runSecondMediumsLeft[5].fullname \n end\n unless runSecondMediumsLeft[6].nil? \n rsml7 = runSecondMediumsLeft[6].fullname \n end\n unless runSecondMediumsLeft[7].nil? \n rsml8 = runSecondMediumsLeft[7].fullname \n end\n unless runSecondMediumsLeft[8].nil? \n rsml9 = runSecondMediumsLeft[8].fullname \n end\n unless runSecondMediumsLeft[9].nil? \n rsml10 = runSecondMediumsLeft[9].fullname\n end \n unless runSecondMediumsLeft[10].nil? \n rsml11 = runSecondMediumsLeft[10].fullname\n end \n\n #Run Right Hash\n unless runSecondMediumsRight[0].nil? \n rsmr1 = runSecondMediumsRight[0].fullname \n end\n unless runSecondMediumsRight[1].nil? \n rsmr2 = runSecondMediumsRight[1].fullname \n end\n unless runSecondMediumsRight[2].nil? \n rsmr3 = runSecondMediumsRight[2].fullname \n end\n unless runSecondMediumsRight[3].nil? \n rsmr4 = runSecondMediumsRight[3].fullname \n end\n unless runSecondMediumsRight[4].nil? \n rsmr5 = runSecondMediumsRight[4].fullname\n end\n unless runSecondMediumsRight[5].nil? \n rsmr6 = runSecondMediumsRight[5].fullname \n end\n unless runSecondMediumsRight[6].nil? \n rsmr7 = runSecondMediumsRight[6].fullname \n end\n unless runSecondMediumsRight[7].nil? \n rsmr8 = runSecondMediumsRight[7].fullname \n end\n unless runSecondMediumsRight[8].nil? \n rsmr9 = runSecondMediumsRight[8].fullname \n end\n unless runSecondMediumsRight[9].nil? \n rsmr10 = runSecondMediumsRight[9].fullname\n end\n unless runSecondMediumsRight[10].nil? \n rsmr11 = runSecondMediumsRight[10].fullname\n end\n\n #Pass Left Hash\n unless passSecondMediumsLeft[0].nil? \n psml1 = passSecondMediumsLeft[0].fullname \n end\n unless passSecondMediumsLeft[1].nil? \n psml2 = passSecondMediumsLeft[1].fullname \n end\n unless passSecondMediumsLeft[2].nil? \n psml3 = passSecondMediumsLeft[2].fullname \n end\n unless passSecondMediumsLeft[3].nil? \n psml4 = passSecondMediumsLeft[3].fullname \n end\n unless passSecondMediumsLeft[4].nil? \n psml5 = passSecondMediumsLeft[4].fullname\n end\n unless passSecondMediumsLeft[5].nil? \n psml6 = passSecondMediumsLeft[5].fullname \n end\n unless passSecondMediumsLeft[6].nil? \n psml7 = passSecondMediumsLeft[6].fullname \n end\n unless passSecondMediumsLeft[7].nil? \n psml8 = passSecondMediumsLeft[7].fullname \n end\n unless passSecondMediumsLeft[8].nil? \n psml9 = passSecondMediumsLeft[8].fullname \n end\n unless passSecondMediumsLeft[9].nil? \n psml10 = passSecondMediumsLeft[9].fullname\n end\n unless passSecondMediumsLeft[10].nil? \n psml11 = passSecondMediumsLeft[10].fullname \n end\n\n #Pass Right Hash\n unless passSecondMediumsRight[0].nil? \n psmr1 = passSecondMediumsRight[0].fullname \n end\n unless passSecondMediumsRight[1].nil? \n psmr2 = passSecondMediumsRight[1].fullname \n end\n unless passSecondMediumsRight[2].nil? \n psmr3 = passSecondMediumsRight[2].fullname \n end\n unless passSecondMediumsRight[3].nil? \n psmr4 = passSecondMediumsRight[3].fullname \n end\n unless passSecondMediumsRight[4].nil? \n psmr5 = passSecondMediumsRight[4].fullname\n end\n unless passSecondMediumsRight[5].nil? \n psmr6 = passSecondMediumsRight[5].fullname \n end\n unless passSecondMediumsRight[6].nil? \n psmr7 = passSecondMediumsRight[6].fullname \n end\n unless passSecondMediumsRight[7].nil? \n psmr8 = passSecondMediumsRight[7].fullname \n end\n unless passSecondMediumsRight[8].nil? \n psmr9 = passSecondMediumsRight[8].fullname \n end\n unless passSecondMediumsRight[9].nil? \n psmr10 = passSecondMediumsRight[9].fullname\n end\n unless passSecondMediumsRight[10].nil? \n psmr11 = passSecondMediumsRight[10].fullname \n end\n\n #Number of user's run plays in situation 4\n num_secondmd = self.user.s_name4_num_run\n\n #Left Hash\n # tll_s0 \n if num_secondmd > 0\n secondmdl_s0 = self.user.s_name4 + ' - Run'\n else\n secondmdl_s0 = self.user.s_name4 + ' - Pass'\n end\n\n #secondmdl_s1 \n if num_secondmd > 0\n secondmdl_s1 = rsml1\n else\n secondmdl_s1 = psml1\n end\n\n #secondmdl_s2\n if num_secondmd == 0\n secondmdl_s2 = psml2\n elsif num_secondmd == 1\n secondmdl_s2 = self.user.s_name4 + ' - Pass'\n else num_secondmd > 1\n secondmdl_s2 = rsml2\n end\n\n #secondmdl_s3\n case num_secondmd\n when 0 then secondmdl_s3 = psml3 \n when 1 then secondmdl_s3 = psml1\n when 2 then secondmdl_s3 = self.user.s_name4 + ' - Pass'\n when 3..100 then secondmdl_s3 = rsml3\n end\n\n #secondmdl_s4\n case num_secondmd\n when 0 then secondmdl_s4 = psml4 \n when 1 then secondmdl_s4 = psml2\n when 2 then secondmdl_s4 = psml1\n when 3 then secondmdl_s4 = self.user.s_name4 + ' - Pass'\n when 4..100 then secondmdl_s4 = rsml4\n end\n\n #secondmdl_s5\n case num_secondmd\n when 0 then secondmdl_s5 = psml5 \n when 1 then secondmdl_s5 = psml3\n when 2 then secondmdl_s5 = psml2\n when 3 then secondmdl_s5 = psml1\n when 4 then secondmdl_s5 = self.user.s_name4 + ' - Pass'\n when 5..100 then secondmdl_s5 = rsml5\n end\n\n #secondmdl_s6\n case num_secondmd\n when 0 then secondmdl_s6 = psml6 \n when 1 then secondmdl_s6 = psml4\n when 2 then secondmdl_s6 = psml3\n when 3 then secondmdl_s6 = psml2\n when 4 then secondmdl_s6 = psml1\n when 5 then secondmdl_s6 = self.user.s_name4 + ' - Pass'\n when 6..100 then secondmdl_s6 = rsml6\n end\n\n #secondmdl_s7\n case num_secondmd\n when 0 then secondmdl_s7 = psml7 \n when 1 then secondmdl_s7 = psml5\n when 2 then secondmdl_s7 = psml4\n when 3 then secondmdl_s7 = psml3\n when 4 then secondmdl_s7 = psml2\n when 5 then secondmdl_s7 = psml1\n when 6 then secondmdl_s7 = self.user.s_name4 + ' - Pass'\n when 7..100 then secondmdl_s7 = rsml7\n end\n\n #secondmdl_s8\n case num_secondmd\n when 0 then secondmdl_s8 = psml8 \n when 1 then secondmdl_s8 = psml6\n when 2 then secondmdl_s8 = psml5\n when 3 then secondmdl_s8 = psml4\n when 4 then secondmdl_s8 = psml3\n when 5 then secondmdl_s8 = psml2\n when 6 then secondmdl_s8 = psml1\n when 7 then secondmdl_s8 = self.user.s_name4 + ' - Pass'\n when 8..100 then secondmdl_s8 = rsml8\n end\n\n #secondmdl_s9\n case num_secondmd\n when 0 then secondmdl_s9 = psml9 \n when 1 then secondmdl_s9 = psml7\n when 2 then secondmdl_s9 = psml6\n when 3 then secondmdl_s9 = psml5\n when 4 then secondmdl_s9 = psml4\n when 5 then secondmdl_s9 = psml3\n when 6 then secondmdl_s9 = psml2\n when 7 then secondmdl_s9 = psml1\n when 8 then secondmdl_s9 = self.user.s_name4 + ' - Pass'\n when 9..100 then secondmdl_s9 = rsml9\n end\n\n #secondmdl_s10\n case num_secondmd\n when 0 then secondmdl_s10 = psml10 \n when 1 then secondmdl_s10 = psml8\n when 2 then secondmdl_s10 = psml7\n when 3 then secondmdl_s10 = psml6\n when 4 then secondmdl_s10 = psml5\n when 5 then secondmdl_s10 = psml4\n when 6 then secondmdl_s10 = psml3\n when 7 then secondmdl_s10 = psml2\n when 8 then secondmdl_s10 = psml1\n when 9 then secondmdl_s10 = self.user.s_name4 + ' - Pass'\n when 10..100 then secondmdl_s10 = rsml10\n end\n\n #secondmdl_s11\n case num_secondmd\n when 0 then secondmdl_s11 = psml11 \n when 1 then secondmdl_s11 = psml9\n when 2 then secondmdl_s11 = psml8\n when 3 then secondmdl_s11 = psml7\n when 4 then secondmdl_s11 = psml6\n when 5 then secondmdl_s11 = psml5\n when 6 then secondmdl_s11 = psml4\n when 7 then secondmdl_s11 = psml3\n when 8 then secondmdl_s11 = psml2\n when 9 then secondmdl_s11 = psml1\n when 10..100 then secondmdl_s11 = rsml11\n end\n \n #Right Hash\n # secondmdr_s0 would always be blank\n\n #secondmdr_s1 \n if num_secondmd > 0\n secondmdr_s1 = rsmr1\n else\n secondmdr_s1 = psmr1\n end\n\n #secondmdr_s2\n if num_secondmd == 0\n secondmdr_s2 = psmr2\n elsif num_secondmd == 1\n secondmdr_s2 = ''\n else num_secondmd > 1\n secondmdr_s2 = rsmr2\n end\n\n #secondmdr_s3\n case num_secondmd\n when 0 then secondmdr_s3 = psmr3 \n when 1 then secondmdr_s3 = psmr1\n when 2 then secondmdr_s3 = ''\n when 3..100 then secondmdr_s3 = rsmr3\n end\n\n #secondmdr_s4\n case num_secondmd\n when 0 then secondmdr_s4 = psmr4 \n when 1 then secondmdr_s4 = psmr2\n when 2 then secondmdr_s4 = psmr1\n when 3 then ''\n when 4..100 then secondmdr_s4 = rsmr4\n end\n\n #secondmdr_s5\n case num_secondmd\n when 0 then secondmdr_s5 = psmr5 \n when 1 then secondmdr_s5 = psmr3\n when 2 then secondmdr_s5 = psmr2\n when 3 then secondmdr_s5 = psmr1\n when 4 then secondmdr_s5 = ''\n when 5..100 then secondmdr_s5 = rsmr5\n end\n\n #secondmdr_s6\n case num_secondmd\n when 0 then secondmdr_s6 = psmr6 \n when 1 then secondmdr_s6 = psmr4\n when 2 then secondmdr_s6 = psmr3\n when 3 then secondmdr_s6 = psmr2\n when 4 then secondmdr_s6 = psmr1\n when 5 then secondmdr_s6 = ''\n when 6..100 then secondmdr_s6 = rsmr6\n end\n\n #secondmdr_s7\n case num_secondmd\n when 0 then secondmdr_s7 = psmr7 \n when 1 then secondmdr_s7 = psmr5\n when 2 then secondmdr_s7 = psmr4\n when 3 then secondmdr_s7 = psmr3\n when 4 then secondmdr_s7 = psmr2\n when 5 then secondmdr_s7 = psmr1\n when 6 then secondmdr_s7 = ''\n when 7..100 then secondmdr_s7 = rsmr7\n end\n\n #secondmdr_s8\n case num_secondmd\n when 0 then secondmdr_s8 = psmr8 \n when 1 then secondmdr_s8 = psmr6\n when 2 then secondmdr_s8 = psmr5\n when 3 then secondmdr_s8 = psmr4\n when 4 then secondmdr_s8 = psmr3\n when 5 then secondmdr_s8 = psmr2\n when 6 then secondmdr_s8 = psmr1\n when 7 then secondmdr_s8 = ''\n when 8..100 then secondmdr_s8 = rsmr8\n end\n\n #secondmdr_s9\n case num_secondmd\n when 0 then secondmdr_s9 = psmr9 \n when 1 then secondmdr_s9 = psmr7\n when 2 then secondmdr_s9 = psmr6\n when 3 then secondmdr_s9 = psmr5\n when 4 then secondmdr_s9 = psmr4\n when 5 then secondmdr_s9 = psmr3\n when 6 then secondmdr_s9 = psmr2\n when 7 then secondmdr_s9 = psmr1\n when 8 then secondmdr_s9 = ''\n when 9..100 then secondmdr_s9 = rsmr9\n end\n\n #secondmdr_s10\n case num_secondmd\n when 0 then secondmdr_s10 = psmr10 \n when 1 then secondmdr_s10 = psmr8\n when 2 then secondmdr_s10 = psmr7\n when 3 then secondmdr_s10 = psmr6\n when 4 then secondmdr_s10 = psmr5\n when 5 then secondmdr_s10 = psmr4\n when 6 then secondmdr_s10 = psmr3\n when 7 then secondmdr_s10 = psmr2\n when 8 then secondmdr_s10 = psmr1\n when 9 then secondmdr_s10 = ''\n when 10..100 then secondmdr_s10 = rsmr10\n end\n\n #secondmdr_s11\n case num_secondmd\n when 0 then secondmdr_s11 = psmr11 \n when 1 then secondmdr_s11 = psmr9\n when 2 then secondmdr_s11 = psmr8\n when 3 then secondmdr_s11 = psmr7\n when 4 then secondmdr_s11 = psmr6\n when 5 then secondmdr_s11 = psmr5\n when 6 then secondmdr_s11 = psmr4\n when 7 then secondmdr_s11 = psmr3\n when 8 then secondmdr_s11 = psmr2\n when 9 then secondmdr_s11 = psmr1\n when 10..100 then secondmdr_s11 = rsmr11\n end\n \n #----------End 2nd & Medium----------\n\n #----------3rd & Medium----------\n thirdMediums = event.plays.where('situation7 = ?', true)\n \n runThirdMediums = thirdMediums.where('play_type = ?', 'Run')\n runThirdMediumsLeft = runThirdMediums.where('hash_mark = ?', 'Left')\n runThirdMediumsRight = runThirdMediums.where('hash_mark = ?', 'Right')\n \n passThirdMediums = thirdMediums.where('play_type = ?', 'Pass')\n passThirdMediumsLeft = passThirdMediums.where('hash_mark = ?', 'Left')\n passThirdMediumsRight = passThirdMediums.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runThirdMediumsLeft[0].nil? \n rtml1 = runThirdMediumsLeft[0].fullname \n end\n unless runThirdMediumsLeft[1].nil? \n rtml2 = runThirdMediumsLeft[1].fullname \n end\n unless runThirdMediumsLeft[2].nil? \n rtml3 = runThirdMediumsLeft[2].fullname \n end\n unless runThirdMediumsLeft[3].nil? \n rtml4 = runThirdMediumsLeft[3].fullname \n end\n unless runThirdMediumsLeft[4].nil? \n rtml5 = runThirdMediumsLeft[4].fullname\n end\n unless runThirdMediumsLeft[5].nil? \n rtml6 = runThirdMediumsLeft[5].fullname \n end\n unless runThirdMediumsLeft[6].nil? \n rtml7 = runThirdMediumsLeft[6].fullname \n end\n unless runThirdMediumsLeft[7].nil? \n rtml8 = runThirdMediumsLeft[7].fullname \n end\n unless runThirdMediumsLeft[8].nil? \n rtml9 = runThirdMediumsLeft[8].fullname \n end\n unless runThirdMediumsLeft[9].nil? \n rtml10 = runThirdMediumsLeft[9].fullname\n end\n unless runThirdMediumsLeft[10].nil? \n rtml11 = runThirdMediumsLeft[10].fullname \n end\n\n #Run Right Hash\n unless runThirdMediumsRight[0].nil? \n rtmr1 = runThirdMediumsRight[0].fullname \n end\n unless runThirdMediumsRight[1].nil? \n rtmr2 = runThirdMediumsRight[1].fullname \n end\n unless runThirdMediumsRight[2].nil? \n rtmr3 = runThirdMediumsRight[2].fullname \n end\n unless runThirdMediumsRight[3].nil? \n rtmr4 = runThirdMediumsRight[3].fullname \n end\n unless runThirdMediumsRight[4].nil? \n rtmr5 = runThirdMediumsRight[4].fullname\n end\n unless runThirdMediumsRight[5].nil? \n rtmr6 = runThirdMediumsRight[5].fullname \n end\n unless runThirdMediumsRight[6].nil? \n rtmr7 = runThirdMediumsRight[6].fullname \n end\n unless runThirdMediumsRight[7].nil? \n rtmr8 = runThirdMediumsRight[7].fullname \n end\n unless runThirdMediumsRight[8].nil? \n rtmr9 = runThirdMediumsRight[8].fullname \n end\n unless runThirdMediumsRight[9].nil? \n rtmr10 = runThirdMediumsRight[9].fullname\n end\n unless runThirdMediumsRight[10].nil? \n rtmr11 = runThirdMediumsRight[10].fullname \n end\n \n\n #Pass Left Hash\n unless passThirdMediumsLeft[0].nil? \n ptml1 = passThirdMediumsLeft[0].fullname \n end\n unless passThirdMediumsLeft[1].nil? \n ptml2 = passThirdMediumsLeft[1].fullname \n end\n unless passThirdMediumsLeft[2].nil? \n ptml3 = passThirdMediumsLeft[2].fullname \n end\n unless passThirdMediumsLeft[3].nil? \n ptml4 = passThirdMediumsLeft[3].fullname \n end\n unless passThirdMediumsLeft[4].nil? \n ptml5 = passThirdMediumsLeft[4].fullname\n end\n unless passThirdMediumsLeft[5].nil? \n ptml6 = passThirdMediumsLeft[5].fullname \n end\n unless passThirdMediumsLeft[6].nil? \n ptml7 = passThirdMediumsLeft[6].fullname \n end\n unless passThirdMediumsLeft[7].nil? \n ptml8 = passThirdMediumsLeft[7].fullname \n end\n unless passThirdMediumsLeft[8].nil? \n ptml9 = passThirdMediumsLeft[8].fullname \n end\n unless passThirdMediumsLeft[9].nil? \n ptml10 = passThirdMediumsLeft[9].fullname\n end\n unless passThirdMediumsLeft[10].nil? \n ptml11 = passThirdMediumsLeft[10].fullname \n end\n\n #Pass Right Hash\n unless passThirdMediumsRight[0].nil? \n ptmr1 = passThirdMediumsRight[0].fullname \n end\n unless passThirdMediumsRight[1].nil? \n ptmr2 = passThirdMediumsRight[1].fullname \n end\n unless passThirdMediumsRight[2].nil? \n ptmr3 = passThirdMediumsRight[2].fullname \n end\n unless passThirdMediumsRight[3].nil? \n ptmr4 = passThirdMediumsRight[3].fullname \n end\n unless passThirdMediumsRight[4].nil? \n ptmr5 = passThirdMediumsRight[4].fullname\n end\n unless passThirdMediumsRight[5].nil? \n ptmr6 = passThirdMediumsRight[5].fullname \n end\n unless passThirdMediumsRight[6].nil? \n ptmr7 = passThirdMediumsRight[6].fullname \n end\n unless passThirdMediumsRight[7].nil? \n ptmr8 = passThirdMediumsRight[7].fullname \n end\n unless passThirdMediumsRight[8].nil? \n ptmr9 = passThirdMediumsRight[8].fullname \n end\n unless passThirdMediumsRight[9].nil? \n ptmr10 = passThirdMediumsRight[9].fullname\n end\n unless passThirdMediumsRight[10].nil? \n ptmr11 = passThirdMediumsRight[10].fullname \n end\n \n\n #Number of user's run plays in situation 7\n num_thirdmd = self.user.s_name7_num_run\n\n #Left Hash\n # thirdmdl_s0 \n if num_thirdmd > 0\n thirdmdl_s0 = self.user.s_name7 + ' - Run'\n else\n thirdmdl_s0 = self.user.s_name7 + ' - Pass'\n end\n\n #thirdmdl_s1 \n if num_thirdmd > 0\n thirdmdl_s1 = rtml1\n else\n thirdmdl_s1 = ptml1\n end\n\n #thirdmdl_s2\n if num_thirdmd == 0\n thirdmdl_s2 = ptml2\n elsif num_thirdmd == 1\n thirdmdl_s2 = self.user.s_name7 + ' - Pass'\n else num_thirdmd > 1\n thirdmdl_s2 = rtml2\n end\n\n #thirdmdl_s3\n case num_thirdmd\n when 0 then thirdmdl_s3 = ptml3 \n when 1 then thirdmdl_s3 = ptml1\n when 2 then thirdmdl_s3 = self.user.s_name7 + ' - Pass'\n when 3..100 then thirdmdl_s3 = rtml3\n end\n\n #thirdmdl_s4\n case num_thirdmd\n when 0 then thirdmdl_s4 = ptml4 \n when 1 then thirdmdl_s4 = ptml2\n when 2 then thirdmdl_s4 = ptml1\n when 3 then thirdmdl_s4 = self.user.s_name7 + ' - Pass'\n when 4..100 then thirdmdl_s4 = rtml4\n end\n\n #thirdmdl_s5\n case num_thirdmd\n when 0 then thirdmdl_s5 = ptml5 \n when 1 then thirdmdl_s5 = ptml3\n when 2 then thirdmdl_s5 = ptml2\n when 3 then thirdmdl_s5 = ptml1\n when 4 then thirdmdl_s5 = self.user.s_name7 + ' - Pass'\n when 5..100 then thirdmdl_s5 = rtml5\n end\n\n #thirdmdl_s6\n case num_thirdmd\n when 0 then thirdmdl_s6 = ptml6 \n when 1 then thirdmdl_s6 = ptml4\n when 2 then thirdmdl_s6 = ptml3\n when 3 then thirdmdl_s6 = ptml2\n when 4 then thirdmdl_s6 = ptml1\n when 5 then thirdmdl_s6 = self.user.s_name7 + ' - Pass'\n when 6..100 then thirdmdl_s6 = rtml6\n end\n\n #thirdmdl_s7\n case num_thirdmd\n when 0 then thirdmdl_s7 = ptml7 \n when 1 then thirdmdl_s7 = ptml5\n when 2 then thirdmdl_s7 = ptml4\n when 3 then thirdmdl_s7 = ptml3\n when 4 then thirdmdl_s7 = ptml2\n when 5 then thirdmdl_s7 = ptml1\n when 6 then thirdmdl_s7 = self.user.s_name7 + ' - Pass'\n when 7..100 then thirdmdl_s7 = rtml7\n end\n\n #thirdmdl_s8\n case num_thirdmd\n when 0 then thirdmdl_s8 = ptml8 \n when 1 then thirdmdl_s8 = ptml6\n when 2 then thirdmdl_s8 = ptml5\n when 3 then thirdmdl_s8 = ptml4\n when 4 then thirdmdl_s8 = ptml3\n when 5 then thirdmdl_s8 = ptml2\n when 6 then thirdmdl_s8 = ptml1\n when 7 then thirdmdl_s8 = self.user.s_name7 + ' - Pass'\n when 8..100 then thirdmdl_s8 = rtml8\n end\n\n #thirdmdl_s9\n case num_thirdmd\n when 0 then thirdmdl_s9 = ptml9 \n when 1 then thirdmdl_s9 = ptml7\n when 2 then thirdmdl_s9 = ptml6\n when 3 then thirdmdl_s9 = ptml5\n when 4 then thirdmdl_s9 = ptml4\n when 5 then thirdmdl_s9 = ptml3\n when 6 then thirdmdl_s9 = ptml2\n when 7 then thirdmdl_s9 = ptml1\n when 8 then thirdmdl_s9 = self.user.s_name7 + ' - Pass'\n when 9..100 then thirdmdl_s9 = rtml9\n end\n\n #thirdmdl_s10\n case num_thirdmd\n when 0 then thirdmdl_s10 = ptml10 \n when 1 then thirdmdl_s10 = ptml8\n when 2 then thirdmdl_s10 = ptml7\n when 3 then thirdmdl_s10 = ptml6\n when 4 then thirdmdl_s10 = ptml5\n when 5 then thirdmdl_s10 = ptml4\n when 6 then thirdmdl_s10 = ptml3\n when 7 then thirdmdl_s10 = ptml2\n when 8 then thirdmdl_s10 = ptml1\n when 9 then thirdmdl_s10 = self.user.s_name7 + ' - Pass'\n when 10..100 then thirdmdl_s10 = rtml10\n end\n\n #thirdmdl_s11\n case num_thirdmd\n when 0 then thirdmdl_s11 = ptml11 \n when 1 then thirdmdl_s11 = ptml9\n when 2 then thirdmdl_s11 = ptml8\n when 3 then thirdmdl_s11 = ptml7\n when 4 then thirdmdl_s11 = ptml6\n when 5 then thirdmdl_s11 = ptml5\n when 6 then thirdmdl_s11 = ptml4\n when 7 then thirdmdl_s11 = ptml3\n when 8 then thirdmdl_s11 = ptml2\n when 9 then thirdmdl_s11 = ptml1\n when 10..100 then thirdmdl_s11 = rtml11\n end\n \n #Right Hash\n # thirdmdr_s0 would always be blank\n\n #thirdmdr_s1 \n if num_thirdmd > 0\n thirdmdr_s1 = rtmr1\n else\n thirdmdr_s1 = ptmr1\n end\n\n #thirdmdr_s2\n if num_thirdmd == 0\n thirdmdr_s2 = ptmr2\n elsif num_thirdmd == 1\n thirdmdr_s2 = ''\n else num_thirdmd > 1\n thirdmdr_s2 = rtmr2\n end\n\n #thirdmdr_s3\n case num_thirdmd\n when 0 then thirdmdr_s3 = ptmr3 \n when 1 then thirdmdr_s3 = ptmr1\n when 2 then thirdmdr_s3 = ''\n when 3..100 then thirdmdr_s3 = rtmr3\n end\n\n #thirdmdr_s4\n case num_thirdmd\n when 0 then thirdmdr_s4 = ptmr4 \n when 1 then thirdmdr_s4 = ptmr2\n when 2 then thirdmdr_s4 = ptmr1\n when 3 then ''\n when 4..100 then thirdmdr_s4 = rtmr4\n end\n\n #thirdmdr_s5\n case num_thirdmd\n when 0 then thirdmdr_s5 = ptmr5 \n when 1 then thirdmdr_s5 = ptmr3\n when 2 then thirdmdr_s5 = ptmr2\n when 3 then thirdmdr_s5 = ptmr1\n when 4 then thirdmdr_s5 = ''\n when 5..100 then thirdmdr_s5 = rtmr5\n end\n\n #thirdmdr_s6\n case num_thirdmd\n when 0 then thirdmdr_s6 = ptmr6 \n when 1 then thirdmdr_s6 = ptmr4\n when 2 then thirdmdr_s6 = ptmr3\n when 3 then thirdmdr_s6 = ptmr2\n when 4 then thirdmdr_s6 = ptmr1\n when 5 then thirdmdr_s6 = ''\n when 6..100 then thirdmdr_s6 = rtmr6\n end\n\n #thirdmdr_s7\n case num_thirdmd\n when 0 then thirdmdr_s7 = ptmr7 \n when 1 then thirdmdr_s7 = ptmr5\n when 2 then thirdmdr_s7 = ptmr4\n when 3 then thirdmdr_s7 = ptmr3\n when 4 then thirdmdr_s7 = ptmr2\n when 5 then thirdmdr_s7 = ptmr1\n when 6 then thirdmdr_s7 = ''\n when 7..100 then thirdmdr_s7 = rtmr7\n end\n\n #thirdmdr_s8\n case num_thirdmd\n when 0 then thirdmdr_s8 = ptmr8 \n when 1 then thirdmdr_s8 = ptmr6\n when 2 then thirdmdr_s8 = ptmr5\n when 3 then thirdmdr_s8 = ptmr4\n when 4 then thirdmdr_s8 = ptmr3\n when 5 then thirdmdr_s8 = ptmr2\n when 6 then thirdmdr_s8 = ptmr1\n when 7 then thirdmdr_s8 = ''\n when 8..100 then thirdmdr_s8 = rtmr8\n end\n\n #thirdmdr_s9\n case num_thirdmd\n when 0 then thirdmdr_s9 = ptmr9 \n when 1 then thirdmdr_s9 = ptmr7\n when 2 then thirdmdr_s9 = ptmr6\n when 3 then thirdmdr_s9 = ptmr5\n when 4 then thirdmdr_s9 = ptmr4\n when 5 then thirdmdr_s9 = ptmr3\n when 6 then thirdmdr_s9 = ptmr2\n when 7 then thirdmdr_s9 = ptmr1\n when 8 then thirdmdr_s9 = ''\n when 9..100 then thirdmdr_s9 = rtmr9\n end\n\n #thirdmdr_s10\n case num_thirdmd\n when 0 then thirdmdr_s10 = ptmr10 \n when 1 then thirdmdr_s10 = ptmr8\n when 2 then thirdmdr_s10 = ptmr7\n when 3 then thirdmdr_s10 = ptmr6\n when 4 then thirdmdr_s10 = ptmr5\n when 5 then thirdmdr_s10 = ptmr4\n when 6 then thirdmdr_s10 = ptmr3\n when 7 then thirdmdr_s10 = ptmr2\n when 8 then thirdmdr_s10 = ptmr1\n when 9 then thirdmdr_s10 = ''\n when 10..100 then thirdmdr_s10 = rtmr10\n end\n\n #thirdmdr_s11\n case num_thirdmd\n when 0 then thirdmdr_s11 = ptmr11 \n when 1 then thirdmdr_s11 = ptmr9\n when 2 then thirdmdr_s11 = ptmr8\n when 3 then thirdmdr_s11 = ptmr7\n when 4 then thirdmdr_s11 = ptmr6\n when 5 then thirdmdr_s11 = ptmr5\n when 6 then thirdmdr_s11 = ptmr4\n when 7 then thirdmdr_s11 = ptmr3\n when 8 then thirdmdr_s11 = ptmr2\n when 9 then thirdmdr_s11 = ptmr1\n when 10..100 then thirdmdr_s11 = rtmr11\n end\n #----------End 3rd & Medium----------\n\n #----------2nd & Short----------\n secondShorts = event.plays.where('situation5 = ?', true)\n \n runSecondShorts = secondShorts.where('play_type = ?', 'Run')\n runSecondShortsLeft = runSecondShorts.where('hash_mark = ?', 'Left')\n runSecondShortsRight = runSecondShorts.where('hash_mark = ?', 'Right')\n \n passSecondShorts = secondShorts.where('play_type = ?', 'Pass')\n passSecondShortsLeft = passSecondShorts.where('hash_mark = ?', 'Left')\n passSecondShortsRight = passSecondShorts.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runSecondShortsLeft[0].nil? \n rssl1 = runSecondShortsLeft[0].fullname \n end\n unless runSecondShortsLeft[1].nil? \n rssl2 = runSecondShortsLeft[1].fullname \n end\n unless runSecondShortsLeft[2].nil? \n rssl3 = runSecondShortsLeft[2].fullname \n end\n unless runSecondShortsLeft[3].nil? \n rssl4 = runSecondShortsLeft[3].fullname \n end\n unless runSecondShortsLeft[4].nil? \n rssl5 = runSecondShortsLeft[4].fullname\n end\n unless runSecondShortsLeft[5].nil? \n rssl6 = runSecondShortsLeft[5].fullname \n end\n unless runSecondShortsLeft[6].nil? \n rssl7 = runSecondShortsLeft[6].fullname \n end\n unless runSecondShortsLeft[7].nil? \n rssl8 = runSecondShortsLeft[7].fullname \n end\n unless runSecondShortsLeft[8].nil? \n rssl9 = runSecondShortsLeft[8].fullname \n end\n unless runSecondShortsLeft[9].nil? \n rssl10 = runSecondShortsLeft[9].fullname\n end\n unless runSecondShortsLeft[10].nil? \n rssl11 = runSecondShortsLeft[10].fullname\n end\n\n #Run Right Hash\n unless runSecondShortsRight[0].nil? \n rssr1 = runSecondShortsRight[0].fullname \n end\n unless runSecondShortsRight[1].nil? \n rssr2 = runSecondShortsRight[1].fullname \n end\n unless runSecondShortsRight[2].nil? \n rssr3 = runSecondShortsRight[2].fullname \n end\n unless runSecondShortsRight[3].nil? \n rssr4 = runSecondShortsRight[3].fullname \n end\n unless runSecondShortsRight[4].nil? \n rssr5 = runSecondShortsRight[4].fullname\n end\n unless runSecondShortsRight[5].nil? \n rssr6 = runSecondShortsRight[5].fullname \n end\n unless runSecondShortsRight[6].nil? \n rssr7 = runSecondShortsRight[6].fullname \n end\n unless runSecondShortsRight[7].nil? \n rssr8 = runSecondShortsRight[7].fullname \n end\n unless runSecondShortsRight[8].nil? \n rssr9 = runSecondShortsRight[8].fullname \n end\n unless runSecondShortsRight[9].nil? \n rssr10 = runSecondShortsRight[9].fullname\n end\n unless runSecondShortsRight[10].nil? \n rssr11 = runSecondShortsRight[10].fullname\n end\n\n #Pass Left Hash\n unless passSecondShortsLeft[0].nil? \n pssl1 = passSecondShortsLeft[0].fullname \n end\n unless passSecondShortsLeft[1].nil? \n pssl2 = passSecondShortsLeft[1].fullname \n end\n unless passSecondShortsLeft[2].nil? \n pssl3 = passSecondShortsLeft[2].fullname \n end\n unless passSecondShortsLeft[3].nil? \n pssl4 = passSecondShortsLeft[3].fullname \n end\n unless passSecondShortsLeft[4].nil? \n pssl5 = passSecondShortsLeft[4].fullname\n end\n unless passSecondShortsLeft[5].nil? \n pssl6 = passSecondShortsLeft[5].fullname \n end\n unless passSecondShortsLeft[6].nil? \n pssl7 = passSecondShortsLeft[6].fullname \n end\n unless passSecondShortsLeft[7].nil? \n pssl8 = passSecondShortsLeft[7].fullname \n end\n unless passSecondShortsLeft[8].nil? \n pssl9 = passSecondShortsLeft[8].fullname \n end\n unless passSecondShortsLeft[9].nil? \n pssl10 = passSecondShortsLeft[9].fullname\n end\n unless passSecondShortsLeft[10].nil? \n pssl11 = passSecondShortsLeft[10].fullname\n end\n\n #Pass Right Hash\n unless passSecondShortsRight[0].nil? \n pssr1 = passSecondShortsRight[0].fullname \n end\n unless passSecondShortsRight[1].nil? \n pssr2 = passSecondShortsRight[1].fullname \n end\n unless passSecondShortsRight[2].nil? \n pssr3 = passSecondShortsRight[2].fullname \n end\n unless passSecondShortsRight[3].nil? \n pssr4 = passSecondShortsRight[3].fullname \n end\n unless passSecondShortsRight[4].nil? \n pssr5 = passSecondShortsRight[4].fullname\n end\n unless passSecondShortsRight[5].nil? \n pssr6 = passSecondShortsRight[5].fullname \n end\n unless passSecondShortsRight[6].nil? \n pssr7 = passSecondShortsRight[6].fullname \n end\n unless passSecondShortsRight[7].nil? \n pssr8 = passSecondShortsRight[7].fullname \n end\n unless passSecondShortsRight[8].nil? \n pssr9 = passSecondShortsRight[8].fullname \n end\n unless passSecondShortsRight[9].nil? \n pssr10 = passSecondShortsRight[9].fullname\n end\n unless passSecondShortsRight[10].nil? \n pssr11 = passSecondShortsRight[10].fullname\n end\n\n #Number of user's run plays in situation 5\n num_secondst = self.user.s_name5_num_run\n\n #Left Hash\n # secondstl_s0 \n if num_secondst > 0\n secondstl_s0 = self.user.s_name5 + ' - Run'\n else\n secondstl_s0 = self.user.s_name5 + ' - Pass'\n end\n\n #secondstl_s1 \n if num_secondst > 0\n secondstl_s1 = rssl1\n else\n secondstl_s1 = pssl1\n end\n\n #secondstl_s2\n if num_secondst == 0\n secondstl_s2 = pssl2\n elsif num_secondst == 1\n secondstl_s2 = self.user.s_name5 + ' - Pass'\n else num_secondst > 1\n secondstl_s2 = rssl2\n end\n\n #secondstl_s3\n case num_secondst\n when 0 then secondstl_s3 = pssl3 \n when 1 then secondstl_s3 = pssl1\n when 2 then secondstl_s3 = self.user.s_name5 + ' - Pass'\n when 3..100 then secondstl_s3 = rssl3\n end\n\n #secondstl_s4\n case num_secondst\n when 0 then secondstl_s4 = pssl4 \n when 1 then secondstl_s4 = pssl2\n when 2 then secondstl_s4 = pssl1\n when 3 then secondstl_s4 = self.user.s_name5 + ' - Pass'\n when 4..100 then secondstl_s4 = rssl4\n end\n\n #secondstl_s5\n case num_secondst\n when 0 then secondstl_s5 = pssl5 \n when 1 then secondstl_s5 = pssl3\n when 2 then secondstl_s5 = pssl2\n when 3 then secondstl_s5 = pssl1\n when 4 then secondstl_s5 = self.user.s_name5 + ' - Pass'\n when 5..100 then secondstl_s5 = rssl5\n end\n\n #secondstl_s6\n case num_secondst\n when 0 then secondstl_s6 = pssl6 \n when 1 then secondstl_s6 = pssl4\n when 2 then secondstl_s6 = pssl3\n when 3 then secondstl_s6 = pssl2\n when 4 then secondstl_s6 = pssl1\n when 5 then secondstl_s6 = self.user.s_name5 + ' - Pass'\n when 6..100 then secondstl_s6 = rssl6\n end\n\n #secondstl_s7\n case num_secondst\n when 0 then secondstl_s7 = pssl7 \n when 1 then secondstl_s7 = pssl5\n when 2 then secondstl_s7 = pssl4\n when 3 then secondstl_s7 = pssl3\n when 4 then secondstl_s7 = pssl2\n when 5 then secondstl_s7 = pssl1\n when 6 then secondstl_s7 = self.user.s_name5 + ' - Pass'\n when 7..100 then secondstl_s7 = rssl7\n end\n\n #secondstl_s8\n case num_secondst\n when 0 then secondstl_s8 = pssl8 \n when 1 then secondstl_s8 = pssl6\n when 2 then secondstl_s8 = pssl5\n when 3 then secondstl_s8 = pssl4\n when 4 then secondstl_s8 = pssl3\n when 5 then secondstl_s8 = pssl2\n when 6 then secondstl_s8 = pssl1\n when 7 then secondstl_s8 = self.user.s_name5 + ' - Pass'\n when 8..100 then secondstl_s8 = rssl8\n end\n\n #secondstl_s9\n case num_secondst\n when 0 then secondstl_s9 = pssl9 \n when 1 then secondstl_s9 = pssl7\n when 2 then secondstl_s9 = pssl6\n when 3 then secondstl_s9 = pssl5\n when 4 then secondstl_s9 = pssl4\n when 5 then secondstl_s9 = pssl3\n when 6 then secondstl_s9 = pssl2\n when 7 then secondstl_s9 = pssl1\n when 8 then secondstl_s9 = self.user.s_name5 + ' - Pass'\n when 9..100 then secondstl_s9 = rssl9\n end\n\n #secondstl_s10\n case num_secondst\n when 0 then secondstl_s10 = pssl10 \n when 1 then secondstl_s10 = pssl8\n when 2 then secondstl_s10 = pssl7\n when 3 then secondstl_s10 = pssl6\n when 4 then secondstl_s10 = pssl5\n when 5 then secondstl_s10 = pssl4\n when 6 then secondstl_s10 = pssl3\n when 7 then secondstl_s10 = pssl2\n when 8 then secondstl_s10 = pssl1\n when 9 then secondstl_s10 = self.user.s_name5 + ' - Pass'\n when 10..100 then secondstl_s10 = rssl10\n end\n\n #secondstl_s11\n case num_secondst\n when 0 then secondstl_s11 = pssl11 \n when 1 then secondstl_s11 = pssl9\n when 2 then secondstl_s11 = pssl8\n when 3 then secondstl_s11 = pssl7\n when 4 then secondstl_s11 = pssl6\n when 5 then secondstl_s11 = pssl5\n when 6 then secondstl_s11 = pssl4\n when 7 then secondstl_s11 = pssl3\n when 8 then secondstl_s11 = pssl2\n when 9 then secondstl_s11 = pssl1\n when 10..100 then secondstl_s11 = rssl11\n end\n \n #Right Hash\n # secondstr_s0 would always be blank\n\n #secondstr_s1 \n if num_secondst > 0\n secondstr_s1 = rssr1\n else\n secondstr_s1 = pssr1\n end\n\n #secondstr_s2\n if num_secondst == 0\n secondstr_s2 = pssr2\n elsif num_secondst == 1\n secondstr_s2 = ''\n else num_secondst > 1\n secondstr_s2 = rssr2\n end\n\n #secondstr_s3\n case num_secondst\n when 0 then secondstr_s3 = pssr3 \n when 1 then secondstr_s3 = pssr1\n when 2 then secondstr_s3 = ''\n when 3..100 then secondstr_s3 = rssr3\n end\n\n #secondstr_s4\n case num_secondst\n when 0 then secondstr_s4 = pssr4 \n when 1 then secondstr_s4 = pssr2\n when 2 then secondstr_s4 = pssr1\n when 3 then ''\n when 4..100 then secondstr_s4 = rssr4\n end\n\n #secondstr_s5\n case num_secondst\n when 0 then secondstr_s5 = pssr5 \n when 1 then secondstr_s5 = pssr3\n when 2 then secondstr_s5 = pssr2\n when 3 then secondstr_s5 = pssr1\n when 4 then secondstr_s5 = ''\n when 5..100 then secondstr_s5 = rssr5\n end\n\n #secondstr_s6\n case num_secondst\n when 0 then secondstr_s6 = pssr6 \n when 1 then secondstr_s6 = pssr4\n when 2 then secondstr_s6 = pssr3\n when 3 then secondstr_s6 = pssr2\n when 4 then secondstr_s6 = pssr1\n when 5 then secondstr_s6 = ''\n when 6..100 then secondstr_s6 = rssr6\n end\n\n #secondstr_s7\n case num_secondst\n when 0 then secondstr_s7 = pssr7 \n when 1 then secondstr_s7 = pssr5\n when 2 then secondstr_s7 = pssr4\n when 3 then secondstr_s7 = pssr3\n when 4 then secondstr_s7 = pssr2\n when 5 then secondstr_s7 = pssr1\n when 6 then secondstr_s7 = ''\n when 7..100 then secondstr_s7 = rssr7\n end\n\n #secondstr_s8\n case num_secondst\n when 0 then secondstr_s8 = pssr8 \n when 1 then secondstr_s8 = pssr6\n when 2 then secondstr_s8 = pssr5\n when 3 then secondstr_s8 = pssr4\n when 4 then secondstr_s8 = pssr3\n when 5 then secondstr_s8 = pssr2\n when 6 then secondstr_s8 = pssr1\n when 7 then secondstr_s8 = ''\n when 8..100 then secondstr_s8 = rssr8\n end\n\n #secondstr_s9\n case num_secondst\n when 0 then secondstr_s9 = pssr9 \n when 1 then secondstr_s9 = pssr7\n when 2 then secondstr_s9 = pssr6\n when 3 then secondstr_s9 = pssr5\n when 4 then secondstr_s9 = pssr4\n when 5 then secondstr_s9 = pssr3\n when 6 then secondstr_s9 = pssr2\n when 7 then secondstr_s9 = pssr1\n when 8 then secondstr_s9 = ''\n when 9..100 then secondstr_s9 = rssr9\n end\n\n #secondstr_s10\n case num_secondst\n when 0 then secondstr_s10 = pssr10 \n when 1 then secondstr_s10 = pssr8\n when 2 then secondstr_s10 = pssr7\n when 3 then secondstr_s10 = pssr6\n when 4 then secondstr_s10 = pssr5\n when 5 then secondstr_s10 = pssr4\n when 6 then secondstr_s10 = pssr3\n when 7 then secondstr_s10 = pssr2\n when 8 then secondstr_s10 = pssr1\n when 9 then secondstr_s10 = ''\n when 10..100 then secondstr_s10 = rssr10\n end\n\n #secondstr_s11\n case num_secondst\n when 0 then secondstr_s11 = pssr11 \n when 1 then secondstr_s11 = pssr9\n when 2 then secondstr_s11 = pssr8\n when 3 then secondstr_s11 = pssr7\n when 4 then secondstr_s11 = pssr6\n when 5 then secondstr_s11 = pssr5\n when 6 then secondstr_s11 = pssr4\n when 7 then secondstr_s11 = pssr3\n when 8 then secondstr_s11 = pssr2\n when 9 then secondstr_s11 = pssr1\n when 10..100 then secondstr_s11 = rssr11\n end \n #----------End 2nd & Short----------\n\n #----------3rd & Short----------\n thirdShorts = event.plays.where('situation8 = ?', true)\n \n runThirdShorts = thirdShorts.where('play_type = ?', 'Run')\n runThirdShortsLeft = runThirdShorts.where('hash_mark = ?', 'Left')\n runThirdShortsRight = runThirdShorts.where('hash_mark = ?', 'Right')\n \n passThirdShorts = thirdShorts.where('play_type = ?', 'Pass')\n passThirdShortsLeft = passThirdShorts.where('hash_mark = ?', 'Left')\n passThirdShortsRight = passThirdShorts.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runThirdShortsLeft[0].nil? \n rtsl1 = runThirdShortsLeft[0].fullname \n end\n unless runThirdShortsLeft[1].nil? \n rtsl2 = runThirdShortsLeft[1].fullname \n end\n unless runThirdShortsLeft[2].nil? \n rtsl3 = runThirdShortsLeft[2].fullname \n end\n unless runThirdShortsLeft[3].nil? \n rtsl4 = runThirdShortsLeft[3].fullname \n end\n unless runThirdShortsLeft[4].nil? \n rtsl5 = runThirdShortsLeft[4].fullname\n end\n unless runThirdShortsLeft[5].nil? \n rtsl6 = runThirdShortsLeft[5].fullname \n end\n unless runThirdShortsLeft[6].nil? \n rtsl7 = runThirdShortsLeft[6].fullname\n end \n unless runThirdShortsLeft[7].nil? \n rtsl8 = runThirdShortsLeft[7].fullname \n end\n unless runThirdShortsLeft[8].nil? \n rtsl9 = runThirdShortsLeft[8].fullname \n end\n unless runThirdShortsLeft[9].nil? \n rtsl10 = runThirdShortsLeft[9].fullname \n end\n unless runThirdShortsLeft[10].nil? \n rtsl11 = runThirdShortsLeft[10].fullname \n end\n\n #Run Right Hash\n unless runThirdShortsRight[0].nil? \n rtsr1 = runThirdShortsRight[0].fullname \n end\n unless runThirdShortsRight[1].nil? \n rtsr2 = runThirdShortsRight[1].fullname \n end\n unless runThirdShortsRight[2].nil? \n rtsr3 = runThirdShortsRight[2].fullname \n end\n unless runThirdShortsRight[3].nil? \n rtsr4 = runThirdShortsRight[3].fullname \n end\n unless runThirdShortsRight[4].nil? \n rtsr5 = runThirdShortsRight[4].fullname\n end\n unless runThirdShortsRight[5].nil? \n rtsr6 = runThirdShortsRight[5].fullname \n end\n unless runThirdShortsRight[6].nil? \n rtsr7 = runThirdShortsRight[6].fullname\n end \n unless runThirdShortsRight[7].nil? \n rtsr8 = runThirdShortsRight[7].fullname \n end\n unless runThirdShortsRight[8].nil? \n rtsr9 = runThirdShortsRight[8].fullname\n end\n unless runThirdShortsRight[9].nil? \n rtsr10 = runThirdShortsRight[9].fullname \n end\n unless runThirdShortsRight[10].nil? \n rtsr11 = runThirdShortsRight[10].fullname\n end \n\n #Pass Left Hash\n unless passThirdShortsLeft[0].nil? \n ptsl1 = passThirdShortsLeft[0].fullname \n end\n unless passThirdShortsLeft[1].nil? \n ptsl2 = passThirdShortsLeft[1].fullname \n end\n unless passThirdShortsLeft[2].nil? \n ptsl3 = passThirdShortsLeft[2].fullname \n end\n unless passThirdShortsLeft[3].nil? \n ptsl4 = passThirdShortsLeft[3].fullname \n end\n unless passThirdShortsLeft[4].nil? \n ptsl5 = passThirdShortsLeft[4].fullname \n end\n unless passThirdShortsLeft[5].nil? \n ptsl6 = passThirdShortsLeft[5].fullname \n end\n unless passThirdShortsLeft[6].nil? \n ptsl7 = passThirdShortsLeft[6].fullname \n end\n unless passThirdShortsLeft[7].nil? \n ptsl8 = passThirdShortsLeft[7].fullname \n end\n unless passThirdShortsLeft[8].nil? \n ptsl9 = passThirdShortsLeft[8].fullname \n end\n unless passThirdShortsLeft[9].nil? \n ptsl10 = passThirdShortsLeft[9].fullname \n end\n unless passThirdShortsLeft[10].nil? \n ptsl11 = passThirdShortsLeft[10].fullname \n end\n\n #Pass Right Hash\n unless passThirdShortsRight[0].nil? \n ptsr1 = passThirdShortsRight[0].fullname \n end\n unless passThirdShortsRight[1].nil? \n ptsr2 = passThirdShortsRight[1].fullname \n end\n unless passThirdShortsRight[2].nil? \n ptsr3 = passThirdShortsRight[2].fullname \n end\n unless passThirdShortsRight[3].nil? \n ptsr4 = passThirdShortsRight[3].fullname \n end\n unless passThirdShortsRight[4].nil? \n ptsr5 = passThirdShortsRight[4].fullname \n end\n unless passThirdShortsRight[5].nil? \n ptsr6 = passThirdShortsRight[5].fullname \n end\n unless passThirdShortsRight[6].nil? \n ptsr7 = passThirdShortsRight[6].fullname \n end\n unless passThirdShortsRight[7].nil? \n ptsr8 = passThirdShortsRight[7].fullname \n end\n unless passThirdShortsRight[8].nil? \n ptsr9 = passThirdShortsRight[8].fullname \n end\n unless passThirdShortsRight[9].nil? \n ptsr10 = passThirdShortsRight[9].fullname \n end\n unless passThirdShortsRight[10].nil? \n ptsr11 = passThirdShortsRight[10].fullname \n end\n\n #Number of user's run plays in situation 8\n num_thirdst = self.user.s_name8_num_run\n\n #Left Hash\n # thirdstl_s0 \n if num_thirdst > 0\n thirdstl_s0 = self.user.s_name8 + ' - Run'\n else\n thirdstl_s0 = self.user.s_name8 + ' - Pass'\n end\n\n #thirdstl_s1 \n if num_thirdst > 0\n thirdstl_s1 = rtsl1\n else\n thirdstl_s1 = ptsl1\n end\n\n #thirdstl_s2\n if num_thirdst == 0\n thirdstl_s2 = ptsl2\n elsif num_thirdst == 1\n thirdstl_s2 = self.user.s_name8 + ' - Pass'\n else num_thirdst > 1\n thirdstl_s2 = rtsl2\n end\n\n #thirdstl_s3\n case num_thirdst\n when 0 then thirdstl_s3 = ptsl3 \n when 1 then thirdstl_s3 = ptsl1\n when 2 then thirdstl_s3 = self.user.s_name8 + ' - Pass'\n when 3..100 then thirdstl_s3 = rtsl3\n end\n\n #thirdstl_s4\n case num_thirdst\n when 0 then thirdstl_s4 = ptsl4 \n when 1 then thirdstl_s4 = ptsl2\n when 2 then thirdstl_s4 = ptsl1\n when 3 then thirdstl_s4 = self.user.s_name8 + ' - Pass'\n when 4..100 then thirdstl_s4 = rtsl4\n end\n\n #thirdstl_s5\n case num_thirdst\n when 0 then thirdstl_s5 = ptsl5 \n when 1 then thirdstl_s5 = ptsl3\n when 2 then thirdstl_s5 = ptsl2\n when 3 then thirdstl_s5 = ptsl1\n when 4 then thirdstl_s5 = self.user.s_name8 + ' - Pass'\n when 5..100 then thirdstl_s5 = rtsl5\n end\n\n #thirdstl_s6\n case num_thirdst\n when 0 then thirdstl_s6 = ptsl6 \n when 1 then thirdstl_s6 = ptsl4\n when 2 then thirdstl_s6 = ptsl3\n when 3 then thirdstl_s6 = ptsl2\n when 4 then thirdstl_s6 = ptsl1\n when 5 then thirdstl_s6 = self.user.s_name8 + ' - Pass'\n when 6..100 then thirdstl_s6 = rtsl6\n end\n\n #thirdstl_s7\n case num_thirdst\n when 0 then thirdstl_s7 = ptsl7 \n when 1 then thirdstl_s7 = ptsl5\n when 2 then thirdstl_s7 = ptsl4\n when 3 then thirdstl_s7 = ptsl3\n when 4 then thirdstl_s7 = ptsl2\n when 5 then thirdstl_s7 = ptsl1\n when 6 then thirdstl_s7 = self.user.s_name8 + ' - Pass'\n when 7..100 then thirdstl_s7 = rtsl7\n end\n\n #thirdstl_s8\n case num_thirdst\n when 0 then thirdstl_s8 = ptsl8 \n when 1 then thirdstl_s8 = ptsl6\n when 2 then thirdstl_s8 = ptsl5\n when 3 then thirdstl_s8 = ptsl4\n when 4 then thirdstl_s8 = ptsl3\n when 5 then thirdstl_s8 = ptsl2\n when 6 then thirdstl_s8 = ptsl1\n when 7 then thirdstl_s8 = self.user.s_name8 + ' - Pass'\n when 8..100 then thirdstl_s8 = rtsl8\n end\n\n #thirdstl_s9\n case num_thirdst\n when 0 then thirdstl_s9 = ptsl9 \n when 1 then thirdstl_s9 = ptsl7\n when 2 then thirdstl_s9 = ptsl6\n when 3 then thirdstl_s9 = ptsl5\n when 4 then thirdstl_s9 = ptsl4\n when 5 then thirdstl_s9 = ptsl3\n when 6 then thirdstl_s9 = ptsl2\n when 7 then thirdstl_s9 = ptsl1\n when 8 then thirdstl_s9 = self.user.s_name8 + ' - Pass'\n when 9..100 then thirdstl_s9 = rtsl9\n end\n\n #thirdstl_s10\n case num_thirdst\n when 0 then thirdstl_s10 = ptsl10 \n when 1 then thirdstl_s10 = ptsl8\n when 2 then thirdstl_s10 = ptsl7\n when 3 then thirdstl_s10 = ptsl6\n when 4 then thirdstl_s10 = ptsl5\n when 5 then thirdstl_s10 = ptsl4\n when 6 then thirdstl_s10 = ptsl3\n when 7 then thirdstl_s10 = ptsl2\n when 8 then thirdstl_s10 = ptsl1\n when 9 then thirdstl_s10 = self.user.s_name8 + ' - Pass'\n when 10..100 then thirdstl_s10 = rtsl10\n end\n\n #thirdstl_s11\n case num_thirdst\n when 0 then thirdstl_s11 = ptsl11 \n when 1 then thirdstl_s11 = ptsl9\n when 2 then thirdstl_s11 = ptsl8\n when 3 then thirdstl_s11 = ptsl7\n when 4 then thirdstl_s11 = ptsl6\n when 5 then thirdstl_s11 = ptsl5\n when 6 then thirdstl_s11 = ptsl4\n when 7 then thirdstl_s11 = ptsl3\n when 8 then thirdstl_s11 = ptsl2\n when 9 then thirdstl_s11 = ptsl1\n when 10..100 then thirdstl_s11 = rtsl11\n end\n \n #Right Hash\n # thirdstr_s0 would always be blank\n\n #thirdstr_s1 \n if num_thirdst > 0\n thirdstr_s1 = rtsr1\n else\n thirdstr_s1 = ptsr1\n end\n\n #thirdstr_s2\n if num_thirdst == 0\n thirdstr_s2 = ptsr2\n elsif num_thirdst == 1\n thirdstr_s2 = ''\n else num_thirdst > 1\n thirdstr_s2 = rtsr2\n end\n\n #thirdstr_s3\n case num_thirdst\n when 0 then thirdstr_s3 = ptsr3 \n when 1 then thirdstr_s3 = ptsr1\n when 2 then thirdstr_s3 = ''\n when 3..100 then thirdstr_s3 = rtsr3\n end\n\n #thirdstr_s4\n case num_thirdst\n when 0 then thirdstr_s4 = ptsr4 \n when 1 then thirdstr_s4 = ptsr2\n when 2 then thirdstr_s4 = ptsr1\n when 3 then ''\n when 4..100 then thirdstr_s4 = rtsr4\n end\n\n #thirdstr_s5\n case num_thirdst\n when 0 then thirdstr_s5 = ptsr5 \n when 1 then thirdstr_s5 = ptsr3\n when 2 then thirdstr_s5 = ptsr2\n when 3 then thirdstr_s5 = ptsr1\n when 4 then thirdstr_s5 = ''\n when 5..100 then thirdstr_s5 = rtsr5\n end\n\n #thirdstr_s6\n case num_thirdst\n when 0 then thirdstr_s6 = ptsr6 \n when 1 then thirdstr_s6 = ptsr4\n when 2 then thirdstr_s6 = ptsr3\n when 3 then thirdstr_s6 = ptsr2\n when 4 then thirdstr_s6 = ptsr1\n when 5 then thirdstr_s6 = ''\n when 6..100 then thirdstr_s6 = rtsr6\n end\n\n #thirdstr_s7\n case num_thirdst\n when 0 then thirdstr_s7 = ptsr7 \n when 1 then thirdstr_s7 = ptsr5\n when 2 then thirdstr_s7 = ptsr4\n when 3 then thirdstr_s7 = ptsr3\n when 4 then thirdstr_s7 = ptsr2\n when 5 then thirdstr_s7 = ptsr1\n when 6 then thirdstr_s7 = ''\n when 7..100 then thirdstr_s7 = rtsr7\n end\n\n #thirdstr_s8\n case num_thirdst\n when 0 then thirdstr_s8 = ptsr8 \n when 1 then thirdstr_s8 = ptsr6\n when 2 then thirdstr_s8 = ptsr5\n when 3 then thirdstr_s8 = ptsr4\n when 4 then thirdstr_s8 = ptsr3\n when 5 then thirdstr_s8 = ptsr2\n when 6 then thirdstr_s8 = ptsr1\n when 7 then thirdstr_s8 = ''\n when 8..100 then thirdstr_s8 = rtsr8\n end\n\n #thirdstr_s9\n case num_thirdst\n when 0 then thirdstr_s9 = ptsr9 \n when 1 then thirdstr_s9 = ptsr7\n when 2 then thirdstr_s9 = ptsr6\n when 3 then thirdstr_s9 = ptsr5\n when 4 then thirdstr_s9 = ptsr4\n when 5 then thirdstr_s9 = ptsr3\n when 6 then thirdstr_s9 = ptsr2\n when 7 then thirdstr_s9 = ptsr1\n when 8 then thirdstr_s9 = ''\n when 9..100 then thirdstr_s9 = rtsr9\n end\n\n #thirdstr_s10\n case num_thirdst\n when 0 then thirdstr_s10 = ptsr10 \n when 1 then thirdstr_s10 = ptsr8\n when 2 then thirdstr_s10 = ptsr7\n when 3 then thirdstr_s10 = ptsr6\n when 4 then thirdstr_s10 = ptsr5\n when 5 then thirdstr_s10 = ptsr4\n when 6 then thirdstr_s10 = ptsr3\n when 7 then thirdstr_s10 = ptsr2\n when 8 then thirdstr_s10 = ptsr1\n when 9 then thirdstr_s10 = ''\n when 10..100 then thirdstr_s10 = rtsr10\n end\n\n #thirdstr_s11\n case num_thirdst\n when 0 then thirdstr_s11 = ptsr11 \n when 1 then thirdstr_s11 = ptsr9\n when 2 then thirdstr_s11 = ptsr8\n when 3 then thirdstr_s11 = ptsr7\n when 4 then thirdstr_s11 = ptsr6\n when 5 then thirdstr_s11 = ptsr5\n when 6 then thirdstr_s11 = ptsr4\n when 7 then thirdstr_s11 = ptsr3\n when 8 then thirdstr_s11 = ptsr2\n when 9 then thirdstr_s11 = ptsr1\n when 10..100 then thirdstr_s11 = rtsr11\n end \n #----------End 3rd & Short---------- \n\n #----------Redzone----------\n redzones = event.plays.where('situation9 = ?', true)\n \n runredzones = redzones.where('play_type = ?', 'Run')\n runredzonesLeft = runredzones.where('hash_mark = ?', 'Left')\n runredzonesRight = runredzones.where('hash_mark = ?', 'Right')\n \n passredzones = redzones.where('play_type = ?', 'Pass')\n passredzonesLeft = passredzones.where('hash_mark = ?', 'Left')\n passredzonesRight = passredzones.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runredzonesLeft[0].nil? \n rrzl1 = runredzonesLeft[0].fullname \n end\n unless runredzonesLeft[1].nil? \n rrzl2 = runredzonesLeft[1].fullname \n end\n unless runredzonesLeft[2].nil? \n rrzl3 = runredzonesLeft[2].fullname \n end\n unless runredzonesLeft[3].nil? \n rrzl4 = runredzonesLeft[3].fullname \n end\n unless runredzonesLeft[4].nil? \n rrzl5 = runredzonesLeft[4].fullname\n end\n unless runredzonesLeft[5].nil? \n rrzl6 = runredzonesLeft[5].fullname \n end\n unless runredzonesLeft[6].nil? \n rrzl7 = runredzonesLeft[6].fullname\n end \n unless runredzonesLeft[7].nil? \n rrzl8 = runredzonesLeft[7].fullname \n end\n unless runredzonesLeft[8].nil? \n rrzl9 = runredzonesLeft[8].fullname \n end\n unless runredzonesLeft[9].nil? \n rrzl10 = runredzonesLeft[9].fullname \n end\n unless runredzonesLeft[10].nil? \n rrzl11 = runredzonesLeft[10].fullname \n end\n unless runredzonesLeft[11].nil? \n rrzl12 = runredzonesLeft[11].fullname\n end\n unless runredzonesLeft[12].nil? \n rrzl13 = runredzonesLeft[12].fullname \n end\n unless runredzonesLeft[13].nil? \n rrzl14 = runredzonesLeft[13].fullname\n end \n unless runredzonesLeft[14].nil? \n rrzl15 = runredzonesLeft[14].fullname\n end \n\n #Run Right Hash\n unless runredzonesRight[0].nil? \n rrzr1 = runredzonesRight[0].fullname \n end\n unless runredzonesRight[1].nil? \n rrzr2 = runredzonesRight[1].fullname \n end\n unless runredzonesRight[2].nil? \n rrzr3 = runredzonesRight[2].fullname \n end\n unless runredzonesRight[3].nil? \n rrzr4 = runredzonesRight[3].fullname \n end\n unless runredzonesRight[4].nil? \n rrzr5 = runredzonesRight[4].fullname\n end\n unless runredzonesRight[5].nil? \n rrzr6 = runredzonesRight[5].fullname \n end\n unless runredzonesRight[6].nil? \n rrzr7 = runredzonesRight[6].fullname\n end \n unless runredzonesRight[7].nil? \n rrzr8 = runredzonesRight[7].fullname \n end\n unless runredzonesRight[8].nil? \n rrzr9 = runredzonesRight[8].fullname \n end\n unless runredzonesRight[9].nil? \n rrzr10 = runredzonesRight[9].fullname \n end\n unless runredzonesRight[10].nil? \n rrzr11 = runredzonesRight[10].fullname \n end\n unless runredzonesRight[11].nil? \n rrzr12 = runredzonesRight[11].fullname\n end\n unless runredzonesRight[12].nil? \n rrzr13 = runredzonesRight[12].fullname \n end\n unless runredzonesRight[13].nil? \n rrzr14 = runredzonesRight[13].fullname\n end \n unless runredzonesRight[14].nil? \n rrzr15 = runredzonesRight[14].fullname\n end \n\n #Pass Left Hash\n unless passredzonesLeft[0].nil? \n przl1 = passredzonesLeft[0].fullname \n end\n unless passredzonesLeft[1].nil? \n przl2 = passredzonesLeft[1].fullname \n end\n unless passredzonesLeft[2].nil? \n przl3 = passredzonesLeft[2].fullname \n end\n unless passredzonesLeft[3].nil? \n przl4 = passredzonesLeft[3].fullname \n end\n unless passredzonesLeft[4].nil? \n przl5 = passredzonesLeft[4].fullname \n end\n unless passredzonesLeft[5].nil? \n przl6 = passredzonesLeft[5].fullname \n end \n unless passredzonesLeft[6].nil? \n przl7 = passredzonesLeft[6].fullname \n end \n unless passredzonesLeft[7].nil? \n przl8 = passredzonesLeft[7].fullname \n end\n unless passredzonesLeft[8].nil? \n przl9 = passredzonesLeft[8].fullname \n end\n unless passredzonesLeft[9].nil? \n przl10 = passredzonesLeft[9].fullname \n end\n unless passredzonesLeft[10].nil? \n przl11 = passredzonesLeft[10].fullname \n end\n unless passredzonesLeft[11].nil? \n przl12 = passredzonesLeft[11].fullname \n end\n unless passredzonesLeft[12].nil? \n przl13 = passredzonesLeft[12].fullname \n end \n unless passredzonesLeft[13].nil? \n przl14 = passredzonesLeft[13].fullname \n end \n unless passredzonesLeft[14].nil? \n przl15 = passredzonesLeft[14].fullname \n end \n\n #Pass Right Hash\n unless passredzonesRight[0].nil? \n przr1 = passredzonesRight[0].fullname \n end\n unless passredzonesRight[1].nil? \n przr2 = passredzonesRight[1].fullname \n end\n unless passredzonesRight[2].nil? \n przr3 = passredzonesRight[2].fullname \n end\n unless passredzonesRight[3].nil? \n przr4 = passredzonesRight[3].fullname \n end\n unless passredzonesRight[4].nil? \n przr5 = passredzonesRight[4].fullname \n end\n unless passredzonesRight[5].nil? \n przr6 = passredzonesRight[5].fullname \n end\n unless passredzonesRight[6].nil? \n przr7 = passredzonesRight[6].fullname \n end \n unless passredzonesRight[7].nil? \n przr8 = passredzonesRight[7].fullname \n end\n unless passredzonesRight[8].nil? \n przr9 = passredzonesRight[8].fullname \n end\n unless passredzonesRight[9].nil? \n przr10 = passredzonesRight[9].fullname \n end\n unless passredzonesRight[10].nil? \n przr11 = passredzonesRight[10].fullname \n end\n unless passredzonesRight[11].nil? \n przr12 = passredzonesRight[11].fullname \n end\n unless passredzonesRight[12].nil? \n przr13 = passredzonesRight[12].fullname \n end\n unless passredzonesRight[13].nil? \n przr14 = passredzonesRight[13].fullname \n end \n unless passredzonesRight[14].nil? \n przr15 = passredzonesRight[14].fullname \n end \n\n #Number of user's run plays in situation 9\n num_rzoner = self.user.s_name9_num_run\n\n #Left Hash\n # rzonel_s0 \n if num_rzoner > 0\n rzonel_s0 = self.user.s_name9 + ' - Run'\n else\n rzonel_s0 = self.user.s_name9 + ' - Pass'\n end\n\n #rzonel_s1 \n if num_rzoner > 0\n rzonel_s1 = rrzl1\n else\n rzonel_s1 = przl1\n end\n\n #rzonel_s2\n if num_rzoner == 0\n rzonel_s2 = przl2\n elsif num_rzoner == 1\n rzonel_s2 = self.user.s_name9 + ' - Pass'\n else num_rzoner > 1\n rzonel_s2 = rrzl2\n end\n\n #rzonel_s3\n case num_rzoner\n when 0 then rzonel_s3 = przl3 \n when 1 then rzonel_s3 = przl1\n when 2 then rzonel_s3 = self.user.s_name9 + ' - Pass'\n when 3..100 then rzonel_s3 = rrzl3\n end\n\n #rzonel_s4\n case num_rzoner\n when 0 then rzonel_s4 = przl4 \n when 1 then rzonel_s4 = przl2\n when 2 then rzonel_s4 = przl1\n when 3 then rzonel_s4 = self.user.s_name9 + ' - Pass'\n when 4..100 then rzonel_s4 = rrzl4\n end\n\n #rzonel_s5\n case num_rzoner\n when 0 then rzonel_s5 = przl5 \n when 1 then rzonel_s5 = przl3\n when 2 then rzonel_s5 = przl2\n when 3 then rzonel_s5 = przl1\n when 4 then rzonel_s5 = self.user.s_name9 + ' - Pass'\n when 5..100 then rzonel_s5 = rrzl5\n end\n\n #rzonel_s6\n case num_rzoner\n when 0 then rzonel_s6 = przl6 \n when 1 then rzonel_s6 = przl4\n when 2 then rzonel_s6 = przl3\n when 3 then rzonel_s6 = przl2\n when 4 then rzonel_s6 = przl1\n when 5 then rzonel_s6 = self.user.s_name9 + ' - Pass'\n when 6..100 then rzonel_s6 = rrzl6\n end\n\n #rzonel_s7\n case num_rzoner\n when 0 then rzonel_s7 = przl7 \n when 1 then rzonel_s7 = przl5\n when 2 then rzonel_s7 = przl4\n when 3 then rzonel_s7 = przl3\n when 4 then rzonel_s7 = przl2\n when 5 then rzonel_s7 = przl1\n when 6 then rzonel_s7 = self.user.s_name9 + ' - Pass'\n when 7..100 then rzonel_s7 = rrzl7\n end\n\n #rzonel_s8\n case num_rzoner\n when 0 then rzonel_s8 = przl8 \n when 1 then rzonel_s8 = przl6\n when 2 then rzonel_s8 = przl5\n when 3 then rzonel_s8 = przl4\n when 4 then rzonel_s8 = przl3\n when 5 then rzonel_s8 = przl2\n when 6 then rzonel_s8 = przl1\n when 7 then rzonel_s8 = self.user.s_name9 + ' - Pass'\n when 8..100 then rzonel_s8 = rrzl8\n end\n\n #rzonel_s9\n case num_rzoner\n when 0 then rzonel_s9 = przl9 \n when 1 then rzonel_s9 = przl7\n when 2 then rzonel_s9 = przl6\n when 3 then rzonel_s9 = przl5\n when 4 then rzonel_s9 = przl4\n when 5 then rzonel_s9 = przl3\n when 6 then rzonel_s9 = przl2\n when 7 then rzonel_s9 = przl1\n when 8 then rzonel_s9 = self.user.s_name9 + ' - Pass'\n when 9..100 then rzonel_s9 = rrzl9\n end\n\n #rzonel_s10\n case num_rzoner\n when 0 then rzonel_s10 = przl10 \n when 1 then rzonel_s10 = przl8\n when 2 then rzonel_s10 = przl7\n when 3 then rzonel_s10 = przl6\n when 4 then rzonel_s10 = przl5\n when 5 then rzonel_s10 = przl4\n when 6 then rzonel_s10 = przl3\n when 7 then rzonel_s10 = przl2\n when 8 then rzonel_s10 = przl1\n when 9 then rzonel_s10 = self.user.s_name9 + ' - Pass'\n when 10..100 then rzonel_s10 = rrzl10\n end\n\n #rzonel_s11\n case num_rzoner\n when 0 then rzonel_s11 = przl11 \n when 1 then rzonel_s11 = przl9\n when 2 then rzonel_s11 = przl8\n when 3 then rzonel_s11 = przl7\n when 4 then rzonel_s11 = przl6\n when 5 then rzonel_s11 = przl5\n when 6 then rzonel_s11 = przl4\n when 7 then rzonel_s11 = przl3\n when 8 then rzonel_s11 = przl2\n when 9 then rzonel_s11 = przl1\n when 10 then rzonel_s11 = self.user.s_name9 + ' - Pass'\n when 11..100 then rzonel_s11 = rrzl11\n end\n\n #rzonel_s12\n case num_rzoner\n when 0 then rzonel_s12 = przl12 \n when 1 then rzonel_s12 = przl10\n when 2 then rzonel_s12 = przl9\n when 3 then rzonel_s12 = przl8\n when 4 then rzonel_s12 = przl7\n when 5 then rzonel_s12 = przl6\n when 6 then rzonel_s12 = przl5\n when 7 then rzonel_s12 = przl4\n when 8 then rzonel_s12 = przl3\n when 9 then rzonel_s12 = przl2\n when 10 then rzonel_s12 = przl1\n when 11 then rzonel_s12 = self.user.s_name9 + ' - Pass'\n when 12..100 then rzonel_s12 = rrzl12\n end\n\n #rzonel_s13\n case num_rzoner\n when 0 then rzonel_s13 = przl13 \n when 1 then rzonel_s13 = przl11\n when 2 then rzonel_s13 = przl10\n when 3 then rzonel_s13 = przl9\n when 4 then rzonel_s13 = przl8\n when 5 then rzonel_s13 = przl7\n when 6 then rzonel_s13 = przl6\n when 7 then rzonel_s13 = przl5\n when 8 then rzonel_s13 = przl4\n when 9 then rzonel_s13 = przl3\n when 10 then rzonel_s13 = przl2\n when 11 then rzonel_s13 = przl1\n when 12 then rzonel_s13 = self.user.s_name9 + ' - Pass'\n when 13..100 then rzonel_s13 = rrzl13\n end\n\n #rzonel_s14\n case num_rzoner\n when 0 then rzonel_s14 = przl14 \n when 1 then rzonel_s14 = przl12\n when 2 then rzonel_s14 = przl11\n when 3 then rzonel_s14 = przl10\n when 4 then rzonel_s14 = przl9\n when 5 then rzonel_s14 = przl8\n when 6 then rzonel_s14 = przl7\n when 7 then rzonel_s14 = przl6\n when 8 then rzonel_s14 = przl5\n when 9 then rzonel_s14 = przl4\n when 10 then rzonel_s14 = przl3\n when 11 then rzonel_s14 = przl2\n when 12 then rzonel_s14 = przl1 \n when 13 then rzonel_s14 = self.user.s_name9 + ' - Pass'\n when 14..100 then rzonel_s14 = rrzl14\n end\n\n #rzonel_s15\n case num_rzoner\n when 0 then rzonel_s15 = przl15 \n when 1 then rzonel_s15 = przl13\n when 2 then rzonel_s15 = przl12\n when 3 then rzonel_s15 = przl11\n when 4 then rzonel_s15 = przl10\n when 5 then rzonel_s15 = przl9\n when 6 then rzonel_s15 = przl8\n when 7 then rzonel_s15 = przl7\n when 8 then rzonel_s15 = przl6\n when 9 then rzonel_s15 = przl5\n when 10 then rzonel_s15 = przl4\n when 11 then rzonel_s15 = przl3\n when 12 then rzonel_s15 = przl2\n when 13 then rzonel_s15 = przl1 \n when 14..100 then rzonel_s15 = rrzl15\n end \n\n\n #Right Hash\n # rzoner_s0 would always be blank\n\n #rzoner_s1 \n if num_rzoner > 0\n rzoner_s1 = rrzr1\n else\n rzoner_s1 = przr1\n end\n\n #rzoner_s2\n if num_rzoner == 0\n rzoner_s2 = przr2\n elsif num_rzoner == 1\n rzoner_s2 = ''\n else num_rzoner > 1\n rzoner_s2 = rrzr2\n end\n\n #rzoner_s3\n case num_rzoner\n when 0 then rzoner_s3 = przr3 \n when 1 then rzoner_s3 = przr1\n when 2 then rzoner_s3 = ''\n when 3..100 then rzoner_s3 = rrzr3\n end\n\n #rzoner_s4\n case num_rzoner\n when 0 then rzoner_s4 = przr4 \n when 1 then rzoner_s4 = przr2\n when 2 then rzoner_s4 = przr1\n when 3 then ''\n when 4..100 then rzoner_s4 = rrzr4\n end\n\n #rzoner_s5\n case num_rzoner\n when 0 then rzoner_s5 = przr5 \n when 1 then rzoner_s5 = przr3\n when 2 then rzoner_s5 = przr2\n when 3 then rzoner_s5 = przr1\n when 4 then rzoner_s5 = ''\n when 5..100 then rzoner_s5 = rrzr5\n end\n\n #rzoner_s6\n case num_rzoner\n when 0 then rzoner_s6 = przr6 \n when 1 then rzoner_s6 = przr4\n when 2 then rzoner_s6 = przr3\n when 3 then rzoner_s6 = przr2\n when 4 then rzoner_s6 = przr1\n when 5 then rzoner_s6 = ''\n when 6..100 then rzoner_s6 = rrzr6\n end\n\n #rzoner_s7\n case num_rzoner\n when 0 then rzoner_s7 = przr7 \n when 1 then rzoner_s7 = przr5\n when 2 then rzoner_s7 = przr4\n when 3 then rzoner_s7 = przr3\n when 4 then rzoner_s7 = przr2\n when 5 then rzoner_s7 = przr1\n when 6 then rzoner_s7 = ''\n when 7..100 then rzoner_s7 = rrzr7\n end\n\n #rzoner_s8\n case num_rzoner\n when 0 then rzoner_s8 = przr8 \n when 1 then rzoner_s8 = przr6\n when 2 then rzoner_s8 = przr5\n when 3 then rzoner_s8 = przr4\n when 4 then rzoner_s8 = przr3\n when 5 then rzoner_s8 = przr2\n when 6 then rzoner_s8 = przr1\n when 7 then rzoner_s8 = ''\n when 8..100 then rzoner_s8 = rrzr8\n end\n\n #rzoner_s9\n case num_rzoner\n when 0 then rzoner_s9 = przr9 \n when 1 then rzoner_s9 = przr7\n when 2 then rzoner_s9 = przr6\n when 3 then rzoner_s9 = przr5\n when 4 then rzoner_s9 = przr4\n when 5 then rzoner_s9 = przr3\n when 6 then rzoner_s9 = przr2\n when 7 then rzoner_s9 = przr1\n when 8 then rzoner_s9 = ''\n when 9..100 then rzoner_s9 = rrzr9\n end\n\n #rzoner_s10\n case num_rzoner\n when 0 then rzoner_s10 = przr10 \n when 1 then rzoner_s10 = przr8\n when 2 then rzoner_s10 = przr7\n when 3 then rzoner_s10 = przr6\n when 4 then rzoner_s10 = przr5\n when 5 then rzoner_s10 = przr4\n when 6 then rzoner_s10 = przr3\n when 7 then rzoner_s10 = przr2\n when 8 then rzoner_s10 = przr1\n when 9 then rzoner_s10 = ''\n when 10..100 then rzoner_s10 = rrzr10\n end\n\n #rzoner_s11\n case num_rzoner\n when 0 then rzoner_s11 = przr11 \n when 1 then rzoner_s11 = przr9\n when 2 then rzoner_s11 = przr8\n when 3 then rzoner_s11 = przr7\n when 4 then rzoner_s11 = przr6\n when 5 then rzoner_s11 = przr5\n when 6 then rzoner_s11 = przr4\n when 7 then rzoner_s11 = przr3\n when 8 then rzoner_s11 = przr2\n when 9 then rzoner_s11 = przr1\n when 10 then rzoner_s11 = ''\n when 11..100 then rzoner_s11 = rrzr11\n end\n\n #rzoner_s12\n case num_rzoner\n when 0 then rzoner_s12 = przr12 \n when 1 then rzoner_s12 = przr10\n when 2 then rzoner_s12 = przr9\n when 3 then rzoner_s12 = przr8\n when 4 then rzoner_s12 = przr7\n when 5 then rzoner_s12 = przr6\n when 6 then rzoner_s12 = przr5\n when 7 then rzoner_s12 = przr4\n when 8 then rzoner_s12 = przr3\n when 9 then rzoner_s12 = przr2\n when 10 then rzoner_s12 = przr1\n when 11 then rzoner_s12 = ''\n when 12..100 then rzoner_s12 = rrzr12\n end\n\n #rzoner_s13\n case num_rzoner\n when 0 then rzoner_s13 = przr13 \n when 1 then rzoner_s13 = przr11\n when 2 then rzoner_s13 = przr10\n when 3 then rzoner_s13 = przr9\n when 4 then rzoner_s13 = przr8\n when 5 then rzoner_s13 = przr7\n when 6 then rzoner_s13 = przr6\n when 7 then rzoner_s13 = przr5\n when 8 then rzoner_s13 = przr4\n when 9 then rzoner_s13 = przr3\n when 10 then rzoner_s13 = przr2\n when 11 then rzoner_s13 = przr1\n when 12 then rzoner_s13 = ''\n when 13..100 then rzoner_s13 = rrzr13\n end\n\n #rzoner_s14\n case num_rzoner\n when 0 then rzoner_s14 = przr14 \n when 1 then rzoner_s14 = przr12\n when 2 then rzoner_s14 = przr11\n when 3 then rzoner_s14 = przr10\n when 4 then rzoner_s14 = przr9\n when 5 then rzoner_s14 = przr8\n when 6 then rzoner_s14 = przr7\n when 7 then rzoner_s14 = przr6\n when 8 then rzoner_s14 = przr5\n when 9 then rzoner_s14 = przr4\n when 10 then rzoner_s14 = przr3\n when 11 then rzoner_s14 = przr2\n when 12 then rzoner_s14 = przr1 \n when 13 then rzoner_s14 = ''\n when 14..100 then rzoner_s14 = rrzr14\n end\n\n #rzoner_s15\n case num_rzoner\n when 0 then rzoner_s15 = przr15 \n when 1 then rzoner_s15 = przr13\n when 2 then rzoner_s15 = przr12\n when 3 then rzoner_s15 = przr11\n when 4 then rzoner_s15 = przr10\n when 5 then rzoner_s15 = przr9\n when 6 then rzoner_s15 = przr8\n when 7 then rzoner_s15 = przr7\n when 8 then rzoner_s15 = przr6\n when 9 then rzoner_s15 = przr5\n when 10 then rzoner_s15 = przr4\n when 11 then rzoner_s15 = przr3\n when 12 then rzoner_s15 = przr2\n when 13 then rzoner_s15 = przr1 \n when 14..100 then rzoner_s15 = rrzr15\n end\n\n #----------End Redzone---------- \n\n #----------Goal Line----------\n goalines = event.plays.where('situation10 = ?', true)\n \n rungoalines = goalines.where('play_type = ?', 'Run')\n rungoalinesLeft = rungoalines.where('hash_mark = ?', 'Left')\n rungoalinesRight = rungoalines.where('hash_mark = ?', 'Right')\n \n passgoalines = goalines.where('play_type = ?', 'Pass')\n passgoalinesLeft = passgoalines.where('hash_mark = ?', 'Left')\n passgoalinesRight = passgoalines.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless rungoalinesLeft[0].nil? \n rgll1 = rungoalinesLeft[0].fullname \n end\n unless rungoalinesLeft[1].nil? \n rgll2 = rungoalinesLeft[1].fullname \n end\n unless rungoalinesLeft[2].nil? \n rgll3 = rungoalinesLeft[2].fullname \n end\n unless rungoalinesLeft[3].nil? \n rgll4 = rungoalinesLeft[3].fullname \n end\n unless rungoalinesLeft[4].nil? \n rgll5 = rungoalinesLeft[4].fullname\n end\n unless rungoalinesLeft[5].nil? \n rgll6 = rungoalinesLeft[5].fullname \n end\n unless rungoalinesLeft[6].nil? \n rgll7 = rungoalinesLeft[6].fullname\n end \n unless rungoalinesLeft[7].nil? \n rgll8 = rungoalinesLeft[7].fullname \n end\n unless rungoalinesLeft[8].nil? \n rgll9 = rungoalinesLeft[8].fullname \n end\n unless rungoalinesLeft[9].nil? \n rgll10 = rungoalinesLeft[9].fullname \n end\n unless rungoalinesLeft[10].nil? \n rgll11 = rungoalinesLeft[10].fullname \n end\n unless rungoalinesLeft[11].nil? \n rgll12 = rungoalinesLeft[11].fullname\n end\n unless rungoalinesLeft[12].nil? \n rgll13 = rungoalinesLeft[12].fullname \n end\n unless rungoalinesLeft[13].nil? \n rgll14 = rungoalinesLeft[13].fullname\n end \n unless rungoalinesLeft[14].nil? \n rgll15 = rungoalinesLeft[14].fullname\n end\n\n #Run Right Hash\n unless rungoalinesRight[0].nil? \n rglr1 = rungoalinesRight[0].fullname \n end\n unless rungoalinesRight[1].nil? \n rglr2 = rungoalinesRight[1].fullname \n end\n unless rungoalinesRight[2].nil? \n rglr3 = rungoalinesRight[2].fullname \n end\n unless rungoalinesRight[3].nil? \n rglr4 = rungoalinesRight[3].fullname \n end\n unless rungoalinesRight[4].nil? \n rglr5 = rungoalinesRight[4].fullname\n end\n unless rungoalinesRight[5].nil? \n rglr6 = rungoalinesRight[5].fullname \n end\n unless rungoalinesRight[6].nil? \n rglr7 = rungoalinesRight[6].fullname\n end \n unless rungoalinesRight[7].nil? \n rglr8 = rungoalinesRight[7].fullname \n end\n unless rungoalinesRight[8].nil? \n rglr9 = rungoalinesRight[8].fullname \n end\n unless rungoalinesRight[9].nil? \n rglr10 = rungoalinesRight[9].fullname \n end\n unless rungoalinesRight[10].nil? \n rglr11 = rungoalinesRight[10].fullname \n end\n unless rungoalinesRight[11].nil? \n rglr12 = rungoalinesRight[11].fullname\n end\n unless rungoalinesRight[12].nil? \n rglr13 = rungoalinesRight[12].fullname \n end\n unless rungoalinesRight[13].nil? \n rglr14 = rungoalinesRight[13].fullname\n end \n unless rungoalinesRight[14].nil? \n rglr15 = rungoalinesRight[14].fullname\n end \n\n #Pass Left Hash\n unless passgoalinesLeft[0].nil? \n pgll1 = passgoalinesLeft[0].fullname \n end\n unless passgoalinesLeft[1].nil? \n pgll2 = passgoalinesLeft[1].fullname \n end\n unless passgoalinesLeft[2].nil? \n pgll3 = passgoalinesLeft[2].fullname \n end\n unless passgoalinesLeft[3].nil? \n pgll4 = passgoalinesLeft[3].fullname \n end\n unless passgoalinesLeft[4].nil? \n pgll5 = passgoalinesLeft[4].fullname \n end\n unless passgoalinesLeft[5].nil? \n pgll6 = passgoalinesLeft[5].fullname \n end \n unless passgoalinesLeft[6].nil? \n pgll7 = passgoalinesLeft[6].fullname \n end \n unless passgoalinesLeft[7].nil? \n pgll8 = passgoalinesLeft[7].fullname \n end\n unless passgoalinesLeft[8].nil? \n pgll9 = passgoalinesLeft[8].fullname \n end\n unless passgoalinesLeft[9].nil? \n pgll10 = passgoalinesLeft[9].fullname \n end\n unless passgoalinesLeft[10].nil? \n pgll11 = passgoalinesLeft[10].fullname \n end\n unless passgoalinesLeft[11].nil? \n pgll12 = passgoalinesLeft[11].fullname \n end\n unless passgoalinesLeft[12].nil? \n pgll13 = passgoalinesLeft[12].fullname \n end \n unless passgoalinesLeft[13].nil? \n pgll14 = passgoalinesLeft[13].fullname \n end \n unless passgoalinesLeft[14].nil? \n pgll15 = passgoalinesLeft[14].fullname \n end \n\n #Pass Right Hash\n unless passgoalinesRight[0].nil? \n pglr1 = passgoalinesRight[0].fullname \n end\n unless passgoalinesRight[1].nil? \n pglr2 = passgoalinesRight[1].fullname \n end\n unless passgoalinesRight[2].nil? \n pglr3 = passgoalinesRight[2].fullname \n end\n unless passgoalinesRight[3].nil? \n pglr4 = passgoalinesRight[3].fullname \n end\n unless passgoalinesRight[4].nil? \n pglr5 = passgoalinesRight[4].fullname \n end\n unless passgoalinesRight[5].nil? \n pglr6 = passgoalinesRight[5].fullname \n end\n unless passgoalinesRight[6].nil? \n pglr7 = passgoalinesRight[6].fullname \n end \n unless passgoalinesRight[7].nil? \n pglr8 = passgoalinesRight[7].fullname \n end\n unless passgoalinesRight[8].nil? \n pglr9 = passgoalinesRight[8].fullname \n end\n unless passgoalinesRight[9].nil? \n pglr10 = passgoalinesRight[9].fullname \n end\n unless passgoalinesRight[10].nil? \n pglr11 = passgoalinesRight[10].fullname \n end\n unless passgoalinesRight[11].nil? \n pglr12 = passgoalinesRight[11].fullname \n end\n unless passgoalinesRight[12].nil? \n pglr13 = passgoalinesRight[12].fullname \n end\n unless passgoalinesRight[13].nil? \n pglr14 = passgoalinesRight[13].fullname \n end \n unless passgoalinesRight[14].nil? \n pglr15 = passgoalinesRight[14].fullname \n end \n\n #Number of user's run plays in situation 10\n num_gliner = self.user.s_name10_num_run\n\n #Left Hash\n # glinel_s0 \n if num_gliner > 0\n glinel_s0 = self.user.s_name10 + ' - Run'\n else\n glinel_s0 = self.user.s_name10 + ' - Pass'\n end\n\n #glinel_s1 \n if num_gliner > 0\n glinel_s1 = rgll1\n else\n glinel_s1 = pgll1\n end\n\n #glinel_s2\n if num_gliner == 0\n glinel_s2 = pgll2\n elsif num_gliner == 1\n glinel_s2 = self.user.s_name10 + ' - Pass'\n else num_gliner > 1\n glinel_s2 = rgll2\n end\n\n #glinel_s3\n case num_gliner\n when 0 then glinel_s3 = pgll3 \n when 1 then glinel_s3 = pgll1\n when 2 then glinel_s3 = self.user.s_name10 + ' - Pass'\n when 3..100 then glinel_s3 = rgll3\n end\n\n #glinel_s4\n case num_gliner\n when 0 then glinel_s4 = pgll4 \n when 1 then glinel_s4 = pgll2\n when 2 then glinel_s4 = pgll1\n when 3 then glinel_s4 = self.user.s_name10 + ' - Pass'\n when 4..100 then glinel_s4 = rgll4\n end\n\n #glinel_s5\n case num_gliner\n when 0 then glinel_s5 = pgll5 \n when 1 then glinel_s5 = pgll3\n when 2 then glinel_s5 = pgll2\n when 3 then glinel_s5 = pgll1\n when 4 then glinel_s5 = self.user.s_name10 + ' - Pass'\n when 5..100 then glinel_s5 = rgll5\n end\n\n #glinel_s6\n case num_gliner\n when 0 then glinel_s6 = pgll6 \n when 1 then glinel_s6 = pgll4\n when 2 then glinel_s6 = pgll3\n when 3 then glinel_s6 = pgll2\n when 4 then glinel_s6 = pgll1\n when 5 then glinel_s6 = self.user.s_name10 + ' - Pass'\n when 6..100 then glinel_s6 = rgll6\n end\n\n #glinel_s7\n case num_gliner\n when 0 then glinel_s7 = pgll7 \n when 1 then glinel_s7 = pgll5\n when 2 then glinel_s7 = pgll4\n when 3 then glinel_s7 = pgll3\n when 4 then glinel_s7 = pgll2\n when 5 then glinel_s7 = pgll1\n when 6 then glinel_s7 = self.user.s_name10 + ' - Pass'\n when 7..100 then glinel_s7 = rgll7\n end\n\n #glinel_s8\n case num_gliner\n when 0 then glinel_s8 = pgll8 \n when 1 then glinel_s8 = pgll6\n when 2 then glinel_s8 = pgll5\n when 3 then glinel_s8 = pgll4\n when 4 then glinel_s8 = pgll3\n when 5 then glinel_s8 = pgll2\n when 6 then glinel_s8 = pgll1\n when 7 then glinel_s8 = self.user.s_name10 + ' - Pass'\n when 8..100 then glinel_s8 = rgll8\n end\n\n #glinel_s9\n case num_gliner\n when 0 then glinel_s9 = pgll9 \n when 1 then glinel_s9 = pgll7\n when 2 then glinel_s9 = pgll6\n when 3 then glinel_s9 = pgll5\n when 4 then glinel_s9 = pgll4\n when 5 then glinel_s9 = pgll3\n when 6 then glinel_s9 = pgll2\n when 7 then glinel_s9 = pgll1\n when 8 then glinel_s9 = self.user.s_name10 + ' - Pass'\n when 9..100 then glinel_s9 = rgll9\n end\n\n #glinel_s10\n case num_gliner\n when 0 then glinel_s10 = pgll10 \n when 1 then glinel_s10 = pgll8\n when 2 then glinel_s10 = pgll7\n when 3 then glinel_s10 = pgll6\n when 4 then glinel_s10 = pgll5\n when 5 then glinel_s10 = pgll4\n when 6 then glinel_s10 = pgll3\n when 7 then glinel_s10 = pgll2\n when 8 then glinel_s10 = pgll1\n when 9 then glinel_s10 = self.user.s_name10 + ' - Pass'\n when 10..100 then glinel_s10 = rgll10\n end\n\n #glinel_s11\n case num_gliner\n when 0 then glinel_s11 = pgll11 \n when 1 then glinel_s11 = pgll9\n when 2 then glinel_s11 = pgll8\n when 3 then glinel_s11 = pgll7\n when 4 then glinel_s11 = pgll6\n when 5 then glinel_s11 = pgll5\n when 6 then glinel_s11 = pgll4\n when 7 then glinel_s11 = pgll3\n when 8 then glinel_s11 = pgll2\n when 9 then glinel_s11 = pgll1\n when 10 then glinel_s11 = self.user.s_name10 + ' - Pass'\n when 11..100 then glinel_s11 = rgll11\n end\n\n #glinel_s12\n case num_gliner\n when 0 then glinel_s12 = pgll12 \n when 1 then glinel_s12 = pgll10\n when 2 then glinel_s12 = pgll9\n when 3 then glinel_s12 = pgll8\n when 4 then glinel_s12 = pgll7\n when 5 then glinel_s12 = pgll6\n when 6 then glinel_s12 = pgll5\n when 7 then glinel_s12 = pgll4\n when 8 then glinel_s12 = pgll3\n when 9 then glinel_s12 = pgll2\n when 10 then glinel_s12 = pgll1\n when 11 then glinel_s12 = self.user.s_name10 + ' - Pass'\n when 12..100 then glinel_s12 = rgll12\n end\n\n #glinel_s13\n case num_gliner\n when 0 then glinel_s13 = pgll13 \n when 1 then glinel_s13 = pgll11\n when 2 then glinel_s13 = pgll10\n when 3 then glinel_s13 = pgll9\n when 4 then glinel_s13 = pgll8\n when 5 then glinel_s13 = pgll7\n when 6 then glinel_s13 = pgll6\n when 7 then glinel_s13 = pgll5\n when 8 then glinel_s13 = pgll4\n when 9 then glinel_s13 = pgll3\n when 10 then glinel_s13 = pgll2\n when 11 then glinel_s13 = pgll1\n when 12 then glinel_s13 = self.user.s_name10 + ' - Pass'\n when 13..100 then glinel_s13 = rgll13\n end\n\n #glinel_s14\n case num_gliner\n when 0 then glinel_s14 = pgll14 \n when 1 then glinel_s14 = pgll12\n when 2 then glinel_s14 = pgll11\n when 3 then glinel_s14 = pgll10\n when 4 then glinel_s14 = pgll9\n when 5 then glinel_s14 = pgll8\n when 6 then glinel_s14 = pgll7\n when 7 then glinel_s14 = pgll6\n when 8 then glinel_s14 = pgll5\n when 9 then glinel_s14 = pgll4\n when 10 then glinel_s14 = pgll3\n when 11 then glinel_s14 = pgll2\n when 12 then glinel_s14 = pgll1 \n when 13 then glinel_s14 = self.user.s_name10 + ' - Pass'\n when 14..100 then glinel_s14 = rgll14\n end\n\n #glinel_s15\n case num_gliner\n when 0 then glinel_s15 = pgll15 \n when 1 then glinel_s15 = pgll13\n when 2 then glinel_s15 = pgll12\n when 3 then glinel_s15 = pgll11\n when 4 then glinel_s15 = pgll10\n when 5 then glinel_s15 = pgll9\n when 6 then glinel_s15 = pgll8\n when 7 then glinel_s15 = pgll7\n when 8 then glinel_s15 = pgll6\n when 9 then glinel_s15 = pgll5\n when 10 then glinel_s15 = pgll4\n when 11 then glinel_s15 = pgll3\n when 12 then glinel_s15 = pgll2\n when 13 then glinel_s15 = pgll1 \n when 14..100 then glinel_s15 = rgll15\n end \n\n\n #Right Hash\n # gliner_s0 would always be blank\n\n #gliner_s1 \n if num_gliner > 0\n gliner_s1 = rglr1\n else\n gliner_s1 = pglr1\n end\n\n #gliner_s2\n if num_gliner == 0\n gliner_s2 = pglr2\n elsif num_gliner == 1\n gliner_s2 = ''\n else num_gliner > 1\n gliner_s2 = rglr2\n end\n\n #gliner_s3\n case num_gliner\n when 0 then gliner_s3 = pglr3 \n when 1 then gliner_s3 = pglr1\n when 2 then gliner_s3 = ''\n when 3..100 then gliner_s3 = rglr3\n end\n\n #gliner_s4\n case num_gliner\n when 0 then gliner_s4 = pglr4 \n when 1 then gliner_s4 = pglr2\n when 2 then gliner_s4 = pglr1\n when 3 then ''\n when 4..100 then gliner_s4 = rglr4\n end\n\n #gliner_s5\n case num_gliner\n when 0 then gliner_s5 = pglr5 \n when 1 then gliner_s5 = pglr3\n when 2 then gliner_s5 = pglr2\n when 3 then gliner_s5 = pglr1\n when 4 then gliner_s5 = ''\n when 5..100 then gliner_s5 = rglr5\n end\n\n #gliner_s6\n case num_gliner\n when 0 then gliner_s6 = pglr6 \n when 1 then gliner_s6 = pglr4\n when 2 then gliner_s6 = pglr3\n when 3 then gliner_s6 = pglr2\n when 4 then gliner_s6 = pglr1\n when 5 then gliner_s6 = ''\n when 6..100 then gliner_s6 = rglr6\n end\n\n #gliner_s7\n case num_gliner\n when 0 then gliner_s7 = pglr7 \n when 1 then gliner_s7 = pglr5\n when 2 then gliner_s7 = pglr4\n when 3 then gliner_s7 = pglr3\n when 4 then gliner_s7 = pglr2\n when 5 then gliner_s7 = pglr1\n when 6 then gliner_s7 = ''\n when 7..100 then gliner_s7 = rglr7\n end\n\n #gliner_s8\n case num_gliner\n when 0 then gliner_s8 = pglr8 \n when 1 then gliner_s8 = pglr6\n when 2 then gliner_s8 = pglr5\n when 3 then gliner_s8 = pglr4\n when 4 then gliner_s8 = pglr3\n when 5 then gliner_s8 = pglr2\n when 6 then gliner_s8 = pglr1\n when 7 then gliner_s8 = ''\n when 8..100 then gliner_s8 = rglr8\n end\n\n #gliner_s9\n case num_gliner\n when 0 then gliner_s9 = pglr9 \n when 1 then gliner_s9 = pglr7\n when 2 then gliner_s9 = pglr6\n when 3 then gliner_s9 = pglr5\n when 4 then gliner_s9 = pglr4\n when 5 then gliner_s9 = pglr3\n when 6 then gliner_s9 = pglr2\n when 7 then gliner_s9 = pglr1\n when 8 then gliner_s9 = ''\n when 9..100 then gliner_s9 = rglr9\n end\n\n #gliner_s10\n case num_gliner\n when 0 then gliner_s10 = pglr10 \n when 1 then gliner_s10 = pglr8\n when 2 then gliner_s10 = pglr7\n when 3 then gliner_s10 = pglr6\n when 4 then gliner_s10 = pglr5\n when 5 then gliner_s10 = pglr4\n when 6 then gliner_s10 = pglr3\n when 7 then gliner_s10 = pglr2\n when 8 then gliner_s10 = pglr1\n when 9 then gliner_s10 = ''\n when 10..100 then gliner_s10 = rglr10\n end\n\n #gliner_s11\n case num_gliner\n when 0 then gliner_s11 = pglr11 \n when 1 then gliner_s11 = pglr9\n when 2 then gliner_s11 = pglr8\n when 3 then gliner_s11 = pglr7\n when 4 then gliner_s11 = pglr6\n when 5 then gliner_s11 = pglr5\n when 6 then gliner_s11 = pglr4\n when 7 then gliner_s11 = pglr3\n when 8 then gliner_s11 = pglr2\n when 9 then gliner_s11 = pglr1\n when 10 then gliner_s11 = ''\n when 11..100 then gliner_s11 = rglr11\n end\n\n #gliner_s12\n case num_gliner\n when 0 then gliner_s12 = pglr12 \n when 1 then gliner_s12 = pglr10\n when 2 then gliner_s12 = pglr9\n when 3 then gliner_s12 = pglr8\n when 4 then gliner_s12 = pglr7\n when 5 then gliner_s12 = pglr6\n when 6 then gliner_s12 = pglr5\n when 7 then gliner_s12 = pglr4\n when 8 then gliner_s12 = pglr3\n when 9 then gliner_s12 = pglr2\n when 10 then gliner_s12 = pglr1\n when 11 then gliner_s12 = ''\n when 12..100 then gliner_s12 = rglr12\n end\n\n #gliner_s13\n case num_gliner\n when 0 then gliner_s13 = pglr13 \n when 1 then gliner_s13 = pglr11\n when 2 then gliner_s13 = pglr10\n when 3 then gliner_s13 = pglr9\n when 4 then gliner_s13 = pglr8\n when 5 then gliner_s13 = pglr7\n when 6 then gliner_s13 = pglr6\n when 7 then gliner_s13 = pglr5\n when 8 then gliner_s13 = pglr4\n when 9 then gliner_s13 = pglr3\n when 10 then gliner_s13 = pglr2\n when 11 then gliner_s13 = pglr1\n when 12 then gliner_s13 = ''\n when 13..100 then gliner_s13 = rglr13\n end\n\n #gliner_s14\n case num_gliner\n when 0 then gliner_s14 = pglr14 \n when 1 then gliner_s14 = pglr12\n when 2 then gliner_s14 = pglr11\n when 3 then gliner_s14 = pglr10\n when 4 then gliner_s14 = pglr9\n when 5 then gliner_s14 = pglr8\n when 6 then gliner_s14 = pglr7\n when 7 then gliner_s14 = pglr6\n when 8 then gliner_s14 = pglr5\n when 9 then gliner_s14 = pglr4\n when 10 then gliner_s14 = pglr3\n when 11 then gliner_s14 = pglr2\n when 12 then gliner_s14 = pglr1 \n when 13 then gliner_s14 = ''\n when 14..100 then gliner_s14 = rglr14\n end\n\n #gliner_s15\n case num_gliner\n when 0 then gliner_s15 = pglr15 \n when 1 then gliner_s15 = pglr13\n when 2 then gliner_s15 = pglr12\n when 3 then gliner_s15 = pglr11\n when 4 then gliner_s15 = pglr10\n when 5 then gliner_s15 = pglr9\n when 6 then gliner_s15 = pglr8\n when 7 then gliner_s15 = pglr7\n when 8 then gliner_s15 = pglr6\n when 9 then gliner_s15 = pglr5\n when 10 then gliner_s15 = pglr4\n when 11 then gliner_s15 = pglr3\n when 12 then gliner_s15 = pglr2\n when 13 then gliner_s15 = pglr1 \n when 14..100 then gliner_s15 = rglr15\n end \n #----------End Goaline---------- \n\n #----------Coming Out----------\n comingOuts = event.plays.where('situation11 = ?', true)\n \n runComingOuts = comingOuts.where('play_type = ?', 'Run')\n runComingOutsLeft = runComingOuts.where('hash_mark = ?', 'Left')\n runComingOutsRight = runComingOuts.where('hash_mark = ?', 'Right')\n \n passComingOuts = comingOuts.where('play_type = ?', 'Pass')\n passComingOutsLeft = passComingOuts.where('hash_mark = ?', 'Left')\n passComingOutsRight = passComingOuts.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runComingOutsLeft[0].nil? \n rcol1 = runComingOutsLeft[0].fullname \n end\n unless runComingOutsLeft[1].nil? \n rcol2 = runComingOutsLeft[1].fullname \n end\n unless runComingOutsLeft[2].nil? \n rcol3 = runComingOutsLeft[2].fullname \n end\n unless runComingOutsLeft[3].nil? \n rcol4 = runComingOutsLeft[3].fullname \n end\n unless runComingOutsLeft[4].nil? \n rcol5 = runComingOutsLeft[4].fullname\n end\n unless runComingOutsLeft[5].nil? \n rcol6 = runComingOutsLeft[5].fullname \n end\n unless runComingOutsLeft[6].nil? \n rcol7 = runComingOutsLeft[6].fullname\n end \n unless runComingOutsLeft[7].nil? \n rcol8 = runComingOutsLeft[7].fullname \n end\n unless runComingOutsLeft[8].nil? \n rcol9 = runComingOutsLeft[8].fullname \n end\n unless runComingOutsLeft[9].nil? \n rcol10 = runComingOutsLeft[9].fullname \n end\n unless runComingOutsLeft[10].nil? \n rcol11 = runComingOutsLeft[10].fullname \n end\n unless runComingOutsLeft[11].nil? \n rcol12 = runComingOutsLeft[11].fullname\n end\n unless runComingOutsLeft[12].nil? \n rcol13 = runComingOutsLeft[12].fullname \n end\n unless runComingOutsLeft[13].nil? \n rcol14 = runComingOutsLeft[13].fullname\n end \n unless runComingOutsLeft[14].nil? \n rcol15 = runComingOutsLeft[14].fullname\n end \n\n #Run Right Hash\n unless runComingOutsRight[0].nil? \n rcor1 = runComingOutsRight[0].fullname \n end\n unless runComingOutsRight[1].nil? \n rcor2 = runComingOutsRight[1].fullname \n end\n unless runComingOutsRight[2].nil? \n rcor3 = runComingOutsRight[2].fullname \n end\n unless runComingOutsRight[3].nil? \n rcor4 = runComingOutsRight[3].fullname \n end\n unless runComingOutsRight[4].nil? \n rcor5 = runComingOutsRight[4].fullname\n end\n unless runComingOutsRight[5].nil? \n rcor6 = runComingOutsRight[5].fullname \n end\n unless runComingOutsRight[6].nil? \n rcor7 = runComingOutsRight[6].fullname\n end \n unless runComingOutsRight[7].nil? \n rcor8 = runComingOutsRight[7].fullname \n end\n unless runComingOutsRight[8].nil? \n rcor9 = runComingOutsRight[8].fullname \n end\n unless runComingOutsRight[9].nil? \n rcor10 = runComingOutsRight[9].fullname \n end\n unless runComingOutsRight[10].nil? \n rcor11 = runComingOutsRight[10].fullname \n end\n unless runComingOutsRight[11].nil? \n rcor12 = runComingOutsRight[11].fullname\n end\n unless runComingOutsRight[12].nil? \n rcor13 = runComingOutsRight[12].fullname \n end\n unless runComingOutsRight[13].nil? \n rcor14 = runComingOutsRight[13].fullname\n end\n unless runComingOutsRight[14].nil? \n rcor15 = runComingOutsRight[14].fullname\n end\n\n #Pass Left Hash\n unless passComingOutsLeft[0].nil? \n pcol1 = passComingOutsLeft[0].fullname \n end\n unless passComingOutsLeft[1].nil? \n pcol2 = passComingOutsLeft[1].fullname \n end\n unless passComingOutsLeft[2].nil? \n pcol3 = passComingOutsLeft[2].fullname \n end\n unless passComingOutsLeft[3].nil? \n pcol4 = passComingOutsLeft[3].fullname \n end\n unless passComingOutsLeft[4].nil? \n pcol5 = passComingOutsLeft[4].fullname \n end\n unless passComingOutsLeft[5].nil? \n pcol6 = passComingOutsLeft[5].fullname \n end \n unless passComingOutsLeft[6].nil? \n pcol7 = passComingOutsLeft[6].fullname \n end \n unless passComingOutsLeft[7].nil? \n pcol8 = passComingOutsLeft[7].fullname \n end\n unless passComingOutsLeft[8].nil? \n pcol9 = passComingOutsLeft[8].fullname \n end\n unless passComingOutsLeft[9].nil? \n pcol10 = passComingOutsLeft[9].fullname \n end\n unless passComingOutsLeft[10].nil? \n pcol11 = passComingOutsLeft[10].fullname \n end\n unless passComingOutsLeft[11].nil? \n pcol12 = passComingOutsLeft[11].fullname \n end\n unless passComingOutsLeft[12].nil? \n pcol13 = passComingOutsLeft[12].fullname \n end \n unless passComingOutsLeft[13].nil? \n pcol14 = passComingOutsLeft[13].fullname \n end\n unless passComingOutsLeft[14].nil? \n pcol15 = passComingOutsLeft[14].fullname \n end\n\n #Pass Right Hash\n unless passComingOutsRight[0].nil? \n pcor1 = passComingOutsRight[0].fullname \n end\n unless passComingOutsRight[1].nil? \n pcor2 = passComingOutsRight[1].fullname \n end\n unless passComingOutsRight[2].nil? \n pcor3 = passComingOutsRight[2].fullname \n end\n unless passComingOutsRight[3].nil? \n pcor4 = passComingOutsRight[3].fullname \n end\n unless passComingOutsRight[4].nil? \n pcor5 = passComingOutsRight[4].fullname \n end\n unless passComingOutsRight[5].nil? \n pcor6 = passComingOutsRight[5].fullname \n end\n unless passComingOutsRight[6].nil? \n pcor7 = passComingOutsRight[6].fullname \n end \n unless passComingOutsRight[7].nil? \n pcor8 = passComingOutsRight[7].fullname \n end\n unless passComingOutsRight[8].nil? \n pcor9 = passComingOutsRight[8].fullname \n end\n unless passComingOutsRight[9].nil? \n pcor10 = passComingOutsRight[9].fullname \n end\n unless passComingOutsRight[10].nil? \n pcor11 = passComingOutsRight[10].fullname \n end\n unless passComingOutsRight[11].nil? \n pcor12 = passComingOutsRight[11].fullname \n end\n unless passComingOutsRight[12].nil? \n pcor13 = passComingOutsRight[12].fullname \n end\n unless passComingOutsRight[13].nil? \n pcor14 = passComingOutsRight[13].fullname \n end \n unless passComingOutsRight[14].nil? \n pcor15 = passComingOutsRight[14].fullname \n end \n\n #Number of user's run plays in situation 11\n num_cor = self.user.s_name11_num_run\n\n #Left Hash\n # coutl_s0 \n if num_cor > 0\n coutl_s0 = self.user.s_name11 + ' - Run'\n else\n coutl_s0 = self.user.s_name11 + ' - Pass'\n end\n\n #coutl_s1 \n if num_cor > 0\n coutl_s1 = rcol1\n else\n coutl_s1 = pcol1\n end\n\n #coutl_s2\n if num_cor == 0\n coutl_s2 = pcol2\n elsif num_cor == 1\n coutl_s2 = self.user.s_name11 + ' - Pass'\n else num_cor > 1\n coutl_s2 = rcol2\n end\n\n #coutl_s3\n case num_cor\n when 0 then coutl_s3 = pcol3 \n when 1 then coutl_s3 = pcol1\n when 2 then coutl_s3 = self.user.s_name11 + ' - Pass'\n when 3..100 then coutl_s3 = rcol3\n end\n\n #coutl_s4\n case num_cor\n when 0 then coutl_s4 = pcol4 \n when 1 then coutl_s4 = pcol2\n when 2 then coutl_s4 = pcol1\n when 3 then coutl_s4 = self.user.s_name11 + ' - Pass'\n when 4..100 then coutl_s4 = rcol4\n end\n\n #coutl_s5\n case num_cor\n when 0 then coutl_s5 = pcol5 \n when 1 then coutl_s5 = pcol3\n when 2 then coutl_s5 = pcol2\n when 3 then coutl_s5 = pcol1\n when 4 then coutl_s5 = self.user.s_name11 + ' - Pass'\n when 5..100 then coutl_s5 = rcol5\n end\n\n #coutl_s6\n case num_cor\n when 0 then coutl_s6 = pcol6 \n when 1 then coutl_s6 = pcol4\n when 2 then coutl_s6 = pcol3\n when 3 then coutl_s6 = pcol2\n when 4 then coutl_s6 = pcol1\n when 5 then coutl_s6 = self.user.s_name11 + ' - Pass'\n when 6..100 then coutl_s6 = rcol6\n end\n\n #coutl_s7\n case num_cor\n when 0 then coutl_s7 = pcol7 \n when 1 then coutl_s7 = pcol5\n when 2 then coutl_s7 = pcol4\n when 3 then coutl_s7 = pcol3\n when 4 then coutl_s7 = pcol2\n when 5 then coutl_s7 = pcol1\n when 6 then coutl_s7 = self.user.s_name11 + ' - Pass'\n when 7..100 then coutl_s7 = rcol7\n end\n\n #coutl_s8\n case num_cor\n when 0 then coutl_s8 = pcol8 \n when 1 then coutl_s8 = pcol6\n when 2 then coutl_s8 = pcol5\n when 3 then coutl_s8 = pcol4\n when 4 then coutl_s8 = pcol3\n when 5 then coutl_s8 = pcol2\n when 6 then coutl_s8 = pcol1\n when 7 then coutl_s8 = self.user.s_name11 + ' - Pass'\n when 8..100 then coutl_s8 = rcol8\n end\n\n #coutl_s9\n case num_cor\n when 0 then coutl_s9 = pcol9 \n when 1 then coutl_s9 = pcol7\n when 2 then coutl_s9 = pcol6\n when 3 then coutl_s9 = pcol5\n when 4 then coutl_s9 = pcol4\n when 5 then coutl_s9 = pcol3\n when 6 then coutl_s9 = pcol2\n when 7 then coutl_s9 = pcol1\n when 8 then coutl_s9 = self.user.s_name11 + ' - Pass'\n when 9..100 then coutl_s9 = rcol9\n end\n\n #coutl_s10\n case num_cor\n when 0 then coutl_s10 = pcol10 \n when 1 then coutl_s10 = pcol8\n when 2 then coutl_s10 = pcol7\n when 3 then coutl_s10 = pcol6\n when 4 then coutl_s10 = pcol5\n when 5 then coutl_s10 = pcol4\n when 6 then coutl_s10 = pcol3\n when 7 then coutl_s10 = pcol2\n when 8 then coutl_s10 = pcol1\n when 9 then coutl_s10 = self.user.s_name11 + ' - Pass'\n when 10..100 then coutl_s10 = rcol10\n end\n\n #coutl_s11\n case num_cor\n when 0 then coutl_s11 = pcol11 \n when 1 then coutl_s11 = pcol9\n when 2 then coutl_s11 = pcol8\n when 3 then coutl_s11 = pcol7\n when 4 then coutl_s11 = pcol6\n when 5 then coutl_s11 = pcol5\n when 6 then coutl_s11 = pcol4\n when 7 then coutl_s11 = pcol3\n when 8 then coutl_s11 = pcol2\n when 9 then coutl_s11 = pcol1\n when 10 then coutl_s11 = self.user.s_name11 + ' - Pass'\n when 11..100 then coutl_s11 = rcol11\n end\n\n #coutl_s12\n case num_cor\n when 0 then coutl_s12 = pcol12 \n when 1 then coutl_s12 = pcol10\n when 2 then coutl_s12 = pcol9\n when 3 then coutl_s12 = pcol8\n when 4 then coutl_s12 = pcol7\n when 5 then coutl_s12 = pcol6\n when 6 then coutl_s12 = pcol5\n when 7 then coutl_s12 = pcol4\n when 8 then coutl_s12 = pcol3\n when 9 then coutl_s12 = pcol2\n when 10 then coutl_s12 = pcol1\n when 11 then coutl_s12 = self.user.s_name11 + ' - Pass'\n when 12..100 then coutl_s12 = rcol12\n end\n\n #coutl_s13\n case num_cor\n when 0 then coutl_s13 = pcol13 \n when 1 then coutl_s13 = pcol11\n when 2 then coutl_s13 = pcol10\n when 3 then coutl_s13 = pcol9\n when 4 then coutl_s13 = pcol8\n when 5 then coutl_s13 = pcol7\n when 6 then coutl_s13 = pcol6\n when 7 then coutl_s13 = pcol5\n when 8 then coutl_s13 = pcol4\n when 9 then coutl_s13 = pcol3\n when 10 then coutl_s13 = pcol2\n when 11 then coutl_s13 = pcol1\n when 12 then coutl_s13 = self.user.s_name11 + ' - Pass'\n when 13..100 then coutl_s13 = rcol13\n end\n\n #coutl_s14\n case num_cor\n when 0 then coutl_s14 = pcol14 \n when 1 then coutl_s14 = pcol12\n when 2 then coutl_s14 = pcol11\n when 3 then coutl_s14 = pcol10\n when 4 then coutl_s14 = pcol9\n when 5 then coutl_s14 = pcol8\n when 6 then coutl_s14 = pcol7\n when 7 then coutl_s14 = pcol6\n when 8 then coutl_s14 = pcol5\n when 9 then coutl_s14 = pcol4\n when 10 then coutl_s14 = pcol3\n when 11 then coutl_s14 = pcol2\n when 12 then coutl_s14 = pcol1 \n when 13 then coutl_s14 = self.user.s_name11 + ' - Pass'\n when 14..100 then coutl_s14 = rcol14\n end\n\n #coutl_s15\n case num_cor\n when 0 then coutl_s15 = pcol15 \n when 1 then coutl_s15 = pcol13\n when 2 then coutl_s15 = pcol12\n when 3 then coutl_s15 = pcol11\n when 4 then coutl_s15 = pcol10\n when 5 then coutl_s15 = pcol9\n when 6 then coutl_s15 = pcol8\n when 7 then coutl_s15 = pcol7\n when 8 then coutl_s15 = pcol6\n when 9 then coutl_s15 = pcol5\n when 10 then coutl_s15 = pcol4\n when 11 then coutl_s15 = pcol3\n when 12 then coutl_s15 = pcol2\n when 13 then coutl_s15 = pcol1 \n when 14..100 then coutl_s15 = rcol15\n end \n\n\n #Right Hash\n # coutr_s0 would always be blank\n\n #coutr_s1 \n if num_cor > 0\n coutr_s1 = rcor1\n else\n coutr_s1 = pcor1\n end\n\n #coutr_s2\n if num_cor == 0\n coutr_s2 = pcor2\n elsif num_cor == 1\n coutr_s2 = ''\n else num_cor > 1\n coutr_s2 = rcor2\n end\n\n #coutr_s3\n case num_cor\n when 0 then coutr_s3 = pcor3 \n when 1 then coutr_s3 = pcor1\n when 2 then coutr_s3 = ''\n when 3..100 then coutr_s3 = rcor3\n end\n\n #coutr_s4\n case num_cor\n when 0 then coutr_s4 = pcor4 \n when 1 then coutr_s4 = pcor2\n when 2 then coutr_s4 = pcor1\n when 3 then ''\n when 4..100 then coutr_s4 = rcor4\n end\n\n #coutr_s5\n case num_cor\n when 0 then coutr_s5 = pcor5 \n when 1 then coutr_s5 = pcor3\n when 2 then coutr_s5 = pcor2\n when 3 then coutr_s5 = pcor1\n when 4 then coutr_s5 = ''\n when 5..100 then coutr_s5 = rcor5\n end\n\n #coutr_s6\n case num_cor\n when 0 then coutr_s6 = pcor6 \n when 1 then coutr_s6 = pcor4\n when 2 then coutr_s6 = pcor3\n when 3 then coutr_s6 = pcor2\n when 4 then coutr_s6 = pcor1\n when 5 then coutr_s6 = ''\n when 6..100 then coutr_s6 = rcor6\n end\n\n #coutr_s7\n case num_cor\n when 0 then coutr_s7 = pcor7 \n when 1 then coutr_s7 = pcor5\n when 2 then coutr_s7 = pcor4\n when 3 then coutr_s7 = pcor3\n when 4 then coutr_s7 = pcor2\n when 5 then coutr_s7 = pcor1\n when 6 then coutr_s7 = ''\n when 7..100 then coutr_s7 = rcor7\n end\n\n #coutr_s8\n case num_cor\n when 0 then coutr_s8 = pcor8 \n when 1 then coutr_s8 = pcor6\n when 2 then coutr_s8 = pcor5\n when 3 then coutr_s8 = pcor4\n when 4 then coutr_s8 = pcor3\n when 5 then coutr_s8 = pcor2\n when 6 then coutr_s8 = pcor1\n when 7 then coutr_s8 = ''\n when 8..100 then coutr_s8 = rcor8\n end\n\n #coutr_s9\n case num_cor\n when 0 then coutr_s9 = pcor9 \n when 1 then coutr_s9 = pcor7\n when 2 then coutr_s9 = pcor6\n when 3 then coutr_s9 = pcor5\n when 4 then coutr_s9 = pcor4\n when 5 then coutr_s9 = pcor3\n when 6 then coutr_s9 = pcor2\n when 7 then coutr_s9 = pcor1\n when 8 then coutr_s9 = ''\n when 9..100 then coutr_s9 = rcor9\n end\n\n #coutr_s10\n case num_cor\n when 0 then coutr_s10 = pcor10 \n when 1 then coutr_s10 = pcor8\n when 2 then coutr_s10 = pcor7\n when 3 then coutr_s10 = pcor6\n when 4 then coutr_s10 = pcor5\n when 5 then coutr_s10 = pcor4\n when 6 then coutr_s10 = pcor3\n when 7 then coutr_s10 = pcor2\n when 8 then coutr_s10 = pcor1\n when 9 then coutr_s10 = ''\n when 10..100 then coutr_s10 = rcor10\n end\n\n #coutr_s11\n case num_cor\n when 0 then coutr_s11 = pcor11 \n when 1 then coutr_s11 = pcor9\n when 2 then coutr_s11 = pcor8\n when 3 then coutr_s11 = pcor7\n when 4 then coutr_s11 = pcor6\n when 5 then coutr_s11 = pcor5\n when 6 then coutr_s11 = pcor4\n when 7 then coutr_s11 = pcor3\n when 8 then coutr_s11 = pcor2\n when 9 then coutr_s11 = pcor1\n when 10 then coutr_s11 = ''\n when 11..100 then coutr_s11 = rcor11\n end\n\n #coutr_s12\n case num_cor\n when 0 then coutr_s12 = pcor12 \n when 1 then coutr_s12 = pcor10\n when 2 then coutr_s12 = pcor9\n when 3 then coutr_s12 = pcor8\n when 4 then coutr_s12 = pcor7\n when 5 then coutr_s12 = pcor6\n when 6 then coutr_s12 = pcor5\n when 7 then coutr_s12 = pcor4\n when 8 then coutr_s12 = pcor3\n when 9 then coutr_s12 = pcor2\n when 10 then coutr_s12 = pcor1\n when 11 then coutr_s12 = ''\n when 12..100 then coutr_s12 = rcor12\n end\n\n #coutr_s13\n case num_cor\n when 0 then coutr_s13 = pcor13 \n when 1 then coutr_s13 = pcor11\n when 2 then coutr_s13 = pcor10\n when 3 then coutr_s13 = pcor9\n when 4 then coutr_s13 = pcor8\n when 5 then coutr_s13 = pcor7\n when 6 then coutr_s13 = pcor6\n when 7 then coutr_s13 = pcor5\n when 8 then coutr_s13 = pcor4\n when 9 then coutr_s13 = pcor3\n when 10 then coutr_s13 = pcor2\n when 11 then coutr_s13 = pcor1\n when 12 then coutr_s13 = ''\n when 13..100 then coutr_s13 = rcor13\n end\n\n #coutr_s14\n case num_cor\n when 0 then coutr_s14 = pcor14 \n when 1 then coutr_s14 = pcor12\n when 2 then coutr_s14 = pcor11\n when 3 then coutr_s14 = pcor10\n when 4 then coutr_s14 = pcor9\n when 5 then coutr_s14 = pcor8\n when 6 then coutr_s14 = pcor7\n when 7 then coutr_s14 = pcor6\n when 8 then coutr_s14 = pcor5\n when 9 then coutr_s14 = pcor4\n when 10 then coutr_s14 = pcor3\n when 11 then coutr_s14 = pcor2\n when 12 then coutr_s14 = pcor1 \n when 13 then coutr_s14 = ''\n when 14..100 then coutr_s14 = rcor14\n end\n\n #coutr_s15\n case num_cor\n when 0 then coutr_s15 = pcor15 \n when 1 then coutr_s15 = pcor13\n when 2 then coutr_s15 = pcor12\n when 3 then coutr_s15 = pcor11\n when 4 then coutr_s15 = pcor10\n when 5 then coutr_s15 = pcor9\n when 6 then coutr_s15 = pcor8\n when 7 then coutr_s15 = pcor7\n when 8 then coutr_s15 = pcor6\n when 9 then coutr_s15 = pcor5\n when 10 then coutr_s15 = pcor4\n when 11 then coutr_s15 = pcor3\n when 12 then coutr_s15 = pcor2\n when 13 then coutr_s15 = pcor1 \n when 14..100 then coutr_s15 = rcor15\n end \n #----------End Coming Out---------- \n\n #----------Custom 1----------\n customOnes = event.plays.where('situation12 = ?', true)\n \n runCustomOnes = customOnes.where('play_type = ?', 'Run')\n runCustomOnesLeft = runCustomOnes.where('hash_mark = ?', 'Left')\n runCustomOnesRight = runCustomOnes.where('hash_mark = ?', 'Right')\n \n passCustomOnes = customOnes.where('play_type = ?', 'Pass')\n passCustomOnesLeft = passCustomOnes.where('hash_mark = ?', 'Left')\n passCustomOnesRight = passCustomOnes.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runCustomOnesLeft[0].nil? \n rcuol1 = runCustomOnesLeft[0].fullname \n end\n unless runCustomOnesLeft[1].nil? \n rcuol2 = runCustomOnesLeft[1].fullname \n end\n unless runCustomOnesLeft[2].nil? \n rcuol3 = runCustomOnesLeft[2].fullname \n end\n unless runCustomOnesLeft[3].nil? \n rcuol4 = runCustomOnesLeft[3].fullname \n end\n unless runCustomOnesLeft[4].nil? \n rcuol5 = runCustomOnesLeft[4].fullname\n end\n unless runCustomOnesLeft[5].nil? \n rcuol6 = runCustomOnesLeft[5].fullname \n end\n unless runCustomOnesLeft[6].nil? \n rcuol7 = runCustomOnesLeft[6].fullname\n end \n unless runCustomOnesLeft[7].nil? \n rcuol8 = runCustomOnesLeft[7].fullname \n end\n unless runCustomOnesLeft[8].nil? \n rcuol9 = runCustomOnesLeft[8].fullname \n end\n unless runCustomOnesLeft[9].nil? \n rcuol10 = runCustomOnesLeft[9].fullname \n end\n unless runCustomOnesLeft[10].nil? \n rcuol11 = runCustomOnesLeft[10].fullname \n end\n unless runCustomOnesLeft[11].nil? \n rcuol12 = runCustomOnesLeft[11].fullname\n end\n unless runCustomOnesLeft[12].nil? \n rcuol13 = runCustomOnesLeft[12].fullname \n end\n unless runCustomOnesLeft[13].nil? \n rcuol14 = runCustomOnesLeft[13].fullname\n end \n unless runCustomOnesLeft[14].nil? \n rcuol15 = runCustomOnesLeft[14].fullname\n end \n\n #Run Right Hash\n unless runCustomOnesRight[0].nil? \n rcuor1 = runCustomOnesRight[0].fullname \n end\n unless runCustomOnesRight[1].nil? \n rcuor2 = runCustomOnesRight[1].fullname \n end\n unless runCustomOnesRight[2].nil? \n rcuor3 = runCustomOnesRight[2].fullname \n end\n unless runCustomOnesRight[3].nil? \n rcuor4 = runCustomOnesRight[3].fullname \n end\n unless runCustomOnesRight[4].nil? \n rcuor5 = runCustomOnesRight[4].fullname\n end\n unless runCustomOnesRight[5].nil? \n rcuor6 = runCustomOnesRight[5].fullname \n end\n unless runCustomOnesRight[6].nil? \n rcuor7 = runCustomOnesRight[6].fullname\n end \n unless runCustomOnesRight[7].nil? \n rcuor8 = runCustomOnesRight[7].fullname \n end\n unless runCustomOnesRight[8].nil? \n rcuor9 = runCustomOnesRight[8].fullname \n end\n unless runCustomOnesRight[9].nil? \n rcuor10 = runCustomOnesRight[9].fullname \n end\n unless runCustomOnesRight[10].nil? \n rcuor11 = runCustomOnesRight[10].fullname \n end\n unless runCustomOnesRight[11].nil? \n rcuor12 = runCustomOnesRight[11].fullname\n end\n unless runCustomOnesRight[12].nil? \n rcuor13 = runCustomOnesRight[12].fullname \n end\n unless runCustomOnesRight[13].nil? \n rcuor14 = runCustomOnesRight[13].fullname\n end \n unless runCustomOnesRight[14].nil? \n rcuor15 = runCustomOnesRight[14].fullname\n end \n\n #Pass Left Hash\n unless passCustomOnesLeft[0].nil? \n pcuol1 = passCustomOnesLeft[0].fullname \n end\n unless passCustomOnesLeft[1].nil? \n pcuol2 = passCustomOnesLeft[1].fullname \n end\n unless passCustomOnesLeft[2].nil? \n pcuol3 = passCustomOnesLeft[2].fullname \n end\n unless passCustomOnesLeft[3].nil? \n pcuol4 = passCustomOnesLeft[3].fullname \n end\n unless passCustomOnesLeft[4].nil? \n pcuol5 = passCustomOnesLeft[4].fullname \n end\n unless passCustomOnesLeft[5].nil? \n pcuol6 = passCustomOnesLeft[5].fullname \n end \n unless passCustomOnesLeft[6].nil? \n pcuol7 = passCustomOnesLeft[6].fullname \n end \n unless passCustomOnesLeft[7].nil? \n pcuol8 = passCustomOnesLeft[7].fullname \n end\n unless passCustomOnesLeft[8].nil? \n pcuol9 = passCustomOnesLeft[8].fullname \n end\n unless passCustomOnesLeft[9].nil? \n pcuol10 = passCustomOnesLeft[9].fullname \n end\n unless passCustomOnesLeft[10].nil? \n pcuol11 = passCustomOnesLeft[10].fullname \n end\n unless passCustomOnesLeft[11].nil? \n pcuol12 = passCustomOnesLeft[11].fullname \n end\n unless passCustomOnesLeft[12].nil? \n pcuol13 = passCustomOnesLeft[12].fullname \n end \n unless passCustomOnesLeft[13].nil? \n pcuol14 = passCustomOnesLeft[13].fullname \n end \n unless passCustomOnesLeft[14].nil? \n pcuol15 = passCustomOnesLeft[14].fullname \n end \n\n #Pass Right Hash\n unless passCustomOnesRight[0].nil? \n pcuor1 = passCustomOnesRight[0].fullname \n end\n unless passCustomOnesRight[1].nil? \n pcuor2 = passCustomOnesRight[1].fullname \n end\n unless passCustomOnesRight[2].nil? \n pcuor3 = passCustomOnesRight[2].fullname \n end\n unless passCustomOnesRight[3].nil? \n pcuor4 = passCustomOnesRight[3].fullname \n end\n unless passCustomOnesRight[4].nil? \n pcuor5 = passCustomOnesRight[4].fullname \n end\n unless passCustomOnesRight[5].nil? \n pcuor6 = passCustomOnesRight[5].fullname \n end\n unless passCustomOnesRight[6].nil? \n pcuor7 = passCustomOnesRight[6].fullname \n end \n unless passCustomOnesRight[7].nil? \n pcuor8 = passCustomOnesRight[7].fullname \n end\n unless passCustomOnesRight[8].nil? \n pcuor9 = passCustomOnesRight[8].fullname \n end\n unless passCustomOnesRight[9].nil? \n pcuor10 = passCustomOnesRight[9].fullname \n end\n unless passCustomOnesRight[10].nil? \n pcuor11 = passCustomOnesRight[10].fullname \n end\n unless passCustomOnesRight[11].nil? \n pcuor12 = passCustomOnesRight[11].fullname \n end\n unless passCustomOnesRight[12].nil? \n pcuor13 = passCustomOnesRight[12].fullname \n end\n unless passCustomOnesRight[13].nil? \n pcuor14 = passCustomOnesRight[13].fullname \n end \n unless passCustomOnesRight[14].nil? \n pcuor15 = passCustomOnesRight[14].fullname \n end \n\n #Number of user's run plays in situation 12\n num_cus1r = self.user.s_name12_num_run\n\n #Left Hash\n # cus1l_s0 \n if num_cus1r > 0\n cus1l_s0 = self.user.s_name12 + ' - Run'\n else\n cus1l_s0 = self.user.s_name12 + ' - Pass'\n end\n\n #cus1l_s1 \n if num_cus1r > 0\n cus1l_s1 = rcuol1\n else\n cus1l_s1 = pcuol1\n end\n\n #cus1l_s2\n if num_cus1r == 0\n cus1l_s2 = pcuol2\n elsif num_cus1r == 1\n cus1l_s2 = self.user.s_name12 + ' - Pass'\n else num_cus1r > 1\n cus1l_s2 = rcuol2\n end\n\n #cus1l_s3\n case num_cus1r\n when 0 then cus1l_s3 = pcuol3 \n when 1 then cus1l_s3 = pcuol1\n when 2 then cus1l_s3 = self.user.s_name12 + ' - Pass'\n when 3..100 then cus1l_s3 = rcuol3\n end\n\n #cus1l_s4\n case num_cus1r\n when 0 then cus1l_s4 = pcuol4 \n when 1 then cus1l_s4 = pcuol2\n when 2 then cus1l_s4 = pcuol1\n when 3 then cus1l_s4 = self.user.s_name12 + ' - Pass'\n when 4..100 then cus1l_s4 = rcuol4\n end\n\n #cus1l_s5\n case num_cus1r\n when 0 then cus1l_s5 = pcuol5 \n when 1 then cus1l_s5 = pcuol3\n when 2 then cus1l_s5 = pcuol2\n when 3 then cus1l_s5 = pcuol1\n when 4 then cus1l_s5 = self.user.s_name12 + ' - Pass'\n when 5..100 then cus1l_s5 = rcuol5\n end\n\n #cus1l_s6\n case num_cus1r\n when 0 then cus1l_s6 = pcuol6 \n when 1 then cus1l_s6 = pcuol4\n when 2 then cus1l_s6 = pcuol3\n when 3 then cus1l_s6 = pcuol2\n when 4 then cus1l_s6 = pcuol1\n when 5 then cus1l_s6 = self.user.s_name12 + ' - Pass'\n when 6..100 then cus1l_s6 = rcuol6\n end\n\n #cus1l_s7\n case num_cus1r\n when 0 then cus1l_s7 = pcuol7 \n when 1 then cus1l_s7 = pcuol5\n when 2 then cus1l_s7 = pcuol4\n when 3 then cus1l_s7 = pcuol3\n when 4 then cus1l_s7 = pcuol2\n when 5 then cus1l_s7 = pcuol1\n when 6 then cus1l_s7 = self.user.s_name12 + ' - Pass'\n when 7..100 then cus1l_s7 = rcuol7\n end\n\n #cus1l_s8\n case num_cus1r\n when 0 then cus1l_s8 = pcuol8 \n when 1 then cus1l_s8 = pcuol6\n when 2 then cus1l_s8 = pcuol5\n when 3 then cus1l_s8 = pcuol4\n when 4 then cus1l_s8 = pcuol3\n when 5 then cus1l_s8 = pcuol2\n when 6 then cus1l_s8 = pcuol1\n when 7 then cus1l_s8 = self.user.s_name12 + ' - Pass'\n when 8..100 then cus1l_s8 = rcuol8\n end\n\n #cus1l_s9\n case num_cus1r\n when 0 then cus1l_s9 = pcuol9 \n when 1 then cus1l_s9 = pcuol7\n when 2 then cus1l_s9 = pcuol6\n when 3 then cus1l_s9 = pcuol5\n when 4 then cus1l_s9 = pcuol4\n when 5 then cus1l_s9 = pcuol3\n when 6 then cus1l_s9 = pcuol2\n when 7 then cus1l_s9 = pcuol1\n when 8 then cus1l_s9 = self.user.s_name12 + ' - Pass'\n when 9..100 then cus1l_s9 = rcuol9\n end\n\n #cus1l_s10\n case num_cus1r\n when 0 then cus1l_s10 = pcuol10 \n when 1 then cus1l_s10 = pcuol8\n when 2 then cus1l_s10 = pcuol7\n when 3 then cus1l_s10 = pcuol6\n when 4 then cus1l_s10 = pcuol5\n when 5 then cus1l_s10 = pcuol4\n when 6 then cus1l_s10 = pcuol3\n when 7 then cus1l_s10 = pcuol2\n when 8 then cus1l_s10 = pcuol1\n when 9 then cus1l_s10 = self.user.s_name12 + ' - Pass'\n when 10..100 then cus1l_s10 = rcuol10\n end\n\n #cus1l_s11\n case num_cus1r\n when 0 then cus1l_s11 = pcuol11 \n when 1 then cus1l_s11 = pcuol9\n when 2 then cus1l_s11 = pcuol8\n when 3 then cus1l_s11 = pcuol7\n when 4 then cus1l_s11 = pcuol6\n when 5 then cus1l_s11 = pcuol5\n when 6 then cus1l_s11 = pcuol4\n when 7 then cus1l_s11 = pcuol3\n when 8 then cus1l_s11 = pcuol2\n when 9 then cus1l_s11 = pcuol1\n when 10 then cus1l_s11 = self.user.s_name12 + ' - Pass'\n when 11..100 then cus1l_s11 = rcuol11\n end\n\n #cus1l_s12\n case num_cus1r\n when 0 then cus1l_s12 = pcuol12 \n when 1 then cus1l_s12 = pcuol10\n when 2 then cus1l_s12 = pcuol9\n when 3 then cus1l_s12 = pcuol8\n when 4 then cus1l_s12 = pcuol7\n when 5 then cus1l_s12 = pcuol6\n when 6 then cus1l_s12 = pcuol5\n when 7 then cus1l_s12 = pcuol4\n when 8 then cus1l_s12 = pcuol3\n when 9 then cus1l_s12 = pcuol2\n when 10 then cus1l_s12 = pcuol1\n when 11 then cus1l_s12 = self.user.s_name12 + ' - Pass'\n when 12..100 then cus1l_s12 = rcuol12\n end\n\n #cus1l_s13\n case num_cus1r\n when 0 then cus1l_s13 = pcuol13 \n when 1 then cus1l_s13 = pcuol11\n when 2 then cus1l_s13 = pcuol10\n when 3 then cus1l_s13 = pcuol9\n when 4 then cus1l_s13 = pcuol8\n when 5 then cus1l_s13 = pcuol7\n when 6 then cus1l_s13 = pcuol6\n when 7 then cus1l_s13 = pcuol5\n when 8 then cus1l_s13 = pcuol4\n when 9 then cus1l_s13 = pcuol3\n when 10 then cus1l_s13 = pcuol2\n when 11 then cus1l_s13 = pcuol1\n when 12 then cus1l_s13 = self.user.s_name12 + ' - Pass'\n when 13..100 then cus1l_s13 = rcuol13\n end\n\n #cus1l_s14\n case num_cus1r\n when 0 then cus1l_s14 = pcuol14 \n when 1 then cus1l_s14 = pcuol12\n when 2 then cus1l_s14 = pcuol11\n when 3 then cus1l_s14 = pcuol10\n when 4 then cus1l_s14 = pcuol9\n when 5 then cus1l_s14 = pcuol8\n when 6 then cus1l_s14 = pcuol7\n when 7 then cus1l_s14 = pcuol6\n when 8 then cus1l_s14 = pcuol5\n when 9 then cus1l_s14 = pcuol4\n when 10 then cus1l_s14 = pcuol3\n when 11 then cus1l_s14 = pcuol2\n when 12 then cus1l_s14 = pcuol1 \n when 13 then cus1l_s14 = self.user.s_name12 + ' - Pass'\n when 14..100 then cus1l_s14 = rcuol14\n end\n\n #cus1l_s15\n case num_cus1r\n when 0 then cus1l_s15 = pcuol15 \n when 1 then cus1l_s15 = pcuol13\n when 2 then cus1l_s15 = pcuol12\n when 3 then cus1l_s15 = pcuol11\n when 4 then cus1l_s15 = pcuol10\n when 5 then cus1l_s15 = pcuol9\n when 6 then cus1l_s15 = pcuol8\n when 7 then cus1l_s15 = pcuol7\n when 8 then cus1l_s15 = pcuol6\n when 9 then cus1l_s15 = pcuol5\n when 10 then cus1l_s15 = pcuol4\n when 11 then cus1l_s15 = pcuol3\n when 12 then cus1l_s15 = pcuol2\n when 13 then cus1l_s15 = pcuol1 \n when 14..100 then cus1l_s15 = rcuol15\n end \n\n\n #Right Hash\n # cus1r_s0 would always be blank\n\n #cus1r_s1 \n if num_cus1r > 0\n cus1r_s1 = rcuor1\n else\n cus1r_s1 = pcuor1\n end\n\n #cus1r_s2\n if num_cus1r == 0\n cus1r_s2 = pcuor2\n elsif num_cus1r == 1\n cus1r_s2 = ''\n else num_cus1r > 1\n cus1r_s2 = rcuor2\n end\n\n #cus1r_s3\n case num_cus1r\n when 0 then cus1r_s3 = pcuor3 \n when 1 then cus1r_s3 = pcuor1\n when 2 then cus1r_s3 = ''\n when 3..100 then cus1r_s3 = rcuor3\n end\n\n #cus1r_s4\n case num_cus1r\n when 0 then cus1r_s4 = pcuor4 \n when 1 then cus1r_s4 = pcuor2\n when 2 then cus1r_s4 = pcuor1\n when 3 then ''\n when 4..100 then cus1r_s4 = rcuor4\n end\n\n #cus1r_s5\n case num_cus1r\n when 0 then cus1r_s5 = pcuor5 \n when 1 then cus1r_s5 = pcuor3\n when 2 then cus1r_s5 = pcuor2\n when 3 then cus1r_s5 = pcuor1\n when 4 then cus1r_s5 = ''\n when 5..100 then cus1r_s5 = rcuor5\n end\n\n #cus1r_s6\n case num_cus1r\n when 0 then cus1r_s6 = pcuor6 \n when 1 then cus1r_s6 = pcuor4\n when 2 then cus1r_s6 = pcuor3\n when 3 then cus1r_s6 = pcuor2\n when 4 then cus1r_s6 = pcuor1\n when 5 then cus1r_s6 = ''\n when 6..100 then cus1r_s6 = rcuor6\n end\n\n #cus1r_s7\n case num_cus1r\n when 0 then cus1r_s7 = pcuor7 \n when 1 then cus1r_s7 = pcuor5\n when 2 then cus1r_s7 = pcuor4\n when 3 then cus1r_s7 = pcuor3\n when 4 then cus1r_s7 = pcuor2\n when 5 then cus1r_s7 = pcuor1\n when 6 then cus1r_s7 = ''\n when 7..100 then cus1r_s7 = rcuor7\n end\n\n #cus1r_s8\n case num_cus1r\n when 0 then cus1r_s8 = pcuor8 \n when 1 then cus1r_s8 = pcuor6\n when 2 then cus1r_s8 = pcuor5\n when 3 then cus1r_s8 = pcuor4\n when 4 then cus1r_s8 = pcuor3\n when 5 then cus1r_s8 = pcuor2\n when 6 then cus1r_s8 = pcuor1\n when 7 then cus1r_s8 = ''\n when 8..100 then cus1r_s8 = rcuor8\n end\n\n #cus1r_s9\n case num_cus1r\n when 0 then cus1r_s9 = pcuor9 \n when 1 then cus1r_s9 = pcuor7\n when 2 then cus1r_s9 = pcuor6\n when 3 then cus1r_s9 = pcuor5\n when 4 then cus1r_s9 = pcuor4\n when 5 then cus1r_s9 = pcuor3\n when 6 then cus1r_s9 = pcuor2\n when 7 then cus1r_s9 = pcuor1\n when 8 then cus1r_s9 = ''\n when 9..100 then cus1r_s9 = rcuor9\n end\n\n #cus1r_s10\n case num_cus1r\n when 0 then cus1r_s10 = pcuor10 \n when 1 then cus1r_s10 = pcuor8\n when 2 then cus1r_s10 = pcuor7\n when 3 then cus1r_s10 = pcuor6\n when 4 then cus1r_s10 = pcuor5\n when 5 then cus1r_s10 = pcuor4\n when 6 then cus1r_s10 = pcuor3\n when 7 then cus1r_s10 = pcuor2\n when 8 then cus1r_s10 = pcuor1\n when 9 then cus1r_s10 = ''\n when 10..100 then cus1r_s10 = rcuor10\n end\n\n #cus1r_s11\n case num_cus1r\n when 0 then cus1r_s11 = pcuor11 \n when 1 then cus1r_s11 = pcuor9\n when 2 then cus1r_s11 = pcuor8\n when 3 then cus1r_s11 = pcuor7\n when 4 then cus1r_s11 = pcuor6\n when 5 then cus1r_s11 = pcuor5\n when 6 then cus1r_s11 = pcuor4\n when 7 then cus1r_s11 = pcuor3\n when 8 then cus1r_s11 = pcuor2\n when 9 then cus1r_s11 = pcuor1\n when 10 then cus1r_s11 = ''\n when 11..100 then cus1r_s11 = rcuor11\n end\n\n #cus1r_s12\n case num_cus1r\n when 0 then cus1r_s12 = pcuor12 \n when 1 then cus1r_s12 = pcuor10\n when 2 then cus1r_s12 = pcuor9\n when 3 then cus1r_s12 = pcuor8\n when 4 then cus1r_s12 = pcuor7\n when 5 then cus1r_s12 = pcuor6\n when 6 then cus1r_s12 = pcuor5\n when 7 then cus1r_s12 = pcuor4\n when 8 then cus1r_s12 = pcuor3\n when 9 then cus1r_s12 = pcuor2\n when 10 then cus1r_s12 = pcuor1\n when 11 then cus1r_s12 = ''\n when 12..100 then cus1r_s12 = rcuor12\n end\n\n #cus1r_s13\n case num_cus1r\n when 0 then cus1r_s13 = pcuor13 \n when 1 then cus1r_s13 = pcuor11\n when 2 then cus1r_s13 = pcuor10\n when 3 then cus1r_s13 = pcuor9\n when 4 then cus1r_s13 = pcuor8\n when 5 then cus1r_s13 = pcuor7\n when 6 then cus1r_s13 = pcuor6\n when 7 then cus1r_s13 = pcuor5\n when 8 then cus1r_s13 = pcuor4\n when 9 then cus1r_s13 = pcuor3\n when 10 then cus1r_s13 = pcuor2\n when 11 then cus1r_s13 = pcuor1\n when 12 then cus1r_s13 = ''\n when 13..100 then cus1r_s13 = rcuor13\n end\n\n #cus1r_s14\n case num_cus1r\n when 0 then cus1r_s14 = pcuor14 \n when 1 then cus1r_s14 = pcuor12\n when 2 then cus1r_s14 = pcuor11\n when 3 then cus1r_s14 = pcuor10\n when 4 then cus1r_s14 = pcuor9\n when 5 then cus1r_s14 = pcuor8\n when 6 then cus1r_s14 = pcuor7\n when 7 then cus1r_s14 = pcuor6\n when 8 then cus1r_s14 = pcuor5\n when 9 then cus1r_s14 = pcuor4\n when 10 then cus1r_s14 = pcuor3\n when 11 then cus1r_s14 = pcuor2\n when 12 then cus1r_s14 = pcuor1 \n when 13 then cus1r_s14 = ''\n when 14..100 then cus1r_s14 = rcuor14\n end\n\n #cus1r_s15\n case num_cus1r\n when 0 then cus1r_s15 = pcuor15 \n when 1 then cus1r_s15 = pcuor13\n when 2 then cus1r_s15 = pcuor12\n when 3 then cus1r_s15 = pcuor11\n when 4 then cus1r_s15 = pcuor10\n when 5 then cus1r_s15 = pcuor9\n when 6 then cus1r_s15 = pcuor8\n when 7 then cus1r_s15 = pcuor7\n when 8 then cus1r_s15 = pcuor6\n when 9 then cus1r_s15 = pcuor5\n when 10 then cus1r_s15 = pcuor4\n when 11 then cus1r_s15 = pcuor3\n when 12 then cus1r_s15 = pcuor2\n when 13 then cus1r_s15 = pcuor1 \n when 14..100 then cus1r_s15 = rcuor15\n end \n #----------End Custom 1---------- \n\n #----------Custom 2----------\n customTwos = event.plays.where('situation13 = ?', true)\n \n runCustomTwos = customTwos.where('play_type = ?', 'Run')\n runCustomTwosLeft = runCustomTwos.where('hash_mark = ?', 'Left')\n runCustomTwosRight = runCustomTwos.where('hash_mark = ?', 'Right')\n \n passCustomTwos = customTwos.where('play_type = ?', 'Pass')\n passCustomTwosLeft = passCustomTwos.where('hash_mark = ?', 'Left')\n passCustomTwosRight = passCustomTwos.where('hash_mark = ?', 'Right')\n\n #Run Left Hash\n unless runCustomTwosLeft[0].nil? \n rcutl1 = runCustomTwosLeft[0].fullname \n end\n unless runCustomTwosLeft[1].nil? \n rcutl2 = runCustomTwosLeft[1].fullname \n end\n unless runCustomTwosLeft[2].nil? \n rcutl3 = runCustomTwosLeft[2].fullname \n end\n unless runCustomTwosLeft[3].nil? \n rcutl4 = runCustomTwosLeft[3].fullname \n end\n unless runCustomTwosLeft[4].nil? \n rcutl5 = runCustomTwosLeft[4].fullname\n end\n unless runCustomTwosLeft[5].nil? \n rcutl6 = runCustomTwosLeft[5].fullname \n end\n unless runCustomTwosLeft[6].nil? \n rcutl7 = runCustomTwosLeft[6].fullname\n end \n unless runCustomTwosLeft[7].nil? \n rcutl8 = runCustomTwosLeft[7].fullname \n end\n unless runCustomTwosLeft[8].nil? \n rcutl9 = runCustomTwosLeft[8].fullname \n end\n unless runCustomTwosLeft[9].nil? \n rcutl10 = runCustomTwosLeft[9].fullname \n end\n unless runCustomTwosLeft[10].nil? \n rcutl11 = runCustomTwosLeft[10].fullname \n end\n unless runCustomTwosLeft[11].nil? \n rcutl12 = runCustomTwosLeft[11].fullname\n end\n unless runCustomTwosLeft[12].nil? \n rcutl13 = runCustomTwosLeft[12].fullname \n end\n unless runCustomTwosLeft[13].nil? \n rcutl14 = runCustomTwosLeft[13].fullname\n end \n unless runCustomTwosLeft[14].nil? \n rcutl15 = runCustomTwosLeft[14].fullname\n end\n\n #Run Right Hash\n unless runCustomTwosRight[0].nil? \n rcutr1 = runCustomTwosRight[0].fullname \n end\n unless runCustomTwosRight[1].nil? \n rcutr2 = runCustomTwosRight[1].fullname \n end\n unless runCustomTwosRight[2].nil? \n rcutr3 = runCustomTwosRight[2].fullname \n end\n unless runCustomTwosRight[3].nil? \n rcutr4 = runCustomTwosRight[3].fullname \n end\n unless runCustomTwosRight[4].nil? \n rcutr5 = runCustomTwosRight[4].fullname\n end\n unless runCustomTwosRight[5].nil? \n rcutr6 = runCustomTwosRight[5].fullname \n end\n unless runCustomTwosRight[6].nil? \n rcutr7 = runCustomTwosRight[6].fullname\n end \n unless runCustomTwosRight[7].nil? \n rcutr8 = runCustomTwosRight[7].fullname \n end\n unless runCustomTwosRight[8].nil? \n rcutr9 = runCustomTwosRight[8].fullname \n end\n unless runCustomTwosRight[9].nil? \n rcutr10 = runCustomTwosRight[9].fullname \n end\n unless runCustomTwosRight[10].nil? \n rcutr11 = runCustomTwosRight[10].fullname \n end\n unless runCustomTwosRight[11].nil? \n rcutr12 = runCustomTwosRight[11].fullname\n end\n unless runCustomTwosRight[12].nil? \n rcutr13 = runCustomTwosRight[12].fullname \n end\n unless runCustomTwosRight[13].nil? \n rcutr14 = runCustomTwosRight[13].fullname\n end \n unless runCustomTwosRight[14].nil? \n rcutr15 = runCustomTwosRight[14].fullname\n end \n\n #Pass Left Hash\n unless passCustomTwosLeft[0].nil? \n pcutl1 = passCustomTwosLeft[0].fullname \n end\n unless passCustomTwosLeft[1].nil? \n pcutl2 = passCustomTwosLeft[1].fullname \n end\n unless passCustomTwosLeft[2].nil? \n pcutl3 = passCustomTwosLeft[2].fullname \n end\n unless passCustomTwosLeft[3].nil? \n pcutl4 = passCustomTwosLeft[3].fullname \n end\n unless passCustomTwosLeft[4].nil? \n pcutl5 = passCustomTwosLeft[4].fullname \n end\n unless passCustomTwosLeft[5].nil? \n pcutl6 = passCustomTwosLeft[5].fullname \n end \n unless passCustomTwosLeft[6].nil? \n pcutl7 = passCustomTwosLeft[6].fullname \n end \n unless passCustomTwosLeft[7].nil? \n pcutl8 = passCustomTwosLeft[7].fullname \n end\n unless passCustomTwosLeft[8].nil? \n pcutl9 = passCustomTwosLeft[8].fullname \n end\n unless passCustomTwosLeft[9].nil? \n pcutl10 = passCustomTwosLeft[9].fullname \n end\n unless passCustomTwosLeft[10].nil? \n pcutl11 = passCustomTwosLeft[10].fullname \n end\n unless passCustomTwosLeft[11].nil? \n pcutl12 = passCustomTwosLeft[11].fullname \n end\n unless passCustomTwosLeft[12].nil? \n pcutl13 = passCustomTwosLeft[12].fullname \n end \n unless passCustomTwosLeft[13].nil? \n pcutl14 = passCustomTwosLeft[13].fullname \n end \n unless passCustomTwosLeft[14].nil? \n pcutl15 = passCustomTwosLeft[14].fullname \n end \n\n #Pass Right Hash\n unless passCustomTwosRight[0].nil? \n pcutr1 = passCustomTwosRight[0].fullname \n end\n unless passCustomTwosRight[1].nil? \n pcutr2 = passCustomTwosRight[1].fullname \n end\n unless passCustomTwosRight[2].nil? \n pcutr3 = passCustomTwosRight[2].fullname \n end\n unless passCustomTwosRight[3].nil? \n pcutr4 = passCustomTwosRight[3].fullname \n end\n unless passCustomTwosRight[4].nil? \n pcutr5 = passCustomTwosRight[4].fullname \n end\n unless passCustomTwosRight[5].nil? \n pcutr6 = passCustomTwosRight[5].fullname \n end\n unless passCustomTwosRight[6].nil? \n pcutr7 = passCustomTwosRight[6].fullname \n end \n unless passCustomTwosRight[7].nil? \n pcutr8 = passCustomTwosRight[7].fullname \n end\n unless passCustomTwosRight[8].nil? \n pcutr9 = passCustomTwosRight[8].fullname \n end\n unless passCustomTwosRight[9].nil? \n pcutr10 = passCustomTwosRight[9].fullname \n end\n unless passCustomTwosRight[10].nil? \n pcutr11 = passCustomTwosRight[10].fullname \n end\n unless passCustomTwosRight[11].nil? \n pcutr12 = passCustomTwosRight[11].fullname \n end\n unless passCustomTwosRight[12].nil? \n pcutr13 = passCustomTwosRight[12].fullname \n end\n unless passCustomTwosRight[13].nil? \n pcutr14 = passCustomTwosRight[13].fullname \n end \n unless passCustomTwosRight[14].nil? \n pcutr15 = passCustomTwosRight[14].fullname \n end \n\n #Number of user's run plays in situation 13\n num_cus2r = self.user.s_name13_num_run\n\n #Left Hash\n # cus2l_s0 \n if num_cus2r > 0\n cus2l_s0 = self.user.s_name13 + ' - Run'\n else\n cus2l_s0 = self.user.s_name13 + ' - Pass'\n end\n\n #cus2l_s1 \n if num_cus2r > 0\n cus2l_s1 = rcutl1\n else\n cus2l_s1 = pcutl1\n end\n\n #cus2l_s2\n if num_cus2r == 0\n cus2l_s2 = pcutl2\n elsif num_cus2r == 1\n cus2l_s2 = self.user.s_name13 + ' - Pass'\n else num_cus2r > 1\n cus2l_s2 = rcutl2\n end\n\n #cus2l_s3\n case num_cus2r\n when 0 then cus2l_s3 = pcutl3 \n when 1 then cus2l_s3 = pcutl1\n when 2 then cus2l_s3 = self.user.s_name13 + ' - Pass'\n when 3..100 then cus2l_s3 = rcutl3\n end\n\n #cus2l_s4\n case num_cus2r\n when 0 then cus2l_s4 = pcutl4 \n when 1 then cus2l_s4 = pcutl2\n when 2 then cus2l_s4 = pcutl1\n when 3 then cus2l_s4 = self.user.s_name13 + ' - Pass'\n when 4..100 then cus2l_s4 = rcutl4\n end\n\n #cus2l_s5\n case num_cus2r\n when 0 then cus2l_s5 = pcutl5 \n when 1 then cus2l_s5 = pcutl3\n when 2 then cus2l_s5 = pcutl2\n when 3 then cus2l_s5 = pcutl1\n when 4 then cus2l_s5 = self.user.s_name13 + ' - Pass'\n when 5..100 then cus2l_s5 = rcutl5\n end\n\n #cus2l_s6\n case num_cus2r\n when 0 then cus2l_s6 = pcutl6 \n when 1 then cus2l_s6 = pcutl4\n when 2 then cus2l_s6 = pcutl3\n when 3 then cus2l_s6 = pcutl2\n when 4 then cus2l_s6 = pcutl1\n when 5 then cus2l_s6 = self.user.s_name13 + ' - Pass'\n when 6..100 then cus2l_s6 = rcutl6\n end\n\n #cus2l_s7\n case num_cus2r\n when 0 then cus2l_s7 = pcutl7 \n when 1 then cus2l_s7 = pcutl5\n when 2 then cus2l_s7 = pcutl4\n when 3 then cus2l_s7 = pcutl3\n when 4 then cus2l_s7 = pcutl2\n when 5 then cus2l_s7 = pcutl1\n when 6 then cus2l_s7 = self.user.s_name13 + ' - Pass'\n when 7..100 then cus2l_s7 = rcutl7\n end\n\n #cus2l_s8\n case num_cus2r\n when 0 then cus2l_s8 = pcutl8 \n when 1 then cus2l_s8 = pcutl6\n when 2 then cus2l_s8 = pcutl5\n when 3 then cus2l_s8 = pcutl4\n when 4 then cus2l_s8 = pcutl3\n when 5 then cus2l_s8 = pcutl2\n when 6 then cus2l_s8 = pcutl1\n when 7 then cus2l_s8 = self.user.s_name13 + ' - Pass'\n when 8..100 then cus2l_s8 = rcutl8\n end\n\n #cus2l_s9\n case num_cus2r\n when 0 then cus2l_s9 = pcutl9 \n when 1 then cus2l_s9 = pcutl7\n when 2 then cus2l_s9 = pcutl6\n when 3 then cus2l_s9 = pcutl5\n when 4 then cus2l_s9 = pcutl4\n when 5 then cus2l_s9 = pcutl3\n when 6 then cus2l_s9 = pcutl2\n when 7 then cus2l_s9 = pcutl1\n when 8 then cus2l_s9 = self.user.s_name13 + ' - Pass'\n when 9..100 then cus2l_s9 = rcutl9\n end\n\n #cus2l_s10\n case num_cus2r\n when 0 then cus2l_s10 = pcutl10 \n when 1 then cus2l_s10 = pcutl8\n when 2 then cus2l_s10 = pcutl7\n when 3 then cus2l_s10 = pcutl6\n when 4 then cus2l_s10 = pcutl5\n when 5 then cus2l_s10 = pcutl4\n when 6 then cus2l_s10 = pcutl3\n when 7 then cus2l_s10 = pcutl2\n when 8 then cus2l_s10 = pcutl1\n when 9 then cus2l_s10 = self.user.s_name13 + ' - Pass'\n when 10..100 then cus2l_s10 = rcutl10\n end\n\n #cus2l_s11\n case num_cus2r\n when 0 then cus2l_s11 = pcutl11 \n when 1 then cus2l_s11 = pcutl9\n when 2 then cus2l_s11 = pcutl8\n when 3 then cus2l_s11 = pcutl7\n when 4 then cus2l_s11 = pcutl6\n when 5 then cus2l_s11 = pcutl5\n when 6 then cus2l_s11 = pcutl4\n when 7 then cus2l_s11 = pcutl3\n when 8 then cus2l_s11 = pcutl2\n when 9 then cus2l_s11 = pcutl1\n when 10 then cus2l_s11 = self.user.s_name13 + ' - Pass'\n when 11..100 then cus2l_s11 = rcutl11\n end\n\n #cus2l_s12\n case num_cus2r\n when 0 then cus2l_s12 = pcutl12 \n when 1 then cus2l_s12 = pcutl10\n when 2 then cus2l_s12 = pcutl9\n when 3 then cus2l_s12 = pcutl8\n when 4 then cus2l_s12 = pcutl7\n when 5 then cus2l_s12 = pcutl6\n when 6 then cus2l_s12 = pcutl5\n when 7 then cus2l_s12 = pcutl4\n when 8 then cus2l_s12 = pcutl3\n when 9 then cus2l_s12 = pcutl2\n when 10 then cus2l_s12 = pcutl1\n when 11 then cus2l_s12 = self.user.s_name13 + ' - Pass'\n when 12..100 then cus2l_s12 = rcutl12\n end\n\n #cus2l_s13\n case num_cus2r\n when 0 then cus2l_s13 = pcutl13 \n when 1 then cus2l_s13 = pcutl11\n when 2 then cus2l_s13 = pcutl10\n when 3 then cus2l_s13 = pcutl9\n when 4 then cus2l_s13 = pcutl8\n when 5 then cus2l_s13 = pcutl7\n when 6 then cus2l_s13 = pcutl6\n when 7 then cus2l_s13 = pcutl5\n when 8 then cus2l_s13 = pcutl4\n when 9 then cus2l_s13 = pcutl3\n when 10 then cus2l_s13 = pcutl2\n when 11 then cus2l_s13 = pcutl1\n when 12 then cus2l_s13 = self.user.s_name13 + ' - Pass'\n when 13..100 then cus2l_s13 = rcutl13\n end\n\n #cus2l_s14\n case num_cus2r\n when 0 then cus2l_s14 = pcutl14 \n when 1 then cus2l_s14 = pcutl12\n when 2 then cus2l_s14 = pcutl11\n when 3 then cus2l_s14 = pcutl10\n when 4 then cus2l_s14 = pcutl9\n when 5 then cus2l_s14 = pcutl8\n when 6 then cus2l_s14 = pcutl7\n when 7 then cus2l_s14 = pcutl6\n when 8 then cus2l_s14 = pcutl5\n when 9 then cus2l_s14 = pcutl4\n when 10 then cus2l_s14 = pcutl3\n when 11 then cus2l_s14 = pcutl2\n when 12 then cus2l_s14 = pcutl1 \n when 13 then cus2l_s14 = self.user.s_name13 + ' - Pass'\n when 14..100 then cus2l_s14 = rcutl14\n end\n\n #cus2l_s15\n case num_cus2r\n when 0 then cus2l_s15 = pcutl15 \n when 1 then cus2l_s15 = pcutl13\n when 2 then cus2l_s15 = pcutl12\n when 3 then cus2l_s15 = pcutl11\n when 4 then cus2l_s15 = pcutl10\n when 5 then cus2l_s15 = pcutl9\n when 6 then cus2l_s15 = pcutl8\n when 7 then cus2l_s15 = pcutl7\n when 8 then cus2l_s15 = pcutl6\n when 9 then cus2l_s15 = pcutl5\n when 10 then cus2l_s15 = pcutl4\n when 11 then cus2l_s15 = pcutl3\n when 12 then cus2l_s15 = pcutl2\n when 13 then cus2l_s15 = pcutl1 \n when 14..100 then cus2l_s15 = rcutl15\n end \n\n\n #Right Hash\n # cus2r_s0 would always be blank\n\n #cus2r_s1 \n if num_cus2r > 0\n cus2r_s1 = rcutr1\n else\n cus2r_s1 = pcutr1\n end\n\n #cus2r_s2\n if num_cus2r == 0\n cus2r_s2 = pcutr2\n elsif num_cus2r == 1\n cus2r_s2 = ''\n else num_cus2r > 1\n cus2r_s2 = rcutr2\n end\n\n #cus2r_s3\n case num_cus2r\n when 0 then cus2r_s3 = pcutr3 \n when 1 then cus2r_s3 = pcutr1\n when 2 then cus2r_s3 = ''\n when 3..100 then cus2r_s3 = rcutr3\n end\n\n #cus2r_s4\n case num_cus2r\n when 0 then cus2r_s4 = pcutr4 \n when 1 then cus2r_s4 = pcutr2\n when 2 then cus2r_s4 = pcutr1\n when 3 then ''\n when 4..100 then cus2r_s4 = rcutr4\n end\n\n #cus2r_s5\n case num_cus2r\n when 0 then cus2r_s5 = pcutr5 \n when 1 then cus2r_s5 = pcutr3\n when 2 then cus2r_s5 = pcutr2\n when 3 then cus2r_s5 = pcutr1\n when 4 then cus2r_s5 = ''\n when 5..100 then cus2r_s5 = rcutr5\n end\n\n #cus2r_s6\n case num_cus2r\n when 0 then cus2r_s6 = pcutr6 \n when 1 then cus2r_s6 = pcutr4\n when 2 then cus2r_s6 = pcutr3\n when 3 then cus2r_s6 = pcutr2\n when 4 then cus2r_s6 = pcutr1\n when 5 then cus2r_s6 = ''\n when 6..100 then cus2r_s6 = rcutr6\n end\n\n #cus2r_s7\n case num_cus2r\n when 0 then cus2r_s7 = pcutr7 \n when 1 then cus2r_s7 = pcutr5\n when 2 then cus2r_s7 = pcutr4\n when 3 then cus2r_s7 = pcutr3\n when 4 then cus2r_s7 = pcutr2\n when 5 then cus2r_s7 = pcutr1\n when 6 then cus2r_s7 = ''\n when 7..100 then cus2r_s7 = rcutr7\n end\n\n #cus2r_s8\n case num_cus2r\n when 0 then cus2r_s8 = pcutr8 \n when 1 then cus2r_s8 = pcutr6\n when 2 then cus2r_s8 = pcutr5\n when 3 then cus2r_s8 = pcutr4\n when 4 then cus2r_s8 = pcutr3\n when 5 then cus2r_s8 = pcutr2\n when 6 then cus2r_s8 = pcutr1\n when 7 then cus2r_s8 = ''\n when 8..100 then cus2r_s8 = rcutr8\n end\n\n #cus2r_s9\n case num_cus2r\n when 0 then cus2r_s9 = pcutr9 \n when 1 then cus2r_s9 = pcutr7\n when 2 then cus2r_s9 = pcutr6\n when 3 then cus2r_s9 = pcutr5\n when 4 then cus2r_s9 = pcutr4\n when 5 then cus2r_s9 = pcutr3\n when 6 then cus2r_s9 = pcutr2\n when 7 then cus2r_s9 = pcutr1\n when 8 then cus2r_s9 = ''\n when 9..100 then cus2r_s9 = rcutr9\n end\n\n #cus2r_s10\n case num_cus2r\n when 0 then cus2r_s10 = pcutr10 \n when 1 then cus2r_s10 = pcutr8\n when 2 then cus2r_s10 = pcutr7\n when 3 then cus2r_s10 = pcutr6\n when 4 then cus2r_s10 = pcutr5\n when 5 then cus2r_s10 = pcutr4\n when 6 then cus2r_s10 = pcutr3\n when 7 then cus2r_s10 = pcutr2\n when 8 then cus2r_s10 = pcutr1\n when 9 then cus2r_s10 = ''\n when 10..100 then cus2r_s10 = rcutr10\n end\n\n #cus2r_s11\n case num_cus2r\n when 0 then cus2r_s11 = pcutr11 \n when 1 then cus2r_s11 = pcutr9\n when 2 then cus2r_s11 = pcutr8\n when 3 then cus2r_s11 = pcutr7\n when 4 then cus2r_s11 = pcutr6\n when 5 then cus2r_s11 = pcutr5\n when 6 then cus2r_s11 = pcutr4\n when 7 then cus2r_s11 = pcutr3\n when 8 then cus2r_s11 = pcutr2\n when 9 then cus2r_s11 = pcutr1\n when 10 then cus2r_s11 = ''\n when 11..100 then cus2r_s11 = rcutr11\n end\n\n #cus2r_s12\n case num_cus2r\n when 0 then cus2r_s12 = pcutr12 \n when 1 then cus2r_s12 = pcutr10\n when 2 then cus2r_s12 = pcutr9\n when 3 then cus2r_s12 = pcutr8\n when 4 then cus2r_s12 = pcutr7\n when 5 then cus2r_s12 = pcutr6\n when 6 then cus2r_s12 = pcutr5\n when 7 then cus2r_s12 = pcutr4\n when 8 then cus2r_s12 = pcutr3\n when 9 then cus2r_s12 = pcutr2\n when 10 then cus2r_s12 = pcutr1\n when 11 then cus2r_s12 = ''\n when 12..100 then cus2r_s12 = rcutr12\n end\n\n #cus2r_s13\n case num_cus2r\n when 0 then cus2r_s13 = pcutr13 \n when 1 then cus2r_s13 = pcutr11\n when 2 then cus2r_s13 = pcutr10\n when 3 then cus2r_s13 = pcutr9\n when 4 then cus2r_s13 = pcutr8\n when 5 then cus2r_s13 = pcutr7\n when 6 then cus2r_s13 = pcutr6\n when 7 then cus2r_s13 = pcutr5\n when 8 then cus2r_s13 = pcutr4\n when 9 then cus2r_s13 = pcutr3\n when 10 then cus2r_s13 = pcutr2\n when 11 then cus2r_s13 = pcutr1\n when 12 then cus2r_s13 = ''\n when 13..100 then cus2r_s13 = rcutr13\n end\n\n #cus2r_s14\n case num_cus2r\n when 0 then cus2r_s14 = pcutr14 \n when 1 then cus2r_s14 = pcutr12\n when 2 then cus2r_s14 = pcutr11\n when 3 then cus2r_s14 = pcutr10\n when 4 then cus2r_s14 = pcutr9\n when 5 then cus2r_s14 = pcutr8\n when 6 then cus2r_s14 = pcutr7\n when 7 then cus2r_s14 = pcutr6\n when 8 then cus2r_s14 = pcutr5\n when 9 then cus2r_s14 = pcutr4\n when 10 then cus2r_s14 = pcutr3\n when 11 then cus2r_s14 = pcutr2\n when 12 then cus2r_s14 = pcutr1 \n when 13 then cus2r_s14 = ''\n when 14..100 then cus2r_s14 = rcutr14\n end\n\n #cus2r_s15\n case num_cus2r\n when 0 then cus2r_s15 = pcutr15 \n when 1 then cus2r_s15 = pcutr13\n when 2 then cus2r_s15 = pcutr12\n when 3 then cus2r_s15 = pcutr11\n when 4 then cus2r_s15 = pcutr10\n when 5 then cus2r_s15 = pcutr9\n when 6 then cus2r_s15 = pcutr8\n when 7 then cus2r_s15 = pcutr7\n when 8 then cus2r_s15 = pcutr6\n when 9 then cus2r_s15 = pcutr5\n when 10 then cus2r_s15 = pcutr4\n when 11 then cus2r_s15 = pcutr3\n when 12 then cus2r_s15 = pcutr2\n when 13 then cus2r_s15 = pcutr1 \n when 14..100 then cus2r_s15 = rcutr15\n end \n #----------End Custom 2---------- \n\n #----------Custom 3----------\n customThrees = event.plays.where('situation14 = ?', true)\n customThreesLeft = customThrees.where('hash_mark = ?', 'Left')\n customThreesRight = customThrees.where('hash_mark = ?', 'Right')\n \n #Left Hash\n unless customThreesLeft[0].nil? \n cuthl1 = customThreesLeft[0].fullname \n end\n unless customThreesLeft[1].nil? \n cuthl2 = customThreesLeft[1].fullname \n end\n unless customThreesLeft[2].nil? \n cuthl3 = customThreesLeft[2].fullname \n end\n unless customThreesLeft[3].nil? \n cuthl4 = customThreesLeft[3].fullname \n end\n unless customThreesLeft[4].nil? \n cuthl5 = customThreesLeft[4].fullname\n end\n unless customThreesLeft[5].nil? \n cuthl6 = customThreesLeft[5].fullname \n end\n unless customThreesLeft[6].nil? \n cuthl7 = customThreesLeft[6].fullname\n end \n unless customThreesLeft[7].nil? \n cuthl8 = customThreesLeft[7].fullname \n end\n unless customThreesLeft[8].nil? \n cuthl9 = customThreesLeft[8].fullname \n end\n unless customThreesLeft[9].nil? \n cuthl10 = customThreesLeft[9].fullname \n end\n unless customThreesLeft[10].nil? \n cuthl11 = customThreesLeft[10].fullname \n end\n unless customThreesLeft[11].nil? \n cuthl12 = customThreesLeft[11].fullname\n end\n unless customThreesLeft[12].nil? \n cuthl13 = customThreesLeft[12].fullname \n end\n unless customThreesLeft[13].nil? \n cuthl14 = customThreesLeft[13].fullname\n end \n unless customThreesLeft[14].nil? \n cuthl15 = customThreesLeft[14].fullname\n end \n\n #Right Hash\n unless customThreesRight[0].nil? \n cuthr1 = customThreesRight[0].fullname \n end\n unless customThreesRight[1].nil? \n cuthr2 = customThreesRight[1].fullname \n end\n unless customThreesRight[2].nil? \n cuthr3 = customThreesRight[2].fullname \n end\n unless customThreesRight[3].nil? \n cuthr4 = customThreesRight[3].fullname \n end\n unless customThreesRight[4].nil? \n cuthr5 = customThreesRight[4].fullname\n end\n unless customThreesRight[5].nil? \n cuthr6 = customThreesRight[5].fullname \n end\n unless customThreesRight[6].nil? \n cuthr7 = customThreesRight[6].fullname\n end \n unless customThreesRight[7].nil? \n cuthr8 = customThreesRight[7].fullname \n end\n unless customThreesRight[8].nil? \n cuthr9 = customThreesRight[8].fullname \n end\n unless customThreesRight[9].nil? \n cuthr10 = customThreesRight[9].fullname \n end\n unless customThreesRight[10].nil? \n cuthr11 = customThreesRight[10].fullname \n end\n unless customThreesRight[11].nil? \n cuthr12 = customThreesRight[11].fullname\n end\n unless customThreesRight[12].nil? \n cuthr13 = customThreesRight[12].fullname \n end\n unless customThreesRight[13].nil? \n cuthr14 = customThreesRight[13].fullname\n end \n unless customThreesRight[14].nil? \n cuthr15 = customThreesRight[14].fullname\n end \n #----------End Custom 3---------- \n\n self.update :gdata => \"[\n ['#{title}', '', '', ''],\n ['#{self.user.s_name1}', '', '#{ftl_s0}', ''],\n ['#{openl1}', '#{openr1}', '#{ftl_s1}', '#{ftr_s1}'],\n ['#{openl2}', '#{openr2}', '#{ftl_s2}', '#{ftr_s2}'],\n ['#{openl3}', '#{openr3}', '#{ftl_s3}', '#{ftr_s3}'],\n ['#{openl4}', '#{openr4}', '#{ftl_s4}', '#{ftr_s4}'],\n ['#{openl5}', '#{openr5}', '#{ftl_s5}', '#{ftr_s5}'],\n ['#{openl6}', '#{openr6}', '#{ftl_s6}', '#{ftr_s6}'],\n ['#{openl7}', '#{openr7}', '#{ftl_s7}', '#{ftr_s7}'], \n ['#{openl8}', '#{openr8}', '#{ftl_s8}', '#{ftr_s8}'],\n ['#{openl9}', '#{openr9}', '#{ftl_s9}', '#{ftr_s9}'],\n ['#{openl10}', '#{openr10}', '#{ftl_s10}', '#{ftr_s10}'],\n ['#{openl11}', '#{openr11}', '#{ftl_s11}', '#{ftr_s11}'],\n ['#{openl12}', '#{openr12}', '#{ftl_s12}', '#{ftr_s12}'],\n ['#{openl13}', '#{openr13}', '#{ftl_s13}', '#{ftr_s13}'],\n ['#{openl14}', '#{openr14}', '#{ftl_s14}', '#{ftr_s14}'],\n ['#{openl15}', '#{openr15}', '#{ftl_s15}', '#{ftr_s15}'],\n ['#{sll_s0}', '', '#{tll_s0}', ''],\n ['#{sll_s1}', '#{slr_s1}', '#{tll_s1}', '#{tlr_s1}'],\n ['#{sll_s2}', '#{slr_s2}', '#{tll_s2}', '#{tlr_s2}'],\n ['#{sll_s3}', '#{slr_s3}', '#{tll_s3}', '#{tlr_s3}'],\n ['#{sll_s4}', '#{slr_s4}', '#{tll_s4}', '#{tlr_s4}'],\n ['#{sll_s5}', '#{slr_s5}', '#{tll_s5}', '#{tlr_s5}'],\n ['#{sll_s6}', '#{slr_s6}', '#{tll_s6}', '#{tlr_s6}'],\n ['#{sll_s7}', '#{slr_s7}', '#{tll_s7}', '#{tlr_s7}'],\n ['#{sll_s8}', '#{slr_s8}', '#{tll_s8}', '#{tlr_s8}'],\n ['#{sll_s9}', '#{slr_s9}', '#{tll_s9}', '#{tlr_s9}'],\n ['#{sll_s10}', '#{slr_s10}', '#{tll_s10}', '#{tlr_s10}'],\n ['#{sll_s11}', '#{slr_s11}', '#{tll_s11}', '#{tlr_s11}'],\n ['#{sll_s12}', '#{slr_s12}', '#{tll_s12}', '#{tlr_s12}'],\n ['#{secondmdl_s0}', '', '#{thirdmdl_s0 }', ''],\n ['#{secondmdl_s1}', '#{secondmdr_s1}', '#{thirdmdl_s1 }', '#{thirdmdr_s1}'],\n ['#{secondmdl_s2}', '#{secondmdr_s2}', '#{thirdmdl_s2}', '#{thirdmdr_s2}'],\n ['#{secondmdl_s3}', '#{secondmdr_s3}', '#{thirdmdl_s3}', '#{thirdmdr_s3}'],\n ['#{secondmdl_s4}', '#{secondmdr_s4}', '#{thirdmdl_s4}', '#{thirdmdr_s4}'],\n ['#{secondmdl_s5}', '#{secondmdr_s5}', '#{thirdmdl_s5}', '#{thirdmdr_s5}'],\n ['#{secondmdl_s6}', '#{secondmdr_s6}', '#{thirdmdl_s6}', '#{thirdmdr_s6}'],\n ['#{secondmdl_s7}', '#{secondmdr_s7}', '#{thirdmdl_s7}', '#{thirdmdr_s7}'],\n ['#{secondmdl_s8}', '#{secondmdr_s8}', '#{thirdmdl_s8}', '#{thirdmdr_s8}'],\n ['#{secondmdl_s9}', '#{secondmdr_s9}', '#{thirdmdl_s9}', '#{thirdmdr_s9}'],\n ['#{secondmdl_s10}', '#{secondmdr_s10}', '#{thirdmdl_s10}', '#{thirdmdr_s10}'],\n ['#{secondmdl_s11}', '#{secondmdr_s11}', '#{thirdmdl_s11}', '#{thirdmdr_s11}'],\n ['#{secondstl_s0}', '', '#{thirdstl_s0}', ''],\n ['#{secondstl_s1}', '#{secondstr_s1}', '#{thirdstl_s1}', '#{thirdstr_s1}'],\n ['#{secondstl_s2}', '#{secondstr_s2}', '#{thirdstl_s2}', '#{thirdstr_s2}'],\n ['#{secondstl_s3}', '#{secondstr_s3}', '#{thirdstl_s3}', '#{thirdstr_s3}'],\n ['#{secondstl_s4}', '#{secondstr_s4}', '#{thirdstl_s4}', '#{thirdstr_s4}'],\n ['#{secondstl_s5}', '#{secondstr_s5}', '#{thirdstl_s5}', '#{thirdstr_s5}'],\n ['#{secondstl_s6}', '#{secondstr_s6}', '#{thirdstl_s6}', '#{thirdstr_s6}'],\n ['#{secondstl_s7}', '#{secondstr_s7}', '#{thirdstl_s7}', '#{thirdstr_s7}'],\n ['#{secondstl_s8}', '#{secondstr_s8}', '#{thirdstl_s8}', '#{thirdstr_s8}'],\n ['#{secondstl_s9}', '#{secondstr_s9}', '#{thirdstl_s9}', '#{thirdstr_s9}'],\n ['#{secondstl_s10}', '#{secondstr_s10}', '#{thirdstl_s10}', '#{thirdstr_s10}'],\n ['#{secondstl_s11}', '#{secondstr_s11}', '#{thirdstl_s11}', '#{thirdstr_s11}']\n ]\"\n\n self.update :gdata2 => \"[ \n ['Page Two', '', '', ''],\n ['#{rzonel_s0}', '', '#{glinel_s0}', ''],\n ['#{rzonel_s1}', '#{rzoner_s1}', '#{glinel_s1}', '#{gliner_s1}'],\n ['#{rzonel_s2}', '#{rzoner_s2}', '#{glinel_s2}', '#{gliner_s2}'],\n ['#{rzonel_s3}', '#{rzoner_s3}', '#{glinel_s3}', '#{gliner_s3}'],\n ['#{rzonel_s4}', '#{rzoner_s4}', '#{glinel_s4}', '#{gliner_s4}'],\n ['#{rzonel_s5}', '#{rzoner_s5}', '#{glinel_s5}', '#{gliner_s5}'],\n ['#{rzonel_s6}', '#{rzoner_s6}', '#{glinel_s6}', '#{gliner_s6}'],\n ['#{rzonel_s7}', '#{rzoner_s7}', '#{glinel_s7}', '#{gliner_s7}'],\n ['#{rzonel_s8}', '#{rzoner_s8}', '#{glinel_s8}', '#{gliner_s8}'],\n ['#{rzonel_s9}', '#{rzoner_s9}', '#{glinel_s9}', '#{gliner_s9}'],\n ['#{rzonel_s10}', '#{rzoner_s10}', '#{glinel_s10}', '#{gliner_s10}'],\n ['#{rzonel_s11}', '#{rzoner_s11}', '#{glinel_s11}', '#{gliner_s11}'],\n ['#{rzonel_s12}', '#{rzoner_s12}', '#{glinel_s12}', '#{gliner_s12}'],\n ['#{rzonel_s13}', '#{rzoner_s13}', '#{glinel_s13}', '#{gliner_s13}'],\n ['#{rzonel_s14}', '#{rzoner_s14}', '#{glinel_s14}', '#{gliner_s14}'],\n ['#{rzonel_s15}', '#{rzoner_s15}', '#{glinel_s15}', '#{gliner_s15}'],\n ['#{coutl_s0}', '', '#{cus1l_s0}', ''],\n ['#{coutl_s1}', '#{coutr_s1}', '#{cus1l_s1}', '#{cus1r_s1}'],\n ['#{coutl_s2}', '#{coutr_s2}', '#{cus1l_s2}', '#{cus1r_s2}'],\n ['#{coutl_s3}', '#{coutr_s3}', '#{cus1l_s3}', '#{cus1r_s3}'],\n ['#{coutl_s4}', '#{coutr_s4}', '#{cus1l_s4}', '#{cus1r_s4}'],\n ['#{coutl_s5}', '#{coutr_s5}', '#{cus1l_s5}', '#{cus1r_s5}'],\n ['#{coutl_s6}', '#{coutr_s6}', '#{cus1l_s6}', '#{cus1r_s6}'],\n ['#{coutl_s7}', '#{coutr_s7}', '#{cus1l_s7}', '#{cus1r_s7}'],\n ['#{coutl_s8}', '#{coutr_s8}', '#{cus1l_s8}', '#{cus1r_s8}'],\n ['#{coutl_s9}', '#{coutr_s9}', '#{cus1l_s9}', '#{cus1r_s9}'],\n ['#{coutl_s10}', '#{coutr_s10}', '#{cus1l_s10}', '#{cus1r_s10}'],\n ['#{coutl_s11}', '#{coutr_s11}', '#{cus1l_s11}', '#{cus1r_s11}'],\n ['#{coutl_s12}', '#{coutr_s12}', '#{cus1l_s12}', '#{cus1r_s12}'],\n ['#{coutl_s13}', '#{coutr_s13}', '#{cus1l_s13}', '#{cus1r_s13}'],\n ['#{coutl_s14}', '#{coutr_s14}', '#{cus1l_s14}', '#{cus1r_s14}'],\n ['#{coutl_s15}', '#{coutr_s15}', '#{cus1l_s15}', '#{cus1r_s15}'],\n ['#{cus2l_s0}', '', '#{self.user.s_name14}', ''],\n ['#{cus2l_s1}', '#{cus2r_s1}', '#{cuthl1}', '#{cuthr1}'],\n ['#{cus2l_s2}', '#{cus2r_s2}', '#{cuthl2}', '#{cuthr2}'],\n ['#{cus2l_s3}', '#{cus2r_s3}', '#{cuthl3}', '#{cuthr3}'],\n ['#{cus2l_s4}', '#{cus2r_s4}', '#{cuthl4}', '#{cuthr4}'],\n ['#{cus2l_s5}', '#{cus2r_s5}', '#{cuthl5}', '#{cuthr5}'],\n ['#{cus2l_s6}', '#{cus2r_s6}', '#{cuthl6}', '#{cuthr6}'],\n ['#{cus2l_s7}', '#{cus2r_s7}', '#{cuthl7}', '#{cuthr7}'],\n ['#{cus2l_s8}', '#{cus2r_s8}', '#{cuthl8}', '#{cuthr8}'],\n ['#{cus2l_s9}', '#{cus2r_s9}', '#{cuthl9}', '#{cuthr9}'],\n ['#{cus2l_s10}', '#{cus2r_s10}', '#{cuthl10}', '#{cuthr10}'],\n ['#{cus2l_s11}', '#{cus2r_s11}', '#{cuthl11}', '#{cuthr11}'],\n ['#{cus2l_s12}', '#{cus2r_s12}', '#{cuthl12}', '#{cuthr12}'],\n ['#{cus2l_s13}', '#{cus2r_s13}', '#{cuthl13}', '#{cuthr13}'],\n ['#{cus2l_s14}', '#{cus2r_s14}', '#{cuthl14}', '#{cuthr14}'],\n ['#{cus2l_s15}', '#{cus2r_s15}', '#{cuthl15}', '#{cuthr15}']\n ]\" \n end",
"def start\n\t\tif @game_over\n\t\t\traise Exception.new(\"GAME #{@id} IS ALREADY OVER\")\n\t\tend\n\t\tplayer_number = 1\n\t\tloop do\n\t\t\t@game_over = player_turn @players[player_number], player_number\n\t\t\tplayer_number = player_number % 2 + 1\n\t\t\tbreak if @game_over\n\t\tend\n\tend",
"def events=(_); end",
"def play_round \n @events.handle(:round) do\n reset_players\n\n take_bets\n deal\n play\n determine_winners\n \n @deck.reset!\n end\n end",
"def run\n game = Game.new\n game.game_start\nend",
"def perform \n application = Application.new\n while application.decide == \"Y\"\n application.ongoing_game\n application.ending_game \n end\nend",
"def gcmake_event\n Event.create :user_id => self.user_id, :gamecall_tag => self.id, :installgc_event_id => self.event_id, :title => self.title, :start_time => self.start_time, :end_time => self.end_time, :event_type => \"Gamecall\"\n end",
"def update_encounter\r\n # Event determinant is via touch of same position event\r\n result = check_event_trigger_here([1,2])\r\n # If event which started does not exist\r\n if result == false\r\n # Disregard if debug mode is ON and ctrl key was pressed\r\n unless $DEBUG and Input.press?(Input::CTRL)\r\n # Encounter countdown\r\n if @encounter_count > 0\r\n @encounter_count -= 1\r\n end\r\n end\r\n end\r\n end",
"def do_finish_ai\n # print \"in do_finish_ai @wait_on_ai #{@wait_on_ai}\\n\"\n # print \"@event_waiting_for #{@event_waiting_for}\\n\"\n # print \"TM.response_queue #{TM.response_queue}\\n\"\n \n if @event_waiting_for == 0 && TM.response_queue.empty?\n \n # At the start of the enemies turn, just push all of them into next start\n # change start_event so that that is when everything happens.\n \n @event_waiting_for = TM.next_start\n # print \"@event_waiting_for = #{@event_waiting_for} start_queue #{TM.start_queue}\\n\"\n # print \"@event_waiting_for = #{@event_waiting_for}\\n\"\n \n if @event_waiting_for != 0\n \n # print \"routine for #{@event_waiting_for}\\n\"\n Era::AI.easy_main_routine(@event_waiting_for)\n Era::AI.start_event(@event_waiting_for)\n else\n ai_done_tb\n end\n else\n # set the event to 0 here responses are evaluted in base control flow.\n e = $game_map.events[@event_waiting_for]\n intp = e.interpreter\n intp_running = intp && intp.running?\n #print \"e.acts_done_tb #{e.acts_done_tb}\\n\" if e\n #print \"intp_running = #{intp_running}\\n\"\n #print \"event.list #{e.list}\\n\"\n if !e || (e.acts_done_tb)# && !(intp_running || e.starting))\n @event_waiting_for = 0\n end\n end\n end",
"def enter(state_manager, game)\n end",
"def game_core\n #frames counter for each job\n j1_frames = 10\n j2_frames = 10\n j3_frames = 10\n #duration of a \"frame\" in s\n multiplier = 10\n frame_duration = 0.005\n #loop untill end of the game\n while !$game_over\n if(j3_frames >= frame_duration * multiplier)\n input = get_inputs.downcase\n if(input == \"e\")\n system 'clear'\n return\n else\n input_handler(input)\n end\n j3_frames = 0\n end\n if(j1_frames >= frame_duration*multiplier)\n draw_graphic()\n j1_frames = 0\n end\n if(j2_frames >= frame_duration*(5-($score/80.01))*multiplier)\n move_player\n event_handler\n j2_frames = 0\n end\n j1_frames += frame_duration\n j2_frames += frame_duration\n j3_frames += frame_duration\n sleep frame_duration\n end\n #we get there only when the game is over\n system 'clear'\n puts \"----Game Over----\"\n puts \"You scored: \" + $score.to_s + \" points\"\n sleep 2\nend",
"def beginGameLoop\n @gameLoop.play\n end",
"def Come_back(shiny=nil, animation=nil)\n events=$PokemonGlobal.dependentEvents\n if $game_variables[Current_Following_Variable]==$Trainer.party.length\n remove_sprite(false)\n for i in 0...events.length \n $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents[i].x,@realEvents[i].y)\n end\n else\n if $Trainer.party[0].isShiny?\n shiny=true\n else\n shiny=false\n end\n change_sprite($Trainer.party[0].species, shiny, false)\n end\n for i in 0..$Trainer.party.length-1\n if $Trainer.party[i].hp>0 && !$Trainer.party[0].egg?\n $game_variables[Current_Following_Variable]=i\n refresh_sprite\n break\n end\n end\n for i in 0...events.length \n for i in 0..$Trainer.party.length-1\n if $Trainer.party[i].hp<=0 \n id = $Trainer.party[i].species\n else\n id = $Trainer.party[i].species\n end\n end\n if events[i] && events[i][8]==\"Dependent\"\n if shiny==true\n events[i][6]=sprintf(\"%03ds\",id)\n if FileTest.image_exist?(\"Graphics/Characters/\"+events[i][6])\n @realEvents[i].character_name=sprintf(\"%03ds\",id)\n else\n events[i][6]=sprintf(\"%03d\",id)\n @realEvents[i].character_name=sprintf(\"%03d\",id)\n end\n else\n events[i][6]=sprintf(\"%03d\",id)\n @realEvents[i].character_name=sprintf(\"%03d\",id)\n end\n if animation==true\n else\n end\n end \n end \nend",
"def onTimeoutAlgorithmHaveToPlay\r\n alg_play_acard\r\n # restore event process\r\n @core_game.continue_process_events if @core_game\r\n end",
"def play\n board_setup\n gameplay_setup\n end",
"def after_players_ready\r\n end",
"def run \n Engine::play(Beginning)\nend",
"def part1\n 2.times do\n \n 6.times do\n play :G4\n play :E4\n play :E2\n sleep 0.5\n end\n \n 2.times do\n play :A4\n play :E4\n play :E2\n sleep 0.5\n end\n end\nend",
"def on_turn_start\n check_turn_start_effects\n end",
"def after_play\n\n end",
"def run\n self.start_time = Time.now\n n = 0\n event = nil\n loop do\n handle_event event, n while event = SDL::Event.poll\n SDL::Key.scan\n handle_keys\n\n unless paused then\n update n unless paused\n\n draw_and_flip n\n\n n += 1 unless paused\n end\n end\n end",
"def initialize\n @id = 0 ## event id\n @ai = 0\n @hp = 30\n @meele_damage = 30\n @range_damage = 10\n @last_attack = 0\n @cooldown = 3 * Graphics.frame_rate ### 3 seconds in frames\n @alive = false\n @index = 0\n @active = false\n @damage_taken = 0\n @initialized = false ## this turns true when Enemy is alive or dead\n \n end",
"def before_players_ready\r\n end",
"def get_event(data)\n case data['game']\n when \"roll\"\n player = (data['sender'].to_i == player1.id) ? player1 : player2\n player.choose_figure! data['figure']\n end\n end",
"def processEvent(eventName)\n\tend",
"def game\n flash.keep\n @handler=EventHandler.new(user: user, game: @game, task: @task)\n # if !@handler.game_started?\n # @start_time=@game.game_started_block.time\n # render \"play/not_started\" # if stale? etag: [@start_time,\"play/not_started\"].join #не кэшируем из-за синхронизации времени\n # # fresh_when etag: [@start_time,\"play/not_started\"].join, public: true\n # elsif @handler.game_passed?\n # render \"play/win\"\n # else\n @task=@handler.current_tasks.last\n if @task #если есть первое (нет, последнее) не пройденное\n redirect_to play_show_url(game_id: @game.id, task_id: @task.id) and return #то перенаправить туда\n else\n render \"play/no_tasks\"\n end\n # end\n end",
"def run\n $log.info \"Starting Event Wizard\"\n loop do\n # reset variables\n min_wait = 30*DAY\n\n # perform overdue events; get min_wait time\n @events.each do |event|\n event.perform if Time.now - event.last_performed >= event.wait\n min_wait = event.wait if event.wait < min_wait\n end\n\n # sleep until another event is ready\n $log.info \"Sleeping for #{min_wait/MINUTE} minutes\"\n sleep min_wait\n end\n end",
"def step\n # Clear the screen.\n @screen.fill( :black )\n \n # Fetch input events, etc. from SDL, and add them to the queue.\n @queue.fetch_sdl_events\n \n # Tick the clock and add the TickEvent to the queue.\n @queue << @clock.tick\n \n # Process all the events on the queue.\n @queue.each do |event|\n handle( event )\n end\n \n # Draw the ship in its new position.\n @ship.draw( @screen )\n \n # Refresh the screen.\n @screen.update()\n end",
"def fire_events!(*events); end",
"def start_game(game_config)\n # start a new game\nend"
] | [
"0.68009317",
"0.66973954",
"0.6611504",
"0.64784753",
"0.6466699",
"0.64578646",
"0.64578646",
"0.64578646",
"0.64578646",
"0.64578646",
"0.64578646",
"0.64578646",
"0.64578646",
"0.63661695",
"0.6310187",
"0.6296134",
"0.62755257",
"0.6265301",
"0.6264616",
"0.62592226",
"0.62419564",
"0.62383056",
"0.6228273",
"0.6228273",
"0.6228273",
"0.6196072",
"0.61913574",
"0.61706954",
"0.6160215",
"0.6153357",
"0.6122078",
"0.6098433",
"0.6084762",
"0.608394",
"0.6083327",
"0.607759",
"0.6064786",
"0.60574645",
"0.6033519",
"0.6003666",
"0.6003666",
"0.6003666",
"0.6003666",
"0.6003666",
"0.60028243",
"0.60028243",
"0.5990145",
"0.59517324",
"0.5948436",
"0.59307545",
"0.59223133",
"0.5919573",
"0.59043396",
"0.59037983",
"0.5896931",
"0.589504",
"0.5888532",
"0.58694845",
"0.58638626",
"0.5862864",
"0.58554155",
"0.58478457",
"0.58453596",
"0.5833948",
"0.583361",
"0.5831983",
"0.58241934",
"0.58057195",
"0.580265",
"0.5800286",
"0.57883346",
"0.5787027",
"0.5777798",
"0.576872",
"0.57618046",
"0.57578015",
"0.5747776",
"0.5740155",
"0.5733833",
"0.5731441",
"0.57277256",
"0.5719843",
"0.5716551",
"0.5697866",
"0.5688784",
"0.56761515",
"0.567526",
"0.56724715",
"0.5660177",
"0.56558335",
"0.5642797",
"0.56404006",
"0.56398755",
"0.56283253",
"0.5626585",
"0.56160146",
"0.56126946",
"0.5596031",
"0.55903816",
"0.55868816"
] | 0.57864386 | 72 |
The sequences of events for a game | def play_cycle
play
earn_achievements
end_game
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_events\n @arpeggiators.each do |arpeggiator|\n arpeggiator.sequencer.event.stop << proc { @clock.stop }\n end\n @clock.event.tick << proc do\n @arpeggiators.map do |arpeggiator|\n arpeggiator.sequencer.exec(arpeggiator.sequence)\n arpeggiator\n end\n end\n true\n end",
"def execute_sequence\n case @acts[0]\n when SEQUENCE_POSE; setup_pose\n when SEQUENCE_MOVE; setup_move\n when SEQUENCE_SLIDE; setup_slide\n when SEQUENCE_RESET; setup_reset\n when SEQUENCE_MOVE_TO_TARGET; setup_move_to_target\n when SEQUENCE_SCRIPT; setup_eval_script\n when SEQUENCE_WAIT; @acts[1].times { method_wait }\n when SEQUENCE_DAMAGE; setup_damage\n when SEQUENCE_CAST; setup_cast\n when SEQUENCE_VISIBLE; @visible = @acts[1]\n when SEQUENCE_SHOW_ANIMATION; setup_anim\n when SEQUENCE_AFTERIMAGE; @afterimage = @acts[1]\n when SEQUENCE_FLIP; setup_flip\n when SEQUENCE_ACTION; setup_action\n when SEQUENCE_PROJECTILE_SETUP; setup_projectile\n when SEQUENCE_PROJECTILE; show_projectile\n when SEQUENCE_LOCK_Z; @lock_z = @acts[1]\n when SEQUENCE_ICON; setup_icon\n when SEQUENCE_SOUND; setup_sound\n when SEQUENCE_IF; setup_branch\n when SEQUENCE_TIMED_HIT; setup_timed_hit\n when SEQUENCE_SCREEN; setup_screen\n when SEQUENCE_ADD_STATE; setup_add_state\n when SEQUENCE_REM_STATE; setup_rem_state \n when SEQUENCE_CHANGE_TARGET; setup_change_target\n when SEQUENCE_TARGET_MOVE; setup_target_move\n when SEQUENCE_TARGET_SLIDE; setup_target_slide\n when SEQUENCE_TARGET_RESET; setup_target_reset\n when SEQUENCE_BLEND; @blend = @acts[1]\n when SEQUENCE_FOCUS; setup_focus\n when SEQUENCE_UNFOCUS; setup_unfocus\n when SEQUENCE_TARGET_LOCK_Z; setup_target_z\n # New update list v1.1\n when SEQUENCE_ANIMTOP; setup_anim_top\n when SEQUENCE_FREEZE; $game_temp.global_freeze = @acts[1]\n when SEQUENCE_CSTART; setup_cutin\n when SEQUENCE_CFADE; setup_cutin_fade\n when SEQUENCE_CMOVE; setup_cutin_slide\n when SEQUENCE_TARGET_FLIP; setup_targets_flip\n when SEQUENCE_PLANE_ADD; setup_add_plane\n when SEQUENCE_PLANE_DEL; setup_del_plane\n when SEQUENCE_BOOMERANG; @proj_setup[PROJ_BOOMERANG] = true\n when SEQUENCE_PROJ_AFTERIMAGE; @proj_setup[PROJ_AFTERIMAGE] = true\n when SEQUENCE_BALLOON; setup_balloon_icon\n # New update list v1.2\n when SEQUENCE_LOGWINDOW; setup_log_message\n when SEQUENCE_LOGCLEAR; get_scene.log_window.clear\n when SEQUENCE_AFTINFO; setup_aftinfo\n when SEQUENCE_SMMOVE; setup_smooth_move\n when SEQUENCE_SMSLIDE; setup_smooth_slide\n when SEQUENCE_SMTARGET; setup_smooth_move_target\n when SEQUENCE_SMRETURN; setup_smooth_return\n # New update list v1.3 + v1.3b + v1.3c\n when SEQUENCE_LOOP; setup_loop\n when SEQUENCE_WHILE; setup_while\n when SEQUENCE_COLLAPSE; tsbs_perform_collapse_effect\n when SEQUENCE_FORCED; setup_force_act\n when SEQUENCE_ANIMBOTTOM; setup_anim_bottom\n when SEQUENCE_CASE; setup_switch_case\n when SEQUENCE_INSTANT_RESET; setup_instant_reset\n when SEQUENCE_ANIMFOLLOW; setup_anim_follow\n when SEQUENCE_CHANGE_SKILL; setup_change_skill\n when SEQUENCE_CHECKCOLLAPSE; setup_check_collapse\n when SEQUENCE_RESETCOUNTER; get_scene.damage.reset_value\n when SEQUENCE_FORCEHIT; @force_hit = default_true\n when SEQUENCE_SLOWMOTION; setup_slow_motion\n when SEQUENCE_TIMESTOP; setup_timestop\n when SEQUENCE_ONEANIM; $game_temp.one_animation_flag = true\n when SEQUENCE_PROJ_SCALE; setup_proj_scale\n when SEQUENCE_COMMON_EVENT; setup_tsbs_common_event\n when SEQUENCE_GRAPHICS_FREEZE; Graphics.freeze\n when SEQUENCE_GRAPHICS_TRANS; setup_transition\n # New update list v1.4\n when SEQUENCE_FORCEDODGE; @force_evade = default_true\n when SEQUENCE_FORCEREFLECT; @force_reflect = default_true\n when SEQUENCE_FORCECOUNTER; @force_counter = default_true\n when SEQUENCE_FORCECRITICAL; @force_critical = default_true\n when SEQUENCE_FORCEMISS; @force_miss = default_true\n when SEQUENCE_BACKDROP; setup_backdrop\n when SEQUENCE_BACKTRANS; setup_backdrop_transition\n when SEQUENCE_REVERT_BACKDROP; $game_temp.backdrop.revert;Fiber.yield\n when SEQUENCE_TARGET_FOCUS; @focus_target = @acts[1]\n when SEQUENCE_SCREEN_FADEOUT; setup_screen_fadeout\n when SEQUENCE_SCREEN_FADEIN; setup_screen_fadein\n when SEQUENCE_CHECK_COVER; setup_check_cover\n when SEQUENCE_STOP_MOVEMENT; stop_all_movements\n when SEQUENCE_ROTATION; setup_rotation\n when SEQUENCE_FADEIN; setup_fadein\n when SEQUENCE_FADEOUT; setup_fadeout\n when SEQUENCE_IMMORTALING; setup_immortaling\n when SEQUENCE_END_ACTION; setup_end_action\n when SEQUENCE_SHADOW_VISIBLE; $game_temp.shadow_visible = default_true\n when SEQUENCE_AUTOPOSE; setup_autopose\n when SEQUENCE_ICONFILE; @icon_file = @acts[1] || ''\n when SEQUENCE_IGNOREFLIP; @ignore_flip_point = default_true\n # Interesting on addons?\n else; custom_sequence_handler\n end\n end",
"def events\n end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def played_events\n self.characters.reduce(Event.none) do |events, c|\n c.character_events.map { |ce| events << ce.event }\n end\n end",
"def tick events\r\n turn_radar 35 if time ==0\r\n turn_gun 25 if time <3\r\n accelaterate 2\r\n turn 2\r\n fire 4 unless events ['robot_scanned'].empty?\r\n end",
"def gameflow\n \n end",
"def events\n Enumerator.new(self,:each_event).to_a\n end",
"def do_turn_end_evs\n @wait_on_turn_end_evs = true\n ev_ids = TM.ev_turn_start[TM.turn_no]\n print \"do_turn_end_evs, ev_ids = #{ev_ids} turn_no = #{TM.turn_no}\\n\"\n if ev_ids\n ev_ids.each{|id| Era::AI.start_event(id)}\n end\n end",
"def make_actions(events, index, height)\n events.each_cons(2).map do |event, next_event|\n Action.new(\n state: event.state,\n start: Time.at(event.stamp),\n x: event.offset,\n y: (index + 1) * height,\n width: next_event.stamp - event.stamp,\n height: height\n )\n end\nend",
"def events\n event_enum\n end",
"def events\n event_enum\n end",
"def send_events; end",
"def action_sequence sequence, options = {}\n delay = options[:delay] || 0\n continuous_loop = false || options[:loop]\n\n first_step = sequence.shift\n\n if first_step.is_a? String\n first_step = CommandParser.parse self, sequence.shift\n end\n\n last_step = first_step\n\n if delay > 0\n sequence.each do |next_step|\n next_step = CommandParser.parse self, next_step if next_step.is_a? String\n last_step.attach_event CommandParser.future_event self, delay, next_step\n last_step = next_step\n end\n else\n sequence.each do |next_step|\n next_step = CommandParser.parse self, next_step if next_step.is_a? String\n last_step.attach_event next_step\n last_step = next_step\n end\n end\n\n if options[:initial_delay]\n first_step = CommandParser.future_event self, options[:initial_delay], first_step\n end\n\n if continuous_loop\n last_step.attach_event first_step\n end\n\n first_step\n end",
"def tick(events)\n end",
"def tick events\n if events['robot_scanned'].empty?\n turn 1\n else\n fire 3\n end\n end",
"def get_events\n events = []\n until ((event = SDL.PollEvent) == nil)\n new_event = Events.match(event)\n if new_event.is_a?(Events::KeyReleased)\n @keys_being_repeated.delete(new_event.key)\n end\n if new_event.is_a?(Events::KeyPressed) and not @keys_being_repeated.include?(new_event.key)\n @keys_being_repeated << new_event.key\n end\n events << new_event\n end\n @keys_being_repeated.each {|num| events << Events::KeyPressed.new(num)}\n events\n end",
"def events=(_); end",
"def possible_events\n\t\t\t@events = []\n\t\t\topts = self.class.class_variable_get :@@options\n\t\t\tif self.has_attribute?(opts[:column_name].to_sym)\n\n\t\t\t\t@current = send(opts[:column_name].to_sym).to_sym #self.state.to_sym\n\t\t\t\tevent_states_table = self.class.class_variable_get :@@event_states_table\n\t\t\t\tevent_states_table.keys.each do |k|\n\t\t\t\t\tevent_states_table[k].each do |s|\n\t\t\t\t\t\tif s[:transition].keys[0] == @current and !@events.include?(k)\n\t\t\t\t\t\t\tif s[:guard] != nil\n\t\t\t\t\t\t\t\tputs \"guard result #{s[:guard].call(self)} for #{k}\"\n\t\t\t\t\t\t\t\tif s[:guard].call(self)\n\t\t\t\t\t\t\t\t\t@events << k\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t@events << k\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\tend\n\t\t\t@events\n\t\tend",
"def process_events(events)\n @card_events = events.select(&:card?) \n events \n end",
"def get_events\n ConsoleDisplay.events_to_command\n end",
"def test_sequence\n result=[]\n at=Activity_tracker.new do |id|\n result.push id\n end\n at.active 1\n sleep at.tick_time\n at.active 2\n sleep at.tick_time\n at.active 1\n sleep at.tick_time\n at.active 3\n sleep at.timeout+at.tick_time\n assert result==[2,1,3], \"result was: \"+result.join(\", \")\n end",
"def next_event message\n return nil if !@events.has_key? message.next_sequence\n @events[message.next_sequence]\n end",
"def print_events(events)\n events.each do |name, description|\n puts \"Event: #{name}\"\n puts \"Description: #{description} \\n\\n\"\n end\n end",
"def game_loop\n end",
"def setup_tsbs_common_event\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n @acts[1] = 0 unless @acts[1].is_a?(Numeric)\n $game_temp.tsbs_event = @acts[1]\n Fiber.yield\n end",
"def game_loop\n end",
"def results\n @results ||= registered_events.map do |event|\n Vedeu.outdent do\n Vedeu.log(type: :event, message: message)\n\n Vedeu.indent do\n event.trigger(*args)\n end\n end\n end\n end",
"def part1\n 2.times do\n \n 6.times do\n play :G4\n play :E4\n play :E2\n sleep 0.5\n end\n \n 2.times do\n play :A4\n play :E4\n play :E2\n sleep 0.5\n end\n end\nend",
"def began msg\n end",
"def play\n greeting\n get_tiles\n move_sequence\n end",
"def events\n @execution.events if @execution\n end",
"def phase_sequence\n hash = {\n :idle => method(:idle_key),\n :victory => method(:victory_key),\n :hurt => method(:hurt_key),\n :skill => method(:skill_key),\n :evade => method(:evade_key),\n :return => method(:return_key),\n :escape => method(:escape_key),\n :prepare => method(:prepare_key),\n :intro => method(:intro_key),\n :counter => method(:counter_key),\n :collapse => method(:collapse_key),\n :forced => method(:forced_act),\n :covered => method(:covered_key),\n }\n return hash\n end",
"def all\n ButterSand::Parser.to_array(get(PATH_SAIJI)).map {|event| ButterSand::Event.new(event)}\n end",
"def event\n\t\twhile event = SDL::Event2.poll\n\t\t\tcase event\n\t\t\twhen SDL::Event2::Quit\n\t\t\t\treturn [:quit]\n\t\t\twhen SDL::Event2::MouseButtonDown\n\t\t\t\treturn [:mouse, event.x, event.y]\n\t\t\twhen SDL::Event2::KeyDown\n\t\t\t\treturn [:escape] if event.sym == SDL::Key::ESCAPE\n\t\t\t\treturn [:space] if event.sym == SDL::Key::SPACE\n\t\t\tend\n\t\tend\n\t\treturn []\n\tend",
"def upcaming_events\n self.attended_events.upcaming\n end",
"def events\n event_lookup()\n end",
"def events\n event_lookup()\n end",
"def human_event; end",
"def on_input\n @movement.each do |entity|\n entity[:movement]= nil\n end\n\n @player[:action]= case @window.active_input\n when \"h\" then [:move, Vector[-1, 0]]\n when \"j\" then [:move, Vector[ 0, 1]]\n when \"k\" then [:move, Vector[ 0, -1]]\n when \"l\" then [:move, Vector[ 1, 0]]\n when \"y\" then [:move, Vector[-1, -1]]\n when \"b\" then [:move, Vector[-1, 1]]\n when \"u\" then [:move, Vector[ 1, -1]]\n when \"n\" then [:move, Vector[ 1, 1]]\n when \"g\" then [:draw_card]\n when \"f\" then [:play_weapon]\n when \"d\" then [:play_spell]\n when \"s\" then [:play_item]\n when \"a\" then [:replace_item]\n when \"q\" then throw(:game_end)\n else\n return\n end\n\n @ai_method.each do |entity|\n entity[:action] = self.send(entity[:ai_method], entity)\n end\n\n @action.each do |entity|\n action, *args = entity[:action]\n next if action.nil?\n\n self.send(action, entity, *args)\n entity[:action]= nil\n end\n\n @movement.each do |entity|\n next if entity[:movement].nil?\n\n oldpos = entity[:position]\n newpos = entity[:position] + entity[:movement]\n\n next if out_of_bounds?(newpos)\n\n entities_at_pos = @map[:index][newpos]\n obstructed = entities_at_pos.any? do |entity|\n entity[:obstructing] == true\n end\n next if obstructed\n\n b = entity[:position]\n m = entity[:movement] / 5.0\n points = 6.times.map { |t| (b + (m*t)) }\n\n entity[:position]= newpos\n entity[:movement]= nil\n entity[:tween_points]= points\n @map[:index][oldpos].delete(entity)\n @map[:index][newpos].push(entity)\n end\n\n @animating = true\n end",
"def start_phase4\n @a_remaining_pk.visible = false\n @e_remaining_pk.visible = false if $game_temp.trainer_battle\n @phase = 4\n $game_temp.battle_turn += 1\n for index in 0...$data_troops[@troop_id].pages.size\n page = $data_troops[@troop_id].pages[index]\n if page.span == 1\n $game_temp.battle_event_flags[index] = false\n end\n end\n @enemy_actions.clear\n @actor_actions.clear\n #Test IA\n @seed = @magneto.get_action\n @actor_actions += @magneto.get_action\n @enemy_actions += @magneto.get_action\n pc \"New seed : #{@seed}\"\n srand(@seed)\n #>Sécurité\n BattleEngine::set_actors(@actors)\n BattleEngine::set_enemies(@enemies)\n @actions = BattleEngine::_make_action_order(@actor_actions, @enemy_actions, @actors, @enemies)\n @phase4_step = 0\n launch_phase_event(4,true)\n end",
"def process_events\n while e = get_event\n begin\n # pre triggers\n obj = Engine.instance.db.get(e.to)\n obj2 = Engine.instance.db.get(e.from)\n sid = obj.get_trigger(\"pre_\"+e.kind.to_s)\n if sid\n script = Engine.instance.db.get(sid)\n if script\n if script.execute(e)\n # success\n if obj2.class == Character\n s,o = obj.msgsucc.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n else\n # failure\n if obj2.class == Character\n s,o = obj.msgfail.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n next\n end\n else\n log.error \"Script not found: #{sid} for Event: #{e}\"\n # We fail the action slently\n next\n end\n end\n\n # action receiver\n obj.send(e.kind,e)\n\n # post triggers\n sid = obj.get_trigger(e.kind)\n if sid\n script = Engine.instance.db.get(sid)\n if script\n if script.execute(e)\n # success\n if obj2.class == Character\n s,o = obj.msgsucc.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n else\n # failure\n if obj2.class == Character\n s,o = obj.msgfail.split(\"|\")\n obj2.sendto(s) if s && !s.empty?\n if o && !o.empty?\n Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|\n add_event(obj2.id,p.id,:show,\"#{obj2.name} #{o}\")\n end\n end\n end\n end\n else\n log.error \"Script not found: #{sid} for Event: #{e.inspect}\"\n # We fail the action slently\n end\n end\n rescue\n log.error \"Event failed: #{e.inspect}\"\n log.error $!\n end\n end\n end",
"def run events\n events.each do |event| \n interprete event\n end\n# return\n puts \"Statistics:\"\n @counts.each do |k,v|\n puts \"#{k.inspect} =>\"\n i = 0\n step = 6\n while i < v.size\n puts \"\\t#{v[i,step]}\"\n i += step\n end\n end\n end",
"def pbCommonEvent(id)\n return false if id<0\n ce=$data_common_events[id]\n return false if !ce\n celist=ce.list\n interp=Interpreter.new\n interp.setup(celist,0)\n begin\n Graphics.update\n Input.update\n interp.update\n pbUpdateSceneMap\n end while interp.running?\n return true\nend",
"def tick events\n @outerlimit = (battlefield_width + battlefield_height) * 3\n #print \"mode=#{@mode},stage=#{@stage},dir=#{@dir},walldir=#{@walldir}\\n\"\n #print \"at (#{x},#{y}) at time #{time},res=#{@trk_res}\\n\"\n #mode nil is startup and initialize variables\n #STDOUT.flush\n # ###########\n # # Sensors\n # ###########\n @since_evade += 1\n @sincehit += 1\n @sincehit = 0 if not events['got_hit'].empty?\n events['got_hit'].each{|e| @hit_filter += e.first}\n @hit_filter *= 0.99\n if events['robot_scanned'].empty?\n @sinceblip += 1\n @closest = @outerlimit\n #print\"\\n\" \n else\n @closest = events['robot_scanned'].collect{|e| e.first}.sort.first\n @sinceblip = 0\n #print \",blip=#{@closest}\\n\"\n end\n # ###########\n # # High level logic - state machine\n # ###########\n #print \"sincehit=#{@sincehit},closest=#{@closest},range=#{@range}\\n\"\n #mode 0 is orient tank\n if @mode == 0\n @stage = 0\n @range = @outerlimit\n @mode = 1 if aimrad(@dir*90)\n #mode 1 find range of nearest target\n elsif @mode == 1\n #setup radar for a scan\n if @stage==0\n aimrad(@dir*90 + 180,60,1)\n @range = min(@range,@closest)\n @stage +=1\n #continue around for full circle\n elsif @stage == 1\n @range = min(@range,@closest)\n if aimrad(@dir*90,60,1)\n #did we see a bot?\n if @range == @outerlimit\n @stage = 0 \n else\n @mode = 2\n @stage = 0\n end\n end\n end\n #mode 2: find the nearestbot\n elsif @mode == 2\n #start next circle to re find the closest bot\n if @stage == 0\n #print \"range is #{@range}\\n\"\n aimrad(@dir*90 + 180,60,1)\n @stage +=1\n #continue scan for the closest bot\n elsif @stage == 1\n #print \"dir=#{@dir},angle=#{radar_heading}, closest=#{@closest}\\n\"\n if @closest < @range * 1.25\n @range = @closest\n @mode = 3\n @stage = 0\n @tangle = radar_heading\n #print \"found target at angle #{@tangle}\\n\"\n #if we finished the scan, and didn't find close target, recompute range\n elsif aimrad(@dir*90,60,1)\n @mode = 0\n @stage =0\n end\n end\n #mode 3 is tracking bot\n elsif @mode == 3\n #entry from previous mode, determine whether to scan ccw or cw\n if @stage == 0\n @trk_dir,@trk_res,@stage = -1,4,2\n #first scan in this direction\n elsif @stage == 1\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n else\n @stage = 2\n end\n #second scan in this direction\n elsif @stage == 2\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n else\n @trk_dir = -@trk_dir\n @trk_res = min(@trk_res + 2,4)\n @stage = 3\n end\n #the target bot has moved out of our window, expand the window\n elsif @stage == 3\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = - @trk_dir\n @trk_res = max(@trk_res - 2,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n elsif @trk_res < 6\n @trk_dir = - @trk_dir\n @trk_res = @trk_res +1\n else\n #we lost our target, reaquire from scratch\n @mode = 0\n @stage = 0\n end\n end\n @tangle += @@ScanRes[@trk_res] * @trk_dir\n aimrad(@tangle)\n #print\"tangle=#{@tangle}, res=#{@@ScanRes[@trk_res]}, rot=#{@trk_dir}\\n\"\n elsif @mode == 4\n #determine which corner to go to from a corner\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 + 95*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 60*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @prevCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n elsif @stage == 3\n aimrad(@dir*90 -5*@walldir)\n @stage += 1\n elsif @stage == 4\n @nextCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + @walldir)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n elsif @mode == 5\n #determine which corner to go to from middle of wall\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 - 5*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @nextCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 150*@walldir)\n @stage += 1\n elsif @stage == 3\n @stage += 1 \n aimrad(@dir*90 -150*@walldir)\n elsif @stage == 4\n aimrad(@dir*90 -185*@walldir)\n @stage += 1\n elsif @stage == 5 \n @prevCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + 2)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n end\n #compute the distances to the four walls\n walls = [battlefield_width - x,y,x,battlefield_height - y]\n #hug the wall, if we are slightly off the wall, than move back to the wall\n toleftwall,torightwall = walls[(@dir+1)%4],walls[(@dir-1)%4]\n #print \"wallroom left=#{toleftwall}, right=#{torightwall}\\n\"\n if toleftwall > 80 and toleftwall < 200\n aimtank(@dir * 90 + 20)\n elsif torightwall > 80 and torightwall < 200\n aimtank(@dir * 90 - 20)\n else\n aimtank(@dir * 90)\n end\n #If we reach a corner or wall, turn towards farthest corner on this wall\n if walls[@dir] < 100\n if toleftwall > torightwall\n @walldir = 1 #we are now going ccw\n @dir = (@dir+1)%4 # turn ccw\n #print \"turn left\\n\" \n else\n @walldir = -1 #we are now going cw\n @dir = (@dir-1)%4 #turn cw\n #print \"turn right\\n\" \n end\n #don't check corners at T junction\n if toleftwall > 100 and torightwall > 100\n @mode = 5 # determin weather it is safer ahead or behind\n @stage = 0\n else\n @mode = 4 # determin if previous corner was safer\n @stage = 0\n end\n #If we are getting hammered, turn now to evade damage\n # once we evade, avoid making another evasive manuver or we will turn in circles\n elsif @hit_filter > 400 and @since_evade > 100\n @dir = (@dir+@walldir)%4\n @hit_filter = 0\n @since_evade = 0\n end\n accelerate 1\n aim = @mytrack.predict(x,y,time) || (@dir * 90)%360\n aimgun(aim)\n fire 0.1\n doturns #we already computed our turns, now execute them\n STDOUT.flush\n end",
"def pbCommonEvent(id)\n return false if id<0\n ce = $data_common_events[id]\n return false if !ce\n celist = ce.list\n interp = Interpreter.new\n interp.setup(celist,0)\n begin\n Graphics.update\n Input.update\n interp.update\n pbUpdateSceneMap\n end while interp.running?\n return true\nend",
"def events_happening_at\n find_related_frbr_objects( :happens_at, :which_events?) \n end",
"def play\n #calls to all the methods that produce game!\n end",
"def next_state_events\n\n t = self.state_transitions(:from => self.state.to_sym)\n authorized_events = Array.new\n\n t.each do |transition|\n #if (is_authorized_event?(transition.event.to_s, user.role.name, self.state))\n authorized_events << transition\n #end\n end\n authorized_events\n end",
"def send_events=(_arg0); end",
"def events\n self.class.state_machine.events_for(current_state)\n end",
"def run\n @running = true\n clock = Rubygame::Clock.new()\n queue = Rubygame::EventQueue.new()\n queue.enable_new_style_events\n rl = ResourceLocator.instance\n \n clock.tick\n while @running and self.current\n pre_transition = self.current # All events in the queue are applied to the\n # current state\n mouseUps = []\n queue.each do |event|\n pre_transition.raw(event) if pre_transition.respond_to?(:raw)\n case(event)\n when QuitRequested\n @running = false\n when KeyPressed\n result = @hooks[event.key]\n result.call(self) if result\n #puts event.key\n pre_transition.keyEvent(event,true)\n when KeyReleased\n pre_transition.keyEvent(event, false)\n when MouseMoved\n pre_transition.mouseMove(event)\n when MousePressed\n pre_transition.mouseDown(event)\n when MouseReleased\n mouseUps << event\n end\n end\n \n # This is done outside of the event-handling loop, because otherwise\n # the when the continuations it causes (i.e. pressing the 'done' button)\n # return, they bring back the old state of the event queue with them,\n # and the mouse events are re-played.\n mouseUps.each do | event |\n pre_transition.mouseUp(event)\n end\n \n rl.screen.fill([0,0,0])\n current.draw(rl.screen) if current\n rl.screen.flip\n elapsed = clock.tick / 1000.0\n current.update(elapsed) if current\n\n Rubygame::Clock.wait(50)\n \n end\n Rubygame::quit\n end",
"def events\n @events ||= LIFECYCLE_EVENTS.each_with_object({}) { |e, a| a[e] = [] }\n end",
"def listOfEvents\r\n puts (@BetESS.fDisplayEvents)\r\n end",
"def event; end",
"def event; end",
"def event; end",
"def onTimeoutAlgorithmHaveToPlay\r\n alg_make_move\r\n # restore event process\r\n @core_game.continue_process_events if @core_game\r\n end",
"def result\n @result = binding.events.select do |e| \n case options[:cyclic]\n when true\n e.cycle?\n when false\n !e.cycle?\n else\n true\n end\n end.map do |event|\n next if options[:event] and event != options[:event]\n returning [] do |ts|\n\n # TODO hmm ... \"sequences\" ... undecided on these. see Event / Lathe for more detail \n if options[:sequences]\n if target = event.target_for_origin(current_state)\n ts << binding.transition([event,target], *args) unless options[:cyclic]\n end\n end\n\n # build a list of transitions from the possible events and their targets\n if event.targets\n next unless event.target if options[:simple]\n event.targets.flatten.each do |target|\n next if options[:target] and target != options[:target]\n t = Transition.new(binding, event, target, *args)\n ts << t if (t.valid? or !options[:valid])\n end\n end\n\n end\n end.flatten.extend(Result)\n \n if @args || @block\n @result.each do |t|\n t.apply!( &@block) if @block \n t.args = @args if @args\n end\n end\n \n @result\n end",
"def step\n @queue << UndrawSprites.new( @screen, @background )\n @queue.fetch_sdl_events\n @queue << $game.clock.tick\n @queue << DrawSprites.new( @screen )\n @queue.each do |event|\n handle( event )\n end\n end",
"def game_state\n end",
"def all_events\n events.keys\n end",
"def next_events\n self.around_events.select{|event|\n event.location.present? && event.start_time > self.end_time\n }.sort{|a,b| a.start_time <=> b.start_time}\n end",
"def next_event\n return [nil,[]] unless location.feature\n f = location.feature\n @next = self.priority\n begin\n @next = f.next_priority(@next)\n return [nil,nil] unless @next\n @choices, @autos = f.available_events(@next, location, player_character.id)\n end while @autos.size + @choices.size == 0\n \n if @autos.size > 0 && @choices.size > 0\n @pick = rand(@autos.size + @choices.size)\n if @pick < @autos.size\n return @next, @autos[@pick]\n else\n return @next, @choices\n end\n elsif @autos.size > 0\n return @next, @autos[rand(@autos.size).to_i]\n else #@choices.size > 0\n return @next, @choices\n end\n end",
"def do_finish_ai\n # print \"in do_finish_ai @wait_on_ai #{@wait_on_ai}\\n\"\n # print \"@event_waiting_for #{@event_waiting_for}\\n\"\n # print \"TM.response_queue #{TM.response_queue}\\n\"\n \n if @event_waiting_for == 0 && TM.response_queue.empty?\n \n # At the start of the enemies turn, just push all of them into next start\n # change start_event so that that is when everything happens.\n \n @event_waiting_for = TM.next_start\n # print \"@event_waiting_for = #{@event_waiting_for} start_queue #{TM.start_queue}\\n\"\n # print \"@event_waiting_for = #{@event_waiting_for}\\n\"\n \n if @event_waiting_for != 0\n \n # print \"routine for #{@event_waiting_for}\\n\"\n Era::AI.easy_main_routine(@event_waiting_for)\n Era::AI.start_event(@event_waiting_for)\n else\n ai_done_tb\n end\n else\n # set the event to 0 here responses are evaluted in base control flow.\n e = $game_map.events[@event_waiting_for]\n intp = e.interpreter\n intp_running = intp && intp.running?\n #print \"e.acts_done_tb #{e.acts_done_tb}\\n\" if e\n #print \"intp_running = #{intp_running}\\n\"\n #print \"event.list #{e.list}\\n\"\n if !e || (e.acts_done_tb)# && !(intp_running || e.starting))\n @event_waiting_for = 0\n end\n end\n end",
"def do_event\n=begin\n\n event = Events.new(@resources[:luck])\n # starts an event\n event.start\n decision = gets.chomp\n\n until event.accepts? decision # Requires valid input\n UiHandler.print_error(event.valid_range)\n decision = gets.chomp\n end\n\n # event.dispatch accepts player decision and affects the world\n # returning new number of resources\n @resources = event.dispatch(decision)\n\n=end\n end",
"def events\n @@events\n end",
"def reccomend_me\n event_list = score_events.keys\n event_list.first 5\n end",
"def fire_events!(*events); end",
"def events\n @events ||= []\n @events\n end",
"def show_action_sequences(targets, item, subj)\n tsbs_action_init(targets, item, subj)\n tsbs_action_pre(targets, item, subj)\n tsbs_action_main(targets, item, subj)\n tsbs_action_post(targets, item, subj)\n tsbs_action_end(targets, item, subj)\n $game_temp.backdrop.reset_transition_flags\n wait(tsbs_wait_dur)\n end",
"def tick args\r\n\r\n # For an example we are going to create an interface with the expressions shown in the demo.\r\n # To show each element one at a time we are going to create an if statement to separate each step\r\n # This way we can see each element introduced individually as to not get too overwhelming.\r\n\r\n #-----------Ticks\r\n # First we are going to want a variable to represent the tick count there are 60 ticks per second\r\n # Ticks also represent the number of frames of the game that exist consecutively per second\r\n ticks = args.state.tick_count # Having a variable lets us bypass using the whole expression going forward.\r\n\r\n # The tick count is useful.\r\n # It allows us to know how many instances of the game have ran,\r\n # it gives us a sense of time for our game,\r\n # and because game will update every frame,\r\n # it will allow us to differentiate actions depending on the current frame.\r\n\r\n # Something it can also allow for is the animation sprites and environments.\r\n # Unfortunately we wont have time to go over that, so expect a later tutorial to cover that.\r\n\r\n #----------- Mouse clicks and inputs\r\n # One more declaration we are going to for the tutorial is click count\r\n # Because there is a game instance every frame,\r\n # we need a way to save the changes from frame to frame\r\n # We can do this by creating a state variable.\r\n # State variables are best created in an if statement for our purposes.\r\n # If we try to create them outside of the if statement,\r\n # it can result in the variable being redeclared with it's starting value every frame.\r\n\r\n # So we create click_count\r\n # In this case, if click_count doesnt exist we create it.\r\n if !args.state.click_count\r\n\r\n args.state.click_count = 0\r\n end\r\n\r\n # We are making click_count, to track how many clicks have occurred inside the game window.\r\n # Using this we are able to change the game state every time a click occurs inside the window.\r\n # Clicking on it now will reveal a temporary message from further in the tutorial.\r\n\r\n # Now we check to see if the click has returned to the up position.\r\n # Every time this occurs we can increment click count by one.\r\n if args.inputs.mouse.up\r\n args.state.click_count += 1\r\n # We also need to reset mouse.up to 0 so it doesn't continuously increment click_count every frame.\r\n args.inputs.mouse.up = 0\r\n end\r\n # This is one of the many example of how you can use inputs to receive information from the user.\r\n # In this case we are receiving a click from the user\r\n # and depending on the number of clicks we are outputting different information onto the screen.\r\n # The way we set it up, it's kind of like a power point in that each click adds an additional component.\r\n\r\n # We can take input from any key, click or button via the\r\n # args.inputs.mouse, args.inputs.keyboard, and args.inputs.controller expressions.\r\n # Adding key designations to keyboard and controller expressions allow us to use\r\n # almost any key or button in our game.\r\n # From there we can add .up, .down, .held, .click\r\n # and all sorts of expressions to change the the information we are obtaining from a press.\r\n\r\n # There will be direct example in the sprite section of the tutorial\r\n\r\n######################################################\r\n # So where do we start?\r\n # We already have.\r\n\r\n # To get some actual output onto the screen though, we will start with labels,\r\n # but there are many other expressions\r\n # that you can expect to find in the dragonruby gametoolkit (gtk).\r\n # These expressions are: labels, lines, borders, solids, sprites, inputs, outputs, keyboard, mouse, and controller\r\n # There are many other expressions with more added with every update, but i am going to start with these.\r\n\r\n #----------- Labels\r\n\r\n # Our first label will be placed onto the top right corner of the screen.\r\n\r\n # This is the if statement that will change what pops up onto the screen\r\n # Each time we click the mouse.\r\n # If you haven't clicked once yet, CLICK NOW!\r\n if args.state.click_count == 1\r\n\r\n # To create a label with the gtk we will need to use the following array format:\r\n # X Y TEXT SIZE ALIGNMENT RED GREEN BLUE ALPHA FONT FILE\r\n args.outputs.labels << [1000, 720, \"This is a temp msg\", 5, 0, 200, 050, 100, 175, \"fonts/coolfont.ttf\"]\r\n end\r\n\r\n # The parameters start with the coordinate, x and y,\r\n # followed by the text in quotations that you want outputted,\r\n # each of which is to be separated by a comma.\r\n # After that we have the text size, alignment, of which 1 will center your text on the coordinates,\r\n # followed by red, green, and blue saturation.\r\n # Finally, the alpha is the transparency,\r\n # which needs to be set at 255 to be solid, and lastly is font with the extension .ttf.\r\n\r\n #\r\n\r\n # Click!\r\n if args.state.click_count > 2\r\n # we are going to replace this temp message with the tick count in the corner.\r\n # It will help us keep track of how many instances of the game have ran among other things.\r\n args.outputs.labels << [1000, 720, ticks, 25, 0, 200, 050, 100, 25]\r\n end\r\n\r\n # Click!\r\n if args.state.click_count > 3\r\n # We can leave off parameters if you dont need them as well.\r\n # Leaving them off will set them to a default value.\r\n args.outputs.labels << [640, 700, \"This is a game\", 0, 1] # This will be the title for the game.\r\n end\r\n\r\n # Click!\r\n if args.state.click_count > 4\r\n # We can also use a hash, which is a more readable version, that sometimes has more functionality.\r\n args.outputs.labels << {\r\n x: 10,\r\n y: 710,\r\n text: \"Lives:\",\r\n size_enum: -3,\r\n alignment_enum: 0,\r\n r: 155,\r\n g: 50,\r\n b: 50,\r\n a: 255,\r\n font: \"fonts/manaspc.ttf\"\r\n }\r\n end\r\n # Most of the expressions have a more readable version like this\r\n # which can help when you are just starting out.\r\n # Hashes may be more readable, but they are harder on performance.\r\n # Arrays are faster and easier to compile.\r\n # It's more efficient to use arrays, so once the developer gets use to them,\r\n # unless hashes are needed for functionality, arrays are the go to.\r\n\r\n #----------- Lines\r\n # Click!\r\n if args.state.click_count > 5\r\n # The next expression we will go through is lines:\r\n # X1 Y1 X2 Y2 RED GREEN BLUE ALPHA\r\n args.outputs.lines << [ 0, 600, 1280, 600, 0, 0, 0, 255]\r\n end\r\n # Lines are different but a little less complicated.\r\n # The first 4 fields are the x/y coordinate beginning and end points.\r\n # x1, y1 are the origin points, and x2, y2 are the end points to the line.\r\n # Just like with labels you can change the color of the line.\r\n # You can even make it invisible or transparent using alpha if you want.\r\n\r\n # The Line also has a hash\r\n\r\n # Click!\r\n if args.state.click_count == 7\r\n args.outputs.lines << {\r\n x: 0,\r\n y: 0,\r\n x2: 1280,\r\n y2: 720,\r\n r: 0,\r\n g: 255,\r\n b: 0,\r\n a: 255\r\n }\r\n args.outputs.lines << [0, 720, 1280, 0]\r\n end\r\n\r\n # So far so good.\r\n # Our user interface is looking alright.\r\n # I think we could make the title more distinct however.\r\n\r\n #----------- Solids and boarders\r\n\r\n # For this we are going to use some boarders and solids.\r\n # Lets declare some values.\r\n # Remember that the coordinate for the title label were: 640, 700\r\n # and alignment was selected to center the text.\r\n # Often you will want to play with the coordinate to get things where you want them.\r\n # We shall create a couple variables to assist in this process.\r\n board_x = 540\r\n board_y = 668\r\n board_w = 200\r\n board_h = 45\r\n echo = 4 # Echo is going to represent a slight modification to the original values\r\n # our echo value will allow us to change additional solids and boarders to make the background more distinct\r\n # Click!\r\n if args.state.click_count > 7\r\n\r\n # X Y WIDTH HEIGHT RED GREEN BLUE ALPHA\r\n args.outputs.borders << [board_x, board_y, board_w, board_h, 0, 0, 200, 255]\r\n end\r\n\r\n # Boarders and solids are like lines, but they start at the desired coordinate and then have\r\n # a width and height.\r\n # X, Y are the coordinates and w and h are width and height.\r\n # Similarly to the other expressions we also have alignment and color.\r\n\r\n\r\n # Click!\r\n if args.state.click_count > 8\r\n # Here we have the additional borders at an offset of size echo\r\n args.outputs.borders << [board_x - echo, board_y - echo, board_w + echo * 2, board_h + echo * 2, 200, 0, 0, 255]\r\n end\r\n if args.state.click_count > 9\r\n args.outputs.solids << [board_x - echo, board_y - echo, board_w + echo * 2, board_h + echo * 2, 35, 0, 50, 255]\r\n end\r\n\r\n echo -= 5\r\n # Changing the echo here can allow to create a depth effect\r\n # or add layers to the background of the title\r\n\r\n # Click!\r\n if args.state.click_count > 9\r\n args.outputs.solids << {\r\n x: board_x - echo,\r\n y: board_y - echo,\r\n w: board_w + echo * 2,\r\n h: board_h + echo * 2,\r\n r: 25,\r\n g: 100,\r\n b: 40,\r\n a: 255\r\n }\r\n echo = 10\r\n args.outputs.solids << [board_x - 4, board_y - echo, board_w + echo + 4, board_h + echo + 4, 0, 35, 0, 20]\r\n # This is a very basic shadow to show how these might be done.\r\n # It doesnt look great but if we used a similar looking sprite \r\n # with rounded edges we might get a better effect\r\n end\r\n\r\n # Now that our tittle is more distinct, our rough user interface is done for the movement.\r\n # The next steps will cover sprites, movement and wrapping.\r\nend",
"def setup\n @turn_order_delegate = self\n @end_game_delegate = self\n #a = self.players.length if self.players\n #puts \"first player id: #{@players.first.id}\"\n #broadcast_event Game::GAME_INITIALIZED, {}\nend",
"def events *args, &block\n valid_in_context nil, State\n each_state_or_event 'event', *args, &block\n end",
"def perform\n\tgame_menu\n\tgameplay\nend",
"def runner_signals\n return @runner_inputs.values + @runner_outputs.values +\n @runner_inouts.values\n end",
"def setup_event_hooks\n hooks = {\n :escape => :quit,\n :q => :quit,\n :s => :toggle_smooth,\n\n QuitRequested => :quit,\n\n # Tell the user where they clicked.\n MousePressed => proc { |owner, event|\n puts \"click: [%d,%d]\"%event.pos\n },\n\n # These help to ensure everything is refreshed after the\n # Rubygame window has been covered up by a different window.\n InputFocusGained => :update_screen,\n WindowUnminimized => :update_screen,\n WindowExposed => :update_screen,\n\n # Refresh the window title.\n :tick => :update_framerate\n }\n\n make_magic_hooks( hooks )\n end",
"def map_events\n mapped_timeline = Timeline.new\n self.each do |time,events|\n mapped_timeline[time] = events.map{|event| yield event }\n end\n mapped_timeline\n end",
"def event_types; end",
"def setup_starting_event\r\n # Refresh the event page when switch/variable was changed\r\n $game_map.refresh if $game_map.need_refresh\r\n # Start common event if required\r\n if $game_temp.common_event_id > 0\r\n setup($data_common_events[$game_temp.common_event_id].list, 0)\r\n $game_temp.common_event_id = 0\r\n return\r\n end\r\n # Try to start an event\r\n $game_map.events.each_value do |event|\r\n next unless event.starting\r\n if event.trigger < 3\r\n event.clear_starting\r\n event.lock\r\n end\r\n return setup(event.list, event.id)\r\n end\r\n # Try to start a common event\r\n $data_common_events.each do |common_event|\r\n next unless common_event&.trigger == 1 && $game_switches[common_event.switch_id]\r\n return setup(common_event.list, 0)\r\n end\r\n end",
"def terminal_events\n bound_events.each_value.find_all(&:terminal?)\n end",
"def handle_event event \n case event[:name]\n when 'sleep'\n puts 'sleep'\n sleep 4\n \n when 'change_state'\n puts 'change_state'\n \n when 'tick'\n puts 'tick'\n \n end\n end",
"def map_events!\n each do |time,events|\n self[time] = events.map{|event| yield event }\n end\n end",
"def remaining_events_slots\n #num de eventos dos pacotes - num de eventos que possui\n self.max_events - self.active_events_count\n end",
"def animloop\n animation_array[@anim_index + 1]\n end",
"def event\r\n @event\r\n @comments\r\n @replies \r\n end",
"def finish_events\n audio_event = @vj.fetch_last_event(:audio)\n audio_event.set_duration_now! unless audio_event.nil?\n video_event = @vj.fetch_last_event(:video)\n video_event.set_duration_now! unless video_event.nil?\n end",
"def initialize\n @started_events = []\n @succeeded_events = []\n @failed_events = []\n end",
"def terminal_events\n each_event.find_all { |_, e| e.terminal? }\n .map { |_, e| e }\n end",
"def start\n events.map(&:schedule)\n end",
"def onTimeoutAlgorithmHaveToPlay\r\n alg_play_acard\r\n # restore event process\r\n @core_game.continue_process_events if @core_game\r\n end",
"def game_core\n #frames counter for each job\n j1_frames = 10\n j2_frames = 10\n j3_frames = 10\n #duration of a \"frame\" in s\n multiplier = 10\n frame_duration = 0.005\n #loop untill end of the game\n while !$game_over\n if(j3_frames >= frame_duration * multiplier)\n input = get_inputs.downcase\n if(input == \"e\")\n system 'clear'\n return\n else\n input_handler(input)\n end\n j3_frames = 0\n end\n if(j1_frames >= frame_duration*multiplier)\n draw_graphic()\n j1_frames = 0\n end\n if(j2_frames >= frame_duration*(5-($score/80.01))*multiplier)\n move_player\n event_handler\n j2_frames = 0\n end\n j1_frames += frame_duration\n j2_frames += frame_duration\n j3_frames += frame_duration\n sleep frame_duration\n end\n #we get there only when the game is over\n system 'clear'\n puts \"----Game Over----\"\n puts \"You scored: \" + $score.to_s + \" points\"\n sleep 2\nend",
"def update_encounter\r\n # Event determinant is via touch of same position event\r\n result = check_event_trigger_here([1,2])\r\n # If event which started does not exist\r\n if result == false\r\n # Disregard if debug mode is ON and ctrl key was pressed\r\n unless $DEBUG and Input.press?(Input::CTRL)\r\n # Encounter countdown\r\n if @encounter_count > 0\r\n @encounter_count -= 1\r\n end\r\n end\r\n end\r\n end"
] | [
"0.6392648",
"0.6280229",
"0.62515795",
"0.62205553",
"0.62205553",
"0.62205553",
"0.62205553",
"0.62205553",
"0.62205553",
"0.62205553",
"0.62205553",
"0.6159653",
"0.6150635",
"0.5977741",
"0.5910575",
"0.587556",
"0.5860652",
"0.58297104",
"0.58297104",
"0.57829034",
"0.57453406",
"0.57429403",
"0.573356",
"0.57159007",
"0.56985664",
"0.56943643",
"0.5681378",
"0.5681207",
"0.5657137",
"0.5639976",
"0.561966",
"0.5616155",
"0.56151104",
"0.5586515",
"0.55843395",
"0.55800366",
"0.5574307",
"0.5568459",
"0.5565688",
"0.5561264",
"0.5557567",
"0.55544317",
"0.55362076",
"0.5535949",
"0.5535949",
"0.5518059",
"0.5512189",
"0.5502478",
"0.5469652",
"0.5466644",
"0.5463498",
"0.5460228",
"0.5458854",
"0.54492927",
"0.54438686",
"0.54386246",
"0.54364425",
"0.5428014",
"0.54275244",
"0.54252195",
"0.5421216",
"0.54167455",
"0.54167455",
"0.54167455",
"0.5415009",
"0.54090476",
"0.54027766",
"0.5394445",
"0.5390223",
"0.5384869",
"0.53813154",
"0.5378585",
"0.537212",
"0.5370027",
"0.53558856",
"0.53529006",
"0.534578",
"0.5331086",
"0.530672",
"0.529237",
"0.52815825",
"0.5280131",
"0.5279409",
"0.5276238",
"0.5270235",
"0.5264724",
"0.52474904",
"0.524746",
"0.52440095",
"0.5240722",
"0.5237028",
"0.5231139",
"0.52285194",
"0.5228309",
"0.52245104",
"0.5203973",
"0.5199545",
"0.5191568",
"0.5190997",
"0.5183705"
] | 0.5350765 | 76 |
Always allow user creation | def create?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def creatable_without_user\n false\n end",
"def auth_create_filter\n if not self.class.allowed_to_create\n false\n else\n true\n end\n end",
"def create?\n #everyone who is loggedin can do this action\n true\n end",
"def can_create?\n allows_current_user_access_to? :create\n end",
"def canCreate?(user=current_user)\n return false if user.nil?\n true\n end",
"def create_user\n super\n end",
"def create\n if Feedbunch::Application.config.signups_enabled\n super\n else\n Rails.logger.warn \"Creation of new user attempted, but signups are disabled\"\n redirect_to root_path\n end\n end",
"def create?\n # false # no access\n user.present? # minimum requirement for creating records \n # like posts or comments is that a user exist and be logged in. \n end",
"def allow_user(user_id)\n create_entry(user_id, USER, true)\n end",
"def create?\n !@user.nil?\n end",
"def creatable_by?(user)\n true\n end",
"def create?\n user.present?\n end",
"def create?\n user.present?\n end",
"def create?\n user.present?\n end",
"def create?\n !user.nil?\n end",
"def create?\n !user.nil?\n end",
"def new\n @user = User.new\n enforce_create_permission(@user)\n end",
"def create?\n\t\t!@user.nil?\n\tend",
"def create?\n @user != nil\n end",
"def set_create_user(opts)\n opts = check_params(opts,[:user_info])\n super(opts)\n end",
"def create?\n user.present? && user.admin?\n end",
"def create?\n @current_user.permission('Fdp', :clerk)\n end",
"def create_user\n @user = User.find(session[:user_id])\n redirect_to(root_url) unless current_user?(@user) || current_user.admin?\n end",
"def creation_allowed_only?\n creation_allowed? && !(\n programme_administrator_logged_in? ||\n Programme.site_managed_programme.present?\n )\n end",
"def user\n super || create_user\n end",
"def create?\n !@current_user.admin?\n end",
"def create_permitted?\n acting_user.signed_up?\n end",
"def create_permitted?\n acting_user.signed_up?\n end",
"def require_valid_user!\n return true\n end",
"def create?\n @current_user.permission('Bid', :clerk)\n end",
"def allow_sign_up?\n @allow_sign_up\n end",
"def new\n @user = User.new\n authorize! :create, @user\n end",
"def create?\n return false unless @user\n\n @user.try(:admin?) || @record.user == @user ||\n @record.group&.users&.include?(@user) ||\n NodePolicy.new(@user, @record.node).create?\n end",
"def create?\n @current_user.permission('Donor', :clerk)\n end",
"def users_only\n deny_access(\"Necesitas crear una cuenta para entrar a esta sección\") unless signed_in?\n end",
"def requires_user_existence!\n if not e.user_exists?\n error \"You have to setup your user before you can perform this action.\"\n exit\n end\n end",
"def make_user\n end",
"def authorized_for_create?\n current_user.is_admin\n end",
"def new\n return appctrl_not_permitted() unless @current_user.admin?\n @record = @user = User.new\n end",
"def create?\n @current_user.permission('Ration', :clerk)\n end",
"def create?\n @user.expert\n end",
"def require_user\n end",
"def create\n\t\tredirect_to '/users/sign_in', alert: 'Access denied.'\n\tend",
"def create_user_if_none_exist\n return if User.exists?\n puts \"Creating Users...\"\n\n User.create :email => \"test@test.com\", :password => \"welcome1\", :password_confirmation => \"welcome1\"\n end",
"def user_access_create\n check_user_access(params[:user_id])\n end",
"def user_access_create\n check_user_access(params[:user_id])\n end",
"def create?\n user.role == \"Envio\" || user.role == \"Cadastro\" || user.admin?\n end",
"def create?\n @current_user.permission('Department', :clerk)\n end",
"def put_can_create?\n false\n end",
"def make_first_user_admin\n return unless User.count.zero?\n\n self.is_admin = true\n self.approved = true\n end",
"def create_user(**data)\n create_object(type: 'User', data: { enabled: true }.merge(data))\n end",
"def creatable_by?(user)\n user.administrator?\n end",
"def newUser\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def new_user\n \n end",
"def current_user_has_create?(uri, options=nil)\n opts = options || current_user.try(:user_options) || nil\n current_user.present? and current_user.has_create?(uri, opts)\n end",
"def check_for_user\n if User.count == 0\n User.create({:login => \"admin\", :password => \"password\", :password_confirmation => \"password\", :name => 'blog owner', :email => \"none@none\", :time_zone => \"Europe/London\"})\n # Display the newly created users details\n notify \"No users found, so default user created: authenticate with login \\\"admin\\\", password \\\"password\\\", and then change your password.\"\n end\n login_required\n end",
"def enforce_new_permissions(opts={})\n enforce_create_permissions(opts)\n end",
"def create\n authorize :user, :create?\n @user = User.new(user_params)\n @user.save\n\n respond_to do |format|\n format.html\n format.json { render :json => @user, status: 200 }\n end\n end",
"def create\n authorize! :create, User\n @user = User.new(params[:user])\n @user.enabled = false\n respond_to do |format|\n if @user.valid? && @user.save\n do_extra_actions\n flash[:notice] = (flash[:notice] == :user_activated) ? :user_created_and_activated : :user_created\n flash[:notice_param] = @user\n format.html do\n redirect_to users_url(:use_session => true)\n end\n format.xml { head :created, :location => user_url(@user) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors.to_xml }\n end\n end\n end",
"def ensure_user_created\n if User.find_by_ldap_uid(ldap_user.uid)\n Rails.logger.debug(\"User in user table.\")\n true\n else\n Rails.logger.debug(\"User not in user table, redirecting to new user form.\")\n redirect_to(new_users_url) and return\n end\n end",
"def can_create?(obj)\n false\n end",
"def can_create?(obj)\n false\n end",
"def new\n unless current_user.admin?\n flash[:error] = \"Users can only be created by administrators.\"\n redirect_to (request.env[\"HTTP_REFERER\"] || root_path) and return\n end\n \n @user = User.new\n end",
"def only_create!\n self.operation = :only_create\n end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def patch_can_create?\n false\n end",
"def no_current_user\n if @user = current_user\n logger.warn \"Restricting user #{@user.id} from calling create!\"\n head :method_not_allowed\n end\n end",
"def create_guest_user\n u = User.create(name: 'guest', email: \"guest_#{Time.current.to_i}#{rand(99)}@example.com\")\n # u.skip_confirmation!\n u.save!(validate: false)\n u\n end",
"def create\n authorize! :create, User\n @user = User.new(user_params)\n if @user.save\n flash[:notice] = 'User is created successfully. '\n else\n flash.now[:alert] = @user.errors.full_messages.first\n end\n end",
"def create\n super do |user|\n if User.where(user_type: 0).empty?\n user.user_type = 0\n resource_saved = user.save\n end\n end\n end",
"def create?\n\t\tuser.course_grants > 0\n\tend",
"def before_create_user\n logger.debug(\"on before creare user\")\n #Generate a unique key\n if facebook_user?\n self.active = 1 \n else\n activation_key_string = self.salt+self.email+self.hashed_password\n self.activation_key =Digest::SHA1.hexdigest(activation_key_string)\n self.active = 0\n end\n self.admin = 0 \n self.handle=generate_unique_handle\n \n end",
"def creation_allowed?\n show_programme_box? && Programme.can_create?\n end",
"def create\n @user = User.new(user_to_be_created)\n\n error = @user.validate_user?\n\n if error.nil? && @user.save\n handler_notice('Usuário cadastrado com sucesso!', login_path)\n else\n handler_notice_error(error, new_user_path)\n end\n end",
"def create_user\n if current_user.manager? || current_user.admin?\n @user = User.new(user_params)\n @user.password = 'test@123'\n @user.password_confirmation = 'test@123'\n redirect_to @user if @user.save\n else\n flash[:notice] = NOT_AUTHORIZED\n redirect_to home_index_path\n end\n end",
"def create_user\n return @user.send_confirmation_instructions if @user\n\n @user = User.create!(new_agent_params.slice(:email, :name, :password, :password_confirmation))\n end",
"def createUser(admin=false) \n usr = User.new \n usr.Admin = admin \n @Users.add usr \n end",
"def create?\n @current_user.permission('FdpContact', :clerk)\n end",
"def create!\n self.save\n self.set_lookup(:login) if self.is_a?(User)\n :ok\n end",
"def login_required\n if params[:create_user] # hidden field in posted form. Create the user.\n user = User.new\n user.last_login = request.remote_ip\n if user.save && user.errors.empty?\n self.current_user = user # !! now logged in\n else\n flash[:error] = \"I am sorry. the system could not create a new account for you.\"\n access_denied\n end\n elsif authorized?\n return true\n else\n access_denied\n end\n end",
"def create?\n record.resourceable.owner == user || user.is?(:admin)\n end",
"def create?\n @current_user.permission('Commodity', :clerk)\n end",
"def create_guest_user\n user = User.new { |user| user.role = 'guest' }\n user.email = \"guest_#{Time.now.to_i}#{rand(99)}@example.com\"\n user.save(validate: false)\n user\n end",
"def ensure_user(user_name:, email:, password:, roles:)\n user = User.where(user_name:).first\n if user.blank?\n user = User.new(user_name:, email:, roles:)\n user.password = password\n user.skip_confirmation!\n\n else\n user.email = email\n user.password = password unless user.valid_password?(password)\n user.roles = roles\n end\n user.skip_creation_email = true\n\n user.save!(validate: false)\n user\nend",
"def create\n return appctrl_not_permitted() unless @current_user.admin?\n\n @record = @user = User.new\n @control_panel = @user.control_panel = ControlPanel.new\n\n update_and_save_user( 'New account created', 'new' )\n end",
"def create_attempted?\n create_attempted\n end",
"def create_user(user_hash={})\n @user = User.new(user_hash)\n if @user.save\n return true\n else\n return false\n end\n end",
"def only_create\n if !@user.is_project_create\n raise Exceptions::GitlabApiException.new(\"Access forbidden for this user\")\n end\n\n # only admin can change anyone project\n if !@user.admin? && params[:owner_id] && params[:owner_id] != @user.id\n raise Exceptions::GitlabApiException.new(\"Access forbidden for this user\")\n end\n\n true\n end",
"def only_create\n if !@user.is_project_create\n raise Exceptions::GitlabApiException.new(\"Access forbidden for this user\")\n end\n\n # only admin can change anyone project\n if !@user.admin? && params[:owner_id] && params[:owner_id] != @user.id\n raise Exceptions::GitlabApiException.new(\"Access forbidden for this user\")\n end\n\n true\n end",
"def create\n @user = User.new(user_params)\n @user.is_admin = true if User.count == 0\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to :root, notice: 'Thank you for creating your MindImp Account! Please check your email for more details.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_name: params[:user_name], email: params[:email], password: params[:password])\n @user.admin = User.all.empty?\n respond_to do |format|\n if @user.save\n format.html { redirect_to root_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource) unless current_user_is_admin?\n end",
"def create_user\n user new_resource.user do\n comment \"Service user for #{new_resource.name}\"\n gid new_resource.group if new_resource.group\n home new_resource.home\n shell '/bin/false'\n system true\n uid new_resource.uid\n end\n end",
"def new_user\n\t\t@resource = User.new\n\t\t@resource_name = 'user'\n\tend",
"def new_user\n\t @user = User.new\t \n\tend"
] | [
"0.76265603",
"0.76195645",
"0.75778466",
"0.75608957",
"0.74747884",
"0.7452297",
"0.7419917",
"0.73087966",
"0.73028094",
"0.7291874",
"0.7263189",
"0.7262738",
"0.7262738",
"0.7262738",
"0.7188688",
"0.7188688",
"0.718685",
"0.71514255",
"0.70988667",
"0.70968986",
"0.70709354",
"0.7018945",
"0.69986665",
"0.697932",
"0.69731116",
"0.69647753",
"0.6931394",
"0.6931394",
"0.69255716",
"0.6912198",
"0.69046015",
"0.68910265",
"0.68800753",
"0.68779427",
"0.68437684",
"0.67953163",
"0.6787705",
"0.6765849",
"0.6764966",
"0.6752576",
"0.6745265",
"0.6738266",
"0.67218494",
"0.6692148",
"0.668818",
"0.668818",
"0.66841996",
"0.6672998",
"0.66681075",
"0.6660851",
"0.66476417",
"0.66430724",
"0.66425306",
"0.6626274",
"0.6626274",
"0.6626274",
"0.6626274",
"0.6621359",
"0.6617181",
"0.6606763",
"0.66063434",
"0.6605907",
"0.6605591",
"0.6603853",
"0.65890646",
"0.65890646",
"0.65818846",
"0.65816736",
"0.6573915",
"0.6573915",
"0.6573915",
"0.65715814",
"0.65640295",
"0.65538937",
"0.65441203",
"0.653417",
"0.6529963",
"0.652512",
"0.6513023",
"0.6512754",
"0.65068907",
"0.65032953",
"0.65013504",
"0.64979434",
"0.6496771",
"0.6492967",
"0.6483562",
"0.6468508",
"0.6464499",
"0.64591324",
"0.6452452",
"0.645157",
"0.64474934",
"0.6441272",
"0.6441272",
"0.6439445",
"0.6435349",
"0.6427572",
"0.64257073",
"0.64239866",
"0.64177996"
] | 0.0 | -1 |
Write a method that determines and returns the ASCII string value of a string that is passed in as an argument. The ASCII string value is the sum of the ASCII values of every character in the string. (You may use Stringord to determine the ASCII value of a character.) | def ascii_value(string)
value = 0
string.chars { |c| value += c.ord }
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ascii_value(string)\n sum = 0\n string.each_char { |x| sum += x.ord }\n sum\nend",
"def ascii_value(string)\n sum = 0\n string.chars.each do |char|\n sum += char.ord\n p char.ord.chr # Further Exploration\n end\n sum\nend",
"def ascii_value(str)\n ascii_sum = 0\n\n str.each_char { |char| ascii_sum += char.ord }\n ascii_sum\nend",
"def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend",
"def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend",
"def ascii_value(string)\n string.each_char.reduce(0) { |sum, char| sum + char.ord }\nend",
"def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord}\n sum\nend",
"def ascii_value(str)\n str.chars.map { |chr| chr.ord }.sum\nend",
"def ascii_value(str)\n sum = 0\n str.each_char { |char| sum += char.ord }\n sum\nend",
"def ascii_value(string)\n sum = 0\n string.each_char { |char| sum += char.ord }\n sum\nend",
"def ascii_value(string)\n letters = string.chars\n ascii_total = 0\n letters.each do |letter|\n ascii_total += letter.ord\n end\n ascii_total\nend",
"def ascii_value(str)\n # str.chars.map(&:ord).reduce(0) { |a, e| a + e } # 0 is default sum\n # OR:\n str.chars.reduce(0) { |a, e| a + e.ord }\nend",
"def ascii_value(string)\n result = 0\n string.chars.each do |char|\n result += char.ord\n end\n result\nend",
"def ascii_value(string)\n string.chars.inject(0) { |sum, char| sum += char.ord }\nend",
"def ascii_value(string)\n return 0 if string.empty?\n string.chars.map { |char| char.ord }.reduce(:+)\nend",
"def ascii_value(string)\n value = 0\n string.chars.each do |char|\n value += char.ord\n end\n value\nend",
"def ascii_value(str)\n str.split('').reduce(0) {|sum,chr| sum + chr.ord }\nend",
"def ascii_value(str)\n# characters = str.chars\n# sum = 0\n\n# characters.each do |char|\n# sum += char.ord # sum = sum + char.ord\n# end\n\n# sum\n\n return 0 if str == ''\n\n ords = str.chars.map {|c| c.ord }\n\n ords.reduce do |sum, c|\n sum + c\n end\nend",
"def ascii_value(str)\n string_value = 0\n if str.is_a? String \n str.each_char do |char|\n string_value += char.ord\n end\n else\n puts \"Invalid entry!\"\n end\n string_value\nend",
"def ascii_value(string)\n value = 0 \n\n string.each_char { |char| value += char.ord }\n\n value\nend",
"def ascii_value(string)\n if string.empty?\n 0\n else\n values = string.chars.map { |char| char.ord }\n values.reduce(:+)\n end\nend",
"def ascii_value(string)\n ascii_value = 0\n\n string.each_char { |char| ascii_value += char.ord }\n\n ascii_value\nend",
"def ascii_value(str)\r\n ascii_values = str.chars.map{|char| char.ord}\r\n (str == '') ? 0 : ascii_values.reduce(:+)\r\nend",
"def ascii_value(str)\n sum = 0\n str.each_char {|char| sum += sum += digit.ord}\n sum\nend",
"def ascii_value(string)\n string.emtpy? ? 0 : string.chars.map{|letter| letter.ord }.reduce(&:+)\nend",
"def ascii_value(str)\n val = str.chars.map(&:ord).reduce(:+)\n !val ? 0 : val\nend",
"def ascii_value(string)\n string.chars.reduce(0) { |result, char| result += char.ord }\nend",
"def ascii_value(str)\n str.chars.map(&:ord).inject(0, &:+)\nend",
"def ascii_value(str)\n sum = 0\n # str.split(\"\").each { |val| sum += val.ord } My ans. Better method each_char\n str.each_char { |char| sum += char.ord }\n sum\nend",
"def ascii_value(str)\n\tarr = str.chars\n\n\tarr.map! do |element|\n\t\telement.ord\n\tend\n\n\tarr.sum\nend",
"def ascii_value(string)\r\n integer = 0\r\n string.each_char { |chr| integer += chr.ord }\r\n integer\r\nend",
"def ascii_value(string)\n value = 0\n for i in (0..string.length-1)\n value += string[i].ord\n end\n value\nend",
"def ascii_value(str)\n counter = 0\n str.each_char do |char|\n counter = counter + char.ord\n end\n counter\nend",
"def ascii_value(string)\n ascii_array = string.split('').map(&:ord)\n ascii_array.reduce(0) { |acc, elem| acc + elem }\nend",
"def ascii_value(ascii_string)\n string_array = ascii_string.chars\n ascii_value_array = [0]\n\n string_array.each do |char|\n ascii_value_array << char.ord\n end\n\n ascii_value = ascii_value_array.reduce(:+)\nend",
"def ascii_value(str)\n str.bytes.sum\nend",
"def ascii_value(string)\n counter = 0\n string.chars.map { |e| counter += e.ord }\n counter\nend",
"def string_sum(string)\n sum = 0\n alphabets = (\"a\"..\"z\").to_a\n string.chars.each do |ch|\n sum += alphabets.index(ch) + 1\n end\n sum\nend",
"def getASCII(c)\n c.ord\nend",
"def sumWithFctChar(string)\n sum = 0\n string.each_char do\n |chr|\n sum += chr.to_i\n end\n puts \"La somme des chiffres de \\\"#{string}\\\" est égal à #{sum}\"\nend",
"def strsum(str)\n total = 1\n str.chars.each do |c|\n total = total * c.to_i\n end\n total\nend",
"def lookup(string)\r\n return 2 ** (string.chr.downcase.ord - ('a'.ord))\r\n end",
"def string_sum(string)\n letters = ('a'..'z').to_a\n sum = 0\n string.split(\"\").each{|x| sum += letters.index(x) + 1}\n sum \nend",
"def ord(x)\n if x.is_a? String\n x.ord\n else\n x\n end\nend",
"def atoi(string_int)\n sum = 0\n string_int.each_byte do |char|\n sum = (sum * 10) + (char - ZERO_ASCII_CODE)\n end\n\n return sum\nend",
"def ascii_value(url)\n ascii_value = 0;\n url.each_char {|url| ascii_value += url.ord}\n return ascii_value\n end",
"def locNumToInt(str)\n\tnum = 0\n\tstr.split('').each {|c|\n\t\tnum += 2**(c.ord - 97)\n\t}\n\tnum\nend",
"def ord(char)\n char.bytes.first\nend",
"def str_to_ints(str)\n str.chars.map{|c| c == ' ' ? c : c.ord - 64 }\nend",
"def hand_score(string)\n cards = { A: 4, K: 3, Q: 2, J: 1 }\n score = 0\n string.each_char do |char|\n score += cards[char.upcase.to_sym]\n end\n\n score\nend",
"def parseAscii str\n\tstr.chars.map { |c| c !~ /[[:print:]]/ ? \"0x\" + c.ord.to_s : c}.join\nend",
"def sum_of_ascii_values(message)\n\treturn message.map{|c| c.to_i}.reduce(:+)\nend",
"def charsSum (s)\n\t\tsum = 0\n\t\ts.each_char { |c| sum += self.letterToInt(c) }\n\t\treturn sum\n\tend",
"def calculate_alphabet(str)\nend",
"def string_to_integer(str)\n arr = []\n str.each_char { |char| arr << char if STR_TO_INT.key?(char) }\n\n sum = 0\n arr.reverse.each.with_index do |num, index|\n sum += STR_TO_INT[num] * 10**index\n end\n sum\nend",
"def get_hash(str, hash_table)\n value = 1\n str.each_char do |c|\n return 0 unless hash_table.key?(c)\n value *= hash_table[c]\n end\n value\nend",
"def string_to_integer(str)\n str.chars.map { |chr| chr.ord - 48 }.reduce { |a, e| (a * 10) + e }\nend",
"def myAtoi( str)\n value = 0\n size = str.length\n i = 0\n while (i < size)\n value = (value << 3) + (value << 1) + (str[i].ord - '0'.ord)\n i += 1\n end\n return value\nend",
"def s_to_i(string)\n string.chars.reduce(0) do |output, char|\n output * charset.length + char_to_codepoint(char)\n end\n end",
"def compare_sum_char_code(chars1, chars2)\n chars1 = '' unless chars1&.match?(/\\A[a-zA-Z]+\\z/)\n chars2 = '' unless chars2&.match?(/\\A[a-zA-Z]+\\z/)\n\n num1 = chars1.to_s.upcase.split('').map(&:ord).sum\n num2 = chars2.to_s.upcase.split('').map(&:ord).sum\n\n num1 == num2\nend",
"def string_to_integer(str)\n convert_hash = {\n '0' => 0,\n '1' => 1,\n '2' => 2,\n '3' => 3,\n '4' => 4,\n '5' => 5,\n '6' => 6,\n '7' => 7,\n '8' => 8,\n '9' => 9,\n }\n sum = 0\n value = 0\n str_arr = str.chars\n str_arr.each do |num|\n value = convert_hash[num]\n sum += value * (10 ** (str_arr.length - (str_arr.index(num) + 1)))\n end\n sum\nend",
"def string_to_integer(string)\n char_to_int = {\n '1'=> 1,\n '2'=> 2,\n '3'=> 3,\n '4'=> 4,\n '5'=> 5,\n '6'=> 6,\n '7'=> 7,\n '8'=> 8,\n '9'=> 9,\n '0'=> 0,\n }\n \n if string[0] == '-' then\n string[1..string.length].chars.reduce(0) { |int, char| int * 10 + char_to_int[char]} * -1\n elsif string[0] == '+' then\n string[1..string.length].chars.reduce(0) { |int, char| int * 10 + char_to_int[char]}\n else\n string.chars.reduce(0) { |int, char| int * 10 + char_to_int[char]}\n end\nend",
"def character_by_character(string)\nend",
"def to_ascii(string)\n\t\tstring.unpack(\"U*\").map do |c| \n\t\t\tc.chr if c < 128\n\t\tend.join\n\tend",
"def hash_code(str)\n str.each_char.reduce(0) do |result, char|\n [((result << 5) - result) + char.ord].pack('L').unpack('l').first\n end\n end",
"def scrabble_score(str)\n str = str.upcase.delete(\"^A-Z\")\n return 0 if str.nil? || str.empty?\n str.chars.map{ |chr| $dict[chr] }.reduce(:+)\nend",
"def encode_string(str)\n str.chars.map(&:ord)\n end",
"def calc_characters(string)\n words = string.split\n chars = 0\n words.each { |word| chars += word.size }\n chars\nend",
"def custom_count(string, char)\ncurrent = 0\nstring.chars do |i|\nif i == char\n current += 1\nend\nend\np current\nend",
"def task_4(string)\n sum = 0\n string.each_char do |chr|\n !chr.to_i.nil? ? sum += chr.to_i : nil\n end\n sum\nend",
"def character_score(character)\n alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n alphabet.index(character) + 1\nend",
"def ae_count(string)\n hash = Hash.new(0)\n string.each_char do |char|\n if char == 'a' || char == 'e'\n hash[char] += 1 \n end\n end\n\n hash\nend",
"def atoi(s)\n\t\tnum = 0\n\t\tacc = 0\n\t\ts.length.downto(0) { |i|\n\t\t\tif s[i] == '0'\n\t\t\t\tnum = 0\n\t\t\telsif s[i] == '1'\n\t\t\t\tnum = 1\n\t\t\telsif s[i] == '2'\n\t\t\t\tnum = 2\n\t\t\telsif s[i] == '3'\n\t\t\t\tnum = 3\n\t\t\telsif s[i] == '4'\n\t\t\t\tnum = 4\n\t\t\telsif s[i] == '5'\n\t\t\t\tnum = 5\n\t\t\telsif s[i] == '6'\n\t\t\t\tnum = 6\n\t\t\telsif s[i] == '7'\n\t\t\t\tnum = 7\n\t\t\telsif s[i] == '8'\n\t\t\t\tnum = 8\n\t\t\telsif s[i] == '9'\n\t\t\t\tnum = 9\n\t\t\telsif s[i] == '-' && i == 0\n\t\t\t\tnum = 0\n\t\t\t\t\tacc *= -1\n\t\t\t\telsif s[i] == nil || (s[i] == '+' && i == 0)\n\t\t\t\tnum = 0\n\t\t\telse\n\t\t\t\tabort(\"No se ingreso un número válido.\")\n\t\t\tend\n\t\t\tif num > 0\n\t\t\t\tacc += num * 10** (s.length-1-i)\n\t\t\tend\n\t\t}\n\t\tacc\n\tend",
"def sum(num)\n sum = 0\n num.to_s.chars.each do |ch|\n sum += ch.to_i\n end\n sum\nend",
"def letter_to_number(letter)\n letter.ord - 64\nend",
"def string_to_integer(string)\n integer = 0\n idx = 0\n while idx < string.length\n integer = integer * 10\n integer += string[idx].to_i\n idx += 1\n end\n\n integer\nend",
"def atoi\n\t\t _int = []; _sum = 0\n\t\t\n\t\t@ascii_string.each do |value| \n\t\t\t_int.push(NILTO9[value])\n\t\tend\n\t\t\n\t\te = _int.length \t\t\n\t\n\t\t_int.each do |value|\n\t\t\t_sum = _sum + ((value/BASE)/(1/(BASE**e))).floor\n\t\t\te -= 1\n\t\tend\t\n\n\t \t_sum\n\tend",
"def get_char_number(char)\n a = 'a'.ord\n z = 'z'.ord\n val = char.ord\n\n if a <= val && val <= z\n return val - a\n end\n\n -1\nend",
"def s_to_i(s)\n if s[0..1] == \"0x\"\n return s.to_i(16)\n else\n return s.to_i(10)\n end\nend",
"def ae_count(str)\n count = {\"a\"=>0, \"e\"=>0}\n\n str.each_char do |char|\n if (char == \"a\" || char == \"e\")\n count[char] += 1\n end\n end\n\n return count\nend",
"def funny string\n arr = string.chars\n count = 0\n arr.each_with_index do |x,xi|\n if xi > 0\n s1 = (x.ord - arr[xi-1].ord).abs\n s2 = (arr[-(xi+1)].ord - arr[-xi].ord).abs\n s1 == s2 ? count +=1 : break\n end\n end\n puts count == arr.size-1 ? 'Funny' : 'Not Funny'\nend",
"def theLoveLetterMystery(s)\n chars = s.chars\n size = chars.length\n sum = 0\n ((size+1)/2..(size -1)).each do |i|\n num = chars[i].ord\n target_num = chars[size-1-i].ord\n sum += (num - target_num).abs\n end\n sum\nend",
"def testing(char)\n p \"Character: #{char} (char.ord == #{char.ord}) (char.ord.chr == #{char.ord.chr}\"\n char.ord.chr == char\nend",
"def string_to_integer(str)\n place_idx = (str.length - 1)\n \n num = 0\n while place_idx >= 0\n digit = str[place_idx].ord - '0'.ord\n num = num + digit * (10 ** (str.length - 1 - place_idx))\n place_idx -= 1\n end\n\n num\nend",
"def string_to_integer(string)\nend",
"def atoi(word)\n results = []\n word.chars.each do |char|\n letter = change_letter(char)\n results << letter\n end\n results.each do |integer|\n print integer\n end\n puts \"\"\nend",
"def roman_to_int(str)\n hash = {\n 'M' => 1000,\n 'D' => 500,\n 'C' => 100,\n 'L' => 50,\n 'X' => 10,\n 'V' => 5,\n 'I' => 1,\n }\n sum = 0\n cur = 0\n\n str.chars.each do |l|\n prev = cur\n cur = hash[l]\n sum += cur\n sum -= (prev * 2) if prev < cur\n end\n\n sum\nend",
"def my_atoi(s)\n new_string = \"\"\n nums = \"+-01234567890.\"\n \n s.each_char do |char| \n if !nums.include?(char) && char != \" \" && new_string == \"\"\n return 0\n elsif !nums.include?(char) && char !=\" \"\n break\n else nums.include?(char)\n new_string << char \n end\n end\n \n if new_string.to_i < -2**31\n return -2**31\n elsif new_string.to_i > 2**31 - 1\n return 2**31 - 1\n else\n return new_string.to_i\n end\nend",
"def char_count(string)\n\tchar_count = Hash.new\n\t\"abcdefghijklmnopqrstuvwxyz\".chars.each {|char| char_count[char] = 0}\n\tstring.chars.each {|char| char_count[char] += 1}\n\tchar_count\nend",
"def string_to_integer(str)\n num_hsh = {'1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'0'=>0,}\n arr = str.chars.reverse\n total = 0\n new_arr = []\n arr.each do |str|\n new_arr << num_hsh[str]\n end\n new_arr.each_with_index do |num, i|\n total += num * 10**i\n end\n total\nend",
"def decode(s)\n i = 0\n base = ALPHABET.length\n s.each_char { |c| i = i * base + ALPHABET.index(c) }\n i\n end",
"def hash_from_string(string)\n hash = Hash.new { 0 }\n string.downcase.gsub(/\\W/, \"\").each_char { |character| hash[character] += 1 }\n hash\nend",
"def count_char(string, character)\n i = 0\n output = 0\n while i < string.length\n if character == string[i]\n output += 1\n end\n i += 1\n end\n return output\nend",
"def char_counter_2(string, char)\n string.count(char)\nend",
"def roman_to_int(s)\n letters = {'I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000}\n words = s.split(\"\")\n result = words.reduce do |accumulator, current|\n letters[accumulator] + letters[current]\n end \n result\nend",
"def string_to_integer2(string)\n digits = string.chars.map { |char| HASH[char] }\n\n value = 0\n digits.each { |digit| value = 10 * value + digit }\n value\nend",
"def change(str)\n if str.class == String\n array = str.split(//)\n binary = Array.new(26, 0)\n array.uniq.sort!\n base = \"a\".ord\n base_upcase = \"A\".ord\n array.each do |x|\n if (65..90).include?(x.ord)\n binary[x.ord - base_upcase] = 1\n elsif (97..122).include?(x.ord)\n binary[x.ord - base] = 1\n end\n end\n end\n binary.join('')\nend",
"def string_to_integer(str)\n str.to_i\nend",
"def ae_count(str)\n count = {\"a\"=> 0, \"e\" => 0}\n puts count\n str.each_char do |char|\n if (char == \"a\" || char == \"e\")\n count[char] += 1\n end \n end\n return count\nend",
"def string_to_integer(string)\n digits = string.chars.map { |digit| MATCH[digit] }\n\n value = 0\n digits.each { |digit| value = 10 * value + digit }\n value\nend"
] | [
"0.8914419",
"0.8901723",
"0.8899416",
"0.88920915",
"0.88920915",
"0.888891",
"0.88865125",
"0.88840854",
"0.8883947",
"0.8879799",
"0.88775134",
"0.887349",
"0.8863588",
"0.8804207",
"0.8775223",
"0.8768086",
"0.8764711",
"0.87321717",
"0.8720412",
"0.87056446",
"0.8691511",
"0.8665273",
"0.86636007",
"0.86628526",
"0.8641719",
"0.86348355",
"0.8619967",
"0.8590892",
"0.85690844",
"0.85197085",
"0.85128963",
"0.8479602",
"0.8408028",
"0.84028023",
"0.83694553",
"0.8360162",
"0.827877",
"0.7081337",
"0.7054206",
"0.6925244",
"0.6922477",
"0.6786358",
"0.67309254",
"0.67251843",
"0.67108077",
"0.66416276",
"0.65190315",
"0.6498512",
"0.6443018",
"0.6435329",
"0.63351953",
"0.6328383",
"0.6315608",
"0.6297209",
"0.62853366",
"0.6270137",
"0.6239503",
"0.62343156",
"0.6214967",
"0.62054765",
"0.61893106",
"0.6176867",
"0.61611503",
"0.61593986",
"0.614163",
"0.61342007",
"0.61242545",
"0.61017674",
"0.6089244",
"0.60790646",
"0.60735935",
"0.60724705",
"0.60631543",
"0.6061034",
"0.6057668",
"0.6057138",
"0.60535777",
"0.60517514",
"0.60446066",
"0.6040604",
"0.6035158",
"0.60296834",
"0.6020077",
"0.6016846",
"0.5998299",
"0.59913146",
"0.59699315",
"0.59544075",
"0.5952465",
"0.5950572",
"0.59431684",
"0.59326464",
"0.59200263",
"0.5908127",
"0.59050155",
"0.5894019",
"0.5886332",
"0.58786094",
"0.5876794",
"0.587412"
] | 0.87450993 | 17 |
Metodo para escolher com qual perfil logar | def escolher_perfil(perfil)
@perfil = perfil
case @perfil
when "pessoa fisica"
pessoa_fisica_div.click
when "pessoa juridica"
pessoa_juridica_div.click
when "area restrita"
visit "/restrito"
else
puts "Erro na selecao do perfil para acesso ao Portal CFM"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_file; end",
"def log_file\n end",
"def logged?; false end",
"def logged?; false end",
"def auth_log\n return './auth.log' if @cfg['run_mode'] == 'full_debug'\n\n AUTH_LOG_FILES.each { |log_file| return log_file if File.exists?(log_file) }\n\n return nil\n end",
"def realizar_login (perfil_usuario)\n\n @perfil = perfil_usuario\n\n \n case @perfil\n\n when \"pessoa fisica\"\n \n escolher_perfil(@perfil)\n realizar_login_pf(\"41906\", \"#ufCrm > option:nth-child(19)\", \"123\")\n\n when \"pessoa juridica\"\n\n visit \"/\"\n sleep(1)\n escolher_perfil(@perfil)\n realizar_login_pj(\"36172\", \"#ufCrmPJ > option:nth-child(19)\", \"'#prestador > option:nth-child(3)'\", \"cn&n77&9\")\n\n when \"area restrita\"\n\n escolher_perfil(@perfil)\n sleep(1)\n realizar_login_restrito(\"ODANIELE\", \"123\")\n\n else\n\n puts \"Erro na selecao de perfil\"\n\n end\n\n\n end",
"def user_logged_in_sin_hogar\n\n\t\t redirect_to new_direccion_path if logged_in? && !tiene_hogar?\n\n \tend",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def login(user)\n\tif $users_profil.include?(user)\n\t\tputs \"Username: #{user}\"\n\t\tputs \"Profil: #{$users_profil[user]}\" \n\telse \n\t\tputs \"Numele de utilizator este gresit.\"\n\t\tprima # daca a scris usernamul gresit sau daca acel username nu exista atunci scriptul practic se reinitializeaza\n\tend\nend",
"def loggin_opc(puser, pcontroller, paction, pcomment)\n #para que no haga logging de clicks de navegacion\n if pcontroller == 'home'\n\t\treturn\n else\n\t logmodel = Logeclubapi.new\n\t logmodel.login = puser.login\n\t logmodel.username = puser.name\n\t logmodel.log_option = pcontroller\n\t logmodel.log_action = paction[0..9]\n\t logmodel.log_comment = pcomment\n\t logmodel.origin = 'W' #origen web\n\t #logmodel.save\n end\n end",
"def loguear\n\t\tif !(verificaUsuario)\n\t\t\tif verificaPass\n\t\t\t\treturn \"correcto\" #Si puede loguearse\n\t\t\telse\n\t\t\t\treturn \"passincorrecto\" #no puede loguearse por que la contrasena no es correcta\n\t\t\tend\n\t\telse\n\t\t\treturn \"usuarioincorrecto\" #no puede loguearse por que el usuario no existe\n\t\tend\n\tend",
"def registrar_log(tipo)\n if Usuario.current.nil? \n snombre = \"Script\"\n superu = nil\n else\n snombre = Usuario.current.login\n superu = Usuario.current.id\n end\n \n logs = Logsesion.new(:usuario_id => self.id, \n :superu_id => superu,\n :tipo => tipo, \n :nusuario => self.login, \n :nsuperu => snombre)\n\n return logs.save\n end",
"def local!\n\t\t\t@local = true\n\t\t\t@root = \"#{Dir.home}/log\"\n\t\t\tlog!\n\t\tend",
"def log\n end",
"def logs\n end",
"def add_in_logfile(date, adresse, utilisateur_id, description)\n fichier = \"app/../log/logs.txt\"\n if File.exist?(fichier)\n mode = 'a'\n check_logfile_size(fichier)\n else\n mode = 'w'\n end\n open(fichier, mode) { |f|\n f << \"DATE : #{date}\\n\"\n f << \"ADRESSE : #{adresse}\\n\"\n f << \"UTILISATEUR_ID : #{utilisateur_id}\\n\"\n f << \"DESCRIPTION : #{description}\\n\"\n f << \"========================================\\n\"\n }\n end",
"def logme(target)\n\n\t# Create Filename info to be appended to files\n\tfilenameinfo = \"_\" + ::Time.now.strftime(\"%Y%m%d.%M%S\")\n\n\t# Create a directory for the logs\n\tlogs = ::File.join(Msf::Config.log_directory,'scripts', 'winbf')\n\n\t# Create the log directory\n\t::FileUtils.mkdir_p(logs)\n\n\t#logfile name\n\tdest = logs + \"/\" + target + filenameinfo\n\n\tdest\nend",
"def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend",
"def logs\n\n end",
"def updateLogFile(operation)\n file = File.open(\"log.txt\", \"a\")\n \n if operation == \"Login\"\n file.puts \"#{$credentials[0]} logged in at #{Time.now}\"\n elsif operation == \"Logout\"\n file.puts \"#{$credentials[0]} logged out at #{Time.now}\"\n elsif operation == \"Updated\"\n file.puts \"#{$credentials[0]} proposed an update to the wiki content at #{Time.now}\"\n elsif operation == \"Deleted\"\n file.puts \"#{$credentials[0]} deleted the wiki content at #{Time.now}\"\n elsif operation == \"Backup\"\n file.puts \"#{$credentials[0]} created a backup of wiki content at #{Time.now}\"\n elsif operation == \"Updateapproved\"\n file.puts \"#{$credentials[0]} approved an update to the wiki at #{Time.now}\"\n elsif operation == \"Updatedenied\"\n file.puts \"#{$credentials[0]} denied a proposed update to the wiki at #{Time.now}\"\n elsif operation == \"Adminupdate\"\n file.puts \"The administrator updated the wiki at #{Time.now}\"\n elsif operation == \"Viewlog\"\n file.puts \"#{$credentials[0]} viewed this file at #{Time.now}\"\n else\n #Do something\n end\n file.close\n end",
"def logging_prefs; end",
"def log_username\n @config.audit_usernames ? username : \"user with key #{@key_id}\"\n end",
"def logger ; @log end",
"def log_writer; end",
"def verifica_perfil\n user = User.find(session[:login]);\n if user.perfil != 1\n redirect_to(bot_path)\n end\n end",
"def pide_login\n if !logado\n redirect_to login_path,:notice=>'Se requiere usuario y clave'\n\t end\n end",
"def secure_change_in_logs(checksum, this_change) \n log = @filename.to_s + Logger::DELIMITER\n log += @version.to_s + Logger::DELIMITER\n log += checksum + Logger::DELIMITER\n log += this_change.username.to_s + Logger::DELIMITER\n log += this_change.position.node.to_s + Logger::DELIMITER \n log += this_change.position.offset.to_s + Logger::DELIMITER\n\n if this_change.is_a? Insertion\n log += \"insertion\" + Logger::DELIMITER\n log += this_change.content + Logger::DELIMITER\n elsif this_change.is_a? Deletion\n log += \"deletion\" + Logger::DELIMITER\n log += this_change.direction + Logger::DELIMITER\n log += this_change.length.to_s + Logger::DELIMITER\n end\n\n # invoke the logger function to log this to the log file\n # it will add the lsn automatically\n Application.logger.recovery log\n end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def verifica_perfil\n @user = User.find(session[:login])\n\t\n \tbegin\n \t@auth_user = User.find(params[:id])\n \tif @user.perfil != 1\n \t\tif action_name != 'ver'\n \t\t\tredirect_to(bot_path)\n \t\telse\tif @auth_user != @user\n \t\t\tredirect_to(bot_path)\t\n \t\t\tend\t\n \t\tend\t\t\n \tend\n \trescue\n \t\tif @user.perfil != 1\n \t\t\tredirect_to(bot_path)\n \t\tend\n \tend\n end",
"def log_full_pathname( data_import_session )\n # Memo-ize the filename the first time this is called:\n @log_filename ||= File.join( Rails.root, 'log', \"#{ get_log_basename(data_import_session) }#{ get_log_extension(data_import_session) }\" )\n end",
"def reopen_logs; end",
"def logged?;\n false\n end",
"def logging_in\n \t\t\n \tend",
"def autoflush_log; end",
"def autoflush_log; end",
"def log_file\n Vedeu::Configuration.log\n end",
"def create_log\n if Role.all.empty?\n unless UserSession.find == nil\n Log.create(user_id: UserSession.find.user.id, message: \n \"#{UserSession.find.user.name} har opprettet en ny rolle med navn: #{self.name}\",\n logtype_id: 2)\n end\n end\n end",
"def log=(log); end",
"def add_to_log\n user_name = self.user.name || self.user.email.split('@')[0]\n Log.create!(loggingtype: 2,user_id_1: self.user.id ,user_id_2: nil,admin_id: nil,story_id: self.story.id ,interest_id: nil,message: (user_name+\" commented on \\\"\" + self.story.title + \"\\\" with \\\"\" + self.content + \"\\\"\").to_s )\n Admin.push_notifications \"/admins/index\" ,\"\"\n end",
"def log_file\n factorio.server.log_file\n end",
"def log_path(name, log_dir)\n # TODO ?\n end",
"def logado?\n !current_user.nil?\n end",
"def path_log\n @path_log ||= File.join(folder, 'log.txt')\n end",
"def logrotated?(file)\n end",
"def log_entry(page_name)\n log_file = File.open(\"text_files/log.txt\", \"a\")\n log_file.puts(Time.now.to_s + \"<br>\")\n log_file.puts(\"Edit to page: \" + page_name + \"<br>\")\n log_file.puts(\"By User: <b>\" + $credentials[0] + \"</b>\" + \"<br>\")\n log_file.close\nend",
"def log_file?\n log_file\n end",
"def log_files(method, *args)\n # When running remotely on an LSF client, the LSF manager will capture STDOUT (i.e. the console log output)\n # and save it to a log file.\n # Don't write to the last log file in that case because we would have multiple processes all vying to\n # write to it at the same time.\n last_file.send(method, *args) unless Origen.running_remotely?\n @job_file.send(method, *args) if @job_file\n end",
"def logging_in\n end",
"def solo_perfilados\n redirect_to root_path if current_user.perfilado !=true\n end",
"def logado?\n !admin_atual.nil?\n end",
"def log\n \"#{self.dir}.log\"\n end",
"def log=(logger); end",
"def Auditlog( mo, msg )\n auditEntry = Audit.new\n auditEntry.message = \"#{mo} #{caller[0][/`.*'/][1..-2]} #{msg.inspect}\"\n #auditEntry.origin = ip\n auditEntry.origin = request.remote_ip\n auditEntry.user = !current_user.nil? ? current_user.email : 'no-user'\n auditEntry.datetime = DateTime.now\n\n if !auditEntry.save\n _auditLog.info \"#{user} #{ip} #{caller[0][/`.*'/][1..-2]} #{msg.inspect}\"\n end\n\n end",
"def apresentacao\n if @permissao === \"convidado\"\n puts \"o usuário selecionado possui a permissao de Convidado\"\n end\n if @permissao === \"autenticado\"\n puts \"o usuário selecionado possui a permissao de Autenticado\"\n end\n if @permissao === \"admin\"\n puts \"o usuário selecionado possui a permissao de Admin\"\n end\n end",
"def log(text=\"\", new_line=true)\n super(DO_LOGGER_FORMAT % [user, name, text], new_line)\n end",
"def error_log\n end",
"def error_log\n end",
"def error_log\n end",
"def index\r\n unless read_fragment(\"#{log_owner.login}/log/index/#{params[:page]||1}/#{write_permission?}\")\r\n #Si es el dueo del log poner un botn para que pueda aadir sesiones\r\n @buttons = write_permission?\r\n\r\n conditions = \"user_id = #{log_owner.id}\"\r\n conditions << \" AND private = FALSE\" unless write_permission?\r\n\r\n #Listar las ultimas sesiones de entrenamiento (paginar)\r\n @pages, @ses = paginate(:training_sessions,\r\n :per_page =>15,\r\n :conditions => conditions,\r\n :order => 'done_on DESC, id DESC')\r\n end\r\n end",
"def log_folder(_ = nil)\n super model_id.to_s\n end",
"def autoflush_log=(_arg0); end",
"def autoflush_log=(_arg0); end",
"def logger_output; end",
"def logfile\n nil\n end",
"def log_production\n #@log.outputters << Outputter.stdout\n set_dir_and_logfilename(Time.now.to_i)\n FileOutputter.new('coregame_log', :filename=> @out_log_name) \n myApacheLikeFormat = PatternFormatter.new(:pattern => \"[%d] %m\") # questo usa [data] <testo>\n mybaseApacheLikeLog = RollingFileOutputter.new 'coregame_log', \n :maxsize => 999999999, \n :maxtime => 86400 * 7, # tempo in secondi (1 * 14 giorni). Dopo 14 giorni avviene il rollout e \n # quindi viene creato un nuovo file\n :filename => out_log_name, \n :trunc => false, # se true viene usato 'w' in File.open, altrimenti con false 'a' \n # voglio 'a' in quanto ogni volta che viene chiamato lo script, devo avere un append\n :formatter => myApacheLikeFormat\n\n \n Log4r::Logger['coregame_log'].add 'coregame_log'\n Log4r::Logger['coregame_log'].level = INFO\n end",
"def note_failed_signin\n flash[:error] = \"Не возможно войти как '#{params['/session'][:login]}'\"\n logger.warn \"Ошибка входа в систему пользователем '#{params['/session'][:login]}' IP: #{request.remote_ip} время: #{Time.now.utc}\"\n l=Loggs.new\n l.username=\"#{params['/session'][:login]}\"\n remote_ip = client_ip\n l.message=\"Ошибка входа в систему IP: #{remote_ip}\"\n l.event='LOGERR'\n l.created_at=Time.now\n l.logg_date=Date.today\n l.save\n end",
"def is_logged?\n if session[:clinica_id].nil?\n redirect_to root_url, :alert => \"Voce nao esta logado\"\n end\n end",
"def log_cog(filename: 'logfile')\n logger = RessurrectorCog.new(\n accessors: %i[log_msg severity],\n args: {\n log_msg: %(======= Log Initialised #{Time.now} =======),\n severity: :info,\n filename: filename,\n file: File.open(\"log/#{filename}.log\", 'a+')\n }) do |log_state|\n begin\n log_msg = %Q(=== #{Time.now} #{log_state[:serverity].to_s.upcase} ===\n #{log_state[:log_msg]}\n )\n f.write log_msg && true\n rescue\n :reinit\n end\n logger.turn && logger\n end\n\n def log_this(log_cog, severity=:info, message)\n log_cog.log_msg = message\n log_cog.severity = severity\n log_cog.turn\n end\nend",
"def logged_in\r\n end",
"def before_save #def self.before_save()\n @my_log.info(\"Creating user with name #{self.name}\")\n end",
"def log_path\n \n @log_path = \"doc/mylog/articles\"\n \n end",
"def log(msg)\n @script = File.basename $0 \n logfile = $config[\"settings\"][\"log_directory\"] + \"/#{@script}.log\"\n if $config[\"settings\"][\"log_file\"]\n File.open(logfile, 'a') do |file|\n now = Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n file.puts \"#{@script} #{now} -> #{msg}\"\n end\n end\n puts \"#{@script} -> #{msg}\"\nend",
"def log_rotation_checks\n detect_os\n \n # this works for php\n app_servers.each do |server|\n force_log_rotation(server)\n log_check(server, \"/mnt/log/#{server.apache_str}/access.log.1\")\n end\n end",
"def registrar_log(tipo)\n logp = Logproducto.new(:usuario_id => self.usuario_id, \n :producto_id => self.id, \n :tipo => tipo, \n :nusuario => self.usuario.nombre, \n :nproducto => self.nombre)\n return logp.save\n end",
"def configure_logger_for(classname, methodname)\n logger = CustomLogger.new(get_log_path, shift_age = LOG_MAX_FILES, shift_size = LOG_MAX_SIZE)\n logger.level = get_log_level\n logger\n end"
] | [
"0.6218747",
"0.60744625",
"0.60131115",
"0.60131115",
"0.5852771",
"0.579949",
"0.57956535",
"0.5786507",
"0.5786507",
"0.5786507",
"0.5786507",
"0.5786507",
"0.5786507",
"0.5786507",
"0.5786507",
"0.57705",
"0.5732644",
"0.57291436",
"0.5722923",
"0.5645564",
"0.56273174",
"0.5621479",
"0.56122667",
"0.5599557",
"0.5583201",
"0.5578102",
"0.5525922",
"0.5509479",
"0.5503717",
"0.5471602",
"0.54692763",
"0.54543966",
"0.5448014",
"0.54269683",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.541647",
"0.5407043",
"0.54065335",
"0.5401288",
"0.5368057",
"0.535161",
"0.53299034",
"0.53299034",
"0.53205657",
"0.5316384",
"0.53098136",
"0.5300263",
"0.5295419",
"0.52855664",
"0.52770543",
"0.52684754",
"0.524715",
"0.524577",
"0.52454805",
"0.5245428",
"0.52363706",
"0.52289987",
"0.5224601",
"0.52227825",
"0.5219044",
"0.5190586",
"0.5180528",
"0.5170494",
"0.51690894",
"0.51690894",
"0.51690894",
"0.5168846",
"0.51676446",
"0.5160532",
"0.5160532",
"0.5153817",
"0.515046",
"0.51487917",
"0.5147137",
"0.5142177",
"0.5141301",
"0.51325905",
"0.5130681",
"0.5129725",
"0.5129033",
"0.51288635",
"0.51220834",
"0.5120777"
] | 0.5316611 | 61 |
Metodos para realizar login como pessoa juridica | def realizar_login_pj(crm, uf, prestador, senha)
@crm = crm
@uf = uf
@prestador = prestador
@senha = senha
numero_crm_pj_input.set(@crm)
sleep(1)
uf_crm_pj_select.click.find(@uf).click
sleep(1)
continuar_pj_button.click
prestador_pj_select.click.find(@prestador).click
sleep(1)
senha_pj_input.set(@senha)
sleep(1)
entrar_pj_button.click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login; end",
"def default_login\n login(\"rohitsjce@gmail.com\",\"codetheoryio\")\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def capable_login_auth?; end",
"def realizar_login\n input_login.set \"juzi\"\n input_senha.set \"jose\"\n btn_login.click\n end",
"def login\n\tend",
"def login\n\n end",
"def login\n\n end",
"def login\n @login || self.username || self.email\n end",
"def fazer_login\n self.input_email.set $dados['user']['user_submarino']\n self.input_senha.set $dados['user']['password_submarino']\n self.button_continuar.click\n end",
"def login(user=:joerg)\r\n login_as(user)\r\n end",
"def login\n @login || self.nickname || self.email\n end",
"def login_valido email, password\n $helper.preencher_web_edit(txt_EmailAddress(), email)\n $helper.preencher_web_edit(txt_Password(), password)\n $helper.clicar_objeto(btn_SigIn())\n end",
"def login\n if not @login.nil? and not @login.blank?\n @login\n elsif not self.username.nil? and not self.username.empty?\n self.username\n else\n self.email\n end\n end",
"def http_auth_login\n # FIXME: Implement\n end",
"def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend",
"def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end",
"def try_to_login\n User.login(self.name, self.password)\n end",
"def needs_login?() false end",
"def login\n self.user_id ? user.login : self.name\n end",
"def login\n @user_login\n end",
"def login\n @login || self.username || self.email\nend",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login_correctly\r\n\t\tuserid = \"correct_user@email.com\"\r\n\t\tpassword = \"correct_password\"\r\n\tend",
"def login_choice\n end",
"def realizar_login (perfil_usuario)\n\n @perfil = perfil_usuario\n\n \n case @perfil\n\n when \"pessoa fisica\"\n \n escolher_perfil(@perfil)\n realizar_login_pf(\"41906\", \"#ufCrm > option:nth-child(19)\", \"123\")\n\n when \"pessoa juridica\"\n\n visit \"/\"\n sleep(1)\n escolher_perfil(@perfil)\n realizar_login_pj(\"36172\", \"#ufCrmPJ > option:nth-child(19)\", \"'#prestador > option:nth-child(3)'\", \"cn&n77&9\")\n\n when \"area restrita\"\n\n escolher_perfil(@perfil)\n sleep(1)\n realizar_login_restrito(\"ODANIELE\", \"123\")\n\n else\n\n puts \"Erro na selecao de perfil\"\n\n end\n\n\n end",
"def require_login\n end",
"def login_code\n self.login.login\n end",
"def attemp_login\n login = params[:email_or_phone]\n password = params[:password]\n\n unless !(login.present? && password.present?)\n #on recherche le customer\n @customer = Customer.find_by_phone(login)\n if @customer.blank?\n respond_to do |format|\n format.json {}\n format.html {render :signing, notice: \"Impossible de trouver #{login}\"}\n end\n else\n if @customer.valid_password?(password)\n session[:customer] = @customer.authentication_token\n respond_to do |format|\n format.html { redirect_to client_index_path(user: @customer.hand), notice: \"Logged in as #{@customer.phone}\"}\n end\n else\n respond_to do |format|\n format.html {redirect_to client_signing_path, notice: \"Utilisateur inconnu\"}\n end\n end\n end\n end\n end",
"def client_login\n user = User.authenticate(params[:email], params[:password])\n if user\n session[:user_id] = user.id\n params.delete(:locale)\n set_locale\n redirect_to :controller=>'home', :action=>'index'\n else # Si hay error:\n #Verifico que el usuario este registrado en el sistema\n if User.find_by_email(params[:email]).nil?\n flash[:error] = I18n.t('session.login_email_error', :user=> params[:email].to_s)\n redirect_to sessions_url\n else\n #Si email es valido entonces el error es el password\n flash[:error] = I18n.t('session.login_password_error')\n render \"index\", :layout => \"login\"\n end\n end\n end",
"def do_login\n type = :unknown\n\n if !cookies[:user].nil? && cookies[:user] != \"\"\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"MD5(CONCAT(?,'|',?,'|',username,'|',password))=?\",\n\t\t\t PW_SALT, request.remote_ip, cookies[:user]\n\t\t\t ]\n );\n\n type = :cookie\n\n elsif params[:token]\n token = Token.find_by_token( params[:token] );\n @user = token.user if ( !token.nil? )\n\t\n type = :token\n\n elsif params[:user]\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"username = ? AND password = ?\",\n\t\t\t params[:user][:username],\n\t\t\t User.make_hashed_password(params[:user][:password])\n\t\t\t ]\n )\n\n type = :form\n end\n\n if ( type == :form && !verify_recaptcha() )\n flash[:error] = \"are you not human?\"\n return( redirect_to :action => \"login\")\n end\n\n if !@user.nil?\n session[:user] = @user.id\n return( redirect_to :controller => \"home\", :action => \"index\" )\n\n else\n flash[:error] = \"Login failed.<br/>\"\n\n if type == :cookie\n\tflash[:error] += \"Your login cookie was not valid\"\n\tcookies[:user] = nil\n\n elsif type == :form\n\tflash[:error] += \"Username and password do not match\"\n\n elsif type == :token\n\tflash[:error] += \"The token is invalid\"\n\n else\n\tflash[:error] += \"Something went terribly wrong.\"+\n\t \"We have been informed, please try again later\"\n\tRAILS_DEFAULT_LOGGER.error(\"Unknown login type found\");\n\n end\n\n return( redirect_to :action => \"login\" )\n end\n end",
"def login(name_or_email, plain_password)\n name_or_email.downcase! # \n if name_or_email.include?(\"@\")\n user = User.find_by_email(name_or_email)\n else\n user = User.find_by_username(name_or_email)\n end\n if user == nil || user.password != plain_password || !user.validated\n user = nil\n end\n return user\nend",
"def userlogin(req)\n\tbasica = request.env[\"HTTP_AUTHORIZATION\"].to_s.split(\"Basic \")\n\tbasicas = basica[1].to_s\n\tauthdata = (Base64.decode64(basica.to_s)).split(':')\n\tusername = authdata[0].to_s\n\tpass = authdata[1].to_s\n\tputs \"Usuario: #{username}\"\n\tputs \"Password: #{pass}\"\n\tu = User.where(email:username,password:pass).take\n\tsession[:username] = username\n\treturn u\nend",
"def login_user(user = User.create!(email: 'marcos@iugu.com.br', password: '123456'))\n \tlogin_as user, scope: :user\n user\n end",
"def login_with_proper_credentials\r\n\r\n set_text(USERNAME_TEXTFIELD_NAME, VALID_USERNAME)\r\n set_text(PASSWORD_TEXTFIELD_NAME, VALID_PASSWORD)\r\n\r\n click_on_button(SUBMIT_BUTTON_ID)\r\n\r\n end",
"def log_in\n end",
"def try_login\n if user = http_auth_login || validation_login || remember_me_login\n session[:uid] = user.id\n end\n end",
"def form_preencher(login, senha)\n txt_username.set login\n txt_password.set senha\n end",
"def login_instructions\n end",
"def login?\n if login\n return true\n else\n return nil\n end\n end",
"def api_login\n creator = Creator.find_by(name: request.headers['name'])\n if creator && creator.authenticate(request.headers['password'])\n encode = encodeJWT(creator)\n selected_format({jwt: encode,creator_id: creator.id,name: creator.name,submits:creator.submits},:ok)\n else\n selected_format({ error: 'Invalid username or password' },:unauthorized)\n end\n end",
"def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end",
"def login(login, password)\n raise NotImplementedError\n end",
"def acessar_login\n self.span_minha_conta.click\n self.button_entrar.click\n end",
"def login\n valid = true\n \n if username.blank?\n self.errors.add_to_base(\"Please enter a user name\")\n valid = false\n end\t\n \n if password.blank?\n self.errors.add_to_base(\"Please enter a password\")\n valid = false\n end\n \t\t\n if valid\n user = User.find(:first, :conditions => [\"username = ? AND password = ?\", username, password])\n \n if user\n self.id = user.id\n self.reload\n else\n self.errors.add_to_base(\"The user name/password was incorrect.\")\n valid = false\n end\n end\n \n valid\n end",
"def login(username,password)\n puts \"in login\"\n sleep(2)\n switch_to_active_modal\n login_modal = find(LOGIN_MODAL)\n puts (\"login_modal is #{login_modal}\")\n find(USERNAME)\n type(USERNAME, username)\n password_field = find(PASSWORD)\n type(PASSWORD, password)\n password_field.submit()\n sleep(4)\n end",
"def make_login user, password\n server = Configuration.SERVER\n addr = Configuration.CLIOWL_ADDRESS\n \n HttpHelper.post \"http://#{server}#{addr}/login\", { 'user' => user, 'password' => password }\n end",
"def login\n self.class.trace_execution_scoped(['Custom/login/find_user']) do\n @u = (User.find_by_primary_email(params[:username].downcase) || User.find_by_nickname(params[:username].downcase.to_s)) if params[:username]\n end\n\n self.class.trace_execution_scoped(['Custom/login/if_block']) do\n if @u and @u.has_password? and @u.valid_password?(params[:password])\n @user = @u\n elsif @u and (params[:password] == \"anonymous\") and (@u.user_type == User::USER_TYPE[:anonymous])\n @user = @u\n else\n query = {:auth_failure => 1, :auth_strategy => \"that username/password\"}\n query[:redir] = params[:redir] if params[:redir]\n redirect_to add_query_params(request.referer || Settings::ShelbyAPI.web_root, query) and return\n end\n end\n\n # any user with valid email/password is a valid Shelby user\n # this sets up redirect\n self.class.trace_execution_scoped(['Custom/login/sign_in_current_user']) do\n sign_in_current_user(@user)\n end\n redirect_to clean_query_params(@opener_location) and return\n end",
"def login\n # pull the user info from the user model with the login params\n user = User.find_by_login(params[:login])\n # Authenciate with password\n if user and user.authenticate(params[:password])\n session[:user_id] = user.id\n session[:user_login] = user.login\n session[:user_authority] = user.authority\n # redirect to the landing page\n redirect_to \"/projects\"\n # failed \n else\n redirect_to login_url, alert: \"無効なID、パスワードの組み合わせです。\"\n end\n end",
"def verifica_logado\n sleep(3)\n if @browser.table(:class, \"f\").exist? == true\n if @browser.table(:class, \"f\").contains_text(\"©2011 Google\")\n @browser.text_field(:name, 'Email').set($login_user)\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"Passwd\").set($password_user)\n else\n @browser.password(:name, \"Passwd\").set($password_user)\n end\n @browser.button(:name, 'signIn').click\n else\n end\n elsif\n if @browser.div(:class, \"glb-bloco layout-login\").exists? ==true\n @browser.text_field(:name, \"login-passaporte\").set(\"teste_timeinfra@corp.globo.com\")\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"senha-passaporte\").set($password_user)\n else\n @browser.password(:name, \"senha-passaporte\").set($password_user)\n end\n @browser.button(:class, \"botao-acessar\").click\n end\n else\n end\n sleep(1)\nend",
"def validate_login_user(params)\n params[\"username\"] and params[\"password\"] and params[\"password\"] == params[\"password_2\"]\n end",
"def login_from_params\n User.authenticate(params[:login], params[:password])\n end",
"def login\n \tauthenticate(params)\n end",
"def login\n mech = Mechanize.new\n page = mech.get(LOGIN_URL)\n username_field = page.form.field_with(id: \"user_email\")\n username_field.value = USER\n password_field = page.form.field_with(id: \"user_password\")\n password_field.value = PASS\n page.form.submit\n end",
"def login\n session[:user_id] = nil\n session[:is_admin] = nil\n session[:is_editor] = nil\n if request.post?\n user = User.authenticate(params[:name], params[:password])\n puts user\n if user\n session[:user_id] = user.id\n session[:is_admin] = (user.is_admin == 1)\n session[:is_editor] = (user.is_editor == 1)\n redirect_to :controller => 'home'\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end",
"def login\n make_login_call\n end",
"def comprobar_usuario_login\n @usuario_actual=nil\n return unless session[:user_id]\n @usuario_actual = Usuario.find_by_id(session[:user_id])\n end",
"def login\n self.login\n end",
"def UserLogin(user)\n choose_language(user.language)\n username_tb.type_text(user.username)\n password_tb.type_text(user.password)\n partnerType = user.partnerType\n case partnerType\n when 'home'\n home_login_btn.click\n when 'pro'\n login_btn.click\n ent_restore_link.click\n when 'ent'\n login_btn.click\n #if (user.keyType == 'ckey')\n # if (\"#{QA_ENV['environment']}\" == \"staging\")\n # ent_restore_link_ckey.click\n # else if (\"#{QA_ENV['environment']}\" == \"production\")\n # ent_restore_link_ckey1.click\n # end\n # end\n #end\n\n if (\"#{QA_ENV['environment']}\" == \"staging\")\n if (user.keyType == 'ckey')\n ent_restore_link_ckey.click\n else\n ent_restore_link_stag.click\n end\n else if (\"#{QA_ENV['environment']}\" == \"production\")\n if (user.keyType == 'ckey')\n ent_restore_link_ckey1.click\n else\n ent_restore_link.click\n end\n\n else\n ent_restore_link.click\n end\n end\n\n when 'oem'\n login_btn.click\n ent_restore_link.click\n end\n #puts \"**********\"\n #puts page.response_headers()\n #puts `pwd`\n end",
"def process_login\r\n# Somebody is probably playing\r\n return dc_render_404 unless ( params[:record] and params[:record][:username] and params[:record][:password] )\r\n\r\n unless params[:record][:password].blank? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username])\r\n if user and user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to params[:return_to] || '/'\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to params[:return_to_error] || '/'\r\nend",
"def logged_in\r\n end",
"def set_functions\n # Login as a given user.\n # @param username [String] The username to use.\n # @return [Boolean] Whether the login process succeeded.\n function(:login) {|as_who = 'ole-khuntley'| raise OLE_QA::Framework::Error,\"Login field not present on this page: #{self.class.name}\" unless login_field.present? ; login_field.set(as_who) ; login_button.click ; if login_confirmation.present? then login_confirmation.text.match(/#{as_who}/) ? true : false else false end}\n # Logout from previous login.\n # @return [Boolean] Whether the logout process succeeded.\n function(:logout) { logout_button.click ; login_confirmation.present? ? false : true}\n end",
"def login_account(username, password)\n login_form.email_txt.set username\n login_form.password_txt.set password\n login_form.login_btn.click\n end",
"def login\n @user = User.find_by nickname: params[:nickname]\n if @user\n if (@user.is_password?(params[:password]))\n session[:id] = @user.id\n redirect_to url_for(:controller => :users, :action => :show, id: @user.id)\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid password.\"\n end\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid username.\"\n end\n end",
"def process_login\r\n # Somebody is probably playing\r\n return dc_render_404 unless ( params.dig(:record, :username) && params.dig(:record, :password) )\r\n\r\n return_to = request.env['HTTP_REFERER'] || '/'\r\n if params[:record][:password].present? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username], active: true)\r\n if user && user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to(params[:return_to] || return_to, allow_other_host: true)\r\n else\r\n clear_login_data # on the safe side\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to return_to\r\nend",
"def login_user_with_interface(username, password)\n activate_authlogic \n visit login_path\n click_link \"Connexion | Inscription\"\n fill_in 'user_session_username', :with => username\n fill_in 'user_session_password', :with => password\n click_button \"Connexion\"\n wait_for_ajax \nend",
"def logon2(username, password, dbname, mode)\n #This is a stub, used for indexing\n end",
"def login\n user = User.find_by_email(params[:username])\n if user.nil? || (user && user.authenticate(params[:password]) == false) || user.deleted\n render status: 400, json: nil \n else\n session[:user_id] = user.id\n session[:username] = user.username\n session[:email] = user.email\n session[:verified] = user.verified\n user.last_ip_login = request.remote_ip\n user.save\n render status: 200, json: session\n end\n end",
"def logged_in?\n \t#devuelve un booleano para saber si hay un usuario loggeado o no. \n \t#para eso sirven los dos signos de exclamacion !!\n \t!!usuario_actual\n end",
"def login\n if request.post? then\n if params[:courriel] && !params[:courriel].empty?\n # Trouvez les profils ayant cette adresse.\n fs = Famille.where(\"courriel1 = :courriel1 or courriel2 = :courriel2\", {:courriel1 => params[:courriel], :courriel2 => params[:courriel]})\n if !fs.empty?\n fs.each do |f|\n msg = t(:public_login_link)\n sujet = t(:public_login_sujet)\n FamilleMailer.info(f, sujet, params[:courriel], msg, f.langue).deliver\n end\n flash[:notice] = t(:public_login_sent)\n else\n flash[:notice] = t(:public_login_unk)\n end\n else\n flash[:notice] = t(:public_login_inv) \n end\n \n end\n \n # On recommence avec le meme formulaire de login\n render 'login'\n end",
"def logon(login, password)\n @login, @password = login, password\n @namespace = @login + \"_\" + (@namespace || '')\n end",
"def get_login_with_full_name\n self.login.to_s + ' | ' + self.escolar.full_name.to_s\n end",
"def login\n # puts \"UserNAme #{username}.\"\n self.login_username_element.when_present(30)\n # expect(self.login_username?).to be_truthy\n self.login_username= DT['ENV']['Username']\n self.login_password= DT['ENV']['Password']\n self.login_login\n end",
"def logar(email, senha)\n find('#login_email').set email\n find('#login_password').set senha\n find('button[id*=btnLogin]').click\n #login_button.click\n end",
"def require_login?\n !(Jiralicious.username.empty? && Jiralicious.password.empty?) && !alive?\n end",
"def login(user)\n\tif $users_profil.include?(user)\n\t\tputs \"Username: #{user}\"\n\t\tputs \"Profil: #{$users_profil[user]}\" \n\telse \n\t\tputs \"Numele de utilizator este gresit.\"\n\t\tprima # daca a scris usernamul gresit sau daca acel username nu exista atunci scriptul practic se reinitializeaza\n\tend\nend",
"def login(user='',password='',save=true)\n if user.class!=String or password.class!=String\n raise ZbxAPI_ExceptionBadAuth.new,'Login called with non-string values'\n end\n if (user!='' and password!='') then\n l_user = user\n l_password = password\n if save then\n @user_name=user\n @password=password\n end\n elsif (@user_name!='' and @password!='') then\n l_user = @user_name\n l_password = @password\n end\n\n #Somewhere in the 1.8.x cycle it was decided to do deprecate with user.authenticate\n #however it was not documented well, so we will try uer.login first, and fall\n #back to user.authenticate as user.login does not exist in 1.8.3\n login_methods=[\"user.login\",\"user.authenticate\"]\n\n begin\n result = do_request(json_obj(login_methods.first,{'user'=>l_user,'password'=>l_password}))\n @auth=result['result']\n\n #setup the version variables\n @major,@minor=do_request(json_obj('APIInfo.version',{}))['result'].split('.')\n @major=@major.to_i\n @minor=@minor.to_i\n rescue ZbxAPI_ExceptionLoginPermission => e\n login_methods.delete_at(0)\n if !login_methods.empty?\n retry\n else\n raise ZbxAPI_ExceptionBadAuth.new('Invalid User or Password',:error_code=>e.error_code)\n end\n rescue SocketError\n raise ZbxAPI_ExceptionBadServerUrl\n rescue JSON::ParserError\n raise ZbxAPI_ExceptionBadServerUrl\n rescue Errno::ECONNREFUSED\n raise ZbxAPI_ExceptionBadServerUrl\n rescue => e\n raise ZbxAPI_ExceptionBadAuth.new('General Login error, check host connectivity.')\n end\n\n return self\n end",
"def log_in_as(login, plaintext_password = 'password')\n visit '/'\n fill_in 'username_or_email', with: login\n fill_in 'password', with: plaintext_password\n click_on 'Login'\nend",
"def login_known(the_user)\n # Get an instance of the user\n user = users(the_user)\n # provide the credentials and log in\n # Note the encrypted_password in the yml was created using an\n # instance of User in console with a password as below\n post user_session_path,\n params: {\n user: {\n email: user.email,\n password: \"secret08\",\n remember_me: 0\n },\n commit: \"Log in\"\n }\n end",
"def get_user_login\n #self.network_login.blank? ? self.login : self.network_login.split('-',2)[1]\n self.get_network_login.blank? ? \"\" : self.get_network_login.gsub(self.primary_network.coded_name+'-', '') rescue ''\n end",
"def login_from_params\n authenticate(params[:password])\n end",
"def get_login_info\n username = ask(\"Acunote Login name:\")\n password = ask(\"Acunote(LDAP) Password:\") {|q| q.echo = false}\n {:username => username, :password => password}\n end",
"def prep_login_form(default_name)\n open_form\n add_field('username', default_name, 'text', \"required\", 'username_or_email', t.labels.username_label )\n add_field('password', '', 'password', \"required\", 'password', t.labels.password_label )\n end",
"def login\n session[:engeener_id] = nil\n if request.post?\n engeener = Engeener.authenticte(params[:nzwisko], params[:password])\n if engeener\n session[:engeener_id] = engeener.id\n uri = session[:original_uri]\n session[:original_uri] = nil\n redirect_to(uri || { :action => \"index\" }) #TODO: move this to status page\n # redirect_to(:action => \"index\", :controller => \"Login\")\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end",
"def password_authentication\n if user = User.authenticate(params[:login], params[:password])\n successful_login(user,params[:url])\n else\n failed_login(user, \"Couldn't log you in as '#{params[:login]}'\")\n end\n end",
"def login\n mandatory_keys = [:app_id, :user_name, :password, :sign]\n if params.slice(*mandatory_keys).values.any?(&:nil?)\n render json: to_response('Some params are lost') and return\n elsif @service_provider.nil?\n render json: to_response('ServiceProvider error') and return\n elsif not CommonUtils.valid_sign?(params[:app_id], params[:user_name], params[:password], @service_provider.credential, params[:sign])\n render json: to_response('Invalid request: parameter error') and return\n end\n\n user = User.find_by_user_name(params[:user_name])\n if user && user.authenticate(params[:password])\n render json: (user.invalid_role? ? to_response('User needs to be activated') : to_response('success', user))\n elsif user.nil?\n render to_response \"User not exist:#{params[:user_name]}\"\n else\n render to_response 'Password error'\n end\n end",
"def login_helper\n username = prompt.ask(\"Enter Username\")\n password = prompt.ask(\"Enter Password\")\n if User.find_by(name: username, password: password)\n self.user = User.find_by(name: username, password: password)\n # no music yet\n puts \"Let's Get Cookin, #{self.user.name.upcase}!!!\"\n sleep(1.5)\n main_menu\n else\n puts \"Incorrect Username or Password\"\n sleep(1.5)\n login_page\n end\n end",
"def login\n\n=begin\n :: Expected Params ::\n\n Constants::REQUEST_PARAM_USERNAME => Username\n Constants::REQUEST_PARAM_USERPASSWORD => UserPassword\n\n=end\n\n # Look up for User in database\n find_user\n\n if @user\n @user.signin!(request)\n\n render json: {status: status_code(:ok), message: '', data: @user.as_signin_json}\n \n end\n\n end",
"def login\n tries ||= 3\n puts \"========= Performing Login\"\n @log.add_message(\"Efetuando login com #{self.aliexpress.email}\\n\")\n @b.goto \"https://login.aliexpress.com/\"\n frame = @b.iframe(id: 'alibaba-login-box')\n frame.text_field(name: 'loginId').set self.aliexpress.email\n sleep 1\n frame.text_field(name: 'password').set self.aliexpress.password\n sleep 1\n frame.button(name: 'submit-btn').click\n sleep 5\n rescue => e\n puts e.message\n @log.add_message \"Erro de login, Tentando mais #{tries} vezes\"\n @log.add_message e.message\n retry unless (tries -= 1).zero?\n end"
] | [
"0.7506705",
"0.73283744",
"0.73107433",
"0.73032063",
"0.73032063",
"0.73032063",
"0.73032063",
"0.73032063",
"0.73032063",
"0.73032063",
"0.73032063",
"0.73032063",
"0.72707826",
"0.720714",
"0.7205281",
"0.7191762",
"0.7191762",
"0.7189113",
"0.7100891",
"0.7067156",
"0.7016488",
"0.70055735",
"0.70026886",
"0.6985046",
"0.6976803",
"0.69697046",
"0.6925232",
"0.6891223",
"0.6868449",
"0.6834583",
"0.6817794",
"0.6790186",
"0.6790186",
"0.6790186",
"0.6781591",
"0.6779913",
"0.676631",
"0.67598003",
"0.6754098",
"0.6750729",
"0.6749461",
"0.6710556",
"0.6706176",
"0.6690248",
"0.6677125",
"0.6672859",
"0.66633177",
"0.6655163",
"0.6634654",
"0.6629612",
"0.66169894",
"0.66048574",
"0.659844",
"0.6595198",
"0.65939385",
"0.65925074",
"0.6586286",
"0.657917",
"0.65704894",
"0.65684545",
"0.6562877",
"0.6562445",
"0.6557571",
"0.6556795",
"0.6543943",
"0.65364367",
"0.65343726",
"0.653132",
"0.65096533",
"0.65095216",
"0.650369",
"0.6495126",
"0.64915997",
"0.648933",
"0.648727",
"0.6487017",
"0.6480395",
"0.6480237",
"0.6479782",
"0.6473784",
"0.6462201",
"0.6457214",
"0.6447718",
"0.6447212",
"0.6441983",
"0.643985",
"0.64374506",
"0.64353067",
"0.6431427",
"0.64230335",
"0.6415595",
"0.6413625",
"0.6411194",
"0.64106095",
"0.6410491",
"0.640761",
"0.640526",
"0.6403533",
"0.640205",
"0.6400297"
] | 0.6614409 | 51 |
Metodos para realizar login como pessoa fisica | def realizar_login_pf(crm, uf, senha)
@crm = crm
@uf = uf
@senha = senha
numero_crm_pf_input.set(@crm)
sleep(1)
uf_crm_pf_select.click.find(@uf).click
sleep(1)
continuar_pf_button.click
senha_pf_input.set(@senha)
sleep(1)
entrar_pf_button.click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login; end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n\tend",
"def login\n\n end",
"def login\n\n end",
"def default_login\n login(\"rohitsjce@gmail.com\",\"codetheoryio\")\n end",
"def capable_login_auth?; end",
"def login\n @login || self.username || self.email\n end",
"def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend",
"def fazer_login\n self.input_email.set $dados['user']['user_submarino']\n self.input_senha.set $dados['user']['password_submarino']\n self.button_continuar.click\n end",
"def login_valido email, password\n $helper.preencher_web_edit(txt_EmailAddress(), email)\n $helper.preencher_web_edit(txt_Password(), password)\n $helper.clicar_objeto(btn_SigIn())\n end",
"def login\n if not @login.nil? and not @login.blank?\n @login\n elsif not self.username.nil? and not self.username.empty?\n self.username\n else\n self.email\n end\n end",
"def http_auth_login\n # FIXME: Implement\n end",
"def try_to_login\n User.login(self.name, self.password)\n end",
"def realizar_login\n input_login.set \"juzi\"\n input_senha.set \"jose\"\n btn_login.click\n end",
"def require_login\n end",
"def needs_login?() false end",
"def login\n @user_login\n end",
"def login_correctly\r\n\t\tuserid = \"correct_user@email.com\"\r\n\t\tpassword = \"correct_password\"\r\n\tend",
"def login\n @login || self.nickname || self.email\n end",
"def login\n self.class.trace_execution_scoped(['Custom/login/find_user']) do\n @u = (User.find_by_primary_email(params[:username].downcase) || User.find_by_nickname(params[:username].downcase.to_s)) if params[:username]\n end\n\n self.class.trace_execution_scoped(['Custom/login/if_block']) do\n if @u and @u.has_password? and @u.valid_password?(params[:password])\n @user = @u\n elsif @u and (params[:password] == \"anonymous\") and (@u.user_type == User::USER_TYPE[:anonymous])\n @user = @u\n else\n query = {:auth_failure => 1, :auth_strategy => \"that username/password\"}\n query[:redir] = params[:redir] if params[:redir]\n redirect_to add_query_params(request.referer || Settings::ShelbyAPI.web_root, query) and return\n end\n end\n\n # any user with valid email/password is a valid Shelby user\n # this sets up redirect\n self.class.trace_execution_scoped(['Custom/login/sign_in_current_user']) do\n sign_in_current_user(@user)\n end\n redirect_to clean_query_params(@opener_location) and return\n end",
"def client_login\n user = User.authenticate(params[:email], params[:password])\n if user\n session[:user_id] = user.id\n params.delete(:locale)\n set_locale\n redirect_to :controller=>'home', :action=>'index'\n else # Si hay error:\n #Verifico que el usuario este registrado en el sistema\n if User.find_by_email(params[:email]).nil?\n flash[:error] = I18n.t('session.login_email_error', :user=> params[:email].to_s)\n redirect_to sessions_url\n else\n #Si email es valido entonces el error es el password\n flash[:error] = I18n.t('session.login_password_error')\n render \"index\", :layout => \"login\"\n end\n end\n end",
"def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end",
"def realizar_login (perfil_usuario)\n\n @perfil = perfil_usuario\n\n \n case @perfil\n\n when \"pessoa fisica\"\n \n escolher_perfil(@perfil)\n realizar_login_pf(\"41906\", \"#ufCrm > option:nth-child(19)\", \"123\")\n\n when \"pessoa juridica\"\n\n visit \"/\"\n sleep(1)\n escolher_perfil(@perfil)\n realizar_login_pj(\"36172\", \"#ufCrmPJ > option:nth-child(19)\", \"'#prestador > option:nth-child(3)'\", \"cn&n77&9\")\n\n when \"area restrita\"\n\n escolher_perfil(@perfil)\n sleep(1)\n realizar_login_restrito(\"ODANIELE\", \"123\")\n\n else\n\n puts \"Erro na selecao de perfil\"\n\n end\n\n\n end",
"def log_in\n end",
"def login_choice\n end",
"def login\n make_login_call\n end",
"def comprobar_usuario_login\n @usuario_actual=nil\n return unless session[:user_id]\n @usuario_actual = Usuario.find_by_id(session[:user_id])\n end",
"def login\n valid = true\n \n if username.blank?\n self.errors.add_to_base(\"Please enter a user name\")\n valid = false\n end\t\n \n if password.blank?\n self.errors.add_to_base(\"Please enter a password\")\n valid = false\n end\n \t\t\n if valid\n user = User.find(:first, :conditions => [\"username = ? AND password = ?\", username, password])\n \n if user\n self.id = user.id\n self.reload\n else\n self.errors.add_to_base(\"The user name/password was incorrect.\")\n valid = false\n end\n end\n \n valid\n end",
"def login\n self.user_id ? user.login : self.name\n end",
"def login\n @login || self.username || self.email\nend",
"def try_login\n if user = http_auth_login || validation_login || remember_me_login\n session[:uid] = user.id\n end\n end",
"def login_instructions\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login(user=:joerg)\r\n login_as(user)\r\n end",
"def login(name_or_email, plain_password)\n name_or_email.downcase! # \n if name_or_email.include?(\"@\")\n user = User.find_by_email(name_or_email)\n else\n user = User.find_by_username(name_or_email)\n end\n if user == nil || user.password != plain_password || !user.validated\n user = nil\n end\n return user\nend",
"def process_login\r\n # Somebody is probably playing\r\n return dc_render_404 unless ( params.dig(:record, :username) && params.dig(:record, :password) )\r\n\r\n return_to = request.env['HTTP_REFERER'] || '/'\r\n if params[:record][:password].present? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username], active: true)\r\n if user && user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to(params[:return_to] || return_to, allow_other_host: true)\r\n else\r\n clear_login_data # on the safe side\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to return_to\r\nend",
"def attemp_login\n login = params[:email_or_phone]\n password = params[:password]\n\n unless !(login.present? && password.present?)\n #on recherche le customer\n @customer = Customer.find_by_phone(login)\n if @customer.blank?\n respond_to do |format|\n format.json {}\n format.html {render :signing, notice: \"Impossible de trouver #{login}\"}\n end\n else\n if @customer.valid_password?(password)\n session[:customer] = @customer.authentication_token\n respond_to do |format|\n format.html { redirect_to client_index_path(user: @customer.hand), notice: \"Logged in as #{@customer.phone}\"}\n end\n else\n respond_to do |format|\n format.html {redirect_to client_signing_path, notice: \"Utilisateur inconnu\"}\n end\n end\n end\n end\n end",
"def login\n self.login\n end",
"def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end",
"def do_login\n type = :unknown\n\n if !cookies[:user].nil? && cookies[:user] != \"\"\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"MD5(CONCAT(?,'|',?,'|',username,'|',password))=?\",\n\t\t\t PW_SALT, request.remote_ip, cookies[:user]\n\t\t\t ]\n );\n\n type = :cookie\n\n elsif params[:token]\n token = Token.find_by_token( params[:token] );\n @user = token.user if ( !token.nil? )\n\t\n type = :token\n\n elsif params[:user]\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"username = ? AND password = ?\",\n\t\t\t params[:user][:username],\n\t\t\t User.make_hashed_password(params[:user][:password])\n\t\t\t ]\n )\n\n type = :form\n end\n\n if ( type == :form && !verify_recaptcha() )\n flash[:error] = \"are you not human?\"\n return( redirect_to :action => \"login\")\n end\n\n if !@user.nil?\n session[:user] = @user.id\n return( redirect_to :controller => \"home\", :action => \"index\" )\n\n else\n flash[:error] = \"Login failed.<br/>\"\n\n if type == :cookie\n\tflash[:error] += \"Your login cookie was not valid\"\n\tcookies[:user] = nil\n\n elsif type == :form\n\tflash[:error] += \"Username and password do not match\"\n\n elsif type == :token\n\tflash[:error] += \"The token is invalid\"\n\n else\n\tflash[:error] += \"Something went terribly wrong.\"+\n\t \"We have been informed, please try again later\"\n\tRAILS_DEFAULT_LOGGER.error(\"Unknown login type found\");\n\n end\n\n return( redirect_to :action => \"login\" )\n end\n end",
"def process_login\r\n# Somebody is probably playing\r\n return dc_render_404 unless ( params[:record] and params[:record][:username] and params[:record][:password] )\r\n\r\n unless params[:record][:password].blank? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username])\r\n if user and user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to params[:return_to] || '/'\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to params[:return_to_error] || '/'\r\nend",
"def userlogin(req)\n\tbasica = request.env[\"HTTP_AUTHORIZATION\"].to_s.split(\"Basic \")\n\tbasicas = basica[1].to_s\n\tauthdata = (Base64.decode64(basica.to_s)).split(':')\n\tusername = authdata[0].to_s\n\tpass = authdata[1].to_s\n\tputs \"Usuario: #{username}\"\n\tputs \"Password: #{pass}\"\n\tu = User.where(email:username,password:pass).take\n\tsession[:username] = username\n\treturn u\nend",
"def form_preencher(login, senha)\n txt_username.set login\n txt_password.set senha\n end",
"def logged_in\r\n end",
"def login_with_proper_credentials\r\n\r\n set_text(USERNAME_TEXTFIELD_NAME, VALID_USERNAME)\r\n set_text(PASSWORD_TEXTFIELD_NAME, VALID_PASSWORD)\r\n\r\n click_on_button(SUBMIT_BUTTON_ID)\r\n\r\n end",
"def login_helper\n username = prompt.ask(\"Enter Username\")\n password = prompt.ask(\"Enter Password\")\n if User.find_by(name: username, password: password)\n self.user = User.find_by(name: username, password: password)\n # no music yet\n puts \"Let's Get Cookin, #{self.user.name.upcase}!!!\"\n sleep(1.5)\n main_menu\n else\n puts \"Incorrect Username or Password\"\n sleep(1.5)\n login_page\n end\n end",
"def login\n \tauthenticate(params)\n end",
"def login_from_params\n User.authenticate(params[:login], params[:password])\n end",
"def login_guest()\n login(:guest)\n end",
"def login\n session[:user_id] = nil\n session[:is_admin] = nil\n session[:is_editor] = nil\n if request.post?\n user = User.authenticate(params[:name], params[:password])\n puts user\n if user\n session[:user_id] = user.id\n session[:is_admin] = (user.is_admin == 1)\n session[:is_editor] = (user.is_editor == 1)\n redirect_to :controller => 'home'\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end",
"def login_user(user = User.create!(email: 'marcos@iugu.com.br', password: '123456'))\n \tlogin_as user, scope: :user\n user\n end",
"def login_code\n self.login.login\n end",
"def login?\n if login\n return true\n else\n return nil\n end\n end",
"def login(login, password)\n raise NotImplementedError\n end",
"def loginpage\n end",
"def login\n if request.post? then\n if params[:courriel] && !params[:courriel].empty?\n # Trouvez les profils ayant cette adresse.\n fs = Famille.where(\"courriel1 = :courriel1 or courriel2 = :courriel2\", {:courriel1 => params[:courriel], :courriel2 => params[:courriel]})\n if !fs.empty?\n fs.each do |f|\n msg = t(:public_login_link)\n sujet = t(:public_login_sujet)\n FamilleMailer.info(f, sujet, params[:courriel], msg, f.langue).deliver\n end\n flash[:notice] = t(:public_login_sent)\n else\n flash[:notice] = t(:public_login_unk)\n end\n else\n flash[:notice] = t(:public_login_inv) \n end\n \n end\n \n # On recommence avec le meme formulaire de login\n render 'login'\n end",
"def check_login\n\n if User.where({ :username => params[:username] }).first\n found_user = User.where({ :username => params[:username] }).first\n\n if found_user && found_user.password == params[:password]\n session[:property_admin_id] = found_user.id\n flash[:success] = \"You successfully logged in!\"\n redirect_to admin_index_path\n return\n else\n flash[:error] = \"Wrong password, please try again.\"\n redirect_to admin_login_path\n return\n end\n \n else\n\n flash[:error] = \"User doesn't exist, please try again.\"\n redirect_to admin_login_path\n return\n\n end\n\n end",
"def displayLoginPage()\n\t# User Name: \n\t# Password:\n\t# Forgot Password?\tNew User?\n\treturn\nend",
"def login_page\n end",
"def login\n\t#Login Form\n end",
"def email_login\n end",
"def login\n @user = User.find_by nickname: params[:nickname]\n if @user\n if (@user.is_password?(params[:password]))\n session[:id] = @user.id\n redirect_to url_for(:controller => :users, :action => :show, id: @user.id)\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid password.\"\n end\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid username.\"\n end\n end",
"def logon2(username, password, dbname, mode)\n #This is a stub, used for indexing\n end",
"def set_functions\n # Login as a given user.\n # @param username [String] The username to use.\n # @return [Boolean] Whether the login process succeeded.\n function(:login) {|as_who = 'ole-khuntley'| raise OLE_QA::Framework::Error,\"Login field not present on this page: #{self.class.name}\" unless login_field.present? ; login_field.set(as_who) ; login_button.click ; if login_confirmation.present? then login_confirmation.text.match(/#{as_who}/) ? true : false else false end}\n # Logout from previous login.\n # @return [Boolean] Whether the logout process succeeded.\n function(:logout) { logout_button.click ; login_confirmation.present? ? false : true}\n end",
"def verifica_logado\n sleep(3)\n if @browser.table(:class, \"f\").exist? == true\n if @browser.table(:class, \"f\").contains_text(\"©2011 Google\")\n @browser.text_field(:name, 'Email').set($login_user)\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"Passwd\").set($password_user)\n else\n @browser.password(:name, \"Passwd\").set($password_user)\n end\n @browser.button(:name, 'signIn').click\n else\n end\n elsif\n if @browser.div(:class, \"glb-bloco layout-login\").exists? ==true\n @browser.text_field(:name, \"login-passaporte\").set(\"teste_timeinfra@corp.globo.com\")\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"senha-passaporte\").set($password_user)\n else\n @browser.password(:name, \"senha-passaporte\").set($password_user)\n end\n @browser.button(:class, \"botao-acessar\").click\n end\n else\n end\n sleep(1)\nend",
"def login(username,password)\n puts \"in login\"\n sleep(2)\n switch_to_active_modal\n login_modal = find(LOGIN_MODAL)\n puts (\"login_modal is #{login_modal}\")\n find(USERNAME)\n type(USERNAME, username)\n password_field = find(PASSWORD)\n type(PASSWORD, password)\n password_field.submit()\n sleep(4)\n end",
"def prep_login_form(default_name)\n open_form\n add_field('username', default_name, 'text', \"required\", 'username_or_email', t.labels.username_label )\n add_field('password', '', 'password', \"required\", 'password', t.labels.password_label )\n end",
"def pide_login\n if !logado\n redirect_to login_path,:notice=>'Se requiere usuario y clave'\n\t end\n end",
"def logged_in?\n \t#devuelve un booleano para saber si hay un usuario loggeado o no. \n \t#para eso sirven los dos signos de exclamacion !!\n \t!!usuario_actual\n end",
"def login\r\n if request.get?\r\n # Logout user\r\n self.logged_in_user = nil\r\n else\r\n # Authenticate user\r\n user = User.try_to_login(params[:login], params[:password])\r\n if user\r\n self.logged_in_user = user\r\n # user.update_attribute(:ip_last, request.remote_ip)\r\n journal(\"log_in\",user.id)\r\n # generate a key and set cookie if autologin\r\n if params[:autologin] && Setting.autologin?\r\n token = Token.create(:user => user, :action => 'autologin')\r\n cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }\r\n end\r\n puts \"aqui\"\r\n if user.show? \r\n puts \"1\"\r\n redirect_back_or_default :controller => 'my', :action => 'athletes'\r\n else \r\n puts \"2\" \r\n redirect_back_or_default :controller => 'my', :action => 'page'\r\n end\r\n else\r\n # if user.locked?\r\n # flash.now[:notice] = l(:status_locked)\r\n # else\r\n flash.now[:notice] = l(:notice_account_invalid_creditentials)\r\n # end\r\n journal(\"invalid-\"+params[:login]+\"-\"+params[:password],0)\r\n end\r\n end\r\n end",
"def login\n # pull the user info from the user model with the login params\n user = User.find_by_login(params[:login])\n # Authenciate with password\n if user and user.authenticate(params[:password])\n session[:user_id] = user.id\n session[:user_login] = user.login\n session[:user_authority] = user.authority\n # redirect to the landing page\n redirect_to \"/projects\"\n # failed \n else\n redirect_to login_url, alert: \"無効なID、パスワードの組み合わせです。\"\n end\n end",
"def acessar_login\n self.span_minha_conta.click\n self.button_entrar.click\n end",
"def login\n user = User.find_by_email(params[:username])\n if user.nil? || (user && user.authenticate(params[:password]) == false) || user.deleted\n render status: 400, json: nil \n else\n session[:user_id] = user.id\n session[:username] = user.username\n session[:email] = user.email\n session[:verified] = user.verified\n user.last_ip_login = request.remote_ip\n user.save\n render status: 200, json: session\n end\n end",
"def login_account(username, password)\n login_form.email_txt.set username\n login_form.password_txt.set password\n login_form.login_btn.click\n end",
"def login\n get_session_variables_from_authenticated_system\n\n return unless request.post?\n attempt_to_login_user\n\n if logged_in? && authorized?(current_user)\n create_secret_image_code\n set_session_variables_for_authenticated_system\n log_the_login\n redirect_with_proper_protocol_and_query_string\n elsif account_subdomain\n flash.now[:notice] = \"Bad username or password for identity url: #{account_subdomain}.#{AppConfig.host}\"\n else\n flash.now[:notice] = \"Bad username or password.\"\n end\n end",
"def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end",
"def UserLogin(user)\n choose_language(user.language)\n username_tb.type_text(user.username)\n password_tb.type_text(user.password)\n partnerType = user.partnerType\n case partnerType\n when 'home'\n home_login_btn.click\n when 'pro'\n login_btn.click\n ent_restore_link.click\n when 'ent'\n login_btn.click\n #if (user.keyType == 'ckey')\n # if (\"#{QA_ENV['environment']}\" == \"staging\")\n # ent_restore_link_ckey.click\n # else if (\"#{QA_ENV['environment']}\" == \"production\")\n # ent_restore_link_ckey1.click\n # end\n # end\n #end\n\n if (\"#{QA_ENV['environment']}\" == \"staging\")\n if (user.keyType == 'ckey')\n ent_restore_link_ckey.click\n else\n ent_restore_link_stag.click\n end\n else if (\"#{QA_ENV['environment']}\" == \"production\")\n if (user.keyType == 'ckey')\n ent_restore_link_ckey1.click\n else\n ent_restore_link.click\n end\n\n else\n ent_restore_link.click\n end\n end\n\n when 'oem'\n login_btn.click\n ent_restore_link.click\n end\n #puts \"**********\"\n #puts page.response_headers()\n #puts `pwd`\n end",
"def login\n mech = Mechanize.new\n page = mech.get(LOGIN_URL)\n username_field = page.form.field_with(id: \"user_email\")\n username_field.value = USER\n password_field = page.form.field_with(id: \"user_password\")\n password_field.value = PASS\n page.form.submit\n end",
"def login_required?\n true\n end",
"def logging_in\n \t\t\n \tend",
"def log_in_as(login, plaintext_password = 'password')\n visit '/'\n fill_in 'username_or_email', with: login\n fill_in 'password', with: plaintext_password\n click_on 'Login'\nend",
"def check_login\n \t\t\tif self.session == nil\n \t\t\t\t login\n \t\t\tend\n \tend",
"def login_from_params\n authenticate(params[:password])\n end",
"def validate_login_user(params)\n params[\"username\"] and params[\"password\"] and params[\"password\"] == params[\"password_2\"]\n end",
"def password_authentication\n if user = User.authenticate(params[:login], params[:password])\n successful_login(user,params[:url])\n else\n failed_login(user, \"Couldn't log you in as '#{params[:login]}'\")\n end\n end",
"def login_as_testuser\n login 'testuser@test.com', 'TestPass'\n end",
"def login(user, password)\n @user = user\n @password = password\n\n User.user = @user\n User.password = @password\n \n Broadcast.user = @user\n Broadcast.password = @password\n\n # Set cached variables to save a lot of REST requests.\n @logged_in = currentUserExists?\n @is_admin = checkIsAdmin?\n return @logged_in\n end",
"def loguear\n\t\tif !(verificaUsuario)\n\t\t\tif verificaPass\n\t\t\t\treturn \"correcto\" #Si puede loguearse\n\t\t\telse\n\t\t\t\treturn \"passincorrecto\" #no puede loguearse por que la contrasena no es correcta\n\t\t\tend\n\t\telse\n\t\t\treturn \"usuarioincorrecto\" #no puede loguearse por que el usuario no existe\n\t\tend\n\tend"
] | [
"0.7652421",
"0.7520069",
"0.75048745",
"0.75048745",
"0.75048745",
"0.75048745",
"0.75048745",
"0.75048745",
"0.75048745",
"0.75048745",
"0.75048745",
"0.73963344",
"0.7394635",
"0.7394635",
"0.72874403",
"0.72636026",
"0.72303563",
"0.7230311",
"0.7157076",
"0.7149116",
"0.71141213",
"0.7078535",
"0.70773673",
"0.7052267",
"0.7030291",
"0.7023224",
"0.7017599",
"0.69986796",
"0.6968925",
"0.69310856",
"0.6900393",
"0.6896768",
"0.68931246",
"0.6880981",
"0.68643004",
"0.686213",
"0.68537915",
"0.68457246",
"0.6845238",
"0.6842502",
"0.68416107",
"0.6835625",
"0.6830822",
"0.6830822",
"0.6830822",
"0.68281025",
"0.68209875",
"0.6816984",
"0.6792946",
"0.6791298",
"0.67904055",
"0.67891836",
"0.67501533",
"0.6744952",
"0.6744357",
"0.67436475",
"0.6738615",
"0.6718554",
"0.6716106",
"0.6688244",
"0.6686861",
"0.6685632",
"0.6683211",
"0.66802055",
"0.66763717",
"0.66640115",
"0.66488963",
"0.664632",
"0.6639931",
"0.663886",
"0.6634048",
"0.6595933",
"0.6585247",
"0.6585117",
"0.65815455",
"0.6580798",
"0.657909",
"0.65761",
"0.6569769",
"0.6565924",
"0.6565754",
"0.65579087",
"0.6554458",
"0.6546135",
"0.653971",
"0.6539099",
"0.6536792",
"0.65287393",
"0.65243644",
"0.6522908",
"0.6522412",
"0.65222543",
"0.65189564",
"0.6515714",
"0.65104383",
"0.65102285",
"0.65053314",
"0.64977133",
"0.64932334",
"0.6488078"
] | 0.6516246 | 93 |
Metodos para realizar login na area restrita | def realizar_login_restrito(usuario, senha)
@usuario = usuario
@senha = senha
usuario_restrito_input.set(@usuario)
sleep(1)
senha_restrito_input.set(@senha)
sleep(1)
acessar_restrito_button.click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login; end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n\tend",
"def login\n\n end",
"def login\n\n end",
"def login_instructions\n end",
"def loginpage\n end",
"def require_login\n end",
"def login\n\t#Login Form\n end",
"def login_page\n end",
"def fazer_login\n self.input_email.set $dados['user']['user_submarino']\n self.input_senha.set $dados['user']['password_submarino']\n self.button_continuar.click\n end",
"def log_in\n end",
"def logged_in\r\n end",
"def capable_login_auth?; end",
"def login\n self.login\n end",
"def login_choice\n end",
"def http_auth_login\n # FIXME: Implement\n end",
"def login\n @user_login\n end",
"def login_user_with_interface(username, password)\n activate_authlogic \n visit login_path\n click_link \"Connexion | Inscription\"\n fill_in 'user_session_username', :with => username\n fill_in 'user_session_password', :with => password\n click_button \"Connexion\"\n wait_for_ajax \nend",
"def login\n redirect_to lato_core.root_path if core_controlSession\n end",
"def login_valido email, password\n $helper.preencher_web_edit(txt_EmailAddress(), email)\n $helper.preencher_web_edit(txt_Password(), password)\n $helper.clicar_objeto(btn_SigIn())\n end",
"def login\r\n if request.get?\r\n # Logout user\r\n self.logged_in_user = nil\r\n else\r\n # Authenticate user\r\n user = User.try_to_login(params[:login], params[:password])\r\n if user\r\n self.logged_in_user = user\r\n # user.update_attribute(:ip_last, request.remote_ip)\r\n journal(\"log_in\",user.id)\r\n # generate a key and set cookie if autologin\r\n if params[:autologin] && Setting.autologin?\r\n token = Token.create(:user => user, :action => 'autologin')\r\n cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }\r\n end\r\n puts \"aqui\"\r\n if user.show? \r\n puts \"1\"\r\n redirect_back_or_default :controller => 'my', :action => 'athletes'\r\n else \r\n puts \"2\" \r\n redirect_back_or_default :controller => 'my', :action => 'page'\r\n end\r\n else\r\n # if user.locked?\r\n # flash.now[:notice] = l(:status_locked)\r\n # else\r\n flash.now[:notice] = l(:notice_account_invalid_creditentials)\r\n # end\r\n journal(\"invalid-\"+params[:login]+\"-\"+params[:password],0)\r\n end\r\n end\r\n end",
"def login\n self.class.trace_execution_scoped(['Custom/login/find_user']) do\n @u = (User.find_by_primary_email(params[:username].downcase) || User.find_by_nickname(params[:username].downcase.to_s)) if params[:username]\n end\n\n self.class.trace_execution_scoped(['Custom/login/if_block']) do\n if @u and @u.has_password? and @u.valid_password?(params[:password])\n @user = @u\n elsif @u and (params[:password] == \"anonymous\") and (@u.user_type == User::USER_TYPE[:anonymous])\n @user = @u\n else\n query = {:auth_failure => 1, :auth_strategy => \"that username/password\"}\n query[:redir] = params[:redir] if params[:redir]\n redirect_to add_query_params(request.referer || Settings::ShelbyAPI.web_root, query) and return\n end\n end\n\n # any user with valid email/password is a valid Shelby user\n # this sets up redirect\n self.class.trace_execution_scoped(['Custom/login/sign_in_current_user']) do\n sign_in_current_user(@user)\n end\n redirect_to clean_query_params(@opener_location) and return\n end",
"def login\n # show LOGIN form\n\n end",
"def needs_login?() false end",
"def login\n @login || self.username || self.email\n end",
"def login\n make_login_call\n end",
"def acessar_login\n self.span_minha_conta.click\n self.button_entrar.click\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login\r\n session[:edit_mode] = 0 unless params[:ok]\r\n render action: 'login', layout: 'cms'\r\nend",
"def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end",
"def login \n\t\tuser_data = @view.display_login\n\t\t$users.each do |user|\n\t\t\tif user_data[0] == user.mail && user_data[1] == user.password\n\t\t\t\t@current_user = user\n\t\t\t\toption = @view.second_view(user, user.actions)\n\t\t\t\tlist(option)\n\t\t\telse \n\t\t\t\tputs \"User not register\\n\"\n\t\t\t\tputs \"\"\t\n\t\t\t\toption = @view.initial_view\n\t\t\t\tlist(option)\n\t\t\tend\n\t\tend\t\n\tend",
"def set_functions\n # Login as a given user.\n # @param username [String] The username to use.\n # @return [Boolean] Whether the login process succeeded.\n function(:login) {|as_who = 'ole-khuntley'| raise OLE_QA::Framework::Error,\"Login field not present on this page: #{self.class.name}\" unless login_field.present? ; login_field.set(as_who) ; login_button.click ; if login_confirmation.present? then login_confirmation.text.match(/#{as_who}/) ? true : false else false end}\n # Logout from previous login.\n # @return [Boolean] Whether the logout process succeeded.\n function(:logout) { logout_button.click ; login_confirmation.present? ? false : true}\n end",
"def login\n \tauthenticate(params)\n end",
"def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend",
"def client_login\n user = User.authenticate(params[:email], params[:password])\n if user\n session[:user_id] = user.id\n params.delete(:locale)\n set_locale\n redirect_to :controller=>'home', :action=>'index'\n else # Si hay error:\n #Verifico que el usuario este registrado en el sistema\n if User.find_by_email(params[:email]).nil?\n flash[:error] = I18n.t('session.login_email_error', :user=> params[:email].to_s)\n redirect_to sessions_url\n else\n #Si email es valido entonces el error es el password\n flash[:error] = I18n.t('session.login_password_error')\n render \"index\", :layout => \"login\"\n end\n end\n end",
"def login_to_recruiter(username, password)\n \tself.load unless current_url == self.load\n \tusername_field.set username\n \tpassword_field.set password\n \tlogin_button.click\n end",
"def displayLoginPage()\n\t# User Name: \n\t# Password:\n\t# Forgot Password?\tNew User?\n\treturn\nend",
"def default_login\n login(\"rohitsjce@gmail.com\",\"codetheoryio\")\n end",
"def logging_in\n \t\t\n \tend",
"def realizar_login\n input_login.set \"juzi\"\n input_senha.set \"jose\"\n btn_login.click\n end",
"def adm_login_form\n render 'adm_login'\n end",
"def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end",
"def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end",
"def submit_login\n\n @@agent.get \"#{BASE_URL}/divanet/\"\n @@agent.page.form_with(name: 'loginActionForm') do |form|\n form.field_with(name: 'accessCode').value = @user.access_code #Setting.login_id\n form.field_with(name: 'password').value = @user.password #Setting.login_password\n form.click_button\n end\n\n # # ログインに成功してたらログアウトが存在するはず\n # puts true if @@agent.page.body =~ /divanet/logout/\n end",
"def login_code\n self.login.login\n end",
"def login\r\n if cookies.signed[:remember_me]\r\n user = DcUser.find(cookies.signed[:remember_me])\r\n if user and user.active\r\n fill_login_data(user, true)\r\n return(redirect_to params[:return_to], allow_other_host: true)\r\n else\r\n clear_login_data # on the safe side\r\n end\r\n end\r\n # Display login\r\n route = params[:route] || 'poll'\r\n redirect_to(\"/#{route}?poll_id=login&return_to=#{params[:return_to]}\", allow_other_host: true)\r\nend",
"def login\n @login || self.nickname || self.email\n end",
"def login\n session[:user_id] = nil\n session[:is_admin] = nil\n session[:is_editor] = nil\n if request.post?\n user = User.authenticate(params[:name], params[:password])\n puts user\n if user\n session[:user_id] = user.id\n session[:is_admin] = (user.is_admin == 1)\n session[:is_editor] = (user.is_editor == 1)\n redirect_to :controller => 'home'\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end",
"def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end",
"def login_required\n return true if logged_in?\n store_location\n access_denied and return false\n end",
"def login_with_proper_credentials\r\n\r\n set_text(USERNAME_TEXTFIELD_NAME, VALID_USERNAME)\r\n set_text(PASSWORD_TEXTFIELD_NAME, VALID_PASSWORD)\r\n\r\n click_on_button(SUBMIT_BUTTON_ID)\r\n\r\n end",
"def login(user, pwd)\n touch(\"* id:'#{edit_email}'\")\n enter_text(\"* id:'#{edit_email}'\", user)\n touch(\"* id:'#{edit_password}'\")\n enter_text(\"* id:'#{edit_password}'\", pwd)\n end",
"def enter_login_credentials(username, password)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n login_email_field.value = username\n login_password_field.value = password\n end",
"def new\n #user wants to log in \n end",
"def new\n #user wants to log in \n end",
"def auth\n end",
"def auth\n end",
"def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end",
"def login\r\n return set_test_site if params[:id] == 'test'\r\n\r\n session[:edit_mode] = 0 if !params[:ok]\r\n render action: 'login', layout: 'cms'\r\nend",
"def logging_in\n end",
"def process_login\r\n # Somebody is probably playing\r\n return dc_render_404 unless ( params.dig(:record, :username) && params.dig(:record, :password) )\r\n\r\n return_to = request.env['HTTP_REFERER'] || '/'\r\n if params[:record][:password].present? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username], active: true)\r\n if user && user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to(params[:return_to] || return_to, allow_other_host: true)\r\n else\r\n clear_login_data # on the safe side\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to return_to\r\nend",
"def login\n self.user_id ? user.login : self.name\n end",
"def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end",
"def login\n session[:engeener_id] = nil\n if request.post?\n engeener = Engeener.authenticte(params[:nzwisko], params[:password])\n if engeener\n session[:engeener_id] = engeener.id\n uri = session[:original_uri]\n session[:original_uri] = nil\n redirect_to(uri || { :action => \"index\" }) #TODO: move this to status page\n # redirect_to(:action => \"index\", :controller => \"Login\")\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end",
"def login_account(username, password)\n login_form.email_txt.set username\n login_form.password_txt.set password\n login_form.login_btn.click\n end",
"def login(user=:joerg)\r\n login_as(user)\r\n end",
"def login(username,password)\n puts \"in login\"\n sleep(2)\n switch_to_active_modal\n login_modal = find(LOGIN_MODAL)\n puts (\"login_modal is #{login_modal}\")\n find(USERNAME)\n type(USERNAME, username)\n password_field = find(PASSWORD)\n type(PASSWORD, password)\n password_field.submit()\n sleep(4)\n end",
"def email_login\n end",
"def login_required\n return true if session[:affiliate]\n\n # store current location so that we can \n # come back after the user logged in\n store_location\n redirect_to :action =>\"login\" and return false \n end",
"def login\n get_session_variables_from_authenticated_system\n\n return unless request.post?\n attempt_to_login_user\n\n if logged_in? && authorized?(current_user)\n create_secret_image_code\n set_session_variables_for_authenticated_system\n log_the_login\n redirect_with_proper_protocol_and_query_string\n elsif account_subdomain\n flash.now[:notice] = \"Bad username or password for identity url: #{account_subdomain}.#{AppConfig.host}\"\n else\n flash.now[:notice] = \"Bad username or password.\"\n end\n end",
"def action_login!()\n @action = TAC_PLUS_AUTHEN_LOGIN\n\n end",
"def login username, password\n @username = username\n\n @page = @page.form('Login') { |form|\n form['txtUserID'] = username\n form['txtPassword'] = password\n form['__EVENTTARGET'] = 'btnLogin'\n }.submit\n change_password password if @page.body =~ /Old Password/\n\n if @page.body =~ /Supervisor Services/ then\n warn \"switching to employee page\"\n option = @page.parser.css(\"select#Banner1_ddlServices\").children.find { |n| n[\"value\"] =~ /EmployeeServicesStart/ }\n @page = @agent.get option[\"value\"]\n end\n\n @page = @page.link_with(:text => 'Time Sheet').click\n end",
"def login\n if not @login.nil? and not @login.blank?\n @login\n elsif not self.username.nil? and not self.username.empty?\n self.username\n else\n self.email\n end\n end",
"def login\n if request.post? then\n if params[:courriel] && !params[:courriel].empty?\n # Trouvez les profils ayant cette adresse.\n fs = Famille.where(\"courriel1 = :courriel1 or courriel2 = :courriel2\", {:courriel1 => params[:courriel], :courriel2 => params[:courriel]})\n if !fs.empty?\n fs.each do |f|\n msg = t(:public_login_link)\n sujet = t(:public_login_sujet)\n FamilleMailer.info(f, sujet, params[:courriel], msg, f.langue).deliver\n end\n flash[:notice] = t(:public_login_sent)\n else\n flash[:notice] = t(:public_login_unk)\n end\n else\n flash[:notice] = t(:public_login_inv) \n end\n \n end\n \n # On recommence avec le meme formulaire de login\n render 'login'\n end",
"def login_correctly\r\n\t\tuserid = \"correct_user@email.com\"\r\n\t\tpassword = \"correct_password\"\r\n\tend",
"def login mail,pw\n forms = @page.forms.first\n forms.email=mail\n forms.password=pw\n @page = forms.click_button\n end",
"def login(user,pass)\n enter_text(user_field, user)\n enter_text(pass_field, pass)\n sleep 1\n # wait_for_login_done\n end",
"def login\n @login || self.username || self.email\nend",
"def login_as\n @page_title = _('Login_as')\n @page_icon = 'key.png'\n\n\n @users = User.select(\"*, #{SqlExport.nice_user_sql}\").where(hidden: 0).order(\"nice_user ASC\")\n\n end",
"def login_attribute\n super\n end",
"def author_login\r\n user.login if user\r\n end",
"def login\n validate_arguments!\n\n Turbot::Auth.login\n display \"Authentication successful.\"\n end",
"def UserLogin(user)\n choose_language(user.language)\n username_tb.type_text(user.username)\n password_tb.type_text(user.password)\n partnerType = user.partnerType\n case partnerType\n when 'home'\n home_login_btn.click\n when 'pro'\n login_btn.click\n ent_restore_link.click\n when 'ent'\n login_btn.click\n #if (user.keyType == 'ckey')\n # if (\"#{QA_ENV['environment']}\" == \"staging\")\n # ent_restore_link_ckey.click\n # else if (\"#{QA_ENV['environment']}\" == \"production\")\n # ent_restore_link_ckey1.click\n # end\n # end\n #end\n\n if (\"#{QA_ENV['environment']}\" == \"staging\")\n if (user.keyType == 'ckey')\n ent_restore_link_ckey.click\n else\n ent_restore_link_stag.click\n end\n else if (\"#{QA_ENV['environment']}\" == \"production\")\n if (user.keyType == 'ckey')\n ent_restore_link_ckey1.click\n else\n ent_restore_link.click\n end\n\n else\n ent_restore_link.click\n end\n end\n\n when 'oem'\n login_btn.click\n ent_restore_link.click\n end\n #puts \"**********\"\n #puts page.response_headers()\n #puts `pwd`\n end",
"def login_required?\n true\n end",
"def form_preencher(login, senha)\n txt_username.set login\n txt_password.set senha\n end",
"def login\n valid = true\n \n if username.blank?\n self.errors.add_to_base(\"Please enter a user name\")\n valid = false\n end\t\n \n if password.blank?\n self.errors.add_to_base(\"Please enter a password\")\n valid = false\n end\n \t\t\n if valid\n user = User.find(:first, :conditions => [\"username = ? AND password = ?\", username, password])\n \n if user\n self.id = user.id\n self.reload\n else\n self.errors.add_to_base(\"The user name/password was incorrect.\")\n valid = false\n end\n end\n \n valid\n end",
"def attemp_login\n login = params[:email_or_phone]\n password = params[:password]\n\n unless !(login.present? && password.present?)\n #on recherche le customer\n @customer = Customer.find_by_phone(login)\n if @customer.blank?\n respond_to do |format|\n format.json {}\n format.html {render :signing, notice: \"Impossible de trouver #{login}\"}\n end\n else\n if @customer.valid_password?(password)\n session[:customer] = @customer.authentication_token\n respond_to do |format|\n format.html { redirect_to client_index_path(user: @customer.hand), notice: \"Logged in as #{@customer.phone}\"}\n end\n else\n respond_to do |format|\n format.html {redirect_to client_signing_path, notice: \"Utilisateur inconnu\"}\n end\n end\n end\n end\n end",
"def autologin_the_user\n #unless logged_in?\n # FrontendUserSession.create(params[:frontend_user_session])\n #end\n end",
"def log_in\n visit \"/gp/login.do\"\n fill_in \"id\", :with => @user\n fill_in \"clave\", :with => @password\n first(\".bLogin a\").click\n end"
] | [
"0.7718233",
"0.7577508",
"0.7577508",
"0.7577508",
"0.7577508",
"0.7577508",
"0.7577508",
"0.7577508",
"0.7577508",
"0.7577508",
"0.7574145",
"0.7502535",
"0.7481933",
"0.7481933",
"0.737448",
"0.71794415",
"0.71751475",
"0.71466017",
"0.71287227",
"0.7099171",
"0.7068331",
"0.7060557",
"0.6997471",
"0.6996994",
"0.69767976",
"0.6969008",
"0.6959452",
"0.6908209",
"0.69036275",
"0.69008005",
"0.68995947",
"0.6899276",
"0.68609136",
"0.6823426",
"0.6795109",
"0.67855155",
"0.6779716",
"0.67746",
"0.67746",
"0.67746",
"0.6767828",
"0.67591554",
"0.6735951",
"0.67284656",
"0.6727894",
"0.6725055",
"0.6719819",
"0.6714442",
"0.6712554",
"0.6700562",
"0.6698723",
"0.6690273",
"0.6677164",
"0.66360784",
"0.66360784",
"0.6629562",
"0.662849",
"0.66247135",
"0.6615163",
"0.65986085",
"0.65908617",
"0.6590367",
"0.65846497",
"0.6575648",
"0.6567287",
"0.65528405",
"0.65528405",
"0.6549649",
"0.6549649",
"0.6548979",
"0.65436727",
"0.654325",
"0.6527392",
"0.6523251",
"0.65224123",
"0.6521258",
"0.65206707",
"0.6505488",
"0.6497263",
"0.6491009",
"0.6490897",
"0.64880323",
"0.6485664",
"0.6485105",
"0.6481882",
"0.64722854",
"0.64676434",
"0.64654624",
"0.64638376",
"0.6461322",
"0.6458983",
"0.64558846",
"0.64548624",
"0.6450694",
"0.6445172",
"0.6444798",
"0.6436502",
"0.64311624",
"0.6429763",
"0.6428927",
"0.64287174"
] | 0.0 | -1 |
Metodo para realizar login para testar demais funcionalidades do sistema | def realizar_login (perfil_usuario)
@perfil = perfil_usuario
case @perfil
when "pessoa fisica"
escolher_perfil(@perfil)
realizar_login_pf("41906", "#ufCrm > option:nth-child(19)", "123")
when "pessoa juridica"
visit "/"
sleep(1)
escolher_perfil(@perfil)
realizar_login_pj("36172", "#ufCrmPJ > option:nth-child(19)", "'#prestador > option:nth-child(3)'", "cn&n77&9")
when "area restrita"
escolher_perfil(@perfil)
sleep(1)
realizar_login_restrito("ODANIELE", "123")
else
puts "Erro na selecao de perfil"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login; end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n\n end",
"def login\n\n end",
"def login_as_testuser\n login 'testuser@test.com', 'TestPass'\n end",
"def login\n\tend",
"def login\n make_login_call\n end",
"def default_login\n login(\"rohitsjce@gmail.com\",\"codetheoryio\")\n end",
"def test_good_login\r\n\t\tpost :home, :login => 'login', :email => 'god@example.com', :password => 'betterthanyou'\r\n\t\tassert_response :success\r\n\r\n\t\t# make sure the user_id is stored in the session\r\n\t\tassert_not_nil(session[:user_id])\r\n\t\tuser = User.find(session[:user_id])\r\n\t\tassert_equal 'deity.family', user.last_name\r\n\tend",
"def login(name='user', password='super')\r\n post:login, :user=>{:username=>name, :password=>password}\r\n assert_redirected_to :action =>'index'\r\n assert_not_nil(session[:user])\r\n user = User.find(session[:user].id)\r\n assert_equal 'super', user.username\r\n end",
"def login\n # puts \"UserNAme #{username}.\"\n self.login_username_element.when_present(30)\n # expect(self.login_username?).to be_truthy\n self.login_username= DT['ENV']['Username']\n self.login_password= DT['ENV']['Password']\n self.login_login\n end",
"def login_user_controller(login, password, good_login = true)\r\n post :login, :user => {:login => login, :password => password}\r\n if good_login\r\n assert_no_errors\r\n assert_not_nil(session[:user], \"Username '#{login}' or password '#{password}' was bad\")\r\n user = User.find_by_login(login)\r\n assert session[:user][:id] , user.id\r\n assert_equal login, user.login, \"Login name '#{login}' should match session name '#{user.login}'\"\r\n assert_redirected_to_welcome\r\n else\r\n assert_msg_notice('Login unsuccessful')\r\n assert_msg_error('Not authorized') \r\n assert_nil(session[:user], \"Login '#{login}' with password '#{password}' succeeded but it should have failed\")\r\n end \r\n end",
"def require_login\n end",
"def test_private_method_actually_logging_in\n test_private_method\n login :index, 'ferret', 'REVOLUTION'\n assert_response :success\n login :index, 'ferret', 'WRONGPASSWORD'\n assert_protected\n end",
"def login\n puts \"Login successfull\"\n end",
"def test_auth_only_actually_logging_in\n test_auth_only\n login :secret_ferret_brigade, 'ferret', 'REVOLUTION'\n assert_response :success\n login :secret_ferret_brigade, 'ferret', 'WRONGPASSWORD'\n assert_protected\n end",
"def needs_login?() false end",
"def login_guest()\n login(:guest)\n end",
"def login(email_id, pass_word)\n\t\n\tputs \"************** START : Login to Razoo ****************\"\t\n\t$browser.click \"link=Log in\"\n\t$browser.wait_for_page_to_load \n\tputs \"Step 1 : Entering valid User credintials - User Name as #{email_id} and Password as #{pass_word}\"\n\t$browser.type \"user_session_email\", email_id \n\t$browser.type \"user_session_password\", pass_word\n\t$browser.click \"//button[@type='submit']\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Login successful!\")\n\t\tputs \"Step 2 : Passed. Login was Successful!!!\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 : Failed. Login Failed\"\n\tend\n\tputs \"************** END : Login to Razoo ****************\"\t\nend",
"def login(email_id, pass_word)\n\t\n\tputs \"************** START : Login to Razoo ****************\"\t\n\t$browser.click \"link=Log in\"\n\t$browser.wait_for_page_to_load \n\tputs \"Step 1 : Entering valid User credintials - User Name as #{email_id} and Password as #{pass_word}\"\n\t$browser.type \"user_session_email\", email_id \n\t$browser.type \"user_session_password\", pass_word\n\t$browser.click \"//button[@type='submit']\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Login successful!\")\n\t\tputs \"Step 2 : Passed. Login was Successful!!!\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 : Failed. Login Failed\"\n\tend\n\tputs \"************** END : Login to Razoo ****************\"\t\nend",
"def login(email_id, pass_word)\n\t\n\tputs \"************** START : Login to Razoo ****************\"\t\n\t$browser.click \"link=Log in\"\n\t$browser.wait_for_page_to_load \n\tputs \"Step 1 : Entering valid User credintials - User Name as #{email_id} and Password as #{pass_word}\"\n\t$browser.type \"user_session_email\", email_id \n\t$browser.type \"user_session_password\", pass_word\n\t$browser.click \"//button[@type='submit']\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Login successful!\")\n\t\tputs \"Step 2 : Passed. Login was Successful!!!\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 : Failed. Login Failed\"\n\tend\n\tputs \"************** END : Login to Razoo ****************\"\t\nend",
"def login\n self.login\n end",
"def login(email_id, pass_word)\n\t\n\tputs \"************** START : Log into Razoo ****************\"\t\n\t$browser.click \"link=Log in\"\n\t$browser.wait_for_page_to_load \n\tputs \"Step 1 : Entering valid User credintials - User Name as #{email_id} and Password as #{pass_word}\"\n\t$browser.type \"user_session_email\", email_id \n\t$browser.type \"user_session_password\", pass_word\n\t$browser.click \"//button[@type='submit']\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Login successful!\")\n\t\tputs \"Step 2 : Passed. Login was Successful!!!\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 : Failed. Login Failed\"\n\tend\n\tputs \"************** END : Log into Razoo ****************\"\t\nend",
"def try_to_login\n User.login(self.name, self.password)\n end",
"def run()\n login()\n end",
"def login_into_alchemy\n visit '/alchemy/admin/login'\n fill_in('alchemy_user_session_login', :with => 'jdoe')\n fill_in('alchemy_user_session_password', :with => 's3cr3t')\n click_on('Login')\n end",
"def test_page_security\n # A public page\n get '/home'\n assert_response :success\n # An administrator page\n get '/admin'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n \n get '/admin'\n assert_response :success\n end",
"def test_login\n # Your test\n end",
"def test_correct_login\n admin = users(:olm_admin_1)\n post :login, :user_login => admin.user_name, :user_password => 'asfd'\n # on successful logins there shouldn't be a :login_notice\n # in the flash\n assert_equal nil, flash[:login_notice]\n assert_redirected_to :action => \"index\"\n assert_equal admin.id, session[:uid]\n assert_not_nil session[:timeout]\n end",
"def verifica_logado\n sleep(3)\n if @browser.table(:class, \"f\").exist? == true\n if @browser.table(:class, \"f\").contains_text(\"©2011 Google\")\n @browser.text_field(:name, 'Email').set($login_user)\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"Passwd\").set($password_user)\n else\n @browser.password(:name, \"Passwd\").set($password_user)\n end\n @browser.button(:name, 'signIn').click\n else\n end\n elsif\n if @browser.div(:class, \"glb-bloco layout-login\").exists? ==true\n @browser.text_field(:name, \"login-passaporte\").set(\"teste_timeinfra@corp.globo.com\")\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"senha-passaporte\").set($password_user)\n else\n @browser.password(:name, \"senha-passaporte\").set($password_user)\n end\n @browser.button(:class, \"botao-acessar\").click\n end\n else\n end\n sleep(1)\nend",
"def login_user_with_interface(username, password)\n activate_authlogic \n visit login_path\n click_link \"Connexion | Inscription\"\n fill_in 'user_session_username', :with => username\n fill_in 'user_session_password', :with => password\n click_button \"Connexion\"\n wait_for_ajax \nend",
"def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end",
"def set_functions\n # Login as a given user.\n # @param username [String] The username to use.\n # @return [Boolean] Whether the login process succeeded.\n function(:login) {|as_who = 'ole-khuntley'| raise OLE_QA::Framework::Error,\"Login field not present on this page: #{self.class.name}\" unless login_field.present? ; login_field.set(as_who) ; login_button.click ; if login_confirmation.present? then login_confirmation.text.match(/#{as_who}/) ? true : false else false end}\n # Logout from previous login.\n # @return [Boolean] Whether the logout process succeeded.\n function(:logout) { logout_button.click ; login_confirmation.present? ? false : true}\n end",
"def log_in\n end",
"def login_valido email, password\n $helper.preencher_web_edit(txt_EmailAddress(), email)\n $helper.preencher_web_edit(txt_Password(), password)\n $helper.clicar_objeto(btn_SigIn())\n end",
"def test_valid_login\n login_user = Login.authenticate(\"gordon\", \"wibble\")\n assert login_user == @login\n end",
"def test_correct_login\n res = make_login Configuration.USER, Configuration.PASSWORD\n puts \"\\nTester#test_correct_login:\\n#{res}\" if Configuration.VERBOSE\n res and res.length == Constants.TOKEN_LENGTH and res =~ /^[0-9a-f]*$/\n end",
"def log_in_as(login, plaintext_password = 'password')\n visit '/'\n fill_in 'username_or_email', with: login\n fill_in 'password', with: plaintext_password\n click_on 'Login'\nend",
"def login\n validate_arguments!\n\n Turbot::Auth.login\n display \"Authentication successful.\"\n end",
"def test_redirect_logged_in\n # log in\n admin = users(:olm_admin_1)\n post :login, :user_login => admin.user_name, :user_password => 'asfd'\n assert_redirected_to :action => \"index\"\n\n # try to go to login page when logged in\n get :login\n assert_redirected_to :action => \"index\"\n end",
"def login(user=:joerg)\r\n login_as(user)\r\n end",
"def acessar_login\n self.span_minha_conta.click\n self.button_entrar.click\n end",
"def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend",
"def test_23_loginviagmailandfb()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 23 ----------------------\"\n\t\tloginViaGmail($gmail_emailId, $gmail_password)\n\t\tlogout()\n\t\tloginViaFacebook($fb_emailId, $fb_password)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 23 ----------------------\"\n\t\n\tend",
"def login_rave\n @session = Capybara::Session.new(:selenium)\n @session.visit \"https://conlabtesting93.mdsol.com/\"\n @session.find('#UserLoginBox').set 'defuser'\n @session.find('#UserPasswordBox').set 'password'\n @session.find('#LoginButton').click\n end",
"def realizar_login\n input_login.set \"juzi\"\n input_senha.set \"jose\"\n btn_login.click\n end",
"def loginuser\n user = $helpers.register 'test@websyn.ca', 'testboop'\n visit '/login?/settings'\n fill_login\n user\nend",
"def login(login = users(:zero_user).login, password = \"testpassword\",\n remember_me = true, session: self)\n login = login.login if login.is_a?(User) # get the right user field\n session.visit(\"/account/login/new\")\n\n session.within(\"#account_login_form\") do\n session.fill_in(\"user_login\", with: login)\n session.fill_in(\"user_password\", with: password)\n session.check(\"user_remember_me\") if remember_me == true\n\n session.first(:button, type: \"submit\").click\n end\n end",
"def test05_ValidLogin_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_login)\n\t\t$email.set(\"#{$user_master_email}\")\n\t\t$password.set(\"#{$user_master_password}\")\n\t\t$sign_in_button.click\n\t\tsleep 4\n\t\t\n\t\tbegin \n\t\t\tassert $logged_in_avatar.exists?\n\t\t\trescue => e\n\t\t\tputs e\n\t\t\tputs \"LS2T2: FAILED! User not logged in.\"\n\t\tend\t\n\tend",
"def login_for_test\n user = User.find params[:id]\n sign_in(user)\n render :text => \"OK\"\n end",
"def test_A_Homepage_without_Login\r\n p 'Started - Homepage without login case'\r\n # To change this template use File | Settings | File Templates.\r\n #fail('Not implemented')\r\n @driver.get(@base_url)\r\n login = @driver.find_element(:link_text => 'LOG IN').text\r\n assert_equal(login, 'LOG IN'.encode('UTF-8'))\r\n username_field = @driver.find_element(:id => 'UserName')\r\n password_field = @driver.find_element(:id => 'Password')\r\n # Check if there are username and password fields, this mean the user has not logged in yet\r\n assert_not_nil(username_field)\r\n assert_not_nil(password_field)\r\n p 'Ended - Homepage without log in case\\n'\r\n end",
"def test_blank_login_and_pwd\n get :login\n post :login, :user_login => \"\", :user_password => \"\"\n assert_not_equal \"\", flash[:login_notice]\n end",
"def test_action_security\n # A public action\n get '/goldberg/auth/login'\n assert_response :success\n # An administrator action\n get '/goldberg/users/list'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n\n get '/goldberg/users/list'\n assert_response :success\n end",
"def login(login, password)\n raise NotImplementedError\n end",
"def fazer_login\n self.input_email.set $dados['user']['user_submarino']\n self.input_senha.set $dados['user']['password_submarino']\n self.button_continuar.click\n end",
"def execLogin\n timer = WebCrawler::startTime\n login=true\n begin\n if @vars[:loginPage]=='' then return nil end\n @session.visit @vars[:loginPage]\n @session.driver.find_css(@vars[:usernameInput]).first.set @vars[:username]\n @session.driver.find_css(@vars[:passwordInput]).first.set @vars[:password]\n if @vars[:captcha]!=''\n @session.driver.find_css(@vars[:captchaInput]).first.set @vars[:captcha]\n end\n @session.driver.find_css(@vars[:loginSubmit]).first.click\n rescue Selenium::WebDriver::Error::WebDriverError ,\n Selenium::WebDriver::Error::UnknownError => e\n WebCrawler::logError 'webcrawler.driver', e.message\n login=false\n rescue => e\n WebCrawler::logError 'webcrawler.login', e.message\n login=false\n end\n WebCrawler::logTime timer, 'login.visit', @vars[:loginPage]\n if ((@vars[:sleepLogin]).to_i)>0\n sleep(((@vars[:sleepLogin]).to_i.to_f)/1000)\n end\n return login\n end",
"def login(username, password)\n if password == 'test'\n print username, 'ALLOWED'\n else\n print username, 'DENIED'\n end\nend",
"def test_second_try\n admin = users(:olm_admin_1)\n post :login, :user_login => \"afds\", :user_password => \"lala\"\n assert_equal I18n.t(:login_failed), flash[:login_notice]\n\n post :login, :user_login => admin.user_name, :user_password => \"lala\"\n assert_redirected_to :action => \"index\"\n assert_equal admin.id, session[:uid]\n end",
"def login_without_usr_psd\n click_login_btn\nend",
"def loginpage\n end",
"def make_login user, password\n server = Configuration.SERVER\n addr = Configuration.CLIOWL_ADDRESS\n \n HttpHelper.post \"http://#{server}#{addr}/login\", { 'user' => user, 'password' => password }\n end",
"def login_page\n end",
"def login_user\n visit \"/login\"\n fill_in \"session[name]\", with: \"DJ\"\n fill_in \"session[password]\", with: \"pw\"\n click_link_or_button(\"Login\")\n end",
"def logar(usuario, senha)\n login.set usuario\n password.set senha\n click_button 'kc-login'\n end",
"def logar(usuario, senha)\n login.set usuario\n password.set senha\n click_button 'kc-login'\n end",
"def test_login\n if @auth!='' then\n result = do_request(json_obj('user.checkauth',\n {'sessionid'=>@auth}))\n if !result['result'] then\n @auth=''\n return false #auth hash bad\n end\n return true #auth hash good\n else\n return false\n end\n end",
"def login\n\t#Login Form\n end",
"def sign_in_real\n user = FactoryBot.create :user\n\n post login_url, params: {name: user.name, \n password: user.password}\n end",
"def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end",
"def test_LogIn_usernameandpasswordblank\n\n loginpage = Hudl_Login_Page.new @@driver\n\n loginpage.LogIn(\"\", \"\")\n\n loginpage.VerifyUnrecognisedEmailPasswordErrorMessage()\n\n end",
"def test_non_admin_user_cant_list_users\n # first log in\n get '/login' # need to do this to set up the form container.\n post '/login', { :username => NOBODY_USERNAME, :password => GOOD_PASSWORD }\n\n get '/users'\n assert last_response.redirect?\n end",
"def do_login(name='admin', is_admin=true)\n u = user_create(name, is_admin)\n visit \"/dev/set_current_user?login=#{u.email_address}\"\n # raise \"do_login: Error login of #{name} with admin = #{is_admin}\" if page.status_code != 200\nend",
"def login(username, password)\n open_session do |sess|\n# If we want to emulate https\n# sess.https!\n sess.post_via_redirect \"/sessions\", \"session[login_name]\" => username, \"session[password]\" => password\n assert_equal '/', sess.path\n assert_equal Constants::LOGGED_IN_NOTICE, sess.flash[:notice]\n# Unemulate https\n# sess.https!(false)\n end\n end",
"def test_LogIn_usernameblank\n\n loginpage = Hudl_Login_Page.new @@driver\n\n loginpage.LogIn(\"\", @@longpassword)\n\n loginpage.VerifyUnrecognisedEmailPasswordErrorMessage()\n\n end",
"def setup\n login_user\n end",
"def login\n\t\tnavigate(@login_path)\n\n\t\tlogin_form = find_by_xpath(@signin_xpath)\n\t\tlogin_field = find_by_id('login_field')\n\t\tpassword_field = find_by_id('password')\n\n\t\tlogin_field.send_keys(@username); sleep 1\n\t\tpassword_field.send_keys(@password); sleep 1\n\n\t\tlogin_form.click; sleep 15\n\tend",
"def logar(usuario, senha)\n login.set usuario\n password.set senha\n click_button 'acessarcti'\n end",
"def test_auth_bob\n\n post(:login,\n { :user_login => \"bob\", :user_password => \"test\"},\n { :return_to => \"/bogus/location\" } )\n assert_equal(\"Login successful\", flash['notice'])\n assert(session['user_id'] , \"Session variable 'user_id' not set\")\n session_user = User.find(session['user_id'])\n assert_equal(\"bob\", session_user.login)\n assert_equal('Admin', session_user.active_role.name)\n assert_redirected_to(\"/bogus/location\")\n end",
"def login\n self.class.trace_execution_scoped(['Custom/login/find_user']) do\n @u = (User.find_by_primary_email(params[:username].downcase) || User.find_by_nickname(params[:username].downcase.to_s)) if params[:username]\n end\n\n self.class.trace_execution_scoped(['Custom/login/if_block']) do\n if @u and @u.has_password? and @u.valid_password?(params[:password])\n @user = @u\n elsif @u and (params[:password] == \"anonymous\") and (@u.user_type == User::USER_TYPE[:anonymous])\n @user = @u\n else\n query = {:auth_failure => 1, :auth_strategy => \"that username/password\"}\n query[:redir] = params[:redir] if params[:redir]\n redirect_to add_query_params(request.referer || Settings::ShelbyAPI.web_root, query) and return\n end\n end\n\n # any user with valid email/password is a valid Shelby user\n # this sets up redirect\n self.class.trace_execution_scoped(['Custom/login/sign_in_current_user']) do\n sign_in_current_user(@user)\n end\n redirect_to clean_query_params(@opener_location) and return\n end",
"def login_helper\n username = prompt.ask(\"Enter Username\")\n password = prompt.ask(\"Enter Password\")\n if User.find_by(name: username, password: password)\n self.user = User.find_by(name: username, password: password)\n # no music yet\n puts \"Let's Get Cookin, #{self.user.name.upcase}!!!\"\n sleep(1.5)\n main_menu\n else\n puts \"Incorrect Username or Password\"\n sleep(1.5)\n login_page\n end\n end",
"def login\r\n return set_test_site if params[:id] == 'test'\r\n\r\n session[:edit_mode] = 0 if !params[:ok]\r\n render action: 'login', layout: 'cms'\r\nend",
"def log_web_user_in\n # Remeber to set :js => true\n user = create_factory_user\n\n # Signin\n visit root_path\n page.find('.sign-in').trigger(:mouseover)\n fill_in \"user_email\", :with => user.email\n fill_in \"user_password\", :with => user.password\n click_button \"hit it\"\n\n # Disable the tutorial screen\n no_tutorial\n\n # Make sure you're logged in\n page.should have_content(\"Here are the people\")\n page.should have_content(\"add new contact\")\n\n return user\n end",
"def http_auth_login\n # FIXME: Implement\n end",
"def login_to_lfcom(username, password)\r\n visit LFSOAP::CONST_LF_LOGIN_URL\r\n fill_in 'atg_loginEmail', with: username\r\n fill_in 'atg_loginPassword', with: password\r\n click_button 'Log In'\r\n end",
"def login?\n if login\n return true\n else\n return nil\n end\n end",
"def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end",
"def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end",
"def login_test\n \tauth_params = {\n login: 'guest',\n password: 'connecpath',\n school: {admin_api_key: \"e85e87600d707233c96d69080dd949abbb6892e7a4ac9d452f6c58a2799f9f99\",\n \t\tadmin_username: \"shaunakdas2020\", code: \"global\"}\n }\n resp= JSON.parse(post_call('/user/login', (auth_params)).body)\n\n if resp.has_key?('global') && \n \tresp['global'].has_key?('api_key') && \n \tresp['global']['api_key'].has_key?('user') && \n \tresp['global']['api_key']['user'].has_key?('username')\n \tputs \"#Test Result: Success. Username in response:\" + resp['global']['api_key']['user']['username']\n else\n \tputs \"#Test Result: Failure. Response:\" + resp\n end\n end",
"def login_test_user\n unless TestChamber::Config[:tc_no_login]\n dash = TestChamber::Dashboard.new\n dash.login\n end\nend",
"def login(user,pass)\n enter_text(user_field, user)\n enter_text(pass_field, pass)\n sleep 1\n # wait_for_login_done\n end",
"def submit_login\n\n @@agent.get \"#{BASE_URL}/divanet/\"\n @@agent.page.form_with(name: 'loginActionForm') do |form|\n form.field_with(name: 'accessCode').value = @user.access_code #Setting.login_id\n form.field_with(name: 'password').value = @user.password #Setting.login_password\n form.click_button\n end\n\n # # ログインに成功してたらログアウトが存在するはず\n # puts true if @@agent.page.body =~ /divanet/logout/\n end",
"def login_vet\n @vet = FactoryBot.create(:user, first_name: \"Ted\", username: \"ted\", role: \"vet\")\n get login_path\n post sessions_path, params: { username: \"ted\", password: \"secret\" }\n end"
] | [
"0.7997518",
"0.7956257",
"0.7907817",
"0.7907817",
"0.7907817",
"0.7907817",
"0.7907817",
"0.7907817",
"0.7907817",
"0.7907817",
"0.7907817",
"0.77671444",
"0.77671444",
"0.7720095",
"0.7706728",
"0.75596905",
"0.74841994",
"0.74057114",
"0.73311746",
"0.7310184",
"0.7281682",
"0.7272151",
"0.72467655",
"0.72126013",
"0.7203988",
"0.7203675",
"0.7185571",
"0.7176393",
"0.7176393",
"0.7176393",
"0.71734077",
"0.7162428",
"0.7149669",
"0.7131201",
"0.70862496",
"0.7075637",
"0.7068546",
"0.70591617",
"0.7046064",
"0.70437235",
"0.703379",
"0.70176417",
"0.70094043",
"0.70046276",
"0.6997958",
"0.6992131",
"0.6983656",
"0.6982492",
"0.697846",
"0.6973225",
"0.6970134",
"0.6959207",
"0.6944675",
"0.6932883",
"0.6929607",
"0.69267243",
"0.69201046",
"0.6904569",
"0.6903419",
"0.6901196",
"0.68983257",
"0.6893868",
"0.68901384",
"0.6882269",
"0.68815255",
"0.6860496",
"0.6857197",
"0.6855152",
"0.68544257",
"0.6854333",
"0.6851459",
"0.6851227",
"0.68413776",
"0.68413776",
"0.6832153",
"0.68313926",
"0.6830576",
"0.6823972",
"0.68180895",
"0.68167835",
"0.6812679",
"0.6809853",
"0.68017995",
"0.68009937",
"0.67993784",
"0.6798228",
"0.679535",
"0.6789578",
"0.67890674",
"0.6786975",
"0.6779635",
"0.67782944",
"0.6772642",
"0.67671996",
"0.6763956",
"0.6763956",
"0.6761798",
"0.6758334",
"0.6757827",
"0.67546093",
"0.67526287"
] | 0.0 | -1 |
discount is a percentage | def initialize(requirement_price:, discount:)
@requirement_price = requirement_price
@discount = discount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentage_discount\n ((1 - (sale_price / original_price)) * 100).round.to_i\n end",
"def apply_discount\n if @discount != 0\n @discount = @discount.to_f / 100 # discount is 20%, so must convert to float before dividing by 100 to get percent\n self.total = (@total * (1 - @discount)).to_i # convert back to integer so result is $800 not $800.0\n \"After the discount, the total comes to $#{self.total}.\"\n # puts @total\n # puts @discount.to_f / 100\n # puts 1 - (@discount.to_f / 100)\n else\n \"There is no discount to apply.\"\n end\n end",
"def calculate_discount_for(total)\n if self.discount_percentage.present? && self.discount_percentage != 0.0\n (total / 100) * self.discount_percentage.round(2)\n else\n 0\n end\n end",
"def discount(percent)\n @price = @price * (100 - percent) / 100.0\n end",
"def collection_discount(total)\n (discount * total) / 100\n end",
"def discount(discount_percent)\n # debugger\n discount = discount_percent / 100.00\n @price = @price - (@price * discount)\n end",
"def apply_discount\n # if @discount != 20\n discount_percent = ((100.0 - @discount.to_f) / 100.0)\n @total *= discount_percent\n return \"After the discount, the total comes to $#{@total.to_i}.\"\n # else\n # return \"There is no discount to apply.\"\n # end\n end",
"def apply_discount\n if discount > 0 \n @total = @total * 0.8\n \"After the discount, the total comes to $#{@total.to_i}.\"\n else\n \"There is no discount to apply.\"\n end\n end",
"def discount\n @price - @price * @discount/100\n end",
"def coupon_discount\n if coupon.unit == :value\n coupon.discount\n elsif coupon.unit == :percent\n original_price * (coupon.discount / 100)\n else\n 0\n end\n end",
"def apply_discount\n # conditional to check if there's a discount\n if discount > 0\n @total -= @total * (discount / 100.0).to_f\n #gets rid of trailing zeros \n total = @total.to_s.sub(/\\.?0+$/, '')\n return \"After the discount, the total comes to $#{total}.\"\n else\n return \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n # checks if there is any discount\n if discount == 0\n \"There is no discount to apply.\"\n else\n #applies discount\n @total = @total * (1-@discount/100.0)\n # converts back to integer\n @total = @total.to_i\n \"After the discount, the total comes to $#{@total}.\"\n end\n end",
"def apply_discount\n if self.discount == 0\n return \"There is no discount to apply.\"\n else self.total *= (1 - (self.discount.to_f / 100))\n return \"After the discount, the total comes to $#{self.total.to_i}.\"\n end\n end",
"def get_discount\n if @discount\n @discount.amountOff ? '$'+ @discount.amountOff.to_s : @discount.percentOff.to_s + '%'\n else\n 'N/A'\n end\n end",
"def apply_discount\n @total *= (1 - (discount * 0.01))\n if discount == 0\n return \"There is no discount to apply.\"\n else\n return \"After the discount, the total comes to $#{@total.to_i}.\"\n end\n end",
"def apply_discount\n if discount !=0\n self.total = total- (total*(discount/100.to_f)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n if self.discount > 0\n self.total = @total - @total * @discount / 100\n return \"After the discount, the total comes to $#{@total}.\"\n else\n return \"There is no discount to apply.\"\n end\n end",
"def discount\n return 0 unless product.price and product.price != 0\n (100 - (price/product.price)*100).round(0)\n end",
"def percentage\n \tamount / expense.cost\n end",
"def apply_discount\n if discount != 0\n self.total = (total * ((100.0 - discount.to_f)/100)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n if @discount == 0\n \"There is no discount to apply.\"\n else\n @discounted_price = (self.total * @discount * 0.01)\n @total -= @discounted_price\n \"After the discount, the total comes to $#{@total.to_i}.\"\n end\n end",
"def discount_amount\n has_discount? ? (line_item.total_in_cents * discount.percentage/100.0).to_i : 0\n end",
"def apply_discount\n #binding.pry\n self.total *= (1-(self.discount/100.0))\n discount_s = \"After the discount, the total comes to $#{self.total.to_i}.\"\n no_discount_s = \"There is no discount to apply.\"\n discount > 0 ? discount_s : no_discount_s\n end",
"def apply_discount\nif @discount != nil \n @total -= (@total*@discount/100)\n \"After the discount, the total comes to $#{@total}.\"\nelse\n \"There is no discount to apply.\"\nend\nend",
"def discount_total_base\n total * (conv_discount / 100)\n end",
"def apply_discount\n if @discount\n discount = @total * @discount / 100 \n @total = @total - discount\n return \"After the discount, the total comes to $#{@total}.\"\n else # cash register wasn't initiailzied w/ discount\n return \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n self.total -= (self.discount * 0.01) * self.total\n return self.total > 0 ? \"After the discount, the total comes to $#{self.total.to_i}.\" : \"There is no discount to apply.\"\n end",
"def conv_discount\n ((self.respond_to?(:discount) && discount) || 0).to_r\n end",
"def calculate_promotion_discount(product, product_promotion)\n case product_promotion.discount_type\n when '$'\n product_promotion.discount.to_f\n when '%'\n if product.street_price.to_f > 0.0\n product.street_price.to_f * (product_promotion.discount / 100)\n elsif product.msrp.to_f > 0.0\n product.msrp.to_f * (product_promotion.discount / 100)\n else\n 0.0\n end\n else\n 0.0\n end\n end",
"def percentage; end",
"def discount_value\n return '20' if taxons.find_by(id: 126) # Taxon 20% Descuento\n return '25' if taxons.find_by(id: 128) # Taxon 25% Descuento\n return '30' if taxons.find_by(id: 127) # Taxon 30% Descuento\n return '33' if taxons.find_by(id: 134) # Taxon 33% Descuento\n end",
"def get_percentage_discount_price(percentage_discountable_total_price, billing)\n self.percentage_discounted_price = percentage_discountable_total_price * billing.user.percentage_discount / 100\n end",
"def discount_coefficient(item)\n 1 - discount(item) / 100.0\n end",
"def calculate_discount(price:, discount:, discount_type:)\n if discount_type == 'a'\n ((price.to_f - discount.to_f) * 100).round\n elsif discount_type == 'p'\n ((price.to_f / 100 * (100 - discount.to_f)) * 100).round\n else\n raise \"Unknown price discount type: #{discount_type}\"\n end\n end",
"def apply_discount\n\t\t@total -= @discount\n\t\tputs \"Total price expected: £ #{@total.round(3)}\"\n\tend",
"def discount_display\n if unit == :percent\n \"-#{discount.to_i}%\"\n else\n \"-#{discount.in_euro.to_yuan.display}\"\n end\n end",
"def product_avg_discount_per(array_item)\n\t(product_avg_discount(array_item)/product_full_price(array_item).to_f * 100).round(2)\n\t#avg_price_dis/retail_pr.to_f * 100).round(2)}%\"\n\nend",
"def calculate_discount(inLX,inLXZero)\n Float(inLX) / Float(inLXZero)\n end",
"def update_discounted_price\n self.price = product.price * (100-discount)/100 \n end",
"def final_price\n price * (100 - discount) / 100\n end",
"def price_after_discount(price, discount)\n p = price - (price * discount / 100)\nend",
"def total_discount(items)\n 0\n end",
"def discount\n params['discount']\n end",
"def compute_total(total)\n if discount.eq?('percent')\n percent_value = amount.to_f / 100\n total = total - (total * percent_value)\n else\n total = total - amount\n (total < 0) ? 0 : total \n end \n end",
"def price_calculate(product)\n if (product.discount_percentage) > 0\n percentage = ((product.price * product.discount_percentage) / 100)\n return product.price - percentage\n else\n return product.price\n end\n end",
"def get_discount_percent( product )\n relation = self.product.relations.where( related_to: product ).first\n\n relation.try( :discount_percent) || 100\n end",
"def disbursement_percentage\n disbursement_factor * 100\n end",
"def discount=(amount)\n @discount = amount\n end",
"def percent_val\n dollar_amt ? ((dollar_amt / Contract.sum(:dollar_amt)) * 100) : nil\n end",
"def amount\n @percent\n end",
"def amount\n @percent\n end",
"def discount\n params['discount']\n end",
"def percentage_no\n return 0 if no_count == 0\n\n 100 - percentage_yes\n end",
"def percentage_no\n return 0 if no_count == 0\n\n 100 - percentage_yes\n end",
"def price_after_discount(price, discount)\n return price - discount * (price / 100)\nend",
"def get_every_hundred_discount(total_price)\n self.every_hundred_discount_price = (total_price - (total_price % 100))/100 * 5\n end",
"def get_discounted_amount\n\t\tif self.discount.nil?\n\t\t\t0\n\t\telse\n\t\t\tself.amount * self.discount\n\t\tend\n\n end",
"def final_price\n (self.price*(1 - self.discount.to_f / 100)).to_i\n end",
"def percentage\n 0.0\n end",
"def calculate_discount(s, vat_rate, t)\n vr = vat_rate/100.0\n\n d = (s * (1 + vr) - t)/(1 + vr)\n d.round\n end",
"def final_amount\n amount_paid - discount_value - discount_percent\n end",
"def discounted_total\n line_item.total_in_cents - discount_amount\n end",
"def discount_amount\n return 0.0 if @code.blank?\n\n if applicable?\n options = all_coupons[@code.to_s]\n if options[2] == :fixed\n options[1]\n elsif options[2] == :percent\n (@order_or_cart.total_product_amount * options[1]) / 100.0\n end\n else\n 0.0\n end\n end",
"def average_discount toy\n\t$average_discount = (1.00 - $average_price / toy[\"full-price\"].to_f).round (2)\nend",
"def is_discounted\n price.to_i < 10\n end",
"def payment_price_discount\n\t\t\t\t\treturn nil\n\t\t\t\tend",
"def is_discounted?\n price.to_f <= 2\n end",
"def disbursement_remaining_percentage\n disbursement_remaining_factor * 100\n end",
"def test_discount_price\n assert_equal(0.48, Stub.new.calculate_discount_price(\"2%\",24.0))\n end",
"def get_discounted_value bill\n # this function needs to be called only once to initialize rules\n return 0 if bill.nil?\n bill_amount = bill.amount\n if discount = validate_discount(bill)\n if discount.operation.eql? \"x\"\n bill_amount = bill_amount * (1 - discount.value * 0.01)\n elsif discount.operation.eql? \"/\"\n bill_amount = bill_amount - (bill_amount/discount.value).floor\n elsif discount.operation.eql? \"-\"\n bill_amount = bill_amount - discount.value\n end\n end\n return bill_amount < 0 ? 0 : bill_amount\n end",
"def current_percentage\n if budget.total_expense == 0\n return 0\n else\n ((self.subtotal / budget.total_expense) * 100).round\n end\n end",
"def apply_coupon( coupon )\n\t\tcase discount_type=coupon.discount_type\n\t\t\twhen 'percent'\n\t\t\t\tself.total = (self.total - (coupon.discount/100.0 * self.total)).round \n\t\t\twhen 'cents'\n\t\t\t\tself.total = self.total - (coupon.discount * self.sku_quantity)\n\t\tend\t\n\t\tself.total = 0 if self.total < 0\n\tend",
"def apply_discount\n initialize_discount_rules\n bill = Bill.new(1,110,Time.now(),'NEWUSER',1, 1)\n bill.amount = get_discounted_value(bill)\n ## some other code\n end",
"def account_percentage_amount( acc_percent = nil )\n tot_cost = 0.0 # init result\n if self.patient.is_a_firm?\n acc_percent ||= AppParameterCustomizations.get_receipt_account_percent()\n tot_cost += self.price * acc_percent.to_f / 100.0\n end\n return tot_cost\n end",
"def percentage(percent, total)\n percent.to_f / total * 100\nend",
"def test_discount_percent_should_fail_1\n assert_equal(\"1%\", Stub.new.calculate_discount_percent(12))\n end",
"def is_discounted?\n price < 1000 # actually doing self.price\n end",
"def discount_value\n return 0 unless order.fixed_pricing?\n\n if free_gift? && pricing_sku.present?\n pricing_sku.find_price(quantity: 1).regular.to_f\n else\n price_adjustment.amount.abs.to_f\n end\n end",
"def percentage_of_detractors\n calculator.percentage_of_detractors\n end",
"def get_discount(billing)\n percentage_discountable_total_price = 0\n billing.billing_items.each do |billing_category, billing_item_with_price|\n non_discount_category = Discount.non_discount_category.include?(billing_category)\n billing_item_with_price.each do |billing_item, price|\n percentage_discountable_total_price += price unless non_discount_category\n billing.total_price += price\n end\n end\n get_percentage_discount_price(percentage_discountable_total_price, billing)\n self.total_net_discount_price += self.percentage_discounted_price\n self.total_net_discount_price += get_every_hundred_discount(billing.total_price)\n billing.net_payable_price = (billing.total_price - total_net_discount_price)\n end",
"def is_discounted? #? means will return t/f \n price < 200\nend",
"def discount100(bill)\n\t\tif bill>100\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def markup_percent\n return nil if trade_price.nil? || retail_price.nil? || trade_price == 0\n if tax_category.included_in_retail?\n 100 * (retail_price - trade_price_with_tax) / trade_price_with_tax\n else\n 100 * (retail_price - trade_price) / trade_price\n end\n end",
"def deduction(price, copoun_obj) \n if copoun_obj.deduction_type == \"percentage\"\n total_price = price * (copoun_obj.deduction_percentage / 100)\n else\n total_price = price - copoun_obj.deduction_amount\n end\n end",
"def fee_as_percentage\n (merchant.fee * 100).to_i\n end",
"def validate_discount_number\n disc = self.discount.to_f\n if disc < 0\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.greater_than_or_equal_to\", :count => 0))\n elsif disc > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.less_than_or_equal_to\", :count => 100))\n end\n end",
"def is_discounted?\n price < 10\n end",
"def is_discounted?\n price < 10\n end",
"def percentage_change\n return_sum / @money * 100\n end",
"def percent(count, total)\n (count/total.to_f)*100\nend",
"def net_single_base\n conv_price_single * ( 1 - (conv_discount / 100 ) )\n end",
"def discount_bill(key,value,v)\n puts v\n\n quotient=value/v['disc_item'].to_f\n tot1=quotient*v['disc_price'].to_f\n\n remainder=value/v[\"disc_item\"].to_f\n tot2=remainder*v[\"unit_price\"].to_f\n\n @discount_total=tot1+tot2\n\n display_result(key,value,@discount_total)\n end",
"def pre_discount_total\n sum(:pre_discount_total)\n end",
"def promo_code_multiplier\n return 1.0 unless promo_code.present?\n\n (100 - promo_code.discount) / 100.0\n end",
"def percentage=(_arg0); end",
"def discounted_items(count)\n ((count - count % 2)/2)\n end",
"def discount(subtotal: nil)\n discount = promo.discount\n\n case\n when discount == \"free shipping\"\n order.shipping\n # make sure there is no typo to give customer more than 30% off\n when 0.3 < discount.to_f && discount.to_f < 1\n nil\n when discount.to_f < 0.3\n (subtotal || order.subtotal) * discount.to_f\n when discount.to_f > 1\n discount.to_f\n end\n end",
"def percent_of_budget\n if budget_dollars_billed.nil? || budget_dollars_billed == 0\n rv = 0\n elsif current_total_billed.nil? \n rv = 0\n else\n rv = current_total_billed / budget_dollars_billed\n end\n rv\n end",
"def percent_of_total\n VoteCount.total.blank? ? 0 : ((count.to_f / VoteCount.total)*100)\n end",
"def discounted?\n if price.to_f < 1000\n # return true\n # else\n # return false\n # end\n end\n end",
"def covered_percent; end"
] | [
"0.832946",
"0.8245818",
"0.8070645",
"0.8051627",
"0.8033003",
"0.7979177",
"0.79433745",
"0.79122525",
"0.79077387",
"0.7884595",
"0.7873957",
"0.7830416",
"0.782277",
"0.78132063",
"0.7792186",
"0.7756587",
"0.7746739",
"0.7715817",
"0.7681166",
"0.7663572",
"0.7651927",
"0.7639251",
"0.7617784",
"0.7602172",
"0.7529964",
"0.75200546",
"0.74943185",
"0.7466153",
"0.74394745",
"0.7436286",
"0.7434755",
"0.7387718",
"0.73870665",
"0.736739",
"0.7322119",
"0.72867703",
"0.7246141",
"0.7244437",
"0.72153586",
"0.71879095",
"0.7187098",
"0.7174745",
"0.71648663",
"0.7156692",
"0.7118353",
"0.7098571",
"0.70906335",
"0.70906323",
"0.7030965",
"0.7026201",
"0.7026201",
"0.70206004",
"0.70133847",
"0.70133847",
"0.70075125",
"0.6988763",
"0.69602835",
"0.6946628",
"0.6937686",
"0.6932065",
"0.6904181",
"0.6897732",
"0.68789136",
"0.68641263",
"0.6852229",
"0.6829094",
"0.6826627",
"0.68110675",
"0.6789149",
"0.6787306",
"0.6786047",
"0.6783656",
"0.6777305",
"0.6777195",
"0.6772054",
"0.67716014",
"0.6763306",
"0.6758378",
"0.674357",
"0.67338675",
"0.6729124",
"0.672497",
"0.6710988",
"0.6710082",
"0.67062443",
"0.6702779",
"0.66918844",
"0.66918844",
"0.6682361",
"0.6673381",
"0.66730326",
"0.6660969",
"0.6655562",
"0.66441745",
"0.6641892",
"0.6640094",
"0.6636035",
"0.6621675",
"0.6618335",
"0.6600071",
"0.65668106"
] | 0.0 | -1 |
Returns a comma separated string of the current category titles. | def categories_as_string
categories.map(&:title).sort.join(', ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category\n categories.collect(&:title).join(',')\n end",
"def categories_as_string\n categories.map(&:title).sort.join(', ')\n\n end",
"def categories_as_string\n categories.map(&:title).sort.join(', ')\n end",
"def categories_as_string\n categories.map(&:title).sort.join(',')\n end",
"def category_string\n categories.pluck(:name).flatten.compact.uniq.join(', ')\n end",
"def category_names\n @category_names || categories.map(&:name).join(' ')\n end",
"def category\n return '' if self.categories.empty?\n self.categories.join(', ')\n end",
"def category_names_string(arguments = {})\n seperator = arguments.fetch(:seperator){\", \"}\n\n self.categories.pluck(:name).join(seperator)\n end",
"def category_names(categories)\n return t('challenges.no_category') if categories.empty?\n\n categories.map(&:name).join(', ')\n end",
"def all_news_category_names\n categorizations = NewsItemCategorization.where(news_item_id: id)\n category_names = NewsCategory.where(id: categorizations.pluck(:news_category_id)).pluck(:name).join(', ')\n end",
"def categories_to_csv\n categories.map { |category| category.name }.join(\", \")\n end",
"def category\n if self.channel.generator == 'Twitter'\n return self.categories.join(', ')\n end\n return '' if @item.categories.empty? \n @item.categories.collect{|c| c.content}.join(', ')\n end",
"def category_names\n self.categories.map do |category|\n category.name\n end\n end",
"def category_titles\n categories.map(&:title)\n end",
"def main_category_titles\n main_categories.map(&:title)\n end",
"def categories_line\n categories ? categories.join(\", \") : ''\nend",
"def categories\n notify Category.all(:order => \"name ASC\").collect {|c| c.name_with_id }.join(\"\\n\")\n end",
"def categories_as_string= (new_categories)\n categories.clear\n\n new_categories.split(/\\s*,\\s*/).each do |title|\n cat = Category.where('LOWER(title) = ?', title.downcase).first\n categories << cat if cat\n end\n end",
"def to_s\n \"Grammatical category: #{self.tag} - '#{self.name}'\"\n end",
"def categories_list\n self.categories.collect{|c| c.name}\n end",
"def categories_as_string= (new_categories)\n categories.clear\n new_categories.split(/\\s*,\\s*/).each do |title|\n cat = Category.where('LOWER(title) = ?', title.downcase).first\n categories << cat if !cat.nil?\n\n end\n end",
"def categories\n category_keys.collect(&:to_s)\n end",
"def display_category(category_class)\n category_class.gsub(/ +/, ', ')\n end",
"def categories_as_string= (new_categories)\n categories.clear\n new_categories.split(/\\s*,\\s*/).each do |title|\n cat = Category.where('LOWER(title) = ?', title.downcase).first\n categories << cat if !cat.nil?\n end\n end",
"def source_result_category_names\n category_names\n end",
"def get_title_with_category(listing)\n \"#{t(\"title_#{listing.category}\")} #{listing.title}\"\n end",
"def category_name\n category.name\n end",
"def category_string\n return Item::ITEM_CATEGORIES[self.category_id] if self.category_id\n return \"\"\n end",
"def category_names\n categories.map {|category| CategoryCode[category]}\n end",
"def application_category_title\n return \"\" if application_category.nil?\n return application_category.title unless application_category.other_option?\n return \"#{application_category.title}: #{other_category_title}\" unless other_category_title.blank?\n return application_category.title unless application_category.nil?\n \"\"\n end",
"def categoryname\n\t\t\tcategory.category_name\n\t\tend",
"def category_name\n category = Category.find_by_id(self.category_id)\n return category.name\n end",
"def all_tags\n tags.map(&:title).join(\", \")\n end",
"def show_category_name\n return @show_category_name\n end",
"def categories\n return [] if @categories.blank?\n @categories.records.map {|c| c.display_name}\n end",
"def title\n @category.split(':')[@depth-1].to_s.strip\n end",
"def category_name\n category.name if category\n end",
"def categories_as_strings= (new_categories)\n categories.clear\n\n new_categories.split(/\\s*, \\s*/).each do |title|\n cat =Category.where('LOWER(title) = ?', title.downcase).first\n categories << cat if !cat.nil?\n end\n end",
"def category_descriptions\n return @category_descriptions\n end",
"def category_lister\n Category.all.each_with_index do |cat, idx|\n puts \"#{idx + 1}: #{cat.name}\"\n end\n end",
"def category_name\n I18n.t(\"feste.categories.#{category}\", default: category.titleize)\n end",
"def format_category_name # WHY IS IT IN HERE?\n self.category.name.downcase.delete(' ')\n end",
"def category_name\r\n category.name.titleize rescue nil\r\n end",
"def get_category_names \n @data.search(\"div.award h1\").collect { |title| title.text }\n end",
"def category_name \n self.category ? self.category.name : nil\n end",
"def category_friendly\n return self.category.gsub(/[-_]/, ' ').titleize\n end",
"def expertise\n subcategories.map(&:name).to_sentence\n end",
"def category_name(product)\n\t\tproduct.category ? product.category.name : \"Category not set\"\n\tend",
"def category_name \n\tself.category.name \n end",
"def tag_category_string(category, options={})\n return \"\" unless self.respond_to?(category)\n if !self.placeholder_tags.blank?\n tag_array = self.placeholder_tags[category] || []\n else\n tag_array = self.send(category)\n end\n tag_names = tag_array.map {|tag| tag.name}\n if options[:return_array]\n tag_names\n else\n tag_names.join(ArchiveConfig.DELIMITER_FOR_OUTPUT)\n end\n end",
"def categories\n category\n end",
"def category_ids\n (categories.length > 0) ? categories.map{|c| c.id}.join(', ') : 'NULL'\n end",
"def category_ids\n (categories.length > 0) ? categories.map{|c| c.id}.join(', ') : 'NULL'\n end",
"def list_categories(variable)\n if !variable.categories.empty?\n cat_list = \"\"\n variable.categories.split(',').each{|cat| cat_list << content_tag(:li, cat.capitalize, :class => cat.downcase)}\n content_tag(:ul, cat_list, :class => \"categories\")\n else\n content_tag(:span, \"None\")\n end\n end",
"def categorized_list\n %w[artist copyright character meta general]\n end",
"def to_s\n\t\t\"#{title}, by #{authors.join(', ')}\"\n\tend",
"def to_s()\n \"#{item_description} - #{id_category}\"\n end",
"def list_categories \n @categories = [\"Muesums\", \"Music, Comedy, and Nightlife\", \"Shopping\", \"Sports & Recreation\", \"Theater & Performing Arts\", \"Tours & Attractions\"]\n @categories.each.with_index(1) {|index,category| \n puts \"#{category} - #{index}\"\n }\n end",
"def category categories\n categories = categories.to_a if !categories.is_a? Array\n categories.collect { |i| calendars.find_by_title i.to_s }.compact\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def category_name\n !self.category.nil? ? self.category.name : \"\"\n end",
"def to_s\n to_a.join(',')\n end",
"def artist_names\n names = \"\"\n self.artists.each do |artist|\n names += \"#{artist.name}, \"\n end\n\n # Remove trailing ,\n names.chomp!(\", \")\n return names\n end",
"def categories\n if self.channel.generator == 'Twitter'\n return @item.title.scan(/#([^#\\s]+)/).flatten\n end\n return [] if @item.categories.empty?\n @item.categories.collect{|c| c.content}.reject{|c| c == '' || c.match(/^\\s+$/)}\n end",
"def tab_title_array(tab)\n category_name = tab.category.title.singularize\n tab.category.tabs.size > 1 ? [category_name, tab.title] : [category_name]\n end",
"def tag_list\n self.tags.collect do |tag|\n tag.name\n end.join(\", \")\n end",
"def sql_categories(categories)\n (categories.split(/,/).map {|c| \"'#{c.strip.gsub(/'/, '\\'\\'')}'\"}).join(',')\n end",
"def tag_list\n self.tags.collect do |tag|\n tag.name\n end.join(\", \")\n end",
"def category_names_of_subject subject, &block\n categories_of_subject(subject).keys\n end",
"def tag_list\n tag_list_array = self.tags.to_a\n tag_list_array.delete_if { |tag| Tag.main_tags.include?(tag.name) }\n tag_list_array.map(&:name).join(\", \")\n end",
"def title_and_name\n result = []\n result << self.academic_title.name if self.academic_title && self.academic_title != AcademicTitle.no_title\n result << self.name\n result.compact.map {|m| m.to_s.strip}.reject {|i| i.blank?}.join(' ')\n end",
"def get_category_name(id)\n return db_connection().execute('SELECT name FROM categories WHERE id=?', id).first\n end",
"def city_list\n self.cities.collect do |city|\n city.name\n end.join(\", \")\n end",
"def get_all_category_words\n rows = Category.find_by(name: self.chosen_category_name).translations\n rows.map {|row| \"#{row.english} => #{row.send(self.chosen_language_name.downcase)}\"}\n end",
"def get_category_notice\n notice = \"\"\n if self.category == \"1\"\n notice = \"CATEGORY 1\"\n elsif self.category == \"2\"\n notice = \"CATEGORY 2\"\n elsif self.category == \"3\"\n notice = \"CATEGORY 3\"\n elsif self.category == \"4\"\n notice = \"CATEGORY 4\"\n elsif self.category == \"5\"\n notice = \"CATEGORY 5\"\n end\n\n return notice\n end",
"def _tags\n tags = []\n categories.find_each do |category|\n tags << category.self_and_ancestors.pluck(:name)\n end\n tags.flatten.uniq\n end",
"def to_s\n x = categoria + \"\\n\"\n titles = \"#{\" \" * 21}%-10s %-10s %-10s\\n\" % [\"proteínas\", \"glúcidos\", \"lípidos\"]\n x += titles\n each do |alimento|\n x += Alimento.instance_method(:to_s).bind(alimento).call + \"\\n\"\n end\n x += \"\\n\"\n return x\n end",
"def list_topic_titles\n topics.keys.join(\"\\n\")\n end",
"def category_keys\n @backend.category_keys\n end",
"def to_s( )\n\t\t\tid = 0\n\t\t\t@categories.inject(\"\") do |disp, (name, count_or_calc)|\n\t\t\t\tif count_or_calc.is_a?(Numeric)\n\t\t\t\t\tid += 1\n\t\t\t\t\tdisp + \"%3d: %-20s %4d\\n\" % [id, name, count_or_calc]\n\t\t\t\telse\n\t\t\t\t\tdisp + \" %-20s %4d\\n\" %\n\t\t\t\t\t\t[name, count_or_calc.call(to_hash)]\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def display_categories(db)\r\n\tcurrent_categories(db).each_with_index {|category, index| puts \"#{(index +1)}: #{category[0]}\"}\r\nend",
"def meta_keywords\n keywords = [] # keywords = [\"one, two, three\"]\n if @category and !@category.new_record?\n keywords << [@category.title]\n end\n if @post and !@post.new_record?\n keywords << [@post.title, @post.subtitle]\n end\n keywords.join(\",\")\n end",
"def tag_list\n\t\tself.tags.collect do |tag|\n\t\t\ttag.name\n\t\tend.join(\", \") #When we joined the array Ruby called the default #to_s method on every one of these Tag instances \n\tend",
"def tag_list\n tags.collect do |tag|\n tag.name\n end.join(', ')\n end",
"def all_tags\n self.tags.map(&:name).join(\", \")\n end",
"def all_tags\n self.tags.map(&:name).join(\", \")\n end",
"def all_tags\n self.tags.map(&:name).join(\", \")\n end",
"def categories\n []\n end",
"def city_names\n cities.pluck(:name).join(\", \")\n end",
"def to_s\n @items.join( _separator )\n end",
"def categories\n return @categories\n end",
"def tags_and_categories_list\n list = []\n target_div = self.div(:class=>\"s3d-contentpage-title\", :text=>\"Basic Information\").parent.parent.div(:id=>\"displayprofilesection_body\")\n target_div.links.each { |link| list << link.text }\n return list\n end",
"def categories_list\n @categories = Category.all.collect { |p| [p.name, p.id] }\n end",
"def all_tags\n\t\ttags.map(&:name).join(\", \")\n\tend",
"def main_categories\n categories.to_a[0..3]\n end",
"def category_name(transaction)\n transaction.category.nil? ? '' : transaction.category.name\n end",
"def bar_category_name\n category.parent.name if category and category.parent\n end",
"def categories\n rpg_shop.handled_categories\n end"
] | [
"0.8224363",
"0.8134241",
"0.80120856",
"0.79779804",
"0.78914976",
"0.7738105",
"0.7533746",
"0.741994",
"0.730062",
"0.72704375",
"0.7236375",
"0.7058555",
"0.69943845",
"0.69729817",
"0.69081104",
"0.67374206",
"0.6704726",
"0.6644644",
"0.65887654",
"0.65695983",
"0.6538802",
"0.65275455",
"0.6434156",
"0.64187026",
"0.6397541",
"0.6370529",
"0.63620776",
"0.6345909",
"0.63335896",
"0.63080496",
"0.62683785",
"0.62618506",
"0.6256948",
"0.62460923",
"0.6199593",
"0.6198369",
"0.6181226",
"0.6148104",
"0.60811",
"0.60528326",
"0.6018917",
"0.5997349",
"0.5990165",
"0.5955638",
"0.593081",
"0.5915085",
"0.59090376",
"0.5894504",
"0.58729357",
"0.5870642",
"0.5852366",
"0.5849785",
"0.5849785",
"0.5846787",
"0.5831926",
"0.5807162",
"0.5791684",
"0.57877016",
"0.57714176",
"0.5767462",
"0.5767462",
"0.5767462",
"0.5764138",
"0.5749278",
"0.57170075",
"0.57161844",
"0.5715868",
"0.57115346",
"0.5706715",
"0.5701125",
"0.5671935",
"0.56686693",
"0.56644267",
"0.56605643",
"0.56582385",
"0.5656762",
"0.5648903",
"0.5640939",
"0.56331915",
"0.56319195",
"0.56291306",
"0.56287235",
"0.5621327",
"0.56137913",
"0.56133574",
"0.5597451",
"0.5595858",
"0.5595858",
"0.5595858",
"0.5588139",
"0.5584921",
"0.5583264",
"0.5575626",
"0.55671334",
"0.55637217",
"0.5549532",
"0.55475026",
"0.55424064",
"0.5537049",
"0.55335456"
] | 0.7681256 | 6 |
Given a comma separated string of category titles, reset the categories for this tweet to the categories in the string. | def categories_as_string= (new_categories)
categories.clear
new_categories.split(/\s*,\s*/).each do |title|
cat = Category.where('LOWER(title) = ?', title.downcase).first
categories << cat if !cat.nil?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categories_as_strings= (new_categories)\n categories.clear\n\n new_categories.split(/\\s*, \\s*/).each do |title|\n cat =Category.where('LOWER(title) = ?', title.downcase).first\n categories << cat if !cat.nil?\n end\n end",
"def category_names=(list)\n list = list.is_a?(Array) ? list : list.split(',').reject(&:blank?).collect { |item| item.try(:strip) }\n delete_unused_categories(list)\n add_new_categories(list)\n end",
"def categories_as_string= (new_categories)\n categories.clear\n\n new_categories.split(/\\s*,\\s*/).each do |title|\n cat = Category.where('LOWER(title) = ?', title.downcase).first\n categories << cat if cat\n end\n end",
"def categories_as_string= (new_categories)\n categories.clear\n new_categories.split(/\\s*,\\s*/).each do |title|\n cat = Category.where('LOWER(title) = ?', title.downcase).first\n categories << cat if !cat.nil?\n end\n end",
"def handle_categories(category_names)\n return if !self.undergrad? || category_names.nil?\n self.categories = [] # eliminates any previous interests so as to avoid duplicates\n category_array = []\n category_array = category_names.split(',').uniq if category_names\n category_array.each do |cat|\n self.categories << Category.find_or_create_by(name: cat.downcase.strip)\n end\n end",
"def assign_categories \n if @category_names \n self.categories = @category_names.split(/\\s+/).map do |name|\n Category.find_or_create_by_name(name)\n end\n end\n end",
"def normalize_categories(categories = [])\n [categories].flatten.collect do |cat|\n cat.to_s.encode(@encoding).downcase.gsub(/[^a-z\\d\\.\\-_ ]/,'')\n end.reject{|cat| cat == ''}.compact\n end",
"def category_names=(names)\n names.each do |name|\n unless name == \"\"\n category = Category.find_or_create_by(name: name)\n self.categories << category unless self.categories.include?(category)\n end\n end\n end",
"def set_categories\n new_categories = extract_categories_from_url\n unless new_categories.nil?\n @categories = new_categories\n else\n @categories = Type::DefaultCategories\n end\n end",
"def cleanCategoryTitle string\n string.strip.upcase\n end",
"def set_categories\r\n csv = CSV.readlines(File.join('data', 'categories.csv'))\r\n @categories = csv.each_with_object({}) do |(key, val), hsh|\r\n hsh[key] = val\r\n end\r\n\r\n @items.each do |i|\r\n i.category = @categories[i.category]\r\n end\r\nend",
"def unassign_category(categories_id)\n categories_id = [categories_id] if categories_id.is_a?(Integer)\n rescue_extra_data\n term_relationships.where(:term_taxonomy_id => categories_id).destroy_all\n update_counters(\"categories\")\n end",
"def untrain(category, text)\n hash = @categories[category.to_sym] ||= Hash.new(0)\n\n split(text).each do |word|\n if hash[word] - 1 > 0\n hash[word] -= 1\n else\n hash.delete(word)\n end\n end\n end",
"def category_ids=(ids)\n self.categories.clear\n self.categories << Category.find(ids[0..-1]) rescue nil\n end",
"def test_reset_categories\n assert @work_opinion.categories_string = @new_cat_string\n assert @work_opinion.reload\n assert_equal 2, @work_opinion.categories.size\n assert @work_opinion.categories.include?(@home_cat)\n assert !@work_opinion.categories.include?(@work_cat)\n end",
"def update_categories(cats=[])\n rescue_extra_data\n cats = cats.to_i\n old_categories = categories.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")\n delete_categories = old_categories - cats\n news_categories = cats - old_categories\n term_relationships.where(\"term_taxonomy_id in (?)\", delete_categories ).destroy_all if delete_categories.present?\n news_categories.each do |key|\n term_relationships.create(:term_taxonomy_id => key)\n end\n update_counters(\"categories\")\n end",
"def remove_category(*category)\n unless category.blank?\n what.query[:categories] && what.query[:categories] >> category.flatten \n changed\n end\n end",
"def sql_categories(categories)\n (categories.split(/,/).map {|c| \"'#{c.strip.gsub(/'/, '\\'\\'')}'\"}).join(',')\n end",
"def cleanup_empty_words_in_category(category)\n word_counts = @redis.hgetall base_category_key + category\n empty_words = word_counts.select{|word, count| count.to_i <= 0}\n if empty_words == word_counts\n @redis.del base_category_key + category\n else\n if empty_words.any?\n @redis.hdel base_category_key + category, empty_words.keys\n end\n end\n end",
"def categories\n if self.channel.generator == 'Twitter'\n return @item.title.scan(/#([^#\\s]+)/).flatten\n end\n return [] if @item.categories.empty?\n @item.categories.collect{|c| c.content}.reject{|c| c == '' || c.match(/^\\s+$/)}\n end",
"def set_categories(ids)\n self.categories = Category.find(ids)\n self.save\n end",
"def categories\n stories.map(&:category).delete_if {|c| c.nil? or c.global}.uniq\n end",
"def slugified_categories\n Array(@obj.data[\"categories\"]).each_with_object(Set.new) do |category, set|\n set << Utils.slugify(category.to_s)\n end.to_a.join(\"/\")\n end",
"def category\n string = Array(@data['categories'])[0]\n return '' if string.to_s.empty?\n\n string.split('/').map { |c|\n Silly::StringFormat.clean_slug_and_escape(c)\n }.join('/')\n end",
"def untrain(category, text)\n word_hash = Hasher.word_hash(text, @language, @enable_stemmer)\n return if word_hash.empty?\n category = CategoryNamer.prepare_name(category)\n word_hash.each do |word, count|\n next if @backend.total_words < 0\n orig = @backend.category_word_frequency(category, word) || 0\n @backend.update_category_word_frequency(category, word, -count)\n if @backend.category_word_frequency(category, word) <= 0\n @backend.delete_category_word(category, word)\n count = orig\n end\n\n @backend.update_category_word_count(category, -count) if @backend.category_word_count(category) >= count\n @backend.update_total_words(-count)\n end\n @backend.update_total_trainings(-1)\n @backend.update_category_training_count(category, -1)\n end",
"def categories_without_update\n ((fspath + '@categories').read rescue '').lines.\n map { |l| site.page_for l.chomp rescue nil }.\n select { |p| p.is_a? Category }.to_set\n end",
"def cats_input=(what)\n self.categories = if what.blank?\n []\n else\n what.chomp.split(\"\\n\").map(&:downcase).map(&:strip)\n end\nend",
"def all_categories\n stories.map(&:category).delete_if {|c| c.nil?}.uniq\n end",
"def build_tags(tags, category)\n \t\ttags = tags.split(',').map{ |tag| tag.strip } << category\n \t\ttags.flatten\n \tend",
"def sanitized_category\n return category.underscore.gsub(/ /, '_').gsub(/[^a-z_0-9]/,'')\n end",
"def categories_attributes=(attributes)\n attributes.each do |index, attribute|\n unless attribute[:title].blank? || self.categories.map(&:title).include?(attribute[:title])\n existing_category = self.categories[index.to_i]\n if existing_category == nil\n new_category = Category.create(title: attribute[:title])\n self.categories << new_category\n else\n existing_category.update(title: attribute[:title])\n end\n end\n end\n end",
"def fix_category(store_path)\n self.category = store_path.split('/')[0...-2].join('/')\n end",
"def add_categories(collection)\n\tcategory = \"\"\n\tcollection[\"results\"][\"collection1\"].each do |article|\n\t\tif article[\"category\"] == \"\"\n article[\"category\"] = category\n else\n category = article[\"category\"]\n end\n\tend\nend",
"def set_categories(product)\n categories = value('category').split('&')\n\n categories.each do |category_string|\n category_string.strip!\n subcategories = category_string.split('>')\n parent_id = self.root_category.id\n subcategories.each do |category_url_key|\n category_url_key.strip!\n category = Gemgento::Category.find_by(url_key: category_url_key, parent_id: parent_id)\n unless category.nil?\n pc = Gemgento::ProductCategory.find_or_create_by!(category: category, product: product, store: self.store)\n parent_id = category.id\n pc.sync_needed = true\n pc.save\n else\n self.process_errors << \"Row ##{@index}: Unknown category url key '#{category_url_key}' - skipped\"\n end\n end\n end\n end",
"def unassign_tags(tag_titles)\n update_counters_before\n tags = tag_titles.split(\",\").strip\n self.term_relationships.where({term_taxonomy_id: self.post_type.post_tags.where(name: tags).pluck(:id)}).destroy_all\n update_counters(\"tags\")\n end",
"def normalize_category_id\n return true if [nil,0].include?(self.category_id)\n if self.category_id.to_s =~ /[a-zA-Z]/\n category = Category.find_or_create( :title => self.category_id )\n self.category_id = category.id\n end\n end",
"def categories=(value)\n @categories = value\n end",
"def tags!(str)\n str.strip!\n tags = str.split(\",\").map { |tag|\n self.tags.find_or_create_by_value(tag.strip.downcase)\n }\n self.tags << tags\n end",
"def categories(str)\n raise NotImplementedError\n end",
"def update_tags\n return unless tag_string\n new_tag_names = tag_string.split(\",\").map { |t| t.strip.downcase }\n current_tag_names = tags.collect(&:name)\n new_tag_names.each do |tag_name| \n unless current_tag_names.include? tag_name\n tag = Tag.where(name: tag_name)[0]\n tag = Tag.create! name: tag_name unless tag\n self.tags << tag \n end\n end\n tags.each { |t| (tags.remove t) unless (new_tag_names.include? t.name) }\n end",
"def remove_category category_name\r\n delete category_name\r\n end",
"def categories(body, headers, expectation = nil)\n expectation ||= Occi::Core::Category\n logger.debug \"Parsing #{expectation} from #{body.inspect} and #{headers.inspect}\" if logger_debug?\n\n cats = transform(body, headers).map do |line|\n cat = Text::Category.plain_category(line, false)\n lookup \"#{cat[:scheme]}#{cat[:term]}\", expectation\n end\n\n setify(cats)\n end",
"def decrement_word_counts_for_category(category, word_occurrences)\n word_occurrences.each do|word,count|\n @redis.pipelined do\n @redis.hincrby base_category_key + category, word, - count\n @redis.incrby sum_key(category), - count\n end\n end\n end",
"def categories=(value)\n @categories = value\n end",
"def categories=(value)\n @categories = value\n end",
"def categories=(value)\n @categories = value\n end",
"def set_categories\n\t\t@categories = Category.all\t\n\tend",
"def set_all_categories\n @all_categories = Category.all.order_by_name\n end",
"def category\n if self.channel.generator == 'Twitter'\n return self.categories.join(', ')\n end\n return '' if @item.categories.empty? \n @item.categories.collect{|c| c.content}.join(', ')\n end",
"def parsed_category\n self.category = self[:category] unless self[:category].to_s =~ /^[A-Z]$/\n self[:category]\n end",
"def modify_category(categories)\n begin\n puts Rainbow(\"Current categories: #{categories.join(', ')}\").whitesmoke\n yield\n\n write_json(categories, \"Categories/cat\", \"Available categories are: #{categories.join(', ')}\")\n rescue StandardError\n puts \"There are no categories to delete\"\n end\nend",
"def categories=(value)\n\t\t@categories = value\n\tend",
"def categories=(value)\n\t\t@categories = value\n\tend",
"def categories=(value)\n\t\t@categories = value\n\tend",
"def slugified_categories; end",
"def clean_up_unused_categories!\n empty_category_codes = []\n @category_types.each do |category_type|\n record_found = 0 # Let's count how many records there are for this category:\n @pool_types.each do |pool_type|\n @gender_types.each do |gender_type|\n next unless @event_types_by_pool.key?(pool_type.id)\n\n @event_types_by_pool[pool_type.id].each do |event_type|\n record_found += 1 if @collector.collection.has_record_for(@record_type_code, pool_type.code, event_type.code, category_type.code, gender_type.code)\n end\n end\n end\n empty_category_codes << category_type.code if record_found == 0\n end\n # Remove unused cateogories:\n @category_types = @category_types.delete_if { |category_type| empty_category_codes.include?(category_type.code) }\n end",
"def tags_string=(titles)\n self.tags = titles.split(',').map do |title|\n Tag.find_or_create_by(title: title, user: user)\n end\n end",
"def clean_keywords(input)\n keywords = input.split(',').map! { |i| i.chomp.strip.downcase }.compact.uniq.keep_if { |i| i != '' }\n if keywords.empty?\n nil\n else\n keywords.join(', ')\n end\n end",
"def set_categories\n @categories = Category.order(:name).pluck(:name, :id)\n end",
"def preprocess(str)\n str.downcase.gsub(URI_PREFIX, ',')\n end",
"def assign_category(categories_id)\n categories_id = [categories_id] if categories_id.is_a?(Integer)\n rescue_extra_data\n categories_id.each do |key|\n term_relationships.where(:term_taxonomy_id => key).first_or_create!\n end\n update_counters(\"categories\")\n end",
"def set_categories\r\n @categories = Category.where('courses_count > 0').order(:name)\r\n end",
"def csv_to_set(string, default = Set[], separator = ',')\n new_set = Set.new(string.to_s.split(separator).map(&:strip))\n new_set.empty? ? default : new_set\n end",
"def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end",
"def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end",
"def train(category, text)\n category = category.downcase\n @redis.sadd(CATEGORIES_KEY, category)\n\n count_occurance(text).each do |word, count|\n @redis.hincrby(redis_category_key(category), word, count)\n end\n end",
"def tags_string=(commastring)\n self.tags.clear\n \n if (commastring.length > 0)\n tagsArr = commastring.split(',');\n tagsArr.each do |tagname|\n # remove white space\n tagname = tagname.strip\n \n if (Tag.find_by_name(tagname))\n aTag = Tag.find_by_name(tagname)\n else\n aTag = Tag.new(:name => tagname)\n aTag.save\n end\n \n self.tags << aTag\n end\n end\n \n Tag.clear_unused\n end",
"def untrain(tokens, category)\n tokens = tokens.uniq if binarized\n data.decrement_examples(category)\n \n tokens.each do |token|\n if data.token_trained?(token, category)\n vocab.delete(token)\n data.remove_token_from_category(category, token)\n end\n end\n end",
"def category_names\n @category_names || categories.map(&:name).join(' ')\n end",
"def set_category\n end",
"def categories\n\t\t\t@cat_cache ||= @db.js('musicthoughts.all_categories()').map {|c| c.merge(category: c[@lang]) }\n\t\t\t@cat_cache\n\t\tend",
"def sanitised(title)\n title.delete(',') # ignore, commas\n .sub(/[?!']$/, '') # ignore ? and ! and ' at the end of the title!\n .gsub(\"' \", ' ') # ignore ' at the endin' of a word\n .sub('Feat. ', 'Feat ')\n end",
"def category\n categories.collect(&:title).join(',')\n end",
"def set_tags(page)\n tags = page.data['tags']\n\n if tags\n tags = (tags.kind_of?(Array) ? tags : tags.split)\n else\n tags = []\n end\n\n tags << page.data['category']\n page.data['tags'] = tags.sort\n end",
"def change_subcategories(subcategory_ids)\n\n Article.transaction do\n #Removal of old categories are rolled back on errors\n categorizations.destroy_all\n subcategory_ids.each do |subcategory_id|\n categorizations.create(subcategory_id: subcategory_id)\n end\n end\n end",
"def format_category_name # WHY IS IT IN HERE?\n self.category.name.downcase.delete(' ')\n end",
"def clean\n keylist = self.list.split(',')\n keylist.each { |i| i.strip! }\n keylist.sort! { |a,b| a.downcase <=> b.downcase }\n self.list = keylist.join(', ')\n end",
"def categories=(categories)\n end",
"def set_counts\n @category_counts = {}\n @category_counts.default = 0\n @lines.map do |line|\n category = line.split[0]\n @category_counts[category] += 1\n end\n end",
"def cleanupstr (str)\n str.strip.gsub(/\\s+/, ' ').gsub(/ ,/, ',') unless str.nil?\n end",
"def update_keyword_categories(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/KeywordCategories\")\n results = put(uri,data,generate_objects)\n end",
"def category categories\n categories = categories.to_a if !categories.is_a? Array\n categories.collect { |i| calendars.find_by_title i.to_s }.compact\n end",
"def _build_category_list\n raw_categories = CatAPI.get_categories\n category_list = raw_categories.map {|category| category['name']}.sort\n # the \"kittens\" category is empty, and never returns photos\n category_list.delete(\"kittens\")\n return category_list.unshift(\"your favorites\")\nend",
"def clean_tweets(results)\n results.first($number_of_tweets).map(&:text).join.gsub(URLS,\"\").gsub(HANDLES_AND_ADV_TWITTER,\"\").squeeze(\" \")\nend",
"def categories(*values)\n values.inject(self) { |res, val| res._categories(val) }\n end",
"def categories(*values)\n values.inject(self) { |res, val| res._categories(val) }\n end",
"def cleanup_image_tags\n self.tags = self.tags.strip\n unless self.tags.empty?\n tags = self.tags.split(\",\")\n tags_new = []\n tags.each do |item|\n tags_new.push(item.strip)\n end\n self.tags = tags_new.join(\",\")\n end\n end",
"def categories=(categories)\n @categories = categories\n end",
"def set_categories\n @categories = Category.all\n end",
"def categories_line\n categories ? categories.join(\", \") : ''\nend",
"def categories\n if @categories.nil?\n @categories = []\n category_nodes =\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"category\",\n \"dc:subject\"\n ])\n unless category_nodes.nil?\n for category_node in category_nodes\n category = FeedTools::Category.new\n category.term = FeedTools::XmlHelper.try_xpaths(category_node, [\n \"@term\",\n \"text()\"\n ], :select_result_value => true)\n category.term.strip! unless category.term.blank?\n category.label = FeedTools::XmlHelper.try_xpaths(\n category_node, [\"@label\"],\n :select_result_value => true)\n category.label.strip! unless category.label.blank?\n category.scheme = FeedTools::XmlHelper.try_xpaths(category_node, [\n \"@scheme\",\n \"@domain\"\n ], :select_result_value => true)\n category.scheme.strip! unless category.scheme.blank?\n @categories << category\n end\n end\n end\n return @categories\n end",
"def categories\n @transactions.empty? ? nil : @transactions.delete_if{ |t| t.category.nil? }.collect(&:category).uniq\n end",
"def tags=(value)\n if value.kind_of?(String)\n @tags = value.split(\",\").uniq.map(&:strip)\n elsif value.kind_of?(Array)\n @tags = value.uniq.map(&:strip)\n end\n end",
"def set_category\n match_data = /^What is [-]?\\d+\\s*(?<operation>[\\+\\-\\*\\/])\\s*[-]?\\d+\\?$/.match(self.query) || {}\n self.category = CATEGORIES[match_data[:operation]]\n end",
"def category\n return '' if self.categories.empty?\n self.categories.join(', ')\n end",
"def set_category\n @categories = Category.friendly.find(params[:id])\n end",
"def all_tags=(names)\n self.tags = names.split(\",\").map do |tag|\n Tag.where(name: tag.strip.capitalize).first_or_create!\n end\n end",
"def titleize(string)\n small_words = [\"and\"]\n new_array = string.split(\",\")\n new_array.map(&:capitalize) unless new_array.include?(small_words)\n\n new_array.join(\" \")\nend",
"def categories\n return [] if @feed.channel.categories.empty? && @feed.channel.dc_subjects.empty?\n [@feed.channel.categories, ((@feed.channel.dc_subjects.empty?) ? nil : @feed.channel.dc_subjects)].flatten.uniq.compact.collect{|c| c.content}.reject{|c| c == '' || c.match(/^\\s+$/)}\n end",
"def categorize_cell(cdscell, category)\r\n\r\n Category.where.not(name: category.name).each do |cat|\r\n #Only run if the cell is not tagged\r\n cdscell = category.cdscells.find_by(name: \"uncategorized\")\r\n if !cdscell\r\n user.tag(cdscell, :with => \"uncategorized\", :on => :categories)\r\n end\r\n end\r\n \r\n end"
] | [
"0.69549704",
"0.69243455",
"0.67097646",
"0.66300946",
"0.6519889",
"0.64701647",
"0.60764104",
"0.6049881",
"0.5900281",
"0.58600694",
"0.5831608",
"0.5716712",
"0.56877077",
"0.56314504",
"0.56175077",
"0.55974466",
"0.5462894",
"0.54461884",
"0.54330766",
"0.5419876",
"0.53741956",
"0.5346094",
"0.53454727",
"0.5315982",
"0.5306982",
"0.5262173",
"0.52358323",
"0.5225722",
"0.51869917",
"0.5145739",
"0.51244515",
"0.5108251",
"0.5096267",
"0.5083196",
"0.5078073",
"0.5071786",
"0.5064675",
"0.5058329",
"0.50571054",
"0.50531065",
"0.50384134",
"0.5014726",
"0.5012989",
"0.49687007",
"0.49687007",
"0.49687007",
"0.4960166",
"0.49572977",
"0.49556231",
"0.49483588",
"0.49274066",
"0.49201638",
"0.49201638",
"0.49201638",
"0.49197134",
"0.49172148",
"0.49144676",
"0.49048278",
"0.48811665",
"0.48716834",
"0.48686913",
"0.4864455",
"0.4864264",
"0.48593843",
"0.48593843",
"0.48476163",
"0.4832334",
"0.48017627",
"0.47977415",
"0.47843868",
"0.47832853",
"0.47821426",
"0.47796214",
"0.47737136",
"0.47728267",
"0.47552332",
"0.47487548",
"0.47415948",
"0.47321463",
"0.47311234",
"0.47291765",
"0.4726907",
"0.47266185",
"0.47243437",
"0.47191486",
"0.47191486",
"0.47146672",
"0.4679453",
"0.46736902",
"0.4666276",
"0.46655798",
"0.46616182",
"0.46567187",
"0.46395615",
"0.46327922",
"0.46239924",
"0.4612397",
"0.46098465",
"0.46097124",
"0.46047238"
] | 0.6752916 | 2 |
title:legend: xAxis: yAxis: tooltip: credits: :plotOptions | def defaults_options
self.title({ :text=>"example test title from highcharts gem"})
self.legend({ :layout=>"vertical", :style=>{} })
self.xAxis({})
self.yAxis({ :title=> {:text=> nil}, :labels=>{} })
self.tooltip({ :enabled=>true })
self.credits({ :enabled => false})
self.plotOptions({ :areaspline => { } })
self.chart({ :defaultSeriesType=>"areaspline" , :renderTo => nil})
self.subtitle({})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def defaults_options\n self.title({:text => nil})\n self.legend({:layout => \"vertical\", :style => {}})\n self.xAxis({})\n self.yAxis({:title => {:text => nil}, :labels => {}})\n self.tooltip({:enabled => true})\n self.credits({:enabled => false})\n self.plotOptions({:areaspline => {}})\n self.chart({:defaultSeriesType => \"line\", :renderTo => nil})\n self.subtitle({})\n end",
"def configurePlot\n end",
"def plot_against e1, e2\n Flot.new('experiment_roc_plot') do |f|\n f.points\n f.grid :hoverable => true\n f.legend :position => \"se\"\n f.yaxis 1\n f.series \"#{e1.title} against #{e2.title}\", e1.aucs_against(e2), :points => {:show => true, :radius => 1.5}\n end\nend",
"def plot; end",
"def add_title(input_args=Hash.new)\n @content[:options] ||= Hash.new\n @content[:options][:scales] ||= Hash.new\n if @args[:title]\n @content[:options][:title] = {\n display: true,\n text: @args[:title]\n }\n end\n\n # adjust where x-axis start or end\n x_scale_ticks = { } # Note this doesn't work for Time, which needs to specifies its own Time Min and Max\n y_scale_ticks = { }\n\n y_axes_left = { position: 'left', id: 'y-axis-left', ticks: y_scale_ticks}\n y_axes_right = {position: 'right', id: 'y-axis-right', ticks: y_scale_ticks}\n x_axes = { ticks: x_scale_ticks }\n\n \n\n # y_label(left) is always the first color, and y_label_right is always the second color\n if @args[:y_label]\n y_axes_left[:scaleLabel] = { display: true, labelString: @args[:y_label], fontColor: @colors[0] }\n end\n if @args[:y_right_label] # Jason 090216 right y axis label doesn't work\n y_axes_right[:scaleLabel] = { display: true, labelString: @args[:y_right_label] , fontColor: @colors[1] }\n\n end\n\n if @args[:stacked] \n x_axes[:stacked] = true\n y_axes_left[:stacked] = true \n end\n @content[:options][:scales][:yAxes] = [ y_axes_left]\n if @args[:y_right_label] # Jason 090216 right y axis label doesn't work\n @content[:options][:scales][:yAxes] << y_axes_right\n end\n @content[:options][:maintainAspectRatio] = @args[:aspect_ratio]\n @content[:options][:showLines] = @args[:showLines] if @args.has_key? :showLines\n\n # Chart Zoom plugin options\n @content[:options][:pan] = { enabled: true, mode: 'xy' }\n @content[:options][:zoom] = { enabled: true, mode: 'xy'}\n\n if self.class == ChartMaker::Scatter\n if @args[:time] # x axis is time (same as localtime, time since 1970) \n x_axes[:type] = 'time'\n else # x axis is number\n x_axes[:type] = 'linear'\n end\n x_axes[:position] = 'bottom'\n end\n \n if @args[:x_label]\n x_axes[:scaleLabel] = { display: true, labelString: @args[:x_label] }\n end\n if @args[:time]\n if ! ['hour','day','week','month','year'].include? @args[:time] # check Chart.js Time Scale for all the different Time Units\n raise \"unsupported time format #{@args[:time]}\"\n end\n x_axes[:time] = {}\n x_axes[:time][:unit] = @args[:time] \n x_axes[:time][:tooltipFormat] = \"MMMM Do YYYY, h a\" # need this or time will be display in integer in tooltip mode (when you hover over data point), note this will return invalid if tooltip doesn't contain time\n if input_args[:last_month]\n #puts \"show just last month\"\n a_month_ago = Time.now.to_i - (86400 * 30) # 30 days in terms of seconds\n x_axes[:time][:min] = to_js_time(a_month_ago)\n # also if last_month, then you know a good time unit is week\n x_axes[:time][:unit] = 'week'\n end\n end\n @content[:options][:scales][:xAxes] = [ x_axes]\n=begin\n jchen I have my own tooltips callback function, check def script_content()\n so below is not needed\n @content[:options][:tooltips] = Hash.new\n @content[:options][:tooltips][:callbacks] = Hash.new\n @content[:options][:tooltips][:callbacks][:label] = \"function(tooltipItem,data) { return \\\"jason\\\"; }\"\n=end\n\n end",
"def legend\n title\n end",
"def xaxis\n end",
"def showLegend _obj, _args\n \"_obj showLegend _args;\" \n end",
"def set_legend(params)\n @legend_position = params[:position] || 'right'\n @legend_delete_series = params[:delete_series]\n end",
"def beanplot\n end",
"def show\n @chart = Chart.find(params[:id])\n @chartnodes = @chart.chartnodes\n data = @chart.chartnodes.map {|node| [node.xaxis, node.yaxis]}.transpose\n if @chart.charttype == 'column'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'column',:name=> @chart.name,:data=> data[1])\n end\n elsif @chart.charttype == 'spline'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'spline',:name=> @chart.name,:data=> data[1])\n f.plot_options( :spline => {\n :dataLabels => {\n :enabled => true\n }})\n f.tooltip( :crosshairs => true, :shared => true)\n end\n elsif @chart.charttype == 'pie'\n @h1 = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> 'pie',\n :name=> @chart.name,\n :data=> data.transpose\n }\n f.series(series)\n f.options[:title][:text] = \"Browser share\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n #:cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chart }\n end\n end",
"def yaxis\n end",
"def axes\n end",
"def plot(title, legend_titles, data)\n graph = Scruffy::Graph.new\n graph.title = title\n graph.renderer = Scruffy::Renderers::Standard.new\n data.each_index do |idx|\n graph.add(:line, legend_titles[idx], data[idx],\n {'stroke-width'=> 7, :stroke => 'black'})\n end\n graph.render :to => \"#{title}.svg\", :width=>500, :height=>400\nend",
"def basic_chart\n \n end",
"def chart_options\n {}\n end",
"def makeChart(*options)\n\ndisplay = \"\n<div class='charts last'>\n\n<div class='left'>\n\n\n<div id='placeholder' style='width:400px;height:200px;'></div>\n<div id='overview' style='width:400px;height:50px'></div>\n<p id='overviewLegend' style='margin-left:10px'></p>\n\n<p> Try zooming. Click and drag to select a zone.</p>\n</div>\n\n<div class='right'>\n\nWeight Chart<br/>\n<div id='miniWeight' style='width:350px;height:100px;'></div>\nWater Chart<br/>\n<div id='miniWater' style='width:350px;height:100px;'></div>\n\n\nCalories Eaten<br/>\n<div id='miniCalorie' style='width:350px;height:100px;'></div>\nFitness (Calories burned not to include resting metabolism)<br/>\n<div id='miniFitness' style='width:350px;height:100px;'></div><br/>\n\nMeasurements (Total inches)<br/>\n<div id='miniMeasures' style='width:350px;height:100px;'></div>\n\n\n</div>\n\n\n\n\n<div class='last'></div>\n<script id='source' language='javascript' type='text/javascript'>\n\n\n$(function () {\nvar options = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { \n show: true, \n container: $('#overviewLegend'),\n noColumns: 2,\n }\n};\n\nvar options_overview = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { show: false}\n};\n\n\nvar plot = $.plot($('#placeholder'), \n[ #{@chartable.to_chart } ], options);\n\n\n\n\nvar overview = $.plot($('#overview'), \n[ #{@chartable.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n\n\n\n\nvar overview_1 = $.plot($('#miniWeight'), \n[ #{@miniWeight.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_2 = $.plot($('#miniWater'), \n[ #{@miniWater.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_3 = $.plot($('#miniCalorie'), \n[ #{@miniCalorie.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_4 = $.plot($('#miniFitness'), \n[ #{@miniFitness.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_5 = $.plot($('#miniMeasures'), \n[ #{@miniMeasures.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n// now connect the two\nvar internalSelection = false;\n\n$('#placeholder').bind('selected', function (event, area) {\n // do the zooming\n plot = $.plot($('#placeholder'), \n [#{@chartable.to_chart}],\n $.extend(true, {}, options, {\n xaxis: { min: area.x1, max: area.x2 }\n }));\n \n if (internalSelection)\n return; // prevent eternal loop\n internalSelection = true;\n overview.setSelection(area);\n internalSelection = false;\n});\n\n$('#overview').bind('selected', function (event, area) {\n if (internalSelection)\n return;\n internalSelection = true;\n plot.setSelection(area);\n internalSelection = false;\n});\n\n\n});\n</script>\n\"\n\nend",
"def generatePlot( options={} )\n # Generate an array of the x hash values to easily find the minimum and maximum.\n x = Array.new\n @x_data.keys.each { |key|\n x.push(@x_data[key].to_f)\n }\n\n defaults = { :filename => \"data\",\n :numBins => 2,\n :x_label => \"X\",\n :y_label => \"Y\",\n :title => \"Title\",\n :min => x.min,\n :max => x.max,\n :logx => false,\n :logy => false,\n :linreg => false,\n :dataLabels => false,\n :doOutliers => false,\n :outlierK => 3,\n :addOutlierLabels => 0,\n :savePlot => false }\n\n options = defaults.merge(options)\n\n savePlot = options[:savePlot]\n filename = options[:filename]\n numBins = options[:numBins]\n x_label = options[:x_label]\n y_label = options[:y_label]\n title = options[:title]\n min = options[:min]\n max = options[:max]\n logx = options[:logx]\n logy = options[:logy]\n linreg = options[:linreg]\n outlierAnalysis = Array.[](options[:doOutliers],options[:outlierK])\n dataLabels = options[:dataLabels]\n addOutlierLabels = options[:addOutlierLabels]\n\n if (@plottype == :histogram)\n\n bw = (max.to_f - min.to_f) / numBins.to_f # Calculate bin width\n x_count = Array.new\n x_axis = Array.new\n\n histfile = File.new(filename + \".histo\", \"w\") # File that shows the keys that belong in each bin.\n\n # checks which values belong in each bin. Edgecases go to the lower bin.\n (1..numBins).each {|n|\n count = 0\n histfile.puts \"Values from #{(min.to_f + (n.to_f-1) * bw.to_f)} to #{min.to_f + n.to_f * bw.to_f}.\" # Label the bin in the file.\n\n if (min == x.min && n == 1) # To fix the issue with keys being left out if the bin minimum == data minimum(s)\n @x_data.keys.each {|key|\n if (@x_data[key] == x.min)\n histfile.puts key # Place a copy of the minimum(s) in the first bin\n count = count + 1 # Increment the first bin to reflect this\n end\n }\n end\n\n @x_data.keys.each {|v|\n if(((min.to_f + (n.to_f-1) * bw.to_f) < (@x_data[v].to_f)) and ((@x_data[v].to_f) <= (min.to_f + n.to_f * bw.to_f)))\n count = count + 1 # Add increment the bin counter if the key qualifies\n histfile.puts v # List the key in the bin if it qualifies\n end\n }\n\n x_count.push(count) # Add the bin count to the count array.\n }\n\n histfile.close\n\n # To check bin counts\n binSum = 0;\n (0..(numBins-1)).each { |index|\n binSum = x_count[index] + binSum\n puts \"Bin #{index} contains #{x_count[index]}\" if $verbose\n }\n puts \"There were #{binSum} samples in the plot.\" if $verbose\n\n # generates the x axis\n (1..numBins).each {|n|\n x_axis.push(min.to_f + (0.5*bw.to_f + bw.to_f * (n-1)))\n }\n\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.title title\n plot.ylabel \"Frequency\"\n plot.xlabel x_label\n\n # Save the plot to a file\n if (savePlot == true)\n plot.terminal \"gif\"\n plot.output filename + \".gif\"\n end\n\n plot.arbitrary_lines << \"set xrange [\" + min.to_s + \":\" + max.to_s + \"]\" # Set x axis according to max and mins\n plot.arbitrary_lines << \"set yrange [0:#{x_count.max.to_f + x_count.max.to_f * 0.1}]\" # Make the y axis 110% of the highest count\n\n plot.data << Gnuplot::DataSet.new( [x_axis, x_count] ) do |ds|\n ds.with = \"boxes\"\n ds.notitle\n end\n end\n end\n end\n\n if (@plottype == :scatter)\n\n if(@x_data.length == @y_data.length)\n\n # generate a datafile to use in gnuplot\n datfile = filename + \".scatter\"\n\n newfile = File.new(datfile, \"w\")\n\n # pointCount tells how many points are on the graph\n pointCount = 0\n @x_data.keys.each { |i|\n newfile.puts \"#{@x_data[i]}\\t#{@y_data[i]}\"\n pointCount = pointCount + 1\n }\n\n puts \"There are #{pointCount} points on the plot.\" if $verbose\n\n newfile.close\n\n # plot data\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n\n # plot to a file\n if (savePlot == true)\n plot.terminal \"gif\"\n plot.output filename + \".gif\"\n end\n\n #apply title/labels\n plot.title title\n plot.ylabel y_label\n plot.xlabel x_label\n\n # check if graphs need to be logscaled\n if (logx)\n plot.arbitrary_lines << \"set logscale x\"\n end\n\n if (logy)\n plot.arbitrary_lines << \"set logscale y\"\n end\n\n # check if a linear regression is desired\n if (linreg)\n plot.arbitrary_lines << \"f(x) = m*x + b\"\n plot.arbitrary_lines << \"fit f(x) '\" + datfile + \"' using 1:2 via m,b\"\n end\n\n # perform outlier analysis\n if (outlierAnalysis[0])\n\n # generate array of slopes of data\n yDivX = Array.new\n @x_data.keys.each { |key|\n yDivX.push(@y_data[key].to_f / @x_data[key].to_f)\n }\n\n # apply the 5 number summary function\n summData = Array.new\n summData = yDivX.fiveNumSum # match to new function\n\n # Calculate slopes of minimum and maximum lines to show outliers\n maxline = summData[2] + outlierAnalysis[1] * (summData[3] - summData[1])\n minline = summData[2] - outlierAnalysis[1] * (summData[3] - summData[1])\n\n # Define the minline and maxline in gnuplot\n plot.arbitrary_lines << \"a(x) = #{minline}*x\"\n plot.arbitrary_lines << \"b(x) = #{maxline}*x\"\n\n end #outlier analysis\n\n\n # Generate a plot string\n plotString = \"plot '#{datfile}' notitle\"\n\n # add linear regression\n if (linreg)\n plotString = plotString + \", f(x) title 'Linear Fit'\"\n end\n\n # plot with outlier analysis\n if (outlierAnalysis[0])\n plotString = plotString + \", a(x) title 'Minimum', b(x) title 'Maximum'\"\n end\n # add data point names if desired\n if (dataLabels && addOutlierLabels == 0) # Won't label everything if outlier labeling is enabled\n @x_data.keys.each { |key|\n plot.arbitrary_lines << \"set label '#{key}' at #{@x_data[key].to_f}, #{@y_data[key].to_f}\"\n }\n end\n\n # add outlier data labels\n if ( addOutlierLabels > 0 )\n self.findOutliers( filename + \"ForLabels\", addOutlierLabels )\n @outlier_data.keys.each { |key|\n # add labels to each point where an outlier exists\n plot.arbitrary_lines << \"set label '#{key}' at #{@x_data[key].to_f}, #{@y_data[key].to_f}\"\n }\n puts \"Labeled #{@outlier_data.size} outliers.\" if $verbose\n end\n plot.arbitrary_lines << plotString\n end\n end\n\n # Regenerate the data file to add in key names.\n newfile = File.new(datfile+ \"WITHNAMES\", \"w\")\n \n newfile.puts \"Name\\tX\\tY\"\n\n @x_data.keys.each { |i|\n newfile.puts \"#{i}\\t#{@x_data[i]}\\t#{@y_data[i]}\"\n }\n\n newfile.close\n\n else\n puts \"X and Y are different sizes\"\n end # x y size check\n end # scatter\n\n end",
"def show_x_axis\n false\n end",
"def plot_data data, series=nil, filename=nil, title=nil\n # stub method to enable documentation in yard\n\t\tend",
"def generatePlotAxisDescriptions\n axisDescriptionOptions={:xlabel=>\"\", :ylabel=>\"\"}\n axisDescription=self.data_string\n if (axisDescription)\n descriptionParts=axisDescription.split(\",\")\n if (descriptionParts[0].present?)\n axisDescriptionOptions[:xlabel]+=descriptionParts[0]\n end\n if (descriptionParts[1].present?)\n axisDescriptionOptions[:ylabel]+=descriptionParts[1]\n end\n if (descriptionParts[2].present?)\n axisDescriptionOptions[:xlabel]+=\" [\"+descriptionParts[2]+\"]\"\n end\n if (descriptionParts[3].present?)\n axisDescriptionOptions[:ylabel]+=\" [\"+descriptionParts[3]+\"]\"\n end\n end\n return axisDescriptionOptions\n end",
"def update_visualization(point)\n\t\tsuper(point)\n\tend",
"def add_series(plot, opts={})\n plot.series(opts)\n plot\n end",
"def add_series(plot, opts={})\n plot.series(opts)\n plot\n end",
"def axes(*)\n super\n end",
"def show_y_axis\n false\n end",
"def show\n \n @end_at = Date.today\n @start_at = @end_at - 6\n @categories = @start_at.upto(@end_at).to_a\n\n \t#Sales Historyグラフ\n @sales_data = [500, 600, 300, 100, 200, 400, 700,500, 600, 300, 100, 200, 400, 700,100, 200, 400, 700,500, 600, 600, 300, 100, 200,]\n @sales_history = LazyHighCharts::HighChart.new(\"graph\") do |f|\n f.title(:text => \"Sales History\", :align =>\"left\")\n f.chart(:type => \"column\")\n f.xAxis(:categories => @categories)\n f.series(:name => \"Sales\", :data => @sales_data)\n\t end\n\n#Order Historyのグラフ\n @order_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @order_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @order_data)\n end\n\n#Price Historyのグラフ\n @price_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @price_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @price_data)\n end\n \n \n end",
"def update_visualization(point)\n\t\t\t\t\n\t\t\tend",
"def default_options\n { \n :x => 20,\n :y => 20,\n :gauge_color => \"ff0000\",\n :legend_color => \"cc0000\",\n }\n end",
"def common_data(name, options)\n {\n # color: color or number\n label: name.to_s.humanize,\n data: series_for(name)\n # xaxis: number\n # yaxis: number\n # clickable: boolean\n # hoverable: boolean\n # shadowSize: number\n # highlightColor: color or number\n }\n end",
"def begin_figure\n @legend_keys = []\n @legend_labels = []\n end",
"def legend_data\n if relevant_data? && @color\n {:title => title, \n :color => @color,\n :priority => :normal}\n else\n nil\n end\n end",
"def graph_params(title: \"\", subtitle: \"\", caption: \"\", x_label: \"\", y_label: \"\")\n R.labs(\n title: title, \n subtitle: subtitle, \n caption: caption,\n y_label: y_label, \n x_label: x_label, \n )\n end",
"def show_legend=(v) Axlsx::validate_boolean(v); @show_legend = v; end",
"def update_visualization(point)\n\t\t\n\tend",
"def update_visualization(point)\n\t\t\n\tend",
"def update_visualization(point)\n\t\t\n\tend",
"def update_visualization(point)\n\t\t\n\tend",
"def show_legend=(v) Axlsx.validate_boolean(v); @show_legend = v; end",
"def getchart()\n # The XY data of the first data series\n dataX0 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY0 = [3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3]\n\n # The XY data of the second data series\n dataX1 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY1 = [1.6, 1.8, 0.8, 0.5, 1.3, 1.5, 2.3, 2.4, 2.9, 1.5]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background\n # and a light grey border (0xc0c0c0). Turn on both horizontal and vertical grid\n # lines with light grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"Server Performance\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Response Time (sec)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.yAxis().setWidth(3)\n c.xAxis().setWidth(3)\n\n # Add a scatter layer using (dataX0, dataY0)\n c.addScatterLayer(dataX0, dataY0, \"Server AAA\", ChartDirector::DiamondSymbol, 11,\n 0x008000)\n\n # Add a trend line layer for (dataX0, dataY0)\n c.addTrendLayer2(dataX0, dataY0, 0x008000).setLineWidth(3)\n\n # Add a scatter layer for (dataX1, dataY1)\n c.addScatterLayer(dataX1, dataY1, \"Server BBB\", ChartDirector::TriangleSymbol, 9,\n 0x6666ff)\n\n # Add a trend line layer for (dataX1, dataY1)\n c.addTrendLayer2(dataX1, dataY1, 0x6666ff).setLineWidth(3)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def overview\n @current_year = Time.zone.today.year\n (current_user.first_billing_date.year..Time.zone.today.year).each do |year|\n add_to_graph(year_start_date(year), year_end_date(year))\n end\n @year_json = {\n title: \"Full Overview\",\n y_title: \"Dollars\",\n categories: (current_user.first_billing_date.year..Time.zone.today.year).to_a,\n series: [\n {\n name: 'Gross Income',\n data: @gross_income,\n color: '#3c763d'\n },\n {\n name: 'Gross Spending',\n data: @gross_spending,\n color: '#a94442'\n },\n {\n name: 'Net Profit',\n data: @net_profit,\n color: '#5cb85c',\n negativeColor: '#d9534f'\n }\n ]\n }\n end",
"def initialize(frame, options={})\n @style = 2\n @graphic_frame=frame\n @graphic_frame.anchor.drawing.worksheet.workbook.charts << self\n @series = SimpleTypedList.new Series\n @show_legend = true\n @series_type = Series\n @title = Title.new\n options.each do |o|\n self.send(\"#{o[0]}=\", o[1]) if self.respond_to? \"#{o[0]}=\"\n end\n start_at(*options[:start_at]) if options[:start_at]\n end_at(*options[:end_at]) if options[:start_at]\n yield self if block_given?\n end",
"def plot_hash hsh, type, options = {}\n options[:colors] ||= :category10\n options[:line_width] ||= 2\n\n colors = Rubyvis::Colors.send(options[:colors])\n options[:panel] = vis(options) # set up panel and store it in the options hash\n \n hsh.real.each_index do |i|\n options[:panel] = hsh.real[i].vis(type, options.merge({ :line_color => colors[i % colors.size] }))\n end if hsh.respond_to?(:real) # may not have anything but controls\n\n hsh.control.each_index do |i|\n options[:panel] = hsh.control[i].vis(type, options.merge({ :line_color => colors[i % colors.size] }))\n end if hsh.respond_to?(:control) # May not have a control set up\n\n options[:panel]\n end",
"def use_axes?\n end",
"def init(data=[], options={}, user_options={})\n # Alternate way is using `add_series` method.\n #\n # There are many options present in Highcharts so it is better to use\n # directly all the options. That means Daru::View::Plot will\n # behave same as LazyHighCharts when `data` is an Array and\n # `options` are passed.\n #\n @chart = LazyHighCharts::HighChart.new do |f|\n # all the options present in `options` and about the\n # series (means name, type, data) used in f.series(..)\n f.options = options.empty? ? LazyHighCharts::HighChart.new.defaults_options : options\n # For multiple series when data is in a series format as in\n # HighCharts official examples\n # TODO: Add support for multiple series when data as\n # Daru::DataFrame/Daru::Vector\n if data.is_a?(Array) && data[0].is_a?(Hash)\n f.series_data = data\n else\n data_new = guess_data(data)\n series_type = options[:type] unless options[:type].nil?\n series_name = options[:name] unless options[:name].nil?\n f.series(type: series_type, name: series_name, data: data_new)\n end\n end\n @chart.user_options = user_options\n @chart\n end",
"def set_legend\n return set_labels if type.to_s =~ /pie|pie_3d|meter/\n\n if legend.is_a?(Array)\n \"chdl=#{@legend.map{|label| \"#{CGI::escape(label.to_s)}\"}.join('|')}\"\n else\n \"chdl=#{legend}\"\n end\n\n end",
"def initialize(frame, options = {})\n @style = 18\n @view_3D = nil\n @graphic_frame = frame\n @graphic_frame.anchor.drawing.worksheet.workbook.charts << self\n @series = SimpleTypedList.new Series\n @show_legend = true\n @legend_position = :r\n @display_blanks_as = :gap\n @series_type = Series\n @title = Title.new\n @bg_color = nil\n @plot_visible_only = true\n @rounded_corners = true\n parse_options options\n start_at(*options[:start_at]) if options[:start_at]\n end_at(*options[:end_at]) if options[:end_at]\n yield self if block_given?\n end",
"def series(label, d, opts = {})\n if opts.blank?\n @data << series_options.merge(:label => label, :data => d)\n else\n @data << opts.merge(:label => label, :data => d)\n end\n end",
"def initialize(chart, options = {})\n @show_marker = false\n @marker_symbol = options[:marker_symbol] || :default\n @smooth = false\n @labels, @data = nil, nil\n super(chart, options)\n @labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?\n @data = NumDataSource.new(options) unless options[:data].nil?\n end",
"def hash\n [type, name, data_source_for_series_name, is_color_varied, inverted_solid_fill_color, smooth, plot_on_second_axis, order, invert_if_negative, explosion, marker, fill_format, effect_format, line_format, data_point_type, data_points, number_format_of_values, data_source_for_values, show_connector_lines, quartile_method, show_inner_points, show_mean_line, show_mean_markers, show_outlier_points].hash\n end",
"def graph\n @data = @category.to_graph_points\n\n @series = [{ values: @data, key: @category.name }]\n\n @title = \"Spending for #{@category.name}\"\n end",
"def serializable_hash(options={})\n options = {\n :methods=>[:attr_names, :dataset, :questions, :max_series_count],\n :chart_series=>{\n :methods=>[:attribute_name, :short_name]\n }\n }.update(options)\n super(options)\n end",
"def generateSeriesPlot(xyData, options={})\n plotOptions={:width=>200, :height=>100, :imagetype=> \"png\", :xlabel=> \"\", :ylabel=> \"\"}\n plotOptions=plotOptions.merge(options)\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.terminal \"#{plotOptions[:imagetype]} small enhanced size #{plotOptions[:width]},#{plotOptions[:height]} crop\"\n plot.output Rails.root.to_s+\"/public/series.png\"\n plot.ylabel plotOptions[:ylabel]\n plot.xlabel plotOptions[:xlabel]\n plot.boxwidth 0.5\n plot.grid \"\"\n plot.data << Gnuplot::DataSet.new( xyData ) do |ds|\n ds.with = \"boxes fill solid 0.5\"\n ds.notitle\n end\n end\n end\n end",
"def legend\r\n border(31)\r\n tab(11, \"Locations\", \"-\" * 31)\r\n tab(5, \"Top row: t1, t2, t3\")\r\n tab(5, \"Middle row: m1, m2, m3\")\r\n tab(5, \"Bottom row: b1, b2, b3\", \"-\" * 31)\r\n end",
"def ctrlSetTooltip _obj, _args\n \"_obj ctrlSetTooltip _args;\" \n end",
"def plot_strategy(data,compare_data)\n your_color = ['#C7E6F2','#70D2E5', '#44BBDF']\n name = ['L1 Questions', 'L2 Questions', 'L3 Questions']\n comparison_color = ['#D9D9D9', '#B2B2B2', '#8C8C8C']\n @yours = PlotGraph::Graphs.percentage name, data, your_color, \"Strategy over the days\", \"No of questions attended\"\n @yours_compare = PlotGraph::Graphs.percentage name, data, your_color, 200, \"Strategy over the days\", \"No of questions attended\"\n @comparison = PlotGraph::Graphs.percentage name, compare_data, comparison_color, 200, \"Strategy over the days\", \"No of questions attended\"\n @comparison = [@yours_compare, @comparison]\n end",
"def initialize(frame, options={})\n @scatterStyle = :lineMarker\n @xValAxId = rand(8 ** 8)\n @yValAxId = rand(8 ** 8)\n @xValAxis = ValAxis.new(@xValAxId, @yValAxId)\n @yValAxis = ValAxis.new(@yValAxId, @xValAxId)\n super(frame, options)\n @series_type = ScatterSeries\n @d_lbls = nil\n parse_options options\n end",
"def plot_params\n params.require(:plot).permit( :name, :desc )\n end",
"def plot_fixed_dataset(**options)\n options = {:sort => false, :reverse => false }.merge(options)\n data = [30, 234, 4, 123, 200, 89, 189, 10,]\n data.sort!() if options[:sort]\n data.reverse!() if options[:reverse]\n graph.plot(data, {:line => 'i', :frame => false, :tags => true})\n end",
"def simple_chart\n \n end",
"def series(opts = {})\n @data ||= []\n if opts.blank?\n @data << series_options.merge(:name => label, :data => d)\n else\n @data << opts.merge(:name => opts[:name], :data => opts[:data])\n end\n end",
"def multiple_series\n render :layout => false\n end",
"def legend(*labels)\n labels.each.with_index do |l, i|\n @dataxy[i][0] = l\n end\n end",
"def labels=(v) DataTypeValidator.validate \"Series.labels\", [AxDataSource], v; @labels = v; end",
"def labels=(v) DataTypeValidator.validate \"Series.labels\", [AxDataSource], v; @labels = v; end",
"def index\n # @dog_expenses = DogExpense.all\n @dog_expenses = DogExpense.order(charge_date: :desc)\n \n\n @colors = Charge.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n @colors2 = Charge.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n\n # @chart = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 50, 50, 50]})\n # f.series({type: 'pie',\n # name: 'Charge in USD',\n # data: Charge.all.map{|c| [\"#{c.name} - (#{c.dog_expenses.where(currency: 'USD').sum(:amount).to_f}) - (#{c.dog_expenses.where(currency: 'USD').size})\", c.dog_expenses.where(currency: 'USD').sum(:amount).to_f ]},\n # colors: @colors,\n # showInLegend: false,\n # center: [210,100],\n # size: 160\n # })\n # f.series({type: 'pie',\n # name: 'Charge in TW',\n # data: Charge.all.map{|c| [\"#{c.name} - (#{c.dog_expenses.where(currency: 'TW').sum(:amount).to_f}) - (#{c.dog_expenses.where(currency: 'TW').size})\", c.dog_expenses.where(currency: 'TW').sum(:amount).to_f]},\n # colors: @colors2,\n # showInLegend: false,\n # center: [800,100],\n # size: 160\n # })\n # f.options[:title][:text] = \"Expenses by USD & TW\"\n # f.legend(:layout=> 'vertical',:width => 220,:borderWidth => 0, align: 'center', verticalAlign: 'bottom') \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\"\n # }\n # })\n # end\n\n respond_to do |format|\n format.html\n format.csv {send_data @dog_expenses.to_csv}\n format.xls\n end\n end",
"def add_tooltip(options)\n if options.keys.include?(:tooltip)\n options[:rel] = 'tooltip'\n\n # tooltip class\n if options.keys.include?(:tooltip_class)\n options[:class] += \" #{options[:tooltip_class]}\"\n else\n options[:class] += ' tooltipped'\n end\n\n # placement of the tooltip\n if options.keys.include?(:tooltip_placement)\n options['data-placement'] = options[:tooltip_placement]\n else\n options['data-placement'] = 'top'\n end\n end\n\n options\n end",
"def args\n plot_coordinates = []\n all_scenarios.each do |scenario|\n line = {\n x: all_years_sequenced,\n y: y_values_grouped_by_secnario_id_sequenced[scenario.id],\n name: scenario.name,\n hoverinfo: 'none',\n line: {color: scenario.colour.hex}\n }\n plot_coordinates << line\n end\n plot_coordinates\n end",
"def index\n @datebodydata = Datebodydatum.order(\"date\")\n require 'date'\n if !params[:start_date_search].blank?\n @start_day = Date.parse(params[:start_date_search])\n if !params[:end_date_search].blank?\n @end_day = Date.parse(params[:end_date_search]) + 1\n else\n @end_day = @start_day + 7\n end\n#X軸間隔設定\n tickInterval = 1\n#データ取得\n @data = @datebodydata.where(:date => @start_day...@end_day)\n#X軸データ取得\n @categories = @data.select(:date).order(\"date\").map{|d| d.date}\n#グラフデータ\n data1 = @data.select(:weight).order(\"date\").map{|d| d.weight.to_f}\n data2 = @data.select(:pulse).order(\"date\").map{|d| d.pulse.to_f}\n data3 = @data.select(:bodytemperature).order(\"date\").map{|d| d.bodytemperature.to_f}\n data4 = @data.select(:bloodpressure).order(\"date\").map{|d| d.bloodpressure.to_i}\n data5 = @data.select(:highbloodpressure).order(\"date\").map{|d| d.highbloodpressure.to_i}\n#グラフ描画\n @graph_data = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'グラフ名')\n#X軸設定反映\n f.xAxis(categories: @categories, tickInterval: tickInterval)\n\n#Y軸設定\n f.options[:yAxis] = [\n#yAxis: 0\n { title: { text: '体重' }, min: 30, max: 130, tickInterval: 10},\n#yAxis: 1\n { title: { text: '血圧' }, min: 50, max: 150, tickInterval: 10},\n#yAxis: 2\n { title: { text: '脈拍' }, min: 50, max: 150, tickInterval: 10, opposite: true},\n#yAxis: 3\n { title: { text: '体温' }, min: 35, max: 41, tickInterval: 0.5, opposite: true }\n ]\n#グラフ設定\n f.series(\n#グラフ名\n name: '体重',\n#グラフデータ\n data: data1,\n#グラフタイプ\n type: 'column',\n#Y軸指定\n yAxis: 0,\n#グラフ単位\n tooltip: { valueSuffix: 'Kg'},\n#グラフにカーソルを合わせた時に説明を出すかどうかの設定。defaultはtrue\n enableMouseTracking: true\n )\n f.series(name: '最低血圧', data: data4, type: 'column', yAxis: 1,\n tooltip: { valueSuffix: 'mmHg'}\n )\n f.series(name: '最高血圧', data: data5, type: 'column', yAxis: 1,\n tooltip: { valueSuffix: 'mmHg'}\n )\n f.series(name: '脈拍', data: data2, type: 'line', yAxis: 2,\n tooltip: { valueSuffix: '回'}\n )\n f.series(name: '体温', data: data3, type: 'line', yAxis: 3,\n tooltip: { valueSuffix: '°C'},\n plotLines: [{ value: 0, width: 1, color: '#808080' }]\n )\n end\n else\n redirect_to root_path \n end\n end",
"def kwargs\n super.merge(\n {\n style: { type: 'scatter' }\n }\n )\n end",
"def chart_feature \n @feature = params[:feature]\n chart = Ziya::Charts::Column.new( @license ) \n chart.add( :axis_category_text, @date_series )\n chart.add( :series, @feature, MoleLog.compute_series( @feature, @app_name, @min_date, @max_date ) )\n chart.add( :theme, \"moles\" ) \n chart.add( :user_data, :delay, rand( 10 ) + REFRESH_RATE )\n chart.add( :user_data, :url, \"/graphs/update_feature?feature=#{CGI.escape(@feature)}\") \n render :xml => chart.to_xml\n end",
"def getchart()\n # Use random table to generate a random series. The random table is set to 1 col x\n # 51 rows, with 9 as the seed\n rantable = ChartDirector::RanTable.new(9, 1, 51)\n\n # Set the 1st column to start from 100, with changes between rows from -5 to +5\n rantable.setCol(0, 100, -5, 5)\n\n # Get the 1st column of the random table as the data set\n data = rantable.getCol(0)\n\n # Create a XYChart object of size 600 x 300 pixels\n c = ChartDirector::XYChart.new(600, 300)\n\n # Set the plotarea at (50, 35) and of size 500 x 240 pixels. Enable both the\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 35, 500, 240).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"LOWESS Generic Curve Fitting Algorithm\", \"timesbi.ttf\", 18)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Set the x axis scale from 0 - 50, with major tick every 5 units and minor tick\n # every 1 unit\n c.xAxis().setLinearScale(0, 50, 5, 1)\n\n # Add a blue layer to the chart\n layer = c.addLineLayer2()\n\n # Add a red (0x80ff0000) data set to the chart with square symbols\n layer.addDataSet(data, 0x80ff0000).setDataSymbol(ChartDirector::SquareSymbol)\n\n # Set the line width to 2 pixels\n layer.setLineWidth(2)\n\n # Use lowess for curve fitting, and plot the fitted data using a spline layer with\n # line width set to 3 pixels\n c.addSplineLayer(ChartDirector::ArrayMath.new(data).lowess().result(), 0x0000ff\n ).setLineWidth(3)\n\n # Set zero affinity to 0 to make sure the line is displayed in the most detail\n # scale\n c.yAxis().setAutoScale(0, 0, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def to_flot\n [\n { label: \"Pageviews\", data: pageviews },\n { label: \"Downloads\", data: downloads }\n ]\n end",
"def initialize(frame, options={})\n @vary_colors = false\n @grouping = :standard\n super(frame, options)\n @series_type = LineSeries\n @d_lbls = nil\n end",
"def set_legend(params)\n # Convert the user default properties to internal properties.\n legend_properties(params)\n end",
"def feedbackchart\n \n end",
"def initialize(chart, options={})\n @xData, @yData = nil\n super(chart, options)\n\n @xData = NamedAxisData.new(\"xVal\", options[:xData]) unless options[:xData].nil?\n @yData = NamedAxisData.new(\"yVal\", options[:yData]) unless options[:yData].nil?\n end",
"def legend_params\n params.require(:legend).permit(:FX_rate, :currency, :name, :year_avg_id, :currency_prefix, :status, :createdOn)\n end",
"def portfolio_line_chart interval=\"5minute\", opts={span: \"day\"}\n get_portfolio_history get_accounts.first[\"account_number\"], interval, opts\n columns = [ {role: :none, data: ['number', 'X']} ] # add x axis\n\n # each stock has a value and a tooltip\n columns = columns + \n [\n {role: :none, data: ['number', \"Portfolio\"]},\n {role: :tooltip, data: {type: :string, role: :tooltip}}\n ]\n\n rows = []\n @portfolio_history[\"equity_historicals\"].each_with_index do |h,i|\n rows[i] ||= [i+1]\n price = (opts[:span] == \"day\" ? h[\"adjusted_open_equity\"] : h[\"adjusted_close_equity\"]).to_f\n date = h[\"begins_at\"].in_time_zone('EST').strftime '%m/%d/%y %l:%M%P'\n rows[i] = rows[i] + [price, \"$#{price} on #{date}\"]\n end\n \n previous_close_price = @portfolio_history[\"adjusted_previous_close_equity\"].to_f\n previous_close_price = @portfolio_history[\"equity_historicals\"].first[\"adjusted_open_equity\"].to_f if previous_close_price == 0.0\n most_recent_price = @portfolio_history[\"equity_historicals\"].last[\"adjusted_open_equity\"].to_f\n color = most_recent_price > previous_close_price ? ROBINHOOD_GREEN : ROBINHOOD_ORANGE\n options = {\n #title: \"Price chart\",\n hAxis: {\n #title: 'Date',\n ticks: 'none', #rows.map{ |r| r.first },\n gridlines: {color: \"transparent\"}\n },\n vAxis: {\n #title: 'Price',\n gridlines: {color: \"transparent\"}\n },\n focusTarget: :category, # show all tooltips for column on hover,\n #curveType: :function, # curve lines, comment out to disable\n legend: :none,\n chartArea: { width: '90%', height: '75%' },\n series: {\"0\": {color: color}},\n backgroundColor: \"#090d16\"\n }\n \n {columns: columns, rows: rows, options: options}\n end",
"def plot_1d\n plotter = Plotter.new(:title => \"Signal: values vs. sample number\", :xtitle => \"sample number\", :ytitle => \"sample value\")\n plotter.plot_1d \"signal data\" => @data\n end",
"def add_circle_plot_legend(closed_label, open_label, rotated, x_start, y_start, plot_below=false)\n\n circle_center_y = @box_size\n circle_center_x = @box_size\n font_size = standard_font_size\n\n # Place legend after or before end of the x_start\n if rotated\n x_start -= @box_size/1.1\n text_rotate = 90\n anchor = 'start'\n text_adjust = circle_center_x-@box_size * Math.sqrt(2)*0.125\n y_adjust = @box_size * Math.sqrt(2)*0.125+@box_size/2\n elsif plot_below\n if @font_size_multiple == 1.0\n x_start -= @box_size * 7\n else\n x_start -= @box_size * 10\n end\n y_start += @box_size * 9\n text_adjust = circle_center_x+@box_size * Math.sqrt(2)*0.125 + @box_size/4\n y_adjust = @box_size * Math.sqrt(2)*0.125\n text_rotate = 0\n anchor = 'start'\n else\n x_start += -@box_size\n text_rotate = 0\n anchor = 'start'\n text_adjust = circle_center_x+@box_size * Math.sqrt(2)*0.125 + @box_size/4\n y_adjust = @box_size * Math.sqrt(2)*0.125\n end\n\n # need circles followed by text\n @canvas.g.translate(x_start,y_start) do |check|\n check.styles(:fill=>'black', :stroke=>'black', :stroke_width=>1, :fill_opacity=>0.9)\n\n\t # need to draw a circle with point above or below line\n\t check.circle(@box_size * Math.sqrt(2)*0.125, circle_center_x, circle_center_y)\n\t end\n\n\t @canvas.g.translate(x_start, y_start).text(text_adjust, circle_center_y + y_adjust).rotate(text_rotate) do |text|\n\t text.tspan(closed_label).styles(:font_size=>font_size, :text_anchor=>anchor)\n\t end\n\n\t if rotated\n\t circle_center_x -= @box_size/1.5\n\t text_adjust = circle_center_x-@box_size * Math.sqrt(2)*0.125\n\t elsif plot_below\n\t if @font_size_multiple == 1.0\n \t circle_center_x += @box_size * 3\n \t else\n \t circle_center_x += @box_size * 4\n \t end\n\t text_adjust = circle_center_x+@box_size * Math.sqrt(2)*0.125 + @box_size/4\n\t else\n circle_center_y += @box_size\n\t end\n\n # need circles followed by text\n @canvas.g.translate(x_start,y_start) do |check|\n check.styles(:fill=>'none', :stroke=>'black', :stroke_width=>1, :fill_opacity=>0.0)\n\t # need to draw a circle with point above or below line\n\t check.circle(@box_size * Math.sqrt(2)*0.125, circle_center_x, circle_center_y)\n\t end\n\n\t @canvas.g.translate(x_start, y_start).text(text_adjust, circle_center_y + y_adjust).rotate(text_rotate) do |text|\n\t text.tspan(open_label).styles(:font_size=>font_size, :text_anchor=>anchor)\n\t end\n\n end",
"def legend_name\n short_name\n end",
"def initialize(frame, options={})\n @vary_colors = true\n super(frame, options)\n @series_type = RadarSeries\n @d_lbls = nil\n end",
"def legend\n \"Current user: #{@current_user.name}\"\n end",
"def lbSetTooltip _args\n \"lbSetTooltip _args;\" \n end",
"def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [170, 300, 1000, 1700]\n dataY0 = [16, 69, 16, 75]\n dataZ0 = [52, 105, 88, 140]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [40, 58, 85]\n dataZ1 = [140, 202, 84]\n\n # Create a XYChart object of size 540 x 480 pixels\n c = ChartDirector::XYChart.new(540, 480)\n\n # Set the plotarea at (70, 65) and of size 400 x 350 pixels. Turn on both\n # horizontal and vertical grid lines with light grey color (0xc0c0c0)\n c.setPlotArea(70, 65, 400, 350, -1, -1, ChartDirector::Transparent, 0xc0c0c0, -1)\n\n # Add a legend box at (70, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(70, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with red (ff3333) glass spheres, where\n # the sphere size is modulated by dataZ0. This creates a bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\",\n ChartDirector::GlassSphere2Shape, 15, 0xff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with blue (0000ff) glass spheres, where\n # the sphere size is modulated by dataZ1. This creates a bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\",\n ChartDirector::GlassSphere2Shape, 15, 0x0000ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def write_chart_type; end",
"def get_chart_options(visualization_id)\n visualization = Visualization.find(visualization_id)\n options = Hash.new\n\n options[:title] = visualization.chart_title\n options[:download] = true\n options[:xtitle] = visualization.x_axis_title\n options[:ytitle] = visualization.y_axis_title\n options[:donut] = true;\n\n return options\n\n end",
"def getchart()\n # The data for the area chart\n data = [3.0, 2.8, 4.0, 5.5, 7.5, 6.8, 5.4, 6.0, 5.0, 6.2, 7.5, 6.5, 7.5, 8.1, 6.0,\n 5.5, 5.3, 3.5, 5.0, 6.6, 5.6, 4.8, 5.2, 6.5, 6.2]\n\n # The labels for the area chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 300 x 180 pixels. Set the background to pale\n # yellow (0xffffa0) with a black border (0x0)\n c = ChartDirector::XYChart.new(300, 180, 0xffffa0, 0x000000)\n\n # Set the plotarea at (45, 35) and of size 240 x 120 pixels. Set the background to\n # white (0xffffff). Set both horizontal and vertical grid lines to black (&H0&)\n # dotted lines (pattern code 0x0103)\n c.setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, c.dashLineColor(0x000000,\n 0x000103), c.dashLineColor(0x000000, 0x000103))\n\n # Add a title to the chart using 10 pts Arial Bold font. Use a 1 x 2 bitmap\n # pattern as the background. Set the border to black (0x0).\n c.addTitle(\"Snow Percipitation (Dec 12)\", \"arialbd.ttf\", 10).setBackground(\n c.patternColor([0xb0b0f0, 0xe0e0ff], 2), 0x000000)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"mm per hour\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis.\n c.xAxis().setLabelStep(3)\n\n # Add an area layer to the chart\n layer = c.addAreaLayer()\n\n # Load a snow pattern from an external file \"snow.png\".\n snowPattern = c.patternColor2(File.dirname(__FILE__) + \"/snow.png\")\n\n # Add a data set to the area layer using the snow pattern as the fill color. Use\n # deep blue (0x0000ff) as the area border line color (&H0000ff&)\n layer.addDataSet(data).setDataColor(snowPattern, 0x0000ff)\n\n # Set the line width to 2 pixels to highlight the line\n layer.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [150, 300, 1000, 1700]\n dataY0 = [12, 60, 25, 65]\n dataZ0 = [20, 50, 50, 85]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [35, 50, 75]\n dataZ1 = [30, 55, 95]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0x80ff3333)\n # circle symbols, where the circle size is modulated by dataZ0. This creates a\n # bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\", ChartDirector::CircleSymbol,\n 9, 0x80ff3333, 0x80ff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with semi-transparent green (0x803333ff)\n # circle symbols, where the circle size is modulated by dataZ1. This creates a\n # bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\", ChartDirector::CircleSymbol,\n 9, 0x803333ff, 0x803333ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def axes3d(*)\n super\n end",
"def getchart()\n # The data for the chart\n data0 = [32, 39, 23, 28, 41, 38, 26, 35, 29]\n data1 = [50, 55, 47, 34, 47, 53, 38, 40, 51]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a pale red (ffdddd)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xffdddd, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a dark red (880000) background, with soft lighting effect from the right\n # side.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x880000, -1, ChartDirector::softLighting(ChartDirector::Right\n ))\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Energy Concentration (KJ per liter)\")\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a spline layer to the chart\n layer = c.addSplineLayer()\n\n # Set the default line width to 2 pixels\n layer.setLineWidth(2)\n\n # Add a data set to the spline layer, using blue (0000c0) as the line color, with\n # yellow (ffff00) circle symbols.\n layer.addDataSet(data1, 0x0000c0, \"Target Group\").setDataSymbol(\n ChartDirector::CircleSymbol, 9, 0xffff00)\n\n # Add a data set to the spline layer, using brown (982810) as the line color, with\n # pink (f040f0) diamond symbols.\n layer.addDataSet(data0, 0x982810, \"Control Group\").setDataSymbol(\n ChartDirector::DiamondSymbol, 11, 0xf040f0)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def show\n @user = User.find(params[:id])\n @time_now = Time.now.utc.at_midnight\n\n @event_data = Array.new\n @activity_data = Array.new\n @user.events.each do |event|\n if event.event_type == 3\n date_start = (event.activity_since.utc.to_f*1000.0).to_i\n # date_end = (event.entered_at.utc.to_f*1000.0).to_i\n @activity_data.push({x: date_start, y: event.activity_type, name: ACTIVITY_TYPE[event.activity_type]})\n # @activity_data.push({x: date_end, y: event.activity_type, name: ACTIVITY_TYPE[event.activity_type]})\n else\n date = (event.entered_at.utc.to_f*1000.0).to_i\n @event_data.push({x: date, y: (event.event_type+6), name: EVENT_TYPE[event.event_type]})\n end\n end\n\n\n @h = LazyHighCharts::HighChart.new('graph') do |f|\n f.chart( zoomType: 'x')\n f.title( text: @user.first_name + \" \" + @user.last_name + ' ' + 'activity and events')\n f.tooltip(\n # useHTML: true,\n # headerFormat: '<small>{point.key} + {point.name} </small><table>',\n # pointFormat: \"<tr><td style=\\\"color: {series.color}\\\">{series.name}: </td>\" + \"<td style=\\\"text-align: right\\\"><b>{point.y}</b></td></tr>\",\n crosshairs: true, followPointer: true,\n xDateFormat: '%Y-%m-%d',\n shared: true,\n # footerFormat: '</table>'\n )\n\n f.yAxis(\n min: 0,\n max: 11,\n categories: [nil, \"Steady\", \"Walking\", \"Biking\", \"Running\", \"\", \"Pain\", \"Meal\", \"Medicine\", \"Activity Change\", \"Other\", \"\"],\n minorGridLineWidth: 1,\n gridLineWidth: 1,\n alternateGridColor: nil,\n tickInterval: 1,\n minTickInterval: 1,\n tickmarkPlacement: 'on',\n plotBands: [{\n from: 0,\n to: 5,\n color: 'rgba(68, 170, 213, 0.1)',\n label: {\n text: 'Activity',\n style: {\n color: '#606060'\n }\n }\n }, {\n from: 5,\n to: 10,\n color: 'rgba(0, 0, 0, 0)',\n label: {\n text: 'Event',\n style: {\n color: '#606060'\n }\n }\n }\n ]\n )\n f.xAxis type: 'datetime'\n\n f.series(type: 'line', :name=>'Activity', :data=>@activity_data, pointStart: (@time_now.to_f*1000.0).to_i, step: \"left\")\n f.series(type: 'line', lineWidth: 0, :name=>'Event', :data=>@event_data, pointStart: (@time_now.to_f*1000.0).to_i)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def getchart()\n # The data for the chart\n data0 = [100, 100, 100, 100, 100]\n data1 = [90, 85, 85, 80, 70]\n data2 = [80, 65, 65, 75, 45]\n\n # The labels for the chart\n labels = [\"Population<*br*><*font=arial.ttf*>6 millions\",\n \"GDP<*br*><*font=arial.ttf*>120 billions\",\n \"Export<*br*><*font=arial.ttf*>25 billions\",\n \"Import<*br*><*font=arial.ttf*>24 billions\",\n \"Investments<*br*><*font=arial.ttf*>20 billions\"]\n\n # Create a PolarChart object of size 480 x 460 pixels. Set background color to\n # silver, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 460, ChartDirector::silverColor(),\n 0x000000, 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep green (008000) background\n c.addTitle(\"Economic Growth\", \"timesbi.ttf\", 15, 0xffffff).setBackground(0x008000)\n\n # Set plot area center at (240, 270), with 150 pixels radius\n c.setPlotArea(240, 270, 150)\n\n # Use 1 pixel width semi-transparent black (c0000000) lines as grid lines\n c.setGridColor(0xc0000000, 1, 0xc0000000, 1)\n\n # Add a legend box at top-center of plot area (240, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with silver background and 1 pixel 3D border effect.\n b = c.addLegend(240, 35, false, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add area layers of different colors to represent the data\n c.addAreaLayer(data0, 0xcc8880, \"Year 2004\")\n c.addAreaLayer(data1, 0xffd080, \"Year 1994\")\n c.addAreaLayer(data2, 0xa0bce0, \"Year 1984\")\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Set radial axis from 0 - 100 with a tick every 20 units\n c.radialAxis().setLinearScale(0, 100, 20)\n\n # Just show the radial axis as a grid line. Hide the axis labels by setting the\n # label color to Transparent\n c.radialAxis().setColors(0xc0000000, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def show\n x = @plot.user.x\n y = @plot.user.y\n puts x\n puts y\n \n end",
"def series_type\n end",
"def piechart (synonym_id, type)\n synonym = Synonym.find(synonym_id)\n if type == @@GENDER\n stats = synonym.get_visual_stats_gender\n header = t(:stats_gender)\n elsif type == @@COUNTRY\n stats = synonym.get_visual_stats_country\n header = t(:stats_country)\n elsif type == @@AGE\n stats = synonym.get_visual_stats_age\n header = t(:stats_age)\n else\n stats = synonym.get_visual_stats_education\n header = t(:stats_education)\n end\n chart = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [0, 10, 150,25], :width => 157, :hieght => 50} )\n series = {\n :type=> 'pie',\n :name=> 'Browser share',\n :borderWidth => 0.7,\n :data=> stats\n\n }\n f.series(series)\n f.options[:title][:text] = header\n f.options[:title][:x] = 0\n\n f.legend(:layout=> 'vertical',:style=> {:left=> '0px', :bottom=> '0px',:right=> '0px',:top=> '0px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" ,\n :size =>'100%', \n :dataLabels=>{\n :enabled=>false,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end",
"def legend=(value)\n @legend = value\n end",
"def make_boxplot_graph(data, xlabels, min_temp, max_temp, title) \n num = data[data.keys.first].length\n # inset data\n data.keys.each do |k| \n data[k].unshift(-1)\n data[k].push(-1)\n end\n # inset labels\n xlabels.unshift(\"\")\n xlabels.push(\"\")\n # build url \n base = \"\"\n # url\n #base << next_chart_url \n base << \"/chart?\" \n \n # graph size\n base << \"chs=600x240&\"\n # graph title\n base << \"chtt=#{title}&\"\n # graph type\n base << \"cht=lc&\"\n # visible axes\n base << \"chxt=x,y&\"\n # axis ranges \n base << \"chxr=1,#{min_temp},#{max_temp},#{(max_temp-min_temp)/10.0}&\"\n # range for scaling data\n base << \"chds=#{min_temp},#{max_temp}&\"\n # axis labels\n base << \"chxl=0:|#{xlabels.join('|')}&\"\n # build series\n serieses = []\n serieses << data[:min].join(',')\n serieses << data[:q1].join(',')\n serieses << data[:q3].join(',')\n serieses << data[:max].join(',')\n serieses << data[:med].join(',')\n base << \"chd=t0:#{serieses.join('|')}&\" \n # build display\n display = []\n display << \"F,FF0000,0,1:#{num},40\"\n display << \"H,FF0000,0,1:#{num},1:20\"\n display << \"H,FF0000,3,1:#{num},1:20\"\n display << \"H,000000,4,1:#{num},1:40\"\n base << \"chm=#{display.join('|')}\"\n\n puts \"DEBUG: graph length = #{base.length}\"\n return base\n end",
"def plot_timedistribution( your_data, compare_data )\n your_color = ['#C7E6F2','#70D2E5', '#44BBDF']\n name = ['Time L1 Questions', 'Time L2 Questions', 'Time L3 Questions']\n comparison_color = ['#D9D9D9', '#B2B2B2', '#8C8C8C']\n @yours = PlotGraph::Graphs.percentage name, your_data, your_color, \"Time distribution over the days\", \"No of questions attended\"\n @yours_compare = PlotGraph::Graphs.percentage name, your_data, your_color, 200, \"Time distribution over the days\", \"No of questions attended\"\n @comparison = PlotGraph::Graphs.percentage name, compare_data, comparison_color, 200, \"Time distribution over the days\", \"No of questions attended\"\n @comparison = [@yours_compare, @comparison]\n end"
] | [
"0.6519339",
"0.6435553",
"0.6315414",
"0.6166688",
"0.61170375",
"0.61118585",
"0.60911965",
"0.6042981",
"0.5959802",
"0.5945858",
"0.5863141",
"0.58454424",
"0.5831566",
"0.58306175",
"0.5789699",
"0.5780289",
"0.5719986",
"0.5702264",
"0.5658842",
"0.56321466",
"0.56189096",
"0.5613021",
"0.5610815",
"0.5610815",
"0.5598521",
"0.5584846",
"0.5578114",
"0.55752444",
"0.55693775",
"0.55367076",
"0.5513888",
"0.54884446",
"0.54768926",
"0.54768234",
"0.5450022",
"0.5450022",
"0.5450022",
"0.5450022",
"0.54109204",
"0.54086876",
"0.54067284",
"0.536692",
"0.53514814",
"0.5329773",
"0.5321943",
"0.5321214",
"0.5283418",
"0.5278335",
"0.5275435",
"0.52400947",
"0.5234717",
"0.5230181",
"0.52219373",
"0.5220909",
"0.52202153",
"0.5219343",
"0.52025604",
"0.5202505",
"0.51982784",
"0.5196915",
"0.5187118",
"0.51826185",
"0.5180038",
"0.51734936",
"0.51734936",
"0.5171202",
"0.5160828",
"0.5158689",
"0.51565915",
"0.51535535",
"0.51505065",
"0.5132537",
"0.5132483",
"0.51285666",
"0.5119705",
"0.5107957",
"0.51050425",
"0.5061937",
"0.5059346",
"0.5057704",
"0.50501597",
"0.50480723",
"0.5047762",
"0.50414073",
"0.50288916",
"0.50232023",
"0.50222003",
"0.50211555",
"0.5020898",
"0.5012314",
"0.5007457",
"0.5004352",
"0.5003613",
"0.50011635",
"0.49950692",
"0.49873665",
"0.49819562",
"0.49777988",
"0.49744654",
"0.49724653"
] | 0.68676376 | 0 |
Pass other methods through to the javascript high_chart object. For instance: high_chart.grid(:color => "699") | def method_missing(meth, opts = {})
merge_options meth, opts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n javascript_tag \"$(function(){\" +\n \"new Highcharts.Chart({\" +\n to_json +\n \"})\" +\n \"});\"\n end",
"def basic_chart\n \n end",
"def show\n @chart = Chart.find(params[:id])\n @chartnodes = @chart.chartnodes\n data = @chart.chartnodes.map {|node| [node.xaxis, node.yaxis]}.transpose\n if @chart.charttype == 'column'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'column',:name=> @chart.name,:data=> data[1])\n end\n elsif @chart.charttype == 'spline'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'spline',:name=> @chart.name,:data=> data[1])\n f.plot_options( :spline => {\n :dataLabels => {\n :enabled => true\n }})\n f.tooltip( :crosshairs => true, :shared => true)\n end\n elsif @chart.charttype == 'pie'\n @h1 = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> 'pie',\n :name=> @chart.name,\n :data=> data.transpose\n }\n f.series(series)\n f.options[:title][:text] = \"Browser share\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n #:cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chart }\n end\n end",
"def simple_chart\n \n end",
"def beanplot\n end",
"def show\n \n @end_at = Date.today\n @start_at = @end_at - 6\n @categories = @start_at.upto(@end_at).to_a\n\n \t#Sales Historyグラフ\n @sales_data = [500, 600, 300, 100, 200, 400, 700,500, 600, 300, 100, 200, 400, 700,100, 200, 400, 700,500, 600, 600, 300, 100, 200,]\n @sales_history = LazyHighCharts::HighChart.new(\"graph\") do |f|\n f.title(:text => \"Sales History\", :align =>\"left\")\n f.chart(:type => \"column\")\n f.xAxis(:categories => @categories)\n f.series(:name => \"Sales\", :data => @sales_data)\n\t end\n\n#Order Historyのグラフ\n @order_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @order_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @order_data)\n end\n\n#Price Historyのグラフ\n @price_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @price_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @price_data)\n end\n \n \n end",
"def get_grafico(obj,tipo_grafico)\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>tipo_grafico , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> tipo_grafico,\n :name=> 'Media de precos dos anuncios',\n :data=> obj,\n\n }\n f.series(series)\n\n f.options[:title][:text] = \"Preco por categoria\"\n\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end",
"def get_grafico_precos_medios_cat\n\n obj1 = avg_price_categoria\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"bar\" ,type: 'column',renderTo: 'container', :margin=> [10, 100, 60, 100]} )\n series = {\n :type=> 'column',\n :name=> 'Media de precos por categoria',\n :data=> obj1\n }\n f.series(series)\n f.options[:title][:text] = \"Preco por categoria\"\n f.options[:xAxis] = {\n\n :title => { :text => \"categorias\" },\n :labels => { :enabled => false }\n }\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '50px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\",\n :width => \"250px\",\n :height => \"150px\" \n }\n }\n })\n end\n end",
"def json_data_for_highcharts\n self.to_json.html_safe\n end",
"def get_grafico_anuncio_categoria\n\n obj1 = categoria_percent\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [30, 70, 0, 70]} )\n series = {\n :type=> \"pie\",\n :name=> 'Percentagem de Anuncios por categoria',\n :data=> obj1\n }\n f.series(series)\n f.options[:title][:text] = \"Percentagem de anuncios por categoria\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\",\n :width => \"50px\",\n :height => \"50px\" \n }\n }\n })\n end\n end",
"def series_json(params={})\n # Create data for charts\n color = params[:color] ||= 'AA4643'\n color = '#' + color\n series = []\n data = []\n\n data << [self.baseline_date, (self.baseline.round*100).round / 100.0]\n # For ideal data\n self.progresses.each{|progress| \n data << [progress.due_date, (progress.accuracy*100).round / 100.0]\n }\n data << [self.due_date, (self.accuracy*100).round / 100.0]\n #Sort data by due date\n data = data.sort_by { |hsh| hsh[0] }\n \n series << {\n :type => 'line',\n :name => \"Ideal chart\",\n :data => data\n }\n if color && color == '#4572A7'\n series[0][:color] = \"#AA4643\"\n end\n # For add grade \n data = []\n self.grades.find_each{|grade| \n data << [grade.due_date, (grade.accuracy*100).round / 100.0]\n }\n data = data.sort_by { |hsh| hsh[0] }\n series << {\n :name => self.name,\n :data => data,\n :color => color \n }\n series.to_json\n end",
"def makeChart(*options)\n\ndisplay = \"\n<div class='charts last'>\n\n<div class='left'>\n\n\n<div id='placeholder' style='width:400px;height:200px;'></div>\n<div id='overview' style='width:400px;height:50px'></div>\n<p id='overviewLegend' style='margin-left:10px'></p>\n\n<p> Try zooming. Click and drag to select a zone.</p>\n</div>\n\n<div class='right'>\n\nWeight Chart<br/>\n<div id='miniWeight' style='width:350px;height:100px;'></div>\nWater Chart<br/>\n<div id='miniWater' style='width:350px;height:100px;'></div>\n\n\nCalories Eaten<br/>\n<div id='miniCalorie' style='width:350px;height:100px;'></div>\nFitness (Calories burned not to include resting metabolism)<br/>\n<div id='miniFitness' style='width:350px;height:100px;'></div><br/>\n\nMeasurements (Total inches)<br/>\n<div id='miniMeasures' style='width:350px;height:100px;'></div>\n\n\n</div>\n\n\n\n\n<div class='last'></div>\n<script id='source' language='javascript' type='text/javascript'>\n\n\n$(function () {\nvar options = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { \n show: true, \n container: $('#overviewLegend'),\n noColumns: 2,\n }\n};\n\nvar options_overview = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { show: false}\n};\n\n\nvar plot = $.plot($('#placeholder'), \n[ #{@chartable.to_chart } ], options);\n\n\n\n\nvar overview = $.plot($('#overview'), \n[ #{@chartable.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n\n\n\n\nvar overview_1 = $.plot($('#miniWeight'), \n[ #{@miniWeight.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_2 = $.plot($('#miniWater'), \n[ #{@miniWater.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_3 = $.plot($('#miniCalorie'), \n[ #{@miniCalorie.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_4 = $.plot($('#miniFitness'), \n[ #{@miniFitness.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_5 = $.plot($('#miniMeasures'), \n[ #{@miniMeasures.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n// now connect the two\nvar internalSelection = false;\n\n$('#placeholder').bind('selected', function (event, area) {\n // do the zooming\n plot = $.plot($('#placeholder'), \n [#{@chartable.to_chart}],\n $.extend(true, {}, options, {\n xaxis: { min: area.x1, max: area.x2 }\n }));\n \n if (internalSelection)\n return; // prevent eternal loop\n internalSelection = true;\n overview.setSelection(area);\n internalSelection = false;\n});\n\n$('#overview').bind('selected', function (event, area) {\n if (internalSelection)\n return;\n internalSelection = true;\n plot.setSelection(area);\n internalSelection = false;\n});\n\n\n});\n</script>\n\"\n\nend",
"def show\n @chart = LazyHighCharts::HighChart.new('area') do |f|\n f.title(:text => \"Shots\")\n f.xAxis(:categories => @player.games.pluck(:opponent_name))\n\n f.series(:name => \"Points\", :yAxis => 0, :data => @player.stat_per_game(:points)) \n\n f.series(:name => \"Field Goals\", :yAxis => 0, :data => @player.stat_per_game(:field_goals)) \n\n f.series(:name => \"Free Throws\", :yAxis => 0, :data => @player.stat_per_game(:free_throws)) \n\n f.series(:name => \"Three Pointers\", :yAxis => 0, :data => @player.stat_per_game(:three_pointers)) \n\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n\n f.chart({defaultSeriesType: \"column\"})\n end\n end",
"def piechart (synonym_id, type)\n synonym = Synonym.find(synonym_id)\n if type == @@GENDER\n stats = synonym.get_visual_stats_gender\n header = t(:stats_gender)\n elsif type == @@COUNTRY\n stats = synonym.get_visual_stats_country\n header = t(:stats_country)\n elsif type == @@AGE\n stats = synonym.get_visual_stats_age\n header = t(:stats_age)\n else\n stats = synonym.get_visual_stats_education\n header = t(:stats_education)\n end\n chart = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [0, 10, 150,25], :width => 157, :hieght => 50} )\n series = {\n :type=> 'pie',\n :name=> 'Browser share',\n :borderWidth => 0.7,\n :data=> stats\n\n }\n f.series(series)\n f.options[:title][:text] = header\n f.options[:title][:x] = 0\n\n f.legend(:layout=> 'vertical',:style=> {:left=> '0px', :bottom=> '0px',:right=> '0px',:top=> '0px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" ,\n :size =>'100%', \n :dataLabels=>{\n :enabled=>false,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end",
"def defaults_options\n self.title({ :text=>\"example test title from highcharts gem\"})\n self.legend({ :layout=>\"vertical\", :style=>{} }) \n self.xAxis({})\n self.yAxis({ :title=> {:text=> nil}, :labels=>{} })\n self.tooltip({ :enabled=>true })\n self.credits({ :enabled => false})\n self.plotOptions({ :areaspline => { } })\n self.chart({ :defaultSeriesType=>\"areaspline\" , :renderTo => nil})\n self.subtitle({})\n end",
"def pie_js(fp,renderto,title,seriesname,series,clickfunction = nil)\n\t\tfp.puts <<-eos\n\t\t$(function () {\n\t\t var chart;\n\t\t $(document).ready(function() {\n\t\t chart = new Highcharts.Chart({\n\t\t \tcredits: {\n\t\t \t\tenabled: false\n\t\t \t},\n\t\t chart: {\n\t\t renderTo: '#{renderto}',\n\t\t plotBackgroundColor: null,\n\t\t plotBorderWidth: null,\n\t\t plotShadow: false\n\t\t },\n\t\t title: {\n\t\t text: '#{title}'\n\t\t },\n\t\t tooltip: {\n\t\t formatter: function() {\n\t\t return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %';\n\t\t }\n\t\t },\n\t\t plotOptions: {\n\t\t pie: {\n\t\t \tsize: '60%',\n\t\t allowPointSelect: true,\n\t\t cursor: 'pointer',\n\t\t dataLabels: {\n\t\t enabled: true,\n\t\t color: '#000000',\n\t\t connectorColor: '#000000',\n\t\t formatter: function() {\n\t\t return '<b>'+ this.point.name +'</b>: '+ this.y;\n\t\t },\n\t\t distance: 20\n\t\t }\n\t\teos\n\n\t\tunless clickfunction.nil?\n\t\t\tfp.puts ',events: { click: function(event) { ' + clickfunction + '} }'\n\t\tend\n\n\t\tfp.puts <<-eos\n }\n },\n series: [{\n type: 'pie',\n name: '#{seriesname}',\n data: [\n\t\teos\n\t\tseries.each_with_index do |val,index|\n\t\t\ttmpline = \"\\t\\t\\t{name: '\" + val[0] + \"', y: \" + val[1].to_s + \", color: '\" + val[2] + \"'}\"\n\t\t\ttmpline += \",\" unless index == series.length - 1\n\t\t\tfp.puts tmpline\n\t\tend\n\n\t\tfp.puts <<-eos\n\t\t ]\n\t\t }]\n\t\t });\n\t\t });\n\n\t\t});\n\t\teos\n\n\tend",
"def write_chart_type; end",
"def jqgrid\n\n\tend",
"def init(data=[], options={}, user_options={})\n # Alternate way is using `add_series` method.\n #\n # There are many options present in Highcharts so it is better to use\n # directly all the options. That means Daru::View::Plot will\n # behave same as LazyHighCharts when `data` is an Array and\n # `options` are passed.\n #\n @chart = LazyHighCharts::HighChart.new do |f|\n # all the options present in `options` and about the\n # series (means name, type, data) used in f.series(..)\n f.options = options.empty? ? LazyHighCharts::HighChart.new.defaults_options : options\n # For multiple series when data is in a series format as in\n # HighCharts official examples\n # TODO: Add support for multiple series when data as\n # Daru::DataFrame/Daru::Vector\n if data.is_a?(Array) && data[0].is_a?(Hash)\n f.series_data = data\n else\n data_new = guess_data(data)\n series_type = options[:type] unless options[:type].nil?\n series_name = options[:name] unless options[:name].nil?\n f.series(type: series_type, name: series_name, data: data_new)\n end\n end\n @chart.user_options = user_options\n @chart\n end",
"def to_html\n <<-EOF\n <span id=\"#{container_id}\" class=\"#{chart_css_class}\">\n #{series.join(',')}\n </span>\n EOF\n end",
"def update_visualization(point)\n\t\t\t\t\n\t\t\tend",
"def index\n # @dog_expenses = DogExpense.all\n @dog_expenses = DogExpense.order(charge_date: :desc)\n \n\n @colors = Charge.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n @colors2 = Charge.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n\n # @chart = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 50, 50, 50]})\n # f.series({type: 'pie',\n # name: 'Charge in USD',\n # data: Charge.all.map{|c| [\"#{c.name} - (#{c.dog_expenses.where(currency: 'USD').sum(:amount).to_f}) - (#{c.dog_expenses.where(currency: 'USD').size})\", c.dog_expenses.where(currency: 'USD').sum(:amount).to_f ]},\n # colors: @colors,\n # showInLegend: false,\n # center: [210,100],\n # size: 160\n # })\n # f.series({type: 'pie',\n # name: 'Charge in TW',\n # data: Charge.all.map{|c| [\"#{c.name} - (#{c.dog_expenses.where(currency: 'TW').sum(:amount).to_f}) - (#{c.dog_expenses.where(currency: 'TW').size})\", c.dog_expenses.where(currency: 'TW').sum(:amount).to_f]},\n # colors: @colors2,\n # showInLegend: false,\n # center: [800,100],\n # size: 160\n # })\n # f.options[:title][:text] = \"Expenses by USD & TW\"\n # f.legend(:layout=> 'vertical',:width => 220,:borderWidth => 0, align: 'center', verticalAlign: 'bottom') \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\"\n # }\n # })\n # end\n\n respond_to do |format|\n format.html\n format.csv {send_data @dog_expenses.to_csv}\n format.xls\n end\n end",
"def plot; end",
"def multiple_series\n render :layout => false\n end",
"def series_type\n end",
"def set_series(*args)\n if args.empty?\n matches = to_s.match(/^(.*)Metrics$/)\n @series =\n if matches.nil?\n superclass.respond_to?(:series) ? superclass.series : to_s.underscore\n else\n matches[1].split(\"::\").join(\"_\").underscore\n end\n elsif args.first.is_a?(Proc)\n @series = args.first\n else\n @series = args\n end\n end",
"def color(*args)\n say HighLine.default_instance.color(*args)\n end",
"def draw_chartjs_chart(type, canvas_id, data, colors, title, titlefontsize, responsive)\n %(\n var ctx = document.getElementById(\"chartjs_canvas#{canvas_id}\");\n var myChart = new Chart(ctx, {\n type: '#{type}',\n data: {\n labels: #{data.map{|x| fir(x)}},\n datasets: [{\n label: '#{title}',\n data: #{data.map(&:last)},\n backgroundColor: #{data.map{|x| colors[:\"#{x[0]}\"].to_s}}\n }]\n },\n options: {\n responsive: #{responsive},\n title : {\n display: true,\n text: '#{title}',\n fontSize: #{titlefontsize}\n }\n }\n });\n )\nend",
"def to_html(input_args=Hash.new)\n #puts \"to_html arg #{input_args}\"\n\n reset_chart(input_args)\n \n open_tag('script',script_content)\n open_tag('div',\"\",class: get_chart_size(input_args[:size])[:column]) do\n if @id\n if @do_not_save_chart\n open_tag('small',\"user generated json has no chart expand function\") \n else \n open_tag('small') do\n #open_tag('span','',class: 'chart_btn') do\n # open_tag('a',\"Expand\",href: \"/chart_expand/#{chart_url}\")\n #end\n #if @args[:time] # if time chart, srg wants to button user can click to show status last month\n # open_tag('span','',class: 'chart_btn') do\n # open_tag('a',\"last month\",href: \"/chart_last_month/#{chart_url}\")\n # end\n #end\n if @args[:title] # jason 111516, intentionally write the chart's title here. this one is useful when there are a lot of chart and people can search chart by using browser's search function\n open_tag('span',\"#{@args[:title]}\");\n end\n open_tag('span','',id: 'tooltip_info') do # this field gets populated when user hovers on tool tip\n end\n end\n end\n end\n open_tag('div',\"\",class: get_chart_size(input_args[:size])[:css]) do\n open_tag('canvas',\"\",id: \"#{@chart_id}\" ) do # matches the javascript code which expect to populate LineChart\n end \n end \n end\n @out\n end",
"def to_html_iruby(placeholder=random_canvas_id)\n # TODO : placeholder pass, in plot#div\n chart_hash_must_be_present\n high_chart_iruby(placeholder, self)\n end",
"def index\n @pregnancies = Pregnancy.order('heat_start_date, surgery_date')\n\n @plist = @pregnancies.already_due.order('due_date').map{|x| x.dog.call_name}.to_s.html_safe \n @colors = [ [ \"#8a10ae\" ],[ \"#f45a39\" ],[ \"#fa7083\" ],[ \"#b8ad3c\" ],[ \"#2babf2\" ],[ \"#1dae30\" ],[ \"#b6932d\" ],[ \"#e24436\" ]]\n @puppy_count = Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]}.to_s.html_safe\n \n \n # @chart = LazyHighCharts::HighChart.new('graph') do |f|\n # f.chart({:type => \"column\"})\n # f.title(:text => \"Pregnancies in 2003 as #{Date.today}\")\n # f.xAxis(:categories => @pregnancies.already_due.order('due_date').map{|x| x.dog.call_name})\n \n # # f.tooltip(:formatter => \"function() { return this.x +' '+ this.y + '<br>'+' Total:' + this.point.stackTotal;}\".js_code)\n\n # f.series(:name => \"Puppies survive\", :data => @pregnancies.already_due.order('due_date').map{|x| x.litters.where(survival: true).size})\n # f.series(:name => \"Puppies not survive\", :data => @pregnancies.already_due.order('due_date').map{|x| x.litters.where(survival: false).size})\n \n # f.plotOptions({column:{\n # stacking: 'normal',\n # # pointPadding: 0,\n # groupPadding: 0, \n # dataLabels:{\n # enabled: true,\n # color: 'white'}\n # }})\n\n # f.yAxis( \n # title: { text: \"Puppies\", margin: 50},\n # stackLabels: {\n # style: {color: 'gray'},\n # enabled: true}\n # )\n\n # f.series(:type => \"pie\", :name=> 'puppies', \n # :center=> [150, 80], :size=> 150, :showInLegend=> false,\n # :data =>Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]},\n # :colors => @colors)\n # end\n\n # @colors = Color.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n # @chart3 = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 50, 50, 50]})\n # series = {\n # :type=> 'pie',\n # :name=> 'Browser share',\n # :data=> Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]},\n # # :data => Pregnancy.set_value( Color.all.map{|c| [c.name, c.litters.size]} ),\n # :colors => @colors,\n # showInLegend: false\n # }\n\n # f.series(series)\n # f.options[:title][:text] = \"Puppies by colors\"\n # f.legend(:layout=> 'vertical',:width => 220,:borderWidth => 0, align: 'left', verticalAlign: 'middle') \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\"\n # }\n # })\n # end\n\n # @chart1 = LazyHighCharts::HighChart.new('graph') do |f|\n # f.title({ :text=>\"Combination chart\"})\n # f.options[:xAxis][:categories] = ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']\n # f.labels(:items=>[:html=>\"Total fruit consumption\", :style=>{:left=>\"40px\", :top=>\"8px\", :color=>\"black\"} ]) \n # f.series(:type=> 'column',:name=> 'Jane',:data=> [3, 2, 1, 3, 4])\n # f.series(:type=> 'column',:name=> 'John',:data=> [2, 3, 5, 7, 6])\n # f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])\n # f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])\n # f.series(:type=> 'spline',:name=> 'Average', :data=> [3, 2.67, 3, 6.33, 3.33])\n # f.series(:type=> 'pie',:name=> 'Total consumption', \n # :data=> [\n # {:name=> 'Jane', :y=> 13, :color=> 'red'}, \n # {:name=> 'John', :y=> 23,:color=> 'green'},\n # {:name=> 'Joe', :y=> 19,:color=> 'blue'}\n # ],\n # :center=> [100, 80], :size=> 100, :showInLegend=> false)\n # end \n\n # @chart2 = LazyHighCharts::HighChart.new('graph') do |f|\n # f.title(:text => \"Population vs GDP For 5 Big Countries [2009]\")\n # f.xAxis(:categories => [\"United States\", \"Japan\", \"China\", \"Germany\", \"France\"])\n # f.series(:name => \"GDP in Billions\", :yAxis => 0, :data => [14119, 5068, 4985, 3399, 2656])\n # f.series(:name => \"Population in Millions\", :yAxis => 1, :data => [310,127,1340,81,65])\n\n # f.yAxis [\n # {:title => {:text => \"GDP in Billions\", :margin => 70}},\n # {:title => {:text => \"Population in Millions\"}, :opposite => true},\n # ]\n # f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n # f.chart({:defaultSeriesType => \"column\"})\n # end\n # @chart3 = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n # series = {\n # :type=> 'pie',\n # :name=> 'Browser share',\n # :data=> [\n # ['Firefox', 45.0],\n # ['IE', 26.8],\n # {\n # :name=> 'Chrome', \n # :y=> 12.8,\n # :sliced=> true,\n # :selected=> true\n # },\n # ['Safari', 8.5],\n # ['Opera', 6.2],\n # ['Others', 0.7]\n # ]\n # }\n # f.series(series)\n # f.options[:title][:text] = \"THA PIE\"\n # f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\",\n # :style=>{\n # :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n # }\n # }\n # })\n # end\n\n # @chart4 = LazyHighCharts::HighChart.new('column') do |f|\n # f.series(:name=>'John',:data=> [3, 20, 3, 5, 4, 10, 12 ])\n # f.series(:name=>'Jane',:data=>[1, 3, 4, 3, 3, 5, 4,-46] ) \n # f.title({ :text=>\"example test title from controller\"})\n\n # ### Options for Bar\n # ### f.options[:chart][:defaultSeriesType] = \"bar\"\n # ### f.plot_options({:series=>{:stacking=>\"normal\"}})\n\n # ## or options for column\n # f.options[:chart][:defaultSeriesType] = \"column\"\n # f.plot_options({:column=>{:stacking=>\"percent\"}})\n # end\n\n\n \n\n respond_to do |format|\n format.html\n format.csv {send_data @pregnancies.to_csv}\n format.xls #{send_data @pregnancies.to_csv(col_sep: \"\\t\")}\n end\n end",
"def plot_against e1, e2\n Flot.new('experiment_roc_plot') do |f|\n f.points\n f.grid :hoverable => true\n f.legend :position => \"se\"\n f.yaxis 1\n f.series \"#{e1.title} against #{e2.title}\", e1.aucs_against(e2), :points => {:show => true, :radius => 1.5}\n end\nend",
"def chart\n case param_context(:chart_type)\n when 'cities' then\n @cities = city_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'cities_chart'\n when 'countries' then\n @countries = country_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'countries_chart'\n when 'years' then\n @years = year_count_data.to_a\n render 'years_chart'\n else\n flash[:error] = 'Unknown chart type'\n redirect_to events_path\n end\n end",
"def as_json(options={})\n\t\tsuper(:methods => [:display_result,:display_normal_biological_interval,:display_count_or_grade,:display_comments_or_inference,:test_is_abnormal,:test_is_ready_for_reporting,:test_is_verified, :successfully_updated_by_lis])\n\tend",
"def life_lines_tt method_names, events\n method_groups = events.group_by(&:method_name)\n values = method_names.map {|name| spread(method_groups[name], event_range(events)) }\n chart(method_names, values.transpose)\nend",
"def js_redraw_filter\n return <<-JS\n jQuery('##{@jqgrid_id}_filter_header').find('.ui-state-highlight').removeClass('ui-state-highlight').addClass('ui-state-default');\n jQuery('##{@filter}__#{@jqgrid_id}_filter_category').addClass('ui-state-highlight');\n jQuery('.jqgw-filter-open').removeClass('jqgw-filter-open').animate({height:'hide'},'fast');\n jQuery('##{@jqgrid_id}_#{@filter}_filter_form').addClass('jqgw-filter-open').animate({height:'show'},'fast');\n JS\n end",
"def grafico_activitad(vaca,num_dias)\n\n date_actividad = num_dias.days.ago.localtime\n\n actividades_total = vaca.actividades.where(\"registrada >= ? and tipo = ?\", date_actividad,'recorrido') \n n=0\n data_total = [[]]\n data_prom = [[]]\n \n actividades_total.each do |actividad|\n data_total[n] = [actividad.registrada.localtime,actividad.valor]\n act_prom = actividad_promedio_en(actividad.registrada)\n data_prom[n] = [actividad.registrada.localtime,act_prom]\n n = n+1\n end \n \n startPoint = 24.hours.ago.localtime\n if !data_total[0][0].nil? && data_total.size >0 \n startPoint = data_total[0][0].advance(:hours => (-3).to_i).localtime\n end\n startPoint = startPoint.change(:min => 0)\n \n @chart = LazyHighCharts::HighChart.new('graph') do |f|\n f.options[:chart][:defaultSeriesType] = \"spline\"\n f.options[:chart][:zoomType] = \"x\"\n f.options[:legend][:align] = \"right\"\n f.options[:legend][:verticalAlign] = \"top\"\n f.options[:legend][:floating] = \"true\"\n f.global(:useUTC => 'false')\n\n f.series(:name=>'Actividad Vaca ' + vaca.caravana.to_s, :data => data_total, \n :pointInterval => 3600000,:pointStart => (startPoint.to_i * 1000))\n f.series(:name=>'Actividad Promedio', :data => data_prom, \n :pointInterval => 3600000,:pointStart => (startPoint.to_i * 1000))\n \n f.options[:yAxis][:title] = {text: \"Eventos\"}\n f.options[:xAxis][:maxZoom] = \"14 * 24 * 3600000\"\n f.options[:xAxis][:type] = \"datetime\"\n f.options[:tooltip][:shared] = 'true'\n \n f.title(text: 'Actividad Vaca ' + vaca.caravana.to_s + ' ultimos ' + num_dias.to_s + ' dias') \n end\n\n return @chart\nend",
"def update_visualization(point)\n\t\t\n\tend",
"def update_visualization(point)\n\t\t\n\tend",
"def update_visualization(point)\n\t\t\n\tend",
"def update_visualization(point)\n\t\t\n\tend",
"def stats\n get_charts\n end",
"def serializable_hash(options={})\n options = {\n :methods=>[:attr_names, :dataset, :questions, :max_series_count],\n :chart_series=>{\n :methods=>[:attribute_name, :short_name]\n }\n }.update(options)\n super(options)\n end",
"def common_data(name, options)\n {\n # color: color or number\n label: name.to_s.humanize,\n data: series_for(name)\n # xaxis: number\n # yaxis: number\n # clickable: boolean\n # hoverable: boolean\n # shadowSize: number\n # highlightColor: color or number\n }\n end",
"def build_graph_generally(chart_type, categories, series, colors)\n graph = get_graph(chart_type)\n graph.add(:axis_category_text, categories)\n graph.add(:series, \"series legend label\", series)\n graph.add(:theme, \"vote\")\n graph.add(:user_data, :colors, colors.join(\",\"))\n graph.add(:user_data, :delay_count, series.size - 1)\n graph\n end",
"def update_visualization(point)\n\t\tsuper(point)\n\tend",
"def plot_hash hsh, type, options = {}\n options[:colors] ||= :category10\n options[:line_width] ||= 2\n\n colors = Rubyvis::Colors.send(options[:colors])\n options[:panel] = vis(options) # set up panel and store it in the options hash\n \n hsh.real.each_index do |i|\n options[:panel] = hsh.real[i].vis(type, options.merge({ :line_color => colors[i % colors.size] }))\n end if hsh.respond_to?(:real) # may not have anything but controls\n\n hsh.control.each_index do |i|\n options[:panel] = hsh.control[i].vis(type, options.merge({ :line_color => colors[i % colors.size] }))\n end if hsh.respond_to?(:control) # May not have a control set up\n\n options[:panel]\n end",
"def initialize(chart, options={})\n @order = nil\n self.chart = chart\n @chart.series << self\n options.each do |o|\n self.send(\"#{o[0]}=\", o[1]) if self.respond_to? \"#{o[0]}=\"\n end\n end",
"def color_methods; end",
"def show\n @devise = Devise.find(params[:id])\n @level = []\n @name = Devise.find(params[:id]).name \n Devise.find(params[:id]).histories.each do |x|\n @level << x.percentage \n @level << x.percentage \n @level << x.percentage \n @level << x.percentage \n end\n \n @h = LazyHighCharts::HighChart.new('graph') do |f|\n f.options[:title][:text] = \"#{@name}'s Light History\"\n f.series(:name=>'Percentage of Light', :data=> @level, type: \"areaspline\", pointInterval: 24 * 3600 * 1000, pointStart: Time.utc(2012,\"aug\",1,20,15,1).to_i * 1000 )\n f.options[:xAxis][:type] = \"datetime\"\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @devise }\n end\n end",
"def chart_feature \n @feature = params[:feature]\n chart = Ziya::Charts::Column.new( @license ) \n chart.add( :axis_category_text, @date_series )\n chart.add( :series, @feature, MoleLog.compute_series( @feature, @app_name, @min_date, @max_date ) )\n chart.add( :theme, \"moles\" ) \n chart.add( :user_data, :delay, rand( 10 ) + REFRESH_RATE )\n chart.add( :user_data, :url, \"/graphs/update_feature?feature=#{CGI.escape(@feature)}\") \n render :xml => chart.to_xml\n end",
"def show\n @reviews = @user.reviews\n @sakes = @user.sakes\n sum_fruity = 0\n sum_taste = 0\n average_fruity = 0\n average_taste = 0\n i = 0\n\n @reviews.each do |review|\n sum_fruity += review[:fruity].to_i\n sum_taste += review[:taste].to_i\n i += 1\n end\n if i != 0 then\n average_fruity = sum_fruity/i\n average_taste = sum_taste/i\n aData = [[average_fruity, average_taste]]\n \n @graph = LazyHighCharts::HighChart.new('graph') do |f|\n f.chart(scatter: true,zoomType: 'xy') #グラフの種類\n f.pane(size:'10%') #グラフサイズの比\n f.title(text: '平均値') \n f.xAxis(title: {\n enabled: true,\n text: '香り'\n },\n startOnTick: true,\n endOnTick: true,\n showLastLabel: true,\n min:-2,max:2\n )#タイトル\n f.yAxis(title: {text: \"味\"} ,min:-2,max:2) #各項目の最大値やら\n f.series(name:'',data: aData)\n f.legend(\n layout: 'vertical',\n align: 'left',\n verticalAlign: 'top',\n x: 50,\n y: 50,\n floating: true,\n borderWidth: 1\n )\n @graph_comp = 1\n end\n \t else\n \t @graph_comp = 0\n \tend\n end",
"def chart_options\n {}\n end",
"def explore\n add_time_series_nav_options(show_title: false)\n\n gon.explore_time_series = true\n gon.explore_time_series_ajax_path = explore_time_series_path(:format => :js)\n gon.embed_ids = @time_series.highlights.embed_ids\n gon.private_user = Base64.urlsafe_encode64(current_user.id.to_s)\n\n # need css for tabbed translations for entering highlight description\n @css.push('tabbed_translation_form.css')\n\n # this method is in application_controller\n # and gets all of the required information\n # and responds appropriately to html or js\n explore_time_series_generator(@time_series)\n\n end",
"def extract_chart_wrapper_editor_js(dom)\n case user_options[:chart_class].to_s.capitalize\n when 'Chartwrapper'\n get_html_chart_wrapper(data, dom)\n when 'Charteditor'\n get_html_chart_editor(data, dom)\n end\n end",
"def configurePlot\n end",
"def build_performance_chart_area(maxcols)\n super\n change_structure_to_timeseries\n end",
"def draw_js_spreadsheet(data, element_id)\n js = ''\n js << \"\\n function #{chart_function_name(element_id)}() {\"\n js << \"\\n var query = new google.visualization.Query('#{data}');\"\n js << \"\\n query.send(#{query_response_function_name(element_id)});\"\n js << \"\\n }\"\n js << \"\\n function #{query_response_function_name(element_id)}(response) {\"\n js << \"\\n var data_table = response.getDataTable();\"\n js << \"\\n var table = new google.visualization.Table\"\\\n \"(document.getElementById('#{element_id}'));\"\n js << add_listeners_js('table')\n js << \"\\n \ttable.draw(data_table, #{js_parameters(@options)});\"\n js << \"\\n };\"\n js\n end",
"def feedbackchart\n \n end",
"def method_missing(meth, *args, &block)\n if @worksheet.respond_to?(meth)\n @worksheet.send(meth, *args)\n else\n super\n end\n end",
"def add_series(plot, opts={})\n plot.series(opts)\n plot\n end",
"def add_series(plot, opts={})\n plot.series(opts)\n plot\n end",
"def series(*eras); end",
"def get_series (series_name)\n end",
"def extend_js(mod)\n extend mod\n mod.public_instance_methods.each do |method_name|\n add_function(sym_to_css(method_name)) { |tree, cxt|\n send method_name.to_sym, unquote(cxt.toCSS())\n }\n end\n end",
"def show_in_iruby\n @adapter.show_in_iruby @chart\n end",
"def admin_query\n @ndays = params[:days] || 62\n\n days = (@ndays).to_i\n render :json => {\n :type => 'LineChart',\n :cols => [['string', 'Fecha'], ['number', 'pages']],\n :rows => (1..days).to_a.inject([]) do |memo, i|\n date = i.days.ago.to_date\n t = date.beginning_of_day\n pages = PageDataDay.where(\"day = #{t.strftime(\"%Y%m%d\").to_i}\").count\n memo << [date, pages]\n memo\n end.reverse,\n :options => {\n :chartArea => { :width => '90%', :height => '75%' , :backgroundColor => 'red' }, \n :hAxis => { :showTextEvery => 30 } \n }\n }\n end",
"def draw_js(element_id)\n js = ''\n js << \"\\n function #{chart_function_name(element_id)}() {\"\n js << \"\\n #{to_js}\"\n js << \"\\n var table = new google.visualization.Table(\"\n js << \"document.getElementById('#{element_id}'));\"\n js << add_listeners_js('table')\n js << \"\\n table.draw(data_table, #{js_parameters(@options)}); \"\n js << \"\\n };\"\n js\n end",
"def show_graph\n url_for_data = url_for(controller.params.merge(:action => :data)).gsub('&', '&')\n relative_url_path = ActionController::Base.respond_to?(:relative_url_root) ? ActionController::Base.relative_url_root : ActionController::AbstractRequest.relative_url_root\n html, div_name = controller.open_flash_chart_object_and_div_name('100%', '400', url_for_data, true, \"#{relative_url_path}/\")\n\n html << '<script type=\"text/javascript\">' << \"\\n\"\n html << \"var charts_to_image_title = '#{h(controller.title)}';\\n\" \n html << \"var charts_to_image_id = '#{div_name}';\\n\"\n html << '</script>'\n\n html\n end",
"def index\n @highlight_data = get_highlight_data(params[:id])\n puts @highlight_data.inspect\n if !@highlight_data[:error]\n puts \"here\"\n # save the js data into gon\n gon.highlight_data = {}\n gon.highlight_data[@highlight_data[:highlight_id].to_s] = @highlight_data[:js]\n\n set_gon_highcharts\n\n gon.update_page_title = true\n\n gon.get_highlight_desc_link = highlights_get_description_path\n gon.powered_by_link = @xtraktr_url\n gon.powered_by_text = I18n.t('app.common.powered_by_xtraktr')\n gon.powered_by_title = I18n.t('app.common.powered_by_xtraktr_title')\n \n gon.visual_type = @highlight_data[:visual_type]\n if @highlight_data[:visual_type] != Highlight::VISUAL_TYPES[:map] # if the visual is a chart, include the highcharts file\n @js.push('highcharts.js')\n elsif @highlight_data[:visual_type] == Highlight::VISUAL_TYPES[:map] # if the visual is a map, include the highmaps file\n @js.push('highcharts.js', 'highcharts-map.js')\n\n if @highlight_data[:type] == 'dataset'\n @shapes_url = Dataset.shape_file_url(@highlight_data[:id]) # have to get the shape file url for this dataset\n end\n end\n @js.push('highcharts-exporting.js')\n end\n puts \"here1\"\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def method_to_js(method, *args)\n self << \"#{self.var}.#{method.to_js_method}(#{args.to_js_arguments});\"\n end",
"def color_code(*colors)\n HighLine.Style(*colors).code\n end",
"def sub_charts\n @sub_charts\n end",
"def index\n @title = get_title\n\n @show_conditions = false\n\n if show_date_condition\n @date_condition = true\n @show_conditions = true\n else\n @date_condition = false\n end\n\n if show_pages\n @show_pages = true\n end\n\n unless get_grouping_options.empty?\n @grouping_options = RedmineCharts::GroupingUtils.to_options(get_grouping_options)\n @show_conditions = true\n else\n @grouping_options = []\n end\n\n unless get_conditions_options.empty?\n @conditions_options = RedmineCharts::ConditionsUtils.to_options(get_conditions_options, @project.id)\n @show_conditions = true\n else\n @conditions_options = []\n end\n \n @show_left_column = @show_conditions\n\n unless get_help.blank?\n @help = get_help\n @show_left_column = true\n else\n @help = nil\n end\n\n @range = RedmineCharts::RangeUtils.from_params(params)\n @pagination = RedmineCharts::PaginationUtils.from_params(params)\n @grouping = RedmineCharts::GroupingUtils.from_params(get_grouping_options, params)\n @conditions = RedmineCharts::ConditionsUtils.from_params(get_conditions_options, @project.id, params)\n\n @data = data\n\n render :template => \"charts/index\"\n end",
"def pie\n\n# Render json data containing the different fields: (For ajax use)\n render :json => [\n { label: ' ', value: Cache.where(source: 'original').count},\n { label: ' ', value: Cache.where(source: 'collamine').count} \n ]\n end",
"def household_heat_curves\n render_serializer FeverCSVSerializer.new(\n @scenario.gql.future_graph,\n %i[space_heating households_hot_water],\n 'household_heat'\n )\n end",
"def set_functions\n super\n end",
"def show\n @user = User.find(params[:id])\n @time_now = Time.now.utc.at_midnight\n\n @event_data = Array.new\n @activity_data = Array.new\n @user.events.each do |event|\n if event.event_type == 3\n date_start = (event.activity_since.utc.to_f*1000.0).to_i\n # date_end = (event.entered_at.utc.to_f*1000.0).to_i\n @activity_data.push({x: date_start, y: event.activity_type, name: ACTIVITY_TYPE[event.activity_type]})\n # @activity_data.push({x: date_end, y: event.activity_type, name: ACTIVITY_TYPE[event.activity_type]})\n else\n date = (event.entered_at.utc.to_f*1000.0).to_i\n @event_data.push({x: date, y: (event.event_type+6), name: EVENT_TYPE[event.event_type]})\n end\n end\n\n\n @h = LazyHighCharts::HighChart.new('graph') do |f|\n f.chart( zoomType: 'x')\n f.title( text: @user.first_name + \" \" + @user.last_name + ' ' + 'activity and events')\n f.tooltip(\n # useHTML: true,\n # headerFormat: '<small>{point.key} + {point.name} </small><table>',\n # pointFormat: \"<tr><td style=\\\"color: {series.color}\\\">{series.name}: </td>\" + \"<td style=\\\"text-align: right\\\"><b>{point.y}</b></td></tr>\",\n crosshairs: true, followPointer: true,\n xDateFormat: '%Y-%m-%d',\n shared: true,\n # footerFormat: '</table>'\n )\n\n f.yAxis(\n min: 0,\n max: 11,\n categories: [nil, \"Steady\", \"Walking\", \"Biking\", \"Running\", \"\", \"Pain\", \"Meal\", \"Medicine\", \"Activity Change\", \"Other\", \"\"],\n minorGridLineWidth: 1,\n gridLineWidth: 1,\n alternateGridColor: nil,\n tickInterval: 1,\n minTickInterval: 1,\n tickmarkPlacement: 'on',\n plotBands: [{\n from: 0,\n to: 5,\n color: 'rgba(68, 170, 213, 0.1)',\n label: {\n text: 'Activity',\n style: {\n color: '#606060'\n }\n }\n }, {\n from: 5,\n to: 10,\n color: 'rgba(0, 0, 0, 0)',\n label: {\n text: 'Event',\n style: {\n color: '#606060'\n }\n }\n }\n ]\n )\n f.xAxis type: 'datetime'\n\n f.series(type: 'line', :name=>'Activity', :data=>@activity_data, pointStart: (@time_now.to_f*1000.0).to_i, step: \"left\")\n f.series(type: 'line', lineWidth: 0, :name=>'Event', :data=>@event_data, pointStart: (@time_now.to_f*1000.0).to_i)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def getchart()\n # The data for the area chart\n data = [3.0, 2.8, 4.0, 5.5, 7.5, 6.8, 5.4, 6.0, 5.0, 6.2, 7.5, 6.5, 7.5, 8.1, 6.0,\n 5.5, 5.3, 3.5, 5.0, 6.6, 5.6, 4.8, 5.2, 6.5, 6.2]\n\n # The labels for the area chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 300 x 180 pixels. Set the background to pale\n # yellow (0xffffa0) with a black border (0x0)\n c = ChartDirector::XYChart.new(300, 180, 0xffffa0, 0x000000)\n\n # Set the plotarea at (45, 35) and of size 240 x 120 pixels. Set the background to\n # white (0xffffff). Set both horizontal and vertical grid lines to black (&H0&)\n # dotted lines (pattern code 0x0103)\n c.setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, c.dashLineColor(0x000000,\n 0x000103), c.dashLineColor(0x000000, 0x000103))\n\n # Add a title to the chart using 10 pts Arial Bold font. Use a 1 x 2 bitmap\n # pattern as the background. Set the border to black (0x0).\n c.addTitle(\"Snow Percipitation (Dec 12)\", \"arialbd.ttf\", 10).setBackground(\n c.patternColor([0xb0b0f0, 0xe0e0ff], 2), 0x000000)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"mm per hour\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis.\n c.xAxis().setLabelStep(3)\n\n # Add an area layer to the chart\n layer = c.addAreaLayer()\n\n # Load a snow pattern from an external file \"snow.png\".\n snowPattern = c.patternColor2(File.dirname(__FILE__) + \"/snow.png\")\n\n # Add a data set to the area layer using the snow pattern as the fill color. Use\n # deep blue (0x0000ff) as the area border line color (&H0000ff&)\n layer.addDataSet(data).setDataColor(snowPattern, 0x0000ff)\n\n # Set the line width to 2 pixels to highlight the line\n layer.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def chart=(v) DataTypeValidator.validate \"Series.chart\", Chart, v; @chart = v; end",
"def jqgrid_js(grid, *args)\n args.include?(:notag) || args.include?(:raw) ? grid.build : javascript_tag(grid.build)\n end",
"def showLegend _obj, _args\n \"_obj showLegend _args;\" \n end",
"def setGridOnClick\n end",
"def write_chart_type(params = {})\n # Write the c:areaChart element.\n write_pie_chart\n end",
"def create\n @income = Income.new(income_params)\n if user_signed_in?\n @income.user_id = current_user.id\n end\n @income.month=Date.today.month\n @income.year=Date.today.year\n @income.day_rec=Date.today.day\n@income_chart_data=[['IE',56.33],['Chrome',24.03],['Safari',4.77],['Opera',0.91],{name: 'Proprietary or Undetectable',y: 0.2,dataLabels: {enabled: false}}]\n respond_to do |format|\n if @income.save\n format.js\n end\n end\n end",
"def determine_method_class(method)\n method = method.to_s\n \"Highcharts::#{base_options.include?(method) ? 'Base' : default_options.include?(method) ? method.capitalize : custom_options[method]}\"\n end",
"def getchart()\n # Use random table to generate a random series. The random table is set to 1 col x\n # 51 rows, with 9 as the seed\n rantable = ChartDirector::RanTable.new(9, 1, 51)\n\n # Set the 1st column to start from 100, with changes between rows from -5 to +5\n rantable.setCol(0, 100, -5, 5)\n\n # Get the 1st column of the random table as the data set\n data = rantable.getCol(0)\n\n # Create a XYChart object of size 600 x 300 pixels\n c = ChartDirector::XYChart.new(600, 300)\n\n # Set the plotarea at (50, 35) and of size 500 x 240 pixels. Enable both the\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 35, 500, 240).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"LOWESS Generic Curve Fitting Algorithm\", \"timesbi.ttf\", 18)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Set the x axis scale from 0 - 50, with major tick every 5 units and minor tick\n # every 1 unit\n c.xAxis().setLinearScale(0, 50, 5, 1)\n\n # Add a blue layer to the chart\n layer = c.addLineLayer2()\n\n # Add a red (0x80ff0000) data set to the chart with square symbols\n layer.addDataSet(data, 0x80ff0000).setDataSymbol(ChartDirector::SquareSymbol)\n\n # Set the line width to 2 pixels\n layer.setLineWidth(2)\n\n # Use lowess for curve fitting, and plot the fitted data using a spline layer with\n # line width set to 3 pixels\n c.addSplineLayer(ChartDirector::ArrayMath.new(data).lowess().result(), 0x0000ff\n ).setLineWidth(3)\n\n # Set zero affinity to 0 to make sure the line is displayed in the most detail\n # scale\n c.yAxis().setAutoScale(0, 0, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def on_high()\n \n end",
"def show\n if @city.statistics.size > 2\n sdate = @city.statistics.keys[1].to_date\n edate = @city.statistics.keys.last.to_date\n stime = Time.new(sdate.year, sdate.month, sdate.day, 0, 0, 0, @city.zone)\n etime = Time.new(edate.year, edate.month, edate.day, 0, 0, 0, @city.zone)\n\n data = @city.statistics.values[1...-1].map{|s| s[:total]}\n interval = 1.day\n\n @count = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Count\")\n f.xAxis(type: \"datetime\", maxZoom: (etime - stime).to_i)\n f.series(\n name: \"count\", \n yAxis: 0, \n data: data,\n pointStart: stime,\n pointInterval: interval\n )\n\n f.yAxis [\n {:title => {:text => \"count\", :margin => 70}, min: 0 },\n ]\n\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n\n distributions = @city.statistics.values[1...-1].map{|s| s[:distribution]}\n distribution_data = distributions.inject([]) do |res, d|\n d.each_with_index do |c, i|\n res[i] ||= []\n res[i] << c\n end\n res\n end\n distribution_data.each{ |d| d.extend(DescriptiveStatistics) }\n\n @distribution = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Distribution\")\n f.xAxis(\n categories: 24.times.map{ |h| (\"%02d\" % h) + \":00\" }\n )\n f.series(\n name: 'mean',\n yAxis: 0,\n data: distribution_data.map(&:mean)\n )\n f.series(\n name: 'standard eviation',\n yAxis: 0,\n data: distribution_data.map(&:standard_deviation)\n )\n f.yAxis [\n {min: 0}\n ]\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 150, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n end\n end",
"def write_chart_type # :nodoc:\n end",
"def chart_life_lines class_name, events\n es = method_events(events).select {|e| e.class_name == class_name }\n names = es.map(&:method_name).uniq\n life_lines_tt names, es\nend",
"def to_html\n @chart.to_html\n end",
"def color_fix\n cli = HighLine.new\n ft = HighLine::ColorScheme.new do |cs|\n cs[:headline] = [ :bold, :yellow, :on_black ]\n cs[:horizontal_line] = [ :bold, :yellow ]\n cs[:headline_1] = [ :bold, :black, :on_yellow ]\n cs[:horizontal_line_1] = [ :yellow ]\n cs[:warning] = [ :bold, :red, :on_white ]\n cs[:menu_choice] = [ :bold, :light_blue, :on_red]\n cs[:menu_line] = [ :bold, :light_blue]\n end\n HighLine.color_scheme = ft\nend",
"def index\n @countries = Country.all(:order => \"created_at ASC\")\n google_chart\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @countries }\n format.js\n end\n end",
"def script_content \n return_val = %{\n $(document).ready(function() {\n var ctx = $(\"##{@chart_id}\");\n var content = #{@content.to_json}\n content[\"options\"][\"tooltips\"] = { \n callbacks: {\n label: function(tooltipItem, data) {\n\n var dataset_label = data.datasets[tooltipItem.datasetIndex].label;\n var data_point = data.datasets[tooltipItem.datasetIndex][\"data\"][tooltipItem.index];\n var array = [];\n\n if (typeof data_point == \"number\") { // bar chart\n dataset_label = dataset_label + \":\" + data_point ;\n }\n else if (data_point.hasOwnProperty(\"y\")) { // line graph\n dataset_label = dataset_label + \":\" + data_point[\"y\"] ;\n if (data_point.hasOwnProperty(\"c\") && (!(data_point[\"c\"] === null))) { // special comment field for json viewer that we can add to tooltip\n array.push(data_point[\"c\"]);\n }\n }\n array.unshift(dataset_label);\n var aggregate_string = \"\"\n for (var i in array) {\n aggregate_string += array[i] + \" \";\n }\n var output_string = \"(\" + aggregate_string + \")\"\n $(this).offsetParent().find(\"#tooltip_info\").text(output_string); // find the current charts tooltip <span> using relative path\n // however, this still doesn't work when you have multiple charts\n // at the same time\n return array; // each item is a new line on tooltip\n }\n }\n }\n var myLineChart = new Chart(ctx, content);\n });\n }\n return_val \n end",
"def index\n @datebodydata = Datebodydatum.order(\"date\")\n require 'date'\n if !params[:start_date_search].blank?\n @start_day = Date.parse(params[:start_date_search])\n if !params[:end_date_search].blank?\n @end_day = Date.parse(params[:end_date_search]) + 1\n else\n @end_day = @start_day + 7\n end\n#X軸間隔設定\n tickInterval = 1\n#データ取得\n @data = @datebodydata.where(:date => @start_day...@end_day)\n#X軸データ取得\n @categories = @data.select(:date).order(\"date\").map{|d| d.date}\n#グラフデータ\n data1 = @data.select(:weight).order(\"date\").map{|d| d.weight.to_f}\n data2 = @data.select(:pulse).order(\"date\").map{|d| d.pulse.to_f}\n data3 = @data.select(:bodytemperature).order(\"date\").map{|d| d.bodytemperature.to_f}\n data4 = @data.select(:bloodpressure).order(\"date\").map{|d| d.bloodpressure.to_i}\n data5 = @data.select(:highbloodpressure).order(\"date\").map{|d| d.highbloodpressure.to_i}\n#グラフ描画\n @graph_data = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'グラフ名')\n#X軸設定反映\n f.xAxis(categories: @categories, tickInterval: tickInterval)\n\n#Y軸設定\n f.options[:yAxis] = [\n#yAxis: 0\n { title: { text: '体重' }, min: 30, max: 130, tickInterval: 10},\n#yAxis: 1\n { title: { text: '血圧' }, min: 50, max: 150, tickInterval: 10},\n#yAxis: 2\n { title: { text: '脈拍' }, min: 50, max: 150, tickInterval: 10, opposite: true},\n#yAxis: 3\n { title: { text: '体温' }, min: 35, max: 41, tickInterval: 0.5, opposite: true }\n ]\n#グラフ設定\n f.series(\n#グラフ名\n name: '体重',\n#グラフデータ\n data: data1,\n#グラフタイプ\n type: 'column',\n#Y軸指定\n yAxis: 0,\n#グラフ単位\n tooltip: { valueSuffix: 'Kg'},\n#グラフにカーソルを合わせた時に説明を出すかどうかの設定。defaultはtrue\n enableMouseTracking: true\n )\n f.series(name: '最低血圧', data: data4, type: 'column', yAxis: 1,\n tooltip: { valueSuffix: 'mmHg'}\n )\n f.series(name: '最高血圧', data: data5, type: 'column', yAxis: 1,\n tooltip: { valueSuffix: 'mmHg'}\n )\n f.series(name: '脈拍', data: data2, type: 'line', yAxis: 2,\n tooltip: { valueSuffix: '回'}\n )\n f.series(name: '体温', data: data3, type: 'line', yAxis: 3,\n tooltip: { valueSuffix: '°C'},\n plotLines: [{ value: 0, width: 1, color: '#808080' }]\n )\n end\n else\n redirect_to root_path \n end\n end",
"def index\n @teachers = @admin.children.unblocked.load_data(filtered_params)\n\n unless request.xhr?\n # Only run here if not ajax request\n @all_teachers = @admin.children.unblocked.order(User::DEFAULT_ORDER)\n series = []\n\n # Options for export select box\n @all_teachers_collection = []\n\n @all_teachers.each do |teacher|\n if series.blank?\n # Only need ONE serie to detect the width and height of the chart.\n teacher_status = teacher.teacher_status\n series << {\n :name => teacher.full_name,\n :data => teacher_status,\n :yAxis => 2\n } unless teacher_status.empty?\n end\n\n # Prepare options for export popup\n @all_teachers_collection << [teacher.full_name, teacher.id]\n end\n\n @all_teachers_count = @all_teachers.length\n\n if series.empty?\n @width = \"0%\"\n @height = \"0\"\n else \n @width = \"100%\"\n @height = \"500\"\n end\n end\n \n respond_to do |format|\n format.js\n format.html\n end\n end",
"def device_volume_graph\n @days = 30\n if (params.nil? or params[:device].nil? or params[:device][:id].empty?)\n @chart = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"No device selected\")\n end\n else\n if (not params[:days].nil? and not params[:days].empty?)\n @days = params[:days].to_i\n end\n @device_id = params[:device][:id]\n @device = Device.find @device_id\n bw_vol = Hash.new\n color_vol = Hash.new\n alerts = Alert.where([\"device_id=? and alert_date > date_sub(curdate(), interval ? day)\",@device_id,@days]).group('date(alert_date)').each do |a|\n unless a.sheet_count.nil?\n bw_vol[a.alert_date.to_i] = a.sheet_count.bw\n color_vol[a.alert_date.to_i] = a.sheet_count.color\n end\n end\n @chart = LazyHighCharts::HighChart.new('chart') do |f|\n f.type('scatter')\n f.title( {:text => \"Print volume for #{@device.name}\"})\n f.xAxis( :labels => {:formatter => 'function(){return (new Date(this.value*1000)).toDateString();}'.js_code} )\n f.yAxis( [{:id => 0, :title => {:text => \"Colour\"}},{:id => 1, :opposite => true, :title => {:text => \"Black and White\"}}])\n f.tooltip( :formatter => 'function(){return(\"<span style=\\\"font-size: 10px\\\">\" + (new Date(this.x*1000)).toDateString() + \"</span><br /><span style=\\\"color:\" + this.series.color + \"\\\">\" + this.series.name + \": \" + this.y + \"</span><br/>\");}'.js_code)\n f.series(:type => 'line', :name => 'Colour',\n# :pointInterval => 1.day,\n# :pointStart => @days.days.ago.to_date,\n :data => color_vol.to_a,\n :yAxis => 0)\n f.series(:type => 'line', :name => 'Black and White',\n # :pointInterval => 1.day,\n # :pointStart => @days.days.ago.to_date,\n :data => bw_vol.to_a,\n :yAxis => 1)\n end\n end\n end",
"def plot_strategy(data,compare_data)\n your_color = ['#C7E6F2','#70D2E5', '#44BBDF']\n name = ['L1 Questions', 'L2 Questions', 'L3 Questions']\n comparison_color = ['#D9D9D9', '#B2B2B2', '#8C8C8C']\n @yours = PlotGraph::Graphs.percentage name, data, your_color, \"Strategy over the days\", \"No of questions attended\"\n @yours_compare = PlotGraph::Graphs.percentage name, data, your_color, 200, \"Strategy over the days\", \"No of questions attended\"\n @comparison = PlotGraph::Graphs.percentage name, compare_data, comparison_color, 200, \"Strategy over the days\", \"No of questions attended\"\n @comparison = [@yours_compare, @comparison]\n end",
"def graph\n @data = @category.to_graph_points\n\n @series = [{ values: @data, key: @category.name }]\n\n @title = \"Spending for #{@category.name}\"\n end",
"def show\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @chart }\n end\n end"
] | [
"0.6293538",
"0.6261295",
"0.6100825",
"0.59735274",
"0.5960883",
"0.58906347",
"0.5813535",
"0.5801103",
"0.58000493",
"0.5768363",
"0.57550055",
"0.57334316",
"0.56388223",
"0.5571125",
"0.5556048",
"0.5494882",
"0.54695845",
"0.5468506",
"0.54363924",
"0.5411419",
"0.5351395",
"0.5349741",
"0.5327548",
"0.52893925",
"0.5254589",
"0.5231513",
"0.5221087",
"0.5216826",
"0.52066606",
"0.5182134",
"0.51718557",
"0.51701677",
"0.516437",
"0.5162597",
"0.51617646",
"0.5154979",
"0.5150393",
"0.51255846",
"0.51255846",
"0.51255846",
"0.51255846",
"0.51204526",
"0.5118523",
"0.5112774",
"0.5106022",
"0.50845015",
"0.5060768",
"0.503136",
"0.502469",
"0.5019566",
"0.5016985",
"0.49946642",
"0.4990037",
"0.4973396",
"0.49460834",
"0.49455717",
"0.49451926",
"0.49424422",
"0.49331784",
"0.49314022",
"0.49233517",
"0.49233517",
"0.492015",
"0.49095637",
"0.49091354",
"0.49041402",
"0.49028257",
"0.4893636",
"0.48860878",
"0.48808128",
"0.48756355",
"0.48471677",
"0.48429024",
"0.4833089",
"0.48307064",
"0.48252416",
"0.48249012",
"0.4820323",
"0.48075956",
"0.47936952",
"0.4793518",
"0.47913557",
"0.4786871",
"0.47790787",
"0.47779626",
"0.47625822",
"0.4746027",
"0.47419375",
"0.4741664",
"0.47331518",
"0.47300348",
"0.47291178",
"0.47236377",
"0.4710956",
"0.4710836",
"0.47103283",
"0.47027218",
"0.46955535",
"0.46901864",
"0.46893486",
"0.46812052"
] | 0.0 | -1 |
Add a simple series to the graph: data = [[0,5], [1,5], [2,5]] | def series(opts = {})
@data ||= []
if opts.blank?
@data << series_options.merge(:name => label, :data => d)
else
@data << opts.merge(:name => opts[:name], :data => opts[:data])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_series(series)\n if (@data[0]) then\n # Require that all column names are identical\n raise \"Column names do not match!\" unless ((@data[0].xlabel == series.xlabel) && (@data[0].ylabel == series.ylabel))\n end\n @data.push(series)\n end",
"def add_series(plot, opts={})\n plot.series(opts)\n plot\n end",
"def add_series(plot, opts={})\n plot.series(opts)\n plot\n end",
"def add_series(series)\n type_check(series, :series)\n Series.create(series)\n end",
"def series(label, d, opts = {})\n if opts.blank?\n @data << series_options.merge(:label => label, :data => d)\n else\n @data << opts.merge(:label => label, :data => d)\n end\n end",
"def data=(series)\n @data = []\n series.each do |d|\n @data << [[0,d]]\n end\n end",
"def series=(value)\n @series = value\n end",
"def add_series(options={})\n @series_type.new(self, options)\n @series.last\n end",
"def add_series(options = {})\n @series_type.new(self, options)\n @series.last\n end",
"def add_line(x, y, label=\"data #{@dataxy.length + 1}\")\n @dataxy << [label, x, y]\n end",
"def init(data=[], options={}, user_options={})\n # Alternate way is using `add_series` method.\n #\n # There are many options present in Highcharts so it is better to use\n # directly all the options. That means Daru::View::Plot will\n # behave same as LazyHighCharts when `data` is an Array and\n # `options` are passed.\n #\n @chart = LazyHighCharts::HighChart.new do |f|\n # all the options present in `options` and about the\n # series (means name, type, data) used in f.series(..)\n f.options = options.empty? ? LazyHighCharts::HighChart.new.defaults_options : options\n # For multiple series when data is in a series format as in\n # HighCharts official examples\n # TODO: Add support for multiple series when data as\n # Daru::DataFrame/Daru::Vector\n if data.is_a?(Array) && data[0].is_a?(Hash)\n f.series_data = data\n else\n data_new = guess_data(data)\n series_type = options[:type] unless options[:type].nil?\n series_name = options[:name] unless options[:name].nil?\n f.series(type: series_type, name: series_name, data: data_new)\n end\n end\n @chart.user_options = user_options\n @chart\n end",
"def graph\n @data = @category.to_graph_points\n\n @series = [{ values: @data, key: @category.name }]\n\n @title = \"Spending for #{@category.name}\"\n end",
"def plot_data_line(sym, data)\n return if data.empty? or data.count == 1\n set_delta_and_offset(data)\n\n ppath = Qt::PainterPath.new(Qt::PointF.new 0, scale_y(data[0]))\n data[1..-1].each_with_index do |val, idx|\n x = idx * @x_mul\n ppath.line_to(Qt::PointF.new x, scale_y(val))\n end\n @items << @scene.addPath(ppath, @pens[sym])\n end",
"def series\n []\n end",
"def plot_1d\n plotter = Plotter.new(:title => \"Signal: values vs. sample number\", :xtitle => \"sample number\", :ytitle => \"sample value\")\n plotter.plot_1d \"signal data\" => @data\n end",
"def new\n @series = Series.new\n end",
"def seriesAdded\n tag_range(\"800\", \"83X\")\n end",
"def plot_data data, series=nil, filename=nil, title=nil\n # stub method to enable documentation in yard\n\t\tend",
"def add_series(params)\n # Check that the required input has been specified.\n raise \"Must specify ':values' in add_series\" unless params.has_key?(:values)\n\n raise \"Must specify ':categories' in add_series for this chart type\" if @requires_category != 0 && !params.has_key?(:categories)\n\n raise \"The maximum number of series that can be added to an Excel Chart is 255.\" if @series.size == 255\n\n @series << Series.new(self, params)\n\n # Set the secondary axis properties.\n x2_axis = params[:x2_axis]\n y2_axis = params[:y2_axis]\n\n # Store secondary status for combined charts.\n @is_secondary = true if ptrue?(x2_axis) || ptrue?(y2_axis)\n\n # Set the gap and overlap for Bar/Column charts.\n if params[:gap]\n if ptrue?(y2_axis)\n @series_gap_2 = params[:gap]\n else\n @series_gap_1 = params[:gap]\n end\n end\n\n # Set the overlap for Bar/Column charts.\n if params[:overlap]\n if ptrue?(y2_axis)\n @series_overlap_2 = params[:overlap]\n else\n @series_overlap_1 = params[:overlap]\n end\n end\n end",
"def simple_chart\n \n end",
"def show\n @user = User.find(params[:id])\n @time_now = Time.now.utc.at_midnight\n\n @event_data = Array.new\n @activity_data = Array.new\n @user.events.each do |event|\n if event.event_type == 3\n date_start = (event.activity_since.utc.to_f*1000.0).to_i\n # date_end = (event.entered_at.utc.to_f*1000.0).to_i\n @activity_data.push({x: date_start, y: event.activity_type, name: ACTIVITY_TYPE[event.activity_type]})\n # @activity_data.push({x: date_end, y: event.activity_type, name: ACTIVITY_TYPE[event.activity_type]})\n else\n date = (event.entered_at.utc.to_f*1000.0).to_i\n @event_data.push({x: date, y: (event.event_type+6), name: EVENT_TYPE[event.event_type]})\n end\n end\n\n\n @h = LazyHighCharts::HighChart.new('graph') do |f|\n f.chart( zoomType: 'x')\n f.title( text: @user.first_name + \" \" + @user.last_name + ' ' + 'activity and events')\n f.tooltip(\n # useHTML: true,\n # headerFormat: '<small>{point.key} + {point.name} </small><table>',\n # pointFormat: \"<tr><td style=\\\"color: {series.color}\\\">{series.name}: </td>\" + \"<td style=\\\"text-align: right\\\"><b>{point.y}</b></td></tr>\",\n crosshairs: true, followPointer: true,\n xDateFormat: '%Y-%m-%d',\n shared: true,\n # footerFormat: '</table>'\n )\n\n f.yAxis(\n min: 0,\n max: 11,\n categories: [nil, \"Steady\", \"Walking\", \"Biking\", \"Running\", \"\", \"Pain\", \"Meal\", \"Medicine\", \"Activity Change\", \"Other\", \"\"],\n minorGridLineWidth: 1,\n gridLineWidth: 1,\n alternateGridColor: nil,\n tickInterval: 1,\n minTickInterval: 1,\n tickmarkPlacement: 'on',\n plotBands: [{\n from: 0,\n to: 5,\n color: 'rgba(68, 170, 213, 0.1)',\n label: {\n text: 'Activity',\n style: {\n color: '#606060'\n }\n }\n }, {\n from: 5,\n to: 10,\n color: 'rgba(0, 0, 0, 0)',\n label: {\n text: 'Event',\n style: {\n color: '#606060'\n }\n }\n }\n ]\n )\n f.xAxis type: 'datetime'\n\n f.series(type: 'line', :name=>'Activity', :data=>@activity_data, pointStart: (@time_now.to_f*1000.0).to_i, step: \"left\")\n f.series(type: 'line', lineWidth: 0, :name=>'Event', :data=>@event_data, pointStart: (@time_now.to_f*1000.0).to_i)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @reviews = @user.reviews\n @sakes = @user.sakes\n sum_fruity = 0\n sum_taste = 0\n average_fruity = 0\n average_taste = 0\n i = 0\n\n @reviews.each do |review|\n sum_fruity += review[:fruity].to_i\n sum_taste += review[:taste].to_i\n i += 1\n end\n if i != 0 then\n average_fruity = sum_fruity/i\n average_taste = sum_taste/i\n aData = [[average_fruity, average_taste]]\n \n @graph = LazyHighCharts::HighChart.new('graph') do |f|\n f.chart(scatter: true,zoomType: 'xy') #グラフの種類\n f.pane(size:'10%') #グラフサイズの比\n f.title(text: '平均値') \n f.xAxis(title: {\n enabled: true,\n text: '香り'\n },\n startOnTick: true,\n endOnTick: true,\n showLastLabel: true,\n min:-2,max:2\n )#タイトル\n f.yAxis(title: {text: \"味\"} ,min:-2,max:2) #各項目の最大値やら\n f.series(name:'',data: aData)\n f.legend(\n layout: 'vertical',\n align: 'left',\n verticalAlign: 'top',\n x: 50,\n y: 50,\n floating: true,\n borderWidth: 1\n )\n @graph_comp = 1\n end\n \t else\n \t @graph_comp = 0\n \tend\n end",
"def graph(data = nil)\n robj = Rserve::Simpler.new\n hash = {}\n hash[\"mass\"] = data.map(&:first)\n hash[\"intensity\"] = data.map(&:last)\n robj.converse( masses: hash.to_dataframe) do \n \"attach(masses)\"\n end\n #robj.converse( data: Rserve::DataFrame.from_structs(list))\n robj.converse \"setwd('#{Dir.pwd}')\"\n output_file_name = \"#{@sequence}_spectra.png\"\n robj.converse do \n %Q{png(file='#{output_file_name}')\n plot(masses$mass, masses$intensity, type='h')\n dev.off()\n }\n end\t\n output_file_name\n end",
"def data=(v) DataTypeValidator.validate \"Series.data\", [NumDataSource], v; @data = v; end",
"def data=(v) DataTypeValidator.validate \"Series.data\", [NumDataSource], v; @data = v; end",
"def line(values, colour = nil, x_axis = nil, y_axis = nil)\n self.push(:item => values, :settings => {:axisx => x_axis, :axisy => y_axis, :colour => colour})\n end",
"def draw_me_a_line_chart\n\t\t@table = StatisticsTable.new\n\t\t@table.title = 'Statistiques'\n\t\t@table.axis_title = 'money'\n\t\t\n\t\t@table.add_header('string','Name')\n\t\t@table.add_header('number','Paul')\n\t\t@table.add_header('number','Joe')\n\t\t@table.add_header('number','Jean')\n\n\t\t@table.add_line(['January', 10000, 20000, 23000])\n\t\t@table.add_line(['February', 9000, 22000, 24000])\n\t\t@table.add_line(['March', 8000, 25000, 21000])\n\t\t@table.add_line(['April', 7000, 29000, 22000])\n\t\t@table.add_line(['May', 6000, 40000, 23000])\n\tend",
"def generateSeriesPlot(xyData, options={})\n plotOptions={:width=>200, :height=>100, :imagetype=> \"png\", :xlabel=> \"\", :ylabel=> \"\"}\n plotOptions=plotOptions.merge(options)\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.terminal \"#{plotOptions[:imagetype]} small enhanced size #{plotOptions[:width]},#{plotOptions[:height]} crop\"\n plot.output Rails.root.to_s+\"/public/series.png\"\n plot.ylabel plotOptions[:ylabel]\n plot.xlabel plotOptions[:xlabel]\n plot.boxwidth 0.5\n plot.grid \"\"\n plot.data << Gnuplot::DataSet.new( xyData ) do |ds|\n ds.with = \"boxes fill solid 0.5\"\n ds.notitle\n end\n end\n end\n end",
"def build_predictive_chart_line(name, color, index, data)\n line = ChartLine.new name, color, \"o,\" + color + \",\" + index + \",-1,4.5\"\n data.each do |key, value|\n line[key] = value\n end\n line\n end",
"def plot_fixed_dataset(**options)\n options = {:sort => false, :reverse => false }.merge(options)\n data = [30, 234, 4, 123, 200, 89, 189, 10,]\n data.sort!() if options[:sort]\n data.reverse!() if options[:reverse]\n graph.plot(data, {:line => 'i', :frame => false, :tags => true})\n end",
"def add_node_to_plot(node, plot, addr_offset, row_offset, addr_div, row_div)\n\tif node.has_key? :data\n\t\tnode[:data].each do |d| # d ~ {row: row, addr: addr, length: words[2].hex, val: 1}\n\t\t\tplot.set((d[:row] - row_offset)/row_div, (d[:addr] - addr_offset)/addr_div, d[:length])\n\t\tend\n\telse\n\t\tnode.each do |key, val|\n\t\t\tadd_node_to_plot(val, plot, addr_offset, row_offset, addr_div, row_div)\n\t\tend\n\tend\nend",
"def <<(data)\n node = DoubleNode.new(:data => data)\n\n # list has nodes, add this to last\n if @tail\n @tail.tail = node\n node.head = @tail\n\n # list empty, add first node\n else\n @head = node\n end\n\n # node always added to end of list\n @tail = node\n @size += 1\n\n self\n end",
"def graph_time_data\r\n g = Gruff::Line.new\r\n g.data :data, @time_data\r\n end",
"def grafico_activitad(vaca,num_dias)\n\n date_actividad = num_dias.days.ago.localtime\n\n actividades_total = vaca.actividades.where(\"registrada >= ? and tipo = ?\", date_actividad,'recorrido') \n n=0\n data_total = [[]]\n data_prom = [[]]\n \n actividades_total.each do |actividad|\n data_total[n] = [actividad.registrada.localtime,actividad.valor]\n act_prom = actividad_promedio_en(actividad.registrada)\n data_prom[n] = [actividad.registrada.localtime,act_prom]\n n = n+1\n end \n \n startPoint = 24.hours.ago.localtime\n if !data_total[0][0].nil? && data_total.size >0 \n startPoint = data_total[0][0].advance(:hours => (-3).to_i).localtime\n end\n startPoint = startPoint.change(:min => 0)\n \n @chart = LazyHighCharts::HighChart.new('graph') do |f|\n f.options[:chart][:defaultSeriesType] = \"spline\"\n f.options[:chart][:zoomType] = \"x\"\n f.options[:legend][:align] = \"right\"\n f.options[:legend][:verticalAlign] = \"top\"\n f.options[:legend][:floating] = \"true\"\n f.global(:useUTC => 'false')\n\n f.series(:name=>'Actividad Vaca ' + vaca.caravana.to_s, :data => data_total, \n :pointInterval => 3600000,:pointStart => (startPoint.to_i * 1000))\n f.series(:name=>'Actividad Promedio', :data => data_prom, \n :pointInterval => 3600000,:pointStart => (startPoint.to_i * 1000))\n \n f.options[:yAxis][:title] = {text: \"Eventos\"}\n f.options[:xAxis][:maxZoom] = \"14 * 24 * 3600000\"\n f.options[:xAxis][:type] = \"datetime\"\n f.options[:tooltip][:shared] = 'true'\n \n f.title(text: 'Actividad Vaca ' + vaca.caravana.to_s + ' ultimos ' + num_dias.to_s + ' dias') \n end\n\n return @chart\nend",
"def add_point\n end",
"def plot; end",
"def series(*eras); end",
"def data_set(data, &block)\n Gnuplot::DataSet.new(data) do |ds|\n ds.with = config.linetype\n ds.linewidth = config.linewidth\n block.call(ds) if block_given?\n end\nend",
"def show\n @chart = LazyHighCharts::HighChart.new('area') do |f|\n f.title(:text => \"Shots\")\n f.xAxis(:categories => @player.games.pluck(:opponent_name))\n\n f.series(:name => \"Points\", :yAxis => 0, :data => @player.stat_per_game(:points)) \n\n f.series(:name => \"Field Goals\", :yAxis => 0, :data => @player.stat_per_game(:field_goals)) \n\n f.series(:name => \"Free Throws\", :yAxis => 0, :data => @player.stat_per_game(:free_throws)) \n\n f.series(:name => \"Three Pointers\", :yAxis => 0, :data => @player.stat_per_game(:three_pointers)) \n\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n\n f.chart({defaultSeriesType: \"column\"})\n end\n end",
"def add(type, *data)\n df = DataFrame.new({x: data[0], y: data[1], z: data[2]})\n return add_with_df(df, type, :x, :y, :z)\n end",
"def add_first_node(data)\n @head = Node.new(data, nil)\n @tail = @head\n end",
"def add_node(data)\n if @head.nil?\n add_first_node(data)\n else\n new_node = Node.new(data, nil)\n @tail.next = new_node\n @tail = new_node\n end\n # puts \"Added node with value: #{data}\"\n end",
"def add_first_node(data)\n\t\t@head = Node.new(data, nil)\n\t\t@last = @head\n\tend",
"def to_flot\n [\n { label: \"Pageviews\", data: pageviews },\n { label: \"Downloads\", data: downloads }\n ]\n end",
"def plot(title, legend_titles, data)\n graph = Scruffy::Graph.new\n graph.title = title\n graph.renderer = Scruffy::Renderers::Standard.new\n data.each_index do |idx|\n graph.add(:line, legend_titles[idx], data[idx],\n {'stroke-width'=> 7, :stroke => 'black'})\n end\n graph.render :to => \"#{title}.svg\", :width=>500, :height=>400\nend",
"def +(data)\n DataArray.new(x_name: @x_name, y_axis: @y_axis, data: super(normalize(data)))\n end",
"def add_first(data)\n new_node = Node.new(value, @head)\n @head = new_node\n end",
"def add_data\n Sol.add_data(\"native_array\", @data.nc_array)\n Sol.add_data(\"labels\", @dimension_labels.nc_array)\n end",
"def show\n @devise = Devise.find(params[:id])\n @level = []\n @name = Devise.find(params[:id]).name \n Devise.find(params[:id]).histories.each do |x|\n @level << x.percentage \n @level << x.percentage \n @level << x.percentage \n @level << x.percentage \n end\n \n @h = LazyHighCharts::HighChart.new('graph') do |f|\n f.options[:title][:text] = \"#{@name}'s Light History\"\n f.series(:name=>'Percentage of Light', :data=> @level, type: \"areaspline\", pointInterval: 24 * 3600 * 1000, pointStart: Time.utc(2012,\"aug\",1,20,15,1).to_i * 1000 )\n f.options[:xAxis][:type] = \"datetime\"\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @devise }\n end\n end",
"def series_type\n end",
"def series(*eras)\n from_eras(*eras, field: :series)\n end",
"def series(*eras)\n from_eras(*eras, field: :series)\n end",
"def add_datapoint(key)\n @redis.sadd \"datapoints\", key\n end",
"def add_first(data)\n @head = Node.new(data, head)\n end",
"def write_series(series) # :nodoc:\n write_ser(series)\n end",
"def write_series(series) # :nodoc:\n write_ser(series)\n end",
"def get_series (series_name)\n end",
"def add_first(data)\n @head = Node.new(data, @head)\n end",
"def add_first(data)\n @head = Node.new(data, @head)\n end",
"def add_first(data)\n @head = Node.new(data, @head)\n end",
"def show\n \n @end_at = Date.today\n @start_at = @end_at - 6\n @categories = @start_at.upto(@end_at).to_a\n\n \t#Sales Historyグラフ\n @sales_data = [500, 600, 300, 100, 200, 400, 700,500, 600, 300, 100, 200, 400, 700,100, 200, 400, 700,500, 600, 600, 300, 100, 200,]\n @sales_history = LazyHighCharts::HighChart.new(\"graph\") do |f|\n f.title(:text => \"Sales History\", :align =>\"left\")\n f.chart(:type => \"column\")\n f.xAxis(:categories => @categories)\n f.series(:name => \"Sales\", :data => @sales_data)\n\t end\n\n#Order Historyのグラフ\n @order_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @order_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @order_data)\n end\n\n#Price Historyのグラフ\n @price_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @price_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @price_data)\n end\n \n \n end",
"def add_graph_option(o)\n @options.push(o)\n end",
"def add_first(data)\n\n new_node = Node.new(data) # create a new node\n new_node.next = @head # assign the new node's NEXT to the @head\n @head = new_node # assign the head position to the new node\n end",
"def series_json(params={})\n # Create data for charts\n color = params[:color] ||= 'AA4643'\n color = '#' + color\n series = []\n data = []\n\n data << [self.baseline_date, (self.baseline.round*100).round / 100.0]\n # For ideal data\n self.progresses.each{|progress| \n data << [progress.due_date, (progress.accuracy*100).round / 100.0]\n }\n data << [self.due_date, (self.accuracy*100).round / 100.0]\n #Sort data by due date\n data = data.sort_by { |hsh| hsh[0] }\n \n series << {\n :type => 'line',\n :name => \"Ideal chart\",\n :data => data\n }\n if color && color == '#4572A7'\n series[0][:color] = \"#AA4643\"\n end\n # For add grade \n data = []\n self.grades.find_each{|grade| \n data << [grade.due_date, (grade.accuracy*100).round / 100.0]\n }\n data = data.sort_by { |hsh| hsh[0] }\n series << {\n :name => self.name,\n :data => data,\n :color => color \n }\n series.to_json\n end",
"def add_first(data)\n new_node = Node.new(data, nextNode = @head)\n @head = new_node\n end",
"def add_first(data)\n new_node = Node.new(data)\n new_node.next = @head\n @head = new_node\n end",
"def add_first(data)\n new_node = Node.new(data)\n new_node.next = @head\n @head = new_node\n end",
"def add_first(data) \n @head = Node.new(data, @head)\n end",
"def add(data)\n node = Node.new(data: data)\n if head\n tail.next_node = node\n else\n @head = node\n end\n\n @tail = node\n self\n end",
"def add_square(point)\n @squares << point\n end",
"def set_gold_chart\n @chart = [[0, 2], [0, 3], [0, 4], [0, 5], [3, 3], [5, 0], [10, 0]]\n end",
"def show\n @chart = Chart.find(params[:id])\n @chartnodes = @chart.chartnodes\n data = @chart.chartnodes.map {|node| [node.xaxis, node.yaxis]}.transpose\n if @chart.charttype == 'column'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'column',:name=> @chart.name,:data=> data[1])\n end\n elsif @chart.charttype == 'spline'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'spline',:name=> @chart.name,:data=> data[1])\n f.plot_options( :spline => {\n :dataLabels => {\n :enabled => true\n }})\n f.tooltip( :crosshairs => true, :shared => true)\n end\n elsif @chart.charttype == 'pie'\n @h1 = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> 'pie',\n :name=> @chart.name,\n :data=> data.transpose\n }\n f.series(series)\n f.options[:title][:text] = \"Browser share\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n #:cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chart }\n end\n end",
"def multi_axis_series(series_name_attributes, attributes_of_interest, chart_data_arr, series_options=[{}, {\"type\" => \"line\", \"yAxis\"=>1}, {\"type\" => \"line\", \"yAxis\"=>2}])\n series = []\n\n chart_data_arr.each_with_index do |chart_data, index|\n inner_series = HighChartSeries.single_series(series_name_attributes[index], attributes_of_interest[index], chart_data, series_options[index])\n series << inner_series\n end\n\n return series\n end",
"def splot(*args)\n contents = parse_plot_args(SPlotItem,args)\n _plot_splot(\"splot\",contents)\n nil\n end",
"def series(opts = {})\n if not opts.empty?\n @series_data << OptionsKeyFilter.filter(opts.merge(:name => opts[:name], :data => opts[:data]))\n end\n end",
"def show\n @user = current_user\n @exercises = @user.exercises\n @exercise = Exercise.find(params[:id])\n @a = []\n @a << @exercise\n @attempt = @user.attempts.new\n @attempts = @exercise.attempts.where(user_id: current_user.id) \n attempts = @attempts.select(:score, :created_at)\n scores_over_time = []\n attempts.each do |attempt|\n scores_over_time.push({\n label: attempt.created_at.strftime(\"%m-%-d-%y\"),\n value: attempt.score,\n })\n end\n @exercise_chart = Fusioncharts::Chart.new({\n type: 'line',\n renderAt: 'chart-container',\n width: '400',\n height: '300',\n dataFormat: 'json',\n dataSource: {\n \"chart\": {\n \"caption\": \"#{@exercise.name} over time\",\n \n \"xAxisName\": \"Date\",\n \"yAxisName\": \"Weight\",\n \"paletteColors\": \"#0075c2\",\n \"bgColor\": \"#ffffff\",\n \"showBorder\": \"0\",\n \"showCanvasBorder\": \"0\",\n \"plotBorderAlpha\": \"10\",\n \"usePlotGradientColor\": \"0\",\n \"plotFillAlpha\": \"50\",\n \"showXAxisLine\": \"1\",\n \"axisLineAlpha\": \"25\",\n \"divLineAlpha\": \"10\",\n \"showValues\": \"1\",\n \"showAlternateHGridColor\": \"0\",\n \"captionFontSize\": \"14\",\n \"subcaptionFontSize\": \"14\",\n \"subcaptionFontBold\": \"0\",\n \"toolTipColor\": \"#ffffff\",\n \"toolTipBorderThickness\": \"0\",\n \"toolTipBgColor\": \"#000000\",\n \"toolTipBgAlpha\": \"80\",\n \"toolTipBorderRadius\": \"2\",\n \"toolTipPadding\": \"5\"\n },\n data: scores_over_time\n }\n })\n \n end",
"def create\n @series = Series.new(params[:series])\n\n respond_to do |format|\n if @series.save\n format.html { redirect_to @series, notice: 'Series se ha creado con éxito.' }\n format.json { render json: @series, status: :created, location: @series }\n else\n format.html { render action: \"new\" }\n format.json { render json: @series.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_noise(data)\n noise(data, :+)\n end",
"def to_s\n javascript_tag \"$(function(){\" +\n \"new Highcharts.Chart({\" +\n to_json +\n \"})\" +\n \"});\"\n end",
"def point(vals = nil, values: vals, tags: nil, time: nil)\r\n tags ||= series.tags\r\n point = Point.new(series.measurement, values, tags: tags, time: time)\r\n store_point(point)\r\n point\r\n end",
"def add_series\n @bib.series.each do |s|\n case s.type\n when \"journal\"\n @item.journal = s.title.title\n @item.number = s.number if s.number\n when nil then @item.series = s.title.title\n end\n end\n end",
"def add_first(data)\n # Create a new node\n new_node = Node.new(data)\n if @head.nil?\n @head = new_node\n return\n end\n\n new_node.next = @head \n # conection between the new node and the next one that is the head.\n @head = new_node # The new node becomes the head.\n\n end",
"def index\n @pregnancies = Pregnancy.order('heat_start_date, surgery_date')\n\n @plist = @pregnancies.already_due.order('due_date').map{|x| x.dog.call_name}.to_s.html_safe \n @colors = [ [ \"#8a10ae\" ],[ \"#f45a39\" ],[ \"#fa7083\" ],[ \"#b8ad3c\" ],[ \"#2babf2\" ],[ \"#1dae30\" ],[ \"#b6932d\" ],[ \"#e24436\" ]]\n @puppy_count = Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]}.to_s.html_safe\n \n \n # @chart = LazyHighCharts::HighChart.new('graph') do |f|\n # f.chart({:type => \"column\"})\n # f.title(:text => \"Pregnancies in 2003 as #{Date.today}\")\n # f.xAxis(:categories => @pregnancies.already_due.order('due_date').map{|x| x.dog.call_name})\n \n # # f.tooltip(:formatter => \"function() { return this.x +' '+ this.y + '<br>'+' Total:' + this.point.stackTotal;}\".js_code)\n\n # f.series(:name => \"Puppies survive\", :data => @pregnancies.already_due.order('due_date').map{|x| x.litters.where(survival: true).size})\n # f.series(:name => \"Puppies not survive\", :data => @pregnancies.already_due.order('due_date').map{|x| x.litters.where(survival: false).size})\n \n # f.plotOptions({column:{\n # stacking: 'normal',\n # # pointPadding: 0,\n # groupPadding: 0, \n # dataLabels:{\n # enabled: true,\n # color: 'white'}\n # }})\n\n # f.yAxis( \n # title: { text: \"Puppies\", margin: 50},\n # stackLabels: {\n # style: {color: 'gray'},\n # enabled: true}\n # )\n\n # f.series(:type => \"pie\", :name=> 'puppies', \n # :center=> [150, 80], :size=> 150, :showInLegend=> false,\n # :data =>Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]},\n # :colors => @colors)\n # end\n\n # @colors = Color.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n # @chart3 = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 50, 50, 50]})\n # series = {\n # :type=> 'pie',\n # :name=> 'Browser share',\n # :data=> Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]},\n # # :data => Pregnancy.set_value( Color.all.map{|c| [c.name, c.litters.size]} ),\n # :colors => @colors,\n # showInLegend: false\n # }\n\n # f.series(series)\n # f.options[:title][:text] = \"Puppies by colors\"\n # f.legend(:layout=> 'vertical',:width => 220,:borderWidth => 0, align: 'left', verticalAlign: 'middle') \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\"\n # }\n # })\n # end\n\n # @chart1 = LazyHighCharts::HighChart.new('graph') do |f|\n # f.title({ :text=>\"Combination chart\"})\n # f.options[:xAxis][:categories] = ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']\n # f.labels(:items=>[:html=>\"Total fruit consumption\", :style=>{:left=>\"40px\", :top=>\"8px\", :color=>\"black\"} ]) \n # f.series(:type=> 'column',:name=> 'Jane',:data=> [3, 2, 1, 3, 4])\n # f.series(:type=> 'column',:name=> 'John',:data=> [2, 3, 5, 7, 6])\n # f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])\n # f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])\n # f.series(:type=> 'spline',:name=> 'Average', :data=> [3, 2.67, 3, 6.33, 3.33])\n # f.series(:type=> 'pie',:name=> 'Total consumption', \n # :data=> [\n # {:name=> 'Jane', :y=> 13, :color=> 'red'}, \n # {:name=> 'John', :y=> 23,:color=> 'green'},\n # {:name=> 'Joe', :y=> 19,:color=> 'blue'}\n # ],\n # :center=> [100, 80], :size=> 100, :showInLegend=> false)\n # end \n\n # @chart2 = LazyHighCharts::HighChart.new('graph') do |f|\n # f.title(:text => \"Population vs GDP For 5 Big Countries [2009]\")\n # f.xAxis(:categories => [\"United States\", \"Japan\", \"China\", \"Germany\", \"France\"])\n # f.series(:name => \"GDP in Billions\", :yAxis => 0, :data => [14119, 5068, 4985, 3399, 2656])\n # f.series(:name => \"Population in Millions\", :yAxis => 1, :data => [310,127,1340,81,65])\n\n # f.yAxis [\n # {:title => {:text => \"GDP in Billions\", :margin => 70}},\n # {:title => {:text => \"Population in Millions\"}, :opposite => true},\n # ]\n # f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n # f.chart({:defaultSeriesType => \"column\"})\n # end\n # @chart3 = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n # series = {\n # :type=> 'pie',\n # :name=> 'Browser share',\n # :data=> [\n # ['Firefox', 45.0],\n # ['IE', 26.8],\n # {\n # :name=> 'Chrome', \n # :y=> 12.8,\n # :sliced=> true,\n # :selected=> true\n # },\n # ['Safari', 8.5],\n # ['Opera', 6.2],\n # ['Others', 0.7]\n # ]\n # }\n # f.series(series)\n # f.options[:title][:text] = \"THA PIE\"\n # f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\",\n # :style=>{\n # :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n # }\n # }\n # })\n # end\n\n # @chart4 = LazyHighCharts::HighChart.new('column') do |f|\n # f.series(:name=>'John',:data=> [3, 20, 3, 5, 4, 10, 12 ])\n # f.series(:name=>'Jane',:data=>[1, 3, 4, 3, 3, 5, 4,-46] ) \n # f.title({ :text=>\"example test title from controller\"})\n\n # ### Options for Bar\n # ### f.options[:chart][:defaultSeriesType] = \"bar\"\n # ### f.plot_options({:series=>{:stacking=>\"normal\"}})\n\n # ## or options for column\n # f.options[:chart][:defaultSeriesType] = \"column\"\n # f.plot_options({:column=>{:stacking=>\"percent\"}})\n # end\n\n\n \n\n respond_to do |format|\n format.html\n format.csv {send_data @pregnancies.to_csv}\n format.xls #{send_data @pregnancies.to_csv(col_sep: \"\\t\")}\n end\n end",
"def create\n @series = Series.new(series_params)\n \n respond_to do |format|\n if @series.save\n format.html { redirect_to @series, notice: 'Series was successfully created.' }\n format.json { render :show, status: :created, location: @series }\n else\n format.html { render :new }\n format.json { render json: @series.errors, status: :unprocessable_entity }\n end\n end\n end",
"def basic_chart\n \n end",
"def create\n @series = Series.new(params[:series])\n if @series.save\n flash[:notice] = t('successfully_created', :default => 'Series was successfully created.')\n redirect_to(@series)\n else\n render :action => \"new\"\n end\n end",
"def plot_2d\n plotter = Plotter.new(:title => \"Signal: values vs. time\", :xtitle => \"time (sec)\", :ytitle => \"sample value\")\n \n data_vs_time = {}\n sp = 1.0 / @sample_rate\n @data.each_index do |i|\n data_vs_time[i * sp] = @data[i]\n end\n \n plotter.plot_2d \"signal data\" => data_vs_time\n end",
"def insert(data)\n node_to_insert = SinglyListNode.new(data, nil)\n if @head.nil? && @tail.nil?\n # both and head and tail is empty so make data both\n @head = node_to_insert\n @tail = @head\n else \n @tail.nextNode = node_to_insert\n @tail = node_to_insert\n end\n @length += 1\n end",
"def getchart()\n # Use random table to generate a random series. The random table is set to 1 col x\n # 51 rows, with 9 as the seed\n rantable = ChartDirector::RanTable.new(9, 1, 51)\n\n # Set the 1st column to start from 100, with changes between rows from -5 to +5\n rantable.setCol(0, 100, -5, 5)\n\n # Get the 1st column of the random table as the data set\n data = rantable.getCol(0)\n\n # Create a XYChart object of size 600 x 300 pixels\n c = ChartDirector::XYChart.new(600, 300)\n\n # Set the plotarea at (50, 35) and of size 500 x 240 pixels. Enable both the\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 35, 500, 240).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"LOWESS Generic Curve Fitting Algorithm\", \"timesbi.ttf\", 18)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Set the x axis scale from 0 - 50, with major tick every 5 units and minor tick\n # every 1 unit\n c.xAxis().setLinearScale(0, 50, 5, 1)\n\n # Add a blue layer to the chart\n layer = c.addLineLayer2()\n\n # Add a red (0x80ff0000) data set to the chart with square symbols\n layer.addDataSet(data, 0x80ff0000).setDataSymbol(ChartDirector::SquareSymbol)\n\n # Set the line width to 2 pixels\n layer.setLineWidth(2)\n\n # Use lowess for curve fitting, and plot the fitted data using a spline layer with\n # line width set to 3 pixels\n c.addSplineLayer(ChartDirector::ArrayMath.new(data).lowess().result(), 0x0000ff\n ).setLineWidth(3)\n\n # Set zero affinity to 0 to make sure the line is displayed in the most detail\n # scale\n c.yAxis().setAutoScale(0, 0, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def addPoints(points) \n\t\t@points += points\n\tend",
"def add_first(data)\n first = Node.new(data, head)\n @head = first\n end",
"def create\n @income = Income.new(income_params)\n if user_signed_in?\n @income.user_id = current_user.id\n end\n @income.month=Date.today.month\n @income.year=Date.today.year\n @income.day_rec=Date.today.day\n@income_chart_data=[['IE',56.33],['Chrome',24.03],['Safari',4.77],['Opera',0.91],{name: 'Proprietary or Undetectable',y: 0.2,dataLabels: {enabled: false}}]\n respond_to do |format|\n if @income.save\n format.js\n end\n end\n end",
"def index\n @series = Series.all\n end",
"def index\n @series = Series.all\n end",
"def index\n @series = Series.all\n end",
"def to_flot\n [\n { label: \"Pageviews\", data: pageviews }\n ]\n end",
"def add_node(data)\n\n\t\t# change tactics if we're adding the first node\n\t\tif @head.nil?\n\n\t\t\tadd_first_node(data)\n\n\t\telse\n\n\t\t\tnew_node = Node.new(data)\n\n\t\t\t# point the last node to our new one\n\t\t\t@last.next = new_node\n\n\t\t\t# set our new node as the official last node\n\t\t\t@last = new_node\n\n\t\tend\n\t\tputs \"Added node with the value: #{data}\"\n\tend",
"def plot_random_dataset(**options)\n options = {:sort => false, :reverse => false }.merge(options)\n data = []\n 10.times { data << rand(500) }\n data = data\n data.sort!() if options[:sort]\n data.reverse!() if options[:reverse]\n graph.plot(data, {:line => 'i', :frame => false, :tags => true})\n end",
"def index\n @chart.series.index(self)\n end",
"def create\n @series = Series.new(series_params)\n\n respond_to do |format|\n if @series.save\n format.html { redirect_to @series, notice: 'Series was successfully created.' }\n format.json { render action: 'show', status: :created, location: @series }\n else\n format.html { render action: 'new' }\n format.json { render json: @series.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.66957986",
"0.65119624",
"0.65119624",
"0.6344792",
"0.6328301",
"0.6260133",
"0.59435666",
"0.59323615",
"0.5903344",
"0.5747088",
"0.57343537",
"0.5729264",
"0.56942457",
"0.56280476",
"0.55120796",
"0.5499946",
"0.5490214",
"0.53849816",
"0.5332435",
"0.53242993",
"0.52855116",
"0.5261717",
"0.52527183",
"0.5238092",
"0.5238092",
"0.5188754",
"0.5173339",
"0.5166964",
"0.5164497",
"0.5164162",
"0.51577955",
"0.51518875",
"0.5139346",
"0.50981176",
"0.50707287",
"0.50622493",
"0.50426203",
"0.5026632",
"0.501775",
"0.49693805",
"0.4963944",
"0.49518102",
"0.49440065",
"0.49421862",
"0.4938892",
"0.49282157",
"0.49279657",
"0.49256954",
"0.4924183",
"0.49226934",
"0.49209255",
"0.49209255",
"0.4916061",
"0.49131",
"0.49053422",
"0.49053422",
"0.4902488",
"0.49012133",
"0.49012133",
"0.49012133",
"0.48958465",
"0.4890654",
"0.48866126",
"0.48796225",
"0.48764604",
"0.4871363",
"0.4871363",
"0.48701778",
"0.48630974",
"0.48588884",
"0.4854067",
"0.48392618",
"0.4836063",
"0.48349813",
"0.483203",
"0.48242128",
"0.48217204",
"0.48085278",
"0.48044884",
"0.48039132",
"0.47889185",
"0.47847012",
"0.4783153",
"0.47795472",
"0.47693533",
"0.476439",
"0.47592595",
"0.4747904",
"0.47465765",
"0.47434208",
"0.4739851",
"0.4721813",
"0.4714869",
"0.4714869",
"0.4714869",
"0.47133064",
"0.471154",
"0.47027874",
"0.46960804",
"0.46943915"
] | 0.5917182 | 8 |
This method will generate the options as a string suitable for straight use. This is required because of the addition of the datetime capability put in. The dates need to be formatted in a JS specific way. | def options_string
options_collection = []
options.keys.each do |key|
k = key.to_s.camelize.gsub!(/\b\w/) { $&.downcase }
options_collection << "\"#{k}\": #{options[key].to_json}"
end
# This check is put in to catch for those graphs that are time series charts. In that event the
# data needs to be reformated rather than just a blind JSON conversion
if data.first[:data].first.class == Array and (data.first[:data].first.first.instance_of? DateTime or data.first[:data].first.first.instance_of? Date)
series_string = "\"series\": ["
data.each do |single_series|
series_string << "{\"name\":\"#{single_series[:name]}\", \"data\":["
single_series[:data].each do |single_data|
series_string << "[#{single_data[0].strftime('%s').to_i * 1000},#{single_data[1]}]"
series_string << "," unless single_data == single_series[:data].last
end
series_string << "]}"
series_string << "," unless single_series == data.last
end
series_string << "]"
options_collection << series_string
else
# If this isn't a time series chart then just convert the data to JSON directly
options_collection << "series: #{data.to_json}"
end
return "{#{options_collection.join(',')}}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_format_options\n DATE_FORMATS.collect {|f| [\"#{Date.today.strftime(f)} - #{f}\", f]}\n end",
"def to_s\n @options.join \" \"\n end",
"def to_s\n \"<#{options.inspect}>\"\n end",
"def date(options = {})\n res = \"\"\n res += \"#{I18n.localize(self.starts_at, :format => '%A %d')} de \" if options[:include_week_day] != false\n res += \"#{I18n.localize(self.starts_at, :format => '%B')} de \" if options[:include_month] != false\n # TODO: hack hack hack 20 min\n res += \"#{self.starts_at.strftime(\"%H:%M\")} a #{self.ends_at.strftime(\"%H:%M\")}\"\n end",
"def format_date options = {}\n dates = options[:start_date].strftime(\"%D\") if options[:start_date]\n dates << \" -- \" + options[:end_date].strftime(\"%D\") if options[:end_date]\n dates = \"N/A\" if !dates\n return dates\n end",
"def to_s\n OPTIONS\n .reject { |v| send(v).nil? }\n .map { |v| \"#{v}=#{send(v)}\" }\n .join(',')\n end",
"def options_as_string\n buff = []\n opts = options\n opts.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |k|\n value = opts[k]\n buff << sprintf( \":%s => '%s'\", k, value.to_s ) if !value.nil? and !value.is_a? YAML::Omap\n end \n buff.join( \",\" )\n end",
"def compile_options\n str = String.new\n @options.each { |o| str = str + ' ' + o.compile }\n return str\n end",
"def inline_options(options = {})\n return '' if options.empty?\n (options.stringify_keys.sort.to_a.collect { |a, b| \"#{a}=\\\"#{b}\\\"\" }).join(' ') << ' '\n end",
"def inline_options(options = {})\n return '' if options.empty?\n (options.stringify_keys.sort.to_a.collect { |a, b| \"#{a}=\\\"#{b}\\\"\" }).join(' ') << ' '\n end",
"def options_string(options)\n return nil if Hash(options).size.zero?\n\n options.map do |k, v|\n [k.to_s, v.to_s].join\n end.join.gsub(/[^A-Za-z0-9\\-_]/, '')\n end",
"def to_s\n \n options = \"\"\n options << \" -t\" << self.target_type unless self.target_type.nil?\n options << \" -m\" << self.min_size.to_s unless self.min_size.nil?\n options << \" -n\" << self.max_size.to_s unless self.max_size.nil?\n options << \" -s\" << self.min_supp.to_s unless self.min_supp.nil?\n options << \" -c\" << self.min_conf.to_s unless self.min_conf.nil?\n options << \" -e\" << self.add_eval.to_s unless self.add_eval.nil?\n options << \" -d\" << self.min_add_eval.to_s unless self.min_add_eval.nil?\n options << \" -v\" << \"\\\";\" << self.output_format << \"\\\"\" unless self.output_format.nil?\n \n options\n \n end",
"def to_option_string(obj)\n case obj\n when PoolParty::Resources::Resource\n \"resources(:#{handle_types(obj.class.to_s.top_level_class.downcase.to_sym)} => \\\"#{obj.name}\\\")\"\n when Fixnum\n \"#{obj.to_i}\"\n when String\n \"\\\"#{obj}\\\"\"\n when Array\n if obj[1] && [:immediately, :delayed].include?(obj[1])\n \"#{to_option_string(obj[0])}, :#{obj[1]}\"\n else\n \"[ #{obj.map {|e| to_option_string(e) }.reject {|a| a.nil? || a.empty? }.join(\", \")} ]\"\n end \n when nil\n nil\n when Hash\n \"#{obj.map {|k,v| \":#{k} => #{to_option_string(v)}\" unless v == obj }.compact.join(\",\\n\")}\"\n else\n \"#{obj}\"\n end\n end",
"def inline_options(options = {})\n return '' if options.empty?\n (options.stringify_keys.to_a.collect { |a, b| \"#{a}=\\\"#{b}\\\"\" }).join(' ')\n end",
"def option_values_to_s\n option_values_string = \"\"\n \n option_values.by_option_type_id.each_with_index do |option_value, index|\n option_values_string << option_value.option_type.name\n option_values_string << \": \" + option_value.name\n option_values_string << \" / \" unless ( index + 1 ) == option_values.size\n end\n \n option_values_string\n end",
"def options_formatted(options = {})\n options.delete_if { |k, v| v.nil? }\n mod_options = MODULES.map { |mod| mod.options_formatted(options) }\n formatted_options = mod_options.inject(:merge)\n [:flags, :output_path].each do |option|\n formatted_options[option] = options[option] unless options[option].nil?\n end\n formatted_options\n end",
"def format_options(options)\n data = []\n options.each do |name, option_spec|\n data << format_option(option_spec)\n end\n \"Options:\\n\" + render_table(data, \": \")\n end",
"def create_datetime_options(attrs, method = nil)\n values = if (time = attrs[:value])\n case time\n when Time, DateTime\n { :day => time.day,\n :month => time.month,\n :year => time.year,\n :hour => time.hour,\n :minute => time.min }\n when Date\n { :day => time.day,\n :month => time.month,\n :year => time.year }\n end\n end\n\n datetime_options.inject({}) do |h, (suffix, defaults)|\n h[suffix] = defaults.merge(attrs).merge(\n :id => '%s_%s' % [attrs[:id] || attrs[:name], suffix],\n :name => '%s[%s]' % [attrs[:name] || attrs[:id], suffix],\n :value => values && values[suffix]\n ) ; h\n end\n end",
"def make_options(items)\n items.map do |item|\n if item.is_a?(Array)\n \"<option value=\\\"#{item.last}\\\">#{item.first}</option>\"\n else\n \"<option value=\\\"#{item}\\\">#{item}</option>\"\n end\n end.join(\"\\n\")\n end",
"def to_s\n option.to_s\n end",
"def to_s\n @option_parser.to_s\n end",
"def to_html_options(options)\n return if options.empty?\n options.delete(:callback) if options[:callback].present?\n options.delete(:class) if options[:class].present?\n\n output = \"\"\n options.each do |k, v|\n output += %Q[#{k.to_s}=\"#{v}\" ]\n end\n\n output\n end",
"def scaffold_options_to_html(options)\n options.collect{|k,v| \"#{k}=\\\"#{h v.to_s}\\\"\"}.join(' ')\n end",
"def format_datelike_objects!(options)\n new_opts = {}\n options.map do |k,v|\n if v.respond_to?(:map)\n new_opts[k] = format_datelike_objects!(v)\n else\n new_opts[k] = v.respond_to?(:strftime) ? v.strftime(\"%d/%m/%Y\") : v\n end\n end\n new_opts\n end",
"def build_options(selected, options = {})\n options = {\n leading_zeros: true, ampm: false, use_two_digit_numbers: false\n }.merge!(options)\n\n start = options.delete(:start) || 0\n stop = options.delete(:end) || 59\n step = options.delete(:step) || 1\n leading_zeros = options.delete(:leading_zeros)\n\n select_options = []\n start.step(stop, step) do |i|\n value = leading_zeros ? sprintf(\"%02d\", i) : i\n tag_options = { value: value }\n tag_options[:selected] = \"selected\" if selected == i\n text = options[:use_two_digit_numbers] ? sprintf(\"%02d\", i) : value\n text = options[:ampm] ? AMPM_TRANSLATION[i] : text\n select_options << content_tag(\"option\", text, tag_options)\n end\n\n (select_options.join(\"\\n\") + \"\\n\").html_safe\n end",
"def sorted_option_string(options)\n options.map {|k, v| \"#{k}#{v}\" }.sort.join\n end",
"def to_s\n element_string = '['\n @options.each { |option| element_string.concat(\"#{option.join(',')}|\") }\n element_string.chop.concat(']')\n end",
"def to_json\n options.collect {|k, v| \"\\\"#{k}\\\":#{v.is_a?(Array) ? \"[{#{v.collect(&:to_json).join('},{')}}]\" : \"{#{v.to_json}}\"}\"}.join(',')\n end",
"def format_date(options={})\n \t@date_type = options[:date_type]\n \t@start_date = options[:start_date]\n \t@end_date = options[:end_date]\n \t@due = options[:due]\n\n if @date_type == \"event\"\n \tdates = @start_date.strftime(\"%D\") if @start_date\n \tdates << \" -- \" + @end_date.strftime(\"%D\") if @end_date\n \tdates = \"N/A\" if !dates\n elsif @date_type == \"todo\"\t\t\t\n \tdates = @due ? @due.strftime(\"%D\") : \"No due date\" \n end\n \n return dates\n end",
"def dialog_options_to_js(options={})\n js_kv_pairs = []\n sorted_keys = options.keys.map { |k| k.to_s }.sort.map { |s| s.to_sym }\n \n sorted_keys.each do |key|\n js_key = key.to_s.camelcase(:lower)\n js_value = \"null\" \n \n options[key] = options[key].to_s unless options[key].respond_to?(:empty?)\n \n unless options[key].empty?\n case key\n when :before_show, :after_show, :before_hide, :after_hide\n js_value = \"#{options[key]}\" \n else\n js_value = \"'#{options[key]}'\" \n end\n end\n \n js_kv_pairs << \"'#{js_key}':#{js_value}\"\n end\n \n \"{#{js_kv_pairs.join(',')}}\"\n end",
"def full_options\n options_collection_as_string self\n end",
"def default_options\n {\n \"Created Date Range\" => {:field_type => :date_range, :for => \"short_interaction_created_at\", :from => \"2012-03-01\".to_date, :to => Time.current},\n Institution => {:field_type => :select_tag, :has_dependencies => \"true\"},\n Provider => {:field_type => :select_tag, :dependency => '#institution_id', :dependency_id => 'parent_id'},\n Program => {:field_type => :select_tag, :dependency => '#provider_id', :dependency_id => 'parent_id'},\n }\n end",
"def to_s\n \"Option :#{@option_name} is not a recognised option.\"\n end",
"def options_string\n self.form_field_options.map {|ffo| ffo.label}.join(', ')\n end",
"def render_options\n hsh = {}\n if minval = @minimalize\n @units = ABBREVIATED_DECIMAL_UNITS\n @format = \"%n%u\"\n @precision = minval\n @strip_insignificant_zeros = true\n @delimiter = ''\n @significant = true\n end\n\n\n hsh[:number_to_human] = HUMAN_ACCESSORS.inject({}) do |h, att|\n if val = self.instance_variable_get(\"@#{att}\")\n h[att] = val\n end\n\n h\n end\n\n return hsh\n end",
"def getOptions(options)\n\t\t\n\t\tputs \"Name\".ljust(19) + \"Description\".ljust(19) + \"Required\".rjust(19) + \"Current Value\".rjust(19)\n\n\t\t@@opt.each{|d| puts d[\"name\"].ljust(19) + d[\"description\"].ljust(19) + d[\"required\"].to_s.rjust(15) + getCurrentOption(d[\"name\"]).rjust(22)}\n\tend",
"def build_opts_string(*additional_opts)\n options = build_opts + additional_opts\n options = options << \"2>&1 | ocunit2junit\" if test_output == :junit\n return options.compact.join(\" \")\n end",
"def transform_options(options)\n options.inject([]) do |result, (option, value)|\n option = option.to_s.gsub(/_/, '-')\n \n result << if option.size == 1\n value == true ? \"-#{option}\" : \"-#{option} '#{e(value)}'\" \n else\n value == true ? \"--#{option}\" : \"--#{option}='#{e(value)}'\" \n end\n end\n end",
"def options_text\n options.map{ |opt| opt.text}\n end",
"def raw_options(options, indent=0)\n out = []\n options.each do |option|\n out << \"#{' '*indent}#{option};\"\n end if options\n out << ''\n end",
"def options_text\n versioned_definition.options_text\n end",
"def _format_date_select(values, order)\n name = @attr[:name]\n id = @attr[:id]\n ops = DEFAULT_DATE_SELECT_OPS\n ops = ops.merge(@opts[:select_options]) if @opts[:select_options]\n first_input = true\n format = DATE_SELECT_FORMAT\n @opts[:select_labels] ||= {}\n order.map do |x|\n next x if x.is_a?(String)\n options = ops[x].map do |value, text|\n [text || sprintf(format, value), value]\n end\n opts = @opts.merge(:label=>@opts[:select_labels][x], :wrapper=>nil, :error=>nil, :name=>\"#{name}[#{x}]\", :value=>values[x], :options=>options)\n opts[:id] = if first_input\n first_input = false\n id\n else\n \"#{id}_#{x}\"\n end\n form._input(:select, opts).format\n end\n end",
"def prepare_options(opts = [])\n opts.inject('') do |string, (option, value)|\n string += case\n when value\n create_option(option, value)\n when option.respond_to?(:each_pair)\n prepare_options(option)\n else\n create_option(option)\n end\n end\n end",
"def valid_options\n self::OPTIONS.map(&:to_s).join(', ')\n end",
"def options # :nodoc:\n [].tap do |o|\n o << \"Lazy\" if lazy?\n o << \"Reverse\" if reverse?\n o << \"Exclude [#{all_excluded_words.join(\", \")}]\" if excluded_words.any?\n o << \"No Options\" if o.empty?\n end\n end",
"def default_options_date_format(format)\n format || '%Y-%m-%d - %l:%M:%S%p'\n end",
"def options_for_javascript(options)\n if options.empty?\n '{}'\n else\n \"{#{options.keys.map { |k| \"#{k}:'#{escape_javascript(options[k])}'\" }.sort.join(', ')}}\"\n end\n end",
"def combined_options\n self.integer_options.all\n .concat(self.string_options)\n .concat(self.boolean_options)\n .concat(self.date_options)\n end",
"def to_s(options = {})\n map { |o| o.to_s(options) }.join\n end",
"def to_s\n \"#{start_date_as_string}-#{end_date_as_string}\"\n end",
"def hash_to_options(options)\n c = ''\n options.each do |key, option|\n c << \"#{key} : \"\n c << case\n when option.to_s.match(/function/i) then option\n when option.class == String then \"\\\"#{option}\\\"\"\n else option.to_s\n end\n c << \",\\n\"\n end\n c\nend",
"def to_options\n texts.zip(values)\n end",
"def to_s\n \"#{tag} #{[@from.quoteize, @to.quoteize, @options].compact.flatten * \" \"}\"\n end",
"def select_html(type, options, prefix = nil, include_blank = false, discard_type = false, disabled = false)\n select_html = %(<select name=\"#{prefix || 'date'})\n select_html << \"[#{type}]\" unless discard_type\n select_html << %(\")\n select_html << %( disabled=\"disabled\") if disabled\n select_html << %(>\\n)\n select_html << %(<option value=\"\"></option>\\n) if include_blank\n select_html << options.to_s\n select_html << \"</select>\\n\"\n select_html.html_safe\n end",
"def docopt_options(width)\n @options['Options'] = {} unless @options['Options']\n @options['Options']['-h --help'] = 'Show this screen'\n @options['Options']['--version'] = 'Show version number' if @version\n\n doc = []\n @options.each do |scope, values|\n doc << \"#{scope}:\"\n values.each do |flag, text|\n helpline = \" #{text}\"\n wrapped = word_wrap helpline, width\n doc << \" #{flag}\\n#{wrapped}\\n\"\n end\n end\n doc\n end",
"def build_year_options(selected, options = {})\n start = options.delete(:start)\n stop = options.delete(:end)\n step = options.delete(:step)\n\n select_options = []\n start.step(stop, step) do |value|\n tag_options = { value: value }\n tag_options[:selected] = \"selected\" if selected == value\n text = year_name(value)\n select_options << content_tag(\"option\", text, tag_options)\n end\n\n (select_options.join(\"\\n\") + \"\\n\").html_safe\n end",
"def date_range_select_tag(name_prefix, field, options = {})\n html = []\n [:start, :end].each do |part|\n html << calendar_date_select_tag(\n \"#{name_prefix}[#{field}][#{part}]\",\n (options[name_prefix][field][part] rescue ''),\n :size => 10\n )\n end\n\n return html.join(' ~ ')\n end",
"def to_s\n\t\t\tout = \"\"\n\t\t\tout << banner << \"\\n\"\n\t\t\t\n\t\t\t@order.each {|option|\n\t\t\t\tif (option.nil?)\n\t\t\t\t\tout << \"\\n\"\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\t\n line = sprintf(\"-%-2s --%-#{longest+6}s \",\n option.short_name,\n option.long_name + (option.flag ? \"\" : \" [VAL]\"))\n\n out << line\n if (line.length + option.description.length <= 80)\n out << option.description\n else\n rem = 80 - line.length\n desc = option.description\n i = 0\n while (i < desc.length)\n out << \"\\n\" if i > 0\n j = [i + rem, desc.length].min\n while desc[j..j] =~ /[\\w\\d]/\n j -= 1\n end\n chunk = desc[i..j].strip\n out << \" \" * line.length if i > 0\n out << chunk\n i = j + 1\n end\n end\n\n if (!option.flag)\n out << \" (default: #{option.default_value})\"\n end\n\n out << \"\\n\"\n }\n return out\n\t\tend",
"def build_year_options(selected, options = {})\n options = {\n leading_zeros: true, ampm: false, use_two_digit_numbers: false\n }.merge!(options)\n\n\n start = options.delete(:start) || 0\n stop = options.delete(:end) || 59\n step = options.delete(:step) || 1\n leading_zeros = options.delete(:leading_zeros)\n\n select_options = []\n start.step(stop, step) do |i|\n value = leading_zeros ? sprintf(\"%02d\", i) : i\n tag_options = { :value => value }\n tag_options[:selected] = \"selected\" if selected == i\n \n text = options[:use_two_digit_numbers] ? sprintf(\"%02d\", i) : value\n text = options[:ampm] ? AMPM_TRANSLATION[i] : text\n\n text = @options[:buddhist_era] ? \"#{text} (#{text + 543})\" : text\n\n select_options << content_tag(:option, text, tag_options)\n end\n\n (select_options.join(\"\\n\") + \"\\n\").html_safe\n end",
"def format_ds_opt(opt)\n modified = ''\n\n opt = opt.to_s\n opt.split('').each { |elem| modified << \"\\'#{elem}\\', \" }\n modified = \"#{modified}0\"\n end",
"def calendar_date_select_process_options(options)\n options, javascript_options = CalendarDateSelect.default_options.merge(options), {}\n image = options.delete(:image)\n callbacks = [:before_show, :before_close, :after_show, :after_close, :after_navigate]\n for key in [:time, :valid_date_check, :embedded, :buttons, :clear_button, :format, :year_range, :month_year, :popup, :hidden, :minute_interval] + callbacks\n javascript_options[key] = options.delete(key) if options.has_key?(key)\n end\n\n # if passing in mixed, pad it with single quotes\n javascript_options[:time] = \"'mixed'\" if javascript_options[:time].to_s==\"mixed\"\n javascript_options[:month_year] = \"'#{javascript_options[:month_year]}'\" if javascript_options[:month_year]\n\n # if we are forcing the popup, automatically set the readonly property on the input control.\n if javascript_options[:popup].to_s == \"force\"\n javascript_options[:popup] = \"'force'\"\n options[:readonly] = true\n end\n\n if (vdc=javascript_options.delete(:valid_date_check))\n if vdc.include?(\";\") || vdc.include?(\"function\")\n raise ArgumentError, \":valid_date_check function is missing a 'return' statement. Try something like: :valid_date_check => 'if (date > new(Date)) return true; else return false;'\" unless vdc.include?(\"return\");\n end\n\n vdc = \"return(#{vdc})\" unless vdc.include?(\"return\")\n vdc = \"function(date) { #{vdc} }\" unless vdc.include?(\"function\")\n javascript_options[:valid_date_check] = vdc\n end\n\n javascript_options[:popup_by] ||= \"this\" if javascript_options[:hidden]\n\n # surround any callbacks with a function, if not already done so\n for key in callbacks\n javascript_options[key] = \"function(param) { #{javascript_options[key]} }\" unless javascript_options[key].include?(\"function\") if javascript_options[key]\n end\n\n javascript_options[:year_range] = format_year_range(javascript_options[:year_range] || 10)\n [image, options, javascript_options]\n end",
"def format_date\n if @opts[:as] == :select\n values = {}\n if v = @attr[:value]\n v = Date.parse(v) unless v.is_a?(Date)\n values[:year], values[:month], values[:day] = v.year, v.month, v.day\n end\n _format_date_select(values, @opts[:order] || DEFAULT_DATE_ORDER)\n else\n _format_input(:date)\n end\n end",
"def generate_options(filename, code); end",
"def generate_options(filename, code); end",
"def build_options(options)\n options.inject([]) do |result, (opt, val)|\n if val\n result << \"--#{shellify_opt(opt)}\"\n result << shellify_opt(val) if val != true\n end\n result\n end\n end",
"def dhcpd_options(options, indent=0)\n out = []\n options.each do |key, value|\n value = value.join(', ') if value.class == Array\n out << \"#{' '*indent}option #{key} #{value.chomp};\"\n end if options\n out << ''\n end",
"def calendar_date_select_process_options(options)\r\n calendar_options = {}\r\n callbacks = [:before_show, :before_close, :after_show, :after_close, :after_navigate]\r\n for key in [:time, :valid_date_check, :embedded, :buttons, :format, :year_range, :month_year, :popup, :hidden, :minute_interval] + callbacks\r\n calendar_options[key] = options.delete(key) if options.has_key?(key)\r\n end\r\n \r\n # if passing in mixed, pad it with single quotes\r\n calendar_options[:time] = \"'mixed'\" if calendar_options[:time].to_s==\"mixed\"\r\n calendar_options[:month_year] = \"'#{calendar_options[:month_year]}'\" if calendar_options[:month_year]\r\n \r\n # if we are forcing the popup, automatically set the readonly property on the input control.\r\n if calendar_options[:popup].to_s == \"force\"\r\n calendar_options[:popup] = \"'force'\"\r\n options[:readonly] = true \r\n end\r\n \r\n if (vdc=calendar_options.delete(:valid_date_check))\r\n if vdc.include?(\";\") || vdc.include?(\"function\")\r\n throw \":valid_date_check function is missing a 'return' statement. Try something like: :valid_date_check => 'if (date > new(Date)) return true; else return false;'\" unless vdc.include?(\"return\");\r\n end\r\n \r\n vdc = \"return(#{vdc})\" unless vdc.include?(\"return\")\r\n vdc = \"function(date) { #{vdc} }\" unless vdc.include?(\"function\")\r\n calendar_options[:valid_date_check] = vdc\r\n end\r\n \r\n calendar_options[:popup_by] ||= \"this\" if calendar_options[:hidden]\r\n \r\n # surround any callbacks with a function, if not already done so\r\n for key in callbacks\r\n calendar_options[key] = \"function(param) { #{calendar_options[key]} }\" unless calendar_options[key].include?(\"function\") if calendar_options[key]\r\n end\r\n \r\n calendar_options[:year_range] = format_year_range(calendar_options[:year_range] || 10)\r\n calendar_options\r\n end",
"def serialize_options(options)\n options.collect {|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n end",
"def date_format_setting_options(locale)\n Setting::DATE_FORMATS.map do |f|\n today = ::I18n.l(User.current.today, :locale => locale, :format => f)\n format = f.delete('%').gsub(/[dmY]/) do\n {'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&]\n end\n [\"#{today} (#{format})\", f]\n end\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def answer_options(question)\n body = []\n today = question[:include_today].present? ? 0 : 1\n from_days_ago = question[:from_days_ago]\n date_format = question[:date_format].presence || DATE_FORMAT\n from_days_ago.downto(today) do |days_ago|\n date = days_ago.days.ago\n next if [6, 0].include?(date.wday) && question[:exclude_weekends].present?\n\n formatted_date = I18n.l(date, locale: question[:locale], format: date_format)\n option = {\n title: formatted_date,\n value: I18n.l(date, locale: :en, format: DATE_FORMAT_BACKEND)\n }\n option[:shows_questions] = question[:shows_questions] if question[:shows_questions].present?\n option[:hides_questions] = question[:hides_questions] if question[:hides_questions].present?\n if question[:morning_and_afternoon]\n option[:title] = \"#{formatted_date} #{I18n.t('time.am', locale: question[:locale])}\"\n option[:value] = I18n.l(date, locale: :en, format: DATE_FORMAT_BACKEND_AM)\n end\n body << days_option_body(question, option.merge(raw: option.deep_dup))\n next unless question[:morning_and_afternoon]\n\n new_option = option.merge(title: \"#{formatted_date} #{I18n.t('time.pm', locale: question[:locale])}\",\n value: I18n.l(date, locale: :en, format: DATE_FORMAT_BACKEND_PM))\n body << days_option_body(question, new_option.merge(raw: new_option.deep_dup))\n end\n safe_join(body)\n end",
"def generate_string(options = {})\n string = ''\n\n string << \"# -----BEGIN SECTION #{name}-----\\n\"\n\n @elements.each do |element|\n string << element.to_s(options)\n end\n\n string << \"# -----END SECTION #{name}-----\\n\"\n\n string\n end",
"def date_filter options\n # date search\n if date_present?(options[\"date_from\"]) || date_present?(options[\"date_to\"])\n from, to = date_set(options[\"date_from\"], options[\"date_to\"])\n options[\"f\"] = [] if !options.key?(\"f\")\n options[\"f\"] << \"date|#{from}|#{to}\"\n end\n options.delete(\"date_from\")\n options.delete(\"date_to\")\n [options, from, to]\n end",
"def out(args = {})\n str = \"\"\n date_shown = false\n time_shown = false\n \n if !args.key?(:date) or args[:date]\n date_shown = true\n str << \"#{\"%02d\" % @t_day}/#{\"%02d\" % @t_month}\"\n \n if !args.key?(:year) or args[:year]\n str << \" #{\"%04d\" % @t_year}\"\n end\n end\n \n if !args.key?(:time) or args[:time]\n show_time = true\n \n if args.key?(:zerotime) and !args[:zerotime]\n if @t_hour == 0 and @t_min == 0\n show_time = false\n end\n end\n \n if show_time\n time_shown = true\n str << \" - \" if date_shown\n str << \"#{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}\"\n end\n end\n \n return str\n end",
"def choice_option\n \"#{assigned_at.to_date.to_s} (#{user_name})\"\n end",
"def program_options\n [\n ['--format', '-f FORMAT', 'Format as html or text(default)',\n lambda { |value| options.format = value }\n ],\n ['--coffee', '-c', 'Show code as coffeescript',\n lambda { |value| options.coffee = true }\n ]\n ]\nend",
"def to_s\n # Comphrensive list of equivs options.\n # Most of them are not mandatory. Leave\n # the option nil if you don't need it.\n options = {\n :source => nil, # probably we'll never implement it\n :section => @package.section,\n :priority => @package.priority,\n :homepage => @package.homepage,\n :standards_version => @package.standards_version, \n :package => @package.name,\n :version => @package.version,\n :maintainer => self.maintainer, \n :pre_depends => @package.pre_depends,\n :depends => @package.depends,\n :reccomends => @package.reccomends,\n :suggests => @package.suggests,\n :provides => @package.provides,\n :replaces => @package.replaces,\n :architecture => @package.architecture,\n :copyright => self.copyright_file,\n # :changelog => self.changelog_file,\n :readme => self.readme_file,\n :postinst => self.postinst,\n :preinst => self.preinst,\n :postrm => self.postrm,\n :prerm => self.prerm,\n :extra_files => nil, # probably we'll never implement it\n :files => self.files,\n :description => self.description \n }\n control = \"\"\n options.each do |k, v|\n if v != nil and v != \"\" #TODO: think if this test needs to be improved \n control << k.to_s.split('_').map(&:capitalize).join('-') << \": \" << v << \"\\n\"\n end\n end\n control\n end",
"def i18n_options\n default_i18n_options.merge(event_interpolations).transform_values do |value|\n if value.is_a?(String)\n decidim_html_escape(value)\n else\n value\n end\n end\n end",
"def parse_options(options)\n options.collect do |key, val|\n str = \"#{key}: \"\n if val.kind_of? Hash\n str += \"{\" + parse_options(val) + \"}\"\n elsif val.kind_of? Array\n str += \"[ \" + val.collect { |v| \"'#{v}'\" }.join(\", \") + \" ]\"\n else\n str += (val.kind_of?(String) ? \"'#{val}'\" : val.to_s)\n end\n str\n end.join(',')\n end",
"def default_options\n {\n \"Date Range\" => {:field_type => :date_range, :for => \"created_at\", :from => \"2012-03-01\".to_date, :to => Date.today},\n SystemSurvey => {:field_type => :select_tag, :custom_name_method => :report_title, :required => true},\n \"Include Pending Responses\" => { field_type: :check_box_tag, for: \"show_pending\" }\n }\n end",
"def build_options(opts)\n options = []\n opts.each do |opt|\n val = new_resource.send(opt.to_sym)\n options << \"--#{opt}=\\\"#{val}\\\"\" unless val.nil?\n end\n options\n end",
"def additional_options\n @additional_options.join(\"\\s\")\n end",
"def date(options = {})\n non_relative_prefix = options[:non_relative_prefix] || \"on \"\n if interrogator.today?\n result = \"today\"\n elsif interrogator.yesterday?\n result = \"yesterday\"\n elsif interrogator.tomorrow?\n result = \"tomorrow\"\n elsif @context == :future && interrogator.next_x_days?(6)\n result = non_relative_prefix + name_of_day\n elsif @context == :future && interrogator.next_week?\n result = \"next #{name_of_day}\"\n elsif @context == :past && interrogator.last_x_days?(6)\n result = non_relative_prefix + name_of_day\n elsif @context == :past && interrogator.last_x_days?(12)\n result = \"last #{name_of_day}\"\n elsif @context == :past && interrogator.next_x_days?(6)\n result = \"next #{name_of_day}\"\n else\n result = non_relative_prefix + \"#{name_of_day} #{day_of_month} #{name_of_month}\"\n result += \" #{@time.year}\" if include_year_in_dates?\n result\n end\n\n unless options[:capitalize] == false\n result[0] = result[0].upcase\n end\n\n result\n end",
"def formatted_usage\n return \"\" if @opt_types.empty?\n @opt_types.map do |opt, type|\n val = respond_to?(\"usage_for_#{type}\", true) ?\n send(\"usage_for_#{type}\", opt) : \"#{opt}=:#{type}\"\n \"[\" + val + \"]\"\n end.join(\" \")\n end",
"def admin_options\n if !user_is_allowed('variants', 'edit')\n render :json => false\n return\n end\n \n options = []\n case params[:field] \n when 'subscription-interval'\n options = [\n { 'value' => Variant::SUBSCRIPTION_INTERVAL_MONTHLY , 'text' => 'Monthly' },\n { 'value' => Variant::SUBSCRIPTION_INTERVAL_YEARLY , 'text' => 'Yearly' }\n ] \n when 'subscription-prorate-method'\n options = [\n { 'value' => Variant::SUBSCRIPTION_PRORATE_METHOD_FLAT , 'text' => 'Flat Amount' },\n { 'value' => Variant::SUBSCRIPTION_PRORATE_METHOD_PERCENTAGE , 'text' => 'Percentage of Interval' },\n { 'value' => Variant::SUBSCRIPTION_PRORATE_METHOD_CUSTOM , 'text' => 'Custom' }\n ]\n when 'subscription-start-day'\n options = (1..31).collect{ |i| { 'value' => i, 'text' => i }} \n when 'subscription-start-month' \n options = (1..12).collect{ |i| { 'value' => i, 'text' => Date.new(2000, i, 1).strftime('%B') }}\n when 'status'\n options = [\n { 'value' => Variant::STATUS_ACTIVE , 'text' => 'Active' },\n { 'value' => Variant::STATUS_INACTIVE , 'text' => 'Inactive' },\n { 'value' => Variant::STATUS_DELETED , 'text' => 'Deleted' }\n ]\n end\n render :json => options\n end",
"def date_select(method, options = {})\n options[:include_blank] ||= false\n options[:start_year] ||= 1801\n options[:end_year] ||= Time.now.year\n options[:label_for] = \"#{object_name}_#{method}_1i\"\n\t\t build_shell(method, options) { super }\n end",
"def build_selected_options options=nil\n options ||= vote_proposal_options\n options.map(&:name).sort.join(\"|\") \n end",
"def default_options\n {\n \"Date Range\" => {:field_type => :date_range, :for => \"service_requests_submitted_at\", :from => \"2012-03-01\".to_date, :to => Time.current},\n Institution => {:field_type => :select_tag, :has_dependencies => \"true\"},\n Provider => {:field_type => :select_tag, :dependency => '#institution_id', :dependency_id => 'parent_id'},\n Program => {:field_type => :select_tag, :dependency => '#provider_id', :dependency_id => 'parent_id'},\n Core => {:field_type => :select_tag, :dependency => '#program_id', :dependency_id => 'parent_id'},\n }\n end",
"def js_params(options)\n opt = []\n\n options.each_pair do |k, v|\n opt << \"scribd_doc.addParam('#{k}', '#{v}');\" if Available_JS_Params.include?(k)\n end\n\n opt.compact.join(\"\\n\")\n end",
"def to_text\n result = ''\n if ! @start_time.nil?\n result += $config.get_abbreviation( 'Start time' ) + ':'\n result += @start_time.strftime( '%Y-%m-%d-%H:%M' ) + \" \"\n end\n if ! @end_time.nil?\n result += $config.get_abbreviation( 'End time' ) + ':'\n result += @end_time.strftime( '%Y-%m-%d-%H:%M' ) + \" \"\n end\n @categories.each { |k,v| result += $config.get_abbreviation(k) + \":#{v} \" }\n result += @description\n end",
"def build_date_format params\n case params[:period_method]\n when \"daily\" then \"DD Mon YYYY\"\n when \"weekly\" then \"DD Mon YYYY\"\n when \"monthly\" then \"DD Mon YYYY\"\n when \"quarter\" then \"Mon YYYY\"\n when \"half\" then \"Mon YYYY\"\n when \"yearly\" then \"Mon YYYY\"\n when \"current_week\" then \"DD Mon YYYY\"\n when \"current_month\" then \"DD Mon YYYY\"\n when \"current_quarter\" then \"Mon YYYY\"\n when \"current_half\" then \"Mon YYYY\"\n when \"current_year\" then \"Mon YYYY\"\n end\n end",
"def orderTypeOptions(orderType, orderTypeDefault)\n\n # Initialize variables\n htmlOutput = ''\n\n # Options for Client Orders\n if orderType == 'client' then\n options = ['P', 'D', 'I', 'E']\n\n # Iterate over all companies and create the HTML OPTIONs\n options.each do |option|\n htmlOutput << '<option value=\"' << option << '\"' \\\n << ((option == orderTypeDefault)? ' selected' : '') << '>' \\\n << case option \\\n when 'P' then 'PickUp by Company' \\\n when 'D' then 'Delivery by Company' \\\n when 'I' then 'PickUp by Client' \\\n when 'E' then 'Delivery by Client' \\\n else 'Error' \\\n end \\\n << '</option>'\n end\n\n # Options for Internal Orders\n else\n options = ['A', 'G', 'B']\n\n # Iterate over all companies and create the HTML OPTIONs\n options.each do |option|\n htmlOutput << '<option value=\"' << option << '\"' \\\n << ((option == orderTypeDefault)? ' selected' : '') << '>' \\\n << case option \\\n when 'A' then 'Air' \\\n when 'G' then 'Ground' \\\n when 'B' then 'Boat' \\\n else 'Error' \\\n end \\\n << '</option>'\n end\n\n end\n\n return htmlOutput\n\n end",
"def options\n render plain: ''\n end",
"def to_switches(options)\n options.map do |key, value|\n case value\n when true\n \"--#{key}\"\n when Array\n \"--#{key} #{value.map { |v| v.inspect }.join(\" \")}\" unless value.empty?\n when Hash\n \"--#{key} #{value.map { |k, v| \"#{k}:#{v}\" }.join(\" \")}\" unless value.empty?\n when nil, false\n \"\"\n else\n \"--#{key} #{value.inspect}\"\n end\n end.join(\" \")\n end",
"def to_s\n return @options[@value ? 0 : 1]\n end",
"def options(*excludes)\n excludes = excludes.flatten.collect { |exc| exc.to_sym }\n @options.inject(\"\") do |str, opt|\n if opt[1].nil? || excludes.include?(opt[0].to_sym)\n str\n else\n val = opt[1] == true ? '' : opt[1]\n option = opt[0].to_s\n option = (option.length == 1 ? \"-\" : \"--\") + option.gsub('_', '-')\n \"#{str} #{option} #{val}\".strip\n end\n end\n end",
"def option_list\n result = @options.dup\n result << \"-o\" << @rdoc_dir\n result << \"--main\" << main if main\n result << \"--markup\" << markup if markup\n result << \"--title\" << title if title\n result << \"-T\" << template if template\n result << '-f' << generator if generator\n result\n end",
"def created_at_filter(options)\n start_date = options[:from].minutes.ago\n end_date = options[:to].minutes.ago\n from = URI.encode(start_date.strftime(TIME_FORMULA))\n to = URI.encode(end_date.strftime(TIME_FORMULA))\n\n \"created_at[from]=#{from}&created_at[to]=#{to}\"\n end",
"def opt(opts)\n opts.map { |k,v|\n next \"\" if [:default,:checked,:selected, :nil].member?(k)\n \" #{escape_html(k)}='#{escape_html(v)}'\"\n }.join\n end",
"def user_options\n @additional_options.join(' ')\n end"
] | [
"0.7026954",
"0.6607382",
"0.65895784",
"0.65024924",
"0.6455781",
"0.64212936",
"0.63766897",
"0.637559",
"0.6292775",
"0.6292775",
"0.62664443",
"0.6252394",
"0.617951",
"0.6178819",
"0.6174106",
"0.61636543",
"0.61605626",
"0.6149303",
"0.6121917",
"0.610379",
"0.61020166",
"0.60820144",
"0.6074769",
"0.606572",
"0.6050277",
"0.60018307",
"0.59932554",
"0.5984376",
"0.59705997",
"0.59540653",
"0.588267",
"0.58745885",
"0.5860212",
"0.58391416",
"0.5826899",
"0.5815577",
"0.5813433",
"0.579911",
"0.5772495",
"0.57638735",
"0.5761297",
"0.57607245",
"0.57466054",
"0.5738339",
"0.57344747",
"0.5730511",
"0.572258",
"0.5712441",
"0.570582",
"0.569489",
"0.56926596",
"0.56863344",
"0.56840354",
"0.56781715",
"0.56766784",
"0.5669417",
"0.5664596",
"0.5648643",
"0.56306624",
"0.5629789",
"0.5625492",
"0.56191915",
"0.5618974",
"0.5618974",
"0.56140274",
"0.561243",
"0.56075543",
"0.55949736",
"0.5590606",
"0.5585892",
"0.5573168",
"0.5571495",
"0.55688107",
"0.5563671",
"0.5561865",
"0.5545697",
"0.5540311",
"0.554004",
"0.55269986",
"0.5524573",
"0.55218303",
"0.550738",
"0.5501451",
"0.5500045",
"0.54949397",
"0.54940385",
"0.5490889",
"0.54903597",
"0.548439",
"0.5483817",
"0.54792327",
"0.5474544",
"0.547151",
"0.54713607",
"0.54708266",
"0.5461721",
"0.5449692",
"0.54465216",
"0.5446171",
"0.54450953"
] | 0.69654065 | 1 |
I worked on this challenge [by myself, with Mason]. Your Solution Below def factorial(number) while number != 1 number (number 1) return number number = 1 break end end def factorial(number) while number >= 1 number = 1 minus = number 1 number minus return number end end factorial(0) | def factorial(number)
result = 1
while number > 0
result = result * number
number -= 1
end
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factorial(number)\n if number == 0\n return 1\n \n elsif number == 1\n return 1\n \n elsif\n x = number\n while x != 1\n x = (x - 1)\n number = (number * x)\n end\n return number\n end\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n i = number-1\n while i >= 1\n number = number * i\n i = i - 1\n end\n return number\n end\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n i = number-1\n while i >= 1\n number = number * i\n i = i - 1\n end\n return number\n end\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n n = number - 1\n while n >= 1\n number *= n\n n -= 1\n end\n return number\n end\nend",
"def factorial((number))\nif number == 0\n return 1\n else\n result = 1\n while number > 1\n result = result * number\n number -= 1\n end\nend\n return result\nend",
"def factorial(number)\n result=1\n if number == 0\n return 1\n else\n while (number>0)\n result *= (number)\n number -= 1\n end\n end\nreturn result\nend",
"def factorial(number)\n # Your code goes here\n if number == 0\n return 1\n elsif number == 1\n return 1\n end\n n = 1\n while number > 1\n n *= number\n number -= 1\n end\n return n\nend",
"def factorial(number)\n counter = number.to_i - 1\n if number.to_i == 0\n return 1\n else\n while counter > 0\n number = number * counter\n counter = counter - 1\n end\nend\nreturn number\nend",
"def factorial(number)\n result=1\n #if number == 0\n # return 1\n else\n while (number>0)\n result *= number\n number -= 1\n end\n end",
"def factorial(number)\n return 1 if number == 0\n result = 1\n while number > 0\n result = result * number\n number -= 1\n end\n return result\nend",
"def factorial(number)\n if number == 0 \n \treturn 1\n end\n result = 1\n while number > 0\n \tresult = result * number\n \tnumber -= 1\n end\n return result\nend",
"def factorial(number)\n if number == 0\n return 1\n elsif number == 1\n return 1\n elsif number > 1 \n product = number\n while number > 1 do \n number -=1\n product *= number \n end\n return product\n end \nend",
"def factorial(number)\n # =begin\n # Pseudo-code here\n # Only accepts a positive number\n # Take number and calculate factorial\n # while number >= 0\n # number*(number-1)*(number-2)*...(1)\n # outputs result\n # =end\n\n if number < 0\n return None\n end\n result = 1\n while number > 1\n result = result * number\n number = number - 1\n end\n return result\nend",
"def factorial(number)\n if number == 0\n \treturn 1\n elsif number == 1\n \treturn 1\n end\n i=number-1\n f=number*i\n while i > 1\n \ti=i-1\n \tf=f*i\n end\n return f\nend",
"def factorial(number)\n total = 1\n if number == 0\n total\n else \n while number > 0\n total *= number\n number -= 1\n end\n end\n return total\nend",
"def factorial(number)\n if number\t== 0\n \treturn 1\n end \t\n result = number \n i = 1\n while i < number\n result = result * i\n i += 1 \n end\n return result\nend",
"def factorial(number)\n i = number\n total = number\n if number == 0 || number == 1\n return 1\n else\n while i > 1\n total=total * (i - 1)\n i -= 1\n end\n end\n return total\nend",
"def factorial(number)\r\ntotal = 1\t\r\n\twhile number != 0\r\n\t\ttotal *= number\r\n\t\tnumber = number -1\r\n\tend\r\n\ttotal\r\nend",
"def factorial(number)\n if number == 0\n p 1\nelsif\n i = 1\n num = i * number\n while number > i do\n num = i * num\n i += 1\n end\n p num\n end\nend",
"def factorial(number)\n i = number\n output = number\n if number == 0\n return 1\n end\n while i > 1\n output *= number-1\n number-=1\n i-=1\n end\n return output\nend",
"def factorial(number)\n result = 1\n while number > 0\n result *= number\n number -= 1\n end\n result\nend",
"def factorial(number)\n result = 1\n while number > 0\n result *= number\n number -= 1\n end\n result\nend",
"def factorial(number)\n num = 1\n until number == 0\n num *= number\n number -=1\n end\n num\nend",
"def factorial(number)\n result = 1\n\n while number > 1\n result = result * number\n number -= 1\n end\n\n return result\nend",
"def factorial(number)\n # Your code goes here\nif number == 0\n return 1\nelse\n until number == 0\n return number * factorial(number - 1)\n end\n end\nend",
"def factorial(number)\n\nif number == 0\n\n\treturn 1\n\nend\n\nif number == 1 \n\n\treturn 1\n\nend \n\nreturn (factorial(number-1) * number)\n\nend",
"def factorial(number)\n result = 1\n while number >= 1\n result = result * number\n number = number - 1\n end\np result\nend",
"def factorial(input)\n if input == 0 \n return 1\n end\n num = input - 1 \n result = input \n \n while num >= 1\n result = result * num\n num -= 1\n end\n return result\nend",
"def factorial(number)\n sum = 1\n while number > 0\n \tsum = sum * number\n \tnumber = number -1\n end\n sum\nend",
"def factorial(number)\n if number < 0\n return \"Error, that is not a positive integer.\"\n else\n counter = number.to_i\n end\n total = 1\n while counter > 0\n total = total*counter\n counter -= 1\n end\n return total\nend",
"def factorial(number)\n #Takes a single number, as an input\n #if number is 0, return 1, else continue\n #Initialize a new variable, factorial, equal to number\n #multiply factorial by all integers between 1 and number (excluding number)\n #Return factorial\n if number == 0\n return 1\n else\n factor = number\n for i in 1...number\n factor = factor * i\n end\n return factor\n end\nend",
"def factorial(number)\n # Your code goes here\n product = number\n if number == 0\n \tproduct = 1\n end\n while number > 1\n \tproduct = product * (number - 1)\n \tnumber = number - 1\n end\n product\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n final_factorial = 1\n\n for x in 1..number\n final_factorial = final_factorial * x\n end\n\n return final_factorial\n end\nend",
"def factorial(number)\n \t if (number >= 2)\n \t\tresult.each do |number| number * (number -1)\n \t\tnumber -=\n \tend\n\n \treturn result\n \telse\n \t\tnumber == 0 || number == 1\n \t\treturn 1\n \tend\n\t\t\n\nend\n#This is as close as i got to getting factorial to work without using refactoring, per instructions.\n#Couldnt really get this to work. ",
"def factorial(number)\n if number < 0\n return \"Error, that is not a positive integer.\"\n else\n counter = number.to_i\n end\n total = 1\n while counter > 0\n total = total*counter\n counter -= 1\n end\n return total\nend",
"def factorial(number)\n # IF number = 0, return 1\n if number == 0\n return 1\n end\n # IF number = 1, return 1\n if number == 1\n return 1\n end\n # set variable factorial to 1\n factorial = 1\n # FROM x=1 to number\n for i in 1..number\n # factorial = x * factorial\n factorial *= i\n end\n # Return factorial\n return factorial\nend",
"def factorial(number)\n raise ArgumentError if number.nil?\n if number == 0 || number == 1\n return 1\n end\n\n i = 0\n result = 1\n\n while i < number\n result *= (number - i)\n i += 1\n end\n return result\nend",
"def factorial(number)\n if number == 0\n return 1\n elsif number == 1\n return 1\n else\n number*factorial(number-1)\n end\nend",
"def factorial(n)\n if n < 0\n return false\n end\n return 1\n while n > 0\n factorial_number = n * factorial_number\n n-= 1\n end\n return factorial_number\nend",
"def factorial(number)\n result = 1\n if number < 0\n puts \"number needs to be a positive integer\"\n elsif number != number.to_i\n puts \"number needs to be an integer\"\n elsif number == 0\n return result\n else\n array = []\n while number > 0\n array << number\n number -= 1\n end\n for i in array do\n result = result * i\n end\n end\n return result\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n final_factorial = 1\n\n for x in 1..number\n final_factorial = final_factorial * x\n end\n\n return final_factorial\n end\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n number*factorial(number-1)\n end\n\nend",
"def factorial(num)\r\n # your code goes here\r\n factorial = 1\r\n\r\n factorial = num\r\n while num > 1\r\n num -= 1\r\n factorial *= num\r\n end\r\n\r\n factorial\r\nend",
"def factorial(number)\n total = 1\n while number >= 1 do\n total *= number\n number -= 1\n end\n total\nend",
"def factorial(number)\n raise ArgumentError, \"number can't be nil\" if !number\n factorial = number > 1 ? number: 1\n while number >= 2\n factorial *= (number - 1)\n number -= 1\n end\n return factorial\nend",
"def factorial(number)\n # Your code goes here\n if number == 0\n 1\n else\n number * factorial(number-1)\n end\nend",
"def factorial (number)\n if number == 0\n return 1\n else\n\n total = 1\n for i in 1..number\n total *= i\n i += 1\n end\n return total\n end\nend",
"def factorial(number)\n if number == 0 \n return 1\n elsif number > 1 \n return number * factorial(number - 1)\n else\n return number\n end\nend",
"def factorial(number)\n result = 1\n if number < 0\n puts \"number needs to be a positive integer\"\n elsif number != number.to_i\n puts \"number needs to be an integer\"\n elsif number == 0\n return result\n else\n array = []\n while number > 0\n array << number\n number -= 1\n end\n for i in array do\n result = result * i\n end\n end\n return result\nend",
"def factorial(number)\n\ttotal = 1\n\tif number == 0\n\t\treturn 1\n\telse\n\t\twhile number > 1\n\t\t\ttotal *= number\n\t\t\tnumber -= 1\n\t\tend\n\t\treturn total\n\tend\nend",
"def factorial(number)\n if number == 1\n return 1\n else\n return number * factorial(number - 1)\n end\nend",
"def factorial(number)\n if number == nil\n raise ArgumentError.new(\"Not an integer\")\n end\n\n factorial = 1\n\n while number >= 1\n factorial *= number\n number -= 1\n end\n\n return factorial\nend",
"def factorial(number)\n\tif number == 0 || number == 1\n\t\treturn 1\n\telse\n\t\tproduct = number\n\t\twhile number > 1\n \t\t product = product*(number - 1)\n \t\t number = (number - 1)\n \t\tend\n \tend\n\treturn product\nend",
"def factorial(number)\n if number == nil\n raise ArgumentError, \"Please enter an integer, you've entered nil.\"\n elsif number == 0\n return 1\n elsif number < 0\n raise ArgumentError, \"Please enter a positive number.\"\n end\n\n lesser_number = number - 1\n (number - 2).times do\n number *= lesser_number\n lesser_number -= 1\n end\n\n return number\nend",
"def factorial(num)\n if num == 0\n return 1\n else\n value = num - 1\n until value == 0\n num *= value\n value -= 1\n end\n return num\n end\nend",
"def factorial(number)\n if number\n factorial = 1\n until number == 0\n factorial *= number\n number -= 1\n end\n return factorial \n else\n raise ArgumentError\n end\nend",
"def factorial(number)\n result = 1\n counter = number\n while counter > 0\n result *= counter\n counter -= 1\n end\n return result\nend",
"def factorial(number)\n if number\n factorial = 1\n while number > 0\n factorial *= number\n number -= 1\n end\n return factorial\n else\n raise ArgumentError, \"Input must be an integer\"\n end\nend",
"def factorial(number)\n\tresult = 1\n\twhile number > 0\n\t\tresult *= number\n\t\tnumber -= 1\n\tend\n\treturn result\nend",
"def factorial(number)\n return 1 if number <= 1\n number * factorial(number - 1)\nend",
"def factorial(number)\n raise ArgumentError, \"Object cannot be nil.\" if number == nil\n\n return 1 if number == 0\n\n n = number\n total = number\n (number - 1).times do\n total = total * (n - 1)\n n -= 1\n end\n\n return total\nend",
"def factorial(num)\n if num <= 1\n 1\n else\n num * factorial(num-1)\n end\nend",
"def factorial(number)\n if number == nil\n raise ArgumentError, \"That's not a number\"\n end\n\n factorial = 1\n\n while number > 0\n factorial *= number\n number -= 1\n end\n return factorial\nend",
"def factorial(num)\n if num == 0\n 1\n else\n num * factorial(num - 1)\n end\nend",
"def factorial(n)\n if n == 0\n n = 1\n else\n x = n - 1\n while x > 0\n n*=x\n x = x-1 \n end\n end\n puts n\nend",
"def factorial(number)\n product = 1\n while number > 1\n product *= number\n number -= 1\n end\n product\nend",
"def factorial(number)\n product = 1\n while number >= 1\n product *= number\n number = number - 1\n end\n product\nend",
"def factorial(number)\n raise ArgumentError if number.nil?\n return 1 if number == 0 || number == 1\n \n i = number\n until i == 1\n i -= 1\n number = number * i\n end\n return number\nend",
"def factorial(n)\r\n\tif n < 0\r\n\t\tnil\r\n\tend\r\n\r\n\tresult = 1\r\n\twhile n > 0\r\n\t\tresult = result * n\r\n\r\n\t\tn -= 1\r\n\tend\r\n\tresult\r\n\r\n\r\nend",
"def factorial(number)\n if number == 0 || number == 1 \n return 1\n end\n total = 1\n number.downto(1) do |x|\n total *= x\n end\n return total\nend",
"def factorial(num)\n if num == 1\n 1\n else\n num * factorial(num - 1)\n end\nend",
"def factorial(number)\n#Return 1 for any number that is 0\nreturn 1 if number == 0 \n# This is where the new number will be store\ntotal = 1\n# Create a range and iterate through each number and then assign that number to total\n(1..number).each do |num|\n total = total * num\nend\n# return total so it can display the last number.\ntotal\nend",
"def factorial(num)\n i = num -1\n output = num\n while i > 0\n output *= i\n i -= 1\n end\n return output\nend",
"def factorial(number)\n result = 1\n current_number = number\n number.times do\n result = result * current_number\n current_number = current_number - 1\n end\n result\nend",
"def factorial(number)\n result = 1\n current_number = number\n number.times do\n result = result * current_number\n current_number = current_number - 1\n end\n result\nend",
"def factorial(number)\n product = 1\n while number > 1\n product *= number\n number -= 1\n end\n p product\nend",
"def factorial(number)\n #above: defining a method with object 'number' which will have a value of a positive integer.\n num = 1\n #value that will be multiplied to method 'number'\n while number != 0\n num = num * number\n #above: see line 10.\n number = number - 1\n #above: value that is inputed by user will have to decrease by 1.\n # that value in turn will be multiplied by it's preceding\n end\nnum\nend",
"def factorial(number)\n # Your code goes here\n if(number > 1)\n number * factorial(number-1)\n else\n 1\n end\nend",
"def factorial(number)\n if number <= 1\n return 1\n else\n result = 1\n (1..number).each {|x| result = result * x}\n return result\n end\nend",
"def factorial(number)\n\tproduct = 1\n\tif number == 0\n\t\treturn product\n\telse\n\t\twhile (number > 0)\n\t\t\tproduct *= number\n\t\t\tnumber -= 1\n\t\tend\n\t\treturn product\n\tend\nend",
"def factorial (number)\n i=1\n until number == 0\n i *= number\n number -= 1\n end\n i\nend",
"def factorial(number)\n\treturn 1 if number == 1 \n\treturn number * factorial(number-1)\nend",
"def factorial(number)\n if number < 0\n return nil\n elsif number <= 1\n 1\n else\n number * factorial(number-1)\n end\nend",
"def factorial(n)\n factorial = 1\n while n > 0\n factorial *= n\n n -= 1\n end\n factorial\nend",
"def factorial(num)\n if num > 0\n #until num == 1\n return num * factorial(num - 1)\n else\n return 1\n end\nend",
"def factorial(number)\n raise 'Only postive numbers allowed' unless number >= 0\n if number == 0 then 1 else number * factorial(number-1) end\nend",
"def factorial(number)\n i = 1\n while number >= 1\n \ti *= number\n \tnumber -= 1\n end\n return i\nend",
"def factorial(number)\n if number <= 1\n return 1\n end\nsum = 1\nnumber.times do |x|\n sum = (x + 1) * sum\nend\nreturn sum\nend",
"def factorial(number)\ni = 1\noutput = 1\n\n while i < number + 1\n output = output * i\n i += 1\n end\n return output\nend",
"def factorial(number)\n\t#initalize answer to number\n\t#loop from number-1 down to 0 decrementing 1 every time.\n\t#answer = answer * iterator\n\t#end loop when iterator less than or equal to 0\n\t#return answer\n\n\treturn 1 if(number == 0)\n\tanswer = number\n\t(number-1).downto(1){|i|\n\t\tanswer *= i\n\t}\n\treturn answer\nend",
"def factorial(n)\r\n\tresult = 1\r\n if(n < 0)\r\n return nil\r\n end\r\n\twhile n > 0\r\n result= result*n\r\n n = n - 1\r\n\tend\r\n return result\r\nend",
"def factorial num\n\tfactorial = 1\n\twhile num > 0\n\t\tfactorial *= num\n\t\tnum -= 1\n\tend\n\treturn factorial\nend",
"def factorial(num)\n i = num - 1\n out = num\n while i > 0\n out = out * i \n i -= 1\n end\n return out\nend",
"def factorial(num)\n return 1 if num == 0\n return num if num < 3\n\n output = 1\n i = 2\n while i <= num\n output *= i\n i += 1\n end\n\n output\nend",
"def factorial(number)\n if number >= 1000\n return final = 0\n elsif\n number >=1\n array = Array.new\n (number + 1).times do |i|\n array.push(i)\n end\n array.shift\n final = 1.0\n array.each { |i| final *= i }\n return final\nelse\n return final = 1\nend\nend",
"def factorial(n)\n if n != 0\n return n *= factorial(n-1)\nelse\n return 1\nend\nend",
"def factorial(number)\n raise ArgumentError if number.class == NilClass\n num = 1\n yay = 1\n until num == number+1\n\n yay *= num\n num += 1\n\n end\n\n return yay\nend",
"def factorial_iterative(number)\n return \"Cannot calculate factorial of 0 or a negative number\" if number <= 0\n\n factorial_count = number\n\n until factorial_count == 1\n factorial_count -= 1\n number = number * factorial_count\n end\n\n return factorial_count\n\nend",
"def factorial_1(num)\n factorial_count = 1\n while num > 0\n factorial_count *= num\n num -= 1\n end\n factorial_count\nend",
"def factorial(number) \n if number == 0\n return 1\n end\n \n product = 1\n \n for number in (1..number)\n product = product * number\n \t\n end\n \n return product\n end"
] | [
"0.9020384",
"0.8904798",
"0.8904798",
"0.8891379",
"0.88627976",
"0.88343716",
"0.8827523",
"0.88164127",
"0.8792207",
"0.875952",
"0.87535053",
"0.8743511",
"0.87191296",
"0.8686371",
"0.8678662",
"0.86458254",
"0.86436015",
"0.862632",
"0.86213857",
"0.8616079",
"0.8612202",
"0.8612202",
"0.860379",
"0.85887253",
"0.85598314",
"0.8558215",
"0.8556681",
"0.85511494",
"0.8546892",
"0.8539514",
"0.8525777",
"0.85251635",
"0.85225004",
"0.85164887",
"0.85069615",
"0.85024685",
"0.8488095",
"0.84832805",
"0.8482722",
"0.84771186",
"0.84736717",
"0.8460179",
"0.8459388",
"0.84574413",
"0.84456706",
"0.8444325",
"0.8441581",
"0.84404796",
"0.8440242",
"0.84358853",
"0.8434837",
"0.84347665",
"0.84258914",
"0.8422904",
"0.8420221",
"0.8406638",
"0.8405469",
"0.84038174",
"0.84018505",
"0.8400851",
"0.83817995",
"0.83738726",
"0.836495",
"0.83614063",
"0.83504725",
"0.83498454",
"0.83471096",
"0.8341422",
"0.8333213",
"0.83304405",
"0.83286524",
"0.83258986",
"0.8324852",
"0.8320122",
"0.8320122",
"0.83135074",
"0.8312758",
"0.83069354",
"0.8296758",
"0.8293974",
"0.8288651",
"0.82812035",
"0.8280106",
"0.82731616",
"0.82689923",
"0.8260931",
"0.8258547",
"0.8251716",
"0.8249511",
"0.8249064",
"0.82398766",
"0.8235182",
"0.8234569",
"0.8234046",
"0.82301724",
"0.8225477",
"0.8221166",
"0.8215807",
"0.8210724",
"0.8208832"
] | 0.8618105 | 19 |
Generates a test which tests authorization code. It assumes a method called access_denied? on the test case. The access_denied? method should return true when access is denied (ie. a 403 status code) and false in other cases. Example: should.allow.get :index | def allow
Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case,
:access_denied?, false,
'Expected access to be allowed'
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index_authorized\n authorize @valid_user\n get :index\n assert_response :success\n assert_template \"index\"\n end",
"def test_auth_only\n make_controller :auth_only\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_protected\n end",
"def test_auth_except\n make_controller :auth_except\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_protected\n end",
"def test_negative_scenario\n result = perform_login\n testFinalActionEqual(result.postAuthResult, \"Allow\")\n end",
"def assert_forbidden\n get :index\n\n assert_redirected_to login_path\n assert_equal evaluations_path, session[:return_to]\n assert_equal STRINGS[:not_logged_in], flash[:notice]\n assert_nil @controller.current_user\n end",
"def test_overly_specific\n make_controller :overly_specific\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_protected\n end",
"def test_private_method\n make_controller :private_method\n get :index\n assert_protected\n get :secret_ferret_brigade\n assert_protected\n end",
"def expect_forbidden_status\n is_expected.to respond_with 403\n end",
"def access_denied\n render status: 401, text: \"nice try\"\n end",
"def test_page_security\n # A public page\n get '/home'\n assert_response :success\n # An administrator page\n get '/admin'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n \n get '/admin'\n assert_response :success\n end",
"def test_set3_16_check()\n prin_name = 'Klubicko'\n acc_type = 'allow'\n priv_name = 'SELECT'\n res_ob_type = 'doc'\n res_ob_adrs='/db/temp'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n acc_type = 'deny' \n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(false, access)\n end",
"def authorise_action\n if !logged_in? or (@annotation.source != current_user)\n # TODO: return either a 401 or 403 depending on authentication\n respond_to do |format|\n flash[:error] = 'You are not allowed to perform this action.'\n format.html { redirect_to :back }\n format.xml { head :forbidden }\n end\n return false\n end\n return true\n end",
"def authorise_action\n if !logged_in? or (@annotation.source != current_user)\n # TODO: return either a 401 or 403 depending on authentication\n respond_to do |format|\n flash[:error] = 'You are not allowed to perform this action.'\n format.html { redirect_to :back }\n format.xml { head :forbidden }\n end\n return false\n end\n return true\n end",
"def access_denied\n request.env[\"HTTP_REFERER\"] = journals_path\n yield\n assert_redirected_to root_path\n assert_equal \"You are not authorized to access this page.\", flash[:alert]\n end",
"def assert_protected(msg = \"401 Unauthorized: You are not authorized to view this page.\")\n assert_response 401\n assert_equal msg, @response.body\n end",
"def test_realm\n make_controller :realm\n get :index\n assert_protected\n assert_equal 'Basic realm=\"GOURANGA!\"', @response.headers['WWW-Authenticate']\n end",
"def test_action_security\n # A public action\n get '/goldberg/auth/login'\n assert_response :success\n # An administrator action\n get '/goldberg/users/list'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n\n get '/goldberg/users/list'\n assert_response :success\n end",
"def do_authorization_fail(ticket, reason)\n # Call Authlete's /auth/authorization/fail API.\n response = call_authorization_fail_api(ticket, reason)\n\n # The content of the response to the client.\n content = response[\"responseContent\"]\n\n # \"action\" denotes the next action.\n case response[\"action\"]\n when \"INTERNAL_SERVER_ERROR\"\n # 500 Internal Server Error\n # The API request from this implementation was wrong\n # or an error occurred in Authlete.\n return WebResponse.new(500, content).json.to_response\n\n when \"BAD_REQUEST\"\n # 400 Bad Request\n # The ticket is no longer valid (deleted or expired)\n # and the reason of the invalidity was probably due\n # to the end-user's too-delayed response to the\n # authorization UI.\n return WebResponse.new(400, content).json.to_response\n\n when \"LOCATION\"\n # 302 Found\n # The authorization request was invalid and the error\n # is reported to the redirect URI using Location header.\n return WebResponse.new(302).location(content).to_response\n\n when \"FORM\"\n # 200 OK\n # The authorization request was invalid and the error\n # is reported to the redirect URI using HTML Form Post.\n return WebResponse.new(200, content).html.to_response\n\n else\n # This never happens.\n return WebResponse.new(500, \"Unknown action\").plain.to_response\n end\nend",
"def validate_authorized_access (response_code)\n if response_code == \"401\" or response_code == \"403\"\n #if the session is valid, then is real unauthorized access\n if check_session\n flash[:danger] = t(:unauthorized_access).capitalize\n redirect_to :back\n return false\n end\n else\n return true\n end\n end",
"def test_subclass_authorization\n new_session do |test|\n test.controller 'really_secure' do\n test.cannot_access 'index'\n bill = test.login :bill\n bill.has_role 'site_admin'\n test.can_access 'index'\n end\n end\n end",
"def test_index_unauthorized\n get :index\n assert_response :redirect\n assert_redirected_to :action => \"login\"\n assert_equal \"Please log in first\", flash[:notice]\n end",
"def require_login\n Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case,\n :login_required?, true,\n 'Expected login to be required'\n )\n end",
"def test_set3_14_check() \n prin_name = 'Klubicko'\n acc_type = 'allow'\n priv_name = 'SELECT'\n res_ob_type = 'doc'\n res_ob_adrs='/db/temp'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n acc_type = 'deny'\n res_ob_adrs='/db/temp/test'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs) \n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(false, access)\n \n res_ob_adrs='/db/temp'\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(true, access)\n end",
"def access_denied\n puts \"access denied\"\n respond_to do |accepts|\n accepts.html do\n store_location\n # render :text => \"Authentication failed: access denied\"\n redirect_to log_in_path\n end\n accepts.json do\n render :json => {:success => false, :message => \"Authentication failed\"}\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n end\n false\n end",
"def authorization_required\n case action_name.to_s\n when /index/, /show/ then list_authorized?\n when /create/ then create_authorized?\n when /update/ then update_authorized?\n when /destroy/ then delete_authorized?\n end\n false\n end",
"def test_index\n assert Pundit.policy!(@admin_user, Role).index?\n refute Pundit.policy!(@not_admin_user, Role).index?\n end",
"def assert_unauthorized(mock)\n assert_response :unauthorized\n assert_select 'h1', '401 Unauthorized', response.body\n assert_mock mock\n end",
"def access_denied!\n render partial: 'errors/401', status: 401 && return\n end",
"def access_denied\n return render(text: 'access_denied: requires a role')\n end",
"def render_access_denied_page\n # Render fail page\n @meta = {}\n @meta[:title] = \"Access Denied\"\n @meta[:description] = \"You do not have access to this application\"\n render :template => \"pages/app_access_unauthorized\", :layout => 'application', :status => :forbidden\n end",
"def assert_access_without_login(*actions)\n\t\t\tuser_options = actions.extract_options!\n\n\t\t\toptions = {}\n\t\t\tif ( self.constants.include?(:ASSERT_ACCESS_OPTIONS) )\n\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n#\t\t\telsif ( self.constants.include?('ASSERT_ACCESS_OPTIONS') )\n#\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n\t\t\tend\n\t\t\toptions.merge!(user_options)\n\t\t\tactions += options[:actions]||[]\n\n\t\t\tm_key = options[:model].try(:underscore).try(:to_sym)\n\n\t\t\ttest \"#{brand}AWoL should get new without login\" do\n\t\t\t\tget :new\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'new'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:new) || options.keys.include?(:new)\n\n\t\t\ttest \"#{brand}AWoL should post create without login\" do\n\t\t\t\targs = if options[:create]\n\t\t\t\t\toptions[:create]\n\t\t\t\telsif options[:attributes_for_create]\n\t\t\t\t\t{m_key => send(options[:attributes_for_create])}\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\t\tassert_difference(\"#{options[:model]}.count\",1) do\n\t\t\t\t\tsend(:post,:create,args)\n\t\t\t\tend\n\t\t\t\tassert_response :redirect\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:create) || options.keys.include?(:create)\n\n#\t\t\ttest \"should NOT get edit without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tsend(:get,:edit, *args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:edit) || options.keys.include?(:edit)\n#\n#\t\t\ttest \"should NOT put update without login\" do\n#\t\t\t\targs={}\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs[:id] = obj.id\n#\t\t\t\t\targs[options[:factory]] = Factory.attributes_for(options[:factory])\n#\t\t\t\tend\n#\t\t\t\tsend(:put,:update, args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:update) || options.keys.include?(:update)\n\n\t\t\ttest \"#{brand}AWoL should get show without login\" do\n\t\t\t\targs={}\n\t\t\t\tif options[:method_for_create]\n\t\t\t\t\tobj = send(options[:method_for_create])\n\t\t\t\t\targs[:id] = obj.id\n\t\t\t\tend\n\t\t\t\tsend(:get,:show, args)\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'show'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:show) || options.keys.include?(:show)\n\n#\t\t\ttest \"should NOT delete destroy without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tassert_no_difference(\"#{options[:model]}.count\") do\n#\t\t\t\t\tsend(:delete,:destroy,*args)\n#\t\t\t\tend\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:destroy) || options.keys.include?(:destroy)\n#\n#\t\t\ttest \"should NOT get index without login\" do\n#\t\t\t\tget :index\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login\" do\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login and items\" do\n\t\t\t\tsend(options[:before]) if !options[:before].blank?\n\t\t\t\t3.times{ send(options[:method_for_create]) } if !options[:method_for_create].blank?\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\tend",
"def test_private_method_actually_logging_in\n test_private_method\n login :index, 'ferret', 'REVOLUTION'\n assert_response :success\n login :index, 'ferret', 'WRONGPASSWORD'\n assert_protected\n end",
"def authorization_denied\n head :unauthorized\n end",
"def test_different_method\n make_controller :different_header\n get :index\n assert_protected\n login :index, 'ferret', 'REVOLUTION', 'MY_OWN_MAGIC1'\n assert_response :success\n login :index, 'ferret', 'REVOLUTION', 'MY_OWN_MAGIC2'\n assert_response :success\n end",
"def test_shold_not_show_to_non_admin\n sign_in Factory.create(:user)\n get :show\n assert_response :redirect\n end",
"def authorized?(test = false)\n if test\n if access_token\n access_token.get('/oauth/test_request').is_a?(Net::HTTPSuccess)\n else\n false\n end\n else\n !!access_token\n end\n\n rescue Exception => e\n false\n end",
"def authorize\n if !current_user.has_role? :admin\n render plain:\"No access for you!\"\n end\n end",
"def authorize\n (render :json => { :error => \"Authentication error\" }, :status => :unauthorized and return) unless User.current.present?\n authorized ? true : deny_access\n end",
"def test_useless_configurations\n make_controller :open_useless\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_response :success\n\n make_controller :closed_useless\n get :index\n assert_protected\n get :secret_ferret_brigade\n assert_protected\n end",
"def access_denied\n\n end",
"def authorize!\n if current_user && current_user.clearance_level > 1\n return true\n else\n respond_to do |format|\n format.html do\n redirect_to main_app.new_session_path\n end\n format.json do\n render status: 403, nothing: true\n end\n end\n end\n end",
"def skip_authorization; end",
"def authorize\n end",
"def authorize\n end",
"def test_contradictory\n make_controller :contradictory\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_response :success\n end",
"def access_denied\n render \"common/access_denied\"\n end",
"def test_negativeauth\n begin\n fakeclient = ZenDeskAPI.new('http://rateitindia.zendesk.com', \"fake\", \"wrongassword\")\n fakeclient.createticket(\"test ticket\", \"4\", 'Captain Cool', \"alphabar@foobar5.com\")\n rescue RequestFailureException # test for 401\n assert(true) # expected exception\n rescue\n assert(false)\n end\n end",
"def authorize\n render :text => \"Authorization error\", :status => 401\n false\n end",
"def authorize_access\n # byebug\n redirect_to root_path, alert: \"Access Denied\" unless can? :modify, Post\n end",
"def access_denied\n respond_to do |accepts|\n accepts.html do\n store_location\n redirect_to '/login'\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n end\n false\n end",
"def access_denied\n end",
"def test_access\n oid = 10590515\n\ttype = \"jpg150\"\n\tip = request.remote_ip\n\thost = request.host_with_port\n\tfull_url = \"http://\"+host+\"/auth?oid=\"+oid.to_s+\"&type=\"+type+\"&ip=\"+ip\n\tlogger.info \"auth path:\"+full_url\n\tresource = RestClient::Resource.new(full_url)\n\tpage = resource.get()\n\tpage = page.to_s\n\tlogger.info page\n\treturn_msg = \"default\"\n\tif page == \"authorized\"\n\t\treturn_msg = \"you we able to pass the test access conditions\"\n\telsif page == \"unauthorized\"\n\t\treturn_msg = \"try cas\"\n\telse \n\t\treturn_msg = \"last else condition, this shouldn't happen\"\n\tend\t\n\trender :text => return_msg\n\treturn\n end",
"def check_access\n @response = Response.new\n \n check_hash()\n \n if @response.error?\n access_denied\n return\n end\n end",
"def test_oauth_fails_for_external_client_user_denies_permission\n # Step 1\n @user = TurtleUser.new({ 'external_client' => true })\n\n turtle_response = @user.register\n assert_response(turtle_response, :success)\n assert(@user.id)\n\n # Step 2\n turtle_response = @user.login_oauth_for_external_client('Deny')\n assert_response(turtle_response, :redirect)\n\n # Step 3\n expected_error = 'error=access_denied&error_description=Access+denied'\n assert_equal(expected_error, turtle_response['location'].gsub(/^.*\\?/, ''))\n end",
"def run\n case\n when args.first =~ /authorize/i\n authorize\n else\n usage\n end\n end",
"def login_required\nauthorized? || access_denied\nend",
"def authorize!\n api_key = ApiKey.find_by_access_token(params[:access_token])\n head :unauthorized unless api_key\n return false\n end",
"def permission_denied\n render :template => \"shared/permission_denied\",\n :status => :forbidden\n end",
"def authorize\n if !current_user.has_role? :admin\n render text:\"No Access For You!!!\"\n end\n end",
"def authorize_user\n # simple authorization: kick out anonymous users from backend actions\n=begin\n if !current_user\n redirect_back_or_default(home_page) and return if action_name =~ /index|edit|update|destroy/\n \n # skip checking permission if user is an admin\n elsif !current_user.has_role?('Admin')\n unless current_user.has_permission?(controller_name, action_name, params)\n flash[:warning] = 'Access Denied'\n redirect_back_or_default(home_page) and return\n end\n end\n=end\n end",
"def test_set3_13_check() \n prin_name = 'Klubicko'\n acc_type = 'allow'\n priv_name = 'ALL_PRIVILEGES'\n res_ob_type = 'doc'\n res_ob_adrs='/db/temp'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n prin_name = 'Klubicko'\n acc_type = 'deny'\n priv_name = 'ALTER'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n priv_name = 'ALTER'\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(false, access)\n priv_name = 'DROP'\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(true, access)\n end",
"def test_get_access_token\n end",
"def authorization; end",
"def test_set3_15_check() \n prin_name = 'Klubicko'\n acc_type = 'allow'\n priv_name = 'SELECT'\n res_ob_type = 'doc'\n res_ob_adrs='/db/temp'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n \n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(true, access)\n \n res_ob_adrs='/db/temp/test' \n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(false, access)\n \n res_ob_adrs='/db/temp/test/hokus'\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(false, access)\n end",
"def access_denied(body = nil)\n error 403, body\n end",
"def test_logged_in_user_access_to_userland_approved\n # first log in\n post '/login', { :username => GOOD_USERNAME, :password => GOOD_PASSWORD }\n\n # then specifically request the index page in userland\n get '/in/index'\n assert last_response.ok?\n assert last_response.body.include?('You are logged in as') \n assert last_response.body.include?(GOOD_USERNAME) \n end",
"def test_should_not_get_new_if_not_admin\n get :new\n \n assert_redirected_to login_path\n end",
"def authorization_required\n authorized? || authorization_denied\n end",
"def access_permissions\n return true if authenticated?\n render(plain: 'Unauthorized!', status: :unauthorized)\n end",
"def test_conditional_true\n act = acl {\n respond(200) { true }\n }.call({})\n assert_equal([200, {}, []], act)\n end",
"def access_denied\n respond_to do |accepts|\n accepts.html do\n store_location\n redirect_to :controller => '/accounts', :action => 'login'\n end\n accepts.js do\n render(:update) { |page| page.redirect_to(:controller => '/accounts', :action => 'login') }\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n end\n false\n end",
"def role_authorization_failure_response\n render nothing: true, status: :unauthorized\n end",
"def is_admin\n test_access :admin\n end",
"def needs_authorization?\n true\n end",
"def verify_rights\n access_allowed?(controller_action_options) || permission_denied\n end",
"def access_denied\n head 401\n end",
"def access_denied\n redirect_to main_app.root_url, alert: \"Not authorized\"\n end",
"def test_set3_17_check() \n prin_name = 'nikdo'\n acc_type = 'allow'\n priv_name = 'SELECT'\n res_ob_type = 'doc'\n res_ob_adrs='/db/temp/*'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n prin_name = 'Klubicko'\n acc_type = 'allow'\n priv_name = 'SELECT'\n res_ob_type = 'doc'\n res_ob_adrs='/db/temp/*'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n \n res_ob_adrs='/db/temp'\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(false, access)\n \n res_ob_adrs='/db/temp/test'\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(true, access)\n \n res_ob_adrs='/db/temp/test/hokus'\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(true, access)\n end",
"def test_logs_first_value_for_authorization\n skip \"Can't easily test, verify in code\"\n # assert_logs_first_value(\"Authorization\", \"request_basic_auth_username\")\n end",
"def deny_access_action( txn, *args )\n\t\t\tself.log.error \"Unauthorized request for %s\" % [ txn.uri ]\n\t\t\ttxn.status = Apache::FORBIDDEN\n\t\t\treturn \"access denied\"\n\t\tend",
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def test_should_show_index\n login_as :admin\n\n get :index\n assert_response :success\n assert_template 'list'\n end",
"def controller_actions_should_fail(cont, opts={})\n except= opts[:except] || []\n actions_to_test= get_all_actions(cont).reject { |a| except.include?(a) } #controller_class.action_methods\n actions_to_test += opts[:include] if opts[:include]\n actions_to_test.each do |a|\n get a\n response.should_not be_success\n #response.should redirect_to('http://test.host/login')\n #flash[:warning].should == @login_warning\n end\n end",
"def access_denied\n case content_type\n when :html\n store_location\n redirect url(:login)\n when :xml\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n set_status(401)\n render :text => \"Couldn't authenticate you\"\n end\n end",
"def try_authorize!(question)\n authorize(question, policy_class: TestCasePolicy)\n end",
"def authorize \n self.make 'authorization' \n end",
"def show\n\n authorize @cov_negative\n end",
"def random_access_code(provided_by, use_limit = 1, unlimited = false, expires_at = 1.year.since)\n access_code = AccessCode.new(:expires_at => expires_at)\n access_code.provided_by = provided_by\n access_code.unlimited = unlimited\n access_code.use_limit = use_limit\n access_code.uses = 0\n access_code.code = AccessCode.random_code\n access_code.save!\n access_code\n end",
"def test_navigation_logged_in\n authorize @valid_user\n get :index\n assert_tag \"a\", :content => /Logout/,\n :attributes => { :href => \"/user/logout\"}\n assert_no_tag \"a\", :content => /Register/\n assert_no_tag \"a\", :content => /Login/\n end",
"def respond_with_forbidden(exception = nil, error_code = \"forbidden\")\n msg = exception ? exception.message : \"Forbidden\"\n render partial: \"api/error\", locals: { message: msg, error_code: error_code }, status: 403\n return false\n end",
"def verify_rights\n access_allowed?(params.slice(:controller, :action)) || permission_denied\n end",
"def expect_forbidden(response)\n expect(response).to redirect_to(root_url)\nend",
"def test_should_get_access_for_invoice\n setup_access_for_invoice\n \n get :access, :access => @access_key\n assert_redirected_to :controller => 'invoices', :action => 'display_invoice', :id => @access_key\n end",
"def test_new_ticket_bannerite()\n get :new, {}, {:cas_user => users(:banner_user).username}\n assert_response :redirect\n assert_redirected_to :controller => 'login', :action => 'index'\n assert_equal @no_permission_msg, flash[:notice]\n end",
"def authorize_access\r\n # authorize!(action_name.to_sym, \"#{controller_name}_controller\".camelcase.constantize)\r\n end",
"def rescue_unauthorized\n render nothing: true, status: 403\n end",
"def rescue_unauthorized\n render nothing: true, status: 403\n end",
"def http_authorize \n redirect_to login_path, alert: 'Authorization required' if !logged_in? \n end",
"def permission_denied\n respond_to do |format|\n format.html { render :template => \"shared/forbidden\", :status => :forbidden }\n format.any { head :forbidden }\n end\n end",
"def access_denied\n respond_to do |format|\n format.html {\n flash[:error] = \"Sie sind nicht angemeldet oder nicht berechtigt, auf die angeforderte Seite zuzugreifen.\"\n render text: \"\", layout: true, status: :unauthorized\n }\n \n format.any {\n head status: :unauthorized\n }\n end\n end"
] | [
"0.6475531",
"0.6461225",
"0.631084",
"0.628509",
"0.61865973",
"0.6093812",
"0.59790725",
"0.58264005",
"0.58198",
"0.5784285",
"0.57606477",
"0.57557863",
"0.57557863",
"0.5750277",
"0.5736917",
"0.57228917",
"0.5657903",
"0.56317997",
"0.5629605",
"0.5628198",
"0.56252605",
"0.56244755",
"0.5577909",
"0.5577491",
"0.5547117",
"0.55391717",
"0.55331326",
"0.5527549",
"0.55247724",
"0.5521423",
"0.5517305",
"0.55080545",
"0.5507874",
"0.55061084",
"0.5505391",
"0.5499996",
"0.5495292",
"0.54715765",
"0.5458074",
"0.54535735",
"0.544451",
"0.5442584",
"0.5439917",
"0.5439917",
"0.54326355",
"0.54274",
"0.5426569",
"0.5420199",
"0.5416643",
"0.5406168",
"0.5400776",
"0.5400261",
"0.5394421",
"0.53877956",
"0.53870684",
"0.5376105",
"0.53523886",
"0.5344118",
"0.5342104",
"0.5336579",
"0.5326811",
"0.5322614",
"0.5322426",
"0.5322014",
"0.53087276",
"0.52819455",
"0.5275845",
"0.5262955",
"0.5257893",
"0.5256419",
"0.52520037",
"0.5235311",
"0.5233803",
"0.5232196",
"0.5229363",
"0.5228357",
"0.5222626",
"0.5217195",
"0.52165484",
"0.52108645",
"0.5207407",
"0.5205255",
"0.5197878",
"0.5196135",
"0.51949984",
"0.51897377",
"0.5186449",
"0.51862293",
"0.51835746",
"0.5182062",
"0.51749235",
"0.5174062",
"0.5171335",
"0.51685065",
"0.5166833",
"0.5161222",
"0.5161222",
"0.51566625",
"0.51534134",
"0.5151049"
] | 0.8330039 | 0 |
Generates a test which tests authorization code. It assumes a method called access_denied? on the test case. The login_required? method should return true when the visitor was asked for credentials (ie. a 401 status code or a redirect to a login page) and false in other cases. Example: should.require_login.get :index | def require_login
Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case,
:login_required?, true,
'Expected login to be required'
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow\n Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case,\n :access_denied?, false,\n 'Expected access to be allowed'\n )\n end",
"def test_auth_only\n make_controller :auth_only\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_protected\n end",
"def test_index_authorized\n authorize @valid_user\n get :index\n assert_response :success\n assert_template \"index\"\n end",
"def assert_forbidden\n get :index\n\n assert_redirected_to login_path\n assert_equal evaluations_path, session[:return_to]\n assert_equal STRINGS[:not_logged_in], flash[:notice]\n assert_nil @controller.current_user\n end",
"def test_negative_scenario\n result = perform_login\n testFinalActionEqual(result.postAuthResult, \"Allow\")\n end",
"def test_page_security\n # A public page\n get '/home'\n assert_response :success\n # An administrator page\n get '/admin'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n \n get '/admin'\n assert_response :success\n end",
"def login_required\n authorized? || access_denied\n end",
"def login_required\n authorized? || access_denied\n end",
"def login_required\n authorized? || access_denied\n end",
"def login_required\nauthorized? || access_denied\nend",
"def test_index_unauthorized\n get :index\n assert_response :redirect\n assert_redirected_to :action => \"login\"\n assert_equal \"Please log in first\", flash[:notice]\n end",
"def test_realm\n make_controller :realm\n get :index\n assert_protected\n assert_equal 'Basic realm=\"GOURANGA!\"', @response.headers['WWW-Authenticate']\n end",
"def login_required\n authorized? || throw(:halt, :access_denied)\n end",
"def test_action_security\n # A public action\n get '/goldberg/auth/login'\n assert_response :success\n # An administrator action\n get '/goldberg/users/list'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n\n get '/goldberg/users/list'\n assert_response :success\n end",
"def test_auth_except\n make_controller :auth_except\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_protected\n end",
"def login_required\n authorized? || throw(:halt, :access_denied)\n end",
"def login_required\n username, passwd = get_auth_data\n logged_in? && authorized? ? true : access_denied\n end",
"def require_login\n authorize_request || render_unathorized(\"Access denied\")\n end",
"def test_logged_in_user_access_to_userland_approved\n # first log in\n post '/login', { :username => GOOD_USERNAME, :password => GOOD_PASSWORD }\n\n # then specifically request the index page in userland\n get '/in/index'\n assert last_response.ok?\n assert last_response.body.include?('You are logged in as') \n assert last_response.body.include?(GOOD_USERNAME) \n end",
"def login_required\n (logged_in? || (controller_name == 'sessions')) ? true : access_denied\n end",
"def test_navigation_logged_in\n authorize @valid_user\n get :index\n assert_tag \"a\", :content => /Logout/,\n :attributes => { :href => \"/user/logout\"}\n assert_no_tag \"a\", :content => /Register/\n assert_no_tag \"a\", :content => /Login/\n end",
"def login_required\n logged_in? || access_denied\n end",
"def test_auth_only_actually_logging_in\n test_auth_only\n login :secret_ferret_brigade, 'ferret', 'REVOLUTION'\n assert_response :success\n login :secret_ferret_brigade, 'ferret', 'WRONGPASSWORD'\n assert_protected\n end",
"def login_required\n logged_in? ? true : access_denied\n end",
"def authorization_required\n case action_name.to_s\n when /index/, /show/ then list_authorized?\n when /create/ then create_authorized?\n when /update/ then update_authorized?\n when /destroy/ then delete_authorized?\n end\n false\n end",
"def test_subclass_authorization\n new_session do |test|\n test.controller 'really_secure' do\n test.cannot_access 'index'\n bill = test.login :bill\n bill.has_role 'site_admin'\n test.can_access 'index'\n end\n end\n end",
"def require_login\n\t\tauthorize_request || render_unauthorized(\"Access Denied\")\n\tend",
"def http_authorize \n redirect_to login_path, alert: 'Authorization required' if !logged_in? \n end",
"def assert_protected(msg = \"401 Unauthorized: You are not authorized to view this page.\")\n assert_response 401\n assert_equal msg, @response.body\n end",
"def test_overly_specific\n make_controller :overly_specific\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_protected\n end",
"def test_private_method_actually_logging_in\n test_private_method\n login :index, 'ferret', 'REVOLUTION'\n assert_response :success\n login :index, 'ferret', 'WRONGPASSWORD'\n assert_protected\n end",
"def access_denied\n request.env[\"HTTP_REFERER\"] = journals_path\n yield\n assert_redirected_to root_path\n assert_equal \"You are not authorized to access this page.\", flash[:alert]\n end",
"def test_login_controls\n get :login_controls\n assert_response :success\n assert_nil session[:user]\n end",
"def login_required\n logged_in? ? true : access_denied\n end",
"def test_no_unauthenticated_access\n # make sure that we can't get to 'home'\n assert_nil @request.session[:user]\n get :home\n assert_redirected_to :action => \"login\"\n assert_match /You need to log in/, flash[:message] \n end",
"def assert_access_without_login(*actions)\n\t\t\tuser_options = actions.extract_options!\n\n\t\t\toptions = {}\n\t\t\tif ( self.constants.include?(:ASSERT_ACCESS_OPTIONS) )\n\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n#\t\t\telsif ( self.constants.include?('ASSERT_ACCESS_OPTIONS') )\n#\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n\t\t\tend\n\t\t\toptions.merge!(user_options)\n\t\t\tactions += options[:actions]||[]\n\n\t\t\tm_key = options[:model].try(:underscore).try(:to_sym)\n\n\t\t\ttest \"#{brand}AWoL should get new without login\" do\n\t\t\t\tget :new\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'new'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:new) || options.keys.include?(:new)\n\n\t\t\ttest \"#{brand}AWoL should post create without login\" do\n\t\t\t\targs = if options[:create]\n\t\t\t\t\toptions[:create]\n\t\t\t\telsif options[:attributes_for_create]\n\t\t\t\t\t{m_key => send(options[:attributes_for_create])}\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\t\tassert_difference(\"#{options[:model]}.count\",1) do\n\t\t\t\t\tsend(:post,:create,args)\n\t\t\t\tend\n\t\t\t\tassert_response :redirect\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:create) || options.keys.include?(:create)\n\n#\t\t\ttest \"should NOT get edit without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tsend(:get,:edit, *args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:edit) || options.keys.include?(:edit)\n#\n#\t\t\ttest \"should NOT put update without login\" do\n#\t\t\t\targs={}\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs[:id] = obj.id\n#\t\t\t\t\targs[options[:factory]] = Factory.attributes_for(options[:factory])\n#\t\t\t\tend\n#\t\t\t\tsend(:put,:update, args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:update) || options.keys.include?(:update)\n\n\t\t\ttest \"#{brand}AWoL should get show without login\" do\n\t\t\t\targs={}\n\t\t\t\tif options[:method_for_create]\n\t\t\t\t\tobj = send(options[:method_for_create])\n\t\t\t\t\targs[:id] = obj.id\n\t\t\t\tend\n\t\t\t\tsend(:get,:show, args)\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'show'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:show) || options.keys.include?(:show)\n\n#\t\t\ttest \"should NOT delete destroy without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tassert_no_difference(\"#{options[:model]}.count\") do\n#\t\t\t\t\tsend(:delete,:destroy,*args)\n#\t\t\t\tend\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:destroy) || options.keys.include?(:destroy)\n#\n#\t\t\ttest \"should NOT get index without login\" do\n#\t\t\t\tget :index\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login\" do\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login and items\" do\n\t\t\t\tsend(options[:before]) if !options[:before].blank?\n\t\t\t\t3.times{ send(options[:method_for_create]) } if !options[:method_for_create].blank?\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\tend",
"def authorization_required\n authorized? || authorization_denied\n end",
"def test_should_not_get_new_if_not_admin\n get :new\n \n assert_redirected_to login_path\n end",
"def test_different_method\n make_controller :different_header\n get :index\n assert_protected\n login :index, 'ferret', 'REVOLUTION', 'MY_OWN_MAGIC1'\n assert_response :success\n login :index, 'ferret', 'REVOLUTION', 'MY_OWN_MAGIC2'\n assert_response :success\n end",
"def authorize\n if session[\"allcool\"] == 1\n return true\n end\n login,password = get_auth_data\n @test = User.find_by_login(login)\n if @test && @test.authenticated?(password) # && @test.is_admin\n session[\"allcool\"] = 1\n return true\n end\n session[\"allcool\"] = 0\n headers[\"Status\"] = \"Unauthorized\" \n headers[\"WWW-Authenticate\"] = 'Basic realm=\"Realm\"'\n self.status = 401\n render \"Authentication Required\"\n return false\n end",
"def check_is_login_required\n authorized_denied unless logged_in?\n end",
"def authorize\n render :text => \"Authorization error\", :status => 401\n false\n end",
"def authorize\n if !current_user.has_role? :admin\n render plain:\"No access for you!\"\n end\n end",
"def login_required\n access_denied unless header_login or session_login or cookie_login\n end",
"def test_logging_out\n make_controller :logout\n login :index, 'u', 'p'\n assert_response :success\n login :index, 'u', 'ping'\n assert_protected\n login :logout, 'u', 'p'\n assert_protected 'You have successfully logged out.'\n end",
"def authorise_action\n if !logged_in? or (@annotation.source != current_user)\n # TODO: return either a 401 or 403 depending on authentication\n respond_to do |format|\n flash[:error] = 'You are not allowed to perform this action.'\n format.html { redirect_to :back }\n format.xml { head :forbidden }\n end\n return false\n end\n return true\n end",
"def authorise_action\n if !logged_in? or (@annotation.source != current_user)\n # TODO: return either a 401 or 403 depending on authentication\n respond_to do |format|\n flash[:error] = 'You are not allowed to perform this action.'\n format.html { redirect_to :back }\n format.xml { head :forbidden }\n end\n return false\n end\n return true\n end",
"def test_auth_except_actually_logging_in\n test_auth_except\n login :secret_ferret_brigade, 'ferret', 'REVOLUTION'\n assert_response :success\n \n login :secret_ferret_brigade, 'ferret', 'WRONGPASSWORD!'\n assert_protected\n end",
"def validate_authorized_access (response_code)\n if response_code == \"401\" or response_code == \"403\"\n #if the session is valid, then is real unauthorized access\n if check_session\n flash[:danger] = t(:unauthorized_access).capitalize\n redirect_to :back\n return false\n end\n else\n return true\n end\n end",
"def test_access\n oid = 10590515\n\ttype = \"jpg150\"\n\tip = request.remote_ip\n\thost = request.host_with_port\n\tfull_url = \"http://\"+host+\"/auth?oid=\"+oid.to_s+\"&type=\"+type+\"&ip=\"+ip\n\tlogger.info \"auth path:\"+full_url\n\tresource = RestClient::Resource.new(full_url)\n\tpage = resource.get()\n\tpage = page.to_s\n\tlogger.info page\n\treturn_msg = \"default\"\n\tif page == \"authorized\"\n\t\treturn_msg = \"you we able to pass the test access conditions\"\n\telsif page == \"unauthorized\"\n\t\treturn_msg = \"try cas\"\n\telse \n\t\treturn_msg = \"last else condition, this shouldn't happen\"\n\tend\t\n\trender :text => return_msg\n\treturn\n end",
"def assert_unauthorized(mock)\n assert_response :unauthorized\n assert_select 'h1', '401 Unauthorized', response.body\n assert_mock mock\n end",
"def authorize_user\n # simple authorization: kick out anonymous users from backend actions\n=begin\n if !current_user\n redirect_back_or_default(home_page) and return if action_name =~ /index|edit|update|destroy/\n \n # skip checking permission if user is an admin\n elsif !current_user.has_role?('Admin')\n unless current_user.has_permission?(controller_name, action_name, params)\n flash[:warning] = 'Access Denied'\n redirect_back_or_default(home_page) and return\n end\n end\n=end\n end",
"def test_authentication\n load_token\n return false if !@token || @token.empty?\n res = get '/'\n !res.key?('error')\n end",
"def test_that_edit_requires_login\n assert_requires_login do |proxy|\n proxy.get :edit, :user_id => 11, :id => 1\n end\n end",
"def authorized?(test = false)\n if test\n if access_token\n access_token.get('/oauth/test_request').is_a?(Net::HTTPSuccess)\n else\n false\n end\n else\n !!access_token\n end\n\n rescue Exception => e\n false\n end",
"def authorize\n (render :json => { :error => \"Authentication error\" }, :status => :unauthorized and return) unless User.current.present?\n authorized ? true : deny_access\n end",
"def authorize\n end",
"def authorize\n end",
"def should_deny_access\n should_respond_with :redirect\n should_redirect_to(\"the login page\") { login_url }\n should_set_the_flash_to(/Vous devez d'abord ouvrir une session!/i)\n end",
"def authorize!\n if current_user && current_user.clearance_level > 1\n return true\n else\n respond_to do |format|\n format.html do\n redirect_to main_app.new_session_path\n end\n format.json do\n render status: 403, nothing: true\n end\n end\n end\n end",
"def test_logs_first_value_for_authorization\n skip \"Can't easily test, verify in code\"\n # assert_logs_first_value(\"Authorization\", \"request_basic_auth_username\")\n end",
"def verify(access_code)\n if !access_code.to_s.empty?\n params = {:accessCode => access_code}\n _send_request(params, VerifyUserUrl)\n else\n raise \"Access Code must be required\"\n end\n end",
"def authorize\n if !current_user.has_role? :admin\n render text:\"No Access For You!!!\"\n end\n end",
"def test_new_ticket_bannerite()\n get :new, {}, {:cas_user => users(:banner_user).username}\n assert_response :redirect\n assert_redirected_to :controller => 'login', :action => 'index'\n assert_equal @no_permission_msg, flash[:notice]\n end",
"def login_required\n not_authorized unless current_user\n end",
"def should_check_for_login(*actions)\n actions.each do |action|\n context \"on not being logged in for #{action} action\" do\n should \"redirect to login\" do\n post action, nil, nil\n assert_redirected_to introduction_url, \"should have been taken to login\"\n assert_flash \"Please log in to continue!\", :notice\n end\n end\n end\n end",
"def test_oauth_fails_for_external_client_user_denies_permission\n # Step 1\n @user = TurtleUser.new({ 'external_client' => true })\n\n turtle_response = @user.register\n assert_response(turtle_response, :success)\n assert(@user.id)\n\n # Step 2\n turtle_response = @user.login_oauth_for_external_client('Deny')\n assert_response(turtle_response, :redirect)\n\n # Step 3\n expected_error = 'error=access_denied&error_description=Access+denied'\n assert_equal(expected_error, turtle_response['location'].gsub(/^.*\\?/, ''))\n end",
"def test_shold_not_show_to_non_admin\n sign_in Factory.create(:user)\n get :show\n assert_response :redirect\n end",
"def test_login_oauth_success_for_external_client_user_grants_permission\n # Step 1\n @user = TurtleUser.new({ 'external_client' => true })\n\n turtle_response = @user.register\n assert_response(turtle_response, :success)\n assert(@user.id)\n\n # Step 2\n turtle_response = @user.login_oauth_for_external_client('Allow')\n assert_response(turtle_response, :success)\n\n # Step 3\n turtle_response = @user.verify_oauth_token(@user.oauth_token)\n assert_response(turtle_response, :success)\n\n # Step 4\n referer = 'http://something.at.xx.com/path'\n\n turtle_response = @user.logout(referer)\n assert_response(turtle_response, :redirect)\n assert_equal(referer, turtle_response['location'])\n end",
"def check_authorization\n if current_user && current_user.admin_role.present?\n return true\n end\n render nothing: true, status: :unauthorized\n false\n end",
"def require_auth\n (authorized? && authenticated?) || halt(401)\n end",
"def login_required\n access_denied unless session_login || cookie_login\n end",
"def needs_authorization?\n true\n end",
"def grant_authorization\n create_verification_code if authorized?\n redirect_back\n end",
"def authorize\n redirect_to login_url, alert: \"Not authorized\" if !current_user\n end",
"def access_denied!\n render partial: 'errors/401', status: 401 && return\n end",
"def do_authorization(params, session)\n # Call Authlete's /auth/authorization API.\n response = call_authorization_api(params)\n\n # The content of the response to the client.\n content = response[\"responseContent\"]\n\n # \"action\" denotes the next action.\n case response[\"action\"]\n when \"INTERNAL_SERVER_ERROR\"\n # 500 Internal Server Error\n # The API request from this implementation was wrong\n # or an error occurred in Authlete.\n return WebResponse.new(500, content).json.to_response\n\n when \"BAD_REQUEST\"\n # 400 Bad Request\n # The authorization request was invalid.\n return WebResponse.new(400, content).json.to_response\n\n when \"LOCATION\"\n # 302 Found\n # The authorization request was invalid and the error\n # is reported to the redirect URI using Location header.\n return WebResponse.new(302).location(content).to_response\n\n when \"FORM\"\n # 200 OK\n # The authorization request was invalid and the error\n # is reported to the redirect URI using HTML Form Post.\n return WebResponse.new(200, content).html.to_response\n\n when \"NO_INTERACTION\"\n # Process the authorization request w/o user interaction.\n return handle_no_interaction(response)\n\n when \"INTERACTION\"\n # Process the authorization request with user interaction.\n return handle_interaction(session, response)\n\n else\n # This never happens.\n return WebResponse.new(500, \"Unknown action\").plain.to_response\n end\nend",
"def skip_authorization; end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def test_basic_auth_with_password\n assert_warning :type => :controller,\n :warning_type => \"Basic Auth\",\n :line => 4,\n :message => /^Basic authentication password stored in source code/,\n :confidence => 0,\n :file => /users_controller\\.rb/\n end",
"def login_required\n \n if not protect?(action_name)\n return true \n end\n\n if @session['user'] and authorize?(@session['user'])\n return true\n end\n\n # store current location so that we can \n # come back after the user logged in\n store_location\n \n # call overwriteable reaction to unauthorized access\n access_denied\n return false \n end",
"def authorization; end",
"def login_required\n # Skip this filter if the requested action is not protected\n return true unless protect?(action_name)\n\n # Check if user is logged in and authorized\n return true if logged_in? and authorized?(current_user)\n\n # Store current location so that we can redirect back after login\n store_location\n\n # Call access_denied for an appropriate redirect and stop the filter\n # chain here\n access_denied and return false\n end",
"def require_login\n return head(:forbidden) unless current_user\n end",
"def request_authorization\n create_ticket\n verify_resource_owner or return\n render_authorize_form\n end",
"def authorize(access)\n @user = AuthorizeController.authorize(request)\n if @user == nil or not @user.has_access?(access)\n render status: :forbidden\n end\n end",
"def test_index\n assert Pundit.policy!(@admin_user, Role).index?\n refute Pundit.policy!(@not_admin_user, Role).index?\n end",
"def test_redirect_logged_in\n # log in\n admin = users(:olm_admin_1)\n post :login, :user_login => admin.user_name, :user_password => 'asfd'\n assert_redirected_to :action => \"index\"\n\n # try to go to login page when logged in\n get :login\n assert_redirected_to :action => \"index\"\n end",
"def test_bounce_not_logged_in\n get :panel\n assert_redirected_to :controller => \"users\", :action => \"login\"\n end",
"def authorize!\n api_key = ApiKey.find_by_access_token(params[:access_token])\n head :unauthorized unless api_key\n return false\n end",
"def verify_access\n return false unless business_line\n return true if current_user.admin?\n return true if business_line.user_has_access?(current_user)\n\n Rails.logger.info(\"User with roles #{current_user.roles.join(', ')} \"\\\n \"couldn't access #{request.original_url}\")\n\n session[\"return_to\"] = request.original_url\n redirect_to \"/unauthorized\"\n end",
"def test_login\n # Your test\n end",
"def authorize\n redirect_to('/login') unless @current_user\n end",
"def authorize(_subject, _auth)\n false\n end",
"def authorize\n if current_user.nil?\n redirect_to events_manager_index_path, :notice => \"Login to continue!\"\n return false\n else\n end \n end",
"def test_should_get_edit\n login_as(:john)\n get :edit, :id => 1\n assert_response :redirect\n end",
"def test_should_get_edit\n login_as(:john)\n get :edit, :id => 1\n assert_response :redirect\n end",
"def login_required\n redirect_to(login_url) unless logged_in? && authorized?\n end",
"def login_required\n return true unless protect?(action_name)\n\n return true if user? && authorize?(session[:user])\n\n # store current location so that we can\n # come back after the user logged in\n store_location\n\n # call overwriteable reaction to unauthorized access\n access_denied\n false\n end",
"def authorize # we can call it anything\n redirect_to '/login' unless current_user # if there is a current user then it will never redirect\n end"
] | [
"0.7289826",
"0.6315427",
"0.622207",
"0.619686",
"0.60465807",
"0.5963903",
"0.59197307",
"0.59197307",
"0.59197307",
"0.5904193",
"0.58407605",
"0.582522",
"0.5821838",
"0.575604",
"0.57368356",
"0.5714388",
"0.5705717",
"0.5691622",
"0.56840664",
"0.5645945",
"0.5645802",
"0.56313723",
"0.5627978",
"0.557735",
"0.55627155",
"0.5558805",
"0.55577207",
"0.5539897",
"0.5534822",
"0.5522835",
"0.5521709",
"0.5505363",
"0.5485852",
"0.5473883",
"0.54656243",
"0.54583174",
"0.54347056",
"0.5412957",
"0.540706",
"0.5402341",
"0.53707504",
"0.5369047",
"0.53639776",
"0.53624845",
"0.53539044",
"0.5353643",
"0.5353643",
"0.53454274",
"0.5345318",
"0.53304845",
"0.5292542",
"0.5278467",
"0.52719283",
"0.526656",
"0.5256698",
"0.5244659",
"0.5242921",
"0.5242921",
"0.52376723",
"0.52355856",
"0.5226457",
"0.52000946",
"0.51924026",
"0.51897526",
"0.5185821",
"0.5183814",
"0.5179815",
"0.51772183",
"0.5176932",
"0.5173038",
"0.5173036",
"0.5142329",
"0.51417977",
"0.5136846",
"0.51097864",
"0.50998145",
"0.50946164",
"0.50898206",
"0.5089092",
"0.5088638",
"0.5087461",
"0.5085196",
"0.508211",
"0.5079121",
"0.50766945",
"0.5076211",
"0.507432",
"0.50729656",
"0.50707823",
"0.5067256",
"0.5067255",
"0.5062446",
"0.50534046",
"0.5044338",
"0.5040543",
"0.5037779",
"0.5037779",
"0.50374204",
"0.5035684",
"0.5035319"
] | 0.72369117 | 1 |
GET /games GET /games.json | def index
@games = Game.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n render json: @games\n end",
"def index\n @games = current_user.games\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n game = Game.all\n\n render json: game, include: :teams\n end",
"def index\n @games = Game.order('title')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def games\n @logger.log(BEFORE_CHECK_GAMES)\n parsed_response = get_and_parse(\"/api/games/my_turn.json\")\n games = parsed_response[\"body\"]\n @logger.log(AFTER_CHECK_GAMES, \"Found #{games.size} games\")\n games\n end",
"def show\n @game = Game.find(params[:id])\n render json: @game, status: 200\n end",
"def index\n @games = Game.paginate page: params[:page], order: 'created_at desc', per_page: 10\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.find_all_by_meeting_id(@meeting.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games_leaderboards = Games::Leaderboard.all\n\n render json: @games_leaderboards\n end",
"def show\n render json: @game\n end",
"def index\n @games = Game.all\n @player_games = current_user.games rescue nil\n @ongoing_games = Game.where(outcome: 'In progress').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def show\n render json: @games_leaderboard\n end",
"def index\n game = Game.find(params[:game_id])\n @player_games = game.player_games\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @player_games }\n format.json { render :json => @player_games}\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def index\n @mini_games = MiniGame.all\n render json: @mini_games, status: :ok\n end",
"def show\n @user = User.find(params[:user_id]) \n @game = @user.games.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @game }\n end\n end",
"def index\n @video_games = VideoGame.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @video_games }\n end\n end",
"def show\n @user = User.find_by_id(params[:id])\n\n if @user\n render json: @user.to_json(include: [:games]), status: 200\n else\n render json: {error: \"User not found\"}, status: 404\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def index\n @games = Game.all\n raise RecordNotFound, 'No records on games' if @games.empty?\n\n # TODO: Just for Test. Do not forget to delete when finish the test.\n # raise 'error !!'\n # sleep 1\n\n render 'index', formats: 'json', handlers: 'jbuilder'\n end",
"def show\n @game = Game.instance\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n render json: Game.find(params[:id])\n end",
"def show_game\n @game = Event.where(\n game_id: params[:game_id]\n ).order(:game_date, :id)\n\n render json: @game, status: 200\n end",
"def index\n gon.yourID = current_user.id\n current_user.game == nil ? @games = Game.all : @games = Game.find(current_user.game.id)\n @team1 = @games.team1.users if @games.try :team1\n @team2 = @games.team2.users if @games.try :team2\n respond_to do |format|\n format.html\n format.json { render :json => { :games => @games.to_json(:include => [:users]),\n :user => current_user.game,\n :will => current_user.will,\n :team1 => @team1,\n :team2 => @team2 }\n }\n end\n end",
"def fetch_json(game)\n RestClient.post(\"#{ENV['BASE_URI']}\" + \"#{ENV['ENDPOINT']}\", game.to_json, content_type: :json)\n end",
"def show\n @game = Game.find(params[:id])\n @home_team = Team.find(@game.home_team_id)\n @away_team = Team.find(@game.away_team_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def index\n @games = current_user.games_ended.paginate(page: current_page, per_page: GAMES_PER_PAGE)\n games_count = current_user.games_ended.count\n\n render json: { games_count: games_count,\n current_page: current_page,\n total_pages: total_pages(games_count),\n games: @games\n }, status: 200\n end",
"def search\n games_data = BoardGameAtlas::API.search(params[:name])\n render json: { games: games_data.map }\n end",
"def index\n @games = Game.get_all_active\n end",
"def index\n\t\t@games = Game.all\n\tend",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @arcade_games }\n end\n end",
"def games_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.games_get ...\"\n end\n # resource path\n local_var_path = \"/games\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#games_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def game\n fetch('games.super_mario.games')\n end",
"def index\n @games = @theme.games.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @games.to_xml }\n end\n end",
"def get_games_url\n \"#{@user_url}/games/?tab=all\"\n end",
"def index\n @game_servers = Game::Server.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_servers }\n end\n end",
"def show\n @user = User.find(params[:id])\n @games = @user.games\n\n end",
"def index\n listing_games\n end",
"def index\n @games = Game.paginate(page: params[:page], per_page: 10) # list 10 games per page\n end",
"def index\n @game_systems = GameSystem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_systems }\n end\n end",
"def index\n @games = @organization.games\n end",
"def show\n @game = Game.find_by_id(params[:id])\n\n unless @game\n flash[:error] = \"Game not found.\"\n redirect_to games_path\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @gameplay = Gameplay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gameplay }\n end\n end",
"def games_get(opts = {})\n data, _status_code, _headers = games_get_with_http_info(opts)\n return data\n end",
"def index\n @games = current_user.games\n end",
"def show\n @bestgame = Bestgame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bestgame }\n end\n end",
"def fetch_games\n games, doc = [], get_xml(bungie_net_recent_games_url)\n (doc/:item).each_with_index do |item, i|\n games[i] = {\n :title => (item/:title).inner_html,\n :date => (item/:pubDate).inner_html.to_time,\n :link => (item/'link').inner_html,\n :description => (item/:description).inner_html,\n :gameid => pull_gameid((item/'link').inner_html)\n }\n end\n return games\n end",
"def show\n if Game.last\n @game = Game.find(params[:id])\n render json: @game\n else\n @game = Game.create()\n render json: @game\n end\n end",
"def index\n @games = current_creator.games\n redirect_to root_path\n end",
"def show\n @player_game = PlayerGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @player_game }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def get_games\n @games = Game.where(:user_id=>:id)\n end",
"def index\n @games = @season.games #Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @games }\n end\n end",
"def index\n if params[:term]\n @games = Game.search(params[:term]).paginate(page: params[:page], per_page: 10)\n elsif params[:filter]\n @filter = params[:filter]\n ids = []\n if @filter == 'popular'\n Game.popular(25).each { |k, _v| ids << k }\n elsif @filter == 'favorited'\n Game.favorited(25).each { |k, _v| ids << k }\n elsif @filter == 'owned'\n Game.owned(25).each { |k, _v| ids << k }\n elsif @filter == 'recent'\n Game.recently_added(25).each { |g| ids << g }\n elsif @filter == 'import'\n Game.none\n end\n @games = Game.for_ids_with_order(ids).paginate(page: params[:page], per_page: 10)\n else\n ids = []\n Game.popular(25).each { |k, _v| ids << k }\n @games = Game.for_ids_with_order(ids).paginate(page: params[:page], per_page: 10)\n end\n\n respond_to do |format|\n format.json.array! @games, partial: 'game.json'\n end\n end",
"def index\n @games = Game.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @games }\n format.text { render :text => @games.map { |g| \"#{g.gameid}\\n\" } }\n end\n end",
"def index\n @games = current_user.games\n @my_turns = current_user.games.my_turn\n\n respond_to do |format|\n format.html do\n @game = Game.new # for the form\n render :action => 'index'\n end\n format.json do\n render json: (params[:my_turn] ? @my_turns : @games)\n end\n end\n end",
"def show\n @game_stat = GameStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_stat }\n end\n end",
"def index\n @teams = Team.all\n render json: @teams\n end",
"def show\n @old_game = OldGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @old_game }\n end\n end",
"def show\n # puts \"PARAMSSSSS CONTROLLER #{params[:id]}\"\n url = \"https://api-2445582011268.apicast.io/games/#{params[:id]}\"\n response = HTTParty.get(url, headers: {\"user-key\" => Figaro.env.igdb_api_key, \"Accept\": \"application/json\"})\n @game_response = response.parsed_response\n end",
"def show\n @game_game_instance = Game::GameInstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_game_instance }\n end\n end",
"def index\n @available_games = Game.available(current_user)\n @users_games = Game.users_games(current_user)\n end",
"def index\n player = Player.all\n render json: players, status: 200\n end",
"def index\n @players = Player.all\n render json: @players, status: 200\n end",
"def index\n @games = Game.all\n respond_to do |format|\n format.html\n format.json { render :json => @games }\n format.xml { render :xml => @games }\n format.csv { render :csv => @posts }\n format.js\n end\n end"
] | [
"0.801388",
"0.7969819",
"0.7854131",
"0.7795904",
"0.77952725",
"0.77952725",
"0.77952725",
"0.7618289",
"0.75276613",
"0.74230546",
"0.74158394",
"0.7390365",
"0.73540944",
"0.7318076",
"0.72921306",
"0.7247407",
"0.7209582",
"0.7190768",
"0.7177297",
"0.7177297",
"0.7177297",
"0.7177297",
"0.7177297",
"0.7177297",
"0.7177297",
"0.71707463",
"0.71584094",
"0.71278137",
"0.7116972",
"0.71049",
"0.7092541",
"0.70740473",
"0.7053364",
"0.7051802",
"0.7030534",
"0.7028812",
"0.7024914",
"0.70072764",
"0.69620264",
"0.6957773",
"0.69546497",
"0.69388497",
"0.6922813",
"0.6913105",
"0.6889157",
"0.6888164",
"0.6852824",
"0.68526334",
"0.68519014",
"0.68193346",
"0.6815733",
"0.6812895",
"0.68116",
"0.6804615",
"0.67975587",
"0.67935896",
"0.6790638",
"0.67863816",
"0.6780091",
"0.6774465",
"0.67723477",
"0.6753603",
"0.6746565",
"0.6720901",
"0.67037916",
"0.66763616",
"0.66600144",
"0.6643752",
"0.6642371",
"0.66416657",
"0.66399306",
"0.6634744",
"0.66214937",
"0.6609838",
"0.6607518",
"0.66054916",
"0.6588816"
] | 0.69501257 | 57 |
GET /games/1 GET /games/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @game = Game.find(params[:id])\n render json: @game, status: 200\n end",
"def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n render json: @games\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = current_user.games\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @game }\n end\n end",
"def index\n @games = Game.order('title')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def show\n render json: Game.find(params[:id])\n end",
"def show\n render json: @game\n end",
"def show\n @user = User.find(params[:user_id]) \n @game = @user.games.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @game }\n end\n end",
"def index\n game = Game.all\n\n render json: game, include: :teams\n end",
"def show\n @game = Game.instance\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game }\n end\n end",
"def index\n @games = Game.find_all_by_meeting_id(@meeting.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def show\n if Game.last\n @game = Game.find(params[:id])\n render json: @game\n else\n @game = Game.create()\n render json: @game\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def index\n @games = Game.paginate page: params[:page], order: 'created_at desc', per_page: 10\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def show_game\n @game = Event.where(\n game_id: params[:game_id]\n ).order(:game_date, :id)\n\n render json: @game, status: 200\n end",
"def show\n @user = User.find_by_id(params[:id])\n\n if @user\n render json: @user.to_json(include: [:games]), status: 200\n else\n render json: {error: \"User not found\"}, status: 404\n end\n end",
"def show\n render json: @games_leaderboard\n end",
"def show\n @gameplay = Gameplay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gameplay }\n end\n end",
"def show\n @game = Game.find_by_id(params[:id])\n\n unless @game\n flash[:error] = \"Game not found.\"\n redirect_to games_path\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def index\n @mini_games = MiniGame.all\n render json: @mini_games, status: :ok\n end",
"def show\n @bestgame = Bestgame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bestgame }\n end\n end",
"def fetch_json(game)\n RestClient.post(\"#{ENV['BASE_URI']}\" + \"#{ENV['ENDPOINT']}\", game.to_json, content_type: :json)\n end",
"def index\n @games_leaderboards = Games::Leaderboard.all\n\n render json: @games_leaderboards\n end",
"def index\n game = Game.find(params[:game_id])\n @player_games = game.player_games\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @player_games }\n format.json { render :json => @player_games}\n end\n end",
"def show\n @game = Game.find(params[:id])\n @home_team = Team.find(@game.home_team_id)\n @away_team = Team.find(@game.away_team_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @player_game = PlayerGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @player_game }\n end\n end",
"def show\n @game_stat = GameStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_stat }\n end\n end",
"def show\n @game_game_instance = Game::GameInstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_game_instance }\n end\n end",
"def index\n @games = Game.all\n @player_games = current_user.games rescue nil\n @ongoing_games = Game.where(outcome: 'In progress').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def show\n @old_game = OldGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @old_game }\n end\n end",
"def show\n # puts \"PARAMSSSSS CONTROLLER #{params[:id]}\"\n url = \"https://api-2445582011268.apicast.io/games/#{params[:id]}\"\n response = HTTParty.get(url, headers: {\"user-key\" => Figaro.env.igdb_api_key, \"Accept\": \"application/json\"})\n @game_response = response.parsed_response\n end",
"def game\n fetch('games.super_mario.games')\n end",
"def index\n @games = Game.all\n raise RecordNotFound, 'No records on games' if @games.empty?\n\n # TODO: Just for Test. Do not forget to delete when finish the test.\n # raise 'error !!'\n # sleep 1\n\n render 'index', formats: 'json', handlers: 'jbuilder'\n end",
"def show\n @user = User.find(params[:id])\n @games = @user.games\n\n end",
"def index\n @video_games = VideoGame.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @video_games }\n end\n end",
"def index\n gon.yourID = current_user.id\n current_user.game == nil ? @games = Game.all : @games = Game.find(current_user.game.id)\n @team1 = @games.team1.users if @games.try :team1\n @team2 = @games.team2.users if @games.try :team2\n respond_to do |format|\n format.html\n format.json { render :json => { :games => @games.to_json(:include => [:users]),\n :user => current_user.game,\n :will => current_user.will,\n :team1 => @team1,\n :team2 => @team2 }\n }\n end\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def show\n @game_system = GameSystem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_system }\n end\n end",
"def show\n @game_tournament = GameTournament.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_tournament }\n end\n end",
"def games\n @logger.log(BEFORE_CHECK_GAMES)\n parsed_response = get_and_parse(\"/api/games/my_turn.json\")\n games = parsed_response[\"body\"]\n @logger.log(AFTER_CHECK_GAMES, \"Found #{games.size} games\")\n games\n end",
"def show\n @game = Game.find(params[:id])\n\n if @game.nil? \n respond_to do |format|\n format.all { render :status => :not_found, :text => \"Game not found.\" }\n end\n else\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @game }\n format.json { render :json => @game }\n end\n end\n end",
"def index\n\t\t@games = Game.all\n\tend",
"def show\n @video_game = VideoGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @video_game }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @arcade_games }\n end\n end",
"def show\n @game_server = Game::Server.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_server }\n end\n end",
"def index\n @games = @theme.games.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @games.to_xml }\n end\n end",
"def index\n @games = current_creator.games\n redirect_to root_path\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def get_game\n @game = Game.find(params[:game_id])\n end",
"def get_game\n @game = Game.find(params[:game_id])\n end",
"def show\n @game_score = GameScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_score }\n end\n end",
"def index\n @games = @organization.games\n end",
"def index\n @game_servers = Game::Server.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_servers }\n end\n end",
"def show\n @player_game_stat = PlayerGameStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_game_stat }\n end\n end",
"def show\n @game_player = GamePlayer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_player }\n end\n end",
"def index\n @games = Game.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @games }\n format.text { render :text => @games.map { |g| \"#{g.gameid}\\n\" } }\n end\n end",
"def show\n @game = Game.find(params[:id])\n @moves = @game.moves\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def game_details\n new_game = Game.last\n\n render :json => new_game.to_json( :include => :players )\n end",
"def index\n listing_games\n end",
"def index\n @game_systems = GameSystem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_systems }\n end\n end",
"def show\n @pgn_file = PgnFile.find(params[:id])\n @games = @pgn_file.games.page(params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pgn_file }\n end\n end",
"def index\n @games = Game.get_all_active\n end",
"def show\n game = Game.find(params[:game_id])\n @player_game = game.player_games.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to @player_game.game, :stab => 1 }\n format.json { render :json => @player_game}\n end\n\n end",
"def games_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.games_get ...\"\n end\n # resource path\n local_var_path = \"/games\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#games_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def new\n @user = User.find(params[:user_id])\n @game = @user.games.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @game }\n end\n end",
"def show\n @game_watch = GameWatch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_watch }\n end\n end"
] | [
"0.77774805",
"0.77492905",
"0.77341574",
"0.75965285",
"0.75962996",
"0.75962996",
"0.75962996",
"0.7543047",
"0.74719816",
"0.74719816",
"0.74719816",
"0.74719816",
"0.74719816",
"0.74719816",
"0.74719816",
"0.7428268",
"0.74045074",
"0.7395587",
"0.73370796",
"0.733467",
"0.7298956",
"0.7242426",
"0.72264177",
"0.7213465",
"0.71707636",
"0.7149283",
"0.713789",
"0.7104457",
"0.71035814",
"0.71010584",
"0.7096434",
"0.7093745",
"0.70532614",
"0.7044359",
"0.70430785",
"0.70421165",
"0.7036599",
"0.7003945",
"0.6981556",
"0.69637966",
"0.6936086",
"0.6935995",
"0.68982756",
"0.6892015",
"0.68838316",
"0.68794197",
"0.6878434",
"0.6863494",
"0.6814823",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.68110013",
"0.67801046",
"0.6767457",
"0.6762125",
"0.6750589",
"0.67487925",
"0.67357725",
"0.6724746",
"0.67102426",
"0.6703343",
"0.6696767",
"0.6696451",
"0.6694326",
"0.6694326",
"0.6686001",
"0.66823274",
"0.66664433",
"0.6664516",
"0.66536885",
"0.66528696",
"0.6647495",
"0.66266567",
"0.6623793",
"0.66170466",
"0.6613073",
"0.66077113",
"0.6602987",
"0.65942526",
"0.65795386",
"0.6574169"
] | 0.0 | -1 |
POST /games POST /games.json | def create
@game = Game.new(game_params)
respond_to do |format|
if @game.save
format.html { redirect_to @game, notice: 'Game was successfully created.' }
format.json { render :show, status: :created, location: @game }
else
format.html { render :new }
format.json { render json: @game.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @game = current_or_guest_user.games.create\n render json: @game, status: 201\n end",
"def create\n game = @current_user.games.create!(game_params)\n render json: { game: game }\n end",
"def create\n @new_game = Game.create(game_params)\n render json: @new_game\n\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n end\n end",
"def create\n @game = Game.new(game_params)\n\n params[:players].each do |player_name|\n p = Player.new\n p.name = player_name\n p.game = @game\n p.save!\n end\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to games_url, notice: \"Game was successfully created.\" }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n @game.user_id = params[:game][:user].first[:id]\n @game.item_id = params[:game][:item].first[:id]\n\n if @game.save\n render json: @game, status: :created, location: @game\n else\n render json: @game.errors, status: :unprocessable_entity\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to games_path, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :ok, location: game_url(@game, format: :json) }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(params[:user_id])\n @game = @user.games.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to user_game_path(@user,@game), :notice => 'Game was successfully created.' }\n format.json { render :json => @game, :status => :created }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @game = current_user.games.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to game_steps_path(game_id: @game.id), notice: 'La partie a bien été créée' }\n format.json { render :show, status: :created, location: games_path }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: \"Game was successfully created.\" }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game].merge({ :user_id => current_user.id }))\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to games_path, notice: 'Game was successfully added.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n @corporations = Corporation.order(:faction, :slogan)\n @runners = Runner.order(:faction, :name)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = GameBuilder.build(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { render :edit, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = @contest.games.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to contest_games_path, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: game_params }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n p = game_params\n\n home_team_name = p.delete(:home_team_name)\n away_team_name = p.delete(:away_team_name)\n p[:home_team_id] = find_or_create_team(home_team_name).try(:id)\n p[:away_team_id] = find_or_create_team(away_team_name).try(:id)\n\n @game = Game.new(p)\n @game.user = current_user\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new, notice: 'Game was successfully created.' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user.role == \"admin\" || current_user.role == \"god\"\n @game = Game.new(game_time: params[\"date\"] + \" \" + params[\"time\"])\n\n @game.game_teams.build(team_id: params[\"home_team_id\"], home_team: true)\n @game.game_teams.build(team_id: params[\"away_team_id\"], home_team: false)\n end\n\n respond_to do |format|\n if current_user.role == :admin || current_user.role == :god || @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: { message: \"Created Game\" } }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'El juego se ha creado!.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n\t\n #First update the players table to indicate who is playing this game\n set_player_availability(params)\n \n #Create a team to hold the home team players\n home_team = Team.new\n home_team.name = params[:home_team_name]\n home_team.save\n @game.home_team_id = home_team.id\n \n #Create a team to hold the away team players\n away_team = Team.new\n away_team.name = params[:away_team_name]\n away_team.save\n @game.away_team_id = away_team.id\n \n #Create home and away teams from available players\n build_teams(home_team, away_team)\n \n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fetch_json(game)\n RestClient.post(\"#{ENV['BASE_URI']}\" + \"#{ENV['ENDPOINT']}\", game.to_json, content_type: :json)\n end",
"def create\n @player_game = PlayerGame.new(params[:player_game])\n\n respond_to do |format|\n if @player_game.save\n format.html { redirect_to @player_game, :notice => 'Player game was successfully created.' }\n format.json { render :json => @player_game, :status => :created, :location => @player_game }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @player_game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n @game.game_state = \"started\"\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n @game.user_id = current_user.id\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n new_game = helpers.generate_game(params[\"game_name\"])\n\n slack_id = params[\"slack_id\"]\n\n response_url = params[\"response_url\"]\n\n @game = Game.new(new_game.new_game_data)\n\n if @game.save\n player = Player.exists?(slack_id: \"#{slack_id}\")\n if player\n player_records = Player.find_by(slack_id: \"#{slack_id}\")\n Rails.logger.info player_records[\"id\"].inspect\n render :json => {game_id: \"#{@game.id}\", player: \"#{player}\", player_id: \"#{player_records[\"id\"]}\"}\n else\n render :json => {game_id: \"#{@game.id}\", player: \"#{player}\"}\n end\n else\n render json: @game.errors, status: :unprocessable_entity\n end\n\n word_blanks = new_game.display_word_state\n\n HTTParty.post(response_url, \n {\n body: {\"text\" => \"#{word_blanks}\",\"response_type\" => \"in_channel\"}.to_json,\n headers: {\n \"Content-Type\" => \"application/json\"\n }\n }\n )\n \n end",
"def create\n @user_game = UserGame.new(user_game_params)\n\n respond_to do |format|\n if @user_game.save\n format.html { redirect_to @user_game, notice: 'User game was successfully created.' }\n format.json { render :show, status: :created, location: @user_game }\n else\n format.html { render :new }\n format.json { render json: @user_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = current_user.games_as_player1.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n populate_players\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n new_user_game = {}\n new_user_game[:game_id] = params[:game_id].to_i\n new_user_game[:user_id] = current_user.id\n @user_game = UserGame.new(new_user_game)\n\n respond_to do |format|\n if @user_game.save\n format.html { redirect_to user_games_url, notice: 'User game was join in game with success.' }\n format.json { render action: 'index', status: :created, location: @user_game }\n else\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n @game.user = current_user\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n gp = game_params\n gp['organizer_id'] = current_user.id\n @game = Game.new(gp)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to edit_game_path(@game), notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@game = Game.new(game_params)\n\n\t\trespond_to do |format|\n\t\t\tif @game.save\n\t\t\t\tformat.html { redirect_to @game, notice: 'Game was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @game }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\tformat.json { render json: @game.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @games_leaderboard = Games::Leaderboard.new(games_leaderboard_params)\n\n if @games_leaderboard.save\n render json: @games_leaderboard, status: :created, location: @games_leaderboard\n else\n render json: @games_leaderboard.errors, status: :unprocessable_entity\n end\n end",
"def create\n @mini_game = MiniGame.new(mini_game_params)\n if @mini_game.save\n render json: @mini_game, status: :ok\n else\n render json: @mini_game.errors, status: :unprocessable_entity\n end\n end",
"def create\n @game = Game.new\n #create the first player\n first_player = Player.new\n first_player.name = params[:first_player_name]\n first_player.game = @game\n\n #create the second player\n second_player = Player.new\n second_player.name = params[:second_player_name]\n second_player.game = @game\n\n # add first and second players to the game object\n @game.first_player = first_player\n @game.second_player = second_player\n\n respond_to do |format|\n if @game.save\n #create a new game round using a redirect to new_game_round_path\n format.html { redirect_to new_game_round_path(@game), notice: t(\"games.successfully_created\") }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = current_user.games.build(game_params)\n if @game.save\n redirect_to @game\n else\n render :new\n end\n end",
"def create\n\n @game = Game.new\n @game.save\n render :json => {}\n # render :json => {}\n # @game = Game.new(game_params)\n # new_game = false\n # if !params.has_key(:secret_id)\n # @game = Game.new\n # secret_id = @game.secret_id\n # new_game = true\n # else\n # secret_id = params[:game_id]\n # end\n # @game.save\n\n # if new_game\n # render :json => {:new_secret_id => @game.secret_id}\n # end\n\n # render :json => {}\n\n # respond_to do |format|\n # if @game.save\n # format.html { redirect_to game_path(:id => @game.secret_id), notice: 'Game was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @game }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @game.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @games_team = GamesTeam.new(games_team_params)\n\n respond_to do |format|\n if @games_team.save\n format.html { redirect_to @games_team, notice: 'Games team was successfully created.' }\n format.json { render :show, status: :created, location: @games_team }\n else\n format.html { render :new }\n format.json { render json: @games_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @playedgame = Playedgame.new(playedgame_params)\n\n respond_to do |format|\n if @playedgame.save\n format.html { redirect_to @playedgame, notice: 'Playedgame was successfully created.' }\n format.json { render :show, status: :created, location: @playedgame }\n else\n format.html { render :new }\n format.json { render json: @playedgame.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @league_game = LeagueGame.new(league_game_params)\n\n respond_to do |format|\n if @league_game.save\n format.html { redirect_to @league_game, notice: 'League game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @league_game }\n else\n format.html { render action: 'new' }\n format.json { render json: @league_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n assign_for_user\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def game_params\n params.require(:game).permit(:date, :round_id, :home_team, :visitor_team, :stadium_id)\n end",
"def create\n if current_user.game == nil\n team1 = Team.new\n team2 = Team.new\n team1.save\n team2.save\n @game = Game.new(game_params)\n @game.team1_id = team1.id\n @game.team2_id = team2.id\n @game.save\n User.update(current_user.id, :game_id => @game.id, :admin => true)\n end\n respond_to do |format|\n format.json { render :json => @game }\n end\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n recalculate_points\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @games = Game.all\n render json: @games\n end",
"def create\n @game = Game.new(game_params)\n\n authorize @game\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to(@game, :notice => 'Game was successfully created.') }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @gameplay = Gameplay.new(params[:gameplay])\n\n respond_to do |format|\n if @gameplay.save\n format.html { redirect_to @gameplay, notice: 'Gameplay was successfully created.' }\n format.json { render json: @gameplay, status: :created, location: @gameplay }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gameplay.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.create params[:id]\n end",
"def create\n @game = Game.new(game_params)\n @game.user_id = current_user.id \n @game.img_url_small = APIS::Giantbomb.new.game_by_id(@game.game_id)[\"results\"][\"image\"][\"screen_url\"]\n @game.img_url_large = APIS::Giantbomb.new.game_by_id(@game.game_id)[\"results\"][\"image\"][\"small_url\"]\n @game.deck = APIS::Giantbomb.new.game_by_id(@game.game_id)[\"results\"][\"deck\"]\n @game.developers = APIS::Giantbomb.new.game_by_id(@game.game_id)[\"results\"][\"developers\"][0][\"name\"]\n @game.genre = APIS::Giantbomb.new.game_by_id(@game.game_id)[\"results\"][\"genres\"][0][\"name\"]\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to search_index_path, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game_tournament = GameTournament.new(params[:game_tournament])\n\n respond_to do |format|\n if @game_tournament.save\n format.html { redirect_to @game_tournament, notice: 'Game tournament was successfully created.' }\n format.json { render json: @game_tournament, status: :created, location: @game_tournament }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_tournament.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # create game and save, then add Score connector\n @game = Game.new(params[:game])\n respond_to do |format|\n # creating new game, and new association between selected player and game\n if @game.save && @game.add_player(@player)\n flash[:notice] = 'Game was successfully created.'\n format.html { redirect_to(games_url) }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @qa_game = QaGame.new(qa_game_params)\n\n respond_to do |format|\n if @qa_game.save\n format.html { redirect_to @qa_game, notice: 'Qa game was successfully created.' }\n format.json { render :show, status: :created, location: @qa_game }\n else\n format.html { render :new }\n format.json { render json: @qa_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bestgame = Bestgame.new(params[:bestgame])\n\n respond_to do |format|\n if @bestgame.save\n format.html { redirect_to @bestgame, notice: 'Bestgame was successfully created.' }\n format.json { render json: @bestgame, status: :created, location: @bestgame }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bestgame.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @board_game = BoardGame.new(board_game_params)\n\n respond_to do |format|\n if @board_game.save\n format.html { redirect_to @board_game, notice: \"Board game was successfully created.\" }\n format.json { render :show, status: :created, location: @board_game }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @board_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(params[:game])\n @game.manager_id = current_user.id\n\n @usergame = UserGame.new\n @usergame.user_id = current_user.id\n\n respond_to do |format|\n if @game.save\n @usergame.game_id = @game.id\n @usergame.balance = @game.budget\n @usergame.save!\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.create(params[:game])\n\t\t@game.rate_average = 0.0\n\t\t@game.rate_quantity = 0\t\n\t\t@game.tags = build_tags_from_params(params) if params[:commit] == 'Update Game' \n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def game_params\n params.require(:game).permit(:home_team, :home_team_result, :visit_team, :visit_team_result, :stadium, :game_date, :tournament_id, :status, :points, :scorepoints)\n end",
"def create\n @espn_game = EspnGame.new(espn_game_params)\n\n respond_to do |format|\n if @espn_game.save\n format.html { redirect_to @espn_game, notice: 'Espn game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @espn_game }\n else\n format.html { render action: 'new' }\n format.json { render json: @espn_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n populate_players\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @game }\n end\n end",
"def create\n @game = Game.new(game_params)\n respond_to do |format|\n if @game.save\n format.html { redirect_to(@game, :notice => 'Game was successfully created.') }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def game_params\n params.require(:game).permit(:nr, :date, :home_id, :away_id, :score_home, :score_away)\n end",
"def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n flash[:notice] = 'Game was successfully created.'\n format.html { redirect_to(@game) }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @game = Game.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @game }\n end\n end",
"def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n\n calculategeneraltable(@game.tournament_id, @game.home_team)\n calculategeneraltable(@game.tournament_id, @game.visit_team)\n\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user = User.find(params[:user_id])\n @game = @user.games.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @game }\n end\n end",
"def create\n @game = Game.new(params[:game])\n @game.player_1_id = current_user.id\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n @game.update(people: Person.order(\"RANDOM()\").first(16))\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = @member.created_games.build(game_params)\n @game.organization_id = params[:organization_id]\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to [@organization, @game], notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new_with_defaults(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n else\n format.html { render action: 'new' }\n end\n end\n end",
"def create\n @game_game_instance = Game::GameInstance.new(params[:game_game_instance])\n\n respond_to do |format|\n if @game_game_instance.save\n format.html { redirect_to @game_game_instance, notice: 'Game instance was successfully created.' }\n format.json { render json: @game_game_instance, status: :created, location: @game_game_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_game_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_game = Game.new(admin_game_params)\n\n respond_to do |format|\n if @admin_game.save\n format.html { redirect_to @admin_game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @admin_game }\n else\n format.html { render :new }\n format.json { render json: @admin_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_game\n\tresponse\n\tif params[\"difficulty\"]\n\t\tdifficulty = params[\"difficulty\"]\n\t\tsettings.game_data = Ben::Game.new( Integer difficulty )\n\t\tresponse = game_json\n\telse\n\t\tresponse = \"Server couldn't load new game.\"\n\tend\n\treturn response\nend",
"def create\n @game = color_param == 'white' ? Game.new(white_player_id: user_param) : Game.new(black_player_id: user_param)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: { redirect: game_path(@game) } }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def game_params\n params.require(:game).permit(:name, :status, :hotline_open)\n end",
"def create\n @old_game = OldGame.new(params[:old_game])\n\n respond_to do |format|\n if @old_game.save\n format.html { redirect_to @old_game, notice: 'Old game was successfully created.' }\n format.json { render json: @old_game, status: :created, location: @old_game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @old_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game_instance = GameInstance.new(params[:game_instance])\n\n respond_to do |format|\n if @game_instance.save\n format.html { redirect_to @game_instance, notice: 'Game instance was successfully created.' }\n format.json { render json: @game_instance, status: :created, location: @game_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def game_params\n params.require(:game).permit(:team_id, :opponent_id, :team_score, :opponent_score, :date, :location,:tournament_id, :fecha)\n end",
"def create\n #directions = Score::DIRECTIONS.map{|k,v| k}\n #directions.shuffle!\n params[:game].merge!({:meeting_id => @meeting.id})\n @game = Game.create!(params[:game])\n participant_ids = params[:participants].collect{|id| id.to_i} if params[:participants]\n participant_ids.each do |id|\n score = Score.new\n score.game_id = @game.id\n score.participant_id = id.to_i\n #score.direction = directions.shift\n score.save!\n end\n\n respond_to do |format|\n if @game\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n current_user.create_game\n redirect_to game_path\n end",
"def update\n\n @game.turn = params[:game][:turn]\n @game.finished = params[:game][:finished]\n @game.winner = params[:game][:winner]\n @game.overall_score = ActiveSupport::JSON.decode(params[:game][:overall_score])\n @game.game_state = ActiveSupport::JSON.decode(params[:game][:game_state])\n\n respond_to do |format|\n if @game.save\n format.json { head :no_content }\n else\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @game = Game.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @game }\n end\n end",
"def new\n @game = Game.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @game }\n end\n end"
] | [
"0.7666801",
"0.75520563",
"0.7413892",
"0.70869124",
"0.7075019",
"0.70485115",
"0.70426613",
"0.7039214",
"0.702803",
"0.702508",
"0.702508",
"0.702508",
"0.702508",
"0.702508",
"0.6992957",
"0.69471335",
"0.6937076",
"0.69172454",
"0.6881612",
"0.6872458",
"0.68417835",
"0.68044984",
"0.6749649",
"0.6745684",
"0.6733691",
"0.67161965",
"0.67146295",
"0.6711086",
"0.6701555",
"0.6691775",
"0.66815704",
"0.6679637",
"0.66507447",
"0.6629254",
"0.66115403",
"0.66048753",
"0.6590435",
"0.6570226",
"0.6551783",
"0.6551244",
"0.6513083",
"0.65082246",
"0.6500183",
"0.6490636",
"0.6482674",
"0.6479603",
"0.6426513",
"0.6421401",
"0.64163965",
"0.6410959",
"0.6392672",
"0.6391312",
"0.6383995",
"0.6382466",
"0.6381736",
"0.6368984",
"0.63538766",
"0.63521874",
"0.63515383",
"0.63498616",
"0.63494825",
"0.6348585",
"0.63252765",
"0.6320171",
"0.63159645",
"0.6297952",
"0.6297008",
"0.62949514",
"0.62923276",
"0.6290498",
"0.6288788",
"0.6275853",
"0.62691045",
"0.6266895",
"0.6265476",
"0.6261938",
"0.6259761",
"0.6252978",
"0.6241498",
"0.6238594",
"0.6234668",
"0.6234624",
"0.6226825",
"0.6225778",
"0.6225623",
"0.6219177",
"0.62130994",
"0.62074083",
"0.6189974",
"0.6183096",
"0.6183096"
] | 0.6903971 | 26 |
PATCH/PUT /games/1 PATCH/PUT /games/1.json | def update
respond_to do |format|
if @game.update(game_params)
format.html { redirect_to @game, notice: 'Game was successfully updated.' }
format.json { render :show, status: :ok, location: @game }
else
format.html { render :edit }
format.json { render json: @game.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n #if game exists, pass here to update state\n @game = Game.find_by(id: params[:id])\n @game.update(game_params)\n render json: @game, status: 201\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, :notice => 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.get(params[:id])\n\n respond_to do |format|\n if @game.update(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = current_user.games.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game].merge({ :user_id => current_user.id }))\n format.html { redirect_to games_path, notice: 'Game was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:user_id])\n @game = @user.games.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to user_game_path(@user,@game), :notice => 'Game was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to games_url, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n @games = current_club_player.games\n format.html { redirect_to dashboard_path, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to contest_games_path, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n game = Game.find(params[:game_id])\n @player_game = game.player_games.find(params[:id])\n\n respond_to do |format|\n if @player_game.update_attributes(params[:player_game])\n format.html { redirect_to(@player_game, :notice => 'Player game was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => @player_game}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player_game.errors, :status => :unprocessable_entity }\n format.json { render :json => @player_game}\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n sync_update @game\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to(@game, :notice => 'Game was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n format.json { render :json => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.instance\n\n respond_to do |format|\n if @game.update_attributes(game_params)\n format.html { redirect_to game_path, flash: { success: 'Game was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to games_path, notice: 'Game was successfully updated.' }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { render :show, status: :ok, location: game_url(@game, format: :json) }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find_by_slug(params[:id])\n\t\t@game.tags = build_tags_from_params(params) if params[:commit] == 'Update Game'\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if User.update(current_user.id, :game_id => params[:id])\n format.json { head :no_content }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n update_standings\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @old_game = OldGame.find(params[:id])\n\n respond_to do |format|\n if @old_game.update_attributes(params[:old_game])\n format.html { redirect_to @old_game, notice: 'Old game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @old_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to games_url, notice: \"Game was successfully updated.\" }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if not @game.locked\n parse_game_params\n\n respond_to do |format|\n if @game.update(:id => params[:id])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_path\n end\n end",
"def update\n @game = Game.find(params[:id])\n @corporations = Corporation.order(:faction, :slogan)\n @runners = Runner.order(:faction, :name)\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.where(\"secret_id='#{secret_id}\").first\n respond_to do |format|\n if game.update\n format.html\n format.json { render json: @game }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: \"Game was successfully updated.\" }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @player_game = PlayerGame.find(params[:id])\n\n respond_to do |format|\n if @player_game.update_attributes(params[:player_game])\n format.html { redirect_to @player_game, :notice => 'Player game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @player_game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @game.update(game_params)\n\t\t\t\tformat.html { redirect_to @game, notice: 'Game was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\tformat.json { render json: @game.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @gameplay = Gameplay.find(params[:id])\n\n respond_to do |format|\n if @gameplay.update_attributes(params[:gameplay])\n format.html { redirect_to @gameplay, notice: 'Gameplay was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gameplay.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bestgame = Bestgame.find(params[:id])\n\n respond_to do |format|\n if @bestgame.update_attributes(params[:bestgame])\n format.html { redirect_to @bestgame, notice: 'Bestgame was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bestgame.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to(@game, :notice => 'Game was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to(@game, :notice => 'Game was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @game.turn = params[:game][:turn]\n @game.finished = params[:game][:finished]\n @game.winner = params[:game][:winner]\n @game.overall_score = ActiveSupport::JSON.decode(params[:game][:overall_score])\n @game.game_state = ActiveSupport::JSON.decode(params[:game][:game_state])\n\n respond_to do |format|\n if @game.save\n format.json { head :no_content }\n else\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_game.update(user_game_params)\n format.html { redirect_to @user_game, notice: 'User game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_game.update(user_game_params)\n format.html { redirect_to @user_game, notice: 'User game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n id = User.find_by_fb_id(params[:id]).id\n @user_game = UserGame.find_by_user_id(id)\n\n respond_to do |format|\n if @user_game.update_attributes(params[:user_game])\n format.json { head :no_content }\n else\n format.json { render json: @user_game.errors }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n #First update the players table to indicate who is playing this game\n set_player_availability(params)\n \n #Find teams and update their names\n home_team = Team.find(@game.home_team_id)\n home_team.name = params[:home_team_name]\n away_team = Team.find(@game.away_team_id)\n away_team.name = params[:away_team_name]\n \n #Create home and away teams from available players\n build_teams(home_team, away_team)\n \n respond_to do |format|\n if @game.update_attributes(params[:game])\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n flash[:notice] = 'Jogo editado com sucesso.'\n format.html { redirect_to theme_games_url(@theme) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors.to_xml }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to root_path, notice: 'Los datos de tu juego se han actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game_info.update(game_info_params)\n format.html { redirect_to @game_info, notice: 'Game info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @game\n \n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n\n respond_to do |format|\n if @game.update_attributes(params[:game])\n flash[:notice] = 'Game was successfully updated.'\n format.html { redirect_to(@game) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @games_team.update(games_team_params)\n format.html { redirect_to @games_team, notice: 'Games team was successfully updated.' }\n format.json { render :show, status: :ok, location: @games_team }\n else\n format.html { render :edit }\n format.json { render json: @games_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @league_game.update(league_game_params)\n format.html { redirect_to @league_game, notice: 'League game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @league_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update_attributes(game_params)\n format.html { redirect_to(@game, :notice => 'Game was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to games_path, notice: 'La partie a bien été éditée' }\n format.json { render :show, status: :ok, location: games_path }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game.update_attributes(params[:game])\n flash[:notice] = 'Game was successfully updated.'\n format.html { redirect_to(@game) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game_set.update(game_set_params)\n format.html { redirect_to @game_set, notice: 'Game set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n byebug\n if @game.update(game_params)\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @game.update(game_old_params)\n listing_games\n format.js\n end\n end",
"def update\n respond_to do |format|\n if @admin_game.update(admin_game_params)\n format.html { redirect_to @admin_game, notice: 'Game was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_game }\n else\n format.html { render :edit }\n format.json { render json: @admin_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @games_leaderboard = Games::Leaderboard.find(params[:id])\n\n if @games_leaderboard.update(games_leaderboard_params)\n head :no_content\n else\n render json: @games_leaderboard.errors, status: :unprocessable_entity\n end\n end",
"def update\n #@game = Game.find(params[:id])\n\n respond_to do |format|\n #if @game.update_attributes(params[:game])\n if @game.update_attributes(game_params)\n format.html { redirect_to(season_game_path(@game.season_id, @game), :notice => 'Game was successfully updated.') }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_game.update(user_game_params)\n format.html { redirect_to @user_game, notice: 'User game was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_game }\n else\n format.html { render :edit }\n format.json { render json: @user_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game_server = Game::Server.find(params[:id])\n\n respond_to do |format|\n if @game_server.update_attributes(params[:game_server])\n format.html { redirect_to @game_server, notice: 'Server was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game_server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @game = Game.find(params[:id])\n if @game.update_attributes(game_params)\n flash[:notice] = \"Game successfully updated\"\n redirect_to games_url\n else\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @games_pick.update(games_pick_params)\n format.html { redirect_to @games_pick, notice: 'Games pick was successfully updated.' }\n format.json { render :show, status: :ok, location: @games_pick }\n else\n format.html { render :edit }\n format.json { render json: @games_pick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game_game_instance = Game::GameInstance.find(params[:id])\n\n respond_to do |format|\n if @game_game_instance.update_attributes(params[:game_game_instance])\n format.html { redirect_to @game_game_instance, notice: 'Game instance was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game_game_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @video_game = VideoGame.find(params[:id])\n\n respond_to do |format|\n if @video_game.update_attributes(params[:video_game])\n format.html { redirect_to @video_game, notice: 'Video game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @video_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game = Game.find(params[:id])\n \n if @game.update(game_params)\n redirect_to @game\n else\n render 'edit'\n end\n end",
"def update\n @games_player = GamesPlayer.find(params[:id])\n\n respond_to do |format|\n if @games_player.update_attributes(params[:games_player])\n format.html { redirect_to(@games_player, :notice => 'Games player was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @games_player.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n begin\n ActiveRecord::Base.transaction do\n closing_game_request? ? close_game : update_game\n respond_to do |format|\n format.html { redirect_to [@organization, @game], notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n end\n end\n rescue => e\n logger.error(e)\n respond_to do |fomat|\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game_player = GamePlayer.find(params[:id])\n\n respond_to do |format|\n if @game_player.update_attributes(params[:game_player])\n format.html { redirect_to @game_player, notice: 'Game player was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game_player.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @game_instance = GameInstance.find(params[:id])\n\n respond_to do |format|\n if @game_instance.update_attributes(params[:game_instance])\n format.html { redirect_to @game_instance, notice: 'Game instance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @game.update_attributes(params[:game])\n redirect_to creators_games_path, notice: 'Игра успешно изменена.'\n else\n render action: 'edit'\n end\n end",
"def update\n @game.battling_armies.each do |army|\n army.is_loser = true if army.is_winner == false\n army.save\n end\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.71581805",
"0.7029499",
"0.702402",
"0.7022699",
"0.7022369",
"0.7022369",
"0.7022369",
"0.7022369",
"0.7022369",
"0.7022369",
"0.7022369",
"0.69909966",
"0.69796234",
"0.6944543",
"0.6894693",
"0.6848518",
"0.6848518",
"0.6848518",
"0.6823052",
"0.681519",
"0.68048114",
"0.67821866",
"0.67754227",
"0.6759647",
"0.6747499",
"0.6738102",
"0.6722526",
"0.672207",
"0.67134064",
"0.6706031",
"0.66727257",
"0.66593385",
"0.6649388",
"0.66378903",
"0.6629123",
"0.6626505",
"0.6612326",
"0.6598635",
"0.6596215",
"0.65824074",
"0.6577671",
"0.6565407",
"0.65312654",
"0.65312654",
"0.65278023",
"0.651604",
"0.65153635",
"0.6511592",
"0.6500519",
"0.64884603",
"0.6470446",
"0.6449585",
"0.6447521",
"0.6445334",
"0.6439716",
"0.64372146",
"0.64369255",
"0.63920844",
"0.6390419",
"0.6355016",
"0.6352634",
"0.6347636",
"0.63410854",
"0.6326622",
"0.63191956",
"0.6301986",
"0.6286225",
"0.6285405",
"0.6282307",
"0.62734705",
"0.6265869",
"0.6260303",
"0.62524533",
"0.62475246",
"0.6245772",
"0.6243425",
"0.6231456",
"0.6221465"
] | 0.667649 | 52 |
DELETE /games/1 DELETE /games/1.json | def destroy
@game.destroy
respond_to do |format|
format.html { redirect_to games_url, notice: 'Game was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @game.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.get(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :ok }\n end\n end",
"def destroy\n # @game = Game.find(params[:id])\n # @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = current_user.games.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to contest_games_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to organization_games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_path }\n # format.json { head :no_content }\n end\n end",
"def destroy\n id = params[:id].to_i\n UserGame.find(id)\n @user_game.destroy\n respond_to do |format|\n format.html { redirect_to user_games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to(games_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to(games_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to(games_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to(games_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to(games_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to(games_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:user_id])\n @game = @user.games.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to user_games_url(@user) }\n format.json { head :ok }\n end\n end",
"def destroy\n puts @game.date.to_s\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to user_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @game.destroy\n render json: { success: true, game: @game}\n end\n end",
"def destroy\n @player_game = PlayerGame.find(params[:id])\n @player_game.destroy\n\n respond_to do |format|\n format.html { redirect_to player_games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url, notice: \"Game was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url, notice: \"Game was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url, notice: 'El juego ha sido correctamente eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @old_game = OldGame.find(params[:id])\n @old_game.destroy\n\n respond_to do |format|\n format.html { redirect_to old_games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_title.destroy\n respond_to do |format|\n format.html { redirect_to game_titles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_stat = GameStat.find(params[:id])\n @game_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n game = Game.find_by_id(params[:id])\n game.destroy\n end",
"def destroy\n @game_info.destroy\n respond_to do |format|\n format.html { redirect_to game_infos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @espn_game.destroy\n respond_to do |format|\n format.html { redirect_to espn_games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gameplay = Gameplay.find(params[:id])\n @gameplay.destroy\n\n respond_to do |format|\n format.html { redirect_to gameplays_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @league_game.destroy\n respond_to do |format|\n format.html { redirect_to league_games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to admin_users_path(@admin), notice: 'Game was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@game.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to games_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n game = Game.find(params[:game_id])\n @player_game = game.player_games.find(params[:id])\n @player_game.destroy\n\n respond_to do |format|\n format.html { redirect_to(player_games_path, :notice => 'Player game was successfully removed.') }\n format.xml { head :ok }\n format.json { render :json => @player_game}\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.comments.destroy_all\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_server = Game::Server.find(params[:id])\n @game_server.destroy\n\n respond_to do |format|\n format.html { redirect_to game_servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bestgame = Bestgame.find(params[:id])\n @bestgame.destroy\n\n respond_to do |format|\n format.html { redirect_to bestgames_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_game.destroy\n respond_to do |format|\n format.html { redirect_to admin_games_url, notice: 'Game was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n game = @goal.game\n @goal.destroy\n respond_to do |format|\n format.html { redirect_to game_path(game) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to theme_games_url(@theme) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:game_id])\n @play = @game.plays.find(params[:id])\n @play.destroy\n\n\n respond_to do |format|\n format.html { redirect_to game_path(@game), notice: 'Play was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @game_game_instance = Game::GameInstance.find(params[:id])\n @game_game_instance.destroy\n\n respond_to do |format|\n format.html { redirect_to game_game_instances_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @game = Game.find(params[:id]).destroy\n flash[:alert] =\" games successfully deleted\"\n redirect_to games_url\n end",
"def destroy\n @gameboard = Gameboard.find(params[:id])\n @gameboard.destroy\n\n respond_to do |format|\n format.html { redirect_to gameboards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @game\n \n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url, notice: 'Game was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.reset\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url, notice: 'La partie a bien été supprimée' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_instance = GameInstance.find(params[:id])\n @game_instance.destroy\n\n respond_to do |format|\n format.html { redirect_to game_instances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drinking_game.destroy\n respond_to do |format|\n format.html { redirect_to drinking_games_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @game.rounds.destroy_all\n # raise @game.inspect\n @game.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Game was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_game.destroy\n respond_to do |format|\n format.html { redirect_to user_games_url, notice: 'User game was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @video_game = VideoGame.find(params[:id])\n @video_game.destroy\n\n respond_to do |format|\n format.html { redirect_to video_games_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7732339",
"0.7712217",
"0.7657307",
"0.76516914",
"0.76516914",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.76474565",
"0.75758624",
"0.75758624",
"0.75758624",
"0.75758624",
"0.75758624",
"0.75758624",
"0.75758624",
"0.75320464",
"0.7511837",
"0.74876463",
"0.74733824",
"0.7471733",
"0.7400644",
"0.7311699",
"0.7311699",
"0.7311699",
"0.7311699",
"0.7311699",
"0.7311699",
"0.7305918",
"0.73024434",
"0.7297653",
"0.72903645",
"0.7283231",
"0.727289",
"0.727289",
"0.7269349",
"0.726635",
"0.72425777",
"0.7213702",
"0.72131515",
"0.72054654",
"0.7205025",
"0.71986395",
"0.71797997",
"0.71675396",
"0.7159598",
"0.7132574",
"0.71312004",
"0.7128595",
"0.70953184",
"0.709299",
"0.7064469",
"0.7061871",
"0.70439327",
"0.7032875",
"0.7032668",
"0.70289457",
"0.7018092",
"0.7017993",
"0.7013621",
"0.70035404",
"0.6999437",
"0.6989435",
"0.6983667",
"0.698324"
] | 0.7275179 | 64 |
Use callbacks to share common setup or constraints between actions. | def set_game
@game = Game.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def game_params
params.require(:game).permit(:map_id, :room_size, :integer, :state, :string)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def list_params\n params.permit(:name)\n end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.6292164",
"0.62917984",
"0.62836355",
"0.6242686",
"0.6241917",
"0.62210834",
"0.6214862",
"0.62125784",
"0.619428",
"0.617912",
"0.617705",
"0.61735916",
"0.6163706",
"0.61532795",
"0.6152666",
"0.6148062",
"0.6123372",
"0.61180484",
"0.61088324",
"0.6106139",
"0.60925204",
"0.608326",
"0.60711503",
"0.606551",
"0.60216546",
"0.6018924",
"0.6015004",
"0.60106766",
"0.6008301",
"0.6008301",
"0.60028726",
"0.60020626",
"0.5999236",
"0.59931505",
"0.5993037",
"0.59917194",
"0.5982164",
"0.5968051",
"0.5960277",
"0.5960268",
"0.5960012",
"0.59594494",
"0.5954652",
"0.5954304",
"0.59440255",
"0.59404963",
"0.59404963",
"0.59401006",
"0.593522",
"0.5932182",
"0.5925528",
"0.5924541",
"0.5918796",
"0.59123147",
"0.5910144",
"0.5909186",
"0.5907257",
"0.5899382",
"0.5897783",
"0.58972496",
"0.58958495",
"0.58948576",
"0.5892734",
"0.5888056",
"0.58843875",
"0.58818483",
"0.5873746",
"0.58700997",
"0.5870056",
"0.5869255",
"0.58668107",
"0.58662325",
"0.5865003",
"0.5862908",
"0.5862406",
"0.58614665",
"0.5859661",
"0.585562",
"0.5855185",
"0.58523446",
"0.58504915"
] | 0.0 | -1 |
Editing options available to pictureables by default, may be overridden on a class by class basis. | def picture_options
{purpose: nil, variant: nil}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_real_picture\n end",
"def card_avatar options={}\n (is_viewer? && !@decorator.imgdata(false).present?) ?\n super + collectible_editpic_button(@decorator, 'lg', label: 'Get a Picture', class: 'upload-button') :\n super\n end",
"def edit_particular_image\n \n end",
"def non_html_attribute_options\n super.push(:image, :src)\n end",
"def edit_control(**opt)\n icon_control(:edit, **opt)\n end",
"def add_options; end",
"def cntrl_settg; det.image(:id, 'imgCtrlSettings'); end",
"def edit_option_selection\n @product = Product.find(params[:product_id])\n @product_option = ProductOption.find(params[:product_option_id])\n @option_selection = ProductOptionSelection.find(params[:id])\n unless params[:product_option_selection].nil?\n @option_selection.name = params[:product_option_selection][:name]\n @option_selection.weight_adjustment = params[:product_option_selection][:weight_adjustment]\n @option_selection.price_adjustment = params[:product_option_selection][:price_adjustment]\n @option_selection.sku_adjustment = params[:product_option_selection][:sku_adjustment]\n @option_selection.save!\n image = ProductOptionSelectionImage.new(params[:product_option_selection][:image])\n @option_selection.images << image\n end\n end",
"def set_img\n\n end",
"def collectible_editpic_button decorator, size=nil, styling={}\n entity = decorator.object\n if policy(entity).update? \n if size.is_a? Hash\n size, options = nil, size\n end\n button = button_to_submit styling.delete(:label),\n polymorphic_path( [:editpic, decorator.as_base_class], styling: styling),\n 'glyph-upload',\n size,\n styling.merge(mode: :modal, title: 'Get Picture')\n # content_tag :div, button, class: 'upload-button glyph-button'\n end\n end",
"def register_evasion_options(options, owner = self.class)\n\t\tself.options.add_evasion_options(options, owner)\n\t\tself.datastore.import_options(self.options, 'self', true)\n\t\timport_defaults(false)\n\tend",
"def render_picture_editor(element, options={})\n default_options = {\n :last_image_deletable => true,\n :maximum_amount_of_images => nil,\n :refresh_sortable => true\n }\n options = default_options.merge(options)\n picture_contents = element.all_contents_by_type(\"EssencePicture\")\n render(\n :partial => \"admin/elements/picture_editor\",\n :locals => {\n :picture_contents => picture_contents,\n :element => element,\n :options => options\n }\n )\n end",
"def override_graphic gr\n @graphic = gr\n end",
"def edit\n raise NotImplementedError\n end",
"def set_defaults\n\t\tself.main_image ||= PlaceholderConcern.image_generator(height: '200', width: '300')\n self.sport_icon ||= PlaceholderConcern.image_generator(height: '40', width: '40')\n\tend",
"def lbSetPicture _obj, _args\n \"_obj lbSetPicture _args;\" \n end",
"def lbSetPicture _obj, _args\n \"_obj lbSetPicture _args;\" \n end",
"def default_file_field_options(method)\n {\n multiple: @object.send(method).is_a?(ActiveStorage::Attached::Many),\n direct_upload: true,\n style: 'opacity: 0;',\n data: {\n dnd: true,\n dnd_zone_id: \"asdndz-#{object_name}_#{method}\",\n icon_container_id: \"asdndz-#{object_name}_#{method}__icon-container\"\n }\n }\n end",
"def edit_gallery_settings(gallery_name = \"test\", cols = \"4\", rows = \"3\", media_display = \"Show title on hover\", _browser = @browser)\n Log.logger.info(\"Editing '#{gallery_name}' Gallery properties (Settings).\")\n self.open_gallery(gallery_name)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_gallery) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_gallery_cols) }.find_elements(:xpath => \"//option[@value]\").each { |e|\n next unless e.text == cols ; e.click ; break ;\n }\n temp = _browser.find_element(:xpath => @galmgr.edit_gallery_rows)\n temp.clear\n temp.send_keys(rows)\n _browser.find_element(:xpath => @galmgr.edit_gallery_media_display).find_elements(:xpath => \"//option[@value]\").each { |e|\n next unless e.text == media_display ; e.click ; break ;\n }\n wait.until { _browser.find_element(:xpath => @galmgr.save_gallery_btn) }.click\n _browser.switch_to.default_content\n end",
"def update\n @idea.assign_attributes idea_params\n @idea.preferred = false unless current_user_has_gold_status?\n respond_to do |format|\n if @idea.save\n if params[:idea][:main_image].blank?\n # @idea.reprocess_main_image if @idea.cropping?\n format.html { redirect_to @idea, notice: 'Idea was successfully updated.' }\n format.json { render :show, status: :ok, location: @idea }\n else\n format.html { render :action => \"crop\" }\n end\n else\n format.html { render :edit }\n format.json { render json: @idea.errors, status: :unprocessable_entity }\n end\n end\n end",
"def media_option\n super\n end",
"def options() end",
"def edit_modifier\n\n\tend",
"def css_classes\n super + ['show-image']\n end",
"def edit!(properties)\n raise NotImplementedError\n end",
"def media_option_sfp\n super\n end",
"def update\n @resource = Resource.find(params[:id])\n\n @resource.assetable_id = 1\n @resource.assetable_type = 'User'\n\n if image_types.include? params[:resource][:data].content_type\n @resource.type = 'Ckeditor::Picture'\n else\n @resource.type = 'Ckeditor::AttachmentFile'\n end\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to admin_resources_path, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def options\n abstract!\n end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def setclip(*)\n super\n end",
"def edit_options_settings(fieldname, remove_options, change_options, new_options, default_options)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n field_label = wait.until { @browser.find_element(:xpath => @webformmgr.fieldset_label(fieldname)) }\n wait.until { field_label.displayed? }\n field_label.click\n JQuery.wait_for_events_to_finish(@browser)\n self.remove_item(remove_options)\n self.change_item(change_options)\n self.add_new_item(new_options)\n self.change_item(change_options)\n self.edit_default_options(fieldname, default_options)\n end",
"def user_options; end",
"def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_url = args[:image_url] if args.key?(:image_url)\n end",
"def permissable_options; read_inheritable_attribute(:permissable_options); end",
"def preview\r\n\t\t\trender(\"option_#{self.id}_preview\")\r\n\t\tend",
"def Com4\n @type = \"Picture\"\n @name = \"\"\n @x = 0\n @y = 0\n @commande_window.hide\n @window_command_command = Window_CommandTextSelect.new(@name,@x,@y)\n @window_command_command.set_handler(:CT1, method(:ComPict1))\n @window_command_command.set_handler(:CT2, method(:ComPict2))\n @window_command_command.set_handler(:CT3, method(:ComPict3))\n @window_command_command.set_handler(:cancel, method(:ComPict4))\n @window_command_command.activate\n end",
"def update!(**args)\n @profile_picture_option = args[:profile_picture_option] if args.key?(:profile_picture_option)\n end",
"def update\r\n super\r\n # Try to load the new file if the name is different\r\n if @picture_name != @picture.name\r\n @picture_name = @picture.name\r\n load_bitmap\r\n end\r\n # Don't update if the name is empty\r\n if @picture_name.empty?\r\n self.visible = false\r\n return\r\n end\r\n self.visible = true\r\n\r\n update_properties\r\n update_gif if @gif_handle\r\n end",
"def set_element pic\n controller_name == 'temp_listings' ? get_pixi_image(pic) : get_pixi_image(pic, 'large')\n end",
"def option_type_config; end",
"def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @icon = args[:icon] if args.key?(:icon)\n @icon_url = args[:icon_url] if args.key?(:icon_url)\n @image_style = args[:image_style] if args.key?(:image_style)\n end",
"def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_uri = args[:image_uri] if args.key?(:image_uri)\n end",
"def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_uri = args[:image_uri] if args.key?(:image_uri)\n end",
"def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_uri = args[:image_uri] if args.key?(:image_uri)\n end",
"def update!(**args)\n @enhanced_image = args[:enhanced_image] if args.key?(:enhanced_image)\n @feature_graphic = args[:feature_graphic] if args.key?(:feature_graphic)\n @screenshot = args[:screenshot] if args.key?(:screenshot)\n end",
"def edit\n @option = Vger::Resources::Suitability::Option.find(params[:id], :factor_id => params[:factor_id], :item_id => params[:item_id], :methods => [:option_type])\n respond_to do |format|\n format.html\n end\n end",
"def set_defaults\n self.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n self.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n end",
"def set_defaults\n self.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n self.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n end",
"def set_defaults\n self.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n self.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n end",
"def set_defaults\n\t\tself.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n\t\tself.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n\tend",
"def set_defaults\n\t\tself.main_image ||= Placeholder.image_generator(height: '200', width: '200')\n\t\tself.thumb_image ||= Placeholder.image_generator(height: '300', width: '300')\n\tend",
"def edit\n return unless (@image = find_image!)\n\n @licenses = current_license_names_and_ids\n check_image_permission!\n init_project_vars_for_add_or_edit(@image)\n end",
"def draw_imgui\n\n\t\tend",
"def set_default_options\n end",
"def pbPokemonEditor\n selection = 0\n species = [\n [_INTL(\"Name\"),LimitStringProperty.new(10),_INTL(\"Name of the Jermon.\")],\n [_INTL(\"InternalName\"),ReadOnlyProperty,_INTL(\"Internal name of the Jermon.\")],\n [_INTL(\"Type1\"),TypeProperty,_INTL(\"Jermon's type. If same as Type2, this Jermon has a single type.\")],\n [_INTL(\"Type2\"),TypeProperty,_INTL(\"Jermon's type. If same as Type1, this Jermon has a single type.\")],\n [_INTL(\"BaseStats\"),BaseStatsProperty,_INTL(\"Base stats of the Jermon.\")],\n [_INTL(\"GenderRate\"),EnumProperty.new([\n _INTL(\"AlwaysMale\"),_INTL(\"FemaleOneEighth\"),_INTL(\"Female25Percent\"),\n _INTL(\"Female50Percent\"),_INTL(\"Female75Percent\"),_INTL(\"FemaleSevenEighths\"),\n _INTL(\"AlwaysFemale\"),_INTL(\"Genderless\")]),\n _INTL(\"Proportion of males to females for this species.\")],\n [_INTL(\"GrowthRate\"),EnumProperty.new([\n _INTL(\"Medium\"),_INTL(\"Erratic\"),_INTL(\"Fluctuating\"),_INTL(\"Parabolic\"),\n _INTL(\"Fast\"),_INTL(\"Slow\")]),\n _INTL(\"Jermon's growth rate.\")],\n [_INTL(\"BaseEXP\"),LimitProperty.new(65535),_INTL(\"Base experience earned when this species is defeated.\")],\n [_INTL(\"EffortPoints\"),EVProperty,_INTL(\"Effort Value points earned when this species is defeated.\")],\n [_INTL(\"Rareness\"),LimitProperty.new(255),_INTL(\"Catch rate of this species (max=255).\")],\n [_INTL(\"Happiness\"),LimitProperty.new(255),_INTL(\"Base happiness of this species (max=255).\")],\n [_INTL(\"Ability1\"),AbilityProperty,_INTL(\"One ability which the Jermon can have.\")],\n [_INTL(\"Ability2\"),AbilityProperty,_INTL(\"Another ability which the Jermon can have.\")],\n [_INTL(\"HiddenAbility 1\"),AbilityProperty,_INTL(\"A secret ability which the Jermon can have.\")],\n [_INTL(\"HiddenAbility 2\"),AbilityProperty,_INTL(\"A secret ability which the Jermon can have.\")],\n [_INTL(\"HiddenAbility 3\"),AbilityProperty,_INTL(\"A secret ability which the Jermon can have.\")],\n [_INTL(\"HiddenAbility 4\"),AbilityProperty,_INTL(\"A secret ability which the Jermon can have.\")],\n [_INTL(\"Moves\"),MovePoolProperty,_INTL(\"Moves which the Jermon learns while levelling up.\")],\n [_INTL(\"EggMoves\"),EggMovesProperty,_INTL(\"Moves which the Jermon can learn via breeding.\")],\n [_INTL(\"Compat1\"),EnumProperty.new([\n \"Undiscovered\",\"Monster\",\"Water 1\",\"Bug\",\"Flying\",\n \"Field\",\"Fairy\",\"Grass\",\"Human-like\",\"Water 3\",\n \"Mineral\",\"Amorphous\",\"Water 2\",\"Ditto\",\"Dragon\"]),\n _INTL(\"Compatibility group (egg group) for breeding purposes.\")],\n [_INTL(\"Compat2\"),EnumProperty.new([\n \"Undiscovered\",\"Monster\",\"Water 1\",\"Bug\",\"Flying\",\n \"Field\",\"Fairy\",\"Grass\",\"Human-like\",\"Water 3\",\n \"Mineral\",\"Amorphous\",\"Water 2\",\"Ditto\",\"Dragon\"]),\n _INTL(\"Compatibility group (egg group) for breeding purposes.\")],\n [_INTL(\"StepsToHatch\"),LimitProperty.new(65535),_INTL(\"Number of steps until an egg of this species hatches.\")],\n [_INTL(\"Height\"),NonzeroLimitProperty.new(999),_INTL(\"Height of the Jermon in 0.1 metres (e.g. 42 = 4.2m).\")],\n [_INTL(\"Weight\"),NonzeroLimitProperty.new(9999),_INTL(\"Weight of the Jermon in 0.1 kilograms (e.g. 42 = 4.2kg).\")],\n [_INTL(\"Color\"),EnumProperty.new([\n _INTL(\"Red\"),_INTL(\"Blue\"),_INTL(\"Yellow\"),_INTL(\"Green\"),_INTL(\"Black\"),\n _INTL(\"Brown\"),_INTL(\"Purple\"),_INTL(\"Gray\"),_INTL(\"White\"),_INTL(\"Pink\")]),\n _INTL(\"Jermon's body color.\")],\n [_INTL(\"Shape\"),LimitProperty.new(14),_INTL(\"Body shape of this species (max=14).\")],\n [_INTL(\"Habitat\"),EnumProperty.new([\n _INTL(\"None\"),_INTL(\"Grassland\"),_INTL(\"Forest\"),_INTL(\"WatersEdge\"),\n _INTL(\"Sea\"),_INTL(\"Cave\"),_INTL(\"Mountain\"),_INTL(\"RoughTerrain\"),\n _INTL(\"Urban\"),_INTL(\"Rare\")]),\n _INTL(\"The habitat of this species.\")],\n [_INTL(\"RegionalNumbers\"),ReadOnlyProperty,_INTL(\"Regional Dex numbers for the Jermon. These are edited elsewhere.\")],\n [_INTL(\"Kind\"),LimitStringProperty.new(13),_INTL(\"Kind of Jermon species.\")],\n [_INTL(\"Jermodex\"),StringProperty,_INTL(\"Description of the Jermon as displayed in the Jermodex.\")],\n [_INTL(\"FormName\"),StringProperty,_INTL(\"Name of this form of the Jermon.\")],\n [_INTL(\"WildItemCommon\"),ItemProperty,_INTL(\"Item commonly held by wild Jermon of this species.\")],\n [_INTL(\"WildItemUncommon\"),ItemProperty,_INTL(\"Item uncommonly held by wild Jermon of this species.\")],\n [_INTL(\"WildItemRare\"),ItemProperty,_INTL(\"Item rarely held by wild Jermon of this species.\")],\n [_INTL(\"BattlerPlayerY\"),ReadOnlyProperty,_INTL(\"Affects positioning of the Jermon in battle. These are edited elsewhere.\")],\n [_INTL(\"BattlerEnemyY\"),ReadOnlyProperty,_INTL(\"Affects positioning of the Jermon in battle. These are edited elsewhere.\")],\n [_INTL(\"BattlerAltitude\"),ReadOnlyProperty,_INTL(\"Affects positioning of the Jermon in battle. These are edited elsewhere.\")],\n [_INTL(\"Evolutions\"),EvolutionsProperty.new(PBEvolution::EVONAMES),_INTL(\"Evolution paths of this species.\")],\n [_INTL(\"Incense\"),ItemProperty,_INTL(\"Item needed to be held by a parent to produce an egg of this species.\")],\n ]\n pbListScreenBlock(_INTL(\"Jermon species\"),SpeciesLister.new(selection,false)){|button,index|\n if index\n if button==Input::A\n if index>=0\n if Kernel.pbConfirmMessageSerious(\"Delete this species?\")\n # A species existing depends on its constant existing, so just need\n # to delete that - recompiling pokemon.txt will do the rest.\n removeConstantValue(PBSpecies,index)\n pbSavePokemonData\n Kernel.pbMessage(_INTL(\"The species was deleted. You should fully recompile before doing anything else.\"))\n end\n end\n elsif button==Input::C\n selection = index\n if selection<0\n Kernel.pbMessage(_INTL(\"Can't add a new species.\"))\n# newid=pbSpeciesEditorNew(nil)\n# selection=newid if newid>=0\n else\n dexdata = File.open(\"Data/dexdata.dat\",\"rb\") rescue nil\n messages = Messages.new(\"Data/messages.dat\") rescue nil\n if !dexdata || !messages\n raise _INTL(\"Couldn't find dexdata.dat or messages.dat to get Jermon data from.\")\n end\n speciesname = messages.get(MessageTypes::Species,selection)\n kind = messages.get(MessageTypes::Kinds,selection)\n entry = messages.get(MessageTypes::Entries,selection)\n cname = getConstantName(PBSpecies,selection) rescue sprintf(\"POKE%03d\",selection)\n formname = messages.get(MessageTypes::FormNames,selection)\n pbDexDataOffset(dexdata,selection,2)\n ability1 = dexdata.fgetw\n ability2 = dexdata.fgetw\n color = dexdata.fgetb\n habitat = dexdata.fgetb\n type1 = dexdata.fgetb\n type2 = dexdata.fgetb\n basestats = []\n for j in 0...6\n basestats.push(dexdata.fgetb)\n end\n rareness = dexdata.fgetb\n shape = dexdata.fgetb\n gender = dexdata.fgetb\n genderrate = 0 if gender==0\n genderrate = 1 if gender==31\n genderrate = 2 if gender==63\n genderrate = 3 if gender==127\n genderrate = 4 if gender==191\n genderrate = 5 if gender==223\n genderrate = 6 if gender==254\n genderrate = 7 if gender==255\n happiness = dexdata.fgetb\n growthrate = dexdata.fgetb\n stepstohatch = dexdata.fgetw\n effort = []\n for j in 0...6\n effort.push(dexdata.fgetb)\n end\n pbDexDataOffset(dexdata,selection,31)\n compat1 = dexdata.fgetb\n compat2 = dexdata.fgetb\n height = dexdata.fgetw\n weight = dexdata.fgetw\n pbDexDataOffset(dexdata,selection,38)\n baseexp = dexdata.fgetw\n hiddenability1 = dexdata.fgetw\n hiddenability2 = dexdata.fgetw\n hiddenability3 = dexdata.fgetw\n hiddenability4 = dexdata.fgetw\n item1 = dexdata.fgetw\n item2 = dexdata.fgetw\n item3 = dexdata.fgetw\n incense = dexdata.fgetw\n dexdata.close\n movelist = []\n File.open(\"Data/attacksRS.dat\",\"rb\"){|f|\n offset = f.getOffset(selection-1)\n length = f.getLength(selection-1)>>1\n f.pos = offset\n for j in 0...length\n alevel = f.fgetw\n move = f.fgetw\n movelist.push([alevel,move,j])\n end\n }\n movelist.sort!{|a,b| (a[0]==b[0]) ? a[2]<=>b[2] : a[0]<=>b[0] }\n eggmovelist = []\n File.open(\"Data/eggEmerald.dat\",\"rb\"){|f|\n f.pos = (selection-1)*8\n offset = f.fgetdw\n length = f.fgetdw\n f.pos = offset\n for j in 0...length\n move = f.fgetw\n eggmovelist.push(move) if move!=0\n end\n }\n regionallist = []\n File.open(\"Data/regionals.dat\",\"rb\"){|f|\n numRegions = f.fgetw\n numDexDatas = f.fgetw\n for region in 0...numRegions\n f.pos = 4+region*numDexDatas*2+(selection*2)\n regionallist.push(f.fgetw)\n end\n }\n numb = regionallist.size-1\n while numb>=0 # Remove every 0 at end of array \n (regionallist[numb]==0) ? regionallist.pop : break\n numb -= 1\n end\n evolutions = pbGetEvolvedFormData(selection)\n metrics = load_data(\"Data/metrics.dat\") rescue nil\n data = []\n data.push(speciesname) # 0\n data.push(cname) # 1\n data.push(type1) # 2\n data.push(type2) # 3\n data.push(basestats) # 4\n data.push(genderrate) # 5\n data.push(growthrate) # 6\n data.push(baseexp) # 7\n data.push(effort) # 8\n data.push(rareness) # 9\n data.push(happiness) # 10\n data.push(ability1) # 11\n data.push(ability2) # 12\n data.push(hiddenability1) # 13\n data.push(hiddenability2) # 14\n data.push(hiddenability3) # 15\n data.push(hiddenability4) # 16\n data.push(movelist) # 17\n data.push(eggmovelist) # 18\n data.push(compat1) # 19\n data.push(compat2) # 20\n data.push(stepstohatch) # 21\n data.push(height) # 22\n data.push(weight) # 23\n data.push(color) # 24\n data.push(shape) # 25\n data.push(habitat) # 26\n data.push(regionallist) # 27\n data.push(kind) # 28\n data.push(entry) # 29\n data.push(formname) # 30\n data.push(item1) # 31\n data.push(item2) # 32\n data.push(item3) # 33\n data.push(metrics[0][selection]) # 34\n data.push(metrics[1][selection]) # 35\n data.push(metrics[2][selection]) # 36\n data.push(evolutions) # 37\n data.push(incense) # 38\n save = pbPropertyList(data[0],data,species,true)\n if save\n # Make sure both Type1 and Type2 are recorded correctly\n data[2] = (data[3] ? data[3] : 0) if !data[2]\n data[3] = data[2] if !data[3]\n # Make sure both Compatibilities are recorded correctly\n data[19] = (data[20] && data[20]!=0) ? data[20] : 15 if !data[19] || data[19]==0\n data[20] = data[19] if !data[20] || data[20]==0\n # Make sure both Abilities are recorded correctly\n data[11] = data[12] if !data[11] || (data[11]==0 && data[12]!=0)\n data[11] = 0 if !data[11]\n data[12] = 0 if data[11]==data[12]\n # Turn GenderRate back into the correct value\n data[5] = 0 if data[5]==0\n data[5] = 31 if data[5]==1\n data[5] = 63 if data[5]==2\n data[5] = 127 if data[5]==3\n data[5] = 191 if data[5]==4\n data[5] = 223 if data[5]==5\n data[5] = 254 if data[5]==6\n data[5] = 255 if data[5]==7\n savedata = []\n for i in 0...76\n savedata[i] = 0\n end\n savedata[2] = data[11]&0xFF # Ability 1 - lower byte\n savedata[3] = (data[11]>>8)&0xFF # Ability 1 - upper byte\n savedata[4] = data[12]&0xFF # Ability 2 - lower byte\n savedata[5] = (data[12]>>8)&0xFF # Ability 2 - upper byte\n savedata[6] = data[24] # Color\n savedata[7] = data[26] # Habitat\n savedata[8] = data[2] # Type1\n savedata[9] = data[3] # Type2\n savedata[10] = data[4][0] # Base HP\n savedata[11] = data[4][1] # Base Attack\n savedata[12] = data[4][2] # Base Defense\n savedata[13] = data[4][3] # Base Speed\n savedata[14] = data[4][4] # Base Special Attack\n savedata[15] = data[4][5] # Base Special Defense\n savedata[16] = data[9] # Rareness\n savedata[17] = data[25] # Shape\n savedata[18] = data[5] # Gender rate\n savedata[19] = data[10] # Happiness\n savedata[20] = data[6] # Growth rate\n savedata[21] = data[21]&0xFF # Steps to hatch - lower byte\n savedata[22] = (data[21]>>8)&0xFF # Steps to hatch - upper byte\n savedata[23] = data[8][0] # HP EV\n savedata[24] = data[8][1] # Attack EV\n savedata[25] = data[8][2] # Defense EV\n savedata[26] = data[8][3] # Speed EV\n savedata[27] = data[8][4] # Special Attack EV\n savedata[28] = data[8][5] # Special Defense EV\n savedata[31] = data[19] # Compatibility 1\n savedata[32] = data[20] # Compatibility 2\n savedata[33] = data[22]&0xFF # Height - lower byte\n savedata[34] = (data[22]>>8)&0xFF # Height - upper byte\n savedata[35] = data[23]&0xFF # Weight - lower byte\n savedata[36] = (data[23]>>8)&0xFF # Weight - upper byte\n savedata[38] = data[7]&0xFF # Base EXP - lower byte\n savedata[39] = (data[7]>>8)&0xFF # Base EXP - upper byte\n savedata[40] = data[13]&0xFF # Hidden Ability 1 - lower byte\n savedata[41] = (data[13]>>8)&0xFF # Hidden Ability 1 - upper byte\n savedata[42] = data[14]&0xFF # Hidden Ability 2 - lower byte\n savedata[43] = (data[14]>>8)&0xFF # Hidden Ability 2 - upper byte\n savedata[44] = data[15]&0xFF # Hidden Ability 3 - lower byte\n savedata[45] = (data[15]>>8)&0xFF # Hidden Ability 3 - upper byte\n savedata[46] = data[16]&0xFF # Hidden Ability 4 - lower byte\n savedata[47] = (data[16]>>8)&0xFF # Hidden Ability 4 - upper byte\n savedata[48] = data[31]&0xFF # Common item - lower byte\n savedata[49] = (data[31]>>8)&0xFF # Common item - upper byte\n savedata[50] = data[32]&0xFF # Uncommon item - lower byte\n savedata[51] = (data[32]>>8)&0xFF # Uncommon item - upper byte\n savedata[52] = data[33]&0xFF # Rare item - lower byte\n savedata[53] = (data[33]>>8)&0xFF # Rare item - upper byte\n savedata[54] = data[38]&0xFF # Incense - lower byte\n savedata[55] = (data[38]>>8)&0xFF # Incense - upper byte\n File.open(\"Data/dexdata.dat\",\"rb+\"){|f|\n f.pos = 76*(selection-1)\n savedata.each {|item| f.fputb(item) }\n }\n namearray = []\n kindarray = []\n entryarray = []\n formarray = []\n for i in 1..(PBSpecies.maxValue rescue PBSpecies.getCount-1 rescue messages.getCount(MessageTypes::Species)-1)\n namearray[i] = messages.get(MessageTypes::Species,i)\n kindarray[i] = messages.get(MessageTypes::Kinds,i)\n entryarray[i] = messages.get(MessageTypes::Entries,i)\n formarray[i] = messages.get(MessageTypes::FormNames,i)\n end\n namearray[selection] = data[0]\n kindarray[selection] = data[28]\n entryarray[selection] = data[29]\n formarray[selection] = data[30]\n MessageTypes.addMessages(MessageTypes::Species,namearray)\n MessageTypes.addMessages(MessageTypes::Kinds,kindarray)\n MessageTypes.addMessages(MessageTypes::Entries,entryarray)\n MessageTypes.addMessages(MessageTypes::FormNames,formarray)\n MessageTypes.saveMessages\n # Save moves data\n newmovelist = []\n File.open(\"Data/attacksRS.dat\",\"rb\"){|f|\n for sp in 1..PBSpecies.maxValueF\n newmovelist[sp] = []\n if sp==selection\n for j in 0...data[17].length\n newmovelist[sp].push(data[17][j])\n end\n else\n offset = f.getOffset(sp-1)\n length = f.getLength(sp-1)>>1\n f.pos = offset\n for j in 0...length\n alevel = f.fgetw\n move = f.fgetw\n newmovelist[sp].push([alevel,move])\n end\n end\n end\n }\n File.open(\"Data/attacksRS.dat\",\"wb\"){|f|\n mx = newmovelist.length-1\n offset = mx*8\n for i in 1..mx\n f.fputdw(offset)\n f.fputdw((newmovelist[i]) ? newmovelist[i].length*2 : 0)\n offset += (newmovelist[i]) ? newmovelist[i].length*4 : 0\n end\n for i in 1..mx\n next if !newmovelist[i]\n for j in newmovelist[i]\n f.fputw(j[0])\n f.fputw(j[1])\n end\n end\n }\n # Save egg moves data\n neweggmovelist = []\n File.open(\"Data/eggEmerald.dat\",\"rb\"){|f|\n for sp in 1..PBSpecies.maxValueF\n neweggmovelist[sp] = []\n if sp==selection\n for j in 0...data[18].length\n neweggmovelist[sp].push(data[18][j])\n end\n else\n f.pos = (sp-1)*8\n offset = f.fgetdw\n length = f.fgetdw\n f.pos = offset\n j = 0; loop do break unless j<length\n move = f.fgetw\n break if move==0\n neweggmovelist[sp].push(move) if move>0\n j += 1\n end\n end\n end\n }\n File.open(\"Data/eggEmerald.dat\",\"wb\"){|f|\n mx = neweggmovelist.length-1\n offset = mx*8\n for i in 1..mx\n f.fputdw(offset)\n f.fputdw((neweggmovelist[i]) ? neweggmovelist[i].length : 0)\n offset += (neweggmovelist[i]) ? neweggmovelist[i].length*2 : 0\n end\n for i in 1..mx\n next if !neweggmovelist[i]\n for j in neweggmovelist[i]\n f.fputw(j)\n end\n end\n }\n # Save evolutions data\n evos = []\n for sp in 1..PBSpecies.maxValueF\n evos[sp] = []\n if sp==selection\n for i in 0...data[37].length\n evos[sp].push([data[37][i][2],data[37][i][0],data[37][i][1],0])\n end\n else\n t = pbGetEvolvedFormData(sp)\n for i in 0...t.length\n evos[sp].push([t[i][2],t[i][0],t[i][1],0])\n end\n end\n end\n _EVODATAMASK = 0x80\n _EVONEXTFORM = 0x00\n _EVOPREVFORM = 0x80\n for e in 0...evos.length\n evolist = evos[e]\n next if !evos\n parent = nil\n child = -1\n for f in 0...evos.length\n evolist = evos[f]\n next if !evolist || e==f\n for g in evolist\n if g[0]==e && (g[3]&_EVODATAMASK)==_EVONEXTFORM\n parent = g\n child = f\n break\n end\n end\n break if parent\n end\n if parent\n evos[e] = [[child,parent[1],parent[2],_EVOPREVFORM]].concat(evos[e])\n end\n end\n File.open(\"Data/evolutions.dat\",\"wb\"){|f|\n mx = evos.length-1\n offset = mx*8\n for i in 1..mx\n f.fputdw(offset)\n f.fputdw((evos[i]) ? evos[i].length*5 : 0)\n offset += (evos[i]) ? evos[i].length*5 : 0\n end\n for i in 1..mx\n next if !evos[i]\n for j in evos[i]\n f.fputb(j[3]|j[1])\n f.fputw(j[2])\n f.fputw(j[0])\n end\n end\n }\n # Don't need to save metrics or regional numbers\n # because they can't be edited here\n pbSavePokemonData\n Kernel.pbMessage(_INTL(\"Data saved.\"))\n end\n end\n end\n end\n }\nend",
"def set_new_pictures\n\n\t\t@targets.each do |x|\n\t\t\tputs \"Would you like to change the #{x.target_name.capitalize} picture?\"\n\t\t puts \"Answer: | (yes) or (no) |\"\n\t\t @answer = gets.chomp\n\t\t \tif @answer == \"yes\"\n\t\t \t\tputs \"\\n\\n\\n\"\n\t\t \t\tputs \"Okay! Please choose a picture from the options folder!\\n\"\n\t\t \t\tputs \"--------------------------\"\n\t\t \t\tputs \"Type in the filename below: (with the .jpg extension)\"\n\t\t \t\tputs \"--------------------------\"\n\t\t \t\tputs \"\\n\"\n\t\t \t\tx.new_picture = gets.chomp\n\t\t \t\tputs\n\t\t \t\tputs\n\n\t \t\t\tchange_picture(x.target_name, x.default_picture, x.new_picture)\n\n\n\t\t \telse\n\t\t\t \tputs\n\t\t\t \tputs \"Okay! On to the next one!\"\n\t\t\t \tputs\n\t\t \tend\n\n\t\tend\n\n\n\tend",
"def add_option_selection_image\n image = ProductOptionSelectionImage.new(params[:option_selection_image])\n option_selection = ProductOptionSelection.find(params[:id])\n option_selection.images << image\n responds_to_parent do\n render :update do |page| \n page[:image_list].replace_html :partial => '/admin/product_options/option_selection_image_list', \n :locals => { :option_selection => option_selection }\n end\n end\n end",
"def render_picture_gallery_editor(element, options={})\n default_options = {\n :maximum_amount_of_images => nil,\n :grouped => true\n }\n options = default_options.merge(options)\n render(\n :partial => \"alchemy/admin/elements/picture_gallery_editor\",\n :locals => {\n :pictures => element.contents.gallery_pictures,\n :element => element,\n :options => options\n }\n )\n end",
"def edit\n super\n end",
"def edit\n super\n end",
"def edit\n super\n end",
"def uploader_options\n end",
"def control; tab.image(:name, 'imgControl'); end",
"def edit_gallery_presentation_settings(gal_name = \"test\", options = {})\n Log.logger.info(\"Editing '#{gal_name}' Gallery Presentation: #{options.inspect}\")\n\n download = options[:download]\n media_view = options[:media_view]\n lightbox_desc_view = options[:lightbox_desc_view]\n\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n self.open_gallery(gal_name)\n wait.until { @browser.find_element(:xpath => @galmgr.edit_gallery) }.click\n frame = wait.until { @browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n @browser.switch_to.frame(frame)\n\n # Downloading of Image action\n download_checkbox = wait.until { @browser.find_element(:xpath => @galmgr.image_download_chkbox) }\n if download != download_checkbox.selected?\n Log.logger.info(\"Toggling download settings, download: #{download}\")\n download_checkbox.click\n else\n Log.logger.info(\"Download was already set to: #{download}. No need to toggle\")\n end\n\n # Full Page/Lightbox View action\n Log.logger.info(\"Setting media presentation view to #{media_view}\")\n if media_view == :lightbox\n lightbox_radio = @browser.find_element(:xpath => @galmgr.media_on_lightbox)\n lightbox_radio.click\n self.check_lightbox_view_settings(lightbox_desc_view)\n elsif media_view == :fullpage\n fullpage_radio = @browser.find_element(:xpath => @galmgr.media_on_fullpage)\n fullpage_radio.click\n end\n\n wait.until { @browser.find_element(:xpath => @galmgr.save_gallery_btn) }.click\n\n @browser.switch_to.default_content\n end",
"def edit\n # super\n end",
"def set_defaults\n self.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n self.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n end",
"def fleximage_editor\n \n ar_object = Kernel::const_get(params[:ar_object_class]).find(params[:ar_object_id])\n display_editor = (params[:display_editor] == \"false\")\n display_thumbnail = (params[:display_thumbnail] == \"true\")\n \n render :update do |page| \n page.replace(MainController.fleximage_domid(ar_object),\n render(:partial => \"/main/media_edit\", \n :locals => {:ar_object => ar_object, \n :timestamp => nil,\n :display_thumbnail => display_thumbnail, \n :display_editor => display_editor})\n )\n\t\tend\n end",
"def set_viewable\n viewable_id = params[:image][:viewable_id]\n\n if viewable_id.is_a?(Hash)\n @product.errors.add(:attachment, 'Erro')\n option_values_array = viewable_id.map {|option_type, option_values| option_values.map(&:to_i) }\n option_values_combinations = option_values_array.shift\n option_values_array.each do |option_value|\n option_values_combinations = option_values_combinations.product(option_value)\n end\n option_values_combinations = option_values_combinations.map(&:flatten) if option_values_combinations.count > 1\n\n @product.variants.each do |variant|\n option_values_combinations.each do |ov_combination|\n variant_option_ids = variant.option_values.pluck(:id)\n\n if ([ov_combination].flatten - variant_option_ids).empty?\n create_image(variant, permitted_resource_params)\n end\n end\n end\n else\n viewable_id = params[:master_option] if params[:master_option]\n @image.viewable_type = 'Spree::Variant'\n @image.viewable_id = viewable_id\n end\n end",
"def edit_picture_dialog_size(content)\n if content.settings[:caption_as_textarea]\n content.settings[:sizes] ? \"380x320\" : \"380x300\"\n else\n content.settings[:sizes] ? \"380x290\" : \"380x255\"\n end\n end",
"def tvSetPicture _args\n \"tvSetPicture _args;\" \n end",
"def edit_options\n menu = hike_menu_maker(@current_user.reload.hikes)\n system 'clear'\n puts \"-----MY HIKES-----\"\n if menu.length > 0\n menu[\"Cancel\"] = \"Cancel\"\n choice = @prompt.select(\"Which hike would you like to edit?\", menu)\n edit_hike_menu(choice)\n else\n puts \"You have no saved hikes at this time.\"\n @prompt.keypress(\"Press any key to continue\")\n end\n end",
"def edit\n\t\t#super\n\tend",
"def option_type; end",
"def set_defaults\n\t\t#when ever you are creating a new portfolio item (nothing else)\n\t\t#||= means if nil, replace with this:\n\t\tself.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n\t\tself.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n\tend",
"def item_edit\n end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end"
] | [
"0.6677112",
"0.61707014",
"0.6066759",
"0.6056141",
"0.5975273",
"0.5891041",
"0.581656",
"0.5789203",
"0.5769411",
"0.5763507",
"0.5735035",
"0.5722455",
"0.5656235",
"0.55947286",
"0.55710685",
"0.5568592",
"0.5568592",
"0.55612564",
"0.5541599",
"0.5508511",
"0.550413",
"0.54908836",
"0.5486491",
"0.5484513",
"0.545893",
"0.5448706",
"0.54467314",
"0.5435102",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.5427306",
"0.540855",
"0.5402241",
"0.5398578",
"0.5395988",
"0.5391765",
"0.5377932",
"0.5377827",
"0.5372646",
"0.53707594",
"0.53507406",
"0.5343604",
"0.53341895",
"0.53212756",
"0.53212756",
"0.53212756",
"0.5320753",
"0.5317186",
"0.5309567",
"0.5309567",
"0.5309567",
"0.5308783",
"0.52974904",
"0.5297181",
"0.52941597",
"0.52938",
"0.5291236",
"0.52851826",
"0.5285134",
"0.5279913",
"0.52796906",
"0.52796906",
"0.52796906",
"0.5279548",
"0.5279231",
"0.52776897",
"0.5271209",
"0.5256481",
"0.52433574",
"0.5237446",
"0.5237175",
"0.5227578",
"0.52243626",
"0.52184457",
"0.5214387",
"0.5212068",
"0.52055085",
"0.5175628",
"0.5175628",
"0.5175628",
"0.5175628",
"0.5175628"
] | 0.6118333 | 2 |
Retrieve all champions, v1.1 | def get
perform_request(api_url("champion"))["champions"].map {|c| Champion.new(c)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n get(resource_path, @version).champions.map do |champion|\n RiotGamesApi::LOL::Model::Champion::Champion.new champion\n end\n end",
"def index\n @champions = Champion.all\n end",
"def index\n @ches = Ch.all\n end",
"def index\n @chitters = Chitter.all\n end",
"def index\n @chas = Cha.all\n end",
"def index\n @chuls = Chul.all\n end",
"def index\n champions = Champion.all\n render json: champions\n end",
"def champion_all(key_by_id = false, data_version = nil)\n champion_list = get(resource_path('champion'), @version, champData: 'all', dataById: key_by_id, version: data_version)\n\n if key_by_id\n RiotGamesApi::LOL::Model::StaticData::ChampionListDataById.new champion_list\n else\n RiotGamesApi::LOL::Model::StaticData::ChampionList.new champion_list\n end\n end",
"def index\n @chapitres = Chapitre.all\n end",
"def show\n set_lobby\n @champions = Champion.all\n end",
"def index\n @championships = Championship.all\n end",
"def index\n @chosains = Chosain.all\n end",
"def index\n @cotiz_mes_cams = CotizMesCam.all\n end",
"def get_champion_names\n Static.get_champion_list.keys\n end",
"def index\n @flow_chapters = FlowChapter.all\n end",
"def index\n @chores = Chore.all\n end",
"def index\n @chats = current_user.chats\n end",
"def index\n @channels = Channel.all\n end",
"def index\n @channels = Channel.all\n end",
"def index\n @mattches = Mattch.all\n end",
"def index\n @chuc_danhs = ChucDanh.all\n end",
"def index\n @cms_chapter_meeting_minutes = Cms::ChapterMeetingMinute.all\n end",
"def index\n @chinese_phrases = ChinesePhrase.all\n end",
"def index\n @chirps = Chirp.getAllChirpsOrdered\n end",
"def channels_list\n get \"channels\"\n end",
"def index\n @chamadas = Chamada.all\n end",
"def get_list\r\n Butterfly::Scraper.scrape_chairs\r\n @chairs = Butterfly::Chair.all\r\n end",
"def chats\n @chats ||= Chat.find_all_by_match_id(params[:match_id], :include => :player)\n end",
"def index\n @church_men = ChurchMan.all\n end",
"def index\n @convites = Convite.all\n end",
"def index\n @chats = Chat.limit(100)\n end",
"def index\n @hearing_conferences = HearingConference.all\n end",
"def index\n @amputation_levels = AmputationLevel.all\n end",
"def index\n @smpl_chats = SmplChat.all\n end",
"def index\n @champion_series_points = ChampionSeriesPoint.all\n end",
"def index\n @talks = @conference.talks\n end",
"def index\n @channel_statistics = ChannelStatistic.all\n end",
"def list_channels(workspace)\n puts \"\\nChannel List\\n\\n\"\n tp workspace.channels, \"id\", \"name\", \"topic\", \"member_count\"\nend",
"def index\r\n @chats = Chat.all\r\n end",
"def index\r\n @chapas = Chapa.all\r\n respond_with(@chapas)\r\n end",
"def index\r\n @channels = current_user.channels.all\r\n end",
"def get_chapters\n @subject = Subject.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @subject.chapters.map {|u| Hash[value: u.id, name: u.name]}\n else\n chapter_ids = ContentUserLayout.get_unlocked_chapters(@subject,current_user)\n if !chapter_ids.nil?\n list = @subject.chapters.where(:id=>chapter_ids).map {|u| Hash[value: u.id, name: u.name]}\n else\n list = @subject.chapters.map {|u| Hash[value: u.id, name: u.name]}\n end\n end\n render json: list\n end",
"def index\n @challenges = Challenge.all params[:filters], params[:page]\n end",
"def index\n @chats = Chat.all\n end",
"def index\n @chats = Chat.all\n end",
"def index\n @chats = Chat.all\n end",
"def index\n @chats = Chat.all\n end",
"def all\r\n channels = Channel.all.order(:id)\r\n render json: channels\r\n end",
"def index\n @zhichengs = Zhicheng.all\n end",
"def index\n @chapters = Chapter.all\n end",
"def all_talks\n Talk.all_talks(id)\n end",
"def index\n @hands = Hand.all\n end",
"def index\n @cinema_film_connections = CinemaFilmConnection.all\n end",
"def index\n @scheduled_chores = ScheduledChore.all\n end",
"def champions\n\t\t\t\n\t\tend",
"def index\n @channels = Channel.where(:user_id => current_user.id).to_a\n end",
"def index\n @universal_channels = UniversalChannel.all\n end",
"def index\n @canchas = Cancha.all\n end",
"def index\n @ab_chapters = AbChapter.all\n end",
"def index\n @whiches = Which.all\n end",
"def index\n @chambers = Chamber.all\n end",
"def index\n @championships = Championship.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @championships }\n end\n end",
"def index\n @cheeps = Cheep.all\n end",
"def index\n @turn_schemes = TurnScheme.all\n end",
"def index\n @pithchers = Pithcher.all\n end",
"def get_topics\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: u.id, name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n end\n end\n render json: list\n end",
"def index\n @mechons = Mechon.all\n end",
"def index\n @mechromancers = Mechromancer.all\n end",
"def index\n @howmanies = Howmany.all\n end",
"def index\n @coches = Coche.all\n end",
"def get_chapters_values\n @subject = Subject.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @subject.chapters.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n chapter_ids = ContentUserLayout.get_unlocked_chapters(@subject,current_user)\n if !chapter_ids.nil?\n list = @subject.chapters.where(:id=>chapter_ids).map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n list = @subject.chapters.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n end\n end\n render json: list\n end",
"def index\n @championships = Championship.all\n\n render json: @championships\n end",
"def index\n @pitches = Pitch.all\n end",
"def index\n @congties = Congty.all\n end",
"def getChannelsList\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n result = HTTParty.get(broker_url + \"/resources/channels\", :verify => false)\n temp2 = JSON.parse(result.body)\n\n channels_data = temp2[\"resource_response\"][\"resources\"]\n return channels_data\n \n end",
"def index\n @simple_chores = SimpleChore.all\n respond_to do |format|\n format.html\n format.json { render :json => @simple_chores }\n end\n end",
"def channels(params = {page:1})\n http.get('/channels', params)\n end",
"def index\n @chore_lists = ChoreList.all\n end",
"def index\n @games = Game.all\n @channels = Game.all_live_channels.order(viewers: :desc).limit(8)\n end",
"def index\n authenticate\n @user = current_user\n @users = User.find_everyone(@user)\n @chats = @user.chats\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chats }\n end\n end",
"def index\n \t@channels = Channel.all\n\t\t render json: @channels\n end",
"def index\n @chatareas = Chatarea.includes(:chatarea_users)\n @common_words = Message.common_words\n end",
"def index\n @all_hands = AllHand.all\n end",
"def index\n @pitches = Pitch.all\n end",
"def all free_to_play: false\n result = perform_request api_url(\"champions\", \"freeToPlay\" => free_to_play)\n result[\"champions\"].map { |c| DynamicModel.new c }\n end",
"def index\n @chronics = Chronic.where(\"patient_id = ?\", params[:p_id])\n end",
"def show\n game = Game.find_by_id params[:id]\n @channels = game.get_live_channels.order(viewers: :desc).limit(20)\n end",
"def index\n @campania = Campanium.all\n end",
"def index\n @cinema_timetables = CinemaTimetable.all\n end",
"def index\n @chi_tiet_gio_hangs = ChiTietGioHang.all\n end",
"def index\n @favorite_chapters = FavoriteChapter.all\n end",
"def list_resources\n 'channels'\n end",
"def index\n @contamination_levels = ContaminationLevel.all\n end",
"def index\n @chargers = Charger.all\n render json: @chargers\n end",
"def index\n @chuyen_mon_nghiep_vus = ChuyenMonNghiepVu.all\n end",
"def index\n @weekly_challenges = WeeklyChallenge.all\n end",
"def index\n chapters = @project.chapters.all\n render json: { chapters: chapters }\n end",
"def index\n @creatures = Monster.all\n end",
"def index\n @campuses = Campus.all\n end",
"def index\n @tv_channels = TvChannel.all\n end"
] | [
"0.69962007",
"0.6849798",
"0.68175745",
"0.66379714",
"0.6508881",
"0.64422816",
"0.64127004",
"0.6386475",
"0.63640076",
"0.6362937",
"0.6172406",
"0.613745",
"0.6065645",
"0.6059269",
"0.59582025",
"0.5948984",
"0.5925127",
"0.58815324",
"0.58815324",
"0.5877014",
"0.587645",
"0.58664066",
"0.5861756",
"0.5859601",
"0.58132446",
"0.5806252",
"0.5801591",
"0.5794534",
"0.579345",
"0.5792573",
"0.5776551",
"0.5763432",
"0.5755334",
"0.57516557",
"0.57501084",
"0.57297474",
"0.57296526",
"0.570711",
"0.5698033",
"0.56975484",
"0.5692056",
"0.5682178",
"0.5677856",
"0.5672514",
"0.5672514",
"0.5672514",
"0.5672514",
"0.56711733",
"0.5663653",
"0.5658005",
"0.5647265",
"0.56445825",
"0.5641787",
"0.5638711",
"0.5637924",
"0.5627598",
"0.5616622",
"0.5604687",
"0.560043",
"0.55837333",
"0.55832034",
"0.5572484",
"0.556757",
"0.5565377",
"0.55629236",
"0.55619425",
"0.5559617",
"0.5559302",
"0.55554026",
"0.5553163",
"0.55531365",
"0.5550202",
"0.5537159",
"0.55309814",
"0.552967",
"0.55294734",
"0.55258846",
"0.5522246",
"0.5520441",
"0.5515111",
"0.5507212",
"0.5504782",
"0.550443",
"0.55039656",
"0.5498422",
"0.5491762",
"0.54805624",
"0.54759413",
"0.5469847",
"0.5463373",
"0.5438942",
"0.5437521",
"0.54373574",
"0.5435859",
"0.54324955",
"0.5430097",
"0.5427341",
"0.54261565",
"0.5422276",
"0.5417141"
] | 0.6659281 | 3 |
Evaluate the ERB template in +file+ and returns the result as a string. Use with +render+: render erb(:muffin) | def erb(file)
path = File.join(@root, "views", file.to_s)
ERB.new(File.read("#{path}.erb")).result(binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render\n template = ERB.new File.new(@template_path).read, nil, \"%\"\n template.result(binding)\n end",
"def render_erb\n require 'erb'\n\n renderer = ERB.new(template_content, trim_mode: '-')\n renderer.filename = @template_file\n renderer.result(binding)\n end",
"def render_template(file, locals = {})\n ERB.new(File.read(file)).result OpenStruct.new(locals).instance_eval{ binding }\n end",
"def render_erb_template(filename)\n template = File.read(filename)\n result = ERB.new(template).result(binding)\n end",
"def render\n ERB.new(File.read(TEMPLATE), 0, \">\").result(binding)\n end",
"def render_erb_template(filename)\n template = File.read(filename)\n result = ERB.new(template).result(binding)\n end",
"def render_erb_template(filename)\n template = File.read(filename)\n result = ERB.new(template).result(binding)\n end",
"def erb(t)\n ERB.new( File.open(t).read, 0, '<>' ).result\nend",
"def render(path)\n template = ERB.new(File.read(File.expand_path(path)), trim_mode: '-')\n template.result(binding)\n end",
"def render\n ERB.new(File.read(@file)).result(binding)\n end",
"def erb(file, b=binding)\n require 'erb'\n erb = ERB.new(File.read(file))\n erb.result b\n end",
"def render(file_path, local_variables = {})\n absolute_path = File.expand_path file_path, base_path\n absolute_path += FILE_EXTENSION unless absolute_path.end_with?(FILE_EXTENSION)\n file_content = File.read absolute_path\n erb = ERB.new file_content\n erb.result create_binding(base_path, local_variables)\n end",
"def erb_template(file_path)\n template = ERB.new(File.read(file_path))\n template.filename = file_path\n template\n end",
"def render_erb(fname)\n ERB.new(\n File.read(\"src/#{fname}.erb\")\n ).result(binding)\nend",
"def erb(file, options)\n # https://www.rubyguides.com/2015/05/working-with-files-ruby/\n result = File.read(\"views/layout.erb\")\n template = File.read(\"views/#{file}.erb\")\n # https://www.rubyguides.com/2019/07/ruby-gsub-method/\n result.gsub! \"<%= yield %>\", template\n result\n end",
"def eval_file\n @file || '(__TEMPLATE__)'\n end",
"def erb(file_name, template_name)\n template = ERB.new(File.open(template_name, \"r:UTF-8\", &:read), nil, \"-\")\n File.open(file_name, \"w:UTF-8\") { |file| file.write(template.result(binding)) }\nend",
"def render\n source = IO.read \"#{Pv.root}/lib/templates/story.txt.erb\"\n template = ERB.new(source)\n template.result(binding)\n end",
"def template(filename, locals={})\n b = binding\n to_display = locals\n load_from = File.expand_path(\"../views/#{filename}.erb\", __FILE__)\n content = File.read(load_from)\n ERB.new(content).result(b)\n end",
"def slurpee(file, safe_level = nil)\n ERB.new(slurp(file), safe_level).result\n end",
"def parse_template(path)\n render(File.read(path))\n end",
"def erubis_template template_filename, *args\n require 'erubis'\n template = Erubis::Eruby.new File.read(template_filename)\n text = template.result *args\n text\nend",
"def process_string(tmpl, fname='(bibout)', hash=nil)\n bind = ErbBinding.new(@bib, @root_dir, hash).get_binding()\n erb = ERB.new(tmpl)\n erb.filename = fname\n erb.result(bind)\n end",
"def template_for file, page = true, klass = ERB\n template = @template_cache[file]\n\n return template if template\n\n if page then\n template = assemble_template file\n erbout = 'io'\n else\n template = file.read\n template = template.encode @options.encoding\n\n file_var = File.basename(file).sub(/\\..*/, '')\n\n erbout = \"_erbout_#{file_var}\"\n end\n\n if RUBY_VERSION >= '2.6'\n template = klass.new template, trim_mode: '-', eoutvar: erbout\n else\n template = klass.new template, nil, '-', erbout\n end\n @template_cache[file] = template\n template\n end",
"def erb_string(erbfile, b = binding)\n template = File.read(erbfile)\n message = ERB.new(template, trim_mode: \"-\")\n message.result(b)\n .gsub(/[\\n]+{3,}/, \"\\n\\n\")\n .squeeze(\"\\s\")\n end",
"def erb(filename, locals={}, layout=nil)\n b = binding\n use_template = template(filename, locals)\n locals = locals\n if layout\n layout = File.expand_path(\"../views/#{layout}.erb\",__FILE__)\n content = File.read(layout)\n ERB.new(content).result(b)\n else\n use_template\n end\n end",
"def render(context = Erubis::Context.new)\n # Read template data\n template_filename = \"#{@template}.rhtml\"\n begin\n template = File.read(template_filename)\n rescue Errno::ENOENT\n raise ScriptError.new(\"Template #{template_filename} does not exist!\")\n end\n\n # Prepare template and variables\n eruby = Erubis::Eruby.new template\n \n # Perform templating\n begin\n result = eruby.evaluate context\n rescue\n raise TemplateError.new(\"Encountered error processing template #{template_filename}.\", $!)\n end\n\n # Output result\n output result \n end",
"def render()\n # WARNING! NO NEED TO UNDERSTAND THIS\n self.action = calling_method = caller[0].split(\"`\").pop.gsub(\"'\", \"\")\n template = File.read(view_filename)\n eruby = Erubis::Eruby.new(template)\n eruby.result(binding())\n end",
"def render(template_name)\n template = ERB.new( \n File.read( full_template_path( template_name ) )\n )\n render_content( template.result( binding ), 'text/html' )\n end",
"def erb(template) render template end",
"def evaluate_template(template_name,bind)\n template_dir = File.expand_path('./scripts',File.dirname(__FILE__))\n template = File.read(File.expand_path(\"./#{template_name}\",template_dir))\n ERB.new(template, nil, '-').result(bind)\nend",
"def evaluate_template(template_name,bind)\n template_dir = File.expand_path('./scripts',File.dirname(__FILE__))\n template = File.read(File.expand_path(\"./#{template_name}\",template_dir))\n ERB.new(template, nil, '-').result(bind)\nend",
"def render(template)\n b = binding\n code = ERB.new template\n code.result b\n end",
"def render_template( templatefile, context, outfile )\n\t\ttemplate_src = templatefile.read\n\t\ttemplate = ERB.new( template_src, nil, '<>' )\n\t\ttemplate.filename = templatefile.to_s\n\n\t\toutput = begin\n\t\t\ttemplate.result( context )\n\t\trescue NoMethodError => err\n\t\t\traise \"Error while evaluating %s: %s (at %p)\" % [\n\t\t\t\ttemplatefile.to_s,\n\t\t\t\terr.message,\n\t\t\t\teval( \"_erbout[-50,50]\", context )\n\t\t\t]\n\t\tend\n\n\t\tunless $dryrun\n\t\t\toutfile.dirname.mkpath\n\t\t\toutfile.open( 'w', 0644 ) do |ofh|\n\t\t\t\tofh.print( output )\n\t\t\tend\n\t\telse\n\t\t\tdebug_msg \" would have written %d bytes to %s\" %\n\t\t\t[ output.length, outfile ]\n\t\tend\n\tend",
"def render_template( templatefile, context, outfile )\n\t\ttemplate_src = templatefile.read\n\t\ttemplate = ERB.new( template_src, nil, '<>' )\n\t\ttemplate.filename = templatefile.to_s\n\n\t\toutput = begin\n\t\t\ttemplate.result( context )\n\t\trescue NoMethodError => err\n\t\t\traise \"Error while evaluating %s: %s (at %p)\" % [\n\t\t\t\ttemplatefile.to_s,\n\t\t\t\terr.message,\n\t\t\t\teval( \"_erbout[-50,50]\", context )\n\t\t\t]\n\t\tend\n\n\t\tunless $dryrun\n\t\t\toutfile.dirname.mkpath\n\t\t\toutfile.open( 'w', 0644 ) do |ofh|\n\t\t\t\tofh.print( output )\n\t\t\tend\n\t\telse\n\t\t\tdebug_msg \" would have written %d bytes to %s\" %\n\t\t\t[ output.length, outfile ]\n\t\tend\n\tend",
"def render_file(src_file, options)\n render_string File.read(src_file), options\n end",
"def renderFile(templateFile, targetFile)\n puts \"Render file: #{targetFile}\" \n erb=ERB.new(File.read(templateFile))\n File.new(targetFile,'w+').write(erb.result(binding))\n end",
"def render\n ERB.new(load_resource(template)).result(bound.get_binding)\n end",
"def convert\n erb = ERB.new(File.readlines(template_file).join)\n File.open(File.basename(content_file, File.extname(content_file)) + '.html', 'w') do |f|\n f << erb.result(get_binding)\n end\n end",
"def render\n ERB.new(@template, nil, '-').result(binding)\n end",
"def render_string_from_view(view_file)\n end",
"def render_string_from_view(view_file)\n end",
"def render(*partial_path)\n template_path = full_path(*partial_path)\n\n code = File.read(template_path)\n\n @output = eval(code, binding, template_path.to_s)\n end",
"def render(template_name)\n #Use controller and template names to construct paths to template files.\n\n\n #Use File.read to read the template file.\n\n #Create a new ERB template from the contents.\n \n #Evaluate the ERB template, using binding to capture the controller's instance variables.\n\n #Pass the result to #render_content with a content_type of text/html.\n\n \n end",
"def export_to_template template, file\n renderer = ERB.new(File.read(template))\n output = renderer.result binding\n output_file = File.open file, 'w'\n output_file << output\n output_file.close\n end",
"def evaluate(tmap)\n raise \"Template was not loaded: #{@template}\" if !@loadOK\n \n @tmap = tmap\n tsub = ERB.new(@template).result(binding) \n tsub\n end",
"def render\n case File.extname(@template_file)\n when '.erb'\n render_erb\n else\n render_plain\n end\n end",
"def render file_name\n template_file = @template_dir + file_name\n\n template = template_for template_file, false, RDoc::ERBPartial\n\n template.filename = template_file.to_s\n\n template.result @context\n end",
"def render_template_to_file(template, file, context)\n t = File.read(File.join(template))\n File.open(file, \"w\") do |f|\n f << ERB.new(t, nil, \"-\").result(context)\n end\n end",
"def render(filename, content)\n if renderer = renderer_for(filename)\n renderer.call content\n else\n content\n end\n end",
"def erb_file(erb_path, context = {})\n erb(IO.read(erb_path))\n end",
"def render\n require 'erb'\n template_file = File.dirname(__FILE__) + '/profile/template.erb'\n template = File.read(template_file)\n ERB.new(template,nil,'-').result(binding)\n end",
"def render_file(file, context=nil, extra_context={})\n File.open(file, 'r') do |file|\n render_string file.read, context, extra_context\n end\n end",
"def load_template\n\t\traw = IO.read( __FILE__ ).split( /^__END__$/m, 2 ).last\n\t\treturn ERB.new( raw, nil, '<%>' )\n\tend",
"def render(template_name)\n template_content = File.read(template_path(template_name))\n template = ERB.new(template_content)\n response_body = template.result(get_binding)\n render_content(response_body, 'text/html')\n end",
"def render(pathname)\n @partial_templates ||= {}\n ::ERB.new(File.read(pathname)).result(binding)\n end",
"def render(template_name)\n # \"views/#{controller_name}/#{template_name}.html.erb\"\n\n # format view path\n controller_name = self.class.to_s.underscore\n view_path = \"views/#{controller_name}/#{template_name}.html.erb\"\n\n # read in contents of view file and interpret embedded ruby\n view_content = File.read(view_path)\n template_content = ERB.new(view_content).result(binding) # binding gives erb access to ivars\n\n # html/text downloads output???\n render_content(template_content, \"text/html\")\n end",
"def fill_template\n @log.debug(\"Reading erb template from file: '#{@template}'.\")\n erb = ERB.new(File.read(@template), nil, '-')\n erb.filename = @template\n erb.result(binding)\n end",
"def uglify(file)\n #'hello world'\n template = Tilt.new(File.join('views',file)).render(self)\n Uglifier.compile(template)\n #Uglifier.compile(ERB.new(File.read(File.join('views', file))).result(binding).force_encoding('UTF-8').gsub(/^#.*?\\n/,''))\n end",
"def template(from, to)\n erb = File.read(from)\n put ERB.new(erb).result(binding), to\nend",
"def rendered_content\n ERB.new(template).result(binding)\n end",
"def erb(content)\n ERB.new(content).result(binding)\nend",
"def render_erb_inline(file, opts = {})\n if File.exist?(erb_path_for(file))\n ERB.new(IO.read(erb_path_for(file))).result(binding).gsub(/\\n/, \"\\n#{sprintf(\"%#{opts[:indent]}s\", \"\")}\").strip\n else\n raise \"Can't do an inline render of '#{file}' because it doesn't exist!\"\n end\nend",
"def render_to_string(template, locals = {})\n read_template(lookup_template(template), locals)\n end",
"def render_template(template)\n doc = ERB.new(template, 0, \"%<>\")\n # doc.run(self.send(:binding))\n doc.result(self.send(:binding))\n end",
"def template_for(file); end",
"def read_base_file(file)\n raw_content = File.read(file)\n file[-4..-1]=='.erb' ? ERB.new(raw_content).result(@context.get_binding) : raw_content\n end",
"def parse(filename, context, output: nil, force: false)\n erb = ERB.new(File.read(filename))\n if(!output)\n output = filename[0..-6]\n end\n \n if(File.exists?(output) and !force)\n raise \"The output #{output} file already exists.\"\n end\n\n File.open(output, 'w') do | file |\n file.write(erb.result(context.get_binding()))\n end\nend",
"def render_text(template_text, options)\n ERB.new(template_text, 0, '%<>').result(binding)\n end",
"def process_template(source_file)\n rfile = ERB.new(File.read(source_file))\n @cookbook = @metadata.name\n\n rfile.result(binding)\n end",
"def render_template(file, variables)\n template = load_template(file) or raise \"template not found: #{path}\"\n template.render(variables)\n end",
"def render_template(file_path)\n @current_file_stack.push(file_path)\n begin\n tilt_template(file_path)\n rescue StaticMatic::TemplateError => e\n raise e # re-raise inline errors\n rescue Exception => e\n raise StaticMatic::TemplateError.new(file_path, e)\n ensure\n @current_file_stack.pop\n end\n end",
"def render(path, options={})\n # render template\n template = File.read(path)\n\n # assign locals to the render binding\n # this almost surely may be optimized...\n locals = options[:locals]\n binding = empty_binding\n\n locals.each_pair do |key, value|\n @assignment_value = value\n eval(\"#{key} = remove_instance_variable(:@assignment_value)\", binding)\n end if locals\n\n erb = ERB.new(template, nil, \"<>\")\n erb.filename = path\n erb.result(binding)\n end",
"def render_template(template, context={})\n Erubis::Eruby.new(template).evaluate(context)\n end",
"def render(template_name)\n controller_name = self.class.to_s.underscore\n\n string = File.read(\"./views/#{controller_name}/#{template_name}.html.erb\")\n #\"./\" for project root dir\n\n template = ERB.new(string)\n capture = template.result(binding) #evaluate and bind\n\n render_content(capture, \"text/html\")\n end",
"def extract_source_from_file(file_path, env = {})\n HtmlMockup::Template.open(file_path, :partials_path => self.project.partial_path, :layouts_path => self.project.layouts_path).render(env.dup)\n end",
"def evaluate_file(file)\n evaluate(parse_file(file))\n end",
"def generate template, file\n if file.kind_of? String then # one file\n write_template(file, ERB.new(load_template(template)).result(binding))\n else # multiple files\n file.each do |f|\n write_template(f, ERB.new(load_template(template)).result(binding))\n end\n end\n end",
"def render_template(template_file, binding, outfile)\n\n debug_msg \" rendering #{outfile}\"\n\n @rel_prefix = @output_dir.relative_path_from(outfile.dirname)\n @stylesheet_url = @babel_options[:stylesheet_url] || (@rel_prefix + 'rdoc.css').to_s\n\n template_src = template_file.read\n template = ERB.new(template_src, trim_mode: '<>')\n template.filename = template_file.to_s\n\n output = nil\n begin\n output = template.result(binding)\n rescue => e\n raise RDoc::Error, \"Error while evaluating %s: %s (%s at %p)\" % [\n template_file.to_s,\n e.message, e.class.name,\n eval(\"_erbout[-50,50]\", binding)\n ], e.backtrace\n end\n\n return if @options.dry_run\n\n outfile.dirname.mkpath\n outfile.open('w', 0644) do |ofh|\n ofh.print(output)\n end\n\n end",
"def file_to_render\n file\n end",
"def evaluate_erb; end",
"def render(source)\n ERB.new(source, nil, '-').result(binding)\n end",
"def get_compiled_file_content(path)\n begin\n Tilt.new(path.to_s).render({}, {\n :spec => spec\n })\n rescue RuntimeError\n File.read(path)\n end\n end",
"def render\n begin\n template = IO.read(get_template_path)\n rescue Exception => e\n raise PhantomError, e.message\n end\n # with all the fields\n @fields.each do |field|\n template = template.gsub(Regexp.new(\"\\\\[\\\\[#{field.field}\\\\]\\\\]\"), field.field_value.to_s)\n end\n template = template.gsub(Regexp.new(\"\\\\[\\\\[ENTRY_POINT\\\\]\\\\]\"), @config['entry_point'])\n # write\n path = ''\n begin\n Tempfile.open(['phantom','.coffee'], \"#{Rails.root}/tmp\") do |f|\n f.print template\n path = f.path\n end\n rescue\n return false\n end\n path\n end",
"def render(template_name)\n #Open template, put content into string-content\n cntrl_name = self.class.to_s.underscore\n\n erb_temp = File.read(\"views/#{cntrl_name}/#{template_name}.html.erb\")\n content = ERB.new(erb_temp).result(binding)\n\n render_content(content , 'text/html')\n end",
"def render(obj, template = obj.template_name)\n file = \"templates/#{template}.erb\"\n eruby = Erubis::Eruby.new File.read(file), filename: File.basename(file)\n context = SimpleDelegator.new(obj)\n context.extend Helpers\n context.extend TemplateHelpers\n eruby.evaluate(context)\n end",
"def template_content(template_file)\n File.read(File.expand_path(find_in_source_paths(template_file)))\n end",
"def render(template_name)\n contents = File.read(\"views/#{self.class.to_s.underscore}/#{template_name}.html.erb\")\n template = ERB.new(contents)\n # ivars = self.instance_variables\n new_content = template.result(binding)\n render_content(new_content, \"text/html\")\n end",
"def to_tex\n ERB.new(IO.read(TEMPLATE_PATH)).result(binding)\n end",
"def erb(template_path, vars)\n template = File.read(template_path)\n ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })\n end",
"def evaluate_dynamic_content(filename, value)\n ruby_content = \"\"\n begin\n # non greedy matching of dynamic code\n value.gsub!(/<%=((.|\\n)*?)%>/) do |match|\n if match =~ /<%=((.|\\n)*?)%>/\n ruby_content = $1.strip\n p = Proc.new {}\n eval(ruby_content, p.binding, filename)\n else\n match\n end\n end\n rescue Exception => e\n raise e, \"error evaluating dynamic content '#{ruby_content}': #{e.message}\", e.backtrace\n end\n value\n end",
"def read_template( name )\n\t\tname = \"%s.erb\" % [ name ] unless name.to_s.end_with?( '.erb' )\n\t\ttemplate_path = DEVEIATE_DATADIR + name\n\t\ttemplate_src = template_path.read( encoding: 'utf-8' )\n\n\t\treturn ERB.new( template_src, trim_mode: '-' )\n\tend",
"def render_template(template_name, locals={})\n parse_file_as_erb(\"#{Rails.root}/lib/tasks/templates/#{template_name}.erb\", locals)\nend",
"def get_template(file) #this is our template, defined as a single string\n s = \"\"\n File.open(file) do |f|\n f.each_line do |line|\n s.concat(line)\n end\n end\n s\nend",
"def get_template_from_file(file_path)\n template_text = nil\n\n File.open(file_path, 'r') do |f_in|\n template_text = f_in.read\n end\n\n return template_text\n end",
"def html\n @html ||= Template.new(\"#{@input_file}:body\", @body).\n render_with(template_ivar => self).to_html\n end",
"def partial(filename, binding)\n template_file = get_template_file(filename)\n ERB.new(template_file, nil, '-', '_erbout2').result(binding)\nend",
"def erb( content )\n puts \" Running embedded Ruby (erb) code/helpers...\"\n \n content = ERB.new( content ).result( binding() )\n content\n end",
"def compile_rails_template(template_file_name)\n template_content = read_template_content(template_file_name)\n if template_file_name[/\\.hbs\\.erb\\z/]\n compiled_rails_template = ERB.new(template_content).result\n elsif template_file_name[/\\.hamlbars\\z/]\n stub = ''\n compiled_rails_template = Haml::Engine.new(template_content).render(stub)\n end\n compiled_rails_template\n end",
"def build template\n erb = File.read(File.join(VIEWS_DIR, template + \".erb\"))\n content = ERB.new(erb).result(binding)\n File.open(template, 'w') do |f|\n f.write content.gsub(/\\n\\n\\n+/, \"\\n\\n\")\n end\n end"
] | [
"0.73885167",
"0.7379999",
"0.7313286",
"0.7293423",
"0.7273247",
"0.72723466",
"0.72723466",
"0.72586757",
"0.71918637",
"0.719027",
"0.71467716",
"0.71028024",
"0.70671463",
"0.70646524",
"0.7013945",
"0.6979676",
"0.68916166",
"0.6866717",
"0.6813862",
"0.6725856",
"0.6724711",
"0.67117244",
"0.6705065",
"0.6700894",
"0.66557",
"0.6636617",
"0.6631995",
"0.6610151",
"0.6595932",
"0.6560984",
"0.6519581",
"0.6519581",
"0.65147626",
"0.6509095",
"0.6509095",
"0.6506338",
"0.65033466",
"0.64981616",
"0.6476992",
"0.646844",
"0.64674866",
"0.64674866",
"0.6451143",
"0.6449967",
"0.644951",
"0.6445216",
"0.64255846",
"0.64169794",
"0.64088845",
"0.6394791",
"0.638783",
"0.63861114",
"0.63848484",
"0.63770396",
"0.6359007",
"0.6349315",
"0.6344071",
"0.634321",
"0.6333503",
"0.63261366",
"0.6325811",
"0.632055",
"0.6308618",
"0.6306235",
"0.6298693",
"0.62921804",
"0.6274388",
"0.62587184",
"0.6250931",
"0.62235945",
"0.62206286",
"0.62082547",
"0.6207848",
"0.6202785",
"0.6200955",
"0.6197945",
"0.6189102",
"0.6180873",
"0.6173959",
"0.61711526",
"0.61701035",
"0.6156389",
"0.6154343",
"0.6150977",
"0.6147684",
"0.61473817",
"0.61447173",
"0.6142904",
"0.6136758",
"0.612893",
"0.6124445",
"0.61208194",
"0.61141783",
"0.6111106",
"0.61057323",
"0.60997504",
"0.60843647",
"0.6081247",
"0.6074514",
"0.6071186"
] | 0.7170457 | 10 |
Build a class object using a Flat scope so we can pass through variables Then pass it as an object to setup_privileges | def objbuilder(user, type="", group="", password="")
# user becomes group when adding / deleting groups
# objbuilder("#{@thmgroupname}", "addgroup")
designobj = Class.new do
attr_reader :type, :group, :password
define_method :initialize do
instance_variable_set("@type", "#{type}")
instance_variable_set("@group", "#{group}")
instance_variable_set("@password", "#{password}")
end
end
setup_privileges("#{user}", designobj)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(user)\n define_global_privileges\n define_user_privileges(user) if user\n define_admin_privileges(user) if user and user.admin?\n end",
"def initialize(scope, user, params, &block)\n @scope = scope\n @params = params.dup\n @user = user\n\n instance_eval(block) if block_given?\n\n build\n end",
"def initialize(key)\n key ||= Apicasso::Key.new\n cannot :manage, :all\n cannot :read, :all\n key.scope&.each do |permission, klasses_clearances|\n build_permissions(permission: permission, clearance: klasses_clearances)\n end\n end",
"def owner_perm privilege, klass, owner\n Permission.new( :privilege => privilege,\n :class_name => klass.name,\n :is_grant => false,\n :has_grant_option => false,\n :target_owned_by_self => false,\n :target_owner => owner\n )\n \n end",
"def with_privilege privilege\n self.clone.tap do |api|\n api.privilege = privilege\n end\n end",
"def initialize_cancan_ability\n ability_class_name = resource.namespace.cancan_ability_class\n\n if ability_class_name.is_a?(String)\n ability_class = ActiveSupport::Dependencies.constantize(ability_class_name)\n else\n ability_class = ability_class_name\n end\n\n ability_class.new(user)\n end",
"def initialize(user)\n authorize_guest(user)\n return if user.nil?\n\n authorize_admin(user)\n end",
"def initialize(name,args,type,scope,abstraction)\n @name = name\n @args = args\n @type = type\n @scope = scope\n @abstraction = abstraction\n end",
"def create_auth(input)\n class_member(input)\n end",
"def owner_firm_perm privilege, klass, firm\n Permission.new( :privilege => privilege,\n :class_name => klass.name,\n :is_grant => false,\n :has_grant_option => false,\n :target_owned_by_self => false,\n :target_owner_firm => firm\n )\n \n end",
"def initialize(user = nil, scope)\n @user = user\n @scope = scope\n end",
"def initialize(role, &blk)\n @role, @policies, @scopes = role, {}, {}\n instance_eval(&blk) if block_given?\n end",
"def initialize(user)\n anonymous_abilities\n\n if user.blank?\n no_user_abilities\n else\n cannot :update, UserSession\n # can :manage, Section do |section|\n # can? :update, section.document\n # end\n # habitapedia_abilities(user)\n # social_abilities(user)\n admin_abilities if user.admin?\n end\n end",
"def initialize_vars\n \n @auth_user_class = Auth.configuration.user_class.constantize\n\n @auth_user_params = permitted_params.fetch(:user,{}) \n\n @auth_user = params[:id] ? @auth_user_class.find_self(params[:id],current_signed_in_resource) : @auth_user_class.new(@auth_user_params)\n \n end",
"def new\n @privacies = Privacy.all\n super\n end",
"def initialize(pass, scope)\n @pass = pass\n @scope = scope\n end",
"def initialize(user)\n user.permissions.each do |permission|\n can permission.action.to_sym, #establishes a permission\n permission.thing_type.constantize do |thing|\n #thing_type.constantize is like <Classname>.<Call constructor>\n thing.nil? || # allows broadly, ie. just specify an action, and not a thing\n permission.thing_id.nil? ||\n permission.thing_id == thing.id\n end\n end\n end",
"def initialize(*args) # * is a splat operator\n #instance variable for email set to argument 0\n @email = args[0]\n @name = args[1]\n @permissions = User.permissions_from_template\n end",
"def initialize_rights\n @permissions ||= {}\n @user_groups ||= {}\n\n @public_access ||= []\n @protected_access ||= []\n end",
"def initialize(user)\n @user = user || User.new\n\n can :manage, :all if user.present?\n\n meta_abilities\n end",
"def initialize(user, controller_namespace)\n # Define abilities for the passed in user here. For example:\n #\n # user ||= User.new # guest user (not logged in)\n # if user.admin?\n # can :manage, :all\n # else\n # can :read, :all\n # end\n #\n # The first argument to `can` is the action you are giving the user permission to do.\n # If you pass :manage it will apply to every action. Other common actions here are\n # :read, :create, :update and :destroy.\n #\n # The second argument is the resource the user can perform the action on. If you pass\n # :all it will apply to every resource. Otherwise pass a Ruby class of the resource.\n #\n # The third argument is an optional hash of conditions to further filter the objects.\n # For example, here the user can only update published articles.\n #\n # can :update, Article, :published => true\n #\n # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities\n \n # if user.role? :moderator\n # can :manage, Project\n # cannot :destroy, Project\n # can :manage, Comment\n # end\n # if user.role? :admin\n # can :destroy, Project\n # end\n\n=begin\n user ||= User.new # guest user \n if user.role? :super_admin\n can :manage, :all #This shows that the super_admin can manage everything\n\n elsif user.role? :product_admin\n can :manage, [Product, Asset, Issue] # Show that the product_admin can manage products and its related other things.\n\n elsif user.role? :product_team\n can :read, [Product, Asset] # manage products, assets he owns\n can :manage, Product do |product|\n product.try(:owner) == user\n end\n can :manage, Asset do |asset|\n asset.assetable.try(:owner) == user\n end\n end \n=end\n\n #puts(\".... controller_namespace: #{controller_namespace}\")\n user ||= User.new # guest user (not logged in)\n case controller_namespace\n when 'Admin'\n can :manage, :all if user.has_role? :admin\n else\n # rules for non-admin controllers here\n #can :read, :all\n # can [:update, :destroy], [Article, Comment]\n cannot :manage, :all\n can :manage, Todo\n end\n \n end",
"def create_with_scope(name); end",
"def initialize(user)\n return unless user\n\n case user.role\n when 'researcher'\n can_acces_rails_admin\n can_do_collection_scoped_actions\n can_do_member_scoped_actions\n when 'super'\n can_acces_rails_admin\n can_do_collection_scoped_actions\n can_do_member_scoped_actions\n end\n end",
"def one_object_perm privilege, obj\n Permission.new( :privilege => privilege,\n :class_name => obj.class.name,\n :is_grant => false,\n :has_grant_option => false,\n :target_owned_by_self => false,\n :target => obj\n )\n \n end",
"def initialize(user:, permission:, klass:, applies_to:, auth_configs:, participations_only:)\n @user = user\n @permission = permission\n @klass = klass\n @applies_to = applies_to\n @auth_configs = auth_configs\n @participations_only = participations_only\n end",
"def new\n requires({'role' => ['admin','faculty']})\n end",
"def initialize(user)\n unless user\n can [:new, :create, :sign_in, :sign_up, :check_username, :check_email, :check_run, :log], [Producer, User]\n cannot [:new, :destroy, :update], Event \n can [:show, :index, :search, :siete_dias_app, :patrocinados_app, :buscar_app, :lista_app, :view_app], Event \n\t cannot [:account, :edit, :destroy, :update], [Producer, User]\n can [:geo], City\n can [:view_app, :check_app], Ticket\n #can :manage, :all#comentar esto si se quiere quitar permiso admin \n else\n if user.has_role? :normal\n can :manage, User\n can [:new, :create, :sign_in, :sign_up, :check_username, :check_email, :check_run, :log], [Producer]\n cannot [:account, :edit, :destroy, :update], Producer\n cannot [:new, :destroy, :update], Event \n can [:show, :index, :search, :detail], Event \n can [:ticket_free, :result_free, :result], Transaction\n can [:view_app, :check_app, :index, :pdf, :render_pdf], Ticket\n #can :manage, :all# esto si se quiere quitar permiso admin \n end\n end\n end",
"def initialize(user,org_id)\n\n user ||= User.new # guest user (not logged in)\n\n # permission view org for any user\n can :show, Organization, :id => user.organization_id\n\n # all permission for super admin\n if user.admin? && user.organization.super_org?\n can :manage, :all\n return\n end\n\n # Allow user == admin of group manage User,Group,Log\n if user.admin? && user.organization_id == org_id\n can :manage, User\n can :manage, UserGroup\n can :index, Activity\n return\n end\n # Allow user to view, edit himself\n alias_action :read, :update, :to => :manage_self\n #can :manage_self, User, :is_deleted => false, :id => current_user.id\n\n # check groups is active\n @groups = user.user_groups.where(:is_active => true)\n @permission =[]\n #only set permissions for active groups\n @groups.each do |group|\n @permission.concat(group.permissions)\n end\n # not have duplicated permissions\n @permission.uniq!\n\n @permission.each do |p|\n case p.code\n # Add additional ability here\n when \"full_organization_management\"\n can :manage, Organization\n when \"full_group_management\"\n can :manage, UserGroup\n when \"full_user_management\"\n can :manage, User\n when \"view_log\"\n can :index, Activity\n when \"view_organization\"\n can [:index, :show], Organization\n when \"view_group\"\n can [:index, :show], UserGroup\n when \"view_user\"\n can [:index, :show], User\n\n end\n end\n end",
"def permitted_to! (privilege, options = {} )\n options = {\n :user => Authorization.current_user,\n :object => self\n }.merge(options)\n\nlogger.debug \"Checking for: #{self.class.name}\"\n\n Authorization::Engine.instance.permit!(privilege,\n {:user => options[:user],\n :object => options[:object]})\n end",
"def initialize(*args)\n @name = args[0]\n @email = args[1]\n @permissions = User.permissions_from_template\n end",
"def initialize(*args)\n @name = args[0]\n @email = args[1]\n @permissions = User.permissions_from_template\n end",
"def build(attrs = {})\n choose_right_class(attrs).new(attrs)\n end",
"def initialize(user)\n \n user ||= User.new # guest user will not be allowed in the admin section\n alias_actions\n \n if user.super_admin?\n can :manage, :all\n elsif user.admin? || user.contractor?\n #can :manage, :all\n #can :read, :all\n #can :view_users, User do\n # user.admin?\n #end\n #authorize! :view_users, @user\n #can :create_users, User do\n # user.super_admin?\n #end\n #authorize! :create_users, @user\n #can :create_orders, User\n\n if user.trial || user.unsubscribed\n unless user.unsubscribed \n can [:make], Product if user.products.count < 1\n end\n can [:read, :change], Product, contractor_id: user.id \n else\n can :manage, Product, contractor_id: user.id\n end\n can :manage, Order, contractor_id: user.id\n can :manage, Shipment, order: {contractor_id: user.id}\n can :manage, ImageGroup, product: {contractor_id: user.id}\n can :manage, Property\n can :manage, Invoice\n\n if user.has_balance?\n can :manage, Requests::Balance, user_id: user.id\n can [:read, :make, :cancel], Requests::Transaction, balance_id: user.balance.id\n can :read, Requests::Credit\n can [:read, :make, :cancel], Requests::Withdraw\n can [:read], Requests::Refund, transaksi: {balance_id: user.balance.id} \n end\n\n can :manage, :overview\n end\n end",
"def initialize_isolation(klass, context)\n pxy = klass.new\n pxy.instance_variable_set(\"@___context___\", context)\n pxy\n end",
"def initialize(user)\n user ||= User.new\n alias_action :claim, :fill, :unclaim, :insert_coins, :return_coins, :start, :remove_clothes, :to => :use\n if user.admin?\n can :manage, :all\n elsif user.new_record?\n can :read, :all\n else\n can :use, [Washer, Dryer], user: user\n can :use, [Washer, Dryer], state: \"available\"\n can :use, MachineDecorator, state: \"available\"\n can :use, MachineDecorator, user: user\n can :manage, Load, user: user\n can :manage, LoadDecorator, user: user\n can :read, :all\n end\n end",
"def initialize(user)\n \n # Country, Region, Area\n can :read, [Country, Region, Area]\n can :for_region_id, Area\n \n can :read, [GrapeVariety, Glossary, Vintage, Estate, Wine, Book]\n \n if (user.nil?)\n return\n end\n \n if user.admin?\n can :manage, :all\n end\n \n if user.moderator?\n can [:sheets, :labels, :books, :proposals], Moderation\n end\n \n #Everybody logged in can comment everything\n can :comment, :all\n \n # User\n can [:read, :search, :tastings, :follow, :unfollow], User\n can [:update, :dashboard, :stat, :books, :friends], User, :id => user.id\n \n # Glossary\n if user.moderator?\n can :manage, Glossary\n end\n \n # Estate, Wine, GrapeVariety\n can [:create, :read, :search, :taste, :tastings, :encave, :recommanded], [Estate, Wine, GrapeVariety]\n can [:add_label], Wine\n if user.moderator?\n can :manage, [Estate, Wine, GrapeVariety]\n end\n \n # Tasting\n can [:create, :read], Tasting\n can :manage, Tasting, :user => user\n \n # Bottles and Racks and Consumptions\n can [:create], [Bottle, WineRack, Consumption]\n can :manage, [Bottle, WineRack, Consumption], :user => user\n \n # Labels\n can [:create, :read], Label\n \n # Vintages\n can [:rate], Vintage\n \n # Proposals\n can [:read, :create], Proposal\n if user.moderator?\n can :close, Proposal\n end\n \n # Books\n can [:create, :read, :own], Book\n end",
"def initialize(user)\n # Define abilities for the passed in user here. For example:\n #\n user ||= User.new # guest user (not logged in)\n # if user.admin?\n # can :manage, :all\n # else\n # can :read, :all\n # end\n #\n # The first argument to `can` is the action you are giving the user\n # permission to do.\n # If you pass :manage it will apply to every action. Other common actions\n # here are :read, :create, :update and :destroy.\n #\n # The second argument is the resource the user can perform the action on.\n # If you pass :all it will apply to every resource. Otherwise pass a Ruby\n # class of the resource.\n #\n # The third argument is an optional hash of conditions to further filter the\n # objects.\n # For example, here the user can only update published articles.\n #\n # can :update, Article, :published => true\n #\n # See the wiki for details:\n # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities\n\n\n # To define a permission for a user, use the 'can' method inside\n # of this classes, initialize method. It takes the following args\n # (in order):\n # - The name of the action you are testing for as a symbol\n # - The class of an object we are testing against.\n # - A block that is used to determine whether or not a user can perform said action\n \n # If the block returns true, the user can perform the action, otherwise they can't\n\n if user.is_admin?\n can :manage, :all \n # manage means they can do everything (not just CRUD)\n end\n\n alias_action :create, :read, :edit, :update, :destroy, to: :crud\n\n can :crud, Question do |question|\n question.user == user\n end\n\n # We can also write abilities like:\n # can :crud, Question, use_id: user.id\n\n can :crud, Answer do |answer|\n answer.user == user\n end\n\n can :crud, JobPost do |job_post|\n job_post.user == user\n # check that if it matched\n end\n\n can :like, Question do |question|\n user.persisted? && user != question.user\n end\n\n can :destroy, Like do |like|\n like.user == user\n end\n end",
"def initialize(user)\n\n # guest user (not logged in) \n user ||= User.new \n\n # Alias to give proper abilities to the owner of his own course and profile\n alias_action :create, :update, :destroy, :mycourses, :myprofil, :to => :cud\n\n # Everyone can read all courses but only the owner can alter it\n can :read, Course\n can :cud, Course, :owner => user.id\n\n # Everyone can read all profiles but only the owner can alter it\n can :read, Profil\n can :cud, Profil, :user_id => user.id\n\n end",
"def initialize(user)\n\t\tuser ||= User.new # guest user\n\t\t\n\t\tif user.role? \"Super Administrator\"\n\t\t\tcan :manage, :all\n\t\t\tcannot :manage, Role, :name => \"Super Administrator\"\n\t\t\tcannot :view, User do |other_user|\n\t\t\t\tother_user.role? \"Super Administrator\" and other_user!=user\n\t\t\tend\n\t\t\tcannot :disable_users, User do |other_user|\n\t\t\t\tother_user==user\n\t\t\tend\n\t\tend\n\n\t\tif user.role? \"User Administrator\"\n\t\t\tcan :manage, User \n\t\t\tcannot :disable_users, User\n\t\t\tcan :manage, Role\n\t\t\tcannot :manage, Role, :name => \"Super Administrator\"\n\t\t\tcannot [:view], User do |other_user|\n\t\t\t\tother_user.role? \"Super Administrator\"\n\t\t\tend\n\t\tend\t\n\t\t\n\t\tif user.role? \"Province Manager\"\n\t\t\tcan :view_compliance_reports, District\n\t\t\tcan :view_indicators_reports, :all\n\t\tend\t\n\t\t\n\t\tif user.role? \"District Manager\"\n\t\t\tcan :view_compliance_reports, District, :id => user.district_ids\n\t\t\tcan :view_indicators_reports, District, :id => user.district_ids\n\t\tend\t\n\t\t\n\tend",
"def setup_perms\n perms = []\n controller_actions(perms)\n model_actions(perms)\n perms << cat_perms\n perms << api_perms\n puts 'Permissions gathering finished...'\n puts \"Permissions were loaded from #{perms.size} classes.\"\n return perms\nend",
"def setup\n login_as Factory(:user,:person => Factory(:person,:roles_mask=> 0))\n @object = Factory(:sample,:contributor => User.current_user,\n :title=> \"test1\",\n :policy => policies(:policy_for_viewable_data_file))\n end",
"def create\n super\n if current_user != nil\n p = Privilege.new\n puts current_user.class\n p.user_id = current_user.id;\n p.role_id = Role.find_by_role_name(\"user\").id;\n p.save;\n end\n end",
"def initialize user\n user ||= User.new\n if user.admin?\n can :manage, :all\n else\n can :read, :all\n end\n end",
"def initialize(user)\n #anyone can read anything, it's an encyclopedia, right?\n can :read, :all\n\n #if user isn't signed in, there are no more permissions for them\n return if user.nil?\n\n if user.dictator?\n can :manage, :all # they can do anything they want\n can :access, :rails_admin # grant access to rails_admin\n can :dashboard # ditto\n else\n #if they're not a dictator, they're a \"contributor\" and they can only\n #modify the following db objects\n can [:create, :update], [Page, Prerequisite, ConceptBundle, Question, Answer]\n end\n \n end",
"def create_authorization\n @authorization = AwsRequestAuthorization.new.tap do |authorization|\n authorization.url = url\n authorization.method = method\n authorization.query = query\n authorization.body = form_body\n authorization.region = region\n authorization.service = service\n authorization.credentials = credentials\n authorization.headers = headers\n end\n end",
"def self_owner_perm privilege, klass\n Permission.new( :privilege => privilege,\n :class_name => klass.name,\n :is_grant => false,\n :has_grant_option => false,\n :target_owned_by_self => true\n )\n end",
"def initialize(member)\n member ||= Member.new # guest user (not logged in)\n\n can :manage, :all if member.holds_position? 'Webmaster'\n can :update, Member if member.holds_position? 'Membership Officer'\n\n committee_permissions if member.committee?\n member_permissions(member) if member.persisted?\n guest_permissions\n end",
"def initialize_generate\n super\n add_accessors\n declare_guardfile\n declare_chefignore_patterns\n end",
"def build_curator(entry, options = {})\n curator_level = options[:level].nil? ? :full : options[:level]\n options.delete :level\n entry ||= FactoryGirl.create(:hierarchy_entry)\n tc = nil # scope\n if entry.is_a? TaxonConcept\n tc = entry\n entry = tc.entry\n end\n tc ||= entry.taxon_concept\n options = {\n curator_approved: true,\n curator_scope: 'scope',\n credentials: 'Curator'\n }.merge(options)\n\n # These two do \"extra work\", so I didn't want to use the merge on these (because they would be calculated even\n # if not used:\n options[:curator_verdict_by] ||= FactoryGirl.create(:user)\n options[:curator_verdict_at] ||= 48.hours.ago\n\n curator = User.gen(options)\n curator.grant_curator(curator_level)\n\n cot = ChangeableObjectType.gen_if_not_exists(:ch_object_type => 'taxon_concept')\n CuratorActivityLog.gen(:user => curator, :taxon_concept => tc, :changeable_object_type => cot,\n :target_id => tc.id)\n\n return curator\n end",
"def initialize(user)\n if user&.admin?\n admin\n elsif user&.viewer?\n viewer\n else\n # If a user was not provided or has no defined role,\n # then the user should not be able to access anything.\n cannot :manage, :all\n end\n end",
"def initialize(args)\n args.symbolize_keys!\n\n @user = args.fetch(:user)\n @admin = args.fetch(:admin)\n end",
"def initialize(user)\n return unless user.present?\n\n if user.student? or user.teacher?\n # Students and teachers can read and pin projects\n can [:read, :pinned], Project\n can :manage, Pin, user: user\n\n # Stduent and teachers can read resources\n can :read, Resource\n # Stduent and teachers can manage their own resources\n can :manage, Resource, user: user\n end\n\n if user.teacher?\n # Teachers can do anything they want\n can :manage, :all\n end\n end",
"def initialize(user)\n\n ############################## Household ##############################\n can :administrate, Household do |household|\n user.administrates?(household)\n end\n\n can :add_admin, Household do |household|\n user == household.head_admin\n end\n\n ############################## Completable ##############################\n can :accept, Completable do |todo|\n household = todo.household\n can?(:edit, todo) &&\n todo.completed? &&\n !todo.accepted? &&\n can?(:administrate, household)\n end\n\n can :complete, Completable do |todo|\n household = todo.household\n user.household == household &&\n !todo.completed? &&\n !todo.accepted?\n end\n\n can :destroy, Completable do |todo|\n household = todo.household\n user.household == household &&\n ( can?(:administrate, household) ||\n todo.creator_id == user.id && !todo.accepted?\n )\n end\n\n can :edit, Completable do |todo|\n household = todo.household\n todo.creator_id == user.id || \n can?(:administrate, household)\n end\n\n can :reorder, Completable do |todo|\n can?(:complete, todo) || can?(:uncomplete, todo)\n end\n\n can :uncomplete, Completable do |todo|\n household = todo.household\n user.household == household &&\n !todo.accepted? && \n todo.completed? &&\n (todo.completor_id == user.id || can?(:edit, todo))\n end\n\n end",
"def initialize(user)\n # Guests can not read anything\n\n cannot :read, User\n cannot :read, Course\n cannot :read, Section\n cannot :read, Lecture\n cannot :read, GoalUser\n\n # Logged in user with cascading permissions\n if user\n if user.access_normal\n can :read, Course do |course|\n user.subscribed_course?(course)\n end\n can :read, Section do |section|\n user.subscribed_section?(section)\n end\n can :read, Lecture do |lecture|\n user.subscribed_lecture?(lecture)\n end\n can :manage, GoalUser, user_id: user.id\n can :read, GoalUser, private: false\n end\n if user.access_affiliate\n can :access, :affiliate\n can :access, :course_creation\n can :read, AffiliateLink, user_id: user.id\n end\n if user.access_instructor\n end\n if user.access_admin\n can :manage, :all\n can :access, :admin\n end\n end\n end",
"def initialize(owner_class, *args, &block); end",
"def create(klass, *args, &block)\n\t\t\t#puts caller\n\t\t\tc = klass\n\t\t\t#go through rules\n\t\t\t#ask each replace? klass\n\n\t\t\tif(@rules)\n\t\t\t\t@rules.each { |r| \n\t\t\t\t\tx = r.replace?(klass)\n\t\t\t\t\tif x && r.test?(klass,*args,&block) then c = x end}\n\t\t\tend\n\n\t\t\tif(!c.is_a?(Class)) then\n\t\t\t\traise \"ClassConductor asked to init something which isn't a class: #{c}\"\n\t\t\tend\n\t\t\t\n\t\t\tobj = c.class_conductor_aliased_new(*args,&block)\n\t\t\t\n\t\t\tif(@rules)\n\t\t\t\t@rules.each {|r| if r.wrap?(obj) then obj = r.dowrap(obj) end}\n\t\t\tend\n\t\t\tobj\n\t\tend",
"def initialize(scope, ids)\n @scope = scope\n @ids = ids\n end",
"def scope\n nodename = Facter.value('hostname')\n fact_values = Facter.to_hash\n node = Puppet::Node.new(nodename, :facts => Puppet::Node::Facts.new(\"facts\", fact_values))\n compiler = Puppet::Parser::Compiler.new(node)\n # configure compiler with facts and node related data\n # Set all global variables from facts\n fact_values.each {|param, value| compiler.topscope[param] = value }\n # Configured trusted data (even if there are none)\n compiler.topscope.set_trusted(node.trusted_data)\n # Set the facts hash\n # compiler.topscope.set_facts(fact_values)\n\n # pretend that the main class (named '') has been evaluated\n # since it is otherwise not possible to resolve top scope variables\n # using '::' when rendering. (There is no harm doing this for the other actions)\n #\n compiler.topscope.class_set('', compiler.topscope)\n scope = Puppet::Parser::Scope.new(compiler)\n scope.source = Puppet::Resource::Type.new(:node, nodename)\n scope.parent = compiler.topscope\n scope\n end",
"def initialize_vars\n instantiate_shopping_classes\n\n @auth_shopping_discount_object_params = permitted_params.fetch(:discount,{})\n\n \n if !@auth_shopping_discount_object_params.blank?\n\n @auth_shopping_discount = params[:id] ? @auth_shopping_discount_class.find(params[:id]) : @auth_shopping_discount_class.new(@auth_shopping_discount_object_params)\n \n end\n\n @auth_shopping_cart_item_params = permitted_params.fetch(:cart_item,{})\n @auth_shopping_cart_item = params[:id] ? @auth_shopping_cart_item_class.find_self(params[:id],current_signed_in_resource) : @auth_shopping_cart_item_class.new(@auth_shopping_cart_item_params)\n \n end",
"def initialize(scope, id, name, type, parent, attributes_before_type_cast)\n @scope, @ID, @Name, @internal_type, @parent, @attributes_before_type_cast = scope, id, name, type, parent, attributes_before_type_cast\n @site = Site === @scope ? @scope : @scope.site\n end",
"def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[scopeUri section]\n end",
"def setup\n @scopes_from_yaml = YAML.load_file(\"#{File.dirname(__FILE__)}/../../../lib/sendgrid/helpers/permissions/scopes.yml\").freeze\n end",
"def initialize(user)\n if user\n # This ability allows admins impersonating other users to revert\n # back to their original user.\n can :unimpersonate, User\n\n # A user should only be able to update himself or herself (assuming no\n # other permissions granted below by the global role).\n can [:show, :update], User do |target_user|\n target_user == user\n end\n\n can :index, User if user.global_role.can_edit_system_configuration?\n\n process_global_role user\n process_courses user\n process_assignments user\n process_repositories user\n process_assignment_checks user\n process_media_items user\n end\n end",
"def build_isolation(klass, inst=nil)\n pxy = create_isolation_for klass\n @isolation = pxy.new\n @subject = inst\n initialize_messenger\n end",
"def class=(_arg0); end",
"def initialize\n @canadian_methods = {}\n\n if defined?(Runtime)\n can_class = Runtime[\"Class\"]\n else\n can_class = nil\n end\n\n super(can_class)\n end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def initialize(user)\n \tif user.admin == true # conditions if registrar is an admin\n can :manage, :all\n\t\t cannot :create, Deadline\n else\n can :read, Registrar\n\t\t can :read, Student\n can :update, Registrar, :id => user.id\n can :destroy, Registrar, :id => user.id\n can :read, Student, :university_id => user.university_id\n can :read, Application, :university_id => user.university_id\n can :read, University\n can :approve, Application\n can :decline, Application\n\t\t can :read, Schedule\n\t\t can :create, Schedule\n\t\t can :update, Schedule, :registrar_id => user.id\n\t\t can :destroy, Schedule, :registrar_id => user.id\n end\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n self.resource.role = params[:r] if hash.blank?\n self.resource.build_profile if self.resource.profile.blank?\n end",
"def init_rac_data\n \n if connected_user and (self.permission_owner.nil? or self.permission_owner.empty?)\n self.permission_owner = connected_user.username\n end\n\n if connected_user and connected_user.usergroups.length > 0 and (self.permission_group.nil? or self.permission_group.empty?)\n self.permission_group = connected_user.usergroups.first.group \n end\n\n if self.permission_modifier_owner.nil? \n self.permission_modifier_owner = 6 \n end\n \n if self.permission_modifier_group.nil?\n self.permission_modifier_group = 2 \n end\n \n if self.permission_modifier_all.nil?\n self.permission_modifier_all = 0\n end \n\n end",
"def initialize(options)\n self.user_id = options[:user_id]\n self.privileges = options[:privileges]\n raise TypeError.new(\"user must be given. got #{options.inspect}\") unless self.user_id\n end",
"def authorize \n self.make 'authorization' \n end",
"def initialize\r\n init_public_members\r\n init_private_members\r\n end",
"def build\n klass = create_class(@class_name, @options)\n klass.new\n end",
"def initialize(user)\n\n if user.present?\n\n # Cache repeated queries\n user_id = user.id\n admin = user.admin?\n supervisor = user.supervisor?\n reviewer = user.reviewer?\n\n can(:manage, :all) if admin\n\n # Address\n can [:create, :show], Address\n\n # Contact\n can :create, Contact\n\n # Delivery\n can [:create, :show, :update], Delivery\n\n # Item\n can [:index, :show, :create, :update], Item, offer: { created_by_id: user_id }\n can [:index, :show, :create, :update], Item if reviewer or supervisor\n can :destroy, Item, offer: { created_by_id: user_id }, state: 'draft'\n can :destroy, Item, state: 'draft' if reviewer\n can :destroy, Item if supervisor\n\n # Image (same as item permissions)\n can [:index, :show, :create, :update], Image, parent: { offer: { created_by_id: user_id } }\n can [:index, :show, :create, :update], Image if reviewer or supervisor\n can :destroy, Image, parent: { offer: { created_by_id: user_id }, state: 'draft' }\n can :destroy, Image, parent: { state: 'draft' } if reviewer\n can :destroy, Image if supervisor\n\n # Message (recipient and sender and admins, not user if private is true)\n can [:index, :show, :create, :update, :destroy], Message if supervisor\n can [:index, :show, :create], Message if reviewer\n can [:index, :show, :create], Message, sender_id: user_id, is_private: false\n can [:index, :show, :create], Message, recipient_id: user_id, is_private: false\n can [:mark_read], Message, id: user.subscriptions.pluck(:message_id)\n\n # Offer\n can :create, Offer\n can [:index, :show, :update], Offer, created_by_id: user_id\n can [:index, :show, :update], Offer if reviewer or supervisor\n can :destroy, Offer, created_by_id: user_id, state: ['draft', 'submitted']\n can :destroy, Offer, state: 'draft' if reviewer\n can :destroy, Offer if supervisor\n can :review, Offer if reviewer or supervisor\n\n # Package (same as item permissions)\n can [:index, :show, :create, :update], Package, item: { offer: { created_by_id: user_id } }\n can [:index, :show, :create, :update], Package if reviewer or supervisor\n can :destroy, Package, item: { offer: { created_by_id: user_id }, state: 'draft' }\n can :destroy, Package, item: { state: 'draft' } if reviewer\n can :destroy, Package if supervisor\n\n # Schedule\n can :create, Schedule\n\n # User\n can [:show, :update], User, id: user_id\n can [:index, :show, :update], User if reviewer or supervisor\n\n # Taxonomies\n can [:index, :show], DonorCondition\n can [:index, :show], ItemType\n can [:index, :show], RejectionReason\n\n end\n\n # Anonymous and all users\n can [:index, :show], District\n can [:index, :show], Territory\n can [:index, :show, :availableTimeSlots], Schedule\n end",
"def build_resource(hash = nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n auth = session['devise.google_data']\n self.resource = User.fill_from_omniauth(resource, auth) if auth\n end",
"def initialize(user)\n user ||= User.new # guest user\n if user.role? :admin\n can :manage, :all\n elsif user.role? :regular_user\n can :manage, [Project, ProjectPhase, Deliverable, EffortLog]\n cannot :read, User\n can :index, [Lifecycle]\n can :read, [Lifecycle]\n cannot :create, [Lifecycle]\n cannot :update, [Lifecycle]\n cannot :destroy, [Lifecycle]\n cannot :manage, LifecyclePhase\n end\n end",
"def initialize(subject, object, rights, salt=nil)\n @object = object\n @right = rights\n \n # Calling a class method instead of an instance method. The actual\n # kernel has no involvement in the \n @token = Capability.sign(subject, object, rights, salt)\n end",
"def initialize(user)\n\n # We instantiate the user to User.new to avoid having user be nil if the user is not signed in - so methods can be called on it. We assume here that 'user' will be User.new if the user is not signed in.\n user ||= User.new\n\n # Gives superpowers to admin user by having the ability to manage all actions on all models\n # If a field is a boolean, Rails automatically creates a helper method with a question mark (alternatively, you can user user.admin, which references the value - true or false)\n can :manage, :all if user.admin?\n\n # Define alias_action instead of using :manage\n alias_action :create, :read, :update, :destroy, :to => :crud\n\n # Defining the ability to :manage (do anything) with a question\n can :crud, Question do |q|\n # This block returns true or false. This determines if the user is allowed to manage a question or not\n # user.persisted? ensures the user is actually logged in\n q.user == user && user.persisted?\n end\n\n can :crud, Answer do |a|\n # Both the author of the question and the author of the answer can CRUD an answer\n (a.question.user == user || a.user == user) && user.persisted?\n end\n\n can :like, Question do |q|\n q.user != user\n end\n\n can :destroy, Like do |l|\n l.user == user\n end\n\n # It is possible to define any action, i.e. can :edit / can :destroy ...etc\n\n # Define abilities for the passed in user here. For example:\n #\n # user ||= User.new # guest user (not logged in)\n # if user.admin?\n # can :manage, :all\n # else\n # can :read, :all\n # end\n #\n # The first argument to `can` is the action you are giving the user\n # permission to do.\n # If you pass :manage it will apply to every action. Other common actions\n # here are :read, :create, :update and :destroy.\n #\n # The second argument is the resource the user can perform the action on.\n # If you pass :all it will apply to every resource. Otherwise pass a Ruby\n # class of the resource.\n #\n # The third argument is an optional hash of conditions to further filter the\n # objects.\n # For example, here the user can only update published articles.\n #\n # can :update, Article, :published => true\n #\n # See the wiki for details:\n # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities\n end",
"def initialize(user)\n user ||= User.new\n\n if user.role?(:admin)\n can :manage, :all\n elsif user.role?(:moderator)\n can :create, Project\n can :update, Project do |project|\n project.ongoing?\n end\n can :read, Project\n elsif user.role?(:user)\n can :read, Project, ongoing: true\n end\n end",
"def new_scope(names)\n values = names.map { |n| self[n] }\n self.class.new(names, values + extras, self)\n end",
"def initialize(user)\n user ||= User.new # guest user (not logged in)\n\n if user.role? :admin\n can :manage, :all\n else\n if user.role? :certifier\n can :certify, User\n end\n\n if user.role? :voter\n can :create, Vote\n end\n\n can :read, Vote do |vote|\n user.id == vote.registration.user_id\n end\n end\n\n # default is can't do anything special for now\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n attrs = session[\"devise.user_attributes\"]\n self.resource.first_name = attrs[\"first_name\"]\n self.resource.last_name = attrs[\"last_name\"]\n self.resource.picture = attrs[\"picture\"]\n end",
"def initialize(params)\n raise 'No companyid given' unless (params[:companyid] or params[:company])\n raise 'No name given' unless params[:name]\n\n super(params)\n\n # COPY role_ (roleid, companyid, classnameid, classpk, name, description, type_) FROM stdin;\n # +10151\t10109\t0\t0\tRegular role\tThis role is a test\t1\n\n self.classnameid ||= 0\n self.classpk ||= 0\n self.description ||= ''\n # Type: 1 = regular, 2 = community, 3 = organization\n self.type_ ||= 1\n\n self.save\n\n # Resource with code scope 1 is primkey'd to company.\n # Resource with code scope 4 is primkey'd to this role.\n\n # These are created regardless of what type_ is.\n\n # COPY resourcecode (codeid, companyid, name, scope) FROM stdin;\n # +29\t10109\tcom.liferay.portal.model.Role\t1\n # +30\t10109\tcom.liferay.portal.model.Role\t4\n\n [1,4].each do |scope|\n rc = self.resource_code(scope)\n unless rc\n ResourceCode.create(\n Company.primary_key => self.companyid,\n :name => self.liferay_class,\n :scope => scope\n )\n end\n end\n\n # COPY resource_ (resourceid, codeid, primkey) FROM stdin;\n # +33\t29\t10109\n # +34\t30\t10151\n\n self.get_resource(:scope => 1)\n r = self.get_resource(:scope => 4)\n\n # Permissions (given to administrators)\n\n # COPY permission_ (permissionid, companyid, actionid, resourceid) FROM stdin;\n # +70 10109 ASSIGN_MEMBERS 34\n # +71 10109 DEFINE_PERMISSIONS 34\n # +72 10109 DELETE 34\n # +73 10109 MANAGE_ANNOUNCEMENTS 34\n # +74 10109 PERMISSIONS 34\n # +75 10109 UPDATE 34\n # +76 10109 VIEW 34\n\n # COPY users_permissions (userid, permissionid) FROM stdin;\n # +10129\t70\n # +10129\t71\n # +10129\t72\n # +10129\t73\n # +10129\t74\n # +10129\t75\n # +10129\t76\n\n self.class.actions.each do |actionid|\n p = Permission.get(\n :companyid => self.companyid,\n :actionid => actionid,\n :resourceid => r.id\n )\n self.company.administrators.each do |user|\n user.permissions << p\n end\n end\n end",
"def new_object\n @object = scope.new params[object_name.to_sym]\n set_instance\n end",
"def create_curator\n curator = User.gen(:username => 'curator_for_tc', :password => 'password', :credentials => 'Curator', :curator_scope => 'very scoped')\n curator.grant_curator\n curator.save!\n return curator\n end",
"def initialize(params, current_user = nil)\n @params = params.to_h.with_indifferent_access\n @provider = @params[:provider]\n @user = current_user\n @authorization = nil\n end",
"def build_resource\n get_resource_ivar || begin\n set_resource_ivar class_name.new\n end\n end",
"def initialize(user)\n\n # The first argument to `can` is the action you are giving the user\n # permission to do.\n # If you pass :manage it will apply to every action. Other common actions\n # here are :read, :create, :update and :destroy.\n #\n # The second argument is the resource the user can perform the action on.\n # If you pass :all it will apply to every resource. Otherwise pass a Ruby\n # class of the resource.\n #\n # The third argument is an optional hash of conditions to further filter the\n # objects.\n # For example, here the user can only update published articles.\n #\n # can :update, Article, :published => true\n #\n # See the wiki for details:\n # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities\n\n user ||= User.new\n\n # we don't do role inheritance b/c I have a sneaking feeling we\n # will want more fine-grained control for our roles as the system\n # grows.\n\n\n if ['contributor', 'editor', 'super_editor', 'admin'].member? user.role\n can [:edit, :update, :show], :all, :created_by_id => user.id\n can :create, DericciLink\n\n can :destroy, [Comment, Reply], :created_by_id => user.id\n cannot :manage, Page\n\n can :link, :all\n can :unlink, :all, :created_by_id => user.id\n can :history, :all\n\n can [:index, :new], DericciGame\n can :index, [Entry, Source, Manuscript, Comment]\n\n can :manage, PrivateMessage, :created_by_id => user.id\n can :manage, PrivateMessage do |pm|\n pm.users.include? user\n end\n can :manage, Rating\n cannot [:import, :upload], Entry\n end\n\n if ['editor', 'super_editor', 'admin'].member? user.role\n can :unlink, :all\n can :edit, Manuscript\n can :manage, DericciRecord\n\n cannot :deprecate, :all\n can :manage, Name\n cannot :review, Name\n # this needs to be RE-Established, since it has been overriden by line 51\n can :edit, :all, :created_by_id => user.id\n cannot :manage, Page\n end\n\n if ['super_editor'].member? user.role\n # allow super-editors to edit legacy records\n can [:edit, :update, :verify, :deprecate], Entry, :unverified_legacy_record => true\n can [:edit, :update], Source, :legacy => true\n can :manage, Place\n can :manage, Language\n end\n\n if ['admin'].member? user.role\n can :manage, :all\n can :update_type, Source\n end\n\n can [:edit, :update], Entry, contributors: { :id => user.id }\n cannot :manage, [Group]\n can [:edit, :update, :destroy], Group, admin: { :id => user.id }\n can [:destroy], Entry, {created_by_id: user.id, draft: true}\n\n can :show, Entry\n cannot :show, Entry do |entry|\n (entry.created_by != user && !entry.contributors.include?(user)) && entry.draft\n end\n end",
"def initialize(parent, full_name, priority, source_root, middleware_stack, middleware_lookup,\n tool_class = nil)\n @parent = parent\n @settings = Settings.new(parent: parent&.settings)\n @full_name = full_name.dup.freeze\n @priority = priority\n @source_root = source_root\n @built_middleware = middleware_stack.build(middleware_lookup)\n @subtool_middleware_stack = middleware_stack.dup\n\n @acceptors = {}\n @mixins = {}\n @templates = {}\n @completions = {}\n\n @precreated_class = tool_class\n\n reset_definition\n end",
"def initialize(usuario = nil)\n Sivel2Gen::Ability.initialize_sivel2_gen(self, usuario)\n initialize_cor1440_gen(usuario)\n if !usuario || !usuario.fechadeshabilitacion.nil?\n return\n end\n cannot :pestanadesaparicion, Sivel2Gen::Caso\n case usuario.rol\n when Ability::ROLOPERADOR\n can [:index,:read], Nodo\n can [:index,:read], Zrc\n can [:index,:read], Observacion\n when Ability::ROLADMIN, Ability::ROLDIR\n can :manage, Nodo\n can :manage, Zrc\n can :manage, Observacion\n end\n\n end",
"def initialize(user)\n if user.role == 'SuperAdmin'\n can :manage, :all\n elsif user.role == 'ChartedAccountant'\n can [:read, :create, :update], :all\n elsif user.role == 'Party'\n can [:read, :create, :update], :all\n end\n end",
"def initialize(name, breed, owner_name)\n @name = name # this returns name of the dog\n @breed = breed # returns the breed classification\n @owner = Owner.new(owner_name, self) # returns Owner when #class is called on #owner \n end",
"def set_scope_class\n klass = self.class::Scope\n klass.send(:include, ScopeMethods)\n @scope_class = klass.new(@scope, @search_attributes)\n end",
"def initialize(args)\n scope = args.delete(:scope)&.to_sym\n org_id = args.delete(:org_id)\n\n valid_value_check(:scope, scope, VALID_SCOPES)\n\n if scope == :user\n @uri_prefix = '/user'\n else\n id_check(:org_id, org_id)\n\n @uri_prefix = \"/organizations/#{org_id}\"\n end\n\n super(**args)\n end",
"def construct\n end",
"def initialize(user)\n can :create, Project\n can :manage, Project do |project|\n project.users.include?(user)\n end\n\n can :manage, Suggestion do |suggestion|\n suggestion.project.users.include?(user)\n end\n\n can :manage, FieldDefinition do |field|\n field.project.users.include?(user)\n end\n end",
"def initialize(current_user)\n # Define abilities for the passed in user here.\n current_user ||= User.new # guest user (not logged in)\n\n # admin can access everything\n if current_user.admin?\n can :manage, :all\n else\n # index, new, and create are open to everyone\n can [:index, :new, :create], User\n#\n # allow if current_user matches the user_record being viewed\n can [:show, :edit, :update], User do |user_record|\n current_user.id == user_record.id\n end\n\n # allow if the location belongs to the current_user\n can :user_location, Location do |location|\n current_user.locations.include?(location)\n end\n end\n end"
] | [
"0.6345937",
"0.5929545",
"0.5720007",
"0.5630158",
"0.5619377",
"0.55986136",
"0.55954444",
"0.5595042",
"0.5594009",
"0.5542252",
"0.554117",
"0.5527415",
"0.55245847",
"0.54903954",
"0.54378486",
"0.5411845",
"0.53952074",
"0.5372943",
"0.5342187",
"0.5330649",
"0.53270376",
"0.5322653",
"0.5320805",
"0.53109616",
"0.52724725",
"0.52695495",
"0.52663225",
"0.52562934",
"0.5251408",
"0.52482164",
"0.52482164",
"0.5246738",
"0.5243123",
"0.52364117",
"0.52098477",
"0.52048105",
"0.5204448",
"0.5200191",
"0.5199176",
"0.51890695",
"0.518744",
"0.5181189",
"0.5175895",
"0.5172884",
"0.51708025",
"0.5170095",
"0.5166775",
"0.5144306",
"0.5132324",
"0.5128976",
"0.51232076",
"0.5121008",
"0.51205254",
"0.511071",
"0.5091797",
"0.5084155",
"0.5082904",
"0.50794137",
"0.5064059",
"0.5062391",
"0.5061548",
"0.5058432",
"0.5057741",
"0.505322",
"0.5050805",
"0.50488317",
"0.50470924",
"0.50470924",
"0.50470924",
"0.5044945",
"0.5042283",
"0.50416094",
"0.5041462",
"0.50386757",
"0.50297964",
"0.5023027",
"0.50216943",
"0.5011971",
"0.5005327",
"0.49961385",
"0.49933296",
"0.4989574",
"0.49893782",
"0.49868792",
"0.49854335",
"0.49793968",
"0.49770766",
"0.497659",
"0.49645346",
"0.49632788",
"0.49630472",
"0.49578547",
"0.49577382",
"0.49541616",
"0.49512464",
"0.49500877",
"0.49492145",
"0.49475545",
"0.49445605",
"0.4941096"
] | 0.603767 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_student
@student = Student.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def call\n setup_context\n super\n end"
] | [
"0.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
"0.5312988",
"0.529798",
"0.52968603",
"0.52962637",
"0.52577317",
"0.5244704",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5233461",
"0.52322435",
"0.5227552",
"0.52224743",
"0.5217851",
"0.521241",
"0.52069896",
"0.5206555",
"0.5176617",
"0.51738507",
"0.51725876",
"0.51660734",
"0.51605034",
"0.51571786",
"0.5152762",
"0.5152164",
"0.5151477",
"0.5145819",
"0.51408994",
"0.5134412",
"0.5114031",
"0.5113695",
"0.5113695",
"0.5108603",
"0.5107358",
"0.5090405",
"0.50889385",
"0.50817686",
"0.5081617",
"0.50658226",
"0.50551206",
"0.5051746",
"0.5049091",
"0.5049091",
"0.5034681",
"0.5024972",
"0.5021291",
"0.5016024",
"0.50134826",
"0.50008893",
"0.50000244",
"0.4999155",
"0.49907947",
"0.49907947",
"0.49853387",
"0.49796683",
"0.4979596",
"0.49778128",
"0.49673793",
"0.49662578",
"0.49587822",
"0.4956063",
"0.49550167",
"0.49523485",
"0.4951614",
"0.49452996",
"0.49442068",
"0.49336892",
"0.49306205",
"0.49264124",
"0.49259305",
"0.4925823",
"0.49229056",
"0.4918999",
"0.49171805",
"0.49167436",
"0.4916559",
"0.49153692",
"0.49148256"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def student_params
params.require(:student).permit(:name, :teacher_id, user_attributes: [:id, :email, :password, :password_confirmation, :student_id] )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
Enables the WebAudio domain and starts sending context lifetime events. | def enable
{
method: "WebAudio.enable"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable\n\t\t\t@last_request = nil\n\t\t\tBase.instance.add_observer(self)\n\t\tend",
"def active_support_timers_start(env); end",
"def main_audio ; end",
"def enable_audio(on: true)\n\n # Set the flag\n @audio_handler.audio = on\n\n # Update the icon\n @audio_sprite.path =\n if @audio_handler.audio\n 'vertices/sprites/audioOn.png'\n else\n 'vertices/sprites/audioOff.png'\n end\n\n end",
"def disable\n {\n method: \"WebAudio.disable\"\n }\n end",
"def enable!\n tracers.each(&:enable!)\n end",
"def startup\r\n\t\t\tenable_gc_optimizations\r\n\t\t\tregister_signal_handlers\r\n\t end",
"def define_listening\n end",
"def start\n backend.start\n end",
"def enable\n @queue << \"enable\"\n end",
"def enable_subscription(name)\n typed_exec(\"ALTER SUBSCRIPTION #{connection.quote_ident(name)} ENABLE\")\n end",
"def start_throttling\n @processed = false\n @timer = EventMachine::PeriodicTimer.new(1.0 / @qps) do\n @processed = false\n end\n end",
"def audio; end",
"def subscribed; end",
"def enable!; end",
"def enable\n end",
"def play\n Audio::Out.add @cpg\n @is_playing = true\n #Audio::Out.add @actuator\n end",
"def enable!\n `tc qdisc add dev lo root netem delay #{delay}ms`\n end",
"def enable\n {\n method: \"Performance.enable\"\n }\n end",
"def start\n find_or_create_active_call\n response = Twilio::TwiML::Response.new do |r|\n r.Pause\n ready_for_connection?(r)\n r.Say('Please try again later.')\n play_audio(r, 'goodbye')\n end\n\n render_twiml response\n end",
"def enable\n end",
"def e\n @queue << \"enable\"\n end",
"def subscribe\n self.subscribed = true\n end",
"def setup_audio!\n self.gun_sound = AudioNode.new($asset_manager, \"Sound/Effects/Gun.wav\", false)\n gun_sound.positional = false\n gun_sound.looping = false\n gun_sound.volume = 3\n root_node.attach_child(gun_sound)\n\n self.ambient_noise = AudioNode.new(asset_manager, \"assets/sound/lost.ogg\", false)\n ambient_noise.looping = true\n ambient_noise.positional = true\n ambient_noise.local_translation = Vector3f::ZERO.clone\n ambient_noise.volume = 2\n root_node.attach_child(ambient_noise)\n ambient_noise.play\n end",
"def subscribed\n \t#stream_from 'demo_chan'\n end",
"def receive_ehlo_domain domain\n true\n end",
"def receive_ehlo_domain domain\n true\n end",
"def receive_ehlo_domain domain\n true\n end",
"def send_events; end",
"def setup\n @running_count = 0\n @context.notifications.on(\"graph.start\", self) { start }\n @context.notifications.on(\"graph.stop\", self) { stop }\n\n start if @context.running?\n end",
"def enableSentences _args\n \"enableSentences _args;\" \n end",
"def enable\n @enabled = true\n end",
"def ensure_speech!\n fail \"Must have active connection\" unless @speech\n end",
"def start\n # Eventmachine run\n EM.run do\n # set what to do on message from websocket\n on_message\n\n # set what to do on close of websocket connection\n on_close\n end\n end",
"def enable!\n @mutex.synchronize do\n @advised.each { | x | x.enable! }\n end\n self\n end",
"def starttls\n raise NotImplementedError\n end",
"def starttls?; end",
"def kiosk_mode_require_mono_audio=(value)\n @kiosk_mode_require_mono_audio = value\n end",
"def _active_start!\n self\n end",
"def subscribe(prefix = EVERYTHING)\n ffi_delegate.set_subscribe(prefix)\n end",
"def setup\n alert_user\n\n # Reset the session counts to zero.\n reset_session_counts\n\n return if not payload_instance\n return if not handler_enabled?\n\n # Configure the payload handler\n payload_instance.exploit_config = {\n 'active_timeout' => self.active_timeout\n }\n\n # Set up the payload handlers\n payload_instance.setup_handler\n\n # Defer starting bind handlers until after exploit completion\n return if handler_bind?\n\n # Start the payload handler\n payload_instance.start_handler\n end",
"def on_message_data_start_event(ctx) end",
"def on_start\n end",
"def start\n subscribe &Proc.new { |message| listener(message) }\n end",
"def add_audio\n update_attribute(:audio, true)\n end",
"def custom_start(rate = nil)\n settings = {}\n if rate == nil\n settings[:rate] = collect_rate_setting\n else\n settings[:rate] = rate\n end\n settings[:voice] = collect_voice_setting\n settings\n end",
"def start\n \n register_signal_handlers\n log.info(\"Registered event handlers...\")\n \n EM.synchrony do\n do_work\n end\n \n end",
"def on_create\n RMQ.debugging = true\n RMQ.caching_enabled = true\n\n mp \"BluePotionApplication on_create\", debugging_only: true\n\n VW::SessionClient.debug = true # Debug network calls\n end",
"def listen\n em_run do\n end\n end",
"def setup(options = {})\n setup_events(options)\n setup_broadcast\n end",
"def start\n $0 = \"vines: #{@id}\"\n\n @connection.connect\n @publisher.broadcast(:online)\n @subscriber.subscribe\n\n EM.add_periodic_timer(1) { heartbeat }\n\n at_exit do\n @publisher.broadcast(:offline)\n @sessions.delete_all(@id)\n end\n end",
"def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end",
"def start\n EM.run do\n @__conn = EventMachine::WebSocketClient.connect(@__socket_url)\n\n @__callbacks[:connection_established] &&\n @__conn.callback do\n instance_exec(&@__callbacks[:connection_established])\n end\n\n @__callbacks[:error] &&\n @__conn.errback do |e|\n instance_exec(e, &@__callbacks[:error])\n end\n\n @__conn.stream do |msg|\n @__conn.close_connection if msg.data == \"done\"\n\n event = JSON.parse(msg.data)[1]\n case event['type']\n when 'paired'\n @__event_pool[:paired] = event\n\n when 'connected'\n break unless @__callbacks[:connected]\n instance_exec(&@__callbacks[:connected])\n @__event_pool[:connected] = event\n\n when 'arm_synced'\n @__event_pool[:arm_synced] = event\n\n when 'unlocked'\n puts(\"unlocked!\")\n @__event_pool[:unlocked] ||= false\n @__event_pool[:unlocked] = true\n\n when 'pose'\n\n break unless @__callbacks[:pose]\n pose = event['pose']\n puts \"this is pose: \" + pose\n #instance_exec(@__event_pool[:pose][:pose], :off, &@__callbacks[:pose]) if @__event_pool[:pose][:pose]\n instance_exec(pose, :on, &@__callbacks[:pose])\n @__event_pool[:pose] = event\n\n when 'orientation'\n break unless @__callbacks[:periodic]\n e = OpenStruct.new({\n :accel => OpenStruct.new({\n :x => event['accelerometer'][0],\n :y => event['accelerometer'][1],\n :z => event['accelerometer'][2]\n }),\n :gyro => OpenStruct.new({\n :x => event['gyroscope'][0],\n :y => event['gyroscope'][1],\n :z => event['gyroscope'][2]\n }),\n :orientation => OpenStruct.new(event['orientation'])\n })\n @__event_pool[:orientation] = e\n instance_exec(e, &@__callbacks[:periodic])\n\n end\n end\n\n @__conn.disconnect do\n EM::stop_event_loop\n end\n end\n end",
"def main_audio\r\n super\r\n # Stop BGM and BGS\r\n $game_system.bgm_play(nil)\r\n $game_system.bgs_play(nil)\r\n # Play game over ME\r\n $game_system.me_play($data_system.gameover_me)\r\n end",
"def start_calls\n @running = true\n ahn_log.hammer.debug 'Calls started...'\n end",
"def setup\n EventBus.subscribe(Events::DOWN_ARE_NODES_ALIVE, self, :on_alive_request)\n info \"Startup\"\n Thread.new {\n OmfCommon.init(CONFIG[:env], communication: {url: CONFIG[:xmpp_url]}) {\n OmfCommon.comm.on_connected { |comm|\n info \"WiseOMF >> Connected to XMPP server\"\n # Test end???\n comm.on_interrupted {\n puts \"WiseOMF >> Interrupt!\"\n ResourceProxyManager.instance.handle_interrupt\n }\n }\n }\n }.run\n sleep(5)\n\n OmfRc::ResourceFactory.load_additional_resource_proxies('../lib')\n ResourceProxyManager.instance\n # Do nothing\n end",
"def enable!\n @active = true\n change_status(:wait)\n end",
"def initialize\n\n # On startup, assume music and audio are enabled, and nothing is playing\n @music = true\n @audio = true\n @track_queued = false\n @music_playing = false\n @active_track = ''\n\n end",
"def enabled_ad_hoc_hooks(hook_context); end",
"def send_presampled\n @libhoney.send_event(self)\n self\n end",
"def subscribe\n @player.subscribe(self)\n end",
"def setup\n @client.clear(self.signals_redis_key)\n @worker_pool.start\n end",
"def enable!\n self.enabled = true\n end",
"def initialize(env = :development, &block)\n @active_environment = env\n\n Loquacious.env_config = true\n Loquacious.env_prefix = \"AHN\"\n\n Loquacious::Configuration.for :core do\n root nil, :desc => \"Adhearsion application root folder\"\n\n lib \"lib\", :desc => <<-__\n Folder to include the own libraries to be used. Adhearsion loads any ruby file\n located into this folder during the bootstrap process. Set to nil if you do not\n want these files to be loaded. This folder is relative to the application root folder.\n __\n\n process_name \"ahn\", :desc => <<-__\n Adhearsion process name, useful to make it easier to find in the process list\n Pro tip: set this to your application's name and you can do \"killall myapp\"\n Does not work under JRuby.\n __\n\n event_threads 5, transform: Proc.new { |v| Adhearsion::Configuration.validate_number v }, desc: <<-__\n The number of threads to include in the event worker pool.\"\n __\n\n desc \"Log configuration\"\n logging {\n level :info, :transform => Proc.new { |v| v.to_sym }, :desc => <<-__\n Supported levels (in increasing severity) -- :trace < :debug < :info < :warn < :error < :fatal\n __\n formatter nil, :desc => <<-__\n A log formatter to apply to the stream. If nil, the Adhearsion default formatter will be used.\n __\n }\n\n type :xmpp , :transform => Proc.new { |v| v.to_sym }, :desc => <<-__\n Platform used to connect to the Telephony provider. Currently supported values:\n - :xmpp\n - :asterisk\n __\n username \"usera@127.0.0.1\", :desc => \"Authentication credentials\"\n password \"1\" , :desc => \"Authentication credentials\"\n host nil , :desc => \"Host to connect to (where rayo/asterisk is located)\"\n port Proc.new { Adhearsion::Configuration.default_port_for_platform type }, :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"Port used to connect\"\n certs_directory nil , :desc => \"Directory containing certificates for securing the connection.\"\n root_domain nil , :desc => \"The root domain at which to address the server\"\n connection_timeout 60 , :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"The amount of time to wait for a connection\"\n reconnect_attempts 1.0/0.0 , :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"The number of times to (re)attempt connection to the server\"\n reconnect_timer 5 , :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"Delay between connection attempts\"\n\n after_hangup_lifetime 1, :transform => Proc.new { |v| v.to_i }, :desc => <<-__\n Lifetime of a call after it has hung up. Should be set to the minimum functional value for your application. Call actors (threads) living after hangup consume more system resources and reduce the concurrent call capacity of your application.\n __\n\n desc \"Media configuration\"\n media {\n default_voice nil, desc: 'The default voice used for all output. Set nil to use platform default.'\n default_renderer nil, desc: 'The default renderer used for all output. Set nil to use platform default.'\n\n min_confidence 0.5, desc: 'The default minimum confidence level used for all recognizer invocations.', transform: Proc.new { |v| v.to_f }\n timeout 5, desc: 'The default timeout (in seconds) used for all recognizer invocations.', transform: Proc.new { |v| v.to_i }\n inter_digit_timeout 2, desc: 'The timeout used between DTMF digits and to terminate partial invocations', transform: Proc.new { |v| v.to_i }\n recognizer nil, desc: 'The default recognizer used for all input. Set nil to use platform default.'\n input_language 'en-US', desc: 'The default language set on generated grammars. Set nil to use platform default.'\n }\n\n desc \"Internationalisation\"\n i18n {\n locale_path [\"config/locales\"], transform: Proc.new { |v| v.split ':' }, desc: <<-__\n List of directories from which to load locale data, colon-delimited\n __\n audio_path \"app/assets/audio\", desc: <<-__\n Base path from which audio files can be found. May be a filesystem path or some other URL (like HTTP)\n __\n fallback true, desc: <<-__\n Whether to include text for translations that provide both text & audio. True or false.\n __\n }\n\n desc \"HTTP server\"\n http do\n enable true, desc: \"Enable or disable the HTTP server\"\n host \"0.0.0.0\", desc: \"IP to bind the HTTP listener to\"\n port \"8080\", desc: \"Port to bind the HTTP listener to\"\n rackup 'config.ru', desc: 'Path to Rack configuration file (relative to Adhearsion application root)'\n end\n end\n\n Loquacious::Configuration.for :core, &block if block_given?\n\n self\n end",
"def subscribe!\n # TODO: Implement\n end",
"def audiences=(value)\n @audiences = value\n end",
"def start\n super\n log.trace \"splunk-http-eventcollector(start) called\"\n\n @http = Net::HTTP::Persistent.new('fluent-plugin-splunk-http-eventcollector', @proxy)\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify\n @http.override_headers['Content-Type'] = 'application/json'\n @http.override_headers['User-Agent'] = 'fluent-plugin-splunk-http-eventcollector/0.0.1'\n @http.override_headers['Authorization'] = \"Splunk #{@token}\"\n\n log.trace \"initialized for splunk-http-eventcollector\"\n end",
"def start\n\n\t\tdebug \"Starting domain %s\" % [resource[:name]]\n\n\t\tif exists? && status == \"stopped\"\n\t\t\tdom.create # Start the domain\n\t\telse\n\t\t\tinstall\n\t\tend\n\n\tend",
"def startPlayback\n end",
"def at_cycle_begin(**options, &block)\n add_propagation_handler(**options.merge(type: :external_events), &block)\n end",
"def start\n raise NotImplementedError, 'Subclasses of Listener should implement #start'\n end",
"def start\n raise NotImplementedError, 'Subclasses of Listener should implement #start'\n end",
"def start\n @thread = Thread.new do\n EM::WebSocket.start(ws_options) do |ws|\n ws.onopen do |handshake|\n log \"onopen: #{handshake.headers}\"\n @clients << ws\n end\n\n ws.onclose do |event|\n log \"closed: #{event}\"\n @clients.delete ws\n end\n\n ws.onmessage do |msg|\n log \"received: #{msg}\"\n end\n end\n end\n end",
"def audio\n \t@playlist = Playlist.last\n send_glued_audio('list', :playlist => @playlist)\n end",
"def start\n return if active?\n begin\n @subject.start\n rescue Errno::ECONNRESET\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed. network error to: #{connection_params}\"\n rescue Bunny::TCPConnectionFailed\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed to: #{connection_params}\"\n rescue Bunny::PossibleAuthenticationFailureError\n raise EventSource::Protocols::Amqp::Error::AuthenticationError,\n \"Likely athentication failure for account: #{@subject.user}\"\n rescue StandardError\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Unable to connect to: #{connection_params}\"\n else\n sleep 1.0\n logger.info \"Connection #{connection_uri} started.\" if active?\n active?\n end\n end",
"def keep_alive=(enable); end",
"def start\n response = Twilio::TwiML::Response.new do |r|\n r.Pause\n play_audio(r, 'intro_message')\n ready_for_connection?(r)\n close_call(r)\n end\n\n render_twiml response\n end",
"def kiosk_mode_require_mono_audio\n return @kiosk_mode_require_mono_audio\n end",
"def enable\n\n @enabled = true\n\n return self\n\n end",
"def starttls_always?; end",
"def run\n capture_signals\n load_config\n\n EM.synchrony do\n connect\n start_throttle\n end\n end",
"def start\n callback = EM.Callback do\n log \"Adding a #{self.class} at #{@host}:#{@port}...\"\n EM.open_datagram_socket(@host, @port, UDPReaderConnection,\n @write_to_channel, starter)\n end\n\n super(callback)\n end",
"def start\n while listen\n # Loop for-ev-er\n end\n end",
"def start_accepting_requests\n\t\tself.log.info \"Starting the request loop.\"\n\t\tself.reactor.start_polling( ignore_interrupts: true )\n\tend",
"def enable\n {\n method: \"WebAuthn.enable\"\n }\n end",
"def context\n unless @instance_context\n @instance_context = SipDomainContext.new(@version , @params['sip_domain'])\n end\n @instance_context\n end",
"def profilerEnableProfiling(enable, mode=ProfilerControl::PROFILE_IN_RAM, connection=$CURRENTCONNECTION)\r\n myCon = CHEmptyConnection.new()\r\n\r\n # Duplicate connection.\r\n myCon = connection.copyConnection()\r\n myCon.open(false)\r\n\r\n # Build accessor\r\n profilerCtrlCfg = $map_table.>(myCon).hal_access.>(myCon).profileControl.config\r\n\r\n val = profilerCtrlCfg.read(myCon)\r\n val = profilerCtrlCfg.prepl(val)\r\n\r\n\r\n case mode\r\n when ProfilerControl::PROFILE_IN_RAM\r\n val = profilerCtrlCfg.Global_Enable_Ram.wl(val, (enable)?(1):(0))\r\n\r\n when ProfilerControl::PROFILE_ON_TRACE\r\n val = profilerCtrlCfg.Global_Enable_Trace.wl(val, (enable)?(1):(0))\r\n\r\n end\r\n\r\n # Clear status if start\r\n if (enable)\r\n $map_table.>(myCon).hal_access.>(myCon).profileControl.status.write(myCon, 0)\r\n end\r\n\r\n # Write register\r\n profilerCtrlCfg.write(myCon, val)\r\n\r\nensure\r\n myCon.close()\r\n\r\nend",
"def get_audio_samples \n send_cmd(\"get_audio_samples\")\n end",
"def play_audio(data)\n @client.make_request(:post, @client.concat_user_path(\"#{CONFERENCE_PATH}/#{id}/audio\"), data)[0]\n end",
"def profilerEnableProfiling(enable, mode=ProfilerControl::PROFILE_IN_RAM, levelmask = 0xFFFF, connection=$CURRENTCONNECTION)\n myCon = CHEmptyConnection.new()\n\n # Duplicate connection.\n myCon = connection.copyConnection()\n myCon.open(false)\n\n # Build accessor (dereference in the wind to gain some time).\n pc = $map_table.>(myCon).hal_access.>(myCon).profileControl\n\n val = pc.config.read(myCon)\n val = pc.config.prepl(val)\n\n case mode\n when ProfilerControl::PROFILE_IN_RAM\n val = pc.config.Global_Enable_Ram.wl(val, (enable)?(1):(0))\n \n when ProfilerControl::PROFILE_ON_TRACE\n val = pc.config.Global_Enable_Trace.wl(val, (enable)?(1):(0))\n end\n \n val = pc.config.Enable_Pxts_Tag_Reserved_0.wl(val, (levelmask>>0)&1 )\n val = pc.config.Enable_Pxts_Tag_Boot.wl(val, (levelmask>>1)&1 )\n val = pc.config.Enable_Pxts_Tag_Hal.wl(val, (levelmask>>2)&1 )\n val = pc.config.Enable_Pxts_Tag_Sx.wl(val, (levelmask>>3)&1 )\n val = pc.config.Enable_Pxts_Tag_Pal.wl(val, (levelmask>>4)&1 )\n val = pc.config.Enable_Pxts_Tag_Edrv.wl(val, (levelmask>>5)&1 )\n val = pc.config.Enable_Pxts_Tag_Svc.wl(val, (levelmask>>6)&1 )\n val = pc.config.Enable_Pxts_Tag_Stack.wl(val, (levelmask>>7)&1 )\n val = pc.config.Enable_Pxts_Tag_Csw.wl(val, (levelmask>>8)&1 )\n val = pc.config.Enable_Pxts_Tag_Reserved_9.wl(val, (levelmask>>9)&1 )\n val = pc.config.Enable_Pxts_Tag_Reserved_10.wl(val, (levelmask>>10)&1 )\n val = pc.config.Enable_Pxts_Tag_Reserved_11.wl(val, (levelmask>>11)&1 )\n val = pc.config.Enable_Pxts_Tag_Bb_Irq.wl(val, (levelmask>>12)&1 )\n val = pc.config.Enable_Pxts_Tag_Spal.wl(val, (levelmask>>13)&1 )\n val = pc.config.Enable_Pxts_Tag_Spp.wl(val, (levelmask>>14)&1 )\n val = pc.config.Enable_Pxts_Tag_Spc.wl(val, (levelmask>>15)&1 )\n\n # Clear status if start\n if (enable)\n pc.status.write(myCon, 0)\n end\n\n # Write register\n pc.config.write(myCon, val)\n\nensure\n myCon.close()\nend",
"def enable_subject\n enable_disable_subject('Enabled')\n end",
"def start_tls(req, options); end",
"def enable(*observers, &block)\n set_enablement(true, observers, &block)\n end",
"def on_open(env)\n req = ::Rack::Request.new(env)\n @cid = req.params['cid']\n @path = req.path\n @subscription = Firehose::Subscription.new(cid, path)\n\n subscription.subscribe do |message, subscription|\n Firehose.logger.debug \"WS sent `#{message}` to `#{cid}@#{path}`\"\n send_data message\n end\n Firehose.logger.debug \"WS subscribed to `#{cid}@#{path}`\"\n end",
"def start(&blk)\n EM.epoll\n EM.synchrony do\n trap(\"INT\") { stop }\n trap(\"TERM\") { stop }\n\n if RUBY_PLATFORM !~ /mswin|mingw/\n trap(\"HUP\") { load_config(options[:config]) }\n end\n\n load_config(options[:config])\n load_plugins\n\n EM.set_effective_user(options[:user]) if options[:user]\n\n config[Goliath::Constants::GOLIATH_SIGNATURE] = start_server(options) do |conn|\n if options[:ssl]\n conn.start_tls(\n :private_key_file => options[:ssl_key],\n :cert_chain_file => options[:ssl_cert],\n :verify_peer => options[:ssl_verify]\n )\n end\n\n conn.port = port\n conn.app = app\n conn.api = api\n conn.logger = logger\n conn.status = status\n conn.config = config\n conn.options = options\n end\n\n blk.call(self) if blk\n end\n end",
"def start\n puts 'launching server'\n EM::run do\n EM::WebSocket.run(:host => \"0.0.0.0\", :port => 6262) do |ws|\n sigHandler\n SparrowWSHandler.new ws\n end\n end\n end",
"def start\n super\n start_proxy\n end",
"def starttls\n @stream.send \"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\"\n end",
"def subscribe_to_channel; end",
"def turn_on\n self.class._start_session\n end"
] | [
"0.52226603",
"0.5178497",
"0.51085854",
"0.50974566",
"0.5092195",
"0.5063775",
"0.5046831",
"0.5042426",
"0.50311345",
"0.50112045",
"0.50009376",
"0.494665",
"0.49414673",
"0.49284717",
"0.4923882",
"0.49152082",
"0.49092498",
"0.48973376",
"0.48753217",
"0.48735997",
"0.4869767",
"0.4852575",
"0.48390555",
"0.48293146",
"0.4818983",
"0.48124942",
"0.48124942",
"0.48124942",
"0.4801681",
"0.47923917",
"0.4770182",
"0.4767771",
"0.47535646",
"0.47501293",
"0.47488442",
"0.47430912",
"0.47345808",
"0.4729989",
"0.4727988",
"0.47052187",
"0.47026423",
"0.46970186",
"0.46966472",
"0.46955925",
"0.46915823",
"0.46806777",
"0.46757993",
"0.46750528",
"0.46738857",
"0.4666518",
"0.46652052",
"0.46509528",
"0.46487162",
"0.46435255",
"0.46421936",
"0.46376315",
"0.4637047",
"0.46351576",
"0.4634923",
"0.46292862",
"0.46268916",
"0.46254376",
"0.46226412",
"0.46208057",
"0.46103385",
"0.46066958",
"0.45986032",
"0.45961484",
"0.45948812",
"0.45881817",
"0.45858565",
"0.45858565",
"0.45834553",
"0.457691",
"0.45731056",
"0.45694077",
"0.4552851",
"0.45528433",
"0.45502543",
"0.45499676",
"0.4541585",
"0.45382994",
"0.4534402",
"0.45332465",
"0.45272756",
"0.45242155",
"0.45231622",
"0.452066",
"0.45184308",
"0.45093456",
"0.45054784",
"0.45039552",
"0.45033577",
"0.4498471",
"0.44978872",
"0.44940656",
"0.44933602",
"0.4486409",
"0.4480512",
"0.44782117"
] | 0.67978 | 0 |
Disables the WebAudio domain. | def disable
{
method: "WebAudio.disable"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsilence\n lightstreamer_subscription.unsilence\n end",
"def disable_subscription(name)\n typed_exec(\"ALTER SUBSCRIPTION #{connection.quote_ident(name)} DISABLE\")\n end",
"def disable_private_who_is(domain)\n validate_list([ [\"Domain\", domain, :domain_format] ])\n options = { \"Domain\" => domain }\n\n connection = Connection.new\n connection.post(\"Domain/PrivateWhois/Disable\", options)\n end",
"def disable\n {\n method: \"WebAuthn.disable\"\n }\n end",
"def disable!\n @enabled = false\n end",
"def unbind()\n Babylon.logger.debug(\"DISCONNECTED\") # Very low level Logging\n EventMachine::stop_event_loop\n end",
"def disable!\n @enabled = false\n end",
"def disable\n {\n method: \"Cast.disable\"\n }\n end",
"def disable!\n self.enabled = false\n end",
"def disable\n @enabled = false\n end",
"def disable\n {\n method: \"DOMStorage.disable\"\n }\n end",
"def disable!\n enabled_site = join_and_expand_path(ServerTools::Configuration.get(\"apache\",\"enabled_sites\"), @name)\n \n if !File.symlink?(enabled_site)\n ServerTools::Logger.error(\"#{@name} is not enabled!\")\n exit\n end\n \n File.delete(enabled_site)\n ServerTools::Logger.message(\"#{@name} disabled\")\n end",
"def stop\n @enabled = false\n end",
"def disable\n end",
"def disable_smart_proxy\n params = {:enabled => false}\n smart_proxy(params)\n end",
"def disable!\n @mutex.synchronize do\n @advised.each { | x | x.disable! }\n end\n self\n end",
"def discard\n @av_stream[:discard]\n end",
"def disable_rate_limits!\n @rate_limits_disabled = true\n end",
"def turn_off!\n set_power!(:off)\n end",
"def disable\n {\n method: \"DOM.disable\"\n }\n end",
"def turn_off_speaker\n puts \"SPEAKER OFF\"\n # The daemons gem will handle the stopping of the \n # # audio file playing process\n #if File.exist?( ALARM_FILE )\n if Applications.alarm_on?\n `#{SOUND_CONTROL_FILE} stop`\n # Delete file to show that the alarm is on\n #File.delete( ALARM_FILE )\n Applications.alarm_off\n end\n end",
"def stop_audio\n @music.each do |music|\n music.fade_out(@fade_ms)\n end\n @channels.each_with_index do |channel, index|\n SDL2::Mixer::Channels.fade_out(index, @fade_ms) if channel\n end\n @sounds.each do |sound|\n sound.destroy if sound && !sound.destroy?\n end\n end",
"def disable\n {\n method: \"Security.disable\"\n }\n end",
"def off\n @music.off\n @playlist.clear\n @song.kill\n end",
"def unbind()\n @connected = false\n Skates.logger.debug {\n \"DISCONNECTED\"\n } # Very low level Logging\n begin\n @handler.on_disconnected() if @handler and @handler.respond_to?(\"on_disconnected\")\n rescue\n Skates.logger.error {\n \"on_disconnected failed : #{$!}\\n#{$!.backtrace.join(\"\\n\")}\"\n }\n end\n end",
"def stop\n Audio::Out.remove @cpg\n @is_playing = false\n #Audio::Out.remove @actuator\n end",
"def halt!\n @running = false\n @audio.stop_audio\n @hardware_interface.teardown\n end",
"def off!\n digital_write(:off)\n end",
"def enable\n {\n method: \"WebAudio.enable\"\n }\n end",
"def smart_disable\n return unless $game_switches[Sw::FM_Enabled]\n $game_player.set_follower(nil, true)\n set_player_follower_particles(false)\n $game_switches[Sw::FM_WasEnabled] = $game_switches[Sw::FM_Enabled]\n $game_switches[Sw::FM_Enabled] = false\n end",
"def unsubscribed\n stop_all_streams\n end",
"def recording_off()\n update({:recording_enabled => false})\n reload()\n end",
"def disable!\n tracers.each(&:disable!)\n end",
"def disable_extension(name)\n end",
"def disable\n\n @enabled = false\n\n return self\n\n end",
"def set_ExcludePartOfSpeech(value)\n set_input(\"ExcludePartOfSpeech\", value)\n end",
"def set_ExcludePartOfSpeech(value)\n set_input(\"ExcludePartOfSpeech\", value)\n end",
"def set_ExcludePartOfSpeech(value)\n set_input(\"ExcludePartOfSpeech\", value)\n end",
"def set_ExcludePartOfSpeech(value)\n set_input(\"ExcludePartOfSpeech\", value)\n end",
"def disable\n exclusively do\n @enabled = false\n @manual_toggle = true\n end\n\n save_state\n sync_control { stop_upkeep }\n end",
"def disable(thing)\n toggle.disable(thing)\n end",
"def disable_scripts(embed_node)\n embed_node['allowscriptaccess'] = 'never'\n embed_node['allownetworking'] = 'internal'\n\n embed_node.search(\"param\").each do |param_node|\n if param_node[:name].downcase == \"allowscriptaccess\"\n param_node.unlink\n end\n if param_node[:name].downcase == \"allownetworking\"\n param_node.unlink\n end\n end\n end",
"def unbind\n @connected = false\n @network.disconnected!\n\n super\n end",
"def disable\n authorize! @user\n @user.enabled = false\n @user.save\n @user.owned_extensions.update_all(enabled: false)\n redirect_to root_path, notice: t(\"user.disabled\", name: @user.username)\n end",
"def trim_silence!\n @audio = Audio.trim_silence(0.03, 0.1, @audio)\n nil\n end",
"def disable\n {\n method: \"Performance.disable\"\n }\n end",
"def play_se_for_item\n # Don't play the sound\n end",
"def cancel!\n self.type = :unsubscribed\n reply_if_needed!\n end",
"def disable\n {\n method: \"HeadlessExperimental.disable\"\n }\n end",
"def stop_sound(type)\r\n begin\r\n set_duration(type, :async)\r\n if $g_os_type == :win32_system\r\n Thread.new{Sound.stop()}\r\n end\r\n if $g_os_type == :linux\r\n @linux_sound_stoppped[type] = true\r\n end\r\n rescue\r\n @log.error(\"stop_sound #{type}, os: #{$g_os_type}\")\r\n end\r\n end",
"def disable!\n @disabled = true\n end",
"def stop\n @av_player.stop unless @av_player.nil?\n end",
"def unbind\r\n debug [@name, :unbind]\r\n @plexer.unbind_backend(@name)\r\n end",
"def disable\n @queue << \"disable\"\n end",
"def disable\n @service.disabled = true\n end",
"def unmute()\n self.mute()\n end",
"def disableAI _obj, _args\n \"_obj disableAI _args;\" \n end",
"def unbind\r\n @time = Time.now - @start\r\n @plexer.unbind_backend(@respond)\r\n end",
"def unsubscribed # :doc:\n # Override in subclasses\n end",
"def off\n set_power(\"off\", \"smooth\",1000)\n end",
"def off!\n set(:on => false)\n end",
"def unmute\n FMOD.invoke(:ChannelGroup_SetMute, self, 0)\n self\n end",
"def off\n pwm(0x00)\n end",
"def disable(patch)\n @socket.disable\n end",
"def disable\n if enabled?\n Cratus::LDAP.replace_attribute(\n dn,\n Cratus.config.user_account_control_attribute,\n ['514']\n )\n refresh\n else\n true\n end\n end",
"def disable\n @disabled = true\n end",
"def unplayed\n @ole.Unplayed\n end",
"def discard=(value)\n @av_stream[:discard] = value\n end",
"def unbind\n @player.logout if @player\n @player = nil\n @connector = nil\n end",
"def unbind\n @player.logout if @player\n @player = nil\n @connector = nil\n end",
"def disable_message(person_or_type)\n aud = Event.process_audience(person_or_type)\n attribute_for_audience(:disable_message, aud)\n end",
"def disable!\n @active = false\n change_status(:disabled)\n end",
"def unsubscribed\n end",
"def unsubscribed\n end",
"def disable\n run \"#{try_sudo} /sbin/chkconfig httpd off\"\n end",
"def disable_extension(name, **)\n end",
"def disableConversation _obj, _args\n \"_obj disableConversation _args;\" \n end",
"def unplayed(value)\n @ole.Unplayed = value\n nil\n end",
"def skip_dampening\n define_singleton_method(:supports_dampening?) do\n false\n end\n end",
"def remove_domain_list(name)\n configure \"no ip domain-list #{name}\"\n end",
"def disconnect!\n app.speakers.ID(@id).disconnect_from\n connected?\n end",
"def disable_community(name, domain=nil)\n comm = find_community(:prod, name, domain, true)\n\n comm.disable\n @browser.wait_until { comm.status == \"Disabled\" }\n comm\n end",
"def disable_subject\n enable_disable_subject('Disabled')\n end",
"def unsend!\n @_sended = false\n end",
"def disable\n redis.set(flag_key, 0)\n end",
"def unsubscribed\n\tend",
"def remove_sound(name)\n music = MSPhysics::Music.get_by_name(name)\n MSPhysics::Music.destroy(music) if music\n dict1 = Sketchup.active_model.attribute_dictionary('MSPhysics Sounds', false)\n dict1.delete_key(name.to_s) if dict1\n dict2 = Sketchup.active_model.attribute_dictionary('MSPhysics Sound Types', false)\n dict2.delete_key(name.to_s) if dict2\n end",
"def unbind\n $dsock_list.delete self\n\n log :info, \"-- #{@player}:#{@addr}:#{@port} disconnected from CoralMUD!\"\n\n if @player\n @player.socket = nil if @player.socket == self\n\n if @player.in_room\n @player.in_room.display([:visual, \"other.can_see?(actor)\"], @player, [@player], \"<%=other.peek(actor)%> has lost their link.\")\n end\n end\n\n end",
"def unbind\n EM.cancel_timer @timer\n\n @registered = false\n\n return if @disconnecting or @reconnecting\n\n reconnect true\n end",
"def disable\n {\n method: \"Page.disable\"\n }\n end",
"def off\n @handler.off\n deactivate\n end",
"def audio; end",
"def stop_song()\n @song_settings.stop rescue nil\n @show_playbar = false\nend",
"def disable(index)\n return enable(:all) if index == :none\n index = check_index(index)\n relay = @relays[index]\n relay.disable\n end",
"def disable_polling(reason = nil)\n self.deactivate\n self.deactivation_reason = reason.to_s\n self.deactivated_at = Time.now\n self.save!\n end",
"def reset_voice\n @voice = \"Boing\"\n end",
"def stop_plugin\n @active = false\n end",
"def skip\n @song.kill\n @music.off\n end",
"def unbind\n puts \"client a connection has terminated\"\n EventMachine::stop_event_loop() \n end",
"def unsubscribed\n if current_user.is_a?(User)\n\n # if @userType == \"known\"\n ActionCable.server.broadcast \"AppearanceChannel\", { user: current_user.email, user_id: current_user.id, online: :off }\n # else\n # reject\n end\n # stop_all_streams\n # Any cleanup needed when channel is unsubscribed\n end"
] | [
"0.62375414",
"0.6026919",
"0.5863623",
"0.5857022",
"0.584489",
"0.58150816",
"0.5790704",
"0.5787989",
"0.5761655",
"0.57405245",
"0.5713707",
"0.5685493",
"0.5660492",
"0.5630568",
"0.55931056",
"0.554675",
"0.55461794",
"0.5489659",
"0.5480845",
"0.5475446",
"0.54735994",
"0.5466979",
"0.54644406",
"0.54629505",
"0.5460336",
"0.5426851",
"0.5425679",
"0.5409096",
"0.5398601",
"0.5394138",
"0.53882796",
"0.5379448",
"0.5375958",
"0.5369418",
"0.5366124",
"0.5364766",
"0.5364766",
"0.5364766",
"0.5364766",
"0.534266",
"0.53333306",
"0.53124094",
"0.53102654",
"0.53089494",
"0.53057927",
"0.52899224",
"0.5285887",
"0.5284406",
"0.5282225",
"0.52742416",
"0.52722627",
"0.52688974",
"0.5267912",
"0.52614635",
"0.52455455",
"0.5244801",
"0.52411515",
"0.5234614",
"0.52338696",
"0.52170366",
"0.52165025",
"0.5215537",
"0.5210604",
"0.52084893",
"0.52001894",
"0.51953816",
"0.5187435",
"0.5176636",
"0.51761585",
"0.51761585",
"0.51723015",
"0.5156606",
"0.5145489",
"0.5145489",
"0.5133913",
"0.5131548",
"0.512973",
"0.51184076",
"0.511293",
"0.51105374",
"0.5108529",
"0.51011986",
"0.51006657",
"0.5087221",
"0.50674874",
"0.50658786",
"0.50604075",
"0.50585026",
"0.5053297",
"0.5053168",
"0.50481504",
"0.50480396",
"0.5047942",
"0.50446963",
"0.5044224",
"0.5044132",
"0.50419086",
"0.5041158",
"0.50402313",
"0.5038682"
] | 0.79204506 | 0 |
Fetch the realtime data from the registered contexts. | def get_realtime_data(context_id:)
{
method: "WebAudio.getRealtimeData",
params: { contextId: context_id }.compact
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_context\n synchronize do\n # The URL to get the context list from sesame\n dir = \"#{@options[\"host\"]}:#{@options[\"port\"]}/openrdf-sesame/repositories/#{@options[\"repo\"]}/contexts\"\n\n # Asks for the context list\n RestClient.get dir, :content_type=>'application/sparql-results+xml'\n end\n end",
"def getContexts\n \n query_processing_time_begin = Time.now\n # In web-ui query processing time is only shown if asked. In atom-feed, it is always shown.\n if params[\"query_processing_time\"] && params[\"query_processing_time\"].downcase == \"true\"\n @query_processing = true\n end\n if params[:qoption] && params[:qoption][\"query_processing_time\"] == \"true\"\n @query_processing = true\n end\n \n @queryparams = params\n \n if request.url.to_s.include?(\"?\")\n @querystring = request.url.to_s.gsub(/http\\:\\/\\/[\\w\\.\\:\\/]+\\?/, \"\").gsub(\"%2A\", \"*\")\n @querystring_for_feed = @querystring.gsub(/\\&?perpage\\=\\d+/i, \"\").gsub(/\\&?page\\=\\d+/i, \"\").gsub(/^\\&/, \"\")\n end\n if @querystring_for_feed == \"\" or @querystring_for_feed == nil then @querystring_for_feed = \"No parameters given. Use name parameter for querying contexts by name.\" end\n \n \n # Find username who is signed in\n if params[:i_am_client]\n username = authenticateClient\n elsif session[:username]\n username = session[:username] \n end\n @user = User.find_by_username(username)\n\n # host parameter, needed when creating atom-feed\n if request.ssl?\n @host = \"https://#{request.host}\"\n else\n @host = \"http://#{request.host}\"\n end\n\n if request.port != nil and request.port != 80\n @host += \":#{request.port}\"\n end \n \n sql = \"SELECT contexts.id as c_id, contexts.user_id as user_id, contexts.name as name, query_uri, icon_url,\n contexts.node_path as node_path, contexts.node_service as node_service,\n description, begin_time, end_time, contexts.email as email, private, location_string, username, \n users.id, contexts.updated_at as updated_at, contexts.created_at as created_at, context_hash,\n contexts.rank as rank\n FROM contexts, users \"\n sql_conditions = nil\n \n if @queryparams[:name] \n sql_names = searchtermForSql(@queryparams[:name], \"name\")\n sql_conditions = sql_conditions ? sql_conditions + \" AND \" + sql_names : sql_names\n end\n \n if @queryparams[:username] \n # Find user_id\n owner = User.find_by_username(@queryparams[:username])\n if owner == nil\n render :text => \"Owner of queried context not found\", :status => 409\n return\n end \n sql_conditions = sql_conditions ? sql_conditions + \" AND user_id = #{owner.id} \" : \"user_id = #{owner.id} \"\n end\n \n if @queryparams[:sort_by]\n # You can sort by created_at/updated_at/name/rank\n if @queryparams[:sort_by].downcase == \"date_added\"\n sort_by = \"created_at\"\n elsif @queryparams[:sort_by].downcase == \"date_updated\"\n sort_by = \"updated_at\"\n elsif @queryparams[:sort_by].downcase == \"name\"\n sort_by = \"name\"\n elsif @queryparams[:sort_by].downcase == \"rank\"\n sort_by = \"rank\"\n end\n \n else\n sort_by = \"updated_at\"\n end\n \n # If searching contexts by name, also take into account context_names given by the user\n if @queryparams[:name] && @user != nil\n tmp_also_these_ctx = Context.find_by_sql(\"SELECT context_names.* FROM context_names WHERE #{sql_conditions} AND context_names.user_id = #{@user.id}\")\n \n if tmp_also_these_ctx != nil && tmp_also_these_ctx.size != 0\n \n add_contexts = \"contexts.id IN (\"\n\n tmp_also_these_ctx.each_with_index do |x, i|\n if i != 0\n add_contexts += \", \"\n end\n add_contexts += x.context_id\n end\n add_contexts += \" ) \"\n \n sql_conditions = \" ( \"+ add_contexts + \" OR \" + sql_conditions +\" ) \"\n end\n \n end\n \n \n if @queryparams[:order] && @queryparams[:order].downcase == \"asc\"\n order = \"ASC\" \n else\n order = \"DESC\"\n end\n \n if sql_conditions\n sql += \" WHERE \" + sql_conditions + \" AND user_id = users.id \"\n else\n sql += \" WHERE contexts.user_id = users.id \"\n end\n \n sql += \" ORDER BY #{sort_by} #{order} \"\n puts \"Context search SQL: #{sql}\"\n \n # Get contexts, user authorization is not yet checked for these\n contexts_unlimited = Context.find_by_sql( sql )\n \n # Move contexts here, that user is authorized to see\n @contexts = Array.new\n # Show the name owner has given, as well as the name the user has given\n @context_info = {}\n \n # Find contexts that user is authorized to see\n contexts_unlimited.each do |cx|\n if authorizedToContext(cx.context_hash)\n \n tmp_owner = User.find_by_id(cx.user_id)\n if tmp_owner == nil\n render :text => \"Couldn't find owner info for context: #{cx.name}\", :status => 409\n return\n end\n\n if @user != nil\n temp_ctx_name = ContextName.find_by_user_id_and_context_id(@user.id, cx.c_id)\n else\n temp_ctx_name = nil\n end\n \n if temp_ctx_name != nil\n \n @context_info.merge!({cx.c_id => { \"owner_name\" => tmp_owner.username, \"user_named\" => temp_ctx_name.name}}) \n else \n @context_info.merge!({cx.c_id => { \"owner_name\" => tmp_owner.username, \"user_named\" => cx.name}})\n end\n @contexts.push(cx)\n next\n end\n end\n \n puts @contexts.to_s\n \n # If user doesn't have access to any context\n if @contexts.empty?\n render :text => \"Nothing found!\", :status => 404\n return\n end\n \n sql = \"SELECT context_metadatas.context_id as id, \n context_metadatas.value as value, \n metadata_types.name as type_name,\n metadata_types.value_type as value_type\n FROM context_metadatas, metadata_types\"\n\n metadata_where_part = \" WHERE context_metadatas.metadata_type_id = metadata_types.id AND \n context_metadatas.context_id in (\"\n @contexts.each_index do |i|\n c = @contexts[i]\n metadata_where_part += \"#{c.c_id.to_s}\"\n metadata_where_part += ',' if @contexts.count > 1 and i != @contexts.count - 1\n end\n metadata_where_part += ')'\n \n sql += metadata_where_part\n \n @metadatas = {}\n mdatas = ContextMetadata.find_by_sql(sql)\n mdatas.each do |md|\n temp = @metadatas[md.id]\n if not temp\n # Wasn't found => new array for the mds\n temp = []\n end\n temp.push(md)\n @metadatas.merge!({md.id => temp})\n end\n \n \n\n @members = {}\n @contexts.each do |x|\n \n sql = \"SELECT users.* \n FROM context_group_permissions, groups, usersingroups, users \n WHERE context_group_permissions.context_id=#{x.c_id} AND \n context_group_permissions.group_id = groups.id AND \n groups.id=usersingroups.group_id AND usersingroups.user_id=users.id;\"\n \n m_temp = User.find_by_sql(sql)\n if not m_temp\n m_temp = []\n end\n @members.merge!({x.c_id => m_temp}) \n end\n\n # Create atom feed\n @host = @@http_host\n \n \n if @queryparams[:format] == \"yaml\" or @queryparams[:format] == \"json\" \n puts \"YAMLII\"\n @yaml_results = {}\n \n @contexts.each do |context|\n context_metadatas = @metadatas[context.c_id.to_i]\n context_members = @members[context.c_id]\n co = ContextObject.new(context, context_metadatas, context_members, @context_info[context.c_id])\n @yaml_results.merge!({co.get_uri => co.to_yaml})\n end\n end\n \n \n if query_processing_time_begin != nil\n query_processing_time_end = Time.now\n @query_processing_time = query_processing_time_end - query_processing_time_begin\n puts \"Time used for processing query: #{@query_processing_time}\"\n end\n \n \n \n # Rendering\n respond_to do |format|\n if @queryparams[:format] == nil\n format.html {render :getcontexts, :layout=>true }\n else\n format.html {render :getcontexts, :layout=>true }\n format.atom {render :getcontexts, :layout=>false }\n format.yaml {render :text => YAML.dump(@yaml_results), :layout=>false }\n format.json {render :text => JSON.dump(@yaml_results), :layout=>false }\n end\n end \n end",
"def fetch(context=nil)\n context.nil? ? global : named_context[context]\n end",
"def get_data(contexts=[\"all\"])\n synchronize do\n \n # Prepares the URL to request the data\n context = contexts.map{|context| \"context=#{context}\"}*\"&&\"\n dir = \"#{@options[\"host\"]}:#{@options[\"port\"]}/openrdf-sesame/repositories/#{@options[\"repo\"]}/statements?#{context}\"\n\n # Asks for the data\n ntriples = RestClient.get dir, :content_type=>select_type\n\n # Makes the graph to return.\n Parser.parse(:rdf, ntriples)\n end\n\t \tend",
"def data\n retrieve_data\n end",
"def load_realtime_data\n proto = Net::HTTP.get(URI.parse(realtime_url))\n data = Transit_realtime::FeedMessage.decode(proto)\n\n schedule_data = []\n data.entity.each do |entity|\n if entity.field?(:trip_update)\n schedule_data << entity.trip_update.to_hash_value\n end\n end\n schedule_data\n end",
"def get_trade_context\n return @trade_context.fetch\n end",
"def context\n init\n @context\n end",
"def contexts\n @store.contexts\n end",
"def realtime\n Query.new(self).realtime\n end",
"def get(context)\n raw(context)\n end",
"def fetch_data\n return @data if @data[\"/type/reflect/any_master\"]\n @data = Ken.session.mqlread(FETCH_DATA_QUERY.merge!(:id => id))\n end",
"def contexts\n @contexts ||= {}\n end",
"def getContext\n \n query_processing_time_begin = Time.now\n # In web-ui query processing time is only shown if asked. In atom-feed, it is always shown.\n if params[\"query_processing_time\"] && params[\"query_processing_time\"].downcase == \"true\"\n @query_processing = true\n end\n if params[:qoption] && params[:qoption][\"query_processing_time\"] == \"true\"\n @query_processing = true\n end\n \n \n if params[:contexthash] != nil\n \n @context = Context.find_by_context_hash(params[:contexthash])\n \n else\n \n user = User.find_by_username(params[:username])\n if user == nil\n render :text => \"Owner of context not found!\", :status => 409\n return\n end\n \n ctxName = ContextName.find_by_user_id_and_name(user.id, params[:contextname])\n if ctxName == nil\n render :text => \"Contextname was not found for this user!\", :status => 404\n return\n end\n \n @context = Context.find_by_id(ctxName.context_id) \n end\n \n # If requested context wasn't found\n if @context == nil\n render :text => \"Context not found!\", :status => 404\n return\n end\n \n sql = \"SELECT users.* \n FROM context_group_permissions, groups, usersingroups, users \n WHERE context_group_permissions.context_id=#{@context.id} AND \n context_group_permissions.group_id = groups.id AND \n groups.id=usersingroups.group_id AND usersingroups.user_id=users.id;\"\n @members = User.find_by_sql(sql)\n \n @owner = User.find_by_id(@context.user_id)\n if @owner == nil\n render :text => \"Owner of the context could not be found\", :status => 409\n return\n end\n \n # User-object who is signed in, if not signed in it's nil\n @user = whoIsSignedIn \n \n # If user is not authorized to see context\n if not authorizedToContext(@context.context_hash)\n render :text => \"You don't have permission to see this context\", :status => 401\n return\n end\n\n ## Context is found and user is authorized to view it. We may proceed.\n \n \n @context_metadatas = ContextMetadata.find_by_sql(\"SELECT context_metadatas.context_id as id, \n context_metadatas.value as value, \n metadata_types.name as type_name,\n metadata_types.value_type as value_type\n FROM context_metadatas, metadata_types\n WHERE context_metadatas.metadata_type_id = metadata_types.id AND \n context_metadatas.context_id = #{@context.id}\") \n \n @context_named_by_user = @context.name\n \n @metadatatypes = MetadataType.find(:all, :order => \"name ASC\" )\n \n # Find if user that is signed in, has named the context\n if @user != nil\n tmp_ctx_name = ContextName.find_by_user_id_and_context_id(@user.id, @context.id)\n if tmp_ctx_name != nil\n # Signed in user has named the context\n @context_named_by_user = tmp_ctx_name.name\n end\n end\n \n \n \n if query_processing_time_begin != nil\n query_processing_time_end = Time.now\n @query_processing_time = query_processing_time_end - query_processing_time_begin\n puts \"Time used for processing query: #{@query_processing_time}\"\n end\n \n \n #Create atom feed\n @host = @@http_host\n respond_to do |format|\n if params[:format] == nil\n format.html {render :getcontext, :layout=>true }\n else\n format.html {render :getcontext, :layout=>true }\n format.atom {render :getcontext, :layout=>false }\n end\n end \n end",
"def realtime_metrics\n current_user = @controller.current_user\n tp = TimeProfile.profile_for_user_tz(current_user.id, current_user.get_timezone) || TimeProfile.default_time_profile\n Metric::Helper.find_for_interval_name('realtime', tp)\n .where(:resource => @ems.try(:all_container_nodes) || ContainerNode.all)\n .where('timestamp > ?', REALTIME_TIME_RANGE.minutes.ago.utc).order('timestamp')\n end",
"def get_feed\n self.class.fetch_from_cache @canvas_course_id do\n get_feed_internal\n end\n end",
"def context\n unless @instance_context\n @instance_context = WorkersRealTimeStatisticsContext.new(@version , @params['workspace_sid'])\n end\n @instance_context\n end",
"def contexts\n JSON.parse(raw_contexts())[\"results\"][\"bindings\"].map{|x| x[\"contextID\"][\"value\"] }\n end",
"def list_ctx\n if @_data.nil?\n return @_deferred_init[1] unless @_deferred_init.empty?\n raise \"Parameter '#{@name}' has not been initialized\"\n end\n @_ctx_list\n end",
"def data(ctx: nil)\n _check_and_get(@_data, ctx)\n end",
"def contexts\n @contexts ||= @contexts = {}\n end",
"def fetch\n end",
"def load_contexts(hash)\n return unless hash\n response = []\n unless hash['data']\n @errors << \"All custom contexts must be contain a `data` element\" and return\n end\n schema = SchemaCache.instance[hash['schema']]\n response << { content: hash['data'], definition: schema, schema_name: hash['schema'] }\n unless hash['data'].is_a? Array\n @errors << \"All custom contexts must be wrapped in an Array\" and return\n end\n hash['data'].each do |data_item|\n schema = SchemaCache.instance[data_item['schema']]\n response << { content: data_item['data'], definition: schema, schema_name: data_item['schema'] }\n end\n response\n end",
"def context\n @context ||= {}\n end",
"def context\n @context ||= {}\n end",
"def reload!\n fetch_data!\n end",
"def realtime\n @attributes[:realtime]\n end",
"def fetch_global_trends\n global_trends = $redis.get('global_trends')\n if global_trends.nil?\n response = twitter.trends(id = 1)\n global_trends = JSON.generate(response.attrs[:trends])\n $redis.set('global_trends', global_trends)\n $redis.expire('global_trends', 15.minutes.to_i)\n end\n @global_trends = JSON.load(global_trends)\n end",
"def all\n @cache ||= Request.get('/data')\n\n end",
"def context\n Thread.current[:ctx] ||= {}\n Thread.current[:ctx]\n end",
"def context\n get('/augeas/context')\n end",
"def current_value\n ::Fiveruns::Dash.sync do\n @data.inject([]) do |all, (context, data)|\n all.push(data.merge(:context => context))\n end\n end\n end",
"def load_context(command_name=nil)\n # when switching to tier 2 we need to use command name from tier one\n # e.g. cc library/public, we are caching context under library_1, library_2\n # so getting context for 'public' will not work and we use than library\n command_name = root? ? 'dtk' : @active_context.last_command_name\n\n if @active_context.last_context_is_shadow_entity?\n @current = ShadowEntity.resolve_tasks(@active_context.last_context)\n else\n # if there is no new context (current) we use old one\n @current = current_context_task_names() || @current\n end\n\n client_commands = CLIENT_COMMANDS\n client_commands.concat(DEV_COMMANDS) if DTK::Configuration.get(:development_mode)\n\n # we add client commands\n @current.concat(client_commands).sort!\n\n # holder for commands to be used since we do not want to remember all of them\n @context_commands = @current\n\n # we load thor command class identifiers for autocomplete context list\n command_context = get_command_identifiers(command_name)\n\n command_name_list = command_context ? command_context.collect { |e| e[:name] } : []\n @context_commands.concat(command_name_list) if current_command?\n\n\n # logic behind context loading\n #Readline.completer_word_break_characters=\" \"\n Readline.completion_proc = proc { |input| dynamic_autocomplete_context(input, Readline.respond_to?(\"line_buffer\") ? Readline.line_buffer : [])}\n end",
"def get_context\n @context_hash ||= {}\n end",
"def live_data\n @live_data ||= if Settings.live_lookup_service == 'LiveLookup::Sirsi'\n LiveLookup.new(id).records\n else\n []\n end\n end",
"def get_all_data\n init_data\n\n Bot::DB[my_name]\n end",
"def get_all_data\n init_data\n\n Bot::DB[my_name]\n end",
"def reload_data\n self.class.new reinit_endpoint.do_get\n end",
"def fetch_context\n val = session.delete(:context)\n @context = val && val.to_sym\n true # TODO: remove in Rails 5.0\n end",
"def fetch_entries(context)\n @site, @page, @portal_user = context.registers[:site], context.registers[:page], context.registers[:current_portal_user]\n set_defaults\n\n page = (case @source\n when 'site' then @all_pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page\n when 'parent' then top_page\n when 'page' then @page\n else\n @all_pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first\n end)\n\n children = children(page)\n\n children.delete_if { |p| !include_page?(p) }\n end",
"def context\n unless @instance_context\n @instance_context = WorkflowRealTimeStatisticsContext.new(\n @version,\n @params['workspace_sid'],\n @params['workflow_sid'],\n )\n end\n @instance_context\n end",
"def refresh!\n self.data = client.get(path).data\n end",
"def refresh_data\n @total_companies = Company.all.count\n @current_companies = Company.in_good_standing\n\n # membership applications by state\n ShfApplication.all_states.each do |app_state|\n shf_apps_state_counts[app_state] = ShfApplication.total_in_state app_state\n end\n @app_states_translated = ShfApplication.group(:state).count.transform_keys {\n |k| I18n.t \"activerecord.attributes.shf_application.state/#{k}\"\n }\n @apps_without_uploads = ShfApplication.decided_with_no_uploaded_files\n @apps_approved_member_fee_not_paid = User.all.select(&method(:membership_fee_due?))\n\n @companies_branding_not_paid = Company.all.reject(&:branding_license?)\n @companies_info_not_completed = Company.all - Company.information_complete\n\n @total_users = User.all.count\n @total_members = User.members.count\n @current_members = User.current_member\n\n @translated_users = User.group(:member).count.transform_keys {\n |k| I18n.t \"activerecord.attributes.member.#{k}\"\n }\n\n get_data_for_past_days(timeframe)\n\n end",
"def fetch\n raise NotImplementedError\n end",
"def fetch\n @_fetch ||= begin\n path = @parent.build_request_path(@query_attrs)\n @parent.request(@query_attrs.merge(:_method => :get, :_path => path)) do |parsed_data, response|\n @parent.new_collection(parsed_data)\n end\n end\n end",
"def refresh\n @data = read_data\n end",
"def current\n all_contexts[Thread.current.object_id]\n end",
"def context\n unless @instance_context\n @instance_context = WorkflowRealTimeStatisticsContext.new(@version , @params['workspace_sid'], @params['workflow_sid'])\n end\n @instance_context\n end",
"def fetch!\n info \"FETCH\"\n Fetcher.run @dbi, @collections, @settings, @logger do |*args| update_db(*args) end # results will be passed to the update function\n end",
"def fetch; end",
"def fetch; end",
"def get_all\n @data\n end",
"def data; @data ||= fetch; end",
"def refresh\n fetch_api_data\n self\n end",
"def get(context = nil)\n with_scope(context) do\n current_base\n end\n end",
"def fetch\n raise NotImplementedError\n end",
"def fetch_entries(context)\n @site, @page = context.registers[:site], context.registers[:page]\n\n children = (case @source\n when 'site' then @site.pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page\n when 'parent' then @page.parent || @page\n when 'page' then @page\n else\n @site.pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first\n end).children_with_minimal_attributes(@options[:add_attributes]).to_a\n\n children.delete_if { |p| !include_page?(p) }\n end",
"def context\n Thread.current[NAME] ||= Array.new\n end",
"def get_feed\n if user_authorized?\n self.class.fetch_from_cache @canvas_course_id do\n get_feed_internal\n end\n else\n nil\n end\n end",
"def get(ctxt, url, key, check_stale = true)\n fetch ctxt, url, key, check_stale\n end",
"def available_data_sources\n data_sources = []\n if self.current_contexts.size == 1\n the_context = self.current_contexts.first\n if the_context != ContextEnum.either\n the_data_source = self.inherited_data_source\n if the_data_source == DataSourceNone # top level data source\n data_sources = ContextDataSourceMap[the_context]\n else\n data_sources = DataSourceChainMap[the_data_source]\n end\n end\n end\n data_sources\n end",
"def fetch\n options = {\n \"url\" => @location\n }\n\n @connector.apply(:get, self, options)\n end",
"def entries\n load_client\n load_entries\n load_preferences\n end",
"def get_context_data(entry_id, context_data_params)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'entryId', entry_id);\n\t\t\tclient.add_param(kparams, 'contextDataParams', context_data_params);\n\t\t\tclient.queue_service_action_call('baseentry', 'getContextData', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def load_context\n if params[:context_id]\n @context = Api::V3::Context.find(params[:context_id])\n return\n end\n if params[:country_id] && params[:commodity_id]\n @context = Api::V3::Context.find_by(\n country_id: params[:country_id], commodity_id: params[:commodity_id]\n )\n return\n end\n ensure_required_param_present(:context_id)\n end",
"def fetch\n client.fetch(self)\n end",
"def refresh_realtime_feed!(config, reload_transit_realtime=true)\n\n if config.handler.present?\n klass = config.handler.constantize\n else\n klass = GTFS::Realtime::RealtimeFeedHandler\n end\n\n handler = klass.new(gtfs_realtime_configuration: config)\n handler.process\n end",
"def get\n execute(:get)\n end",
"def get\n execute(:get)\n end",
"def get_appdata_global (*keys)\n @restv1.get_global_appdata(*keys)\n end",
"def retrieve!\n raise Error::NotImplementedError, \"There is no current end point to get sensor data by id\"\n end",
"def realtime_lifetime\n get_realtime_views(self)\n end",
"def get(data, ctx, lazy=false) # IDENTITY TRACKING AND LAZY LOADING\n entity_key = extract_key(data)\n key = [self, entity_key]\n # extract_key is generated ad-hoc by model compiler!\n if cached = ctx.entity_cache[key]\n cached\n else\n ctx.entity_cache[key] = get(*entity_key)\n # get is generated ad-hoc by model compiler\n end\n end",
"def get(*args)\n result = super\n reload_ldp\n result\n end",
"def fetch(*)\n raise NotImplementedError, 'This should be defined in a subclass'\n end",
"def context\n Context.instance\n end",
"def reload\n self.attributes = Connection.get(create_route(:get)).body['data']\n self\n end",
"def request_data\n Thread.current[THREAD_LOCAL_NAME] ||= {}\n end",
"def get\n processed_dataset = route.features.inject(dataset){|ds, f| f.process_dataset(ds, params)}\n result = processed_dataset.all\n route.features.inject(result){|res, f| f.process_output(processed_dataset, res, params)}\n end",
"def fetch!\n begin\n obj = self.class.find(self.id)\n @_data = obj.webflow_data\n true\n rescue\n false\n end\n end",
"def fetch(force=false)\n if @fetch.nil? || force\n query = @query.dup\n query[:q] = query[:q].join(\" \")\n perform_get(query)\n end\n\n @fetch\n end",
"def get_data\n\t\texecute unless @result\n\t\treturn get_data_from_result(@result)\n\tend",
"def retrieve_data\n @data_retrieved = nil\n\n @data_retrieved = @meeting.meeting_individual_results.\n includes(:meeting_event, :swimmer, :event_type, :category_type, :gender_type, :team_affiliation, meeting_event: [:heat_type]).\n to_a\n end",
"def lookup_context; end",
"def lookup_context; end",
"def lookup_context; end",
"def context\n Thread.current[NAME] ||= Hash.new\n end",
"def fetch\n @fetched_value\n end",
"def get_global_appdata(*keys)\r\n context.appdata_to_hash do\r\n if keys.length > 0\r\n @context.call_myspace_api(:appdata_global_keys_get, :keys => keys.join(';'), :v1_json => true)\r\n else\r\n @context.call_myspace_api(:appdata_global_get, :v1_json => true)\r\n end\r\n end\r\n end",
"def load_all\n thread_local_store.load_all\n self\n end",
"def fetch_hooks_to_be_processed\n acquire_lock\n fetch_locked_hooks\n end",
"def raw_contexts(result_format=\"application/sparql-results+json\")\n easy = Curl::Easy.new\n easy.headers[\"Accept\"] = result_format\n\n easy.url = self.uri + \"/contexts\"\n easy.http_get\n\n raise(SesameException.new(easy.body_str)) unless easy.response_code == 200\n\n easy.body_str\n end",
"def fetch\n raise \"not implemented\"\n end",
"def get(context = Context.current)\n context[self]\n end",
"def data\n self.reload if @should_reload\n return @data\n end",
"def context\n @context.to_flat_hash\n end",
"def get_data\n response = proxy.get_data(handle)\n self.update_properties(response)\n self.partial = false\n self.persisted = true\n end",
"def refresh\n self.first_name, self.last_name, self.email =\n @redis.hmget(\"contact:#{@id}\", 'first_name', 'last_name', 'email')\n self.media = @redis.hgetall(\"contact_media:#{@id}\")\n self.media_intervals = @redis.hgetall(\"contact_media_intervals:#{self.id}\")\n self.media_rollup_thresholds = @redis.hgetall(\"contact_media_rollup_thresholds:#{self.id}\")\n\n # similar to code in instance method pagerduty_credentials\n if service_key = @redis.hget(\"contact_media:#{@id}\", 'pagerduty')\n self.pagerduty_credentials =\n @redis.hgetall(\"contact_pagerduty:#{@id}\").merge('service_key' => service_key)\n end\n end",
"def running_contexts\n contexts = FakeTraceObserverHelpers::RUNNING_SERVER_CONTEXTS\n contexts.map{|k,v| v}.inspect\n end",
"def get_all_metrics()\n return nil unless Config.metrics\n f = Fiber.current\n resp = metrics.find().defer_as_a\n resp.callback do |doc|\n f.resume doc\n end\n resp.errback do |err|\n raise *err\n end\n docs = Fiber.yield\n # convert ids to int\n docs.collect{|doc| doc['_id'] = doc['_id'].to_i ; doc }\n end"
] | [
"0.64655477",
"0.61454755",
"0.59322417",
"0.5926333",
"0.57833904",
"0.5738207",
"0.5692313",
"0.5625469",
"0.56071573",
"0.5576035",
"0.55699784",
"0.5557334",
"0.55421406",
"0.54988605",
"0.5480596",
"0.54701126",
"0.5451086",
"0.54372704",
"0.54148805",
"0.54106694",
"0.5374128",
"0.5365944",
"0.5360424",
"0.53143317",
"0.53143317",
"0.53024346",
"0.5298052",
"0.52686006",
"0.5247977",
"0.5244295",
"0.52330464",
"0.5228896",
"0.52250504",
"0.5222249",
"0.5221644",
"0.52210444",
"0.52210444",
"0.5209564",
"0.5177959",
"0.51613414",
"0.5143365",
"0.513175",
"0.5128887",
"0.51207596",
"0.512068",
"0.5115671",
"0.51152205",
"0.5112663",
"0.5101699",
"0.5100126",
"0.5100126",
"0.50981104",
"0.5096176",
"0.50938195",
"0.5091159",
"0.5085134",
"0.50669163",
"0.50612086",
"0.50598764",
"0.50573814",
"0.5055775",
"0.5050661",
"0.50437605",
"0.5039027",
"0.5034841",
"0.50347173",
"0.5014738",
"0.5010988",
"0.5010988",
"0.5010968",
"0.50095266",
"0.5004236",
"0.4993051",
"0.49908793",
"0.49799457",
"0.49779272",
"0.4969867",
"0.49655062",
"0.49580503",
"0.49507797",
"0.49462038",
"0.4943475",
"0.49424475",
"0.49354613",
"0.49354613",
"0.49354613",
"0.4933634",
"0.49325883",
"0.49324983",
"0.49230555",
"0.49133682",
"0.49092114",
"0.49067074",
"0.48998582",
"0.48888955",
"0.488486",
"0.4878074",
"0.4876748",
"0.4876683",
"0.4875893"
] | 0.65922636 | 0 |
Creating a new order is handled by the Stripe ChargesController | def checkout
@user = User.find(session[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @order = Order.new(params[:order])\n end",
"def create_order\n @order = Order.create\n end",
"def create\n\n # Remember to change this to your live secret key in production\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n\n # Get the credit card details submitted by the form\n token = params[:stripeToken]\n logger.info \"Token is #{token.inspect}\"\n\n @order = Order.new(order_params)\n @order.add_items_from_cart(@cart)\n @order.user_id = current_user.id\n\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n\n # Send a notification email to Alex\n UserMailer.email_alert(@order)\n\n # Send an email receipt to user\n UserMailer.email_receipt(current_user, @order).deliver\n\n # Create the charge on Stripe's servers - this will charge the user's card\n begin\n charge = Stripe::Charge.create(\n :amount => (100 * (@order.total_price*1.08 + 6.00)).to_i,\n :currency => \"usd\",\n :card => token,\n :description => \"payinguser@example.com\"\n )\n flash[:success] = \"Thanks for ordering!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n format.html { redirect_to(root_url) }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @orders = Order.all\n @order = Order.new(order_params)\n @order.card = params[:stripeToken]\n @order.amount_in_cents = @order.amount * 100\n if @order.save_with_payment\n redirect_to @order\n else\n render action: \"new\", error: \"There was a problem. Please try again.\"\n end\n end",
"def create\n @order = order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @amount = ((current_order.subtotal + 8)*100).to_i\n @description = \"Order: #{current_order.id}\"\n\n @checkout = Checkout.new(checkout_params)\n @checkout.add_order_items_from_cart(current_order) \n token = params[:stripeToken]\n\n charge = Stripe::Charge.create({\n source: token,\n amount: @amount,\n currency: \"usd\",\n description: @description\n })\n\n respond_to do |format|\n if @checkout.save\n Order.destroy(session[:order_id])\n session[:order_id] = nil\n OrderMailer.order_recived(@checkout).deliver_now\n format.html { redirect_to root_path, notice: 'Thanks for you order!' }\n format.json { render :show, status: :created, location: @checkout }\n else\n format.html { render :new }\n format.json { render json: @checkout.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Stripe::CardError => e\n flash.alert = e.message\n render action: :new\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n @order.order_create\n format.html { redirect_to @order, notice: 'Замовлення успішно створено.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # 前端傳回的資料,呼叫 order_params 過濾前端傳回來的資料,用 new 創出一個 Order 的物件 (此時還是 ruby 物件喔)\n @order = Order.new(order_params)\n\n respond_to do |format|\n # save 是指把該筆 物件裡的資料存入資料庫內\n if @order.save\n # 若儲存成功,就導回該筆資料的 show 頁面\n format.html { redirect_to order_path(@order), notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n # 若儲存失敗,就導回新增的頁面重新填寫資料\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Provider was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t('app.orders.create.success') }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, flash: { sucess: 'Order was successfully created.' } }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.buyer = current_user\n @order.product = Product.find(order_params[:product_id])\n # Amount in cents\n @amount = @order.product.price_cents + @order.product.postage_cents\n\n customer = Stripe::Customer.create(\n :email => current_user.email,\n :source => params[:stripeToken]\n )\n\n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => @amount,\n :description => @order.product.title,\n :currency => 'aud'\n )\n\n @order.charge_identifier = charge.id\n\n @order.save\n buyer_email = current_user.email\n order_details = {\n title: @order.product.title,\n artist: @order.product.artist,\n total_amount: @amount\n }\n\n OrderMailer.order_confirmation(buyer_email, order_details).deliver_now\n\n redirect_to order_path(@order)\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_order_path(product_id: @order.product.id)\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, :notice => 'Order was successfully created.' }\n format.json { render :json => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @order = Order.new(order_params)\n @shopping_cart = ShoppingCart.find(params[:shopping_cart_id])\n @order.shopping_cart_id = @shopping_cart.id\n @order.fulfilled = false\n @order.in_transit = false\n\n if(user_signed_in?)\n @order.user_id = current_user.id\n else\n @order.user_id = -1\n end\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => (@shopping_cart.total * 100).floor,\n :currency => \"eur\",\n :card => token\n )\n flash[:notice] = \"We're on our way!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n session[:shopping_cart_id] = ShoppingCart.new.id\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to root_url}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n @order.donor_id = current_donor.id\n @order.price = @cart.total_price\n respond_to do |format|\n if @order.save\n @order.line_items.each do |line|\n thing = Product.find(line.product_id)\n thing.sold = true\n thing.save\n end\n token = params[:stripeToken]\n @amount = @cart.total_price.to_i*100\n\n charge = Stripe::Charge.create({\n amount: @amount,\n currency: 'aud',\n description: 'Example charge',\n source: token,\n \n })\n \n Order.new[:params]\n\n redirect_to controller: 'orders', action: 'show', id: Order.last.id\n\n\n Cart.destroy(session[:cart_id])\n session[:cart_id]\n format.html \n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = @orders.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: \"Order was successfully created.\" }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.user_id = current_user.id\n @order.uuid = SecureRandom.hex(8)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render 'show', status: :created, location: @order }\n else\n format.html { render 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cp_order = Order.new(cp_order_params)\n\n respond_to do |format|\n if @cp_order.save\n format.html { redirect_to cp_order_path(@cp_order), notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @cp_order }\n else\n format.html { render :new }\n format.json { render json: @cp_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n if @order.save\n render json: { status: 'SUCCESS', data: @order }\n else\n render json: { status: 'ERROR', data: @order.errors }\n end\n end",
"def create\n\t\torder = Order.new(order_params)\n\t\torder.save ? (redirect_to orders_path, flash: {notice: 'Order created successfully'}) : (redirect_to new_order_path, flash: {error: order.errors.full_messages.to_sentence})\n\tend",
"def create\n @order = current_user.orders.build(order_params)\n @order.add_line_items_from_cart(@cart)\n\n # STRIPE INTEGRATION\n @amount = @cart.total_price.to_i * 100\n\n customer = Stripe::Customer.create(\n email: params[:stripeEmail],\n source: params[:stripeToken]\n )\n\n charge = Stripe::Charge.create(\n customer: customer.id,\n amount: @amount,\n description: 'Port Moody Delivery',\n currency: 'cad'\n )\n\n\n respond_to do |format|\n if @order.save\n\n send_text_message\n \n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n\n format.html { redirect_to root_url, notice: 'Thank you for your order' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = current_owner.orders.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to orders_path, notice: 'Order was created successfully' }\n format.json { render :show, status: :created, location: orders_path }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n redirect_to :action => :index\n else\n render :action => :new\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @seller = @listing.user\n @order.buyer_id = current_user.id\n @order.seller_id = @seller.id\n @order.listing_id = @listing.id\n\n Stripe.api_key = Rails.application.secrets.stripe_api_key\n begin\n Stripe::Charge.create(amount: (@listing.price * 100).floor,\n currency: 'usd',\n source: params[:stripe_token],\n description: \"Charge for #{@listing.description}\")\n flash[:notice] = 'Thanks for your order!'\n rescue Stripe::CardError => error\n flash[:danger] = error.message\n end\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to root_path }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n @order.user_id = current_user.user_id\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to order_url(@order), notice: I18n.t('orders.successfully_created') }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, :notice=>\"Order was successfully created.\" }\n format.json { render :json=>@order, :status=>:created, :location=>@order }\n else\n format.html { render :action=>\"new\" }\n format.json { render :json=>@order.errors, :status=>:unprocessable_entry }\n end\n end\n end",
"def create\n @spree_order = Spree::Order.new(spree_order_params)\n\n respond_to do |format|\n if @spree_order.save\n format.html { redirect_to @spree_order, notice: t(\"activerecord.models.spree/order\") + t(\"messages.successfully_created\") }\n format.json { render :show, status: :created, location: @spree_order }\n else\n format.html { render :new }\n format.json { render json: @spree_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'La commande a été créée avec succès.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: \"Don't think you're going to be there when we deliver? Leave cash in an envelope outside your door. Otherwise, we'll see you in person!\" }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n\n @order.order_type = Order::TYPE[:b2c]\n @order.status = Order::STATUS[:waiting]\n @order.unit = current_user.unit\n @order.storage = current_storage\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_order(params)\n camelcase_params!(params)\n call_api('NewOrder', params)\n end",
"def create\n\t\t@order = Order.new(order_params)\n\t\t@order.user_id = current_user.id\n\t\t@order.order_date = Time.now\n\t\t@order.status = 1\n\n\t\trespond_to do |format|\n\t\t\tif @order.save\n\t\t\t\tformat.html { redirect_to @order, notice: 'Order was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @order }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @order.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n persist_order_address\n format.html { redirect_to [:admin, @order], notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = current_user.orders.new(params[:order])\n @order.add_line_items_from_cart(current_cart)\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to(\"http://cs410.cs.ualberta.ca:42001/paybuddy/payment.cgi?grp=5&amt=#{@order.total_price}&tx=#{@order.id}&ret=#{paid_url}\") }\n format.json { render json: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to admin_order_path(@order), notice: 'Order was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def create_order(options)\n request :account, :post, 'order', options\n end",
"def create\n @order = Order.new\n if @order.save\n flash[:success] = \"Elemento creado con exito\"\n redirect_to @order\n else\n render 'new'\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to home_path, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n @order.submitted_by_id = current_user.id\n respond_to do |format|\n if @order.save\n format.html { redirect_to orders_url, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to orders_url, notice: 'Dati commessa caricati.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n puts \"======ENTERING ORDER CREATE ROUTINE===\"\n\n @order = Order.new(order_params)\n\n puts \"=====EXECUTED ORDER.new ===============\"\n\n @order.user_id = current_user.id\n\n puts \"===Retrieving LINE_ITEMS in Order.create==============\"\n if user_signed_in? \n @line_items = LineItem.all.where(user: current_user).order(\"created_at DESC\")\n else\n @line_items = LineItem.all.where(user: 0)\n end\n\n @line_item = @line_items.first\n @order.delivery_date = @line_item.delivery_date\n @order.total_price = @line_items.to_a.sum { |item| item.unit_price(item.quantity) }\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => ( 11.99 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for ordering!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n \n puts \"=======Entering Order.save=====\"\n\n respond_to do |format|\n if @order.save\n \n puts \"=====EXECUTED ORDER.new Order Id is #{@order.id}\"\n LineItem.where(:user_id => current_user).update_all(\"order_id = #{@order.id}\")\n\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n\n format.html { redirect_to store_index_path, notice: 'Thank you for your order.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n # sets the current order to be the new order which the current customer is creating\n @order = current_customer.orders.new\n end",
"def create\n @order = Order.new(order_params)\n @order.user = current_user\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \tredirect_to orders_url\n# @order = Order.new(params[:order])\n\n# respond_to do |format|\n# if @order.save\n# format.html { redirect_to @order, notice: 'Order was successfully created.' }\n# format.json { render json: @order, status: :created, location: @order }\n# else\n# format.html { render action: \"new\" }\n# format.json { render json: @order.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def create\n @order = current_user.orders.build(order_params)\n\n respond_to do |format|\n if @order.save_with_items(current_user)\n format.json { render json: @order, status: :created }\n format.html { redirect_to @order }\n else\n format.html do\n set_feed_back\n set_addresses_add_express_fee\n\n set_wx_cards\n\n flash.now[:error] = @order.errors.full_messages.join(', ')\n\n render :confirmation, status: :unprocessable_entity\n end\n\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = current_user.orders.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Create the order \n @order = Order.new\n @email = params[:email]\n \n # Invoke the customer service to retrieve the customer id using the customers\n customerCode, customer = Customer_Service.getCustomerByEmail(@email)\n \n # Check to make sure the customer can be found\n if customerCode != 200\n render json: { error: \"Customer could not be found. \", status: 400 }\n return\n end\n \n # Invoke the item service to retrieve the item information\n orderCode, item = Item_Service.getItemById(params[:itemId])\n # Check to see if the item can be found\n if orderCode != 200\n render json: { error: \"Item could not be found\", status: 400 }\n return\n end\n # Check to see if the item is in stock\n if item[:stockQty] <= 0\n render json: { error: \"Item is out of stock\", status: 400 }\n return\n end\n \n \n # Construct the object\n @order.itemId = params[:itemId]\n @order.description = item[:description]\n @order.customerId = customer[:id]\n @order.price = item[:price]\n @order.award = customer[:award]\n @order.total = @order.price - @order.award\n \n # Check to see if the order can be saved\n if @order.save\n # Save the order to the customer and save it to the item\n tempCode = Customer_Service.postOrder(@order)\n tempCode = Item_Service.postOrder(@order)\n render json: @order, status: 201\n else\n render json: @order.errors, status: 400\n end\n \n end",
"def create\n if params[:order][:id]\n build do\n message 'Повторый заказ'\n order Order.create_order_from_order(params[:order][:id])\n view 'consumer/orders/show'\n end\n elsif Order.create_orders_from_cart(params[:cart_id], current_user)\n build do\n message 'Создание заказов'\n view 'consumer/orders/create'\n end\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def create\n @order = Order.new(items: items, promocode: promocode_params[:promocode])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to new_order_path, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@customer = current_customer\n @order = Order.new(params[:order].merge!({:customer_id => @customer.id}))\n\t\t@order.add_line_items_from_cart(current_cart)\n\t\n respond_to do |format|\n if @order.save\n\t\t\t\tCart.destroy(session[:cart_id])\n\t\t\t\tsession[:cart_id] = nil\n\t\t\t\tNotifier.order_received(@order).deliver\n format.html { redirect_to(store_url, :notice => I18n.t('.thanks')) }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@admin_order = Admin::Order.new(order_params)\n\n\t\trespond_to do |format|\n\t\t\tif @admin_order.save\n\t\t\t\tif params[:order_update].present?\n\t\t\t\t\tformat.html { redirect_to edit_admin_order_path(@admin_order), notice: 'Pedido criado com sucesso.'}\n\t\t\t\telse\n\t\t\t\t\tformat.html { redirect_to @admin_order, notice: 'Pedido criado com sucesso.' }\n\t\t\t\t\tformat.json { render json: @admin_order, status: :created, location: @admin_order }\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @admin_order.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @order = Order.new(order_params)\n @order.user_id = current_user.id\n @order.provider_id = current_user.default_provider_id\n respond_to do |format|\n if @order.save\n format.html { redirect_to orders_path, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.create(order_params.merge(user_id: current_user.id))\n process_order_items\n\n if @order.save\n OrderNotifier.kitchen(@order).deliver_now\n OrderNotifier.customer(@order).deliver_now\n else\n invalid_request\n end\n end",
"def create\n @order = Order.create(order_params.merge(user_id: current_user.id))\n process_order_items\n\n if @order.save\n OrderNotifier.kitchen(@order).deliver_now\n OrderNotifier.customer(@order).deliver_now\n else\n invalid_request\n end\n end",
"def create\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: { order_id: @order.id }, status: :ok }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n prize = Prize.find( params[:prize_id] )\n @order = prize.orders.new( params[:order] )\n\n respond_to do |format|\n if @order.save\n flash[:notice] = 'Order was successfully created.'\n format.html { redirect_to(orders_path) }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @payment_order = PaymentOrder.new(payment_order_params)\n\n respond_to do |format|\n if @payment_order.save\n format.html { redirect_to @payment_order, notice: t('payment_orders.success_create') }\n format.json { render :show, status: :created, location: @payment_order }\n else\n format.html { render :new }\n format.json { render json: @payment_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to root_path, notice: 'Order berhasil, tunggu untuk konfirmasi selanjutnya' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order.attributes = order_params\n if !session[:promocode_id].nil?\n @order.promocode_id = session[:promocode_id]\n end\n\n respond_to do |format|\n if @order.save\n session[:order_id] = @order.id\n format.html { redirect_to new_charge_path}\n #format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n \n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, :print => 'true' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_stripe\n # Order created by promotions#order and passed to merchant/orders/order_form\n # Cases: 1) not a customer; saving card\n # 2) not a customer; not saving card\n # 3) customer; using saved card\n # 4) customer; using new card and saving it\n # 5) customer; using new card and not saving it\n #\n # NOTE: I'm saving the associated user object in the orders controller, instead of trying to do it in the User model\n # I think it makes more sense to isolate all the Stripe stuff here, than have it scattered through models.\n # I also removed Stripe code from the Order model. It is all in the controller and User model (where it belongs).\n\n @stripe_customer = @order.user.stripe_customer_obj\n\n # Calculate total charge, adjusting for macho bucks. Do we need to charge the card?\n total_charge = @order.total_cost - @order.user.total_macho_bucks\n if total_charge > 0\n # We need to charge the credit card \n if @stripe_customer.nil?\n charge_success = false\n \n if params[:save_card] == 'true'\n # case 1\n @stripe_customer = Stripe::Customer.create(:email => @order.email,\n :description => @order.description,\n :card => @order.stripe_card_token)\n \n # Not in attr_accessible for security; must assign explicitly\n @order.user.stripe_id = @stripe_customer.id\n if @order.user.save\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n else\n flash[:notice] = \"Card could not be saved.\"\n charge_success = charge_card(@order, total_charge)\n end\n else \n # case 2\n charge_success = charge_card(@order, total_charge)\n end\n else\n # get existing customer\n if params[:new_card] == 'true'\n if params[:save_card] == 'true'\n # case 4\n # Update the card information for an existing customer\n @stripe_customer.card = @order.stripe_card_token\n @stripe_customer.save\n \n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n else\n # case 5\n charge_success = charge_card(@order, total_charge)\n end\n else\n # case 3\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n end\n end\n else\n # No charge necessary\n charge_success = true\n # Validated, so it has to be there\n @order.transaction_id = Order::MACHO_BUCKS_TRANSACTION_ID\n end\n \n # Charge operation should either succeed or throw an exception\n if charge_success\n # If the charge was successful, order will have charge_id (validated on save)\n if @order.save\n # After saving the order, create the associated vouchers using the promotion strategy\n # status defaults to Available; uuid is created upon save\n if @order.promotion.strategy.generate_vouchers(@order)\n flash[:notice] = I18n.t('order_successful')\n \n # If everything worked (voucher(s) saved), send the email\n # Products are handled differently in the mailer\n UserMailer.delay.promotion_order_email(@order)\n @order.user.log_activity(@order)\n \n # Debit the Macho Bucks. Usually 0, but possible they had more bucks than it cost\n # In the pathological case where they have negative macho bucks, the card was charged extra. That has to be cleared as well.\n # So we have to check for != 0, not > 0\n if @order.user.total_macho_bucks != 0\n deduction = @order.user.total_macho_bucks < 0 ? @order.user.total_macho_bucks : [@order.user.total_macho_bucks, @order.total_cost].min\n bucks = @order.build_macho_buck(:user_id => @order.user.id, :amount => -deduction, :notes => \"Credited on order: #{@order.description}\")\n if !bucks.save\n flash[:alert] = 'Unable to apply macho bucks!'\n end\n UserMailer.delay.macho_bucks_order_email(bucks)\n end\n \n redirect_to merchant_order_path(@order) and return\n end\n else\n @order.errors.add :base, \"Could not save order.\"\n end\n end\n\n # Should never get here, put theoretically possible if orders don't validate somehow; avoid template error\n render 'new' \n \n # Don't need a begin inside a def\n rescue Stripe::InvalidRequestError => error\n logger.error \"Stripe error while creating customer: #{error.message}\"\n @order.errors.add :base, \"There was a problem with your credit card. #{error.message}\"\n @promotion = @order.promotion\n render 'promotions/order'\n \n rescue Stripe::CardError => error\n logger.error \"Stripe error: #{error.message}\"\n @order.errors.add :base, \"There was a problem with your credit card. #{error.message}\"\n @promotion = @order.promotion\n render 'promotions/order'\n end",
"def create_order(order)\n # response = post(\n # 'peatio/market/orders',\n # {\n # market: order.market.downcase,\n # side: order.side.to_s,\n # volume: order.amount,\n # price: order.price\n # }\n # )\n\n return if order.amount < 1e-8\n od = build_order(order)\n return if od.nil?\n\n# Arke::Log.debug \"Skip order creation #{od.to_json}\\n#{order.inspect}\"\n Ordering.new(od).submit\n @open_orders.add_order(order, od.id) if od.id\n Arke::Log.debug \"Order created #{od.to_json}\"\n\n # @open_orders.add_order(order, response.env.body['id']) if response.env.status == 201 && response.env.body['id']\n\n # response\n end",
"def new\n @order = Order.new\n\n end",
"def create\n @admin_order = Order.new(params[:admin_order])\n\n respond_to do |format|\n if @admin_order.save\n format.html { redirect_to @admin_order, notice: 'Order was successfully created.' }\n format.json { render json: @admin_order, status: :created, location: @admin_order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n \n if @order.save\n\n redirect_to(:action=>'new',:orderId=>@order.id)\n\n else\n render :new\n\n end\n end",
"def create_order\n @order = Order.find(params[:order_id])\n @tire_listing = TireListing.find(params[:tire_listing_id])\n\n # can we find it? If not we need to recreate it.\n if !@order.stripe_buyer_customer_token.blank?\n begin\n @customer = Stripe::Customer.retrieve(@order.stripe_buyer_customer_token)\n rescue Exception => e\n # could not retrieve the customer record, so let's just re-create the customer\n @customer = nil \n @order.stripe_buyer_customer_token = \"\"\n end\n end\n\n if @order.stripe_buyer_customer_token.blank?\n begin\n @customer = Stripe::Customer.create(:card => params[:stripeToken], :description => params[:email])\n rescue Exception => e\n @order.destroy\n redirect_to @order.tire_listing, notice: \"There was an error with your data - message: #{e.to_s}\"\n return\n end\n @order.stripe_buyer_customer_token = @customer.id\n @order.uuid = SecureRandom.uuid\n elsif @customer.nil?\n @customer = Stripe::Customer.retrieve(@order.stripe_buyer_customer_token)\n end\n\n stripe_buyer_customer_cc_token = @customer.default_source #@customer.active_card.id\n @order.buyer_name = @customer.sources.first.name #@customer.active_card.name\n @order.buyer_email = params[:email]\n @order.buyer_phone = params[:phone]\n @order.notify_buyer_with_text = params[:notify_buyer_via_text]\n @order.buyer_address1 = @customer.sources.first.address_line1 #@customer.active_card.address_line1\n @order.buyer_city = @customer.sources.first.address_city #@customer.active_card.address_city\n @order.buyer_state = @customer.sources.first.address_state #@customer.active_card.address_state\n @order.buyer_zip = @customer.sources.first.address_zip #@customer.active_card.address_zip\n\n @order.status = order_status_array[:ready_for_billing]\n @order.save\n\n @order.delay.bill_order\n\n flash[:alert] = 'Your credit card will be billed shortly. It is important for you to schedule an appointment time now to complete the order. You will receive a confirmation email in 10 minutes -OR- after scheduling your appointment.'\n redirect_to :action => :new, :controller => :appointments, :tire_store_id => @order.tire_listing.tire_store_id, :tire_listing_id => @order.tire_listing_id, :order_id => @order.id, :order_uuid => @order.uuid\n end",
"def create\n @order = WebOrder.new(order_params)\n respond_to do |format|\n if @order.save\n @order.payments.create(total_paid: params[:initial], kind: :initial, date: @order.date) if params[:initial] && params[:initial].to_i != 0\n format.html { redirect_to order_path(@order.id), notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { redirect_to new_order_path }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to(@order, :notice => 'Order was successfully created.') }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if order.save\n format.html { redirect_to order, notice: 'Order was successfully created.' }\n format.json { render json: order, status: ':created', location: order }\n else\n format.html { render action: 'new' }\n format.json { render json: order.errors, status: ':unprocessable_entity' }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n flash[:notice] = 'Order was successfully created.'\n format.html { redirect_to order_url(@order) }\n format.xml { head :created, :location => order_url(@order) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors.to_xml }\n end\n end\n end",
"def create\n params[:order][:amount] = params[:amount]\n params[:order][:duration] = params[:duration]\n @order = Order.new(params[:order])\n params[:order][:name] = params[:order][:first_name] + \" \" + params[:order][:last_name] unless params[:order].blank?\n Rails.logger.info params.inspect\n @order.user = current_user\n host = request.instance_variable_get(:@env)[\"HTTP_HOST\"]\n\n respond_to do |format|\n if @order.save\n session[:order] = @order.id\n if @order.purchase\n UserMailer.payment_confirmation(@order,host).deliver\n session[:order] = @order.id\n format.html { render :action => \"success\"}\n else\n UserMailer.order_failure_confirmation(@order,host).deliver\n format.html { render :action => \"failure\"}\n end\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @order = signed_in? ? current_user.orders.new(params[:order]) : Order.new(params[:order])\n if @order.save\n flash[:info] = \"Order placed for #{@order.name} in bunk #{@order.bunk} for #{@order.white} white, #{@order.orange} orange, and #{@order.blue} blue frisbees.\"\n if @order.paid\n flash[:success] = \"#{@order.name} paid $#{@order.price}.\"\n else\n flash[:danger] = \"Remeber to bring $#{@order.price} when you pick up your discs.\"\n end\n redirect_to root_path\n else\n render 'new'\n end\n end",
"def create_new_cart_upon_submit()\n new_order = Order.create()\n return new_order\n end",
"def create\n @order = Order.new(order_params)\n @order.status = \"Pending\"\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @order = Order.new\n end",
"def new\n @order = Order.new\n end",
"def new\n @order = Order.new\n end",
"def new\n @order = Order.new\n end",
"def new\n @order = Order.new\n end",
"def new\n @order = Order.new\n end",
"def create\n\t\tisuser = params[:order][:user_id]\n\t\tif isuser.nil?\n\t\t\t@user = current_user\n\t\telse\n\t\t\t@user = User.find_by(id: isuser.to_i)\n\t\tend\n\t\t@order = @user.orders.build(order_params)\n\t\t\n\t\tif @order.name.blank?\n\t\t\t@order.name = 'unnamed'\n\t\tend\n\t\t\n\t\tif @order.save\n\t\t\tflash[:success] = \"Order created!\"\n\t\t\tredirect_to @user and return\n\t\telse\n#\t\t\tdebugger\n\t\t\tflash[:danger] = \"Order failed, not saved\"\n\t\t\tredirect_to new_order_path and return # was render 'new'\n\t\tend\n\tend",
"def create\n order = Order.create(order_params)\n if order.save\n render json: order\n else\n render new\n end\n end"
] | [
"0.8045561",
"0.79558164",
"0.7946343",
"0.7864079",
"0.78072095",
"0.7766064",
"0.77429366",
"0.77403486",
"0.7728683",
"0.7719493",
"0.7719493",
"0.7719493",
"0.7719493",
"0.7716423",
"0.7716423",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77149415",
"0.77044594",
"0.7692209",
"0.76845795",
"0.76808995",
"0.76613736",
"0.76562333",
"0.765527",
"0.76505923",
"0.7639169",
"0.76190203",
"0.761785",
"0.7613199",
"0.76110643",
"0.75852317",
"0.75851095",
"0.7572302",
"0.7566753",
"0.75635314",
"0.75585765",
"0.7555817",
"0.75556624",
"0.75395554",
"0.7534461",
"0.75293946",
"0.75279486",
"0.7516587",
"0.750855",
"0.75039655",
"0.7496734",
"0.7493162",
"0.74851245",
"0.7473585",
"0.74726933",
"0.74563634",
"0.7456123",
"0.7455122",
"0.7438907",
"0.74100465",
"0.7408986",
"0.74043345",
"0.7390446",
"0.73895943",
"0.73838353",
"0.7378489",
"0.7368946",
"0.73599935",
"0.73599935",
"0.7358587",
"0.73524165",
"0.7341956",
"0.7339958",
"0.7332482",
"0.7323332",
"0.7317583",
"0.73168564",
"0.73061395",
"0.730591",
"0.73019975",
"0.7300859",
"0.73002326",
"0.7296344",
"0.7294778",
"0.728798",
"0.7285849",
"0.72853863",
"0.728353",
"0.72822213",
"0.7280583",
"0.7280583",
"0.7280583",
"0.7280583",
"0.7280583",
"0.7280583",
"0.72780865",
"0.72540104"
] | 0.0 | -1 |
successfully finds: blogspot pages, vbulletin, microtik routers, ning sites, also identifies stuff like various types of 404s, virtual directory listings not allowed, apache default expect some noise. 100 matched too much, 1000 matched too litte. 500 is ok | def passive
if @body.size > 4
hash=Digest::MD5.hexdigest(@body[0..500])
[{:name=>"hash",:string=>hash}]
else
[]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(pages)\n robot = Robots.new USER_AGENT\n until pages.nil? or pages.empty?\n newfound_pages = []\n pages.each { |page|\n begin\n if add_to_index?(page) then\n uri = URI.parse(page)\n host = "#{uri.scheme}://#{uri.host}"\n open(page, "User-Agent" => USER_AGENT) { |s|\n (Hpricot(s)/"a").each { |a|\n url = scrub(a.attributes['href'], host)\n newfound_pages << url unless url.nil? or !robot.allowed? url or newfound_pages.include? url\n }\n }\n end\n rescue => e\n print "\\n** Error encountered crawling - #{page} - #{e.to_s}"\n rescue Timeout::Error => e\n print "\\n** Timeout encountered - #{page} - #{e.to_s}"\n end\n }\n pages = newfound_pages\n File.open(LAST_CRAWLED_PAGES, 'w') { |out| YAML.dump(newfound_pages, out) }\n end",
"def search_page(url, agent, keywords, depth, log_level=1)\n begin\n page = agent.get(url.to_s.downcase) # agent acquires the page.\n rescue => e\n puts \"Get page: #{e}\"\n return \"page not found\"\n end\n if !((sf = find_software(keywords, page, agent)) || depth == 0)\n if !page.nil?\n link_array = []\n puts \"... iterate over #{page.links.count} links\" if log_level>1\n page.links.each do |link| # Loops through each link and appends it to the link array to be searched.\n if link.href.to_s != '' && !link.href.index(' ')\n puts \"... ... adding #{link.href}\" if log_level>1 # Optional logging\n begin\n if link.href.to_s.index(\"http\") == 0\n link_array << link.href\n else\n puts page.uri.to_s + \" : \" + link.href.to_s if log_level>1\n link_array << URI.join(page.uri, link.href).to_s\n end\n rescue => e\n puts \"link loop: #{e}\"\n end\n end\n end\n for page_url in link_array.uniq # Performs search_page on each link in link_array\n if !\"#{page_url}\".match(/(mailto:|javascript|facebook|instagram|twitter|yelp|youtube|plus.google|pinterest|vimeo|buckley.af|tel:1800|tel:1-800)/)\n puts \"... checking #{page_url}\" if log_level > 0\n sf = search_page(page_url, agent, keywords, depth-1, log_level) # depth-1 so the function won't call itself forever\n #if sf == \"none found\" || \"page not found\"\n #doc = Nokogiri::HTML(open(page_url))\n # Input function for searching iFrame\n #end\n break if ![\"none found\",\"page not found\"].index(sf) # Breaks out of loop if sf isn't \"none found\" or \"page not found\"\n sf = nil\n end\n end\n end\n end\n return sf || \"none found\" # Returns software (sf) or \"none found\"\nend",
"def analyze_404\n selected_files.each do |file_name|\n result = [file_name[0,6], 0, 0]\n url = ''\n File.readlines(file_name).each do |line|\n if m = /Started(.*?)for/.match(line)\n url = m[1]\n end\n if m = /404/.match(line)\n p url.gsub('\"','')\n end\n end\n end\nend",
"def crawler_process_page(t, page, cnt)\n msg = \"[#{\"%.5d\" % cnt}/#{\"%.5d\" % max_page_count}] #{page.code || \"ERR\"} - #{t[:vhost]} - #{page.url}\"\n case page.code\n when 301,302\n if page.headers and page.headers[\"location\"]\n print_status(msg + \" -> \" + page.headers[\"location\"].to_s)\n else\n print_status(msg)\n end\n when 500...599\n # XXX: Log the fact that we hit an error page\n print_good(msg)\n when 401,403\n print_good(msg)\n when 200\n print_status(msg)\n when 404\n print_error(msg)\n else\n print_error(msg)\n end\n\n #\n # Process the web page\n #\n\n info = {\n :web_site => t[:site],\n :path => page.url.path,\n :query => page.url.query,\n :code => page.code,\n :body => page.body,\n :headers => page.headers\n }\n\n if page.headers['content-type']\n info[:ctype] = page.headers['content-type']\n end\n\n if !page.cookies.empty?\n info[:cookie] = page.cookies\n end\n\n if page.headers['authorization']\n info[:auth] = page.headers['authorization']\n end\n\n if page.headers['location']\n info[:location] = page.headers['location']\n end\n\n if page.headers['last-modified']\n info[:mtime] = page.headers['last-modified']\n end\n\n # Report the web page to the database\n report_web_page(info)\n\n # Only process interesting response codes\n return if not [302, 301, 200, 500, 401, 403, 404].include?(page.code)\n\n #\n # Skip certain types of forms right off the bat\n #\n\n # Apache multiview directories\n return if page.url.query =~ /^C=[A-Z];O=/ # Apache\n\n forms = []\n form_template = { :web_site => t[:site] }\n\n if form = form_from_url( t[:site], page.url )\n forms << form\n end\n\n if page.doc\n page.doc.css(\"form\").each do |f|\n\n target = page.url\n\n if f['action'] and not f['action'].strip.empty?\n action = f['action']\n\n # Prepend relative URLs with the current directory\n if action[0,1] != \"/\" and action !~ /\\:\\/\\//\n # Extract the base href first\n base = target.path.gsub(/(.*\\/)[^\\/]+$/, \"\\\\1\")\n page.doc.css(\"base\").each do |bref|\n if bref['href']\n base = bref['href']\n end\n end\n action = (base + \"/\").sub(/\\/\\/$/, '/') + action\n end\n\n target = page.to_absolute(URI( action )) rescue next\n\n if not page.in_domain?(target)\n # Replace 127.0.0.1 and non-qualified hostnames with our page.host\n # ex: http://localhost/url OR http://www01/url\n target_uri = URI(target.to_s)\n if (target_uri.host.index(\".\").nil? or target_uri.host == \"127.0.0.1\")\n target_uri.host = page.url.host\n target = target_uri\n else\n next\n end\n end\n end\n\n # skip this form if it matches exclusion criteria\n if !(target.to_s =~ get_link_filter)\n form = {}.merge!(form_template)\n form[:method] = (f['method'] || 'GET').upcase\n form[:query] = target.query.to_s if form[:method] != \"GET\"\n form[:path] = target.path\n form[:params] = []\n f.css('input', 'textarea').each do |inp|\n form[:params] << [inp['name'].to_s, inp['value'] || inp.content || '', { :type => inp['type'].to_s }]\n end\n\n f.css( 'select' ).each do |s|\n value = nil\n\n # iterate over each option to find the default value (if there is a selected one)\n s.children.each do |opt|\n ov = opt['value'] || opt.content\n value = ov if opt['selected']\n end\n\n # set the first one as the default value if we don't already have one\n value ||= s.children.first['value'] || s.children.first.content rescue ''\n\n form[:params] << [ s['name'].to_s, value.to_s, [ :type => 'select'] ]\n end\n\n forms << form\n end\n end\n end\n\n # Report each of the discovered forms\n forms.each do |form|\n next if not form[:method]\n print_status((\" \" * 24) + \"FORM: #{form[:method]} #{form[:path]}\")\n report_web_form(form)\n self.form_count += 1\n end\n\n @for_each_page_blocks.each { |p| p.call( page ) }\n end",
"def process(pages)\n robot = Robots.new USER_AGENT\n until pages.nil? or pages.empty? \n newfound_pages = []\n pages.each { |page|\n begin\n if add_to_index?(page) then \n uri = URI.parse(page)\n host = \"#{uri.scheme}://#{uri.host}\"\n open(page, \"User-Agent\" => USER_AGENT) { |s|\n (Hpricot(s)/\"a\").each { |a| \n url = scrub(a.attributes['href'], host)\n newfound_pages << url unless url.nil? or !robot.allowed? url or newfound_pages.include? url\n }\n } \n end\n rescue => e \n print \"\\n** Error encountered crawling - #{page} - #{e.to_s}\"\n rescue Timeout::Error => e\n print \"\\n** Timeout encountered - #{page} - #{e.to_s}\"\n end\n }\n pages = newfound_pages\n File.open(LAST_CRAWLED_PAGES, 'w') { |out| YAML.dump(newfound_pages, out) }\n end \n end",
"def check_for_hits(url)\n \n response = http_fetch(url).body\n\n response_html = Nokogiri::HTML(response)\n\n title = response_xml.at('title').inner_text\n # title is \"X documents\" (or 'Documents') if there are hits.\n # It's annoyingly \"Search Error\" if there are either 0 hits, or\n # if there was an actual error. So we can't easily log actual\n # errors, sorry.\n title.downcase =~ /^\\s*(\\d+)?\\s+document/\n if ( hits = $1)\n return hits.to_i\n else\n return 0\n end \n end",
"def url_redirect_checker\n require 'curb'\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(crm_url_redirect: nil)\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(geo_url_redirect: nil)[20...-1]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%http%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%www%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where.not(\"raw_url LIKE '%www%'\")[a...z]\n # Indexer.where.not(\"redirect_status LIKE '%Error%'\")\n\n # a=0\n # z=-1\n\n indexers = Indexer.where(indexer_status: \"COP URL\").where(clean_url: nil)[a...z] ##17,033\n\n\n counter_fail = 0\n counter_result = 0\n total = 0\n indexers.each do |indexer|\n total +=1\n\n raw_url = indexer.raw_url\n\n begin ## rescue\n result = Curl::Easy.perform(raw_url) do |curl|\n curl.follow_location = true\n curl.useragent = \"curb\"\n curl.connect_timeout = 10\n curl.enable_cookies = true\n # curl.ssl_verify_peer = false\n end\n\n curb_url_result = result.last_effective_url\n\n crm_url_hash = url_formatter(curb_url_result)\n raw_url_final = crm_url_hash[:new_url]\n\n if raw_url != raw_url_final\n counter_result +=1\n puts\n puts \"[#{a}...#{z}] (#{counter_result}/#{total})\"\n puts \"O: #{raw_url}\"\n puts \"N: #{raw_url_final}\"\n puts \"--------------------------------------------\"\n puts\n indexer.update_attributes(redirect_status: \"Updated\", clean_url: raw_url_final)\n else\n puts \"[#{a}...#{z}] (#{total}): Same\"\n indexer.update_attributes(redirect_status: \"Same\", clean_url: raw_url_final)\n end\n\n rescue #begin rescue\n error_message = $!.message\n counter_fail +=1\n final_error_msg = \"Error: #{error_message}\"\n puts \"(#{counter_fail}/#{total}) (#{final_error_msg})\"\n\n if final_error_msg && final_error_msg.include?(\"Error:\")\n if final_error_msg.include?(\"SSL connect error\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"SSL Error\")\n elsif final_error_msg.include?(\"Couldn't resolve host name\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Host Error\")\n elsif final_error_msg.include?(\"Peer certificate\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Certificate Error\")\n elsif final_error_msg.include?(\"Failure when receiving data\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Transfer Error\")\n else\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Error\")\n end\n end\n end #end rescue\n end\n end",
"def check_wildcard(suffix)\n _log \"Checking for wildcards on #{suffix}.\"\n all_discovered_wildcards = []\n\n # First check if we can even get a reliable result\n timeout_count = 0\n 10.times do\n random_string = \"#{(0...8).map { (65 + rand(26)).chr }.join.downcase}.#{suffix}\"\n\n # keep track of timeouts\n _log \"Checking: #{random_string}\"\n timeout_count += 1 if check_resolv_sanity random_string\n end\n\n # fail if most timed out\n if timeout_count > 5\n _log_error \"More than 50% of our wildcard checks timed out, cowardly refusing to continue\"\n return nil\n end\n\n # first, check wordpress....\n # www*\n # ww01*\n # web*\n # home*\n # my*\n check_wordpress_list = []\n [\"www.doesntexist.#{suffix}\",\"ww01.#{suffix}\",\"web1.#{suffix}\",\"hometeam.#{suffix}\",\"myc.#{suffix}\"].each do |d|\n resolved_address = _resolve(d)\n check_wordpress_list << resolved_address\n #unless resolved_address.nil? || all_discovered_wildcards.include?(resolved_address)\n # all_discovered_wildcards << resolved_address\n #end\n end\n\n if check_wordpress_list.compact.count == 5\n _log \"Looks like wordpress-connected domain\"\n all_discovered_wildcards = check_wordpress_list\n end\n\n # Now check for wildcards\n 10.times do\n random_string = \"#{(0...8).map { (65 + rand(26)).chr }.join.downcase}.#{suffix}\"\n\n # do the resolution\n # www.shopping.intrigue.io - 198.105.244.228\n # www.search.intrigue.io - 198.105.254.228\n resolved_address = _resolve(random_string)\n\n # keep track of it unless we already have it\n unless resolved_address.nil? || all_discovered_wildcards.include?(resolved_address)\n all_discovered_wildcards << resolved_address\n end\n\n end\n\n # If that resolved, we know that we're in a wildcard situation.\n #\n # Some domains have a pool of IPs that they'll resolve to, so\n # let's go ahead and test a bunch of different domains to try\n # and collect those IPs\n if all_discovered_wildcards.uniq.count > 1\n _log \"Multiple wildcard ips for #{suffix} after resolving these: #{all_discovered_wildcards}.\"\n _log \"Trying to create an exhaustive list.\"\n\n # Now we have to test for things that return a block of addresses as a wildcard.\n # we to be adaptive (to a point), so let's keep looking in chuncks until we find\n # no new ones...\n no_new_wildcards = false\n\n until no_new_wildcards\n _log \"Testing #{all_discovered_wildcards.count * 20} new entries...\"\n newly_discovered_wildcards = []\n\n (all_discovered_wildcards.count * 20).times do |x|\n random_string = \"#{(0...8).map { (65 + rand(26)).chr }.join.downcase}.#{suffix}\"\n resolved_address = _resolve(random_string)\n\n # keep track of it unless we already have it\n unless resolved_address.nil? || newly_discovered_wildcards.include?(resolved_address)\n newly_discovered_wildcards << resolved_address\n end\n end\n\n # check if our newly discovered is a subset of all\n if (newly_discovered_wildcards - all_discovered_wildcards).empty?\n _log \"Hurray! No new wildcards in #{newly_discovered_wildcards}. Finishing up!\"\n no_new_wildcards = true\n else\n _log \"Continuing to search, found: #{(newly_discovered_wildcards - all_discovered_wildcards).count} new results.\"\n all_discovered_wildcards += newly_discovered_wildcards.uniq\n end\n\n _log \"Known wildcard count: #{all_discovered_wildcards.uniq.count}\"\n _log \"Known wildcards: #{all_discovered_wildcards.uniq}\"\n end\n\n elsif all_discovered_wildcards.uniq.count == 1\n _log \"Only a single wildcard ip: #{all_discovered_wildcards.sort.uniq}\"\n else\n _log \"No wildcard detected! Moving on!\"\n end\n\n all_discovered_wildcards.uniq # if it's not a wildcard, this will be an empty array.\n end",
"def run\n super\n\n checks = [{ :path => \"robots.txt\", :signature => \"User-agent\" }]\n\n checks.each do |check|\n # Concat the uri to create the check\n url = \"#{@entity.name}/#{check[:path]}\"\n\n @task_logger.log \"Connecting to #{url} for #{@entity}\" \n\n # Grab a known-missing page so we can make sure it's not a \n # 404 disguised as a 200\n test_url = \"#{@entity.name}/there-is-no-way-this-exists-#{rand(10000)}\"\n missing_page_content = open_uri_and_return_content(test_url,@task_logger)\n\n # Do the request\n content = open_uri_and_return_content(url,@task_logger)\n\n # Check to make sure this is a legit page, and create an entity if so\n # TODO - improve the checking for wildcard page returns and 404-200's\n if content.include? check[:signature] and content != missing_page_content\n\n # for each line of the file\n content.each_line do |line|\n \n # don't add comments\n next if line =~ /^#/\n next if line =~ /^User-agent/\n\n # This will work for the following types\n # Disallow: /path/\n # Sitemap: http://site.com/whatever.xml.gz\n if line =~ /Sitemap/\n path = line.split(\" \").last.strip\n full_path = \"#{path}\"\n elsif line =~ /Disallow/\n path = line.split(\" \").last.strip\n full_path = \"#{@entity.name}#{path}\"\n end\n\n # otherwise create a webpate \n create_entity Entities::WebPage, { :name => full_path, :uri => full_path, :content => \"#{content}\" }\n end\n\n end\n\n end\n\nend",
"def check_site\n\t\t\tpage = @agent.get(@page[:url])\n\t\t\traise \"got redirected on #{@page[:name]}\" if redirect?\n\n\t\t\tdoc = Nokogiri::HTML(page.parser.to_s)\n\t\t\tnodes_with_euros = doc.search(\"//text()[contains(.,'€')]\")\n\t\t\tcontainers_array = []\n\t\t\traise \"no euros found #{@page[:name]}\" if nodes_with_euros == []\n\n\t\t\t# Previous version was with ruby, now xpath, less code. \n\t\t\tcontainers_array = nodes_with_euros.collect { |node| node.ancestors(\"//table | //div\").first } unless @page[:search_string]\n\n\t\t\tif @page[:search_string]\n\t\t\t\t#remove escapes\n\t\t\t\t@page[:search_string].gsub!(/\\\\/) { ''}\n\t\t\t\tcontainers_array << doc.search(\"//text()[contains(.,#{@page[:search_string]})]\").first\n\t\t\tend\n\n\t\t\t#Nodeset is an array, but doesn't act like one, really annoying.\n\t\t\tcontainers_nodeset = Nokogiri::XML::NodeSet.new(doc)\n\t\t\tcontainers_freqs = containers_array.inject(Hash.new(0)) { |h,v| h[v] += 1; h}\n\t\t\t\n\t\t\t# Refactored from double block\n\t\t\tcontainers_nodeset = containers_freqs.collect { |node,freq| freq > 1 ? node : nil }\n\t\t\tcontainers_nodeset.uniq!\n\t\t\traise \"no hits found in #{@page[:name]}\" if (containers_nodeset.empty? || containers_nodeset == [nil])\n\n\t\t\twrite_to_file(containers_nodeset)\n\t\t\t\n\t\trescue Timeout::Error => e\n\t\t\t# Only occures when site is down or script runs too often. So we try again once, then bail\n\t\t\tretry if @retry\n\t\t\t@retry = false\n\t\t\traise\n\t\trescue => e\n\t\t\thandle_me(e)\n\t\tend",
"def get_urls(proxy=nil)\n query = SETTINGS.extract_query!\n payloads = SETTINGS.create_payloads(PAYLOAD_TEMPLATE_PATH)\n File.read(\"#{QUERY_BLACKLIST_PATH}\").each_line do |black| # check if the search query is black listed\n if query == black\n FORMAT.warning(\"Query: #{query} is blacklisted, defaulting to random query\")\n query = File.readlines(\"#{PATH}/lib/lists/search_query.txt\").sample # Retry if it is\n end\n end\n\n FORMAT.info(\"I'm searching for possible SQL vulnerable sites, using search query #{query.chomp}\")\n agent = Mechanize.new\n if proxy\n agent.set_proxy(proxy.split(\":\").first, proxy.split(\":\").last) # Set your proxy if used\n end\n correct_agent = SETTINGS.random_agent?\n agent.user_agent = correct_agent\n\n correct_agent == DEFAULT_USER_AGENT ? FORMAT.info(\"Using default user agent\") :\n FORMAT.info(\"Grabbed random agent from #{RAND_AGENT_PATH}\")\n\n google_page = agent.get(\"http://google.com\")\n google_form = google_page.form('f')\n\n FORMAT.info(\"Verifying search query...\")\n unless SETTINGS.test_query(query, correct_agent, proxy)\n query = File.readlines(\"#{PATH}/lib/lists/search_query.txt\").sample\n LOGGER.info(\"Query changed to: #{query}\")\n end\n\n google_form.q = \"#{query}\" # Search Google for the query\n url = agent.submit(google_form, google_form.buttons.first)\n\n url.links.each do |link|\n if link.href.to_s =~ /url.q/ # Pull the links from the search\n str = link.href.to_s\n str_list = str.split(%r{=|&})\n urls = str_list[1]\n if urls.split(\"/\")[2].start_with?(*SKIP) # Skip all the bad URLs\n next\n end\n urls_to_log = URI.decode(urls)\n FORMAT.success(\"Site found: #{urls_to_log}\")\n sleep(0.3)\n payloads.each { |payload|\n File.open(\"#{SITES_TO_CHECK_PATH}\", \"a+\") { |to_check| to_check.puts(\"#{urls_to_log}#{payload}\")}\n }\n end\n end\n FORMAT.info(\"I've dumped possible vulnerable sites into #{SITES_TO_CHECK_PATH}\")\n end",
"def scan_pages(num_pages, url_pattern)\n returning([]) do |mentions|\n current_page = nil\n num_pages.times do |page_number|\n current_page = get_next_page(current_page)\n @log.info \"Scanning #{current_page.uri} for #{url_pattern}\"\n current_page.search('//tr[td[@class=\"title\"]]').each do |entry|\n link_anchor = entry.xpath('td[3]/a').first\n comment_anchor = entry.xpath(\"following-sibling::tr[1]/td[2]/a[2]\").first\n link = nil\n if(link_anchor)\n link = link_anchor['href']\n end\n if url_pattern === link && comment_anchor\n comment_url = comment_anchor['href']\n mentions << Preen::Mention.new(link, comment_url)\n end\n end\n end\n end\n end",
"def visit_all links\n not_found = []\n server_error = []\n\n links.each do |link|\n puts \"visiting link: #{link}\"\n visit link\n\n grab_screen \"visited #{link}\"\n current_url.should == link\n\n if page.has_content?('404')\n not_found << link\n next\n end\n\n server_error << link if page.has_content?('500') || page.has_content?('rror') || page.has_content?('ception')\n end\n\n unless not_found.empty? && server_error.empty?\n fail \"The following links responded with status 404: #{not_found.inspect} and these responded with status 500: #{server_error}\"\n end\nend",
"def page404(pathname);end",
"def robots_error(url); end",
"def static_search(url, query)\n response = Faraday::Connection.new.get(url) do |request|\n request.headers = {\n user_agent: \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36\" }\n request.options.timeout = 5\n end\n\n status = response.status.to_i\n return nil unless status < 300\n\n formatted_content = ActionController::Base.helpers.strip_tags(response.body)\n formatted_content = formatted_content.squish.strip\n\n return formatted_content.scan(/.{#{InRailsWeBlog.settings.scrap_fragment_size}}\\b#{query}\\b.{#{InRailsWeBlog.settings.scrap_fragment_size}}/i)\n rescue StandardError\n return nil\n end",
"def dianping_search_shops(keywords,limit_query_pages)\n shops = []\n query_link = \"#{$DIANPING_SHOP_SEARCH_PATH_START_PAGE}#{URI.escape(keywords)}\"\n pages = DianpingPageParser.number_of_pages(query_link)\n \n puts pages\n \n max_page_to_crawl = (limit_query_pages.to_int < pages) ? limit_query_pages.to_int : pages\n \n (1..max_page_to_crawl).each { | page | shops << DianpingPageParser.shops_in_page(File.join(query_link, \"p#{page}\")) }\n \n return shops\nend",
"def run\n super\n\n # Base checklist\n to_check = [\n { :path => \"crossdomain.xml\", :signature => \"<?xml\" },\n { :path => \"elmah.axd\", :signature => \"Error Log for\" },\n { :path => \"phpinfo.php\", :signature => \"phpinfo()\" },\n { :path => \"robots.txt\", :signature => \"user-agent:\" },\n { :path => \"sitemap.xml\", :signature => \"<?xml\" },\n { :path => \"sitemap.xml.gz\", :signature => \"<?xml\" },\n ]\n\n # Add in un-sig'd checks \n unsig_checks = IO.readlines(\"#{Rails.root}/data/web.list\")\n unsig_check_list = unsig_checks.map { |x| { :path => x.chomp, :signature => \"\" } } \n to_check += unsig_check_list\n\n test_url = \"#{@entity.name}/there-is-no-way-this-exists-#{rand(10000)}\"\n missing_page_content = open_uri_and_return_content(test_url, @task_logger)\n\n # Run through the checks\n to_check.each do |check|\n\n # Concat the uri to create the check\n url = \"#{@entity.name}/#{check[:path]}\"\n @task_logger.log \"Connecting to #{url} for #{@entity}\" \n\n # Do the request\n content = open_uri_and_return_content(url,@task_logger)\n\n # Return if we didn't get anyting\n next unless content\n\n # Check to make sure this is a legit page, and create an entity if so\n # \n # Note that the signature is blank for unsig_checks\n #\n # TODO - improve the checking for wildcard page returns and 404-200's\n\n if content.include? check[:signature] and content != missing_page_content\n # create an entity if we match\n create_entity Entities::WebPage, { :name => \"#{url}\", :uri => \"#{url}\", :content => \"#{content}\" }\n end\n\n end\nend",
"def index_pages\n debug_msg \" generating pages search index\"\n\n pages = @files.select do |file|\n file.text?\n end\n\n pages.each do |page|\n debug_msg \" #{page.page_name}\"\n record = page.search_record\n @index[:searchIndex] << search_string(record.shift)\n @index[:longSearchIndex] << ''\n record.shift\n @index[:info] << record\n end\n end",
"def scan_site!\n add_pages_for_scan!\n while @pages_for_scan.size > 0\n page = convert_to_valid @pages_for_scan.pop\n next unless page\n @max_pages -= 1\n add_page convert_to_valid(page)\n return if @max_pages <= 0\n add_pages_for_scan!\n optimize_scan!\n end\n end",
"def run\n super\n\n uri = _get_entity_attribute \"name\"\n\n # Scanner options\n @opt_threads = _get_option(\"threads\").to_i\n @opt_max_pages = _get_option(\"max_pages\").to_i\n #@opt_user_agent = _get_option \"user_agent\"\n @opt_extract_uris = _get_option \"extract_uris\" # create an object for each page\n @opt_extract_dns_records = _get_option \"extract_dns_records\" # create an object for each dns_record\n @opt_extract_file_metadata = _get_option \"extract_file_metadata\" # create a Uri object for each page\n @opt_extract_patterns = _get_option(\"extract_patterns\").split(\",\") # only extract entities withthe following patterns\n\n crawl_and_extract(uri)\n\n end",
"def add_pages_for_scan!\n @pages_for_scan = []\n @bad_pages = []\n @pages.each do |page|\n @bad_pages << page.page_url unless page.page_a_tags\n next unless page.page_a_tags\n page.home_a.each do |link|\n @pages_for_scan << link\n end\n end\n end",
"def find(search_string)\n result_array = []\n search_words = search_string.split(/\\s+/)\n\n # Loop over all entries in the index.\n @data.each{ |entry|\n begin\n # Check whether this entry matches the search words.\n score = 0\n search_words.each{ |search_word|\n next if search_word.empty?\n\n s = 2 * AE::LaunchUp::Scorer.score(search_word, entry[:name]) if entry[:name].is_a?(String)\n s += 2 * AE::LaunchUp::Scorer.score(search_word, entry[:description]) if entry[:description].is_a?(String)\n s += 2 * AE::LaunchUp::Scorer.score(search_word, entry[:category]) if entry[:category].is_a?(String)\n s += exact_matches(search_word, entry[:keywords].join(\" \"))/(entry[:keywords].length|1).to_f if entry[:keywords].is_a?(Array) && !entry[:keywords].empty?\n s += 2 * AE::LaunchUp::Scorer.score(search_word, entry[:keywords].join(\" \")) if entry[:keywords].is_a?(Array)\n s += exact_matches( search_word.gsub(/\\/|\\\\/, \"\"), entry[:file].gsub(/\\/|\\\\/, \"\") ) if entry[:file].is_a?(String) && search_word.length > 4\n\n # Skip if no match has been found.\n break score = 0.0 if s == 0.0\n score += s\n }\n\n # Tweaks for relevance:\n # Entries with icons match better with users's expectation,\n # urls or \"about\" rather not.\n score *= 3 if entry[:icon].is_a?(String)\n #score *= 0.5 if entry[:name][/about|paypal/i] || entry[:description][/http/]\n\n # Check wether the command is available in the current context. We don't\n # want to reject it completely from the search results, so that the user\n # won't miss it in an explicit search will. We give a hint if it's disabled.\n if entry[:validation_proc]\n status = nil\n begin\n status = entry[:validation_proc].call == MF_ENABLED\n rescue LocalJumpError => e\n # Validation proc contains a \"return\"?\n $stderr.write(\"Validation proc of '#{entry[:name]}' (#{entry[:id]}) contains 'return'\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/)\n rescue Exception => e\n # Validation proc contains other bug.\n $stderr.write(\"Error in validation proc of '#{entry[:name]}' (#{entry[:id]})\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/) if $VERBOSE\n end\n entry[:enabled] = status\n score *= 0.5 if status == false\n end\n\n # Skip if no match has been found.\n next if score < 1.0\n\n # Consider tracking data, how often this entry has been selected over others:\n # Divide track by half of average track (total_track/data.length).\n score += [entry[:track] / (@total_track|1).to_f * 0.5 * @data.length, 5].min if entry[:track]\n entry[:score] = score\n\n # Add it to results.\n result_array << entry\n rescue Exception => e\n $stderr.write(\"AE::LaunchUp::Index: Error in 'find' when searching '#{entry[:name]}' (#{entry[:id]})\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/)\n break\n end\n }\n\n return result_array\n rescue Exception => e\n $stderr.write(\"AE::LaunchUp::Index: Error in 'find' when searching '#{search_string}'\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/)\n return []\n end",
"def get_urls\n Format.info(\"I'll run in default mode!\")\n Format.info(\"I'm searching for possible SQL vulnerable sites, using search query #{SEARCH}\")\n agent = Mechanize.new\n agent.user_agent = USER_AGENT\n page = agent.get('http://www.google.com/')\n google_form = page.form('f')\n google_form.q = \"#{SEARCH}\"\n url = agent.submit(google_form, google_form.buttons.first)\n url.links.each do |link|\n if link.href.to_s =~ /url.q/\n str = link.href.to_s\n str_list = str.split(%r{=|&})\n urls = str_list[1]\n #check_urls_for_blacklist(urls)\n urls_to_log = URI.decode(urls)\n Format.success(\"Site found: #{urls_to_log}\")\n sleep(1)\n %w(' ` -- ;).each { |sql|\n File.open(\"#{PATH}/tmp/SQL_sites_to_check.txt\", 'a+') { |s| s.puts(\"#{urls_to_log}#{sql}\") }\n }\n end\n end\n Format.info(\"I've dumped possible vulnerable sites into #{PATH}/tmp/SQL_sites_to_check.txt\")\nend",
"def test_solr_crawler_no_title\n @log.expects(:info).once.with('Indexed http://www.foo.com/foo.html').returns(nil)\n \n SolrIndexer.expects(:curl).with(regexp_matches(\n /--silent \"http:\\/\\/localhost:1234\\/update\\/extract\\?literal\\.id=8a3ca15ba2d277f677b4b2d3598ae57b&commit=true&literal\\.url=http%3A%2F%2Fwww.foo.com%2Ffoo.html\" -H 'Content-type%3Atext%2Fhtml' -F \"myfile=@/\n )).returns(true)\n \n url = 'http://www.foo.com/foo.html'\n \n add_expect_uri(url)\n assert_equal(1, crawl(params(url)).length, \"Crawled one url\")\n end",
"def add_to_index?(url)\n print "\\n- indexing #{url}"\n t0 = Time.now\n page = Page.find(scrub(url))\n \n # if the page is not in the index, then index it\n if page.new_record? then\n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts " [new] - (#{dsize.to_i} words)"\n doc_words.each_with_index { |w, l|\n printf("\\r\\e - %6.2f%",(l*100/dsize))\n loc = Location.new(:position => l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n }\n }\n \n # if it is but it is not fresh, then update it\n elsif not page.fresh? then\n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts " [refreshed] - (#{dsize.to_i} words)"\n page.locations.destroy!\n doc_words.each_with_index { |w, l|\n printf("\\r\\e - %6.2f%",(l*100/dsize))\n loc = Location.new(:position => l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n }\n }\n page.refresh\n \n #otherwise just ignore it\n else\n puts " - (x) already indexed"\n return false\n end\n t1 = Time.now\n puts " [%6.2f sec]" % (t1 - t0)\n return true\n end\n \n # scrub the given link\n def scrub(link, host=nil)\n unless link.nil? then\n return nil if DO_NOT_CRAWL_TYPES.include? link[(link.size-4)..link.size] or link.include? '?' or link.include? '/cgi-bin/' or link.include? '&' or link[0..8] == 'javascript' or link[0..5] == 'mailto'\n link = link.index('#') == 0 ? '' : link[0..link.index('#')-1] if link.include? '#'\n if link[0..3] == 'http'\n url = URI.join(URI.escape(link))\n else\n url = URI.join(host, URI.escape(link))\n end\n return url.normalize.to_s\n end\n end\n \n # do the common indexing work\n def index(url)\n open(url, "User-Agent" => USER_AGENT){ |doc|\n h = Hpricot(doc)\n title, body = h.search('title').text.strip, h.search('body')\n %w(style noscript script form img).each { |tag| body.search(tag).remove}\n array = []\n body.first.traverse_element {|element| array << element.to_s.strip.gsub(/[^a-zA-Z ]/, '') if element.text? }\n array.delete("")\n yield(array.join(" ").words, title)\n }\n end\nend\n \n$stdout.sync = true\nspider = Spider.new\nspider.start\n",
"def ping_search_engine(blog)\n # http://www.google.cn/intl/zh-CN/help/blogsearch/pinging_API.html\n # http://www.baidu.com/search/blogsearch_help.html\n baidu = XMLRPC::Client.new2(\"http://ping.baidu.com/ping/RPC2\")\n baidu.timeout = 5 # set timeout 5 seconds\n baidu.call(\"weblogUpdates.extendedPing\",\n APP_CONFIG['site_title'],\n APP_CONFIG['site_url'],\n APP_CONFIG['site_url'] + '/' + blog_url(blog),\n APP_CONFIG['site_url'] + '/rss')\n\n google = XMLRPC::Client.new2(\"http://blogsearch.google.com/ping/RPC2\")\n google.timeout = 5 # set timeout 5 seconds\n google.call(\"weblogUpdates.extendedPing\",\n APP_CONFIG['site_title'],\n APP_CONFIG['site_url'],\n APP_CONFIG['site_url'] + '/' + blog_url(blog),\n APP_CONFIG['site_url'] + '/rss',\n blog.cached_tag_list.gsub(/,/, '|'))\n rescue Exception => e\n logger.error e\n end",
"def index\n if params[:q].present?\n @results = Page.search(query: { fuzzy: { content: { value: params[:q] } } }, highlight: { fields: { content: {} } })\n @has_highlights = true\n else\n @results = Page.search('*')\n end\n @pages = @results.records\n end",
"def test_stats\n assert @page != nil\n\n wc = @analyzer.word_count @view\n puts wc\n # word count from MS Word: 3.648 (including UI text from Mahara)\n assert_equal 3759, wc\n\n external_links = @analyzer.external_links @view\n puts \"external links: #{external_links.size}\"\n # external_links.each do |link|\n # puts \"> \" + link.uri.to_s\n # end\n\n images = @analyzer.images @view\n puts \"images: #{images.size}\"\n # images.each do |image|\n # puts \"> \" + image.to_s\n # end\n\n uploaded_images = @analyzer.uploaded_images @view\n puts \"uploaded_images: #{uploaded_images.size}\"\n\n wikipedia_images = @analyzer.images_from_domain(@view, \"wikipedia\")\n puts \"wikipedia_images: #{wikipedia_images.size}\"\n end",
"def fetch\n hydra = Typhoeus::Hydra.new(:max_concurrency => @threads)\n page, pages = nil, []\n\n @urls.each do |url|\n request = Typhoeus::Request.new(url, :timeout => @timeout, :followlocation => false, :headers => {\"Accept\" => \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\", \"Cache-Control\" => \"no-cache\", \"Pragma\" => \"no-cache\", \"User-Agent\" => UserAgents.random})\n request.on_complete do |response|\n uri = URI(url)\n if response.success?\n puts \"fetching #{url}\".green.on_black\n page = Page.new(uri, response_code: response.code,\n response_head: response.headers,\n response_body: response.body,\n response_time: response.time*1000,\n crawled_time: (Time.now.to_f*1000).to_i)\n elsif (300..307).include?(response.code)\n puts \"fetching #{url}\".green.on_black\n puts \"### #{response.code} ### redirect to #{response.headers['Location']}\".white.on_black\n page = Page.new(uri, response_code: response.code,\n response_head: response.headers,\n response_body: response.body,\n response_time: response.time*1000,\n redirect_url: response.headers['Location'])\n elsif 404 == response.code\n puts \"fetching #{url}\".green.on_black\n puts \"### #{response.code} ### not found #{url}\".magenta.on_black\n page = Page.new(uri, response_code: response.code,\n response_time: response.time*1000)\n else\n puts \"fetching #{url}\".green.on_black\n puts \"### #{response.code} ### failed #{url}\".magenta.on_black\n puts \"### Time: #{response.time} ### #{response.return_message}\".magenta.on_black\n page = Page.new(uri, response_code: response.code,\n response_time: response.time*1000)\n end\n pages << page\n end\n hydra.queue(request)\n end\n hydra.run\n return pages\n end",
"def robots_error!(url); end",
"def home\n\n# find_all_blog_posts\n#\n# find_blog_post\n#\n# find_tags\n (@blog_posts = BlogPost.live.includes(:comments, :categories).all) if request.format.rss? \n respond_with (@blog_posts) do |format|\n format.html\n format.rss\n end\n\n error_404 unless (@page = Page.where(:link_url => '/').first).present?\n end",
"def thread_main\r\n # We'll do this in a loop until the list is finished\r\n loop do\r\n # Wrap this in a try-catch just in case\r\n begin\r\n\t # Getting the name\r\n\t name = $arr[$ind]\r\n\t return if name.nil?\r\n\t $ind += 1\r\n\t # Getting the parsed page contents\r\n\t body = JSON.parse(\r\n\t HTTParty.get(\r\n\t\t \"http://community.wikia.com/api.php\",\r\n\t\t :query => {\r\n\t\t :action => \"query\",\r\n\t\t :prop => \"revisions\",\r\n\t\t :titles => name.strip.scrub,\r\n\t\t :rvprop => \"content\",\r\n\t\t :rvparse => 1,\r\n\t\t :format => \"json\"\r\n\t\t }\r\n\t ).body,\r\n\t :symbolize_names => true\r\n\t )\r\n\t pages = body[:query][:pages]\r\n\t # Finding if the page has redlinks and which are they\r\n\t split = pages[pages.keys[0]][:revisions][0][:\"*\"].split(\"<a href=\\\"/wiki/\")\r\n\t split.each {|s|\r\n\t matches = /\\?action=edit&redlink=1\" class=\"new\" title=\"(.*) \\(page does not exist\\)\"/.match(s)\r\n\t $res << matches.captures[0] if matches\r\n\t }\r\n rescue Exception => e\r\n\t # If error happens I want to know\r\n puts(e)\r\n end\r\n end\r\nend",
"def test_searches\n\n Page.indexers[1].rebuild!\n # make sure that terms are hooked in\n assert SearchTerm.count > 0\n \n assert_equal 288, SearchTerm.count\n \n assert_kind_of SearchTerm, SearchTerm.find_by_term('brazil')\n assert_kind_of SearchTerm, SearchTerm.find_by_term('casablanca')\n assert_kind_of SearchTerm, SearchTerm.find_by_term('japanese')\n assert_kind_of SearchTerm, SearchTerm.find_by_term('commonterm')\n \n assert_kind_of ActiveSearch::TermIndexer, @page_term_indexer\n \n assert_equal Set.new( [Page.find(1)] ), Set.new(@page_term_indexer.query(\"brazil\"))\n \"The first page should be found\"\n \n assert_equal Set.new( [Page.find(1)] ), Set.new(@page_term_indexer.query(\"ministry\")),\n \"The first page should be found\"\n \n assert_equal Set.new( Page.find(:all) ), Set.new(@page_term_indexer.query('commonterm')),\n \"All pages should be found\" \n \n assert_equal Set.new( [Page.find(1)] ), Set.new(@page_term_indexer.query(\"brazil ministry\")),\n \"Should search on intersection\" \n\n assert_equal Set.new( [Page.find(1)] ), Set.new(@page_term_indexer.query(\"ministry commonterm\")),\n \"The first page should be found - the search is exclusive\"\n\n assert_equal Set.new( [Page.find(2)] ), Set.new(@page_term_indexer.query(\"japanese\")),\n \"Related paras should be included in the search\"\n\n assert_equal Set.new( [Page.find(1)] ), Set.new(@page_term_indexer.query(\"TARKHANOV\")),\n \"Related authors should be included in the search\" \n end",
"def test_multiple_inherit_same_base\n deploy_app(SearchApp.new.sd(selfdir + \"app2/multimedia.sd\").cluster(\n SearchCluster.new(\"mp3\").\n sd(selfdir + \"app2/mp3.sd\").\n indexing(\"dp\")).\n cluster(\n SearchCluster.new(\"image\").\n sd(selfdir + \"app2/image.sd\").\n indexing(\"dp\")).\n container(Container.new(\"dp\").\n search(Searching.new).\n docproc(DocumentProcessing.new)))\n start\n feed_and_wait_for_docs(\"mp3\", 1, :file => selfdir+\"onemp3.xml\", :cluster => \"mp3\")\n feed_and_wait_for_docs(\"image\", 1, :file => selfdir+\"oneimage.xml\", :cluster => \"image\")\n wait_for_hitcount(\"query=rida&search=mp3\", 1)\n wait_for_hitcount(\"query=make:foo&search=image\", 1)\n assert_hitcount(\"query=rida&search=mp3\", 1)\n assert_result(\"query=rida&search=mp3\", selfdir+\"rida.result.json\")\n assert_hitcount(\"query=uri.path:path&search=mp3\", 1)\n assert_hitcount(\"query=site:foo.bar.com&search=mp3\", 1)\n assert_hitcount(\"query=uri.path:path&search=image\", 0)\n assert_hitcount(\"query=site:foo.bar.com&search=image\", 0)\n assert_result(\"query=make:foo&search=image\", selfdir+\"foo.result.json\")\n end",
"def crawl\n while NG_URL.where(:a_hrefs_unprocessed => { :$not => { :$size => 0}}).count > 0 do\n next_unprocessed_url\n end\n end",
"def search(str)\n return [] if str.to_s.empty?\n \n words = str.downcase.split(' ')\n pattern = Regexp.new(words.join('|'))\n matches = []\n\n pages.each do |page|\n if page.title.downcase =~ pattern\n matches << [page, []]\n \n elsif page.body.downcase =~ pattern\n matches << [page, highlight(page.html, words)]\n end\n end\n\n matches\n end",
"def get_pages\n @pages << base_gallery_url\n (@doc/\"a\").select{|a| a[\"href\"] =~ /ndxpage/}.each do |e|\n @pages << base_gallery_url_prefix + e[\"href\"]\n end\n puts \"got pages!\"\n puts @pages.inspect\n puts \"---\"\n end",
"def does_not_include_badwords\n\n badwords = %w(\n aloha!\n href=\n -online\n 1freewebspace.com\n 4u\n 5gighost.com\n accutane\n adipex\n adultsex\n advicer\n alprazolam\n amoxil\n arcadepages\n arimidex\n associations.missouristate.edu\n ativan\n augmentin\n baccarrat\n baclofen\n beaver\n blackjack\n bllogspot\n blogs.blackmarble.co.uk\n blowjob\n booker\n buspar\n byob\n car-rental-e-site\n car-rentals-e-site\n carisoprodol\n casino\n casinos\n chatroom\n cialis\n cipro\n citalopram\n clomid\n clonazepam\n comment1\n comment2\n comment3\n comment4\n comment5\n comment6\n coolcoolhu\n coolhu\n credit-card-debt\n credit-report-4u\n creditonlinepersonalloans\n cwas\n cyclen\n cyclobenzaprine\n dating-e-site\n day-trading\n debt-consolidation\n debt-consolidation-consultant\n diazepam\n diovan\n discreetordering\n dostinex\n duty-free\n dutyfree\n dvxuser.com\n equityloans\n fanreach.com\n fioricet\n flagyl\n flowers-leading-site\n fosamax\n freenet\n freenet-shopping\n gambling-\n hair-loss\n health-insurancedeals-4u\n hi5.com\n holdem\n holdempoker\n holdemsoftware\n holdemtexasturbowilson\n homeequityloans\n homefinance\n hotel-dealse-site\n hotele-site\n hotelse-site\n hydrocodone\n hyves.mn\n incest\n insurance-quotesdeals-4u\n insurancedeals-4u\n isuzuforums.com\n jestmaster\n jizz\n jrcreations\n kaboodle.com\n kamagra\n klonopin\n lamictal\n lesbian\n levaquin\n levitra\n lezbian\n loans\n lorazepam\n lycos\n macinstruct\n metformin\n metronidazole\n mortgage-4-u\n mortgagequotes\n musicstation\n nojazzfest\n nolvadex\n online-gambling\n onlinegambling-4u\n ottawavalleyag\n ownsthis\n palm-texas-holdem-game\n paxil\n paydal\n penguinforum\n penis\n personalloansbad\n pharmacy\n phenergan\n phentermine\n poker-chip\n porn\n poze\n profiles.friendster.com\n propecia\n proscar\n pussy\n remeron\n rental-car-e-site\n ringtone\n ringtones\n roulette\n shemale\n shoes\n slot-machine\n Staphcillin\n tamiflu\n tegretol\n texas-holdem\n thorcarlson\n top-e-site\n top-site\n toprol\n toradol\n tramadol\n tramodal\n tramodol\n trim-spa\n ultram\n valeofglamorganconservatives\n valium\n viagra\n vibramycin\n vicodin\n vioxx\n voltaren\n vytorin\n xanax\n zantac\n zithromax\n zofran\n zolpidem\n zolus\n )\n badwords.each do |bw|\n if !comment.nil? && comment.downcase.include?(bw) \n errors.add_to_base(\"Comment Rejected\") \n break\n end\n end\n end",
"def twitter_search(skeyword, rec_per_page)\n recs_found = 0\n \n Twitter::Search.new(skeyword).per_page(rec_per_page).each do |r|\n #puts r.inspect\n #puts \"@\" + r.from_user + \": \" + r.text\n #puts \"at \" + r.created_at\n #puts \"......................................................................\"\n #puts\n recs_found = recs_found + 1\n end\n recs_found\nend",
"def search\n begin\n words= params[:search][:qw].strip\n @query_info=words\n\n # search in the descriptions\n @videos=VMetadata.search(words, :page => params[:page], :per_page => @@per_page,\n :match_mode => :any, :rank_mode => :proximity_bm25)\n\n respond_to do |format|\n format.html { render 'query/show' }\n end\n rescue ActiveRecord::RecordNotFound\n render(:file => \"#{Rails.root}/public/404.html\",\n :status => \"404 Not Found\")\n end\n end",
"def check_404\n end",
"def suggestions\n words = params[:query].split(/\\s+/).reject(&:blank?)\n\n suggestions = case words.size\n when 1\n if words.first.starts_with?('@')\n users = find_users(words.first[1..-1]).limit(MAX_SUGGESTIONS)\n users.map do |user|\n {\n user: user.as_json,\n url: user_url(user),\n type: 'user'\n }\n end\n else\n projects = find_projects(words[0]).limit(MAX_SUGGESTIONS).map(&:sluggable).compact\n projects.map do |project|\n {\n project: project.as_json,\n url: project_url(project),\n type: 'project',\n }\n end\n end\n when 2\n project = find_projects(words[0]).only.try!(:sluggable)\n envs = find_environments(project, words[1]).limit(10) if project\n envs.map do |env|\n {\n project: project.as_json,\n environment: env.as_json,\n type: 'environment',\n url: project_environment_bugs_url(project, env)\n\n\n }\n end if project\n when 3\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n [{\n type: 'bug',\n url: project_environment_bug_url(project, env, bug),\n project: project.as_json,\n environment: env.as_json,\n bug: bug.as_json\n }] if bug\n when 4\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n occurrence = bug.occurrences.find_by_number(words[3].to_i) if bug\n [{\n type: 'occurrence',\n url: project_environment_bug_occurrence_url(project, env, bug, occurrence),\n project: project.as_json,\n environment: env.as_json,\n bug: bug.as_json,\n occurrence: occurrence.as_json\n }] if occurrence\n end\n\n respond_to do |format|\n format.json { render json: (suggestions || []).to_json }\n end\n end",
"def index_file(file, pages_dir, stopwords, file_data)\n # Removing the dir from the file name\n # begin\n actual_name = file.gsub(pages_dir, \"\")\n # rescue NoMethodError\n# actual_name = badpage.html\n \n\n # Resetting the file path\n file_path = \"\"\n file_path = File.expand_path(\".\") + \"/\" + file\n\n print \"Parsing HTML document: \" + actual_name + \" \\n\"\n\n # Finding all the tokens in the file\n tokens = find_tokens(file_path)\n\n # Getting the page title, word count, and page url\n page_title = get_title(file_path)\n word_count = tokens.length\n page_url = file_data[actual_name]\n\n # Updating the docindex hash\n $docindex[file.gsub(pages_dir, \"\")] = [word_count, page_title, page_url]\n\n # Removing the stop words and getting the stem words in the file\n tokens = remove_stop_tokens(tokens, stopwords)\n tokens = stem_tokens(tokens)\n\n # Creating the invindex hash table\n for token in tokens\n begin\n if $invindex.member?(token)\n if $invindex[token].member?(actual_name)\n $invindex[token][actual_name] += 1\n else\n $invindex[token][actual_name] = 1\n end\n else\n $invindex[token] = {actual_name => 1}\n end\n # end\n# rescue NoMethodError\n # puts \"NoMethodError\"\n end\n #puts file_name\n # title = nil\n end\n #end\nend",
"def search\n words = params[:query].split(/\\s+/).reject(&:blank?)\n url = nil\n\n case words.size\n when 1\n if words.first.starts_with?('@')\n user = find_users(words.first[1..-1]).only\n url = user_url(user) if user\n else\n project = find_projects(words[0]).only.try!(:sluggable)\n url = project_url(project) if project\n end\n when 2\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n url = project_environment_bugs_url(project, env) if env\n when 3\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n url = project_environment_bug_url(project, env, bug) if bug\n when 4\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n occurrence = bug.occurrences.find_by_number(words[3].to_i) if bug\n url = project_environment_bug_occurrence_url(project, env, bug, occurrence) if occurrence\n end\n\n url ? render(text: url) : head(:ok)\n end",
"def index\n @blacklisted_site_search = params[:blacklisted_site_search]\n conditions = [\"url like ?\", \"%#{@blacklisted_site_search}%\"] unless @blacklisted_site_search.nil?\n @blacklisted_sites = BlacklistedSite.paginate(:all, :conditions => conditions, :order => \"url ASC\", :page => params[:page])\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @blacklisted_sites }\n end\n end",
"def perform\n self.err_msg = ''\n self.http_status = 200\n begin\n self.results = FinderServices.glean page_ref.url, page_ref.site\n rescue Exception => msg\n breakdown = FinderServices.err_breakdown page_ref.url, msg\n self.err_msg = breakdown[:msg] + msg.backtrace.join(\"\\n\")\n self.http_status = breakdown[:status]\n errors.add :url, breakdown[:msg]\n exc = Exception.new breakdown[:msg]\n exc.set_backtrace msg.backtrace\n raise exc # msg, breakdown[:msg] if dj\n end\n end",
"def parse_search_results(page)\n libraries_available = []\n links = page.css(\"ol[class=result] li[class=clearfix] h3 a\")\n links.each do |link|\n fetch_result = fetch(\"#{LIBRARY_BASE_URL + (link.attr 'href')}\")\n body = Zlib::GzipReader.new(StringIO.new(fetch_result[:response].body)).read\n libraries_available.concat parse_detail(body)\n\n # should we go to the next link? do we already know if it's available at our library?\n if libraries_available.include? LIBRARY_MY_STRING; return [LIBRARY_MY_STRING] end\n end\n\n libraries_available\nend",
"def process_url(url)\n begin\n\n # the following scans\n url_kind_normalized = is_valid_url(url, nil)\n url_kind = url_kind_normalized[0]\n url = url_kind_normalized[1] ## normalized i.e. canonical format\n\n unless [:ref_static_content, :not_valid_url].include?(url_kind)\n if ::Crawl::Db::SiteMap.internal_links[url] || ::Crawl::Db::SiteMap.non_internal_links[url] || should_skip(url)\n # already scanned, we could bump the count if needed\n # if skip just skip!\n else\n # scan it and all its nested pages\n navigate_to_url_and_validate_that_url_was_found( url )\n page_content = browser.html\n @@page_scanner.scan_content(page_content, url)\n end\n end\n\n rescue StandardError => err\n puts \"Err: on url #{url} received: #{err}\"\n end\n\n end",
"def poll_extractions url=nil\n url ||= site.sample\n finders = all_finders\n begin\n pagetags = PageTags.new(url, @site, finders, true, false)\n correct_result = nil\n finders.each do |finder|\n pagetags.results_for(finder[:id]).each do |result|\n # pagetags.results_for(label).each do |result|\n # finder = result.finder\n puts \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n puts \"URL: #{url}\"\n label = finder[:label]\n finder.each { |key, value| puts \"\\t(#{key}: #{value})\" unless [:label, :count, :foundlings].include?(key) }\n # accepted = false\n if (foundstr = result.out.shift)\n unless column = correct_result && (foundstr == correct_result) && :yes_votes\n puts \"#{label}: #{foundstr}\"\n site_option = [\"Description\", \"Site Name\", \"Title\", \"Image\", \"Author Name\", \"Author Link\", \"Tags\"].include?(label) ? \" S(ave value to Site) \" : \"\"\n puts \"Good? [y](es) n(o) #{site_option} Q(uit)\"\n answer = gets.strip\n case answer[0]\n when 'Q'\n return nil\n when 'N', 'n'\n column = :no_votes\n if answer[0] == 'N'\n @site.reviewed = nil\n @site.save\n return false\n end\n when 'Y', 'y', nil\n column = :yes_votes\n # accepted = (answer[0] == 'Y')\n correct_result = foundstr\n # Include the finder on the site\n unless @site.finders.exists?(finds: finder[:label], selector: finder[:path], read_attrib: finder[:attribute])\n if existing = @site.finders.where(finds: finder[:label]).first\n existing.selector = finder[:path]\n existing.read_attrib = finder[:attribute]\n existing.save\n else\n @site.finders.create(finds: finder[:label], selector: finder[:path], read_attrib: finder[:attribute])\n @site.save\n end\n end\n # Saved the title finder: take a crack at the editing RegExp\n if label == \"Title\"\n done = false\n until done\n trimmed = trim_title foundstr\n puts \"Title In: #{foundstr}\"\n puts \"Title Out: #{trimmed}\"\n puts \"Good? (sS to save, qQ to quit, otherwise type new regexp for title) \"\n answer = gets.strip\n case answer\n when 's', 'S'\n site.save\n done = true\n when 'q', 'Q'\n done = true\n else\n @site.ttlcut = answer\n end\n end\n end\n when 'S'\n # Copy the value to the corresponding field on the site\n rest_of_line = answer[1..-1].strip\n field_val = rest_of_line.blank? ? foundstr : rest_of_line\n case label\n when \"Image\"\n @site.logo = field_val\n @site.save\n when \"Description\"\n @site.description = field_val\n @site.save\n when \"Site Name\", \"Title\"\n @site.name = field_val\n @site.save\n when \"Author Name\"\n TaggingServices.new(@site).tag_with field_val, User.super_id, type: \"Author\"\n @site.save\n when \"Author Link\"\n # Add a reference to the author, if any\n @site.tags(User.super_id, tagtype: \"Author\").each { |author|\n Reference.assert field_val, author, \"Home Page\"\n }\n when \"Tags\"\n ts = TaggingServices.new @site\n field_val.split(',').collect { |tagname|\n tagname = tagname.split(':').last.strip\n tagname if (tagname.length>0)\n }.compact.each { |tagname|\n ts.tag_with tagname, User.super_id\n }\n else\n puts \"There's no field on the site for #{label}\"\n end\n end\n end\n if column\n finder[column] = 0 unless finder[column]\n finder[column] = finder[column]+1\n end\n end\n end\n end\n return true\n rescue Exception => e\n puts \"Error: couldn't open page '#{url}' for analysis:\"\n puts e.to_s\n return false\n end\n end",
"def querytest_failing_common\n wait_for_hitcount(\"query=test&streaming.selection=true\", 28, 10)\n end",
"def stats\n\n # extract the content\n extract_content\n generate_titles\n\n rescue ActiveRecord::RecordNotFound\n\n not_found and return\n\n end",
"def count_all_html_pages(dir)\n perform_global_search('//html', [], dir)\n end",
"def parseIndexPage(page)\n folders = []\n # ASF main page references currently look like this: <a href=\"abdera/\">abdera/</a>\n # the Perl script looked for this match: m!> ?$dir/?<!\n links = page.scan(%r{<a href=['\"]([.a-z0-9-]+)/?['\"](?: title=['\"][.a-z0-9-]+/?['\"])?>([.a-z0-9-]+)/?</a>})\n links.each { |l|\n if l[1] == l[0]\n folders << l[1]\n end\n }\n folders\nend",
"def pageInstanceAnalysis(entity) \n\t\tputs \"search for page #{entity}\"\n\t\tparams=process_params(entity)\n\t\tresult=server_rest_api(@pages_restapi,params)\n\t\tputs \"result=#{result}\"\n\t\tpages_uuids=[]\n\t\tputs \"#{@pg_uuids}\"\n\t\tmatches=result.select{ |h| ! @pg_uuids.any?{ |t| t == h[:pageId] && h[:name] == entity[:name]} }\tif ! result.nil?\n\t\tputs \"matches=#{matches}\"\n\t\tmatches.each do |tr|\n\t\t\tpages_uuids.push(tr[:pageId])\n\t\tend unless matches.nil?\n\t\treturn pages_uuids\n\tend",
"def process_page(t, response, count)\n msg = \"[#{\"%.3d\" % count}/#{\"%.3d\" % datastore['MAX_PAGES']}] #{response.code || \"ERR\"} - #{t[:host]} - #{response.request.url}\"\n case response.code\n when 301,302\n if response.headers and response.headers[\"location\"]\n print_status(msg + \" -> \" + response.headers[\"location\"].to_s)\n else\n print_status(msg)\n end\n when 500...599\n print_good(msg)\n when 401\n print_good(msg)\n print_good((\" \" * 24) + \"WWW-Authenticate: #{response.headers['WWW-Authenticate']}\")\n when 200\n print_status(msg)\n when 404\n print_error(msg)\n else\n print_error(msg)\n end\n\n #\n # Process the web page\n #\n uri = URI(response.request.url)\n info = {\n :web_site => t[:site],\n :path => uri.path,\n :query => uri.query,\n :code => response.code,\n :body => response.body,\n :headers => response.headers\n }\n\n if response.headers['content-type']\n info[:ctype] = response.headers['content-type']\n end\n\n # TODO\n #if !page.cookies.empty?\n # info[:cookie] = page.cookies\n #end\n\n if response.headers['authorization']\n info[:auth] = response.headers['authorization']\n end\n\n if response.headers['location']\n info[:location] = response.headers['location']\n end\n\n if response.headers['last-modified']\n info[:mtime] = response.headers['last-modified']\n end\n\n # Report the web page to the database\n report_web_page(info)\n\n # Only process interesting response codes\n return unless [302, 301, 200, 500, 401, 403, 404].include?(response.code)\n\n # Skip certain types of forms right off the bat\n\n # Apache multiview directories\n return if uri.query =~ /^C=[A-Z];O=/ # Apache\n\n forms = []\n form_template = { :web_site => t[:site] }\n\n if form = form_from_url(t[:site], response.request.url)\n forms << form\n end\n\n doc = Nokogiri::HTML(response.body) if response.body rescue nil\n if doc\n doc.css(\"form\").each do |f|\n target = uri\n\n if f['action'] and not f['action'].strip.empty?\n action = f['action']\n\n # Prepend relative URLs with the current directory\n if action[0,1] != \"/\" and action !~ /\\:\\/\\//\n # Extract the base href first\n base = uri.path.gsub(/(.*\\/)[^\\/]+$/, \"\\\\1\")\n doc.css(\"base\").each do |bref|\n if bref['href']\n base = bref['href']\n end\n end\n action = (base + \"/\").sub(/\\/\\/$/, '/') + action\n end\n\n target = to_absolute(URI(action), uri) rescue next\n\n target = URI(target)\n unless target.host == uri.host\n # Replace 127.0.0.1 and non-qualified hostnames with our response.host\n # ex: http://localhost/url OR http://www01/url\n if (target.host.index(\".\").nil? or target.host == \"127.0.0.1\")\n target.host = uri.host\n else\n next\n end\n end\n end\n\n # skip this form if it matches exclusion criteria\n unless target.to_s =~ get_link_filter # TODO will need to filter more than this\n form = {}.merge!(form_template)\n form[:method] = (f['method'] || 'GET').upcase\n form[:query] = target.query.to_s if form[:method] != \"GET\"\n form[:path] = target.path\n form[:params] = []\n f.css('input', 'textarea').each do |inp|\n form[:params] << [inp['name'].to_s, inp['value'] || inp.content || '', { :type => inp['type'].to_s }]\n end\n\n f.css( 'select' ).each do |s|\n value = nil\n\n # iterate over each option to find the default value (if there is a selected one)\n s.children.each do |opt|\n ov = opt['value'] || opt.content\n value = ov if opt['selected']\n end\n\n # set the first one as the default value if we don't already have one\n value ||= s.children.first['value'] || s.children.first.content rescue ''\n\n form[:params] << [ s['name'].to_s, value.to_s, [ :type => 'select'] ]\n end\n\n forms << form\n end\n end\n end\n\n # Report each of the discovered forms\n forms.each do |form|\n next unless form[:method]\n print_status((\" \" * 24) + \"FORM: #{form[:method]} #{form[:path]}\")\n report_web_form(form)\n end\n end",
"def search_words\n begin\n regex = Regexp.new(@pattern)\n rescue RegexpError => msg\n error_msg(msg)\n rescue NameError => msg\n error_msg(msg)\n end\n @results = DICT.select do |word|\n regex =~ word\n end\n @num_results = @results.length\n format_results\n display_results\n end",
"def search(project: nil, text: nil, kind: 'subject', tags: { }, page: 1, results: [])\n raise 'no project specified' unless project\n tag_query = tags.each_pair.collect{ |k, v| \"tags[#{ k }]=#{ v }\" }.join '&'\n uri = URI.parse \"https://api.zooniverse.org/projects/#{ project }/talk/search?text=#{ text }&kind=#{ kind }&#{ tag_query }&per_page=20&page=#{ page }\"\n req = Net::HTTP::Get.new uri.to_s\n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = true\n res = http.request req\n json = JSON.parse res.body\n \n pages = (json['total'] / json['per_page'].to_f).ceil\n \n # More than 1,000 results\n if page == 1 && pages > 50\n puts \"\\n\\nThis query has #{ json['total'] } results.\"\n puts \"It could take a long time and degrade server performance.\"\n puts \"Are you really sure you want to run this query? (y/n)\"\n return unless gets.chomp =~ /y/i\n end\n \n if json['page'] < pages\n puts \"#{ json['page'] } / #{ pages }\"\n search project: project, text: text, kind: kind, tags: tags, page: page + 1, results: results + json['results']\n else\n results + json['results']\n end\nend",
"def ml_scrape(body_ml, url, result_xpaths, max_results = nil, \n res_href_append = nil, result_filter = nil, result_matcher = nil, \n content_max_length = nil)\n\n result_xpaths = [ result_xpaths ] unless result_xpaths.class == Array\n max_results = MAX_RESULTS if max_results > MAX_RESULTS\n\n @log.debug \"ml_scraping for #{max_results} results with \" +\n \"'#{result_xpaths.join(', ')}' in #{body_ml.length} bytes \" +\n \"from #{url}\"\n\n ret=[]\n doc = Nokogiri.parse(body_ml)\n result_xpaths.each do |result_xpath|\n @log.debug \"result_xpath: #{result_xpath}\"\n counter = max_results\n doc.search(result_xpath).each do |link|\n @log.debug \"to match on link: \" + PP.singleline_pp(link, '')\n if result_matcher.nil? or not link.search(result_matcher).empty?\n if counter > 0\n @log.debug \"matched: \" + PP.singleline_pp(result_matcher, '')\n # ...in case no 'href' attr. for tag\n result_href = link.content if result_filter\n\n if link['href'] && link['href'].start_with?(\"/\")\n uri = Addressable::URI.parse url\n result_href = uri.omit(:user, :password) + link['href']\n\n elsif link['href']\n result_href = link['href']\n end\n\n\n if link.content == nil || link.content == \"\"\n content = result_href\n elsif not link.element_children.empty?\n content = link.element_children.first.content\n link.element_children[1..-1].each { |c| content << \", #{c.content}\" }\n else\n content = link.content\n end\n\n @log.debug \"content: \" + PP.singleline_pp(content, '')\n if content && result_filter\n content = CGI.unescape(content.gsub(Regexp.new(result_filter), \n '\\1'))\n end\n\n @log.debug \"counter: #{counter}, content: #{content}, href+: \" +\n \"#{result_href}#{res_href_append}\"\n ret.push(\"#{truncate(content,\n :length => content_max_length || CONTENT_MAX_LENGTH,\n :separator => ' ')} \" + \"#{result_href}#{res_href_append}\")\n counter -= 1\n end\n end\n end\n end\n\n ret\n end",
"def crawl_parser(results)\n\t\tputs \"[\".light_green + \"*\".white + \"] OK\".light_green + \", \".white + \"running parser on\".light_green + \": #{results}\".white\n\t\timportant = File.open(results, \"r\") #place our found links in variable to manipulate and search as needed\n\t\trezDir = \"#{$results}#{@zsite}/\" #Our results dir for this site which has been already created in first function cycles\n\n\t\t# placeholder arrays for sorting and finding unique testable links\n\t\tspreadsheetz=[]; executablez=[]; no_params=[]; test_keys=[]; noparamz=[]; archivez=[]; testlink=[]; opendocz=[]; outlookz=[]; paramz=[]; imagez=[];\n\t\taudioz=[]; videoz=[]; flashz=[]; multi=[]; vcardz=[]; bkupz=[]; jsz=[]; confz=[]; wordz=[]; xmlz=[]; pazz=[]; pdfz=[]; txtz=[]; pptz=[]; dbz=[];\n\n\t\tmcount=0 #Multi Parameter Links Count\n\t\tscount=0 #Single Parameter Links Count\n\t\tnocount=0 #No Parameter Links Count\n\n\t\t#loop through content of crawler.links file line by line...\n\t\timportant.each do |line|\n\t\t\tbegin\n\t\t\t\t#parse out parameters if they are present, if not will error NoMethodError and be handled there with rescue\n\t\t\t\tparam = URI.parse(line).query\n\n\t\t\t\t#break paramaters into hash [ \"@key\" => \"@value\" ] formatting held in storage for easier manipulation\n\t\t\t\tparamsHash = Hash[URI.parse(line).query.split('&').map{ |q| q.split('=') }] \n\n\t\t\t\t# Parse according to the number of parameters in link\t\t\n\t\t\t\t###### Handle Single Parameter links ######\n\t\t\t\tif paramsHash.length == 1\n\t\t\t\t\tscount += 1\n\t\t\t\t\tparamz << line\n\t\t\t\t\tparamsHash.each do |key, value|\n\t\t\t\t\t\tif value =~ /\\d+/ #if value is numerical replace with number and then we unique ;)\n\t\t\t\t\t\t\ttestlink << line.sub(/#{value}/, '1') \n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttestlink << line #keep strings since they can be funky sometimes\n\t\t\t\t\t\tend\n\t\t\t\t\tend #finish cycle\n\n\t\t\t\telsif \"#{paramsHash.length}\".to_i > 1\n\t\t\t\t\t###### Handle Multi Parameter links ######\n\t\t\t\t\tmcount += 1\n\t\t\t\t\tparamz << line\n\t\t\t\t\t#Test each link and see if the parameter key has been logged or not, this way we only get unique paramter links ;)\n\t\t\t\t\tparamsHash.keys.each do |key|\n\t\t\t\t\t\tif test_keys.include?(key)\n\t\t\t\t\t\t\t#Do Nothing, its already included in our test_keys array!\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t#Unique paramter, include key in test_key array and URL link in multi array for injector tests l8r\n\t\t\t\t\t\t\ttest_keys << key #so we dont catch anymore links with this parameter\n\t\t\t\t\t\t\tmulti << line.chomp #so we note the link for injection tests\n\t\t\t\t\t\tend\n\t\t\t\t\tend#end hash.key cycle\n\t\t\t\tend # parameter check looping\n\n\t\t\t###### Handle NO Parameter links ######\n\t\t\trescue NoMethodError\n\t\t\t\t# We really only need to check a few links without params to see if they throw errors (URL re-write type stuff hiding)\n\t\t\t\tnocount += 1\n\t\t\t\tif nocount < 10 # gives us up to 15 no parameter links to check, more than enough\n\t\t\t\t\tno_params << line\n\t\t\t\tend\n\n\t\t\t\t#Parse over links we're ditching & sort into appropriate results files (in case that info is needed for follow up l8r)\n\t\t\t\tif /\\/.+\\.pdf/i.match(line)\n\t\t\t\t\tpdfz << line.chomp\n\t\t\t\telsif /\\/.+\\.doc/i.match(line)\n\t\t\t\t\twordz << line.chomp\n\t\t\t\telsif /\\/.+\\.js|\\/.+\\.javascript/i.match(line)\n\t\t\t\t\tjsz << line.chomp\n\t\t\t\telsif /\\/.+\\.txt|\\/.+\\.rtf/i.match(line)\n\t\t\t\t\ttxtz << line.chomp\n\t\t\t\telsif /\\/.+\\.png|\\/.+\\.jpg|\\/.+\\.jpeg|\\/.+\\.gif|\\/.+\\.bmp|\\/.+\\.exif|\\/.+\\.tiff/i.match(line)\n\t\t\t\t\timagez << line.chomp\n\t\t\t\telsif /\\/.+\\.msg/i.match(line)\n\t\t\t\t\toutlookz << line.chomp\n\t\t\t\telsif /\\/.+\\.odt/i.match(line)\n\t\t\t\t\topendocz << line.chomp\n\t\t\t\telsif /\\/.+\\.csv|\\/.+\\.xlr|\\/.+\\.xls/i.match(line)\n\t\t\t\t\tspreadsheetz << line.chomp\n\t\t\t\telsif /\\/.+\\.pps|\\/.+\\.ppt/i.match(line)\n\t\t\t\t\tpptz << line.chomp\n\t\t\t\telsif /\\/.+\\.tar|\\/.+\\.zip|\\/.+\\.7z|\\/.+\\.cbr|\\/.+\\.deb|\\/.+\\.gz|\\/.+\\.bz|\\/.+\\.pkg|\\/.+\\.rar|\\/.+\\.rpm|\\/.+\\.sit/i.match(line)\n\t\t\t\t\tarchivez << line.chomp\n\t\t\t\telsif /\\/.+\\.vcf/i.match(line)\n\t\t\t\t\tvcardz << line.chomp\n\t\t\t\telsif /\\/.+\\.xml/i.match(line)\n\t\t\t\t\txmlz << line.chomp\n\t\t\t\telsif /\\/.+\\.m3u|\\/.+\\.m4a|\\/.+\\.mp3|\\/.+\\.mpa|\\/.+\\.wav|\\/.+\\.wma/i.match(line)\n\t\t\t\t\taudioz << line.chomp\n\t\t\t\telsif /\\/.+\\.avi|\\/.+\\.mov|\\/.+\\.mp4|\\/.+\\.mpg|\\/.+\\.srt|\\/.+\\.vob|\\/.+\\.wmv/i.match(line)\n\t\t\t\t\tvideoz << line.chomp\n\t\t\t\telsif /\\/.+\\.swf|\\/.+\\.flv/i.match(line)\n\t\t\t\t\tflashz << line.chomp\n\t\t\t\telsif /\\/.+\\.sql|\\/.+\\.accdb|\\/.+\\.db|\\/.+\\.mdb|\\/.+\\.pdb/i.match(line)\n\t\t\t\t\tdbz << line.chomp\n\t\t\t\telsif /\\/.+\\.apk|\\/.+\\.app|\\/.+\\.bat|\\/.+\\.cgi|\\/.+\\.exe|\\/.+\\.gadget|\\/.+\\.jar|\\/.+\\.pif|\\/.+\\.vbs|\\/.+\\.wsf/i.match(line)\n\t\t\t\t\texecutablez << line.chomp\n\t\t\t\telsif /\\/.+\\.bak|\\/.+\\.tmp|\\/.+\\.bk/i.match(line)\n\t\t\t\t\tbkupz << line.chomp\n\t\t\t\telsif /\\/.+\\.conf/i.match(line)\n\t\t\t\t\tconfz << line.chomp\n\t\t\t\telsif /\\/.+\\.passwd|\\/.+\\.htpasswd/i.match(line)\n\t\t\t\t\tpazz << line.chomp\n\t\t\t\telse\n\t\t\t\t\tnoparamz << line\n\t\t\t\tend\n\t\t\tend #End begin/rescue block\n\t\tend\n\n\t\t#make sure we dont have duplicates\n\t\tno_params = no_params.uniq\n\t\ttest_keys = test_keys.uniq\n\t\ttestlink = testlink.uniq\n\t\tmulti = multi.uniq\n\t\tinjtestlinks=[]\n\n\t\tputs \"[\".light_green + \"*\".white + \"] Crawler Results\".light_green + \": \".white\n\t\t#Write found NO parameter links to their own file just like everything else, just these dont fall into any group\n\t\tcount=0\n\t\tif not noparamz.empty?\n\t\t\tzfile=\"NO_paramaters\"\n\t\t\tnoparamz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\") #Open our file handle in write mode\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\") #Open our file handle in append mode\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\" #write the hits to file \n\t\t\t\tlostANDfound.close #close our file handle we opened a minute ago\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{noparamz.length} Links in total with NO paramaters in them\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not paramz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"paramater\"\n\t\t\tparamz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links in total with paramaters in them\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not jsz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"JS\"\n\t\t\tjsz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for JS Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not pdfz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"PDF\"\n\t\t\tpdfz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for PDF Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not wordz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"MS_WORD\"\n\t\t\twordz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for MS Word Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not txtz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"TEXT\"\n\t\t\ttxtz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for TEXT Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not outlookz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"OUTLOOK-MSG\"\n\t\t\toutlookz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for OUTLOOK-MSG Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not opendocz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"OpenDoc\"\n\t\t\topendocz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for OpenDoc Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not spreadsheetz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"SpreadSheet\"\n\t\t\tspreadsheetz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for SpreadSheet Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not pptz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"PowerPoint\"\n\t\t\tpptz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for PowerPoint Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not archivez.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"ARCHIVE\"\n\t\t\tarchivez.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for ARCHIVE Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not vcardz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"vCard\"\n\t\t\tvcardz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for vCard Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not xmlz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"XML\"\n\t\t\txmlz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for XML Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not audioz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"AUDIO\"\n\t\t\taudioz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for AUDIO Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not videoz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"VIDEO\"\n\t\t\tvideoz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for VIDEO Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not flashz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"FLASH\"\n\t\t\tflashz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for FLASH Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not dbz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"DATABASE\"\n\t\t\tdbz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for DATABASE Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not executablez.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"EXECUTABLES\"\n\t\t\texecutablez.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for EXECUTABLES Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not bkupz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"BackUp\"\n\t\t\tbkupz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for BackUp Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not confz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"CONFIG\"\n\t\t\tconfz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for CONFIG Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not pazz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"PASSWORDS\"\n\t\t\tpazz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for PASSWORDS Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not imagez.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"IMAGE\"\n\t\t\timagez.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for IMAGE Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tputs \"[\".light_green + \"*\".white + \"] Other Info\".light_green + \".....\".white\n\t\tif not test_keys.empty?\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{test_keys.length} Testable Parameters\".light_green + \": \".white\n\t\t\tputs \"[\".light_green + \"*\".white + \"] \".light_green + \"#{test_keys.join(', ').to_s}\".white\n\t\tend\n\t\tif not testlink.empty?\n\t\t\t#print single parameter links we will test\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{testlink.length} Unique Single Parameter Links (out of #{scount} total)\".light_green + \": \".white\n\t\t\ttestlink.each do |line|\n\t\t\t\tputs \"\\t#{line.chomp}\".white\n\t\t\t\tinjtestlinks << line\n\t\t\tend\n\t\tend\n\t\tif not multi.empty?\n\t\t\t#print multi parameter links we will test\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{multi.length} Unique Multi Parameter Links (out of #{mcount} total)\".light_green + \":\".white\n\t\t\tmulti.each do |line|\n\t\t\t\tputs \"\\t#{line.chomp}\".white\n\t\t\t\tinjtestlinks << line\n\t\t\tend\n\t\tend\n\t\tif not no_params.empty?\n\t\t\tif no_params.length < 9\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] Found the following NO Parameter links\".light_green + \": \".white\n\t\t\t\tnopam = no_params\n\t\t\telse\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] 10 random No Parameter Links (out of #{nocount} total)\".light_green + \": \".white\n\t\t\t\tnopam = no_params.sort_by{rand}[0..9]\n\t\t\tend\n\t\t\t#print no parameter links we will test\n\t\t\tnopam.each do |line|\n\t\t\t\tputs \"\\t#{line.chomp}\".white\n\t\t\t\tinjtestlinks << line\n\t\t\tend\n\t\tend\n\t\tif not injtestlinks.empty?\n\t\t\t#Write the suggested testable links to their own file for use with other tools\n\t\t\tf = File.new(\"#{rezDir}testable.links\", \"w+\")\n\t\t\tinjtestlinks.each do |link|\n\t\t\t\tf.puts link\n\t\t\tend\n\t\t\tf.close\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Suggested Testable Links\".light_green + \": #{rezDir}testable.links\".white\n\t\tend\n\t\t#Display the emails found now....\n\t\tif not @emails_array.empty?\n\t\t\t@emails_array.uniq!\n\t\t\tf=File.open(\"#{rezDir}temp.emails\", 'w+')\n\t\t\t@emails_array.each do |email|\n\t\t\t\tf.puts email\n\t\t\tend\n\t\t\tf.close\n\t\t\t#Because Ruby built-in uniq function doesn't seem to be fully doing the job we use some OS magic to make sure it is unique emails only....\n\t\t\tsystem(\"cat #{rezDir}temp.emails | sort -u > #{rezDir}emails.txt\")\n\t\t\tcount=`wc -l #{rezDir}emails.txt | cut -d' ' -f1`\n\t\t\tFileUtils.rm(\"#{rezDir}temp.emails\")\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{count} emails while crawling\".light_green + \"....\".white\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Find them here\".light_green + \": #{rezDir}emails.txt\".white\n\t\tend\n\tend",
"def find_keywords(feedEntryUrl, tags)\n\tputs \"extracting keywords\"\n\tdoc = Nokogiri::HTML(open(feedEntryUrl))\n\t# LOAD THE DICTIONARY OF KEYWORDS\n\t@keywords = Keyword.all # change to select only new ones in the controller\n\tdoc.xpath('//@style').remove\n\tdoc.css(\"p\").each do |para| # PRETTY SURE THIS IS CRAZY INEFFECIENT!\n\t#paraString = para.to_s\t\n\tparaString = para.text\n\n\t@keywords.each do |keyword| \n\n\t\t# use regex to find the keywrods and end of sentences - probably could be more effecient!\t\n\t\t# CHANGE TO DYNAMIC KEYWORD! \n\t\t# AND FIX PLURALS! - put them all in with an 'or'?\n\n\t\tpositions = paraString.enum_for(:scan, /\\b#{Regexp.escape(keyword.word)}\\b/).map { Regexp.last_match.begin(0) }\n\t\tdots = paraString.enum_for(:scan, /[\\.\\?\\!]/).map { Regexp.last_match.begin(0) }\n\n\t\t# find the end of a sentence immediatly before a keyword\n\n\t\tif dots.length >=1 # maybe check that it's not a title by having a few fullstops in a P\n\n\t\t\tpositions.each do |position|\n\n\t\t\t\tdotBefore = dots.find_all {|i| i< position}.max\n\t\t\tdotBefore=-2 if dotBefore.nil? # start of string if no punctuation before\n\t\t\t# if it's the last sentence we might actually want to go back one\n\n\t\t\tresult = paraString[dotBefore+2, position+CharacterFollow]+\"...\"\n\n\t\t\tputs paraString\n\t\t\tPost.create!(:title => \"bam\",:content => paraString,:contentSummary => result,:score => 1, :image => \"radio.jpg\",:link => feedEntryUrl, :tags => tags, :datefound => DateTime.now, :keyword => keyword.word) \n\n\tend # each keyword\n\n\tend #each\n\n\tend #if a few sentences\n\n\nend\n\nLink.update_all(:updated_at => Time.now)\n\nend",
"def index\n raise 'no page params' if params[:search][:page].blank?\n page, value = params[:search][:page], params[:search][:value]\n\n if page.include? 'home'\n logger.debug('!! searging by all')\n @links = Link.search value\n elsif page.include? 'favorit'\n logger.debug('!! searging by favorits')\n @links = Link.search value, :with => {:favorits_user_id => current_user.id}\n elsif page.include? 'links'\n logger.debug('!! searging by my links')\n @links = Link.search value, :with => {:user_id => current_user.id}\n end\n\n respond_to do |format|\n format.html\n end\n end",
"def search_page_use_hpricot(url)\n # do something and put the new urls into the queue\n doc = Hpricot(open(url,{\n 'User-Agent' => 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.0)'\n }))\n converter = Iconv.new('utf-8', 'GBK')\n doc.search('a').each do |a|\n # a.inner_html.force_encoding('utf-8') is useless\n begin\n if a.attributes['href'] != nil && !filtered?(a.attributes['href'])\n #sync_puts \"#{converter.iconv(a.inner_html)} => #{a.attributes['href']}\"\n @queue.push(a.attributes['href'])\n end\n rescue ArgumentError\n sync_puts \"ArgumentError!!!\"\n end\n end\n end",
"def hunt_for_wiki_image_in links, agent\n return\n links.each{|l| puts l.href}\n STDIN.gets\n if links = links.compact.select{|l| l.href =~ /(?!book)(.*)F.*jl.*(jpg|png|gif|JPG|PNG|GIF)/}\n unless links.empty?\n link = agent.get( \"#{WIKIPEDIA_MAIN}#{links[ rand(links.size) ]}\" ).links.select{|l| l.href =~ /.*\\.(jpg|png|gif|JPG|PNG|GIF).*/}.first.href\n\n push_to_freeblog(@@settings[:freeblog].first,@@settings[:freeblog].last,link)\n else\n puts 'nincs kép'\n end\n end\nend",
"def get_mag_index_pages(mag_url)\n links = []\n doc = Nokogiri::HTML(open(mag_url, :allow_redirections => :safe)) \n doc.css(\"a[href]\").each do |p|\n if p.attribute('href').to_s.include? \"#issues\"\n links.push(p.attribute('href').to_s)\n end\n end\n # the link of the actual url is not in the array. it needs to be,\n # since this is the first page that index issues.\n links.push(mag_url)\n return links.uniq\nend",
"def search\n if params[:keyword].nil? or params[:keyword].empty?\n redirect_back :fallback_location => root_path, :alert => \"Unrecognized user input. \"\n else\n keyword = params[:keyword].downcase.strip\n end\n @domain = Domain.find_by(name: keyword)\n if @domain.present?\n site_header=[\"Primary Website\",\"Primary IP\",\"Port\",\"Hosting Status\",\"Server\",\"Response Code\",\"MD5 Fingerprint\",\"Detected Redirection\",\"Timestamp\"]\n @prime_site = site_header.zip(site_lookup(@domain.name)).to_h\n else\n @prime_site = nil\n end\n end",
"def crawl(url = base_url)\n document = Crawler::Document.new(url)\n index.consume_document url.sub(base_url, ''), document\n\n paths_queue = index.get_paths_to_visit\n next_path = paths_queue[0]\n\n print \" Pages remaing - #{paths_queue.count} \\r\"\n crawl \"#{base_url}#{next_path}\" if next_path\n end",
"def analyze_domain_network(page)\n get_relevant_pages(page)\n @pages.inject(0) { |score, (key, _value)| score + @pages[key].nil? ? 0 : SCORE[key] }\n end",
"def find_target_cgi\r\n\r\n target_uris = []\r\n common_dirs = %W^\r\n/\r\n/cgi-bin/\r\n/cgi/\r\n^\r\n common_exts = [\"\", \".cgi\"]\r\n common_cgis = %W^\r\nadmin\r\napply\r\nnon-CA-rev\r\ncheckCookie\r\ncheck_user\r\nchn/liveView\r\ncht/liveView\r\ncnswebserver\r\nconfig\r\nconfigure/set_link_neg\r\nconfigure/swports_adjust\r\neng/liveView\r\nfirmware\r\ngetCheckCode\r\nget_status\r\ngetmac\r\ngetparam\r\nguest/Login\r\nhome\r\nhtmlmgr\r\nindex\r\nindex/login\r\njscript\r\nkvm\r\nliveView\r\nlogin\r\nlogin.asp\r\nlogin/login\r\nlogin/login-page\r\nlogin_mgr\r\nluci\r\nmain\r\nmain-cgi\r\nmanage/login\r\nmenu\r\nmlogin\r\nnetbinary\r\nnobody/Captcha\r\nnobody/VerifyCode\r\nnormal_userLogin\r\notgw\r\npage\r\nrulectl\r\nservice\r\nset_new_config\r\nsl_webviewer\r\nssi\r\nstatus\r\nsysconf\r\nsystemutil\r\nt/out\r\ntop\r\nunauth\r\nupload\r\nvariable\r\nwanstatu\r\nwebcm\r\nwebmain\r\nwebproc\r\nwebscr\r\nwebviewLogin\r\nwebviewLogin_m64\r\nwebviewer\r\nwelcome\r\ncgitest\r\n^\r\n\r\n if datastore['TARGET_URI'].to_s.length > 0\r\n target_uris << datastore['TARGET_URI']\r\n end\r\n\r\n common_dirs.each do |cgi_dir|\r\n common_cgis.each do |cgi_path|\r\n common_exts.each do |cgi_ext|\r\n target_uris << \"#{cgi_dir}#{cgi_path}#{cgi_ext}\"\r\n end\r\n end\r\n end\r\n\r\n print_status(\"Searching #{target_uris.length} paths for an exploitable CGI endpoint...\")\r\n\r\n target_uris.each do |uri|\r\n if is_cgi_exploitable?(uri)\r\n print_good(\"Exploitable CGI located at #{uri}\")\r\n return uri\r\n end\r\n end\r\n\r\n print_error(\"No valid CGI endpoints identified\")\r\n return\r\n end",
"def Scrap(search)\n short_name = search.gsub(/\\./, ' ')\n short_name.gsub!(/ (DVDRip|LiMiTED|REPACK|720p|FRENCH|UNRATED|iNTERNAL|TRUEFRENCH).*$/, '')\n \n DataLoadFromSite(short_name)\n end",
"def index\n if !/(scrape)/.match(request.url).nil?\n # obviously temporary \n commence_scraping\n elsif !/(releases.json)/.match(request.url).nil?\n get_releases\n elsif !/(videos.json)/.match(request.url).nil?\n get_youtube\n elsif !/(merch.json)/.match(request.url).nil?\n get_merch\n elsif !/(youtube_api_fetch)/.match(request.url).nil?\n youtube_api_fetch\n end\n end",
"def get_links(page_url)\n ndoc = Nokogiri::HTML(open(page_url))\n links = ndoc.css('a')\n tmp = []\n found = nil\n links.each do |ln|\n if ln.text == \"next 5,000\"\n tmp = get_links(\"http://en.wikipedia.org\" + ln[\"href\"])\n tmp << \"http://en.wikipedia.org\" + ln[\"href\"]\n found = true\n break\n end\n end\n if found == nil\n tmp << page_url\n end\n tmp\nend",
"def search_and_save(category:, indexes:[], types:[],\n source:[:id, :site, :url, :lang, :title, :content],\n queries:[nil], min_nchars: 200, limit:nil, output:nil)\n\n @es_fields = source.dup\n @min_nchars = min_nchars\n corpus = Xi::ML::Corpus::PushCorpus.new(output)\n\n # store SHA256(content) to check for duplicate contents\n checkup = {}\n\n counts = {}\n ndocs = { saved: 0, limit: 0, long: 0, total: 0 }\n\n @timer.start_timer()\n\n queries.each do |query|\n indexes.each do |index|\n types.each do |type|\n\n # setup a new search for each index and for each type\n @search.search_setup(\n index: index,\n type: type,\n source: @es_fields,\n query: query,\n )\n\n begin\n # scroll results (yield => loop)\n @search.scroll do |search_entry|\n entry = process_result(search_entry)\n site = entry[:site].sub('www.', '')\n\n counts[site] = { saved: 0, limit: 0, long: 0, total: 0 } \\\n unless counts[site]\n\n ndocs[:total] += 1\n counts[site][:total] += 1\n\n # skip documents with empty content\n next if entry[:content].empty?\n\n ndocs[:long] += 1\n counts[site][:long] += 1\n\n # skip documents for sites that reached their limit\n next if !limit.nil? && counts[site][:saved] >= limit\n\n # count duplicates for documents within limit\n ndocs[:limit] += 1\n counts[site][:limit] += 1\n\n save_entry = entry.select {|k, _| @corpus_fields.include?(k) }\n save_entry[:category] = category.to_s\n\n raise Xi::ML::Error::DataError, \\\n \"Extracted document '#{save_entry}' \"\\\n \"does not match required structure '#{@corpus_fields}'\" \\\n unless save_entry.keys.sort == @corpus_fields.sort\n\n content_sha = Digest::SHA256.hexdigest(entry[:raw_content])\n unless checkup.key?(content_sha)\n corpus.add(save_entry)\n\n ndocs[:saved] += 1\n counts[site][:saved] += 1\n\n checkup[content_sha] = true\n\n # progress information\n @logger.info(\"Saved #{ndocs.values.join(' / ')} documents\") \\\n if ndocs[:saved] % 100_000 == 0\n end\n end\n rescue => e\n raise Xi::ML::Error::CaughtException, \\\n \"Exception encountered when scrolling results #{e.message}\"\n end\n end\n end\n end\n\n corpus.close_stream\n\n # log info\n @timer.stop_timer(\"Processed documents from #{counts.size} host names\")\n @logger.info(\"Stored #{ndocs.values.join(' / ')} documents\")\n\n counts = Hash[counts.sort_by {|_, value| value[:saved] }.reverse]\n @logger.info(\"# of total documents per domain:\\n#{PP.pp(counts, '')}\")\n\n pshort = (100 - 1.0 * ndocs[:long] / ndocs[:total] * 100).round(2)\n pignored = (100 - 1.0 * ndocs[:limit] / ndocs[:long] * 100).round(2)\n pdup = (100 - 1.0 * ndocs[:saved] / ndocs[:limit] * 100).round(2)\n\n @logger.info(\"#{pshort}% docs have less than #{min_nchars} characters\")\n @logger.info(\"#{pignored}% docs ignored due to the #{limit}docs/site limit\")\n @logger.info(\"#{pdup}% docs have duplicates (with respect to saved docs)\")\n end",
"def find_keywords(feedEntryUrl)\n\tputs \"extracting keywords\"\n\tdoc = Nokogiri::HTML(open(feedEntryUrl))\n\tdoc.css(\"p\").each do |para|\n\t\t# regex on para if true extract and save\n\t\t# for now just save the p tags\n\t\tPost.create!(:title => \"test\",:content => \"test\",:contentSummary => para.text,:score => 1, :image => \"radio.jpg\",:link => \"www.google.com\")\n\tend\n\nend",
"def collect_raw_univ_pages(mirrors, univ_name)\n if mirrors.is_a? Array\n mirrors.each do | url|\n if url =~ /http:\\/\\/pastesite.com\\// # use pastesite only \n begin\n mc = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }\n page = mc.get(url)\n rescue => e\n $no_data_univs << univ_name\n puts \"[Error] retrieving #{url} \"; puts e.message; puts e.backtrace\n page = nil\n ensure\n #puts page.inspect ; #puts page.content\n #return page\n end \n dump_web_pages_of_univ(\"#{univ_name.gsub(/\\s+/, '')}\", page.body ) if page\n end\n end\n end\n \nend",
"def perform\n if perform_crawl?\n if get_page\n store_page\n normalize_links\n filter_links\n continue_crawl\n end\n else\n # puts \"Depth limit reached for #{@url}\"\n end\n end",
"def checkHTTP(base)\n # We don't check the pattern on the form for two reasons:\n # - not all browsers support it\n # - allows the input to be more flexible\n\n # Fix up the URL\n base.strip!\n base += '/' unless base.end_with? '/'\n base = 'http://' + base unless base.start_with? 'http'\n # Now check the syntax:\n\n I \"Checking #{base} ...\"\n\n unless URLMATCH.match(base)\n F \"Invalid URL syntax: #{base}\"\n return\n end\n\n setup\n\n response = getHTTPHdrs(base)\n server = response['server']\n if server =~ /Apache/\n I \"Server: #{server}\"\n else\n W \"Server: '#{server}' - expected 'Apache' in server response\"\n end\n\n # Check the mirror time (and that zzz/ is readable)\n time = check_page(base, 'zzz/time.txt', severity = :F)\n if time\n match = /^(\\d+) \\S+$/.match(time)\n if match\n now = Time.now.to_i\n stamp = match[1].to_i\n age = (now - stamp)/60 # minutes\n if age > 60*24\n W \"Mirror is over 1 day old: #{age} minutes\"\n else\n I \"Mirror is less than 1 day old: #{age} minutes\"\n end\n else\n F \"Invalid time.txt contents: #{time}\"\n end\n else\n return # cannot process further (already recorded the error\n end\n\n # check the main body\n body = check_page(base, '')\n checkHdrFtr(base, body)\n if %r{<(img|IMG) (src|SRC)=\"/icons/}.match(body)\n I \"Index page has icons as expected\"\n else\n W \"Missing or unexpected img icon tags\"\n end\n checkIndex(body, :tlps)\n\n ibody = check_page(base, 'incubator/')\n checkHdrFtr(base+'incubator/', ibody)\n checkIndex(ibody, :podlings)\n\n check_page(base, 'harmony/', :E, expectedStatus=\"404\")\n\n zbody = check_page(base, HTTPDIR)\n# Not sure this is useful on its own anymore\n# It was originally used to detect sites with advertising wrappers,\n# but most recent examples have been tables around directory listings\n# which is obviously OK as it does not affect the user experience.\n# if %r{<table}i.match(zbody)\n# W \"#{HTTPDIR} - TABLE detected\"\n# else\n# I \"#{HTTPDIR} - No TABLE detected, OK\"\n# end\n checkHdrFtr(base+HTTPDIR, zbody)\n if HDRMATCH.match(zbody)\n I \"Index page for #{HTTPDIR} contains the expected header text\"\n else\n W \"Index page for #{HTTPDIR} does not contain the expected header text\"\n end\n if FTRMATCH.match(zbody)\n I \"Index page for #{HTTPDIR} contains the expected footer text\"\n else\n W \"Index page for #{HTTPDIR} does not contain the expected footer text\"\n end\n\n check_page(base,HTTP404,:E, expectedStatus=\"404\")\n\n # Check that archives don't have Content-Encoding\n MIRRORTEST_FILES.each do |file|\n check_CT(base, MIRRORTEST + file)\n end\n check_redirect(base, 'zzz/mirror-tests/redirect-test/xyz', 'http://www.apache.org/')\nend",
"def findPositions(count)\n\tcount += 1\n\tif count < 50\n\t\telements = $driver.find_elements(:tag_name,'a')\n\t\telements.each do |x|\n\t\t\ttxt = x.text.downcase\n\t\t\t# Less than 13 tend to not be descriptive and or internal nav links\n\t\t\tif txt.length > 13\n\t\t\t\tif txt.include?(\"ruby\")||txt.include?(\"rails\")\n\t\t\t\t\t$ruby +=1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"python\")\n\t\t\t\t\t$python +=1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"php\")\n\t\t\t\t\t$php +=1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"mobile\") || txt.include?(\"android\") || txt.include?(\"ios\")\n\t\t\t\t\t$mobile +=1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"c#\") || txt.include?(\".net\")\n\t\t\t\t\t$csharp +=1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"java\") && !txt.include?(\"javascript\")\n\t\t\t\t\t$java += 1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"javascript\") || txt.include?(\"front-end\") || txt.include?(\"angular\") || txt.include?(\"backbone\") || txt.include?(\"node\")\n\t\t\t\t\t$javascript +=1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"senior\") || txt.include?(\"sr.\")\n\t\t\t\t\t$senior += 1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"junior\") || txt.include?(\"jr.\")\n\t\t\t\t\t$junior += 1\n\t\t\t\tend\n\t\t\t\tif txt.include?(\"qa\") || txt.include?(\"sdet\")\n\t\t\t\t\t$qa += 1\n\t\t\t\tend\t\n\t\t\t\tif txt.include?(\"c++\")\n\t\t\t\t\t$clang +=1\n\t\t\t\tend\t\t\n\t\t\t\tif txt.include?(\"web\")\n\t\t\t\t\t$web +=1\n\t\t\t\tend\t\t\n\t\t\t\tif txt.include?(\"data\")\n\t\t\t\t\t$data +=1\n\t\t\t\tend\t\n\t\t\t\tif txt.include?(\"front-end\") || txt.include?(\"frontend\")\n\t\t\t\t\t$front +=1\n\t\t\t\tend\t\n\t\t\t\tif txt.include?(\"back-end\") || txt.include?(\"backend\")\n\t\t\t\t\t$back +=1\n\t\t\t\tend\t\n\t\t\tend\n\t\t\tend\n\t\tend\n\t\tbegin\n\t\t\twait = Selenium::WebDriver::Wait.new(:timeout => 3)\n\t\t\t# date loads with entries -- wait for date\n\t\t\twait.until {$driver.find_element(:class, \"date\")}\n\t\trescue Selenium::WebDriver::Error::TimeOutError\n\t\t\tsummary()\n\t\tend\n\t\t# Search the next page\n\t\tbegin\n\t\t\telement = $driver.find_element(:link_text, \"next >\")\n\t\trescue Selenium::WebDriver::Error::NoSuchElementError\n\t\t\tsummary()\n\t\tend\n\n\t\tif element.enabled?\n\t\t\telement.click\n\t\t\tfindPositions(count)\n\t\tend\nend",
"def search_on_filename\n needle = query.downcase.as_wiki_link\n all_pages.select { |name| name.downcase.include? needle }.map do |name|\n # unfreeze the String name by creating a \"new\" one\n SearchResult.new(name, 2 * @score, [0, name.tr('_', ' ')])\n end\n end",
"def test_huge_rankproperties\n @valgrind = false\n deploy_app(SearchApp.new.sd(selfdir + \"huge_expression.sd\").\n rank_expression_file(selfdir + \"huge.expression\"))\n start(360)\n feed_and_wait_for_docs(\"huge_expression\", 1, :file => selfdir + \"doc2.xml\")\n # The huge expression should give 25000*1 relevancy\n result = search_with_timeout(is_streaming ? 60 : 10, \"test&ranking=rank1\")\n assert_relevancy(result, 25000, 0)\n end",
"def scan_pages0( index, directory )\n unless index\n index = Page.new( File.join( directory, \"index.src\" ) )\n @root = index \n end\n \n @subdir_pages = get_nondir_pages( directory )\n @nondir_pages = get_subdir_pages( directory )\n \n @nondir_pages.each do |page_src|\n Page.new( page_src, index )\n end\n @subdir_pages.each do |page_src|\n page = Page.new( page_src, index )\n scan_pages( config, page, File.dirname( page_src ) )\n end\n end",
"def find_urls_on_page(doc, current_url)\t\n #puts \"Search and return URLs within the doc: #{doc}\" if @verbose\n\t\tbegin \n\t\t\turls_list = []\n\t\t\t# case 1 - search embedded HTML tag <a href='url'> for the url elements\n\t\t\tlinks=doc.css('a')\n\t\t\tlinks.map do |x|\n\t\t\t\t#puts \"x: #{x}\"\n\t\t\t\tnew_url = x.attribute('href').to_s\n\t\t\t\tunless new_url == nil\n\t\t\t\t\tif new_url.match(\"http\")\n\t\t\t\t\t\t#if urls_on_same_domain?(new_url,current_url)\n\t\t\t\t\t\t\turls_list.push(new_url)\n\t\t\t\t\t\t#end\n\t\t\t\t\telse\n\t\t\t\t\t\tnew_url = make_absolute(current_url, new_url)\n\t\t\t\t\t\turls_list.push(new_url)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\t# case 2 - search client side redirect - <meta http-equiv=\"refresh\" content=\"5;URL='http://example.com/'\">\n\t\t\telements=doc.css(\"meta[http-equiv]\")\n\t\t\tunless elements.size == 0\n\t\t\t\tlink=elements.attr(\"content\").value.split(/url\\=/i)[1]\n\t\t\t\tunless link.nil?\n\t\t\t\t\tnew_url = make_absolute(current_url, link)\n\t\t\t\t\turls_list.push(new_url) unless new_url.nil?\n\t\t\t\tend\t\t\t\t\n\t\t\tend\n\t\t\t#puts \"Found URLs under page #{current_url}:\\n#{urls_list}\" if @verbose\n\t\t\treturn urls_list.uniq-[\"\",nil]\n rescue => ee\n puts \"Exception on method #{__method__}: #{ee}\" if @verbose\n return nil\n\t\tend\n end",
"def search\r\n @search = Post.search(params[:search])\r\n @posts = @search.all\r\n @posts = @search.paginate :page => params[:page], :per_page => 24, :order => \"created_at DESC\"\r\n @posts_count = @search.count\r\n # @search = Post.offer_like_any(params[:search])\r\n # @posts = @search.all.paginate :page => params[:page], :per_page => 24, :order => \"created_at DESC\"\r\n # @posts = Post.offer_like_any(params[:search].to_s.split).paginate :page => params[:page], :per_page => 24, :order => \"created_at DESC\"\r\n # @posts = Post.company_like_any(params[:search].to_s.split).paginate :page => params[:page], :per_page => 24, :order => \"created_at DESC\"\r\n respond_to do |format|\r\n format.html # search.html.erb\r\n format.xml { render :xml => @posts }\r\n end\r\n end",
"def not_found; end",
"def crawl(pages, depth=2)\n depth.times do\n new_pages = Set.new\n pages.each do |page|\n begin\n doc = Hpricot(open(page))\n rescue\n printf \"Could not open %s\\n\", page\n next\n end\n \n add_to_index(page, doc)\n \n (doc/'a').each do |link|\n if link['href']\n url = URI.join(page, link['href']).to_s\n next if url =~ /'/\n url = url.split('#').first # drop the fragment\n if url[0,4] == 'http' and not is_indexed(url)\n new_pages << url\n end\n link_text = get_text_only(link)\n add_link_ref(page, url, link_text)\n end\n end\n end\n \n pages = new_pages\n end\n end",
"def index_www(max_sites: -1, max_data: 1_048_576_000)\n if max_sites.negative?\n Wgit.logger.info(\"Indexing until the database has been filled or it \\\nruns out of urls to crawl (which might be never).\")\n end\n site_count = 0\n\n while keep_crawling?(site_count, max_sites, max_data)\n Wgit.logger.info(\"Current database size: #{@db.size}\")\n\n uncrawled_urls = @db.uncrawled_urls(limit: 100)\n\n if uncrawled_urls.empty?\n Wgit.logger.info('No urls to crawl, exiting.')\n\n return\n end\n Wgit.logger.info(\"Starting crawl loop for: #{uncrawled_urls}\")\n\n docs_count = 0\n urls_count = 0\n\n uncrawled_urls.each do |url|\n unless keep_crawling?(site_count, max_sites, max_data)\n Wgit.logger.info(\"Reached max number of sites to crawl or \\\ndatabase capacity, exiting.\")\n\n return\n end\n site_count += 1\n\n site_docs_count = 0\n ext_links = @crawler.crawl_site(url) do |doc|\n if !doc.empty? && write_doc_to_db(doc)\n docs_count += 1\n site_docs_count += 1\n end\n end\n\n raise 'Error updating url' unless @db.update(url) == 1\n\n urls_count += write_urls_to_db(ext_links)\n\n Wgit.logger.info(\"Crawled and saved #{site_docs_count} docs for the \\\nsite: #{url}\")\n end\n\n Wgit.logger.info(\"Crawled and saved docs for #{docs_count} url(s) \\\noverall for this iteration.\")\n Wgit.logger.info(\"Found and saved #{urls_count} external url(s) for \\\nthe next iteration.\")\n\n nil\n end\n end",
"def search_process\r\nsearch_text=params[:q].to_s\r\nall=params[:all].to_s\r\nexact=params[:exact].to_s\r\nany=params[:any].to_s\r\nnone=params[:none].to_s\r\nadvanced_query=\"\"\r\n\r\nif all != \"\"\r\nall=all.split(' ')\r\nall_like=all.map {|x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nall_like=all_like.join(' and ')\r\nadvanced_query=all_like\r\nend\r\n\r\nif exact != \"\" && all != \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = advanced_query + \" and keyword like \" + exact\r\nend\r\n\r\nif exact != \"\" && all == \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = \"keyword like \" + exact\r\nend\r\n\r\nif any != \"\" and ( all != \"\" or exact != \"\" )\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = advanced_query + \" and (\" + any_like + \")\"\r\nend\r\n\r\nif any != \"\" and all == \"\" and exact == \"\"\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = \"(\" + any_like + \")\"\r\nend\r\n\r\nif none != \"\" and (all != \"\" or exact != \"\" or any != \"\")\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query=advanced_query + \" and \" + none_not_like\r\n\r\nend\r\n\r\nif none != \"\" and all == \"\" and exact == \"\" and any == \"\"\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query= none_not_like\r\nend\r\n\r\n\r\n\r\n\r\n\r\nadvanced_query = \"SELECT Model_ID FROM keyword_symbol_tables WHERE \"+advanced_query\r\nputs \"\\n\\n***********************************\\n\\n\"+advanced_query+\"\\n\\n**********************\\n\\n\"\r\n\r\nparameter_search_text=search_text.split.join(\" \")\r\n keyword_array=parameter_search_text.split(' ')\r\n keyword_count=keyword_array.size\r\n\r\nconnection = ActiveRecord::Base.connection();\r\nif all != \"\" or exact != \"\" or any != \"\" or none != \"\"\r\n@resultset = connection.execute(\"#{advanced_query}\");\r\nelse\r\n@resultset = connection.execute(\"call keyword_search('#{parameter_search_text}',#{keyword_count})\");\r\nend\r\nActiveRecord::Base.clear_active_connections!()\r\n\r\n@resultset.each do |res|\r\nputs res\r\nend\r\n@resultset_strings = @resultset.map { |result| result.to_s.gsub(/[^0-9A-Za-z]/, '')}\r\n@model_ids=Array.new\r\n@model_names=Array.new\r\n@model_types=Array.new\r\n@resultset_strings.each do |result|\r\nsubstring=result[0..4]\r\nputs\"\\n\\n************\"+substring\r\nif substring == \"NMLCL\"\r\ncell=Cell.find_by_Cell_ID(result.to_s)\r\nname=cell.Cell_Name\r\ntype=\"Cell\"\r\nend\r\n\r\nif substring == \"NMLCH\"\r\nchannel=Channel.find_by_Channel_ID(result.to_s)\r\nname=channel.Channel_Name\r\ntype=\"Channel\"\r\nend\r\n\r\n\r\nif substring == \"NMLNT\"\r\nnetwork=Network.find_by_Network_ID(result.to_s)\r\nname=network.Network_Name\r\ntype=\"Network\"\r\nend\r\n\r\n#if substring == \"NMLSY\"\r\n#name=Synapse.find_by_Synapse_ID(result.to_s)\r\n#type=\"Syanpse\"\r\n#end\r\n\r\n@model_ids.push(result)\r\n@model_names.push(name)\r\n@model_types.push(type)\r\nputs \"result-\"+result+\"name-\"+name.to_s\r\nend\r\n\r\nif @model_ids.count != 0\r\nrender :partial => 'keyword_results_list',:locals => {:model_ids => @model_ids,:model_names => @model_names,:model_types => @model_types}\r\nelse\r\nrender :partial => 'no_results'\r\nend\r\n\r\n\r\n end",
"def search_process\r\nsearch_text=params[:q].to_s\r\nall=params[:all].to_s\r\nexact=params[:exact].to_s\r\nany=params[:any].to_s\r\nnone=params[:none].to_s\r\nadvanced_query=\"\"\r\n\r\nif all != \"\"\r\nall=all.split(' ')\r\nall_like=all.map {|x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nall_like=all_like.join(' and ')\r\nadvanced_query=all_like\r\nend\r\n\r\nif exact != \"\" && all != \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = advanced_query + \" and keyword like \" + exact\r\nend\r\n\r\nif exact != \"\" && all == \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = \"keyword like \" + exact\r\nend\r\n\r\nif any != \"\" and ( all != \"\" or exact != \"\" )\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = advanced_query + \" and (\" + any_like + \")\"\r\nend\r\n\r\nif any != \"\" and all == \"\" and exact == \"\"\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = \"(\" + any_like + \")\"\r\nend\r\n\r\nif none != \"\" and (all != \"\" or exact != \"\" or any != \"\")\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query=advanced_query + \" and \" + none_not_like\r\n\r\nend\r\n\r\nif none != \"\" and all == \"\" and exact == \"\" and any == \"\"\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query= none_not_like\r\nend\r\n\r\n\r\n\r\n\r\n\r\nadvanced_query = \"SELECT Model_ID FROM keyword_symbol_tables WHERE \"+advanced_query\r\nputs \"\\n\\n***********************************\\n\\n\"+advanced_query+\"\\n\\n**********************\\n\\n\"\r\n\r\nparameter_search_text=search_text.split.join(\" \")\r\n keyword_array=parameter_search_text.split(' ')\r\n keyword_count=keyword_array.size\r\n\r\nconnection = ActiveRecord::Base.connection();\r\nif all != \"\" or exact != \"\" or any != \"\" or none != \"\"\r\n@resultset = connection.execute(\"#{advanced_query}\");\r\nelse\r\n@resultset = connection.execute(\"call keyword_search('#{parameter_search_text}',#{keyword_count})\");\r\nend\r\nActiveRecord::Base.clear_active_connections!()\r\n\r\n@resultset.each do |res|\r\nputs res\r\nend\r\n@resultset_strings = @resultset.map { |result| result.to_s.gsub(/[^0-9A-Za-z]/, '')}\r\n@model_ids=Array.new\r\n@model_names=Array.new\r\n@model_types=Array.new\r\n@resultset_strings.each do |result|\r\nsubstring=result[0..4]\r\nputs\"\\n\\n************\"+substring\r\nif substring == \"NMLCL\"\r\ncell=Cell.find_by_Cell_ID(result.to_s)\r\nname=cell.Cell_Name\r\ntype=\"Cell\"\r\nend\r\n\r\nif substring == \"NMLCH\"\r\nchannel=Channel.find_by_Channel_ID(result.to_s)\r\nname=channel.Channel_Name\r\ntype=\"Channel\"\r\nend\r\n\r\n\r\nif substring == \"NMLNT\"\r\nnetwork=Network.find_by_Network_ID(result.to_s)\r\nname=network.Network_Name\r\ntype=\"Network\"\r\nend\r\n\r\n#if substring == \"NMLSY\"\r\n#name=Synapse.find_by_Synapse_ID(result.to_s)\r\n#type=\"Syanpse\"\r\n#end\r\n\r\n@model_ids.push(result)\r\n@model_names.push(name)\r\n@model_types.push(type)\r\nputs \"result-\"+result+\"name-\"+name.to_s\r\nend\r\n\r\nif @model_ids.count != 0\r\nrender :partial => 'keyword_results_list',:locals => {:model_ids => @model_ids,:model_names => @model_names,:model_types => @model_types}\r\nelse\r\nrender :partial => 'no_results'\r\nend\r\n\r\n\r\n end",
"def check_keyword_results\n i = 0\n # This boolean variable is set to false in advance for every freelancer and set to true only if any condition is met\n keyword_is_present = false\n wait_for { displayed?(RESULTS) }\n results_array = get_array(RESULTS)\n\n # This method iterates on the results array only for the first 10 elements (1st page of results)\n results_array.each do |elem|\n i=i+1\n if(i > 10)\n break\n end\n # For each element it is extracted this attribute and uses regex expression to take only {...} to create JSON file\n results_json = elem.attribute(\"data-ng-click\").match(/\\{(.*)\\}/).to_s\n json_file = JSON.parse(results_json.to_s)\n # Extracting from JSON created only the fields that we need for verification against the keyword searched\n short_name = json_file['shortName'].to_s\n title = json_file['title'].to_s\n description = json_file['description'].to_s\n skills = json_file['skills'].to_s\n # Creating a hash for each freelancer\n hash = {:name => short_name.to_s, :description => description.to_s, :title => title.to_s, :skills => skills.to_s}\n # Pushing each hash created to an array variable that will be used on the verification\n @@array.push(hash)\n end\n log \"STEP 7: Parse the 1st page with search results: store info given on the 1st page of search results as structured data of any chosen by you type (i.e. hash of hashes or array of hashes, whatever structure handy to be parsed).\"\n log \"STEP 8: Make sure at least one attribute (title, overview, skills, etc) of each item (found freelancer) from parsed search results contains '#{$keyword}' Log in stdout which freelancers and attributes contain '#{$keyword}' and which do not.\"\n # Iterating over the first page results array\n @@array.each do |freelancer|\n # Extracting data from each hash\n title = freelancer[:title].to_s\n description = freelancer[:description].to_s\n skills = freelancer[:skills].to_s\n keyword = $keyword.to_s\n # Verifies whether keyword is present on any field of each, if so keyword_is_present = true (avoiding a test failure)\n if title.include?(keyword.to_s)\n keyword_is_present = true\n elsif description.include?(keyword.to_s)\n keyword_is_present = true\n elsif skills.include?(keyword.to_s)\n keyword_is_present = true\n end\n # Verification: for each freelancer, if keyword_is_present is false, then keyword was not present on all important fields\n if keyword_is_present == false\n # log which freelancer is\n log \"ERROR!!! => Description differs between profiles search results and freelancer profile for #{@@array[@@n.to_i][:name].to_s}.\"\n puts \"freelancer failed: #{freelancer[:name].to_s}\"\n # In addition of logging this failure, the whole test case needs to be marked as FAILED by setting global variable $test_result\n $test_result = false\n else\n puts \"freelancer passed: #{freelancer[:name].to_s}\"\n end\n end\n end",
"def custom_render_not_found\n post_types = []\n categories = []\n posts = []\n\n PAGENOTFOUND_DEFAULTS.keys.each do |option|\n next if option.to_s == 'tags'\n slugs = get_pagenotfound_slugs(option.to_s)\n post_types = post_types | slugs[:post_types] if slugs[:post_types].present?\n categories = categories | slugs[:categories] if slugs[:categories].present?\n posts = posts | slugs[:posts] if slugs[:posts].present?\n end\n\n self.render_page_not_found if request.path == \"/index.html\" ||\n params[:action] == 'post_type' && post_types.include?(params['post_type_slug']) ||\n params[:action] == 'post' && posts.include?(params[:slug]) ||\n params[:action] == 'category' && get_pagenotfound_option('category_list').include?(params[:category_id].to_i)\n end",
"def bad_urls\n result = []\n @pages.each do |page|\n result << page.hlu\n end\n result.compact!\n end",
"def nonadword_urls(page)\n\t\tnonadwords_xpath(page).inject([]) do |result, adword|\n\t\t\tresult << fetch_nonadword_url(adword)\n\t\tend\t\t\n\tend",
"def run\n page_faults=0\n\n extra_info=`mongo --eval \"printjson(db.serverStatus().extra_info.page_faults)\"`\n extra_info.each_line do |line|\n page_faults=line if line.match /^[0-9]*/\nend\n\n message \"#{page_faults} pagefaults occured \"\n warning if page_faults.to_i > config[:warn]\n critical if page_faults.to_i > config[:crit]\n ok\n\n end",
"def search_process\n @search_text =params[:q].to_s\n all =params[:all].to_s\n exact =params[:exact].to_s\n any =params[:any].to_s\n none =params[:none].to_s\n advanced_query=\"\"\n\n if all != \"\"\n all =all.split(' ')\n all_like =all.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\n all_like =all_like.join(' and ')\n advanced_query=all_like\n end\n\n if exact != \"\" && all != \"\"\n exact =\"'%\"+exact+\"%'\"\n advanced_query = advanced_query + \" and keyword like \" + exact\n end\n\n if exact != \"\" && all == \"\"\n exact =\"'%\"+exact+\"%'\"\n advanced_query = \"keyword like \" + exact\n end\n\n if any != \"\" and (all != \"\" or exact != \"\")\n any =any.split(' ')\n any_like =any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\n any_like =any_like.join(' or ')\n advanced_query = advanced_query + \" and (\" + any_like + \")\"\n end\n\n if any != \"\" and all == \"\" and exact == \"\"\n any =any.split(' ')\n any_like =any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\n any_like =any_like.join(' or ')\n advanced_query = \"(\" + any_like + \")\"\n end\n\n if none != \"\" and (all != \"\" or exact != \"\" or any != \"\")\n none =none.split(' ')\n none_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\n\n none_not_like=none_not_like.join(' and ')\n\n advanced_query=advanced_query + \" and \" + none_not_like\n\n end\n\n if none != \"\" and all == \"\" and exact == \"\" and any == \"\"\n none =none.split(' ')\n none_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\n\n none_not_like=none_not_like.join(' and ')\n\n advanced_query= none_not_like\n end\n\n\n advanced_query = \"SELECT Model_ID FROM keyword_symbol_tables WHERE \"+advanced_query\n\n parameter_search_text=@search_text.split.join(\" \")\n keyword_array =parameter_search_text.split(' ')\n keyword_count =keyword_array.size\n\n connection = ActiveRecord::Base.connection\n\n if all != \"\" or exact != \"\" or any != \"\" or none != \"\"\n @resultset = connection.execute(\"#{advanced_query}\");\n else\n @resultset = connection.execute(\"call keyword_search('#{parameter_search_text}',#{keyword_count})\");\n end\n\n ActiveRecord::Base.clear_active_connections!\n\n @resultset_strings = @resultset.map { |result| result.to_s.gsub(/[^0-9A-Za-z]/, '') }\n\n @model_ids =Array.new\n @model_names =Array.new\n @model_types =Array.new\n\n @resultset_strings.each do |result|\n\n substring=result[0..4]\n\n if substring == \"NMLCL\"\n cell=Cell.find_by_Cell_ID(result.to_s)\n name=cell.Cell_Name\n type=\"Cell\"\n end\n\n if substring == \"NMLCH\"\n channel=Channel.find_by_Channel_ID(result.to_s)\n name =channel.Channel_Name\n type =\"Channel\"\n end\n\n\n if substring == \"NMLNT\"\n network=Network.find_by_Network_ID(result.to_s)\n name =network.Network_Name\n type =\"Network\"\n end\n\n if substring == \"NMLSY\"\n synapse=Synapse.find_by_Synapse_ID(result.to_s)\n name =synapse.Synapse_Name\n type =\"Synapse\"\n end\n\n @model_ids.push(result)\n @model_names.push(name)\n @model_types.push(type)\n\n end\n\n if @model_ids.count != 0\n\n render :partial => 'keyword_results_list',\n :locals => {\n :model_ids => @model_ids,\n :model_names => @model_names,\n :model_types => @model_types\n }\n\n else\n\n render :partial => 'no_results'\n\n end\n\n end",
"def perfect_match\n query = @query.downcase.as_wiki_link\n page = all_pages.detect { |name| name.downcase == query }\n SearchResult.new(page, 1) if page\n end",
"def find_3rd_party_apps(weibo_screen_name)\n user = $client.user_show_by_screen_name(weibo_screen_name) ;#user = $client.user_show 1961488257\n sts = $client.statuses(user.id)\n \n sources = {}\n i = 0\n while sts.next_page? #Loops untill end of collection\n sts.each do | s |\n link = Nokogiri::XML s.source\n xpath = \"//a[@href]\"\n elem = link.search(xpath) # ; puts elem.first.text ; puts elem.first['href']\n \n uri = URI(elem.first['href']).host\n sources[elem.first.text] = uri unless sources.keys.include? elem.first.text\n \n # IDEA: it doesn't looks smart to iterative through all the statuses to find out all 3rd party links. Better solution?\n \n # Debug use: limited search\n #i += 1\n #if i > 5 then\n # break \n #end\n end\n end \n # puts sources.inspect\n return sources\nend",
"def nonadword_count_total(page)\n\t\tnonadword_urls(page).length\n\tend",
"def traverse_links(seed_url, max_pages, output_dir, algo, spam_path, nonspam_path)\n spamCalc = SpamCalculator.new(spam_path, nonspam_path)\n #contains [link, spamScore] arrays for the sake of bestfirst\n links_to_visit = []\n links_to_visit.push([seed_url, 0])\n pages_visited = 0\n time_of_last_get = Time.now.to_f\n while (links_to_visit.length != 0 && pages_visited < max_pages)\n time_difference = Time.now.to_f - time_of_last_get\n if time_difference < 1\n sleep(1-time_difference)\n end\n time_of_last_get = Time.now.to_i\n link = links_to_visit.pop[0]\n puts \"link: \" + link\n if $index[link]\n next\n end\n process_results = process_link(link, output_dir, spamCalc, pages_visited)\n if !process_results\n puts \"error retrieving page at \" + link\n next\n end\n currentPage = process_results[0]\n currentScore = process_results[1]\n pages_visited += 1\n puts \"size: \" + $index.size.to_s\n links = find_links(process_results[0])\n for link in links\n if !link.is_a?(\"\".class)\n abort \"Non-string in link queue\"\n end\n if $index.has_key?(link) || links_to_visit.include?(link)\n next\n end\n if (algo == 'dfs' || algo == 'bestfirst')\n links_to_visit.push([link, currentScore])\n elsif (algo == 'bfs')\n links_to_visit.unshift([link, currentScore])\n else\n abort \"Not a valid algorithm name\"\n end\n end\n if (algo == 'bestfirst')\n links_to_visit.sort_by!{|item| -item[1]}\n end\n end\n path_to_index_file = File.join(output_dir + '../index.dat').to_s\n puts path_to_index_file\n output = File.new(path_to_index_file, \"w+\")\n for key in $index.keys\n scoreAndFilename = $index[key]\n output_line = scoreAndFilename[1] + \"\\t\" + scoreAndFilename[0].to_s + \"\\t\" + key + \"\\n\"\n output.write(output_line)\n end\n output.close\nend",
"def run\n super\n\n # Attach to the google service & search\n results = Client::Google::SearchService.new.search(@entity.name)\n\n results.each do |result|\n # Create a domain\n create_entity Entities::DnsRecord, :name => result[:visible_url]\n\n # Create the top-level domain\n create_entity Entities::DnsRecord, :name => result[:visible_url].split(\".\").last(2).join(\".\")\n\n #Handle Twitter search results\n if result[:title_no_formatting] =~ /on Twitter/\n account_name = result[:title_no_formatting].scan(/\\(.*\\)/).first[1..-2]\n create_entity(Entities::TwitterAccount, { :name => account_name,\n :uri => \"http://www.twitter.com/#{account_name}\" })\n \n # Handle Facebook search results\n elsif result[:unescaped_url] =~ /https:\\/\\/www.facebook.com/\n account_name = result[:unescaped_url].scan(/[^\\/]+$/).first\n create_entity(Entities::FacebookAccount, { :name => account_name, \n :uri => \"http://www.facebook.com/#{account_name}\" })\n \n # Handle LinkedIn search results\n elsif result[:unescaped_url] =~ /http:\\/\\/www.linkedin.com\\/in/\n account_name = result[:unescaped_url].scan(/[^\\/]+$/).first\n create_entity(Entities::LinkedinAccount, { :name => account_name,\n :uri => \"http//www.linkedin.com/in/#{account_name}\" })\n # Otherwise, just create a generic search result\n else\n create_entity(Entities::WebPage, {\n :name => result[:title_no_formatting],\n :uri => result[:unescaped_url],\n :content => result[:content]\n })\n end\n end\n\nend",
"def scrape_items(url)\n page = Nokogiri::HTML(open(url))\n # debug, todo: make conditional, if DEBUG\n print url\n div = page.xpath(\"//div[@class = 'postarea']\")\n paras = div.xpath(\"//p[position() > 2]\")\n # debug, todo: make conditional, if DEBUG\n print paras.count.to_s()\n paras.each {\n |para|\n scrape(para)\nparas.length\n }\nend",
"def scrape_items(url)\n page = Nokogiri::HTML(open(url))\n # debug, todo: make conditional, if DEBUG\n print url\n div = page.xpath(\"//div[@class = 'postarea']\")\n paras = div.xpath(\"//p[position() > 2]\")\n # debug, todo: make conditional, if DEBUG\n print paras.count.to_s()\n paras.each {\n |para|\n scrape(para)\nparas.length\n }\nend"
] | [
"0.62940407",
"0.61513144",
"0.60866755",
"0.5989479",
"0.59825987",
"0.58607256",
"0.5754765",
"0.5718583",
"0.56773067",
"0.5640277",
"0.5631777",
"0.5624514",
"0.56178576",
"0.5604908",
"0.5587801",
"0.55495423",
"0.55492294",
"0.5548418",
"0.551061",
"0.550915",
"0.5471665",
"0.5459459",
"0.5433099",
"0.5429643",
"0.5427875",
"0.54246366",
"0.5409822",
"0.5400982",
"0.5397452",
"0.5372611",
"0.5371516",
"0.53665197",
"0.53653514",
"0.53545547",
"0.53339416",
"0.5332181",
"0.53228104",
"0.5316221",
"0.5305813",
"0.53006315",
"0.52946043",
"0.52805895",
"0.5277929",
"0.52647454",
"0.52606153",
"0.52509105",
"0.5249435",
"0.52466893",
"0.52456045",
"0.5193231",
"0.5190681",
"0.5185013",
"0.51846623",
"0.51831967",
"0.51794916",
"0.5174009",
"0.5172948",
"0.5155464",
"0.51449865",
"0.51320153",
"0.5130648",
"0.5122033",
"0.51200384",
"0.5118206",
"0.51071006",
"0.5106128",
"0.50998",
"0.50952214",
"0.50838566",
"0.50831187",
"0.50806874",
"0.5077698",
"0.5073734",
"0.50726265",
"0.5071112",
"0.5061201",
"0.5035449",
"0.50279415",
"0.50267893",
"0.5025823",
"0.5016077",
"0.50154984",
"0.50119334",
"0.50063944",
"0.50032735",
"0.49973908",
"0.49966267",
"0.49966267",
"0.49836862",
"0.49794015",
"0.49787703",
"0.49768558",
"0.49761406",
"0.49702853",
"0.49684638",
"0.49647143",
"0.4962657",
"0.49616224",
"0.49600512",
"0.49595857",
"0.49595857"
] | 0.0 | -1 |
find the cookie for this app deserialize the cookie into a hash | def initialize(cookie)
@cookie = cookie
@now = cookie[FLASH_KEY] || {}
reset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode cookie\n data = cookie[@name].to_s\n return empty_hash if data.empty?\n\n sig, str = data.split '/', 2\n return empty_hash unless str\n\n h = nil\n digest = nil\n begin\n sig = decode64 sig\n digest = @dss.digest str\n if @dsa.sysverify(digest, sig)\n str = @cipher_key ? decipher(str) : decode64(str)\n h = JSON.parse str, JSON_DECODE_OPTS\n end\n ensure\n return empty_hash unless h\n end\n\n if h.is_a?(Session)\n h.instance_variable_set :@init_digest, digest\n h.instance_variable_set :@init_data, data\n h\n else\n empty_hash\n end\n end",
"def unmarshal(cookie)\n if cookie.blank?\n {}\n else\n data, digest = Merb::Parse.unescape(cookie).split('--')\n return {} if data.blank? || digest.blank?\n unless digest == generate_digest(data)\n clear\n unless Merb::Config[:ignore_tampered_cookies]\n raise TamperedWithCookie, \"Maybe the site's session_secret_key has changed?\"\n end\n end\n unserialize(data)\n end\n end",
"def unmarshal(cookie)\n if cookie\n data, digest = cookie.split('--')\n return {} unless digest == generate_digest(data)\n Marshal.load(data.unpack('m').first)\n end\n end",
"def unmarshal(cookie)\n if cookie\n data, digest = cookie.split('--')\n return {} if data.blank?\n unless digest == generate_digest(data)\n delete\n raise TamperedWithCookie, \"Maybe the site's session_secret_key has changed?\"\n end\n Marshal.load(Base64.decode64(data))\n end\n end",
"def get_id_from_cookie\n Sinatra::Authentication::Cookies::Hashing.decrypt(cookies[:ottoman_connection], settings.private_key)\n end",
"def unmarshal(cookie)\n persistent_session_id!(@verifier.verify(cookie)) if cookie\n rescue ActiveSupport::MessageVerifier::InvalidSignature\n nil\n end",
"def cookie_hash\n\t\t\t{ 'Cookie' => @cookies.to_s }\n\t\tend",
"def read_cookie\n unless @data.nil?\n updated = marshal(@data)\n raise CookieOverflow if updated.size > MAX\n updated\n end\n end",
"def get_cookie\n self.headers[\"Cookie\"]\n end",
"def cookie(cookie)\n raise \"No HTTP-session attached to this thread.\" if !_httpsession\n raise \"HTTP-session not active.\" if !_httpsession.resp\n raise \"Not a hash: '#{cookie.class.name}', '#{cookie}'.\" unless cookie.is_a?(Hash)\n _httpsession.resp.cookie(cookie)\n return nil\n end",
"def cookie_content\n @cookie_content ||= parse_cookie\n end",
"def cookie_content\n @cookie_content ||= parse_cookie\n end",
"def extract(env)\n hash = env[Action::COOKIE_HASH_KEY] ||= {}\n string = env[Action::HTTP_COOKIE]\n\n return hash if string == env[Action::COOKIE_STRING_KEY]\n\n # TODO: Next Rack 1.7.x ?? version will have ::Rack::Utils.parse_cookies\n # We can then replace the following lines.\n hash.clear\n\n # According to RFC 2109:\n # If multiple cookies satisfy the criteria above, they are ordered in\n # the Cookie header such that those with more specific Path attributes\n # precede those with less specific. Ordering with respect to other\n # attributes (e.g., Domain) is unspecified.\n cookies = ::Rack::Utils.parse_query(string, COOKIE_SEPARATOR) { |s|\n begin\n ::Rack::Utils.unescape(s)\n rescue StandardError\n s\n end\n }\n cookies.each { |k, v| hash[k] = v.is_a?(Array) ? v.first : v }\n env[Action::COOKIE_STRING_KEY] = string\n hash\n end",
"def serialize_into_cookie\n [uid, self.remember_token]\n end",
"def serialize_from_cookie(*args); end",
"def hubssolib_get_secure_cookie_data(name)\n return HubSsoLib::Crypto.decode_object(cookies[name], request.remote_ip)\n end",
"def get_cookie\n cookies[GeventAnalysis::Application::CONSTS[:cookie_name]]\n end",
"def raw_cookie\n @raw_cookie ||= controller.cookies[\"fbs_#{self.facebook_api_key}\"]\n end",
"def to_cookie\n unless self.empty?\n data = self.serialize\n value = Merb::Parse.escape \"#{data}--#{generate_digest(data)}\"\n if value.size > MAX\n msg = \"Cookies have limit of 4K. Session contents: #{data.inspect}\"\n Merb.logger.error!(msg)\n raise CookieOverflow, msg\n end\n value\n end\n end",
"def cookies\n HTTY::CookiesUtil.cookies_from_string @headers[COOKIES_HEADER_NAME]\n end",
"def serialize_into_cookie(record); end",
"def hashcookie\n cookies[daw_cookie_name] && Digest::SHA1.hexdigest(cookies[daw_cookie_name])\n end",
"def extract(env)\n hash = env[COOKIE_HASH_KEY] ||= {}\n string = env[HTTP_HEADER]\n\n return hash if string == env[COOKIE_STRING_KEY]\n # TODO Next Rack 1.7.x ?? version will have ::Rack::Utils.parse_cookies\n # We can then replace the following lines.\n hash.clear\n\n # According to RFC 2109:\n # If multiple cookies satisfy the criteria above, they are ordered in\n # the Cookie header such that those with more specific Path attributes\n # precede those with less specific. Ordering with respect to other\n # attributes (e.g., Domain) is unspecified.\n cookies = ::Rack::Utils.parse_query(string, COOKIE_SEPARATOR) { |s| ::Rack::Utils.unescape(s) rescue s }\n cookies.each { |k,v| hash[k] = Array === v ? v.first : v }\n env[COOKIE_STRING_KEY] = string\n hash\n end",
"def cookie\n { :value => Crypt.encrypt(cookie_value), :expires => 1.year.from_now }\n end",
"def cookie_value\n @screen_data.to_json\n end",
"def auth_cookie\n cookies[:auth]\n end",
"def http_cookie\n http.cookie\n end",
"def get_cookie\n txid = get_txid\n response = send('q' => 'cookie', 'txid' => txid)\n raise 'wrong txid in reply' if response['txid'] and response['txid'] != txid\n response['cookie']\n end",
"def stash_cookie\n cookies[self.class.els_options['cookie']] = {\n :value => @els_identity.token_id,\n :domain => request.env[\"SERVER_NAME\"],\n :path => '/',\n :expires => Time.now + 24.hours\n }\n end",
"def getCookie()\n return @cookie\n\tend",
"def serialize_from_cookie(*args)\n id, token, generated_at = *args\n\n record = to_adapter.get(id)\n record if record && record.remember_me?(token, generated_at)\n end",
"def decrypt_cookie(cookie)\n servicename, serverip, serverport = parse_cookie(cookie)\n realname = decrypt_service_name(servicename)\n realip = decrypt_server_ip(serverip)\n realport = decrypt_server_port(serverport)\n [realname, realip, realport]\nend",
"def get_cookie(my_env,key)\r\n cookies = Hash.new\r\n if my_env.has_key?('rack.request.cookie_hash')\r\n if my_env['rack.request.cookie_hash'].has_key?(key)\r\n return(my_env['rack.request.cookie_hash'][key])\r\n else\r\n return(nil)\r\n end\r\n end\r\n end",
"def cookie\n @cookie ||= Coca::AuthCookie.new(cookies, scope)\n end",
"def decrypt_cookie(data)\n data.nil? ? {} : Firebug.unserialize(Firebug.decrypt(Base64.strict_decode64(data)))\n end",
"def raw_cookie\n env_table[\"HTTP_COOKIE\"]\n end",
"def encode_to_cookie h, cookie\n cookie[@name] = encode h\n end",
"def name_and_value\n @cookie.split(\";\").first\n end",
"def payload\n token = cookies.signed[:remember_me_token]\n JsonWebToken.decode(token)\n rescue\n nil\n end",
"def to_hash\n cookies = {}\n\n @cookies.each do |cookie|\n cookies[cookie.name] = cookie.value\n end\n\n cookies\n end",
"def get_cookie\n resp = @cookie\n if @atl_token != \"\"\n resp = resp + \"; atl.xsrf.token=#{@atl_token}\"\n end\n puts \"Using cookie: #{resp}\".yellow\n resp\n end",
"def cookie_info\n authenticated_crowd_call(:get_cookie_info)\n end",
"def get_user_data\n user_data = nil\n \n if cookies.has_key?(:user_data) && cookies[:user_data].to_s != ''\n user_data = string_to_hash(cookies[:user_data])\n end\n user_data\n end",
"def cookies\n rack_request.cookies\n end",
"def cookie_hash_offset\n super\n end",
"def raw_cookie2\n env_table[\"HTTP_COOKIE2\"]\n end",
"def decoded_token\n if token_from_cookie\n token= token_from_cookie\n # byebug\n begin\n JWT.decode(token, Rails.application.credentials.jwt_token, true, algorithm: \"HS256\")\n # JWT.decode => [{ \"user_id\"=>\"2\" }, { \"alg\"=>\"HS256\" }]\n rescue JWT::DecodeError\n nil\n end\n end\n end",
"def get_cookie(data)\n if data['set-cookie']\n t = []\n data['Set-Cookie'].split(\", \").map{|c|\n tmp = c.scan(/([a-zA-Z0-9_\\-\\.]*=[^;]*)/).flatten\n tmp.delete_if{|cc| cc.downcase.include?(\"path\")}\n tmp.delete_if{|cc| cc.downcase.include?(\"expires\")}\n tmp.delete_if{|cc| cc.downcase.include?(\"domain\")}\n t << tmp\n }\n if t.length == 1\n @cookie = @cookie + t.join(\"; \")\n else\n @cookie = t.join(\"; \")\n end\n end\n end",
"def cookies\n @cookies ||= (self.headers[:set_cookie] || \"\").split('; ').inject({}) do |out, raw_c|\n key, val = raw_c.split('=')\n unless %w(expires domain path secure).member?(key)\n out[key] = val\n end\n out\n end\n end",
"def my_archive_from_cookie\n # initialize the cookie store if nil?\n if cookies[:my_archive].nil?\n my_archive_to_cookie\n end\n return cookies[:my_archive].split(\",\").map{ |i| i.to_i }\n end",
"def get_cookies\n {\n method: \"Page.getCookies\"\n }\n end",
"def cookie\n @xmlrpc.cookie\n end",
"def cookie_to_mash(headers)\n if headers && headers.is_a?(Faraday::Utils::Headers)\n cookie = headers_to_mash(headers).set_cookie\n if cookie\n sanitized_cookie = cookie.split(/\\;/).map{|x|\n key,value = x.split(\"=\");\n {key.strip.gsub(/\\W/,\"_\").gsub(/^\\_|\\_$/,\"\").to_sym => value.to_s.downcase.strip}\n }\n return sanitized_cookie.reduce Hashie::Mash.new, :merge\n end\n end\n end",
"def cookies\n request.cookies\n end",
"def get_string_from_cookie_data(cookie_h)\n expiration = cookie_h.expiration\n cookie_h.to_cookie_string if expiration.blank? || (expiration.present? && expiration >= Time.zone.now.gmtime)\n end",
"def [](name)\n cookie = @cookies[name.to_s]\n if cookie && cookie.respond_to?(:value)\n cookie.size > 1 ? cookie.value : cookie.value[0]\n else\n cookie\n end\n end",
"def get_ext_cookie(key)\n c = cookies['ys-' + key]\n row = c.split(/:/)\n case row[0]\n when 's'\n return row[1]\n when 'n'\n return row[1].to_s\n when 'o'\n return JSON.parse(row[1])\n end\n return false\n end",
"def cookie_value; end",
"def cookie_hash_length\n super\n end",
"def cookies\n request.cookies\n end",
"def retrieve_tag(cli, request)\n cookie = CGI::Cookie.parse(request.headers['Cookie'].to_s)\n tag = cookie.has_key?(cookie_name) && cookie[cookie_name].first\n\n if tag.blank?\n # Browser probably doesn't allow cookies, plan B :-/\n vprint_status(\"No cookie received for #{cli.peerhost}, resorting to headers hash.\")\n ip = cli.peerhost\n os = request.headers['User-Agent']\n tag = Rex::Text.md5(\"#{ip}#{os}\")\n else\n vprint_status(\"Received cookie '#{tag}' from #{cli.peerhost}\")\n end\n\n tag\n end",
"def extract_cookie(cookie_val)\n cleaned_val = cookie_val.gsub(/(path=[^,;]+[,;])|(expires=.*)/, ' ')\n cleaned_val.gsub!(/\\s+/, ' ')\n\n if @proxied_cookies.empty?\n return ['', cleaned_val]\n else\n @proxied_cookies.each do |key|\n if match = cleaned_val.match(/#{key}=(?<val>(.*));/i)\n return [key, match[:val]]\n end\n end\n end\n\n ['', '']\n end",
"def credentials\n if self.authenticating_with_facebook?\n {\n :facebook_cookie => self.raw_cookie\n }\n else\n super\n end\n end",
"def get_cookie(name)\n @cookies.each do |cookie|\n return cookie if cookie.name == name\n end\n nil\n end",
"def load_cookie_jar_json(jar, data)\n VkMusic.log.info('cookie_reader') { 'Loading JSON cookies' }\n JSON.parse(data).each_pair do |k, v|\n jar.add(URI('https://m.vk.com'), HTTP::Cookie.new(k, v))\n end\n end",
"def name\n @cookie.split(\"=\").first\n end",
"def store(fortune_cookie_text)\n hash = msg(fortune_cookie_text)\n puts \"Stored cookie: #{fortune_cookie_text}\"\n puts \"Cookie ID: #{hash}\"\n return hash\n end",
"def session_cookie_value\n cookies[_session_id_key]\n end",
"def sso_cookie_content\n return nil if @current_user.blank?\n\n {\n 'patientIcn' => (@current_user.mhv_icn || @current_user.icn),\n 'mhvCorrelationId' => @current_user.mhv_correlation_id,\n 'signIn' => @current_user.identity.sign_in.deep_transform_keys { |key| key.to_s.camelize(:lower) },\n 'credential_used' => sso_cookie_sign_credential_used,\n 'expirationTime' => @session_object.ttl_in_time.iso8601(0)\n }\n end",
"def cookies\n CookieJar.new(self)\n end",
"def get(cookie_hash)\n begin\n commit = Commit.find(:user => @user, :repo => @repo_name, :sha => cookie_hash)\n return commit.message\n rescue Octopi::NotFound\n puts \"Requested cookie does not exist.\"\n return nil\n end\n end",
"def cookies\n request.cookies\n end",
"def cookies\n @agent.cookie_jar.to_a\n end",
"def cookie\n shiftnote = RestClient.get('https://ww1.shiftnote.com/BulletinBoard/', Cookie: @cookie)\n\n doc = Nokogiri::HTML.parse(shiftnote.body)\n\n begin\n doc.search('div#MyScheduleDiv').at('script').text\n rescue NoMethodError\n generate_cookie(@credentials[:username], @credentials[:password])\n end\n @cookie\n end",
"def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secret_key_base)\n config = Rails.application.config\n cookie = CGI.unescape(cookie)\n salt = config.action_dispatch.authenticated_encrypted_cookie_salt\n encrypted_cookie_cipher = config.action_dispatch.encrypted_cookie_cipher || \"aes-256-gcm\"\n serializer = ActionDispatch::Cookies::JsonSerializer\n key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)\n key_len = ActiveSupport::MessageEncryptor.key_len(encrypted_cookie_cipher)\n secret = key_generator.generate_key(salt, key_len)\n encryptor = ActiveSupport::MessageEncryptor.new(secret, cipher: encrypted_cookie_cipher,\n serializer: serializer)\n session_key = config.session_options[:key].freeze\n encryptor.decrypt_and_verify(cookie, purpose: \"cookie.#{session_key}\")\n end",
"def [](name)\n name = name.to_s\n @cookies.each do |cookie|\n return cookie.value if cookie.name == name\n end\n nil\n end",
"def get_session_cookie(response)\n response.get_fields('set-cookie').each do |cookie|\n return cookie if cookie =~ /JSESSIONID/\n end\n end",
"def cookies\n WEBrick::Cookie.parse_set_cookies(@headers['set-cookie']) rescue []\n end",
"def parse_cookie(line)\n cookie = nil\n if line =~ /^Set-Cookie\\d?: .+=.+/\n cookie = {}\n line.chomp!\n cookie[:line] = line\n # Remove the Set-Cookie portion of the line\n setcookie, rest = line.split(' ', 2)\n # Then break off the name and value from the cookie attributes\n namevalue, rawattributes = rest.split('; ', 2)\n name, value = namevalue.split('=', 2)\n cookie[:name] = name\n cookie[:value] = value\n attributes = {}\n rawattributes.split('; ').each do |attribute|\n attrname, attrvalue = attribute.split('=', 2)\n # The Perl cookie jar uses a non-standard syntax, which seems to\n # include wrapping some fields (particularly path) in quotes. The\n # Perl nVentory library uses the Perl cookie jar code so we need to be\n # compatible with it.\n if attrvalue =~ /^\".*\"$/\n attrvalue.sub!(/^\"/, '')\n attrvalue.sub!(/\"$/, '')\n end\n # rfc2965, 3.2.2:\n # If an attribute appears more than once in a cookie, the client\n # SHALL use only the value associated with the first appearance of\n # the attribute; a client MUST ignore values after the first.\n if !attributes[attrname]\n attributes[attrname] = attrvalue\n end\n end\n cookie[:attributes] = attributes\n else\n # Invalid lines in the form of comments and blank lines are to be\n # expected when we're called by read_cookiefile, so don't treat this as\n # a big deal.\n puts \"parse_cookie passed invalid line: #{line}\" if (@debug)\n end\n cookie\n end",
"def cookies; @cookies ||= CookieJar.new; end",
"def cookie\n self[HttpClient::SET_COOKIE]\n end",
"def find_cookie_store(app)\n if app.is_a? ActionDispatch::Session::CookieStore\n app\n else\n find_cookie_store(app.instance_variable_get('@app'))\n end\n end",
"def parse_rack_env! env\n env['HTTP_COOKIE'].to_s =~ /fbs_#{app_id}=([^\\;]+)/\n self.data = parse_fbs!($1)\n end",
"def parse_rack_env! env\n env['HTTP_COOKIE'].to_s =~ /fbs_#{app_id}=([^\\;]+)/\n self.data = parse_fbs!($1)\n end",
"def cookie_value(symbol)\n cookies[symbol.to_s].value.first\n end",
"def get_auth_tkt_user_data\n cookie_decoded = Base64.decode64(cookies[:auth_tkt])\n return cookie_decoded.split('!')[2]\n end",
"def cookies\n WEBrick::Cookie.parse_set_cookies(headers['Set-Cookie']) rescue []\n end",
"def inspect\n \"#<CGI::Cookie: #{self.to_s.inspect}>\"\n end",
"def store_session(res)\n res.cookies << WEBrick::Cookie.new('_rails_lite_app', @hash.to_json)\n end",
"def login_from_cookie\n employee = cookies[:auth_token] && Employee.find_by_remember_token(cookies[:auth_token])\n if employee && employee.remember_token?\n cookies[:auth_token] = { :value => employee.remember_token, :expires => employee.remember_token_expires_at }\n self.current_employee = employee\n end\n end",
"def cookies\n @request.cookies\n end",
"def cookies\n call_once\n @cookies\n end",
"def cookies() @_cookies ||= ::Merb::Cookies.new(request.cookies, @_headers) end",
"def from_cookie(value)\n ticket = value && find_by_value(value)\n ticket\n end",
"def fgraph_session_cookies(app_id = fgraph_config['app_id'], \n app_secret = fgraph_config['app_secret'])\n\n return @fgraph_session_cookies if @fgraph_session_cookies\n return if @fgraph_session_cookies == false\n\n fbsr_cookie = request.cookies[\"fbsr_#{app_id}\"]\n if app_id.blank? or app_secret.blank? or fbsr_cookie.blank?\n return @fgraph_session_cookies = false\n end\n\n # Get authorization code and access token\n signed_request = fgraph_parse_signed_request(fbsr_cookie, app_secret)\n resp = FGraph.oauth_access_token(app_id, app_secret, :code => signed_request['code'])\n\n @fgraph_session_cookies = { \n 'access_token' => resp['access_token'] \n }\n end",
"def retrieve_cookie(response, cookie_name)\n value = response.headers['set-cookie'].scan(/#{cookie_name}=[a-zA-Z0-9]+/).first\n value = value[cookie_name.length+1..-1] if value\n end",
"def rails_5_1_verify_and_decrypt_session_cookie(cookie, secret_key_base)\n cookie = CGI.unescape(cookie)\n salt = \"encrypted cookie\"\n signed_salt = \"signed encrypted cookie\"\n key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)\n secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len]\n sign_secret = key_generator.generate_key(signed_salt)\n encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: JSON)\n\n encryptor.decrypt_and_verify(cookie)\nend",
"def get_cookies\n if cookies.signed[:name].present? && cookies.signed[:email].present?\n render json: { allow: true, name: cookies.signed[:name], email: cookies.signed[:email] }\n else\n render json: { allow: false }\n end\n end",
"def get_userid\n request.cookies['userid']\n end",
"def cookies # :doc:\n request.cookie_jar\n end",
"def cookies # :doc:\n request.cookie_jar\n end"
] | [
"0.73880845",
"0.7199041",
"0.693789",
"0.69199616",
"0.6871762",
"0.6716877",
"0.6615971",
"0.66148853",
"0.64481163",
"0.6434833",
"0.6415685",
"0.6415685",
"0.6410395",
"0.6297952",
"0.6282913",
"0.6208957",
"0.6205864",
"0.6199352",
"0.61971503",
"0.6185585",
"0.61666894",
"0.61605155",
"0.6121743",
"0.60963565",
"0.6092313",
"0.60547024",
"0.60453504",
"0.60385686",
"0.59781086",
"0.59757805",
"0.5963762",
"0.59503645",
"0.59421337",
"0.59415835",
"0.59274465",
"0.59183794",
"0.5907833",
"0.5901303",
"0.5894486",
"0.58907974",
"0.587114",
"0.58606803",
"0.58560824",
"0.5824052",
"0.5806049",
"0.5806038",
"0.57378644",
"0.5709849",
"0.56994885",
"0.5675208",
"0.56710565",
"0.56696856",
"0.5663118",
"0.563816",
"0.5622337",
"0.5610228",
"0.56062835",
"0.5598278",
"0.5596857",
"0.55811644",
"0.5569724",
"0.5568433",
"0.55659986",
"0.5561655",
"0.5557994",
"0.5529755",
"0.55253327",
"0.55205524",
"0.550631",
"0.54986066",
"0.54841715",
"0.5462425",
"0.5457225",
"0.5453762",
"0.54532653",
"0.54484814",
"0.5445383",
"0.5444871",
"0.5438677",
"0.5437915",
"0.5434657",
"0.54340297",
"0.5422765",
"0.5422765",
"0.5415396",
"0.5414958",
"0.5411973",
"0.5410776",
"0.5409847",
"0.53913236",
"0.538851",
"0.53846425",
"0.53741866",
"0.5372239",
"0.53588057",
"0.5354413",
"0.53527427",
"0.53377736",
"0.5332258",
"0.5329123",
"0.5310269"
] | 0.0 | -1 |
Creates a Video object set to work on the +file+ given. It will attempt to transcode the video into one defined by +target_geometry+ which is a "WxH"style string. +format+ should be specified. Video transcoding will raise no errors unless +whiny+ is true (which it is, by default. If +convert_options+ is set, the options will be appended to the convert command upon video transcoding. | def initialize file, options = {}, attachment = nil
@convert_options = {
:input => {},
:output => {}
}
unless options[:convert_options].nil? || options[:convert_options].class != Hash
unless options[:convert_options][:input].nil? || options[:convert_options][:input].class != Hash
@convert_options[:input].reverse_merge! options[:convert_options][:input]
end
unless options[:convert_options][:output].nil? || options[:convert_options][:output].class != Hash
@convert_options[:output].reverse_merge! options[:convert_options][:output]
end
end
@file = file
@whiny = options[:whiny].nil? ? true : options[:whiny]
@format = options[:format]
@time = options[:time].nil? ? 3 : options[:time]
@current_format = File.extname(@file.path)
@basename = File.basename(@file.path, @current_format)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize file, target_geometry, format = nil, convert_options = nil, whiny_thumbnails = true\n @file = file\n @crop = target_geometry[-1,1] == '#'\n @target_geometry = Geometry.parse target_geometry\n @current_geometry = Geometry.from_file file\n @convert_options = convert_options\n @whiny_thumbnails = whiny_thumbnails\n\n @current_format = File.extname(@file.path)\n @basename = File.basename(@file.path, @current_format)\n \n @format = format\n end",
"def make\n src = @file\n filename = [@basename, @format ? \".#{@format}\" : \"\"].join\n dst = TempfileFactory.new.generate(filename)\n\n begin\n parameters = []\n parameters << source_file_options\n parameters << \":source\"\n parameters << transformation_command\n parameters << convert_options\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n\n frame = animated? ? \"\" : \"[#{@frame_index}]\"\n convert(\n parameters,\n source: \"#{File.expand_path(src.path)}#{frame}\",\n dest: File.expand_path(dst.path)\n )\n rescue Terrapin::ExitStatusError => e\n if @whiny\n message = \"There was an error processing the thumbnail for #{@basename}:\\n\" + e.message\n raise Paperclip::Error, message\n end\n rescue Terrapin::CommandNotFoundError => e\n raise Paperclip::Errors::CommandNotFoundError.new(\"Could not run the `convert` command. Please install ImageMagick.\")\n end\n\n dst\n end",
"def video_convert_to_mov_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_mov ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mov'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_mov\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def initialize(file, options = {}, attachment = nil)\n super\n\n geometry = options[:geometry].to_s\n @crop = geometry[-1, 1] == \"#\"\n @target_geometry = options.fetch(:string_geometry_parser, Geometry).parse(geometry)\n @current_geometry = options.fetch(:file_geometry_parser, Geometry).from_file(@file)\n @source_file_options = options[:source_file_options]\n @convert_options = options[:convert_options]\n @whiny = options.fetch(:whiny, true)\n @format = options[:format]\n @animated = options.fetch(:animated, true)\n @auto_orient = options.fetch(:auto_orient, true)\n @current_geometry.auto_orient if @auto_orient && @current_geometry.respond_to?(:auto_orient)\n @source_file_options = @source_file_options.split(/\\s+/) if @source_file_options.respond_to?(:split)\n @convert_options = @convert_options.split(/\\s+/) if @convert_options.respond_to?(:split)\n\n @current_format = File.extname(@file.path)\n @basename = File.basename(@file.path, @current_format)\n @frame_index = multi_frame_format? ? options.fetch(:frame_index, 0) : 0\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n\n begin\n parameters = []\n parameters << source_file_options\n parameters << \":source\"\n parameters << transformation_command\n parameters << convert_options\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n\n success = Paperclip.run(\"convert\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Exception => e\n error_details = \"#{e.class}: #{e}\"\n error_details += \"\\n#{e.backtrace.join(\"\\n\")}\" if e.backtrace\n\n p \"ERROR: #{error_details}\"\n \n raise \"There was an error processing the thumbnail for #{@basename}\" if @whiny\n end\n\n dst\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, 'png'].compact.join(\".\"))\n dst.binmode\n \n\n parms = []\n parms << \"-size #{@target_geometry.width.to_i}x#{@target_geometry.height.to_i}\"\n parms << \"-quality 95\"\n parms << convert_options\n parms << \"#{File.expand_path(src.path)}[0]\"\n parms << File.expand_path(dst.path)\n \n parameters = parms.flatten.compact.join(\" \").strip.squeeze(\" \")\n \n \n# Rails.logger.info @file.path\n# Rails.logger.info '========== gm convert ' + parameters\n # success = Paperclip.run('gm convert', parameters)\n # success = Paperclip::CommandLine.new('gm convert', parameters, :expected_outcodes => [0, 1]).run\n\n output = `gm convert #{parameters}`\n if ! [0, 1].include?($?.exitstatus)\n raise PaperclipError, \"There was an error converting pdf to png: #{output} #{e}\" if @whiny\n end\n\n# success = Paperclip.run('gm convert', parameters)\n\n\n\n Rails.logger.info '========== tmpfile: ' + dst.path\n\n return dst\n# return ' s'\n end",
"def convert_video(params = {}, options = {}, converter = Conversion::VideoConverter)\n convert_file(params, converter, options)\n end",
"def video_convert_to_webm_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_webm ...'\n end\n # resource path\n local_var_path = '/video/convert/to/webm'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_webm\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n \n\n parameters = []\n \n # Add source\n parameters << @convert_options[:input].map { |k,v| \"-#{k.to_s} #{v} \"}\n parameters << \"-f --quiet :source\"\n parameters << @convert_options[:output].map { |k,v| \"-#{k.to_s} #{v} \"}\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n \n Paperclip.log(\"[lame] #{parameters}\")\n begin\n success = Paperclip.run(\"lame\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Cocaine::ExitStatusError => e\n raise PaperclipError, \"error while processing video for #{@basename}: #{e}\" if @whiny\n end\n\n dst\n end",
"def make\n return @file unless @streaming\n\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n\n parameters = []\n # Add source\n parameters << \":source\"\n # Add destination\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n\n Paperclip.log(\"[qtfaststart] #{parameters}\")\n begin\n success = Paperclip.run(\"qtfaststart\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Cocaine::ExitStatusError => e\n raise PaperclipError, \"error while processing video for #{@basename}: #{e}\" if @whiny\n end\n\n dst\n end",
"def video_convert_to_mp4_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_mp4 ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mp4'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_mp4\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def initialize file, options = {}, attachment = nil\n super\n\n geometry = options[:geometry]\n @file = file\n @target_geometry = Geometry.parse geometry\n @convert_options = options[:convert_options]\n @whiny = options[:whiny].nil? ? true : options[:whiny]\n\n @source_file_options = @source_file_options.split(/\\s+/) if @source_file_options.respond_to?(:split)\n @convert_options = @convert_options.split(/\\s+/) if @convert_options.respond_to?(:split)\n\n @current_format = File.extname(@file.path)\n @basename = File.basename(@file.path, @current_format)\n\n end",
"def convert(f, opts = {})\n opts = opts.dup\n f = f.to_s.downcase\n allowed = cwv_config.allowed_formats\n raise ArgumentError, \"Format must be one of: #{allowed.join(',')}\" unless allowed.include?(f)\n self.format_override = f == 'jpeg' ? 'jpg' : f\n opts[:Q] = opts.delete(:quality) if opts.has_key?(:quality)\n write_opts.merge!(opts)\n get_image\n end",
"def video_format=(video_format)\n if !video_format.nil? && video_format.to_s.length > 5\n fail ArgumentError, 'invalid value for \"video_format\", the character length must be smaller than or equal to 5.'\n end\n\n @video_format = video_format\n end",
"def make\n source = @file\n destination = Tempfile.new(@basename)\n\n Paperclip.run(\"convert\",\n \":source \" \\\n \"-quality 100 \" \\\n \"-bordercolor \\\"#000000\\\" \" \\\n \"-border 1x1 \" \\\n \"-fuzz 10% \" \\\n \"-trim +repage \" \\\n \":dest\",\n :source => File.expand_path(source.path),\n :dest => File.expand_path(destination.path)\n )\n\n destination\n end",
"def create_from_file\n\n\t\t@user = current_user\n\n\t\tif current_user.is_bot?\n\t\t\tcurrent_user = User.bots.sample\n\t\telse\n\t\t\t# idk why this is necessary but without it current_user becomes nil\n\t\t\tcurrent_user = @user\n\t\tend\n\n\t\t@video = Video.new\n\t\t@video.creator = current_user\n\t\t@video.component = Component.find_by_id(params[:component_id])\n\t\t@video.s3_key = params[:s3_key]\n\t\t@video.hosted = true\n\t\t@video.source = \"vimeo\"\n\t\t@video.save\n\t\t@video.upload # starts the bg task (uploads to vimeo)\n\n\t\tflash[:blue] = \"Your video has been uploaded! Please allow some time for processing.\"\n\n\t\trender :type => \"text/javascript\", :text => \"#{@video.id}\"\n\t\t\n end",
"def storeFormatOnAmazonS3(videomp4, videoconverted, format)\n Formatvideo.create({\n :video_clip_id => videomp4.id,\n :format => File.open(videoconverted),\n :type => format\n })\n end",
"def set_formatvideo\n @formatvideo = Formatvideo.find(params[:id])\n end",
"def mux(options={})\n if File.file?(options[:output])\n File.delete(options[:output])\n end\n\n create do |mp4creator|\n mp4creator.create = options[:audio]\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.create = options[:video]\n mp4creator.rate = options[:frame_rate].to_f\n mp4creator.file = options[:output]\n end\n\n if options[:hint]\n create do |mp4creator|\n mp4creator.hint = 1\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.hint = 2\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.optimize = true\n mp4creator.file = options[:output]\n end\n end\n end",
"def convert(file_info)\n input_name = Shellwords.escape(file_info[:filename])\n input_suffix = File.extname input_name\n output_name = File.basename input_name, input_suffix\n output_suffix = \"mp4\"\n command = [ \"ffmpeg\", \"-y\", \"-i #{input_name}\", \"-max_muxing_queue_size 9999\", \"-map_chapters -1\" ]\n\n if (file_info[:video].empty? && !file_info[:audio].empty?) || input_suffix == '.flac' || input_suffix == '.mp3' || input_suffix == '.aiff'\n #\n # Audio-only files are converted to either ALAC if the source was FLAC, or\n # AAC for all other formats.\n #\n stream = file_info[:audio][0]\n case stream[:codec]\n when \"alac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a copy\"\n when \"flac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n when \"mp3\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n else\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a aac\" << \"-ar:a:0 48k\" << \"-ab:a 256k\"\n end\n output_suffix = \"m4a\"\n elsif !file_info[:video].empty? && !file_info[:audio].empty?\n # Removes all of the default metadata that junks up the final file.\n command << \"-map_metadata -1\"\n \n # Maps the video track\n command << \"-map 0:v:0\" << \"-metadata:s:v:0 language=und\" << \"-metadata:s:v:0 title='Video Track'\"\n\n #\n # The video track is copied if the codec is h265 (hevc) and a video tag\n # is added so that Apple products understand the format. Otherwise, the\n # video track is copied if it's in h264 format and the frame size is\n # to remain the same, or it's converted to h264 using high-quality\n # settings.\n #\n if \"hevc\" == file_info[:video][:codec]\n command << \"-codec:v copy -vtag hvc1\"\n elsif \"h264\" == file_info[:video][:codec] && !Options.options[:P480] && !Options.options[:P720]\n command << \"-codec:v copy\"\n else\n # This converts the video using settings that provide nearly visual\n # lossless results.\n output_suffix = \"mp4\"\n command << \"-codec:v libx265\" << \"-vtag hvc1\" << \"-preset:v slow\" << \"-profile:v main\" << \"-crf:v 18\" << \"-threads:v 0\"\n\n # Converts HD video to wide-screen 720P if necessary.\n command << \"-vf:v scale=1280:-1\" if Options.options[:P720]\n\n # Converts HD video to wide-screen 480P if necessary.\n command << \"-vf:v scale=854:-1\" if Options.options[:P480]\n end\n\n # Convert all of the audio tracks to AAC (stereo) and AC3 (multi-channel)\n index = 0\n file_info[:audio].each do |stream|\n index, c = convert_audio(stream, index)\n command << c\n end\n\n if file_info.key?(:subtitle) && !file_info[:subtitle].nil? && !file_info[:subtitle].empty?\n command << \"-map 0:s:#{file_info[:subtitle][:index]}\" << \"-metadata:s:s:0 language=eng\" << \"-metadata:s:s:0 title='Subtitle Track'\"\n command << ('dvd_subtitle' == file_info[:subtitle][:codec] ? \"-codec:s:0 copy\" : \"-codec:s:0 mov_text\")\n end\n\n end\n\n command << \"#{output_name}.#{output_suffix}\"\n\n if Options.options[:dump]\n puts command.join(' ')\n exit\n end\n\n #\n # Starts the transcoding process.\n #\n puts file_info[:filename]\n progress = ProgressBar.create(:format => \"%t |%B| %e\",\n :total => file_info[:duration] + 1,\n :title => \"Encoding Progress\")\n execute(command, true) do |line|\n begin\n line.match /time=(\\d\\d):(\\d\\d):(\\d\\d)/ do |match|\n if match.length == 4\n time = match[1].to_i * 3600 + match[2].to_i * 60 + match[3].to_i\n progress.progress = time\n end\n end\n rescue\n # Some UTF-8 characters can cause match to throw, but these characters are not used by this script.\n end\n end\n progress.finish\nend",
"def create\n @movie_format = MovieFormat.new(params[:movie_format])\n\n respond_to do |format|\n if @movie_format.save\n format.html { redirect_to @movie_format, notice: 'Movie format was successfully created.' }\n format.json { render json: @movie_format, status: :created, location: @movie_format }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie_format.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Rails.logger.info \"params\"\n Rails.logger.info params\n Rails.logger.info params[:file]\n @help_video = HelpVideo.new\n Rails.logger.info @help_video\n if @help_video.help_video=params[:file]\n respond_to do |format|\n if @help_video.save!\n format.html { redirect_to @help_video, notice: 'Help video was successfully created.' }\n format.json { render action: 'show', status: :created, location: @help_video }\n else\n format.html { render action: 'new' }\n format.json { render json: @help_video.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def run\n\n @options = @video.convert_options\n @output_file = \"#{generate_path @video.name}/#{@video.name}#{@options[:postfix]}.#{@options[:extension]}\"\n\n command = \"#{CONFIG[:ffmpeg_binary]} -y -i '#{@video.path}' #{@options} '#{@output_file}'\"\n output = \"\"\n convert_error = true\n\n # before convert callbacks\n Hook.exec :before_convert, @video, command\n\n # process video\n Open3.popen3(command) do |stdin, stdout, stderr|\n stderr.each \"r\" do |line|\n VTools.fix_encoding line\n output << line\n\n # we know, that all is not so bad, if \"time=\" at least once met\n if line.include? \"time=\"\n\n convert_error = false # that is why, we say \"generally it's OK\"\n\n if line =~ /time=(\\d+):(\\d+):(\\d+.\\d+)/ # ffmpeg 0.8 and above style\n time = ($1.to_i * 3600) + ($2.to_i * 60) + $3.to_f\n elsif line =~ /time=(\\d+.\\d+)/ # ffmpeg 0.7 and below style\n time = $1.to_f\n else # in case of unexpected output\n time = 0.0\n end\n progress = time / @video.duration\n Hook.exec :in_convert, @video, progress # callbacks\n end\n end\n end\n\n raise ProcessError, output.split(\"\\n\").last if convert_error # exit on error\n\n # callbacks\n unless error = encoding_invalid?\n Hook.exec :convert_success, @video, @output_file\n else\n Hook.exec :convert_error, @video, error, output\n raise ProcessError, error # raise exception in error\n end\n\n encoded\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, @format].compact.join(\".\"))\n dst.binmode\n\n command = <<-end_command\n #{ Paperclip.path_for_command('convert') }\n \"#{ File.expand_path(src.path) }\"\n #{ transformation_command }\n \"#{ File.expand_path(dst.path) }\"\n end_command\n success = system(command.gsub(/\\s+/, \" \"))\n\n if success && $?.exitstatus != 0 && @whiny_thumbnails\n raise PaperclipError, \"There was an error processing this thumbnail\"\n end\n\n dst\n end",
"def convert\n\t\tif self.video.file?\n\t\t\tself.convert!\n\n\t\t\tsuccess = system(convert_command)\n\t\t\tif success && $?.exitstatus == 0\n\t\t\t\tself.converted!\n\t\t\telse\n\t\t\t\tself.failed!\n\t\t\tend\n\t\tend\n\tend",
"def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end",
"def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end",
"def generate_previews(filename, options = {})\n\tframegrab_grid = options['framegrab_grid'] || Config['PreviewSettings']['default_grid']\n\tframegrab_interval = options['framegrab_interval'] || Config['PreviewSettings']['default_interval']\n\tframegrab_height = options['framegrab_height'] || Config['PreviewSettings']['default_height']\n\n\tbase_filename = File.basename(filename)\n\tfilesize = File.size(filename)\n\tfile_info = Mediainfo.new filename\n\n\tif framegrab_interval.to_i == 0\n\t\ttotal_images = 1\n\t\tframegrab_grid.split('x').each do |x|\n\t\t\ttotal_images *= x.to_i\n\t\tend\n\t\tframegrab_interval = file_info.duration / total_images\n\tend\n\n\tcount = 0\n\tunits = ['bytes', 'KB', 'MB', 'GB', 'TB']\n\tloop do\n\t\tbreak if filesize < 1024.0\n\t\tcount += 1\n\t\tfilesize /= 1024.0\n\tend\n\n\tpretty_filesize = filesize.round(2).to_s + ' ' + units[count]\n\n\tduration = file_info.duration\n\tremainder = 0\n\tcount = 0\n\tunits = ['sec','min','h']\n\tloop do\n\t\tbreak if duration < 60\n\t\tcount += 1\n\t\tremainder = duration % 60\n\t\tduration /= 60\n\tend\n\n\tpretty_duration = duration.round(0).to_s + ' ' + units[count]\n\n\tif remainder > 0\n\t\tpretty_duration += ' ' + remainder.round(0).to_s + ' ' + units[count-1]\n\tend\n\n\tcommand = \"ffmpeg -loglevel panic -y -i \\\"#{filename}\\\" -frames 1 -q:v 1 -vf \\\"select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,\" + framegrab_interval.to_s + \")',scale=-1:\" + framegrab_height.to_s + \",tile=\" + framegrab_grid + \"\\\" '/tmp/video_preview.jpg'\"\n\t# puts command\n\tif system(command)\n\t# \t# Now that the preview is generated, post it to Mattermost\n\t\tif !(uploaded_file_url = upload_file('/tmp/video_preview.jpg', base_filename))\n\t\t\tcall_mattermost({:text => \"We ran into a problem uploading the file. Have someone look at this!\"})\n\t\telse\n\t\t\tmessage = \"\\n\\n\"\n\t\t\tmessage+= \"|#{base_filename}|[(preview)](#{uploaded_file_url})|\\n\"\n\t\t\tmessage+= \"|-|-:|\\n\"\n\t\t\tmessage+= \"|File Size| **#{pretty_filesize}**|\\n\"\n\t\t\tmessage+= \"|Duration| **#{pretty_duration}**|\\n\"\n\t\t\tmessage+= \"|Format| **#{file_info.format}**|\"\n\n\t\t\tactions = Config['FileOperations']\n\t\t\tattachments_actions = []\n\t\t\tactions.keys.each do |key|\n\t\t\t\taction_hash = {\n\t\t\t\t\t'name': key,\n\t\t\t\t\t'integration': {\n\t\t\t\t\t\t'url': [Config['Webhook']['url'], 'run-command'].join('/'),\n\t\t\t\t\t\t'context': {\n\t\t\t\t\t\t\t'command': key,\n\t\t\t\t\t\t\t'filename': File.realpath(filename)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tattachments_actions.push(action_hash)\n\t\t\tend\n\n\n\t\t\tattachments = [\n \t\t{\n \t\t\t\"text\": message,\n \t\t\t\"actions\": attachments_actions\n\t\t }]\n\n\t\t\tpayload = {:attachments => attachments}\n\n\t\t\tcall_mattermost(payload)\n\t\tend\n\telse\n\t\tLog.error \"There was an error running the command: #{command}\"\n\t\tcall_mattermost({:text => \"### DANGER WILL ROBINSON\\nERROR\"})\n\tend\n\nend",
"def create_clean_file(file)\n name = clean_file_name(file)\n system(\"ffmpeg -i '#{file}' -map_metadata -1 -c:v copy -c:a copy #{@destination}/'#{name}'\")\n end",
"def build(filename, frames)\n frames = normalize_depth frames, to: 3 # frames are rows of pixels\n pixel_args = frames.flat_map.with_index do |rows, z|\n width, height = frames.first.first.length, frames.first.length\n [ '(',\n '-size', \"#{width}x#{height}\", 'xc:none',\n '-frame', z.to_s,\n *rows.flat_map.with_index { |pixels, y|\n pixels.flat_map.with_index do |pixel, x|\n color = if pixel[:transparent]\n ['-alpha', 'Transparent']\n else\n [\"-fill\", \"RGB(#{pixel.fetch :red},#{pixel.fetch :green},#{pixel.fetch :blue})\",\n \"-draw\", \"point #{x},#{y}\"\n ]\n end\n end\n },\n ')',\n ]\n end\n\n if File.exist? filename\n puts \"skipping #{filename}\"\n else\n program = 'convert', '-coalesce', *pixel_args, filename\n puts program.join ' '\n system *program\n end\nend",
"def create(projectid, file, filename, target_langs, options = {})\n payload = File.open(file, 'r')\n encoding = payload.external_encoding.to_s\n\n options[:targetLangs] = target_langs\n\n headers = {\n memsource: options.to_json,\n content_type: 'application/octet-stream',\n content_disposition: \"filename\\*=#{encoding}''#{filename}\"\n }\n\n path = \"#{Project::PATH}/#{projectid}/#{PATH}\"\n\n post(path, payload, headers: headers)\n end",
"def convert(from_file, to_file = {})\n @from_file = from_file\n FFMpegCommand << \"-i #{from_file}\"\n begin\n yield if block_given?\n rescue Exception => exception\n disable_method_checking!\n raise exception\n end\n \n build_output_file_name(from_file, to_file[:to]) do |file_name|\n FFMpegCommand << file_name\n end\n end",
"def create\n @videofile = Videofile.new(params[:videofile])\n \n respond_to do |format|\n if @videofile.save\n format.html { redirect_to(@videofile, :notice => 'Videofile was successfully created.') }\n format.xml { render :xml => @videofile, :status => :created, :location => @videofile }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @videofile.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def build_movie(movie_file)\n extension = File.extname(movie_file)\n \n if(extension == \".xml\")\n return build_from_xml(movie_file)\n elsif(extension == \".json\")\n update_all(\"MovieBuilder\", \"Creating movie from JSON\")\n json_builder = JSONBuilder.new\n return json_builder.build_movie(movie_file)\n else\n update_all(\"MovieBuilder\", \"Unknown extension. See documentation for supported formats and markups\")\n end\n return nil\n end",
"def convert(f, opts = {})\n f = f.to_s.downcase\n allowed = %w(jpeg png)\n raise ArgumentError, \"Format must be one of: #{allowed.join(',')}\" unless allowed.include?(f)\n @_format = f\n @_format_opts = opts\n end",
"def convert(from_file, to_file = {})\n FFMpegCommand.clear\n FFMpegCommand << \"-i #{from_file}\"\n yield if block_given?\n \n build_output_file_name(from_file, to_file[:to]) do |file_name|\n FFMpegCommand << file_name\n end\n end",
"def convert_to(format)\n prepare_for_conversion unless @prepare_for_conversion\n output_path = output_path(format)\n\n log_folder = create_log_folder\n stdout_log, stderr_log = stdout_log(format), stderr_log(format)\n\n Cmd::Conversion.new(temp_path, output_path, format).run! %W(#{stdout_log} a), %W(#{stderr_log} a)\n rescue StandardError => e\n FileUtils.rm_rf output_folder\n raise e\n end",
"def build_convert_command(input_file, output_file)\n builder = CommandBuilder.new([Sox::File.new(input_file)], Sox::File.new(output_file))\n builder.effects = {:channels => @options[:channels], :rate => @options[:rate]}\n builder.build\n end",
"def run\n begin\n prepare_for_conversion\n\n Queue.run *FORMATS.map{ |format| proc{ convert_to(format) } }, close_connection_before_execution: true\n \n mp4_file_info = Info.new output_path(:mp4)\n webm_file_info = Info.new output_path(:webm)\n \n unless similar_durations?(mp4_file_info.duration, webm_file_info.duration) \n raise Error.new( 'output videos have different duration', \n model_id: model_id, mp4_duration: mp4_file_info.duration, webm_duration: webm_file_info.duration )\n end\n \n cover_path = File.join output_folder, COVER_FORMAT % output_filename_without_extension\n extract_cover output_path(:mp4), cover_path, mp4_file_info.duration\n \n thumb_path = File.join output_folder, THUMB_FORMAT % output_filename_without_extension\n extract_thumb cover_path, thumb_path, *THUMB_SIZES\n \n rescue StandardError => e\n FileUtils.rm_rf output_folder\n \n input_path = \n if File.exists? temp_path\n temp_path\n elsif File.exists? uploaded_path\n uploaded_path\n end\n FileUtils.cp input_path, create_log_folder if input_path\n\n if model.present? and model.user_id.present?\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.failed.title'),\n I18n.t('notifications.video.upload.failed.message', :item => model.title),\n ''\n )\n model.destroyable_even_if_not_converted = true\n model.destroy\n end\n\n raise e\n end\n \n model.converted = true\n model.rename_media = true\n model.mp4_duration = mp4_file_info.duration\n model.webm_duration = webm_file_info.duration\n model.media = output_filename_without_extension\n model[:media] = output_filename_without_extension\n model.save!\n\n #FileUtils.rm temp_path\n FileUtils.rm_r temp_folder\n\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.ok.title'),\n I18n.t('notifications.video.upload.ok.message', :item => model.title),\n ''\n )\n end",
"def make\n\n src = @file\n dst = Tempfile.new([@basename, @output_ext].compact.join(\".\"))\n\n # build gpsbabel option string\n opt = %{ -i #{@input_format} }\n opt << %{ -f \"#{ File.expand_path(src.path) }\" }\n opt << @filters\n opt << %{ -o #{@gpsbabel_format} -F \"#{ File.expand_path(dst.path) }\" }\n \n begin\n success = Paperclip.run(\"gpsbabel\", opt.gsub(/\\s+/, \" \"))\n rescue PaperclipCommandLineError\n raise PaperclipError, \"There was an error processing the GPS file #{@basename}\" if @whiny\n end\n\n dst\n end",
"def convert_command\n\t\t\tflv = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.flv\")\n\t\t\tmpeg4 = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.mp4\")\n\t\t\tFile.open(flv, 'w')\n\t\t\tFile.open(mpeg4, 'w')\n\t\t\t#command = \"cd log/ && ffmpeg -i #{ self.video.path } -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y #{ flv }; ffmpeg -i #{ self.video.path } -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 1024k -bt 1024k -threads 0 -y #{ mpeg4 }\"\n\t\t\tcommand = \"cd log/ && ffmpeg -i '#{ self.video.path }' -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y '#{ flv }'; ffmpeg -threads 4 -i '#{ self.video.path }' -r 29.97 -vcodec libx264 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 0 -subq 5 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -sc_threshold 40 -i_qfactor 0.71 -acodec libfaac -ab 128k -ar 48000 -ac 2 '#{ mpeg4 }'\"\n\n\t\t\tcommand.gsub!(/\\s+/, \" \")\n\t\t\tlogger.debug command\n\t\tend",
"def convertSlidesToVideo(presentationSlidesStart)\n presentationSlidesStart.each do |item|\n # Path to original svg\n originalLocation = File.join(item[\"filepath\"], item[\"filename\"])\n # Save conversion with similar path in tmp\n dirname = File.join(TMP_PATH, item[\"presentationName\"], \"svgs\")\n finalLocation = File.join(dirname, changeFileExtensionTo(item[\"filename\"], \"mp4\"))\n\n if (!File.exists?(finalLocation))\n # Create path to save conversion to\n unless File.directory?(dirname)\n FileUtils.mkdir_p(dirname)\n end\n\n # Convert to png\n image = MiniMagick::Image.open(originalLocation)\n image.format 'png'\n pathToImage = File.join(dirname, changeFileExtensionTo(item[\"filename\"], \"png\"))\n image.write pathToImage\n\n # Convert to video\n # Scales the output to be divisible by 2\n system \"ffmpeg -loglevel quiet -nostdin -nostats -y -r 30 -i #{pathToImage} -vf crop='trunc(iw/2)*2:trunc(ih/2)*2' #{finalLocation}\"\n end\n\n item[\"filepath\"] = dirname\n item[\"filename\"] = finalLocation.split('/').last\n end\n\n return presentationSlidesStart\nend",
"def generate_video_thumbnail file\n FileUtils.rm(\"tmp/thumb.jpg\") if File.exists?(\"tmp/thumb.jpg\")\n begin\n `ffmpegthumbnailer -i #{file} -o tmp/thumb.jpg /dev/null 2>&1`\n File.new(\"tmp/thumb.jpg\").size > 0 ? true : false\n rescue => e\n logger.info e.inspect\n return false\n end\n end",
"def video_convert_to_gif_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_gif ...'\n end\n # resource path\n local_var_path = '/video/convert/to/gif'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'startTime'] = opts[:'start_time'] if !opts[:'start_time'].nil?\n header_params[:'timeSpan'] = opts[:'time_span'] if !opts[:'time_span'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_gif\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def convert\n success = system(convert_command + \" > conversion.log\")\n if success && $?.exitstatus == 0\n local_path_util = LocalMediaPathUtil.new \n file_dir = local_path_util.local_media_complete_dir(id)\n t_local_path = file_dir + \"/\" + filename + \".flv\"\n update_attribute(:converted_media_local_path,t_local_path)\n end\n end",
"def initialize( conf, video_format, file_in, file_out='' )\n @conf = conf\n @video_format = video_format\n @file_in = file_in\n @file_out = file_out\n @frame_size = ''\n @orig_frame_size = ''\n @ffmpeg_ver = 0\n @os = ''\n\n exe(\"#{@conf.ffmpeg} -version\").each do |r|\n if r =~ /libavfilter/\n @ffmpeg_ver = 1\n break\n end\n end\n \n @os = exe(\"uname\")[0].strip.downcase\n\n # puts \"VERSION: #{@ffmpeg_ver}\"\n # puts \"OS: #{@os}\"\n end",
"def create_black_video(movie, visual)\n #Render an image and create a video file from it\n @generated_videos += 1\n filename = movie.project.trimmed + \"/generated-#{@generated_videos}.avi\"\n cmd = @settings['still_video'].dup\n length = visual.end_point - visual.start_point\n cmd.sub!('<frames>', length.to_frames(25).to_s)\n cmd.sub!('<source>', VREConfig.instance.vre_root + \"resources/black_box.png\")\n cmd.sub!('<resolution>', movie.resolution)\n cmd.sub!('<target>', filename)\n system(cmd)\n visual.file = filename\n visual.type = \"video\"\n visual.mute = true\n filename\n end",
"def create_frame_and_thumbnail\n if (File.extname(self.image_sequence) == \".mha\")\n file_path = Rails.root.join(dir_path, self.image_sequence)\n result = system(Rails.root.join('scripts','mha_to_png','bin',\"MhaToPng #{file_path} 1\").to_s)\n base_name = File.basename(file_path, \".mha\")\n image = MiniMagick::Image.open(\"#{dir_path}/#{base_name}_frame.png\")\n image.resize \"200x200\"\n image.format \"png\"\n image.write \"#{dir_path}/#{base_name}_thumbnail.png\"\n File.chmod(0644, \"#{dir_path}/#{base_name}_thumbnail.png\")\n self.thumbnail = \"#{base_name}_thumbnail.png\"\n self.frame = \"#{base_name}_frame.png\"\n end\n end",
"def create\n @raw_video = RawVideo.new(params[:raw_video])\n\n respond_to do |format|\n if @raw_video.save\n format.html { redirect_to(@raw_video, :notice => 'Raw video was successfully created.') }\n format.xml { render :xml => @raw_video, :status => :created, :location => @raw_video }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @raw_video.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n #動画基本情報\n @video = Video.new(video_params)\n @video.user_id = get_user_id\n\n upload_file = params[:file]\n\n # ファイル必須\n if upload_file.nil?\n @video.errors.add(:file, \"は最低1つアップしてください。\")\n end\n\n respond_to do |format|\n if !upload_file.nil? && @video.save\n UpfileManageService.save(upload_file, @video)\n format.html { redirect_to videos_url, notice: '動画情報を登録しました。' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def output(format = :pls)\n format = format.to_sym\n raise ArgumentError.new(\"Format must be one of #{FORMATS.join(', ')}\") unless FORMATS.include? format\n\n case format\n when :text\n create_text\n when :m3u\n create_m3u\n else\n create_pls\n end\n end",
"def path_to_video(source, options = T.unsafe(nil)); end",
"def create\r\n flash[:notice] = ''\r\n\r\n if params.has_key?(:file)\r\n register_device params[:device_id]\r\n\r\n @video = Video.new(:video => params[:file],\r\n :upload_password => params[:upload_password],\r\n :device_id => params[:device_id],\r\n :timestamp => params[:timestamp],\r\n :annotation => params[:annotation]\r\n )\r\n else\r\n @video = Video.new(params[:upload])\r\n @video.timestamp = DateTime.now.to_i\r\n end\r\n\r\n respond_to do |format|\r\n if @video.save\r\n format.html { redirect_to :action => 'index' }\r\n format.xml { render :xml => @video, :status => :created, :location => @video }\r\n else\r\n format.html do\r\n flash[:notice] = 'Upload Error.'\r\n redirect_to :action => \"index\"\r\n end\r\n format.xml { render :xml => @video.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create!(path, args)\n return usage if /\\?/ =~ path || /--help/ =~ path\n main_file = File.basename(path, '.rb') # allow uneeded extension input\n # Check to make sure that the main file doesn't exist already\n already_exist(path)\n @name = StringExtra.new(main_file).camelize\n writer = SketchWriter.new(main_file)\n @title = StringExtra.new(main_file).titleize\n @width, @height = args[0], args[1]\n @mode = args[2].upcase unless args[2].nil?\n template = @mode.nil? ? class_template : class_template_mode\n writer.save(template)\n end",
"def ffmpeg\n @log.info \"Running ffmpeg to convert to MP4\"\n ffmpegOutOptions = \"-strict experimental -vcodec copy -acodec aac\"\n if @remux\n ffmpegOutOptions = \"-vcodec copy -acodec copy\"\n end \n ffmpeg_command =\"ffmpeg -y -i \\\"#{@out_file}.flv\\\" #{ffmpegOutOptions} \\\"#{@out_file}.mp4\\\"\"\n success = system(ffmpeg_command)\n\n if not success\n raise \"Something went wrong running ffmpeg :(. Your file may not have converted properly.\"\n end\n\n @log.info \"File converted\"\n end",
"def create_locally\n write_file(@video_file, @video_name)\n write_file(@poster_file, @poster_name)\n end",
"def video_convert_to_mov(opts = {})\n data, _status_code, _headers = video_convert_to_mov_with_http_info(opts)\n data\n end",
"def video_convert_to_still_frames_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_still_frames ...'\n end\n # resource path\n local_var_path = '/video/convert/to/still-frames'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'framesPerSecond'] = opts[:'frames_per_second'] if !opts[:'frames_per_second'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'StillFramesResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_still_frames\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def av_convert(options)\n if @external_url\n return 'av_convert does not support external URLs. Please upload file first.'\n end\n @transform_tasks.push(\n add_transform_task('video_convert', options)\n )\n response = UploadUtils.make_call(url, 'post')\n if response.code == 200\n return AV.new(url, apikey: @apikey, security: @security)\n end\n JSON.parse(response.body)\n end",
"def convert(output_file, *opt)\n options = {}\n options.merge!(opt.pop) if !opt.empty? && opt.last.is_a?(Hash)\n\n converted = CaptionFile.open(output_file, options.merge(mode: 'w'))\n\n converted.print_header\n each_frame{|frame| converted.print_frame(frame)}\n converted.print_footer\n\n converted.close\n end",
"def set_file_format\n @file_format = FileFormat.find(params[:id])\n end",
"def convert_command\n @original_video_filename = compute_original_local_filename\n @flv_filename = \"#{@original_video_filename}.flv\"\n @flv_url = \"#{public_filename}.flv\"\n \n if is_mov?\n command = \"/opt/ffmpeg/ffmpeg -y -i #{@original_video_filename} -target ntsc-dvd #{@flv_filename}\" \n else\n command = \"/opt/ffmpeg/ffmpeg -y -i #{@original_video_filename} #{@flv_filename}\"\n end\n command.gsub!(/\\s+/, \" \")\n end",
"def new_video_track(width, height)\n track = new_track(width, height)\n track.new_video_media\n track\n end",
"def new_video_track(width, height)\n track = new_track(width, height)\n track.new_video_media\n track\n end",
"def create\n params[:visualization][:user_id] = current_user.id\n\n # Remove any piggybacking updates\n if params[:visualization].try(:[], :tn_file_key)\n params[:visualization].delete :tn_file_key\n end\n if params[:visualization].try(:[], :tn_src)\n params[:visualization].delete :tn_src\n end\n\n # Try to make a thumbnail\n mo = nil\n\n if params[:visualization].try(:[], :svg)\n begin\n mo = MediaObject.new\n mo.media_type = 'image'\n mo.name = 'image.png'\n mo.file = 'image.png'\n mo.user_id = current_user.id\n mo.check_store!\n\n image = MiniMagick::Image.read(params[:visualization][:svg], '.svg')\n image.format 'png'\n image.resize '512x512'\n\n File.open(mo.file_name, 'wb') do |ff|\n ff.write(image.to_blob)\n end\n\n mo.add_tn\n rescue MiniMagick::Invalid => err\n mo = nil\n logger.info \"Failed to create thumbnail (#{err}).\"\n end\n\n params[:visualization].delete :svg\n end\n\n @visualization = Visualization.new(visualization_params)\n\n respond_to do |format|\n if @visualization.save\n unless mo.nil?\n mo.visualization_id = @visualization.id\n mo.save!\n @visualization.thumb_id = mo.id\n @visualization.save!\n end\n\n flash[:notice] = 'Visualization was successfully created.'\n format.html { redirect_to @visualization }\n format.json { render json: @visualization.to_hash(false), status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @visualization.errors, status: :unprocessable_entity }\n end\n end\n end",
"def url_to_video(source, options = T.unsafe(nil)); end",
"def create\n @video = Video.new(video_params)\n @video.board_id = @board.id\n\n urlVideo = VideoInfo.new(@video.source)\n\n\n @video.iFrame_Source = urlVideo.embed_code\n @video.title = urlVideo.title\n @video.date = urlVideo.date\n @video.provider = urlVideo.provider\n @video.description = urlVideo.description\n @video.smaller_thumbnail = urlVideo.thumbnail_small\n @video.larger_thumbnail = urlVideo.thumbnail_large\n\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to board_video_path(@board, @video), notice: 'Video was successfully created.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def format=(format)\n validator = EnumAttributeValidator.new('String', [\"mp4\", \"gif\", \"mp3\", \"jpg\", \"png\", \"bmp\"])\n unless validator.valid?(format)\n fail ArgumentError, \"invalid value for \\\"format\\\", must be one of #{validator.allowable_values}.\"\n end\n @format = format\n end",
"def to_m4a(options={})\n options[:quality] ||= 320\n options[:output] ||= self.basename_with_path + '.m4a'\n cmd = \"afconvert -v \\\"#{self.path}\\\" -o \\\"#{options[:output]}\\\" -f m4af -d aac -b #{options[:quality]}000 -s 0\"\n system(cmd)\n end",
"def convert_mkv_to_mp4(mkv_file)\n mp4_name = clean_mp4_name(mkv_file)\n system(\"ffmpeg -i '#{mkv_file}' -vcodec copy -acodec copy '#{mp4_name}'\")\n end",
"def set_scene\n if params[:id].include? '.vtt'\n params[:id].slice! '_thumbs.vtt'\n params[:format] = :vtt\n end\n if params[:id].include? '.jpg'\n params[:id].slice! '_sprite.jpg'\n params[:format] = :jpg\n end\n\n if Scene.find_by(checksum: params[:id])\n @scene = Scene.find_by(checksum: params[:id])\n else\n @scene = Scene.find(params[:id])\n end\n end",
"def set_scene\n if params[:id].include? '.vtt'\n params[:id].slice! '_thumbs.vtt'\n params[:format] = :vtt\n end\n if params[:id].include? '.jpg'\n params[:id].slice! '_sprite.jpg'\n params[:format] = :jpg\n end\n\n if Scene.find_by(checksum: params[:id])\n @scene = Scene.find_by(checksum: params[:id])\n else\n @scene = Scene.find(params[:id])\n end\n end",
"def video_gen(slide)\n term = slide['term']\n kind = slide['kind']\n index = slide['index']\n audio = slide['audio']\n image = slide['image']\n raise \"audio is required fof #{term}\" unless audio\n raise \"image is required fof #{term}\" unless image\n file_name = file_name_gen(slide, \".mpg\")\n audio = command_arg(slide['audio'])\n image = command_arg(slide['image'])\n video = command_arg(file_name)\n `ffmpeg -loop 1 -y -i #{image} -i #{audio} -acodec libmp3lame -vcodec mpeg4 -shortest -qscale:v 1 #{video}`\n slide['video'] = file_name\nend",
"def encode(file=\"output.avi\")\n puts \"encoding video #{file}\"\n MEncoder.encode do |mencoder|\n mencoder.input = \"mf://#{@frames_dir.file_list(@date, @hour, @length, @frame_type).join(',')}\"\n mencoder.mf.fps = 2\n mencoder.mf.type = \"jpg\"\n mencoder.output_video_codec = :lavc\n mencoder.lavc.vcodec = \"mpeg4\"\n mencoder.lavc.mbd = 2\n mencoder.lavc.trell = true\n mencoder.output_audio_codec = 'copy'\n mencoder.output = file\n end\n end",
"def transform(file, format:); end",
"def create_image output_file, format, opts\n width = opts.fetch(:width, opts[:height]*1.5)\n\n if (opts[:crop])\n img_derivative = Vips::Image.thumbnail_buffer(source_file.content,\n 1000000, height: opts[:height], auto_rotate: true)\n # Centre is used for smartcrop due to an issue with JPEGs that will\n # otherwise break the process with an Out of Tile error\n if (width < img_derivative.width)\n img_derivative = img_derivative.smartcrop(width, opts[:height],\n interesting: 'centre')\n end\n else\n img_derivative = Vips::Image.thumbnail_buffer(source_file.content,\n width, height: opts[:height], auto_rotate: true)\n end\n \n return img_derivative\n end",
"def create_job_from_preset project_id:, location:, input_uri:, output_uri:, preset:\n # [START transcoder_create_job_from_preset]\n # project_id = \"YOUR-GOOGLE-CLOUD-PROJECT\" # (e.g. \"my-project\")\n # location = \"YOUR-JOB-LOCATION\" # (e.g. \"us-central1\")\n # input_uri = \"YOUR-GCS-INPUT-VIDEO\" # (e.g. \"gs://my-bucket/my-video-file\")\n # output_uri = \"YOUR-GCS-OUTPUT-FOLDER/\" # (e.g. \"gs://my-bucket/my-output-folder/\")\n # preset = \"YOUR-JOB-PRESET\" # (e.g. \"preset/web-hd\")\n\n # Require the Transcoder client library.\n require \"google/cloud/video/transcoder\"\n\n # Create a Transcoder client.\n client = Google::Cloud::Video::Transcoder.transcoder_service\n\n # Build the resource name of the parent.\n parent = client.location_path project: project_id, location: location\n\n # Set the job fields.\n new_job = {\n input_uri: input_uri,\n output_uri: output_uri,\n template_id: preset\n }\n\n job = client.create_job parent: parent, job: new_job\n\n # Print the job name.\n puts \"Job: #{job.name}\"\n # [END transcoder_create_job_from_preset]\n\n job\nend",
"def convert(format)\n manipulate! do |img|\n img.manipulate!(:format => format.to_s.downcase)\n img = yield(img) if block_given?\n img\n end\n end",
"def create\n @file = vid_params['file'].tempfile\n type = vid_params['file'].content_type\n client = YouTubeIt::Client.new(:username => ENV['GMAIL'], :password => ENV['GMAIL_PASSWORD'], :dev_key => ENV[\"YOUTUBE_API_KEY\"])\n res = client.video_upload(@file, title: vid_params['title'], description: vid_params['description'], category: 'People', :keywords => ['darity', 'dare', 'charity'])\n @video = Video.new(url: res.player_url, uid: res.player_url.gsub(/&.*/, \"\").gsub(/.*=/, \"\"), description: vid_params[\"description\"], title: vid_params['title'], dare_id: params[:dare_id])\n if @video.save\n redirect_to current_user\n else\n render html: \"Error\"\n end\n end",
"def transformation_command\n scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)\n trans = \"-scale \\\"#{scale}\\\"\"\n trans << \" -crop \\\"#{crop}\\\" +repage\" if crop\n trans << \" #{convert_options}\" if convert_options\n trans\n end",
"def create(file, name, project)\n\n asset = VAsset.new\n asset.v_project = project\n asset.v_user_data = project.v_user_data\n asset.path = userPath(name, asset.v_user_data)\n\n if asset.save\n File.open(asset.path, \"wb\") do |f|\n f.write file.read\n end\n end\n\n return asset\n end",
"def to_mzXML\n puts \"\\n--------------------------------\"\n puts \"Transforming raw file to mzXML format...\\n\\n\"\n \n system(\"wine readw.exe --mzXML #{@file}.raw #{$path}../data/spectra/#{File.basename(@file + \".raw\", \".raw\")}.mzXML 2>/dev/null\")\n end",
"def convert(format)\n manipulate!(:format => format)\n @format = format\n end",
"def write_to_target target, format_string, **opts\n raise Vips::Error, \"filename is nil\" if format_string.nil?\n filename = Vips.p2str(Vips.vips_filename_get_filename(format_string))\n option_string = Vips.p2str(Vips.vips_filename_get_options(format_string))\n saver = Vips.vips_foreign_find_save_target filename\n raise Vips::Error if saver.nil?\n\n Vips::Operation.call saver, [self, target], opts, option_string\n write_gc\n end",
"def create\n # byebug\n image_file = Cloudinary::Uploader.upload(params[:image_file])\n audio_file = Cloudinary::Uploader.upload(params[:audio_file], :resource_type => :video)\n sample = Sample.create(image_file: image_file[\"url\"], audio_file: audio_file[\"url\"], name: params[:name], genre: params[:genre], collection: params[:collection])\n\n render json: sample\n end",
"def create_processed_video(clazz)\n set_url\n processed_video = clazz.find(:first, :conditions => {:lesson_id => self.lesson})\n unless processed_video\n processed_video = clazz.create!(:lesson_id => self.lesson.id,\n :video_file_name => self.video_file_name,\n :s3_key => self.s3_key,\n :processed_video_cost => 0,\n :input_video_cost => 0,\n :converted_from_video => self,\n :s3_root_dir => self.s3_root_dir)\n end\n begin\n grant_s3_permissions_to_flix\n rescue Exception => e\n # rethrow the exception so we see the error in the periodic jobs log\n processed_video.change_status(VIDEO_STATUS_FAILED, e.message)\n raise e\n end\n processed_video\n end",
"def create\n @video = Video.new(video_params)\n @video.relateds.build\n @video.resources.build\n # obtain video metadata using the Wistia API\n Rails.logger.info(\"obtaining metadata from Wistia API for #{@video.wistia}\")\n media = Wistia::Media.find(@video.wistia)\n @video.title = media.name\n @video.description = ActionController::Base.helpers.strip_tags(media.description)\n @video.duration = (media.duration.to_i / 60) % 60\n @video.thumbnail_url = media.thumbnail.url\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to videos_path, notice: 'Created video listing.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @video = Video.new(video_params)\n file = @video.video.tempfile\n\n video = Panda::Video.create(:file => file)\n # binding.pry\n video.encodings['h264'].reload\n\n until video.encodings['h264'].status == 'success'\n video.encodings['h264'].reload\n end\n\n video.encodings['h264'].encoding_progress\n @video.video = video.encodings['h264'].url\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to @video, notice: 'video was successfully created.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def convert(filename)\n\n uuid = UUID.timestamp_create().to_s22\n\n source_file = Rails.root.join(DIRECTORY, \"#{uuid}_#{filename}\")\n full_size_image_file = Rails.root.join(DIRECTORY, \"#{uuid}_full_image.jpg\")\n large_thumbnail_file = Rails.root.join(DIRECTORY, \"#{uuid}_large_thumb_image.jpg\")\n small_thumbnail_file = Rails.root.join(DIRECTORY, \"#{uuid}_small_thumb_image.jpg\")\n\n # Write the source file to directory.\n f = File.new(source_file, \"wb\")\n f.write(self.raw_data)\n f.close\n\n # Use RMagick to resize the source file to the size defined by FULL_IMAGE_SIZE\n # and write the result to full_size_image_file\n full_size = Magick::Image.read(source_file).first\n full_size.change_geometry(FULL_IMAGE_SIZE) { |cols, rows, img|\n img.resize!(cols, rows)\n }\n full_size.write(full_size_image_file)\n\n # Use RMagick to resize the source file to the size defined by LARGE_THUMB_SIZE\n # and write the result to large_thumbnail_file\n large_thumb = Magick::Image.read(source_file).first\n large_thumb.change_geometry(LARGE_THUMB_SIZE) { |cols, rows, img|\n img.resize!(cols, rows)\n }\n large_thumb.write(large_thumbnail_file)\n\n # Make a thumbnail using RMagick. Thumbnail is created by cutting as big as possible\n # square-shaped piece from the center of the image and then resizing it to 50x50px.\n small_thumb = Magick::Image.read(source_file).first\n small_thumb.crop_resized!(SMALL_THUMB_WIDTH, SMALL_THUMB_HEIGHT, Magick::NorthGravity)\n small_thumb.write(small_thumbnail_file)\n\n # All conversions must succeed, else it's an error, probably because image file\n # is somehow corrupted.\n unless File.exists?(full_size_image_file) and File.exists?(large_thumbnail_file) and File.exists?(small_thumbnail_file)\n errors.add(:base, \"File upload failed. Image file is probably corrupted.\")\n return false\n end\n\n # Write new images to database and then delete image files.\n self.data = File.open(full_size_image_file,'rb').read\n File.delete(full_size_image_file)\n self.large_thumb = File.open(large_thumbnail_file,'rb').read\n File.delete(large_thumbnail_file)\n self.small_thumb = File.open(small_thumbnail_file,'rb').read\n File.delete(small_thumbnail_file)\n\n # Delete source file if it exists.\n File.delete(source_file)\n\n return true\n end",
"def create_thumb(filename, height = 130)\n convert_cmd = `which convert`.strip\n \n output_filename = filename.gsub(\".png\", \"\") + \"-thumb-height-#{height}.png\"\n \n if !system(\"#{convert_cmd} -resize 'x#{height}' \\\"#{filename}\\\" \\\"#{output_filename}\\\" 2>&1\")\n @convert_errors.push(\"Errors during running convert utility (thumbnailing) on file '#{filename}'\")\n end\n \n output_filename\n end",
"def convert(target)\n converter = VCardConverter.new\n converter.convert(self, target)\n end",
"def transformation_command\n scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)\n trans = []\n trans << \"-coalesce\" if animated?\n trans << \"-auto-orient\" if auto_orient\n trans << \"-resize\" << %[\"#{scale}\"] unless scale.nil? || scale.empty?\n trans << \"-crop\" << %[\"#{crop}\"] << \"+repage\" if crop\n trans << '-layers \"optimize\"' if animated?\n trans\n end",
"def initialize(file, output = false)\n @input = !output\n @timestamp_offset = 0\n @sync_pts = 0\n @video_stream = nil\n @stream_info = nil\n @format_parameters = FFMPEG::FormatParameters.new\n\n unless output then\n raise NotImplementedError, 'input from IO not supported' unless\n String === file\n\n open_input_file file, nil, 0, @format_parameters\n\n stream_info\n else\n @stream_info = true\n\n output_format = FFMPEG::OutputFormat.guess_format nil, file, nil\n\n self.output_format = output_format\n self.filename = file\n\n file = \"pipe:#{file.fileno}\" if IO === file\n\n open file, FFMPEG::URL_WRONLY\n end\n end",
"def video_resize_video_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_resize_video ...'\n end\n # resource path\n local_var_path = '/video/resize/preserveAspectRatio'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n header_params[:'extension'] = opts[:'extension'] if !opts[:'extension'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_resize_video\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def process_video(options = {})\n vzaar_video_id = nil\n request_xml = %{\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <vzaar-api>\n <video>\n <guid>#{options[:guid]}</guid>\n <title>#{options[:title]}</title>\n <description>#{options[:description]}</description>\n <profile>#{options[:profile]}</profile>\n }\n if !options[:transcoding].nil?\n request_xml += %{\n <transcoding>#{options[:transcoding]}</transcoding>\n }\n end\n request_xml += %{ \n </video>\n </vzaar-api>\n }\n auth_connection HTTP_POST, '/api/videos', request_xml do |response_body|\n vzaar_video_id = get_video_id_from_response_body(response_body)\n end\n vzaar_video_id\n end",
"def video(filename, opts = {})\n n = input(filename, opts)\n @videos << n\n n\n end",
"def initialize(options = {})\n if options[:raw_response]\n @raw_response = options[:raw_response]\n elsif options[:file]\n if options[:ffmpeg_binary]\n @ffmpeg_binary = options[:ffmpeg_binary]\n raise RuntimeError, \"ffmpeg could not be found (trying #{@ffmpeg_binary})\" unless FileTest.exist?(@ffmpeg_binary)\n else\n # assume it is in the unix path\n raise RuntimeError, 'ffmpeg could not be found (expected ffmpeg to be found in the Unix path)' unless FileTest.exist?(`which ffmpeg`.chomp)\n @ffmpeg_binary = \"ffmpeg\"\n end\n\n file = options[:file]\n @filename = File.basename(file)\n @path = File.dirname(file)\n @full_filename = file\n raise TranscoderError::InputFileNotFound, \"File not found (#{file})\" unless FileTest.exist?(file.gsub(\"\\\"\",\"\"))\n @raw_response = `#{@ffmpeg_binary} -i #{@full_filename} 2>&1`\n else\n raise ArgumentError, \"Must supply either an input file or a pregenerated response\" if options[:raw_response].nil? and file.nil?\n end\n\n # patched in https://github.com/zencoder/rvideo/pull/7\n metadata = /(Input \\#.*)\\n.+\\n\\Z/m.match(@raw_response)\n\n if /Unknown format/i.match(@raw_response) || metadata.nil?\n @unknown_format = true\n elsif /Duration: N\\/A/im.match(@raw_response)\n# elsif /Duration: N\\/A|bitrate: N\\/A/im.match(@raw_response)\n @unreadable_file = true\n @raw_metadata = metadata[1] # in this case, we can at least still get the container type\n else\n @raw_metadata = metadata[1]\n end\n end",
"def create\n\n @video_object = params[:video][:video_file] \n @video = Video.new(video_params)\n @video.competition = @competition \n @video.video_original_filename = @video_object.original_filename.to_s\n @video.video_content_type = @video_object.content_type.to_s\n\n respond_to do |format|\n if @video.save\n upload_file(@video.id, @video_object, \"original-videos\")\n send_msg_to_queue(@video.id.to_s)\n format.html { redirect_to @video.competition, success: 'Hemos recibido tu video y lo estamos procesando para que sea publicado. Tan pronto el video quede publicado en la página del concurso te notificaremos por email. Gracias.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def convert_file(markdown_file, to_format: :html, output_file: nil, full_document: false)\n opts = []\n opts.push('-t', String(to_format).downcase) if to_format\n opts.push('-o', File.expand_path(output_file)) if output_file\n opts.push('-f') if full_document == true\n @sh.run_command(@bin.to_path, *opts, File.expand_path(markdown_file))\n end",
"def create\n allowed_params = movie_params\n allowed_params[:genres] = [allowed_params[:genres]]\n allowed_params[:video_quality] = [allowed_params[:video_quality]]\n @movie = Movie.new(allowed_params)\n @movie.created_by = current_user\n\n if @movie.save\n redirect_to @movie\n else\n render :new\n end\n end"
] | [
"0.64386",
"0.5399262",
"0.52418005",
"0.509675",
"0.5071222",
"0.49909717",
"0.49622345",
"0.49142376",
"0.48898482",
"0.48708323",
"0.48601314",
"0.4829371",
"0.47956696",
"0.47826734",
"0.47809377",
"0.47781214",
"0.47545224",
"0.4665213",
"0.46629882",
"0.46584943",
"0.46475953",
"0.46366894",
"0.46356422",
"0.4598328",
"0.45979965",
"0.4590933",
"0.4590933",
"0.45804486",
"0.4519001",
"0.44926247",
"0.44482487",
"0.4441635",
"0.4404989",
"0.44005018",
"0.4396841",
"0.43692964",
"0.43413016",
"0.43374926",
"0.43088955",
"0.4297596",
"0.42648846",
"0.42336136",
"0.42121512",
"0.42003617",
"0.41963497",
"0.4193014",
"0.4174234",
"0.41713402",
"0.41651878",
"0.4159336",
"0.41593283",
"0.414528",
"0.41396382",
"0.41357976",
"0.41356254",
"0.41352212",
"0.41334373",
"0.4131972",
"0.41307256",
"0.41202694",
"0.41202503",
"0.4115185",
"0.41139337",
"0.41139337",
"0.41135225",
"0.41027975",
"0.40959063",
"0.4094504",
"0.40943247",
"0.4091692",
"0.4087773",
"0.4087773",
"0.40673968",
"0.4065494",
"0.40652043",
"0.40635166",
"0.40580043",
"0.40568697",
"0.40529",
"0.40496665",
"0.40479293",
"0.40348074",
"0.40332815",
"0.40285954",
"0.4016649",
"0.40154827",
"0.40082663",
"0.40066433",
"0.40046117",
"0.4001687",
"0.4001569",
"0.40003243",
"0.39910632",
"0.39894706",
"0.39886224",
"0.39875662",
"0.39848238",
"0.3979063",
"0.39774302",
"0.39718983"
] | 0.46732193 | 17 |
Performs the transcoding of the +file+ into a thumbnail/video. Returns the Tempfile that contains the new image/video. | def make
src = @file
dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
dst.binmode
parameters = []
# Add source
parameters << @convert_options[:input].map { |k,v| "-#{k.to_s} #{v} "}
parameters << "-f --quiet :source"
parameters << @convert_options[:output].map { |k,v| "-#{k.to_s} #{v} "}
parameters << ":dest"
parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
Paperclip.log("[lame] #{parameters}")
begin
success = Paperclip.run("lame", parameters, :source => "#{File.expand_path(src.path)}", :dest => File.expand_path(dst.path))
rescue Cocaine::ExitStatusError => e
raise PaperclipError, "error while processing video for #{@basename}: #{e}" if @whiny
end
dst
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end",
"def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n\n begin\n parameters = []\n parameters << source_file_options\n parameters << \":source\"\n parameters << transformation_command\n parameters << convert_options\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n\n success = Paperclip.run(\"convert\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Exception => e\n error_details = \"#{e.class}: #{e}\"\n error_details += \"\\n#{e.backtrace.join(\"\\n\")}\" if e.backtrace\n\n p \"ERROR: #{error_details}\"\n \n raise \"There was an error processing the thumbnail for #{@basename}\" if @whiny\n end\n\n dst\n end",
"def make\n src = @file\n filename = [@basename, @format ? \".#{@format}\" : \"\"].join\n dst = TempfileFactory.new.generate(filename)\n\n begin\n parameters = []\n parameters << source_file_options\n parameters << \":source\"\n parameters << transformation_command\n parameters << convert_options\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n\n frame = animated? ? \"\" : \"[#{@frame_index}]\"\n convert(\n parameters,\n source: \"#{File.expand_path(src.path)}#{frame}\",\n dest: File.expand_path(dst.path)\n )\n rescue Terrapin::ExitStatusError => e\n if @whiny\n message = \"There was an error processing the thumbnail for #{@basename}:\\n\" + e.message\n raise Paperclip::Error, message\n end\n rescue Terrapin::CommandNotFoundError => e\n raise Paperclip::Errors::CommandNotFoundError.new(\"Could not run the `convert` command. Please install ImageMagick.\")\n end\n\n dst\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, @format].compact.join(\".\"))\n dst.binmode\n\n command = <<-end_command\n #{ Paperclip.path_for_command('convert') }\n \"#{ File.expand_path(src.path) }\"\n #{ transformation_command }\n \"#{ File.expand_path(dst.path) }\"\n end_command\n success = system(command.gsub(/\\s+/, \" \"))\n\n if success && $?.exitstatus != 0 && @whiny_thumbnails\n raise PaperclipError, \"There was an error processing this thumbnail\"\n end\n\n dst\n end",
"def generate_video_thumbnail file\n FileUtils.rm(\"tmp/thumb.jpg\") if File.exists?(\"tmp/thumb.jpg\")\n begin\n `ffmpegthumbnailer -i #{file} -o tmp/thumb.jpg /dev/null 2>&1`\n File.new(\"tmp/thumb.jpg\").size > 0 ? true : false\n rescue => e\n logger.info e.inspect\n return false\n end\n end",
"def upload(file)\n logger.info 'Downloading video...'\n path = file.download.path\n movie = FFMPEG::Movie.new(path)\n @mp4_path = encode('mp4', movie, '-vcodec libx264 -strict -2')\n @webm_path = encode('webm', movie, '-vcodec libvpx -acodec libvorbis -f webm -deadline realtime -s 640x480')\n end",
"def checkForTranscode(path, filename)\n pathToFile = File.join(path, filename)\n outputPathToFile = File.join(TMP_PATH, pathToFile)\n\n if ($doNotConvertVideosAgain && File.exists?(outputPathToFile))\n BigBlueButton.logger.info( \"Converted video for #{pathToFile} already exists, skipping...\")\n return path\n end\n\n # Gather possible commands\n transcodeCommands = []\n movie = FFMPEG::Movie.new(pathToFile)\n unless (movie.width % 2 == 0 && movie.height % 2 == 0)\n BigBlueButton.logger.info( \"Video #{pathToFile} requires cropping to be DivBy2\")\n transcodeCommands.push(%w(-y -r 30 -vf crop=trunc(iw/2)*2:trunc(ih/2)*2))\n end\n if (movie.duration <= 0)\n BigBlueButton.logger.info( \"Video #{pathToFile} requires transcoding due to missing duration\")\n transcodeCommands.push(%w(-y -c copy))\n end\n\n # Run gathered commands\n if(transcodeCommands.length == 0)\n BigBlueButton.logger.info( \"Video #{pathToFile} is fine\")\n return path\n else\n # Create path to save conversion to\n outputPath = File.join(TMP_PATH, path)\n unless File.directory?(outputPath)\n FileUtils.mkdir_p(outputPath)\n end\n\n BigBlueButton.logger.info( \"Start converting #{pathToFile} ...\")\n transcodeCommands.each do | command |\n BigBlueButton.logger.info( \"Running ffmpeg with options: #{command}\")\n movie.transcode(outputPath + 'tmp' + filename, command)\n FileUtils.mv(outputPath + 'tmp' + filename, outputPathToFile)\n movie = FFMPEG::Movie.new(outputPathToFile) # Further transcoding should happen on the new file\n end\n\n BigBlueButton.logger.info( \"Done converting #{pathToFile}\")\n return outputPath\n end\nend",
"def make\n source = @file\n destination = Tempfile.new(@basename)\n\n Paperclip.run(\"convert\",\n \":source \" \\\n \"-quality 100 \" \\\n \"-bordercolor \\\"#000000\\\" \" \\\n \"-border 1x1 \" \\\n \"-fuzz 10% \" \\\n \"-trim +repage \" \\\n \":dest\",\n :source => File.expand_path(source.path),\n :dest => File.expand_path(destination.path)\n )\n\n destination\n end",
"def transcode!\n raise PaperclipError, 'The attachment is not a video' unless video?\n original_file = Paperclip.io_adapters.for(asset)\n asset.queued_for_write[:transcoded] = Paperclip.processor(:video_transcode).make(original_file, { :whiny => true, :geometry => '480x360' }, asset)\n asset.save\n ensure\n original_file.close if original_file.respond_to?(:close)\n end",
"def transcode!(file)\n optimize = transloadit_client.step('image', '/image/optimize', {\n progressive: true,\n use: ':original',\n result: true\n })\n store = transloadit_client.step('store', '/s3/store', {\n key: ENV.fetch('S3_ACCESS_KEY'),\n secret: ENV.fetch('S3_SECRET_KEY'),\n bucket: ENV.fetch('S3_BUCKET'),\n bucket_region: ENV.fetch('S3_REGION'),\n use: 'image'\n })\n assembly = transloadit_client.assembly(steps: [optimize, store])\n assembly.submit! open(file)\n end",
"def create_clean_file(file)\n name = clean_file_name(file)\n system(\"ffmpeg -i '#{file}' -map_metadata -1 -c:v copy -c:a copy #{@destination}/'#{name}'\")\n end",
"def make\n return @file unless @streaming\n\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n\n parameters = []\n # Add source\n parameters << \":source\"\n # Add destination\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n\n Paperclip.log(\"[qtfaststart] #{parameters}\")\n begin\n success = Paperclip.run(\"qtfaststart\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Cocaine::ExitStatusError => e\n raise PaperclipError, \"error while processing video for #{@basename}: #{e}\" if @whiny\n end\n\n dst\n end",
"def encode!(videofile)\n begin\n\n #output_filename = \"s3://#{ZENCODER_CONFIG['bucket']}/#{File.basename(self.video.name)}.webm\"\n \n logger.warn \"Transcoding '#{videofile.url}'\"\n \n response = Zencoder::Job.create({\n :input => videofile.url,\n :output => {\n :width => \"480\",\n :height => \"320\",\n #:url => output_filename,\n :notification => ZENCODER_CONFIG['notification_url']\n }\n })\n \n logger.warn 'Response: '+response.raw_response\n \n if(response.success?)\n self.encoded_state = \"queued\"\n self.output_url = response.body[\"outputs\"].first[\"url\"]\n self.job_id = response.body['id']\n else\n errors.add_to_base(response.raw_response)\n end \n \n# zen = Zencoder.new(\"http://s3.amazonaws.com/\" + zencoder_setting[\"s3_output\"][\"bucket\"], zencoder_setting[\"settings\"][\"notification_url\"])\n# # 'video.url(:original, false)' prevents paperclip from adding timestamp, which causes errors\n# if zen.encode(self.video.url(:original, false), 800, 450, \"/thumbnails_#{self.id}\", options)\n# self.encoded_state = \"queued\"\n# self.output_url = zen.output_url\n# self.job_id = zen.job_id\n# self.save\n# else\n# errors.add_to_base(zen.errors)\n# nil\n# end\n rescue RuntimeError => exception\n errors.add_to_base(\"Video encoding request failed with result: \" + exception.to_s)\n nil\n end\n end",
"def pre_conversion(file)\n # puts \"===== PRE ====\"\n tmp_file = tmp_filepath(file)\n FileUtils.cp(file, tmp_file)\n # puts \"Copied #{file} to #{tmp_file}\"\n end",
"def _copy_to_tempfile(file)\n args = [File.basename(file.path, \".*\"), File.extname(file.path)] if file.respond_to?(:path)\n tempfile = Tempfile.new(args || \"image\", binmode: true)\n IO.copy_stream(file, tempfile.path)\n file.rewind\n tempfile\n end",
"def convert(filename)\n\n uuid = UUID.timestamp_create().to_s22\n\n source_file = Rails.root.join(DIRECTORY, \"#{uuid}_#{filename}\")\n full_size_image_file = Rails.root.join(DIRECTORY, \"#{uuid}_full_image.jpg\")\n large_thumbnail_file = Rails.root.join(DIRECTORY, \"#{uuid}_large_thumb_image.jpg\")\n small_thumbnail_file = Rails.root.join(DIRECTORY, \"#{uuid}_small_thumb_image.jpg\")\n\n # Write the source file to directory.\n f = File.new(source_file, \"wb\")\n f.write(self.raw_data)\n f.close\n\n # Use RMagick to resize the source file to the size defined by FULL_IMAGE_SIZE\n # and write the result to full_size_image_file\n full_size = Magick::Image.read(source_file).first\n full_size.change_geometry(FULL_IMAGE_SIZE) { |cols, rows, img|\n img.resize!(cols, rows)\n }\n full_size.write(full_size_image_file)\n\n # Use RMagick to resize the source file to the size defined by LARGE_THUMB_SIZE\n # and write the result to large_thumbnail_file\n large_thumb = Magick::Image.read(source_file).first\n large_thumb.change_geometry(LARGE_THUMB_SIZE) { |cols, rows, img|\n img.resize!(cols, rows)\n }\n large_thumb.write(large_thumbnail_file)\n\n # Make a thumbnail using RMagick. Thumbnail is created by cutting as big as possible\n # square-shaped piece from the center of the image and then resizing it to 50x50px.\n small_thumb = Magick::Image.read(source_file).first\n small_thumb.crop_resized!(SMALL_THUMB_WIDTH, SMALL_THUMB_HEIGHT, Magick::NorthGravity)\n small_thumb.write(small_thumbnail_file)\n\n # All conversions must succeed, else it's an error, probably because image file\n # is somehow corrupted.\n unless File.exists?(full_size_image_file) and File.exists?(large_thumbnail_file) and File.exists?(small_thumbnail_file)\n errors.add(:base, \"File upload failed. Image file is probably corrupted.\")\n return false\n end\n\n # Write new images to database and then delete image files.\n self.data = File.open(full_size_image_file,'rb').read\n File.delete(full_size_image_file)\n self.large_thumb = File.open(large_thumbnail_file,'rb').read\n File.delete(large_thumbnail_file)\n self.small_thumb = File.open(small_thumbnail_file,'rb').read\n File.delete(small_thumbnail_file)\n\n # Delete source file if it exists.\n File.delete(source_file)\n\n return true\n end",
"def _copy_to_tempfile(file)\n args = [File.basename(file.path, \".*\"), File.extname(file.path)] if file.respond_to?(:path)\n tempfile = Tempfile.new(args || \"image\", binmode: true)\n IO.copy_stream(file, tempfile.path)\n file.rewind\n tempfile\n end",
"def convert\n # TODO: implementation\n output_file = choose_output\n return if output_file.nil?\n Converter.translate(@file, output_file)\n log(\"File conversion finished\")\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, 'png'].compact.join(\".\"))\n dst.binmode\n \n\n parms = []\n parms << \"-size #{@target_geometry.width.to_i}x#{@target_geometry.height.to_i}\"\n parms << \"-quality 95\"\n parms << convert_options\n parms << \"#{File.expand_path(src.path)}[0]\"\n parms << File.expand_path(dst.path)\n \n parameters = parms.flatten.compact.join(\" \").strip.squeeze(\" \")\n \n \n# Rails.logger.info @file.path\n# Rails.logger.info '========== gm convert ' + parameters\n # success = Paperclip.run('gm convert', parameters)\n # success = Paperclip::CommandLine.new('gm convert', parameters, :expected_outcodes => [0, 1]).run\n\n output = `gm convert #{parameters}`\n if ! [0, 1].include?($?.exitstatus)\n raise PaperclipError, \"There was an error converting pdf to png: #{output} #{e}\" if @whiny\n end\n\n# success = Paperclip.run('gm convert', parameters)\n\n\n\n Rails.logger.info '========== tmpfile: ' + dst.path\n\n return dst\n# return ' s'\n end",
"def temp_file\n File.join($config[\"processed_loc\"], File.basename(@origional_file).sub('.'+process_tag, '').sub(File.extname(@origional_file), '.mkv'))\n end",
"def process\n result = Tempfile.new([\"\", self.extension])\n result.binmode\n begin\n parameters = []\n parameters << self.path\n if width and height\n parameters << case operation\n when '#' then \"-resize #{width}x#{height}^ -gravity center -extent #{width}x#{height}\"\n when '<' then \"-resize #{width}x#{height}\\\\<\"\n when '>' then \"-resize #{width}x#{height}\\\\>\"\n else \"-resize #{width}x#{height}\"\n end\n end\n parameters << \"-quality #{quality}\" if quality\n parameters << result.path\n parameters = parameters.join(\" \").squeeze(\" \")\n `convert #{parameters} #{redirect}`\n raise Errno::ENOENT if $?.exitstatus == 127\n rescue Errno::ENOENT\n raise \"command 'convert' not found: ensure ImageMagick is installed\"\n end\n unless $?.exitstatus == 0\n raise Attached::Processor::Error, \"must be an image file\"\n end\n return result\n end",
"def transcode\n if EncodingStrategy == 'transcode'\n logger.info \"Sending video to transcode worker (#{self.id})\"\n # NOTE:\n # At this point attachment_fu has not copied the file to its proper place.\n # The worker may fail if it executes before attachment_fu's callback does...\n # How to chain after_create with after_process_attachment???\n TranscodeWorker.async_transcode_video(:id => self.id)\n end\n end",
"def convertFile(file)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFile\", \"html-to-image\", \"The file must exist and not be empty.\", \"convert_file\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data)\n end",
"def destination_file\n @origional_file.sub('.'+process_tag, '').sub(File.extname(@origional_file), '.mkv')\n end",
"def convertFileToStream(file, out_stream)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFileToStream::file\", \"html-to-image\", \"The file must exist and not be empty.\", \"convert_file_to_stream\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data, out_stream)\n end",
"def via_files(filename, thumbnail_width)\n thumb = Vips::Image.thumbnail filename, thumbnail_width, crop: \"centre\"\n\n thumb.write_to_buffer \".jpg\"\nend",
"def make\n src = @file\n dst = Tempfile.new(@basename)\n dst.binmode\n\n command = <<-end_command\n #{transformation_command}\n \"#{File.expand_path(src.path)}[0]\"\n \"#{File.expand_path(dst.path)}\"\n end_command\n\n begin\n success = Paperclip.run('composite', command.gsub(/\\s+/, ' '))\n rescue PaperclipCommandLineError\n raise PaperclipError, \"There was an error processing the watermark for #{@basename}\" if @whiny\n end\n\n dst\n end",
"def create_from_file\n\n\t\t@user = current_user\n\n\t\tif current_user.is_bot?\n\t\t\tcurrent_user = User.bots.sample\n\t\telse\n\t\t\t# idk why this is necessary but without it current_user becomes nil\n\t\t\tcurrent_user = @user\n\t\tend\n\n\t\t@video = Video.new\n\t\t@video.creator = current_user\n\t\t@video.component = Component.find_by_id(params[:component_id])\n\t\t@video.s3_key = params[:s3_key]\n\t\t@video.hosted = true\n\t\t@video.source = \"vimeo\"\n\t\t@video.save\n\t\t@video.upload # starts the bg task (uploads to vimeo)\n\n\t\tflash[:blue] = \"Your video has been uploaded! Please allow some time for processing.\"\n\n\t\trender :type => \"text/javascript\", :text => \"#{@video.id}\"\n\t\t\n end",
"def convert(filename)\n\n uuid = UUID.timestamp_create().to_s22\n\n source_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_#{filename}\")\n full_size_image_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_full_image.jpg\")\n large_thumbnail_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_large_thumb_image.jpg\")\n small_thumbnail_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_small_thumb_image.jpg\")\n\n # Write the source file to directory.\n f = File.new(source_file, \"wb\")\n f.write(self.raw_data)\n f.close\n\n # Then resize the source file to the size defined by full_image_size parameter\n # and convert it to .jpg file. Resize uses ImageMagick directly from command line.\n img = system(\"#{'convert'} '#{source_file}' -resize #{FULL_IMAGE_SIZE} '#{full_size_image_file}' > #{RAILS_ROOT}/log/convert.log\")\n large_thumb = system(\"#{'convert'} '#{source_file}' -resize #{LARGE_THUMB_SIZE} '#{large_thumbnail_file}' > #{RAILS_ROOT}/log/convert.log\")\n\n # If new file exists, it means that the original file is a valid image file. If so,\n # make a thumbnail using RMagick. Thumbnail is created by cutting as big as possible\n # square-shaped piece from the center of the image and then resizing it to 50x50px.\n if img\n small_thumb = Magick::Image.read(source_file).first\n small_thumb.crop_resized!(SMALL_THUMB_WIDTH, SMALL_THUMB_HEIGHT, Magick::NorthGravity)\n small_thumb.write(small_thumbnail_file)\n end\n\n # Delete source file if it exists.\n File.delete(source_file) if File.exists?(source_file)\n\n # Both conversions must succeed, else it's an error, probably because image file\n # is somehow corrupted.\n unless img and large_thumb and small_thumb\n errors.add_to_base(\"File upload failed. Image file is probably corrupted.\")\n return false\n end\n\n # Write new images to database and then delete image files.\n self.data = File.open(full_size_image_file,'rb').read\n File.delete(full_size_image_file) if File.exists?(full_size_image_file)\n self.large_thumb = File.open(large_thumbnail_file,'rb').read\n File.delete(large_thumbnail_file) if File.exists?(large_thumbnail_file)\n self.small_thumb = File.open(small_thumbnail_file,'rb').read\n File.delete(small_thumbnail_file) if File.exists?(small_thumbnail_file)\n return true\n end",
"def convertFile(file)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFile\", \"image-to-image\", \"The file must exist and not be empty.\", \"convert_file\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data)\n end",
"def convert(force = false)\n return false if !force && STATUS_CONVERSION_PENDNG != status\n update_attribute(:status, STATUS_PROCESSING)\n # convert to flv\n flv_path = \"#{AppConfig.tmp_dir}/video-#{id}.flv\"\n File.delete flv_path if File.exists? flv_path\n\n # get an image from the video after 4 seconds \n img_path = \"#{AppConfig.tmp_dir}/video-#{id}-%d.jpg\"\n img_path2 = \"#{AppConfig.tmp_dir}/video-#{id}-1.jpg\"\n File.delete img_path2 if File.exists? img_path2\n\n begin\n system(\"#{AppConfig.video_conversion_command} -i #{File.expand_path(RAILS_ROOT)}/#{original_file} -ar 44100 #{flv_path}\")\n raise \"Failed to convert '#{File.expand_path(RAILS_ROOT)}/#{original_file}' to flv!\" unless $? == 0\n self.stream_file = File.new(flv_path)\n if image.blank?\n system(\"#{AppConfig.video_conversion_command} -i #{File.expand_path(RAILS_ROOT)}/#{original_file} -an -ss 00:00:04 -an -r 1 -vframes 1 -y #{img_path}\")\n unless File.exists? img_path2\n system(\"#{AppConfig.video_conversion_command} -i #{File.expand_path(RAILS_ROOT)}/#{original_file} -an -ss 00:00:00 -an -r 1 -vframes 1 -y #{img_path}\")\n end\n p \"tmp img - #{img_path2}\"\n self.image = File.new(img_path2) if File.exists? img_path2\n end\n\n self.status = STATUS_LIVE\n self.save!\n watermark_image(\"#{RAILS_ROOT}/#{image('thumb')}\") unless image.blank?\n FileUtils.rm_rf(self.original_file_dir)\n return true\n rescue\n update_attribute(:status, STATUS_ERROR)\n logger.error \"ERROR:#{Time.now.iso8601}: #{$!}\"\n return false\n ensure\n File.delete flv_path if File.exists? flv_path\n File.delete img_path2 if File.exists? img_path2\n end\n end",
"def encoded_to_file(encoded_file, file_name = nil)\n extension = file_name ? \".#{file_name.match(/[^\\.]+$/)}\" : ''\n temp_file = Tempfile.new([SecureRandom.hex(3), extension])\n temp_file.binmode\n temp_file.write(Base64.decode64(encoded_file))\n temp_file.close\n temp_file\n end",
"def mv(file)\n abort \"#{file} does not exist\" unless File.exist? file\n\n timestamp = Time.now.strftime(\"%F %H.%M.%S\")\n new_file = \"Screenshot #{timestamp}.#{File.extname(file).slice(1..-1)}\"\n new_path = File.join(destination_directory, new_file)\n new_dir = File.dirname(new_path)\n\n FileUtils.mkdir_p(new_dir) or abort \"Couldn't create #{new_dir}\"\n FileUtils.mv(file, new_path) or abort \"Coudln't move #{file} to #{new_path}\"\n\n new_path\n end",
"def get_thumbnail(input)\n puts \"getting thumbnail of #{input}\"\n out = File.join(File.dirname(input),File.basename(input,File.extname(input)) + \"-%d.jpg\")\n FFmpeg.encode do |ff| \n ff.input = input\n ff.record_start_time = 0\n ff.record_for = 0.001\n ff.video_frames = 1\n ff.video_frame_size = '200x150'\n ff.output = out\n end\n end",
"def convert(file_info)\n input_name = Shellwords.escape(file_info[:filename])\n input_suffix = File.extname input_name\n output_name = File.basename input_name, input_suffix\n output_suffix = \"mp4\"\n command = [ \"ffmpeg\", \"-y\", \"-i #{input_name}\", \"-max_muxing_queue_size 9999\", \"-map_chapters -1\" ]\n\n if (file_info[:video].empty? && !file_info[:audio].empty?) || input_suffix == '.flac' || input_suffix == '.mp3' || input_suffix == '.aiff'\n #\n # Audio-only files are converted to either ALAC if the source was FLAC, or\n # AAC for all other formats.\n #\n stream = file_info[:audio][0]\n case stream[:codec]\n when \"alac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a copy\"\n when \"flac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n when \"mp3\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n else\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a aac\" << \"-ar:a:0 48k\" << \"-ab:a 256k\"\n end\n output_suffix = \"m4a\"\n elsif !file_info[:video].empty? && !file_info[:audio].empty?\n # Removes all of the default metadata that junks up the final file.\n command << \"-map_metadata -1\"\n \n # Maps the video track\n command << \"-map 0:v:0\" << \"-metadata:s:v:0 language=und\" << \"-metadata:s:v:0 title='Video Track'\"\n\n #\n # The video track is copied if the codec is h265 (hevc) and a video tag\n # is added so that Apple products understand the format. Otherwise, the\n # video track is copied if it's in h264 format and the frame size is\n # to remain the same, or it's converted to h264 using high-quality\n # settings.\n #\n if \"hevc\" == file_info[:video][:codec]\n command << \"-codec:v copy -vtag hvc1\"\n elsif \"h264\" == file_info[:video][:codec] && !Options.options[:P480] && !Options.options[:P720]\n command << \"-codec:v copy\"\n else\n # This converts the video using settings that provide nearly visual\n # lossless results.\n output_suffix = \"mp4\"\n command << \"-codec:v libx265\" << \"-vtag hvc1\" << \"-preset:v slow\" << \"-profile:v main\" << \"-crf:v 18\" << \"-threads:v 0\"\n\n # Converts HD video to wide-screen 720P if necessary.\n command << \"-vf:v scale=1280:-1\" if Options.options[:P720]\n\n # Converts HD video to wide-screen 480P if necessary.\n command << \"-vf:v scale=854:-1\" if Options.options[:P480]\n end\n\n # Convert all of the audio tracks to AAC (stereo) and AC3 (multi-channel)\n index = 0\n file_info[:audio].each do |stream|\n index, c = convert_audio(stream, index)\n command << c\n end\n\n if file_info.key?(:subtitle) && !file_info[:subtitle].nil? && !file_info[:subtitle].empty?\n command << \"-map 0:s:#{file_info[:subtitle][:index]}\" << \"-metadata:s:s:0 language=eng\" << \"-metadata:s:s:0 title='Subtitle Track'\"\n command << ('dvd_subtitle' == file_info[:subtitle][:codec] ? \"-codec:s:0 copy\" : \"-codec:s:0 mov_text\")\n end\n\n end\n\n command << \"#{output_name}.#{output_suffix}\"\n\n if Options.options[:dump]\n puts command.join(' ')\n exit\n end\n\n #\n # Starts the transcoding process.\n #\n puts file_info[:filename]\n progress = ProgressBar.create(:format => \"%t |%B| %e\",\n :total => file_info[:duration] + 1,\n :title => \"Encoding Progress\")\n execute(command, true) do |line|\n begin\n line.match /time=(\\d\\d):(\\d\\d):(\\d\\d)/ do |match|\n if match.length == 4\n time = match[1].to_i * 3600 + match[2].to_i * 60 + match[3].to_i\n progress.progress = time\n end\n end\n rescue\n # Some UTF-8 characters can cause match to throw, but these characters are not used by this script.\n end\n end\n progress.finish\nend",
"def uploadoriginal(file,path)\n\text = File.extname(file)\n \tif ext.upcase == \".JPG\"\n \t\textfinal = \".jpg\"\n \telsif ext.upcase == \".JPEG\"\n \t\textfinal = \".jpg\"\n \telsif ext.upcase == \".GIF\"\n \t\textfinal = \".gif\"\n \telsif ext.upcase == \".PNG\"\n \t\textfinal = \".png\"\n \tend\t\n\t\t\n\t\t\n \t#nombre original de la imagen\n \tfilename_orig = File.basename(file, '.*')\n\n \t#remove white space in image name\n \tfilename_orig = filename_orig.gsub(\" \",\"-\")\n\n \twidth = 800\n\n \timage = Magick::Image.read(file).first\n\n \twidthimage = image.columns\n \theightimage = image.rows\n \theight = (width * heightimage) / widthimage\n \tthumbnail = image.thumbnail(width, height)\n\n\n \tfinalname = path + \"800-\" + filename_orig + extfinal\n \tq=99\n \tthumbnail.write(finalname){ self.quality = q }\n return filename_orig + extfinal\n \nend",
"def create_locally\n write_file(@video_file, @video_name)\n write_file(@poster_file, @poster_name)\n end",
"def upload_file (filename, video_filename)\n\t# new filename is the md5 of the old filename, plus \"jpg\"\n\tnew_filename = Digest::MD5.hexdigest video_filename\n\tnew_filename += '.jpg'\n\n\tFileUtils.mv(filename, [Config['WebServer']['webroot'], Config['WebServer']['preview_dir'], new_filename].join('/'))\n\n\treturn [Config['WebServer']['url'], Config['WebServer']['preview_dir'], new_filename].join('/')\nend",
"def convert_file(file_name, from_format, to_format)\n begin\n from_file_name = Rails.root.join('public', 'uploads', request.remote_ip, file_name)\n to_file_name = Rails.root.join('public', 'uploads', request.remote_ip, file_name.gsub(from_format, to_format))\n #Read the uploaded image from the disk\n from_image = Image.read(from_file_name).first\n #Copy the image into a new variable\n to_image = from_image.copy\n #Change the format for the selected by user\n to_image.format = to_format[1..3].upcase\n #Write the copied image with the new format into the user temporal folder\n to_image.write(to_file_name)\n rescue Exception => e\n raise\n end\n end",
"def generate_thumb(tmp_file_path)\n %x(convert #{tmp_file_path}.pdf[0-#{@num_thumb_pages}] -thumbnail x640 #{tmp_file_path}.png)\n stripped_file_names = (0...@num_thumb_pages).to_a.map { |i| \"#{tmp_file_path}-#{i}.png\" }.join(\" \")\n output_path = \"#{tmp_file_path}_merged.jpg\"\n %x(montage #{stripped_file_names} -mode concatenate -quality 80 -tile x1 #{output_path})\n\n output_path\n end",
"def to_mp3\n temp = Tempfile.new(File.basename(filename, '.flv') + \".mp3\")\n \n begin\n transcoder = Transcoder.new(full_filename, temp.path)\n transcoder.flashToAudio\n save_transcoder_commands(transcoder)\n rescue RVideo::TranscoderError => e\n save_transcoder_commands(transcoder)\n raise AudioConversionException.new(\"Unable to convert recording to audio: #{e.message}\")\n end\n \n temp.path\n end",
"def fast_asset=(file)\n if file && file.respond_to?('[]')\n self.tmp_upload_dir = \"#{file['filepath']}_1\"\n tmp_file_path = \"#{self.tmp_upload_dir}/#{file['original_name']}\"\n FileUtils.mkdir_p(self.tmp_upload_dir)\n FileUtils.mv(file['filepath'], tmp_file_path)\n self.asset = File.new(tmp_file_path)\n end\n end",
"def upload_thumb\n path = \"#{Rails.root}/tmp/#{id}_#{Process.pid}.png\"\n `convert #{@file.tempfile.path}[0] -scale 128x128 #{path}`\n\n if File.exists? path\n file_s3_obj_thumb.write(file: path, content_type: 'image/png')\n File.delete(path)\n end\n end",
"def flac_to (origin, destination)\n puts_and_logs \"Transforming \\\"#{origin}\\\" into \\\"#{destination}\\\".\"\n return if config[:simulate]\n unless should_process_file? destination\n puts_and_logs ' - File exists. Skipping transformation...'\n return\n end\n verify_destination_folder(destination)\n begin\n temp_file = Tempfile.new(self.class.name)\n temp_file.close\n tags = flac_tags(origin)\n run_command build_flac_cmd(origin, temp_file.path)\n yield temp_file, tags\n puts_and_logs ' - Done'\n ensure\n temp_file.unlink\n end\n end",
"def convertFileToStream(file, out_stream)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFileToStream::file\", \"image-to-image\", \"The file must exist and not be empty.\", \"convert_file_to_stream\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data, out_stream)\n end",
"def uploaded_file(filename, content_type = \"image/png\")\n t = Tempfile.new(filename)\n t.binmode\n path = File.join(RAILS_ROOT, \"spec\", \"images\", filename)\n FileUtils.copy_file(path, t.path)\n (class << t; self; end).class_eval do\n alias local_path path\n define_method(:original_filename) {filename}\n define_method(:content_type) {content_type}\n end\n return t\n end",
"def move_temp_to_destination\n if !File.exist? temp_file\n $logger.info \"no moving, transcode didn't complete\"\n return\n end\n $logger.info \" moving (temp->destination)\\n #{temp_file} ->\\n #{destination_file}\"\n FileUtils.mv temp_file, destination_file\n end",
"def thumbnail_file(input_path, output_path, options = {})\n opts = {\n :format => File.extname(output_path).sub(/^\\./, '')\n }.merge(options)\n \n data = SmartImage.thumbnail File.read(input_path), opts\n File.open(output_path, 'w') { |file| file << data }\n end",
"def thumbnail(options={})\n image = File.expand_path(options[:image])\n\n encode do |ffmpeg|\n ffmpeg.input = options[:video]\n ffmpeg.record_start_time = options[:start]\n ffmpeg.record_for = options[:length]\n ffmpeg.video_frames = options[:frames]\n ffmpeg.fps = (options[:fps] || 1)\n ffmpeg.video_frame_size = \"#{options[:width]}x#{options[:height]}\"\n ffmpeg.disable_audio = true\n ffmpeg.overwrite_output_files = true\n ffmpeg.output = image\n end\n\n image_search = image.split('%d').map { |part|\n Regexp.escape(part)\n }.join('*')\n\n return Dir[image_search]\n end",
"def convert\n\t\tif self.video.file?\n\t\t\tself.convert!\n\n\t\t\tsuccess = system(convert_command)\n\t\t\tif success && $?.exitstatus == 0\n\t\t\t\tself.converted!\n\t\t\telse\n\t\t\t\tself.failed!\n\t\t\tend\n\t\tend\n\tend",
"def save_to_temp_file\n result = true\n unless upload_temp_file\n\n # Image is supplied in a input stream. This can happen in a variety of\n # cases, including during testing, and also when the image comes in as\n # the body of a request.\n if upload_handle.is_a?(IO) || upload_handle.is_a?(StringIO) ||\n defined?(Unicorn) && upload_handle.is_a?(Unicorn::TeeInput)\n begin\n # Using an instance variable so the temp file lasts as long as\n # the reference to the path.\n @file = Tempfile.new(\"image_upload\")\n File.open(@file, \"wb\") do |write_handle|\n loop do\n str = upload_handle.read(16_384)\n break if str.to_s.empty?\n\n write_handle.write(str)\n end\n end\n # This seems to have problems with character encoding(?)\n # FileUtils.copy_stream(upload_handle, @file)\n self.upload_temp_file = @file.path\n self.upload_length = @file.size\n result = true\n rescue StandardError => e\n errors.add(:image,\n \"Unexpected error while copying attached file \" \\\n \"to temp file. Error class #{e.class}: #{e}\")\n result = false\n end\n\n # It should never reach here.\n else\n errors.add(:image, \"Unexpected error: did not receive a valid upload \" \\\n \"stream from the webserver (we got an instance of \" \\\n \"#{upload_handle.class.name}). Please try again.\")\n result = false\n end\n end\n result\n end",
"def convert_file tempfile\n path = tempfile.path\n filetype = get_mime_type(path)\n\n if filetype == 'application/pdf'\n convert_pdf_to_html(path)\n elsif filetype == 'text/html'\n File.read(path)\n else\n convert_document_to_html(path)\n end\n end",
"def savevid\n tmp = params[:vids][:video].tempfile\n #require 'ftools'\n file = File.join(\"app/assets/videos\", params[:vids][:video].original_filename) # use public if you want\n FileUtils.cp tmp.path, file\n\n redirect_to \"/admin\"\nend",
"def thumbnail\n source_dir = Item.new(Path.new(params[:source_dir]))\n filetype = params[:filetype]\n #filetype = params[:filetype].present? ? params[:filetype] : 'tif'\n size = params[:size].present? ? params[:size] : '200'\n size_input = \"x#{size}\"\n \n response = {}\n \n # Check if source package folder exists\n if !source_dir.exist?\n response[:msg] = \"No folder at location #{source_dir.path.to_s}, nothing to do\"\n render json: response, status: 404\n return\n end\n\n # Check if original file exists\n original_file = Item.new(Path.new(source_dir.path.to_s + \"/#{params[:source]}/#{params[:image]}.#{filetype}\"))\n \n if !original_file.exist?\n response[:msg] = \"No original file at location #{original_file.path.to_s}, nothing to do\"\n render json: response, status: 404\n return\n end\n\n # Check if thumnail file exists\n thumbnail_file = Item.new(Path.new(source_dir.path.to_s + \"/thumbnails/#{params[:source]}/#{size}/#{params[:image]}.jpg\"))\n \n thumbnail_exists = false\n if thumbnail_file.exist?\n # check if original file is older than thumbnail, if so replace it\n if File.mtime(original_file.path.to_s) < File.mtime(thumbnail_file.path.to_s)\n thumbnail_exists = true\n # Set thumbnail to return as existing\n end\n end\n\n # If thumbnail doesn't exist or is old, generate it\n if !thumbnail_exists\n original_file.copy_and_convert_to(thumbnail_file, '50%', size_input)\n end\n\n f = File.read(thumbnail_file.path.to_s)\n # Return thumbnail response\n response = {}\n response[:thumbnail] = Base64.encode64(f)\n render json: response, status: 200\n end",
"def convertFile(file)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFile\", \"image-to-pdf\", \"The file must exist and not be empty.\", \"convert_file\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data)\n end",
"def convertFileToFile(file, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertFileToFile::file_path\", \"html-to-image\", \"The string must not be empty.\", \"convert_file_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertFileToStream(file, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end",
"def video_convert_to_mov_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_mov ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mov'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_mov\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def tempfile\n ::Tempfile.new(filename, tempfile_path).tap do |tmp|\n tmp.binmode\n tmp.write(blob)\n tmp.close\n end\n end",
"def via_memory(filename, thumbnail_width)\n data = IO.binread(filename)\n\n thumb = Vips::Image.thumbnail_buffer data, thumbnail_width, crop: \"centre\"\n\n thumb.write_to_buffer \".jpg\"\nend",
"def create_gzip_file(file) \n unless (MIME::Types.type_for(file).first.try(:media_type)==\"image\" or MIME::Types.type_for(file).first.try(:raw_sub_type)==\"x-shockwave-flash\")\n file_name=file.gsub(\"#{Rails.root}/public/\",\"\")\n new_file_path=\"#{Rails.root}/s3_assets/#{file_name}\"\n base_name=File.basename(file)\n dir_name=new_file_path.gsub(base_name,\"\")\n #no need to compress image files\n FileUtils.mkdir_p(dir_name) unless File.directory? dir_name\n system(\"gzip -c #{file} > #{new_file_path}\")\n end\n end",
"def encode(file=\"output.avi\")\n puts \"encoding video #{file}\"\n MEncoder.encode do |mencoder|\n mencoder.input = \"mf://#{@frames_dir.file_list(@date, @hour, @length, @frame_type).join(',')}\"\n mencoder.mf.fps = 2\n mencoder.mf.type = \"jpg\"\n mencoder.output_video_codec = :lavc\n mencoder.lavc.vcodec = \"mpeg4\"\n mencoder.lavc.mbd = 2\n mencoder.lavc.trell = true\n mencoder.output_audio_codec = 'copy'\n mencoder.output = file\n end\n end",
"def tempfile\n @tempfile ||= ::Tempfile.new(filename, tempfile_path).tap do |t|\n t.close\n image.write(t.path)\n end\n end",
"def store_file\n # TODO\n # - kick BOM if present\n # - convert to UTF-8 if a different encoding is given\n # - we should check double encoding because the tempfile is always read as utf8\n\n # writes the file binary/raw without taking encodings into account.\n # If we want to convert incoming files this should be done before\n File.open(full_filename, 'wb') do |f| #w:UTF-8\n f.write @uploaded_file.read\n end\n end",
"def video_convert_to_mp4_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_mp4 ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mp4'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_mp4\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n\n @video = Video.new(video_params)\n file = @video.video.tempfile\n\n video = Panda::Video.create(:file => file)\n # binding.pry\n video.encodings['h264'].reload\n\n until video.encodings['h264'].status == 'success'\n video.encodings['h264'].reload\n end\n\n video.encodings['h264'].encoding_progress\n @video.video = video.encodings['h264'].url\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to @video, notice: 'video was successfully created.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def decompress_file(file, to)\n end",
"def create\n @videofile = Videofile.new(params[:videofile])\n \n respond_to do |format|\n if @videofile.save\n format.html { redirect_to(@videofile, :notice => 'Videofile was successfully created.') }\n format.xml { render :xml => @videofile, :status => :created, :location => @videofile }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @videofile.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def encode_file(_file_suffix, _options = {})\n # convert to pdf\n self.class.encode(source_path, \"pdf\", Hydra::Derivatives.temp_file_base)\n pdf_file = File.join(Hydra::Derivatives.temp_file_base, [File.basename(source_path, \".*\"), 'pdf'].join('.'))\n\n # persist pdf original as access\n\n output_file_service.call(File.open(pdf_file, \"rb\"), url: directives.fetch(:access))\n\n # create thumbnails from the pdf using Hydra::Derivatives::Processors::Image\n Hydra::Derivatives::Processors::Image.new(pdf_file, thumbnail_directives).process\n Hydra::Derivatives::Processors::Image.new(pdf_file, citi_thumbnail_directives).process\n\n # clean up\n File.unlink(pdf_file)\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, '.ogg'])\n command = <<-end_command\n-\n\"#{ File.expand_path(src.path) }\"\n| /usr/bin/oggenc - -o\n\"#{ File.expand_path(dst.path) }\"\nend_command\n\n begin\n success = Paperclip.run(\"/usr/bin/mpg321 -q -w\", command.gsub(/\\s+/, \" \"))\n Rails.logger.info \"Converting #{src.path} to #{dst.path} in the Ogg processor.\"\n rescue Cocaine::ExitStatusError => e\n raise PaperclipError, \"There was an error converting #{@basename}\" if @whiny\n end\n dst\n end",
"def convertFileToFile(file, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertFileToFile::file_path\", \"image-to-image\", \"The string must not be empty.\", \"convert_file_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertFileToStream(file, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end",
"def convertFile(fpath, outstream=nil)\n return post_multipart(fpath, outstream)\n end",
"def convert_video_to_AVI(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to H264\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.avi\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoavi = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.avi\")\n system(\"ffmpeg -i #{url} -acodec copy -vcodec copy #{videoavi} -y\")\n return videoavi\n end",
"def convert\n generate_uid\n tmp_file = Pathname.new(Dir::tmpdir).join(\"#{@uid}_#{@source.basename}\")\n tmp_image = image_to_tiff\n `#{@command} '#{tmp_image}' '#{tmp_file.to_s}' #{lang} #{psm} #{config_file} #{clear_console_output}`\n @value = File.read(\"#{tmp_file.to_s}.txt\").to_s\n @uid = nil\n remove_file([tmp_image,\"#{tmp_file.to_s}.txt\"])\n rescue\n raise RTesseract::ConversionError\n end",
"def create\n @local_file = LocalFile.new(local_file_params)\n\n respond_to do |format|\n if save_and_set_session @local_file\n format.html { redirect_to :back, notice: 'Please fill out the media file information below' }\n else\n format.html { redirect_to :back, notice: 'There was a problem with the Youtube link' }\n end\n end\n end",
"def transcode_movie\n @command = \"#{@movie.ffmpeg_command} -y #{@raw_options} #{Shellwords.escape(@output_file)}\"\n\n FFMPEG.logger.info(\"Running transcoding...\\n#{@command}\\n\")\n @output = \"\"\n\n Open3.popen3(@command) do |stdin, stdout, stderr, wait_thr|\n begin\n yield(0.0) if block_given?\n next_line = Proc.new do |line|\n fix_encoding(line)\n @output << line\n if line.include?(\"time=\")\n if line =~ /time=(\\d+):(\\d+):(\\d+.\\d+)/ # ffmpeg 0.8 and above style\n time = ($1.to_i * 3600) + ($2.to_i * 60) + $3.to_f\n else # better make sure it wont blow up in case of unexpected output\n time = 0.0\n end\n progress = time / @movie.duration\n yield(progress) if block_given?\n end\n end\n\n if @@timeout\n stderr.each_with_timeout(wait_thr.pid, @@timeout, 'size=', &next_line)\n else\n stderr.each('size=', &next_line)\n end\n\n rescue Timeout::Error => e\n FFMPEG.logger.error \"Process hung...\\n@command\\n#{@command}\\nOutput\\n#{@output}\\n\"\n raise Error, \"Process hung. Full output: #{@output}\"\n end\n end\n end",
"def write_swap_file(filename, decoded_image)\n\n f = File.new \"./public/swap/#{filename}\", \"wb\"\n # f = File.new \"../public/swap/#{filename}\", \"wb\" # inline testing path\n f.write(decoded_image)\n f.close if f\n\nend",
"def write_swap_file(filename, decoded_image)\n\n f = File.new \"./public/swap/#{filename}\", \"wb\"\n # f = File.new \"../public/swap/#{filename}\", \"wb\" # inline testing path\n f.write(decoded_image)\n f.close if f\n\nend",
"def perform(video_id)\n video = Video.get(video_id)\n flv_video = FFMPEG::Movie.new(video.flv)\n options = {\n resolution: flv_video.resolution,\n video_bitrate: flv_video.video_bitrate,\n audio_bitrate: flv_video.audio_bitrate\n }\n mp4_video = flv_video.transcode('uploads/' + video.id.to_s + '.mp4', options)\n video.update(mp4: mp4_video.path)\n end",
"def create\n\n @video_object = params[:video][:video_file] \n @video = Video.new(video_params)\n @video.competition = @competition \n @video.video_original_filename = @video_object.original_filename.to_s\n @video.video_content_type = @video_object.content_type.to_s\n\n respond_to do |format|\n if @video.save\n upload_file(@video.id, @video_object, \"original-videos\")\n send_msg_to_queue(@video.id.to_s)\n format.html { redirect_to @video.competition, success: 'Hemos recibido tu video y lo estamos procesando para que sea publicado. Tan pronto el video quede publicado en la página del concurso te notificaremos por email. Gracias.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def run\n\n @options = @video.convert_options\n @output_file = \"#{generate_path @video.name}/#{@video.name}#{@options[:postfix]}.#{@options[:extension]}\"\n\n command = \"#{CONFIG[:ffmpeg_binary]} -y -i '#{@video.path}' #{@options} '#{@output_file}'\"\n output = \"\"\n convert_error = true\n\n # before convert callbacks\n Hook.exec :before_convert, @video, command\n\n # process video\n Open3.popen3(command) do |stdin, stdout, stderr|\n stderr.each \"r\" do |line|\n VTools.fix_encoding line\n output << line\n\n # we know, that all is not so bad, if \"time=\" at least once met\n if line.include? \"time=\"\n\n convert_error = false # that is why, we say \"generally it's OK\"\n\n if line =~ /time=(\\d+):(\\d+):(\\d+.\\d+)/ # ffmpeg 0.8 and above style\n time = ($1.to_i * 3600) + ($2.to_i * 60) + $3.to_f\n elsif line =~ /time=(\\d+.\\d+)/ # ffmpeg 0.7 and below style\n time = $1.to_f\n else # in case of unexpected output\n time = 0.0\n end\n progress = time / @video.duration\n Hook.exec :in_convert, @video, progress # callbacks\n end\n end\n end\n\n raise ProcessError, output.split(\"\\n\").last if convert_error # exit on error\n\n # callbacks\n unless error = encoding_invalid?\n Hook.exec :convert_success, @video, @output_file\n else\n Hook.exec :convert_error, @video, error, output\n raise ProcessError, error # raise exception in error\n end\n\n encoded\n end",
"def convertFile(file)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFile\", \"pdf-to-html\", \"The file must exist and not be empty.\", \"convert_file\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data)\n end",
"def modify(options)\n Rails.logger.debug \" Modifying #{options.inspect}\"\n \n if options[:size]\n tempfile = Tempfile.new(['watchmemake','.jpg'])\n ImageScience.with_image(@file.path) { |i| i.thumbnail(options[:size]) { |t| t.save tempfile.path }}\n else\n tempfile = @file\n end\n \n return tempfile\n end",
"def run\n outputs = nil\n \n in_tmp_dir do\n image = tmp_path 'text_to_image.jpg'\n Image::Editing::Cmd::TextToImage.new(text, image, @options).run!\n\n outputs = ImageToVideo.new(image, @output_without_extension, duration, @log_folder).run\n end\n\n outputs\n end",
"def convert_video(params = {}, options = {}, converter = Conversion::VideoConverter)\n convert_file(params, converter, options)\n end",
"def process_image(tmp)\n random = 2 + rand(10**24-10)+10\n path =\"public/data/\"\n file = File.join(path, random.to_s + \"-\" + params[:image][:filename].original_filename)\n\t\n\t#check extencion\n\t\text = File.extname(file)\n \tif ext.upcase == \".JPG\"\n \t\textfinal = \".jpg\"\n \t\timagevalid = true\n \telsif ext.upcase == \".JPEG\"\n \t\textfinal = \".jpg\"\n \t\timagevalid = true\n \telsif ext.upcase == \".GIF\"\n \t\textfinal = \".gif\"\n \t\timagevalid = true\n \telsif ext.upcase == \".PNG\"\n \t\textfinal = \".png\"\n \t\timagevalid = true\n \tend\t\n \t\n if imagevalid == true \n\t\n #Subo la imagen original recibida\n FileUtils.cp tmp.path, file\n\t\n\tarchivo_final = uploadoriginal(file,path)\n\t\n\t#utilizo su nombre\n\tfilenamethumb = random.to_s + \"-\" + params[:image][:filename].original_filename\n\t#width desired / ancho deseado\n\tw = 150\n\t#function call / llamada a la funcion\n\thubermann_thumbnail(path, filenamethumb,w,square=true, bw=true, q=99)\n\thubermann_thumbnail(path, filenamethumb,w,square=true, bw=false, q=99)\n\t\n\t\n\tFileUtils.rm file\n\t\n\t\n\t@image.filename = archivo_final\n\t#end unless valid image\n\telse\n\t@image.filename = nil\n\n\tend\nend",
"def process(path, transformations, user_id)\n file = upload_file(path, (id = SecureRandom.uuid))\n file.save\n end",
"def av_convert(options)\n if @external_url\n return 'av_convert does not support external URLs. Please upload file first.'\n end\n @transform_tasks.push(\n add_transform_task('video_convert', options)\n )\n response = UploadUtils.make_call(url, 'post')\n if response.code == 200\n return AV.new(url, apikey: @apikey, security: @security)\n end\n JSON.parse(response.body)\n end",
"def write_swap_file(filename, decoded_image)\n\n f = File.new \"./public/swap/#{filename}\", \"wb\"\n f.write(decoded_image)\n f.close if f\n\n end",
"def convertFile(file)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFile\", \"html-to-pdf\", \"The file must exist and not be empty.\", \"convert_file\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data)\n end",
"def transform_path(file)\n render(file.sub(template_path, target_path))\n end",
"def convert_video_to_H264(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to H264\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.h264\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoh264 = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.h264\")\n system(\"ffmpeg -i #{url} -an -vcodec libx264 -crf 23 #{videoh264} -y\")\n return videoh264\n end",
"def transcode_movie\n @command = \"#{FFMPEG.ffmpeg_binary} -y -i #{Shellwords.escape(@movie.path)} #{@raw_options} #{Shellwords.escape(@output_file)}\"\n FFMPEG.logger.info(\"Running transcoding...\\n#{@command}\\n\")\n @output = ''\n\n Open3.popen3(@command) do |_stdin, _stdout, stderr, wait_thr|\n begin\n yield(0.0) if block_given?\n\n next_line = proc do |line|\n fix_encoding(line)\n @output << line\n\n # frame= 1253 fps=249 q=0.0 size=N/A time=00:00:23.90 bitrate=N/A speed=4.75x\n if line.include?('time=')\n time = 0.0\n if line =~ /time=(?<hours>\\d+):(?<minutes>\\d+):(?<seconds>\\d+\\.\\d+)/ # ffmpeg 0.8 and above style\n time = (Regexp.last_match(:hours).to_i * 3600) + (Regexp.last_match(:minutes).to_i * 60) + Regexp.last_match(:seconds).to_f\n end\n progress = time / @movie.duration\n\n yield(progress) if block_given?\n end\n end\n\n if self.class.timeout\n stderr.each_with_timeout(wait_thr.pid, self.class.timeout, 'size=', &next_line)\n else\n stderr.each('size=', &next_line)\n end\n rescue Timeout::Error => e\n FFMPEG.logger.error \"Process hung... #{e.message}\\n@command\\n#{@command}\\nOutput\\n#{@output}\\n\"\n raise Error, \"Process hung. Full output: #{@output}\"\n end\n end\n end",
"def create\n @video = Video.new(event_id: params[:event_id], has_youtube: params[:has_youtube], video: params[:video], youtube: params[:youtube], default: params[:default])\n\n if params[:has_youtube] == 'false'\n image = StringIO.new(Base64.decode64(params[:poster]))\n image.class.class_eval { attr_accessor :original_filename, :content_type }\n image.original_filename = 'tester.jpg'\n image.content_type = 'image/jpeg'\n @video.poster = image\n end\n\n respond_to do |format|\n if @video.save\n unless @video.has_youtube\n transcode_flv(opentok_flv_url(@video.video), @video.video)\n end\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render json: @video, status: :created, location: @video }\n else\n format.html { render action: \"new\" }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def convertFileToStream(file, out_stream)\n if (!(File.file?(file) && !File.zero?(file)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file, \"convertFileToStream::file\", \"image-to-pdf\", \"The file must exist and not be empty.\", \"convert_file_to_stream\"), 470);\n end\n \n @files['file'] = file\n @helper.post(@fields, @files, @raw_data, out_stream)\n end",
"def ffmpeg\n @log.info \"Running ffmpeg to convert to MP4\"\n ffmpegOutOptions = \"-strict experimental -vcodec copy -acodec aac\"\n if @remux\n ffmpegOutOptions = \"-vcodec copy -acodec copy\"\n end \n ffmpeg_command =\"ffmpeg -y -i \\\"#{@out_file}.flv\\\" #{ffmpegOutOptions} \\\"#{@out_file}.mp4\\\"\"\n success = system(ffmpeg_command)\n\n if not success\n raise \"Something went wrong running ffmpeg :(. Your file may not have converted properly.\"\n end\n\n @log.info \"File converted\"\n end",
"def convert\n success = system(convert_command + \" > conversion.log\")\n if success && $?.exitstatus == 0\n local_path_util = LocalMediaPathUtil.new \n file_dir = local_path_util.local_media_complete_dir(id)\n t_local_path = file_dir + \"/\" + filename + \".flv\"\n update_attribute(:converted_media_local_path,t_local_path)\n end\n end",
"def create_image_temp(base_filename='resize')\n # raise \"do i need this\"\n t_temp = Tempfile.new([base_filename, '.jpg'])\n img = yield; img.write(t_temp.path) if block_given?\n return img, t_temp\n end",
"def process\n result = Tempfile.new([\"\", self.extension])\n result.binmode\n begin\n parameters = []\n parameters << \"--preset #{self.preset}\" if self.preset\n parameters << self.path\n parameters << result.path\n parameters = parameters.join(\" \").squeeze(\" \")\n `lame #{parameters} #{redirect}`\n raise Errno::ENOENT if $?.exitstatus == 127\n rescue Errno::ENOENT\n raise \"command 'lame' not found: ensure LAME is installed\"\n end\n unless $?.exitstatus == 0\n raise Attached::Processor::Error, \"must be an audio file\"\n end\n return result\n end",
"def upload_file\n upload_thumb if Rails.configuration.thumbnails_enabled\n file_s3_obj.write(@file.tempfile.open, content_type: @file.content_type)\n end"
] | [
"0.66065586",
"0.66065586",
"0.65499616",
"0.64945865",
"0.6106258",
"0.6044804",
"0.5969813",
"0.5949358",
"0.5918212",
"0.589946",
"0.57592237",
"0.57361066",
"0.5728526",
"0.5641925",
"0.56212693",
"0.5603243",
"0.55834115",
"0.5563469",
"0.5561464",
"0.5549072",
"0.5541774",
"0.55380446",
"0.5535867",
"0.55054265",
"0.54848284",
"0.53896016",
"0.5381075",
"0.5373641",
"0.5361473",
"0.535077",
"0.5338257",
"0.53273916",
"0.5325606",
"0.53137046",
"0.5306912",
"0.5300416",
"0.52992845",
"0.52939475",
"0.5292515",
"0.5269452",
"0.52689874",
"0.5268319",
"0.5264752",
"0.52518123",
"0.5232706",
"0.52051806",
"0.51920605",
"0.51918954",
"0.5164829",
"0.5155281",
"0.513952",
"0.512022",
"0.511399",
"0.5111678",
"0.51105314",
"0.5107493",
"0.5089344",
"0.5088873",
"0.5083297",
"0.5083115",
"0.5071326",
"0.5068254",
"0.5065701",
"0.506526",
"0.5058023",
"0.5041057",
"0.5039189",
"0.50375926",
"0.50213945",
"0.50210977",
"0.50203717",
"0.5006478",
"0.50039524",
"0.5003905",
"0.50016",
"0.4995436",
"0.49875236",
"0.49875236",
"0.49799576",
"0.49794772",
"0.4973978",
"0.49710307",
"0.4964811",
"0.4957056",
"0.49557364",
"0.4954502",
"0.49499744",
"0.49462968",
"0.49444452",
"0.49374786",
"0.4936855",
"0.49337372",
"0.49233684",
"0.492134",
"0.49119592",
"0.49097797",
"0.48998916",
"0.48917222",
"0.48915273",
"0.48877126"
] | 0.5985842 | 6 |
Defaults to target type and id. | def display_name
"#{Target.type_of(self).titleize} #{id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_type=(value)\n @target_type = value\n end",
"def target\n get_or_make_reference(@data['target_type'], @data, 'target_id')\n end",
"def target_id=(value)\n @target_id = value\n end",
"def set_target\n @target = Target.find(params[:id]||params[:target_id])\n end",
"def target=( object )\n\t\tcase object\n\t\twhen Mongrel2::Config::Directory\n\t\t\tself.target_type = 'dir'\n\t\twhen Mongrel2::Config::Proxy\n\t\t\tself.target_type = 'proxy'\n\t\twhen Mongrel2::Config::Handler\n\t\t\tself.target_type = 'handler'\n\t\telse\n\t\t\traise ArgumentError, \"unknown target type %p\" % [ object.class ]\n\t\tend\n\n\t\tself.target_id = object.id\n\tend",
"def target_type\n location_id ? :location : name_id ? :name : observation_id ? :observation : project_id ? :project : species_list_id ? :species_list :\n glossary_term_id ? :glossary_term : article_id ? :article : nil\n end",
"def target\n type = target_type\n type ? @references[\"#{target_type}#{target_id}\"] : nil\n end",
"def set_target(id)\n @target = Target.find(id)\n end",
"def target_type\n return @target_type\n end",
"def default_target_key\n nil\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def before_create\n self.target_id = target.id if target\n end",
"def target_id\n RssLog.all_types.each do |type|\n obj_id = send(\"#{type}_id\".to_sym)\n return obj_id if obj_id\n end\n nil\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def set_TargetID(value)\n set_input(\"TargetID\", value)\n end",
"def clear_target_id\n RssLog.all_types.each do |type|\n send(\"#{type}_id=\", nil)\n end\n end",
"def target=(value)\n @target = value\n end",
"def set_target_alum\n @@target_alum_id = params[:id]\n end",
"def target_def; target.name; end",
"def target_types=(value)\n @target_types = value\n end",
"def target=(target)\n @target = target\n end",
"def target\n target_hash_or_obj = self[:datacenter]\n if target_hash_or_obj.is_a?(Target)\n target_hash_or_obj\n else\n target_hash = target_hash_or_obj\n target_idh = base_node.model_handle(:target_instance).createIDH(id: target_hash[:id])\n target_idh.create_object(target_hash)\n end\n end",
"def target_id\n return @target_id\n end",
"def target_type(_target_type)\n return if _target_type.nil?\n return unless _target_type.instance_of?(String) || _target_type.instance_of?(Symbol)\n _target_type = _target_type.to_sym if _target_type.instance_of? String\n return unless TARGET_TYPES.include? _target_type\n @_target_type = _target_type\n end",
"def target_type(target_type)\n return if target_type.nil?\n return unless [String, Symbol].include?(target_type.class)\n target_type = target_type.to_sym if target_type.instance_of? String\n return unless TARGET_TYPES.include? target_type\n @_target_type = target_type\n end",
"def update!(**args)\n @target_id = args[:target_id] if args.key?(:target_id)\n @target_type = args[:target_type] if args.key?(:target_type)\n end",
"def target_id\n location_id ||\n name_id ||\n observation_id ||\n project_id ||\n species_list_id ||\n glossary_term_id ||\n article_id\n end",
"def target(*args)\n if args.blank?\n const_defined?(:Target) ? const_get(:Target) : (@target || name[0..-5].classify.constantize)\n else\n self.target = args.first\n end\n end",
"def target_type\n scan_ses_notes if @target_type.nil?\n @target_type\n end",
"def target\n\t\tcase self.target_type\n\t\twhen 'dir'\n\t\t\treturn Mongrel2::Config::Directory[ self.target_id ]\n\t\twhen 'proxy'\n\t\t\treturn Mongrel2::Config::Proxy[ self.target_id ]\n\t\twhen 'handler'\n\t\t\treturn Mongrel2::Config::Handler[ self.target_id ]\n\t\telse\n\t\t\traise ArgumentError, \"unknown target type %p\" % [ self.target_type ]\n\t\tend\n\tend",
"def set_user_target\n @user_target = UserTarget.find(params[:id])\n end",
"def target=(target)\n @target = target.type == :four ? target.ledger_table : target\n end",
"def initialize options\r\n super\r\n @target = options[:target]\r\n end",
"def target_type\n RssLog.all_types.each do |type|\n return type.to_sym if send(\"#{type}_id\".to_sym)\n end\n nil\n end",
"def target=(new_value)\n @target = new_value unless const_defined?(:Target)\n end",
"def target\n nil\n end",
"def target!\n @target\n end",
"def set_image_target\n @image_target = Admin::ImageTarget.find(params[:id])\n end",
"def target=(target)\n @target = target\n @ori_target = target\n end",
"def target_name(target_name = nil)\n @target_name = target_name unless target_name.nil?\n \n return 'default' if @target_name.nil?\n @target_name\n end",
"def set_defaults\n super\n self.asset_type_id ||= AssetType.where(class_name: self.name).pluck(:id).first\n end",
"def set_defaults\n super\n self.asset_type_id ||= AssetType.where(class_name: self.name).pluck(:id).first\n end",
"def target; end",
"def target; end",
"def target_model(*args)\n if args.blank?\n const_defined?(:TargetModel) ? const_get(:TargetModel) : (@target_model || target.name[0..-11].classify.constantize)\n else\n self.target_model = args.first\n end\n end",
"def target=(_arg0); end",
"def target=(_arg0); end",
"def set_target\n access_key = '16e5c472cbad4e592e977029af54b1500b551362'\n secret_key = '932998f43862357f0da1a3e9b0340f5b38c55eb1'\n connection = Vws::Api.new(access_key, secret_key)\n width = 32\n active_flag = true\n application_metadata = nil\n puts @target.image.inspect\n puts vuforia_return = \"ok\"\n # vuforia_return = connection.add_target(target_name, \"http://api.playarshop.com\" + @target.image.url, width, active_flag, application_metadata)\n vuforia_return = connection.add_target(target_name, \"./public/logo.png\", width, active_flag, application_metadata)\n puts vuforia_return.inspect\n @target = Target.find(params[:id])\n end",
"def target\n @target\n end",
"def load_target\r\n @target = params[:target]\r\n end",
"def load_target\r\n @target = params[:target]\r\n end",
"def id\n config[:id] || Origen.target.name\n end",
"def id\n config[:id] || Origen.target.name\n end",
"def target_name(*args)\n if args.blank?\n (const_defined?(:TargetName) ? const_get(:TargetName) : (@target_name || target_model.name.underscore.titleize)).to_s\n else\n self.target_name = args.first\n end\n end",
"def comment_target\n get_or_make_reference(@data['comment_target_type'], @data, 'comment_target_id')\n end",
"def target=(target)\n self.each{|e| e.target=target}\n end",
"def target_class\n options[:class] || target_class_name.constantize\n end",
"def select_target\n @target or raise Vanagon::Error, '#select_target has not been implemented for your engine.'\n end",
"def target\n @target\n end",
"def target\n @target ||= Details.new(request(build_request))\n end",
"def target\n @target ||= Details.new(request(build_request))\n end",
"def target\n if self.respond_to?(:auto_targeted_index)\n if auto_target?\n auto_idx = auto_targeted_index\n if auto_idx.present?\n datastore['TARGET'] = auto_idx\n else\n # If our inserted Automatic Target was selected but we failed to\n # find a suitable target, we just grab the original first target.\n datastore['TARGET'] = 1\n end\n end\n end\n\n target_idx = target_index\n return (target_idx) ? targets[target_idx.to_i] : nil\n end",
"def target\n \"\"\n end",
"def target\n \"\"\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def target\n @target ||= Target.find(options[:target]).new(options[:directory])\n end",
"def target_model=(new_value)\n @target_model = new_value unless const_defined?(:TargetModel)\n end",
"def target_types\n return @target_types\n end",
"def initialize_target\n end",
"def for_target(target)\n @target_name = target[:target_name].to_s\n return self\n end",
"def set_product_target\n @product_target = ProductTarget.find(params[:id])\n end",
"def initialize(target)\n @target = target\n @name = target.display_name\n @is_test_target = target.test_target_type?\n end",
"def initialize( target )\n\t\t@target = target\n\tend",
"def set_TargetUserID(value)\n set_input(\"TargetUserID\", value)\n end",
"def target\n base.image_for(\"#{name}_target\")\n end",
"def target_name(id)\n case id\n when -2; Vocab::LastTarget\n when -1; Vocab::RandomTarget;\n else; sprintf(Vocab::Target, id+1); end\n end",
"def target_index\n target_idx =\n begin\n Integer(datastore['TARGET'])\n rescue TypeError, ArgumentError\n datastore['TARGET']\n end\n\n default_idx = default_target || 0\n # Use the default target if one was not supplied.\n if (target_idx == nil and default_idx and default_idx >= 0)\n target_idx = default_idx\n elsif target_idx.is_a?(String)\n target_idx = targets.index { |target| target.name == target_idx }\n end\n\n return (target_idx) ? target_idx.to_i : nil\n end",
"def target=(target)\n @target = target\n loaded!\n end",
"def target=(target)\n @target = target\n loaded!\n end",
"def set_target_class_defaults\n self._notification_email = nil\n self._notification_email_allowed = ActivityNotification.config.email_enabled\n self._batch_notification_email_allowed = ActivityNotification.config.email_enabled\n self._notification_subscription_allowed = ActivityNotification.config.subscription_enabled\n self._notification_action_cable_allowed = ActivityNotification.config.action_cable_enabled || ActivityNotification.config.action_cable_api_enabled\n self._notification_action_cable_with_devise = ActivityNotification.config.action_cable_with_devise\n self._notification_devise_resource = ->(model) { model }\n self._notification_current_devise_target = ->(current_resource) { current_resource }\n self._printable_notification_target_name = :printable_name\n nil\n end"
] | [
"0.7058479",
"0.7026978",
"0.701764",
"0.69035727",
"0.6849382",
"0.67725694",
"0.67681766",
"0.6684628",
"0.667665",
"0.66498345",
"0.66367394",
"0.66367394",
"0.66229665",
"0.6605385",
"0.6546946",
"0.6546946",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6462322",
"0.6417071",
"0.637315",
"0.63605815",
"0.6353498",
"0.63346577",
"0.63035494",
"0.6281099",
"0.6279466",
"0.62668455",
"0.62459075",
"0.62424546",
"0.62227166",
"0.6200699",
"0.6181853",
"0.61564887",
"0.6099838",
"0.6099766",
"0.6098199",
"0.60958076",
"0.609081",
"0.60789144",
"0.6063326",
"0.60598993",
"0.60439175",
"0.5972512",
"0.5970539",
"0.5970539",
"0.5954379",
"0.5954379",
"0.5939357",
"0.5921458",
"0.5921458",
"0.5877684",
"0.5865712",
"0.58098274",
"0.58098274",
"0.58089364",
"0.58089364",
"0.5805301",
"0.5800614",
"0.57895565",
"0.57893056",
"0.57720274",
"0.57607377",
"0.5759351",
"0.5759351",
"0.57538813",
"0.5750547",
"0.5739653",
"0.57384473",
"0.57384473",
"0.57384473",
"0.57384473",
"0.57384473",
"0.57384473",
"0.57384473",
"0.57384473",
"0.57384473",
"0.5735896",
"0.5721252",
"0.56924397",
"0.5685192",
"0.56776565",
"0.567441",
"0.5659642",
"0.56568724",
"0.5649237",
"0.5649158",
"0.5632169",
"0.56265223",
"0.5619783",
"0.5619783",
"0.5615796"
] | 0.5810347 | 61 |
Returns the inspection of the type without fetched data. | def inspect_not_fetched
"#<#{self.class} id=\"#{id}\" is_fetched?=false>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type; nil end",
"def type; nil end",
"def type\n nil\n end",
"def type\n nil\n end",
"def notable_type_data\n notable_type\n end",
"def type\n return @type if @type != \"unknown\"\n info\n @type\n end",
"def type\n ''\n end",
"def type\n _type rescue nil\n end",
"def type\n self['!']\n end",
"def type\n @data[:type].empty? ? false : @data[:type]\n end",
"def unknown?\n @type == 'TYPE_UNSPECIFIED'\n end",
"def type\n @type\n end",
"def type\n Sequel::SQL::StringExpression.new(:NOOP, function(:type, self))\n end",
"def nonregular_type; end",
"def type\n @type ||= calculate_type\n end",
"def type\n @attributes.fetch('type', nil)\n end",
"def custom?\n self.type.blank?\n end",
"def type\n _type\n end",
"def get_type; raise NotImplementedError end",
"def get_type\n\n end",
"def type\n @type\n end",
"def _type\n special_attribute('@type'.freeze)\n end",
"def type\n return nil if checktype.nil?\n checktype.name \n end",
"def type\n return @type\n end",
"def type; self._type; end",
"def not_persisted\n self.content_types.values.find_all { |content_type| !content_type.persisted? }\n end",
"def type\n @@type\n end",
"def type\n @@type\n end",
"def get_by_type(type)\r\n facts2typerule = {:methodcall => [:cant_access, :can_access],\r\n :inheritance => [:cant_extend, :can_extend],\r\n :objcreation => [:cant_create, :can_create]}\r\n\r\n find_all { |x| facts2typerule[type].index(x.type_interaction) != nil }\r\n end",
"def display_type\n @params.fetch('type', nil)\n end",
"def type\n raise UnimplementedError\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def display_type\n @params.fetch('type', nil)\nend",
"def type\n\t\t@type\n\tend",
"def type\n # :nocov:\n raise NotImplementedError\n # :nocov:\n end",
"def get_type()\n res = super(context,self)\n return res\n end",
"def dummy?\n @type.nil?\n end",
"def get_filter_context( inspection_type )\n qry = inspection_type.qc_filter_context_search || ''\n if qry.strip == ''\n errors.add_to_base \"QC Inspection Type '#{inspection_type.qc_inspection_type_code}' does not have a filter context search.\"\n return nil\n end\n\n qry.gsub!('{business_object_id}', self.business_object_id.to_s)\n records = QcInspection.find_by_sql( qry )\n if records.nil? || records.empty?\n errors.add_to_base \"filter context search returned no values for business object id #{self.business_object_id}.\" \n nil\n else\n records.first\n end\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def not\n require_relative './not'\n \n NRSER::Types.not self\n end",
"def type\n memoized_info[:type]\n end",
"def type\n @types ||= strip(:type)\n end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end"
] | [
"0.63976306",
"0.63976306",
"0.62295747",
"0.62245804",
"0.6186242",
"0.59081644",
"0.58745974",
"0.584129",
"0.5786812",
"0.5681511",
"0.56400836",
"0.5622492",
"0.56177527",
"0.56148255",
"0.5599104",
"0.5594335",
"0.5585912",
"0.55679476",
"0.5564008",
"0.55547225",
"0.5553778",
"0.5549843",
"0.553625",
"0.5522396",
"0.5510216",
"0.5500376",
"0.5493519",
"0.5493519",
"0.54772174",
"0.5473766",
"0.54486746",
"0.5445964",
"0.5445219",
"0.5445219",
"0.5445219",
"0.54374653",
"0.54226536",
"0.540306",
"0.5380528",
"0.535374",
"0.53324467",
"0.5319003",
"0.5319003",
"0.5319003",
"0.5319003",
"0.5319003",
"0.5319003",
"0.5319003",
"0.5305057",
"0.529756",
"0.5288464",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724",
"0.52587724"
] | 0.5921615 | 5 |
Returns the inspection of the type with fetched data. | def inspect_fetched
"#<#{self.class} id=\"#{id}\" is_fetched?=true>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n return @type if @type != \"unknown\"\n info\n @type\n end",
"def get_type\n\n end",
"def type\n @data['type']\n end",
"def get_by_type(type)\r\n facts2typerule = {:methodcall => [:cant_access, :can_access],\r\n :inheritance => [:cant_extend, :can_extend],\r\n :objcreation => [:cant_create, :can_create]}\r\n\r\n find_all { |x| facts2typerule[type].index(x.type_interaction) != nil }\r\n end",
"def type\n @data['type']\n end",
"def type\n fetch('restaurant.type')\n end",
"def type\n result_hash['typ']\n end",
"def type\n @type\n end",
"def type\n\t\t\t@data[\"type\"]\n\t\tend",
"def details_by_type_and_name(type, name)\n entity_id = get_id_by_type_and_name(type, name)\n if entity_id.nil?\n raise \"Id for entity with type '#{type}' and name '#{name}' can't be found\"\n else\n details_by_type_and_id(type, entity_id)\n end\n end",
"def type\n self['type']\n end",
"def type\n @type\n end",
"def type\n entity_type.name\n end",
"def notable_type_data\n notable_type\n end",
"def returned_type\n model.returned_type\n end",
"def type\n data.type\n end",
"def type\n return @type\n end",
"def show_details\n @type = params[:type]\n @elem= eval(@type).find(params[:elem])\n end",
"def type\n self['type']['type']\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n fetch('company.type')\n end",
"def type\n self[:type]\n end",
"def type\n _type\n end",
"def type\n self[:type]\n end",
"def type ; metadata[:type] ; end",
"def type\n @@type\n end",
"def type\n @@type\n end",
"def type\n @type ||= @data[:edupersonaffiliation].last\n end",
"def fetch_type name\n exercises = []\n data.exercises.each do |exe|\n if exe.target === name\n exercises.push(exe.name)\n end\n end\n exercises\n end",
"def get_type()\n res = super(context,self)\n return res\n end",
"def result_type\n properties['type']\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def get_data_type(args)\n type = get_data_type_from_body(args[:body])\n type ||= get_data_type_from_response(args[:response])\n end",
"def type\n raw_data['type']\n end",
"def type\n self.attributes[:type]\n end",
"def type\n memoized_info[:type]\n end",
"def type\n response[\"type\"]\n end",
"def type\n response[\"type\"]\n end",
"def type; self._type; end",
"def type\n\t\t@type\n\tend",
"def type\n field[:type]\n end",
"def fetch\n if raw\n field_config.accessor ? retieve_using_accessor : retrieve_simple\n else\n super\n end\n end",
"def get_user_type\n uri = URI.parse(\"#{BASE_URL}/users/info\")\n response = JSON.parse(@client.get(uri).body)\n return response['type'] if response['success']\n\n throw_error(response)\n end",
"def type\n @type.name\n end",
"def get_filter_context( inspection_type )\n qry = inspection_type.qc_filter_context_search || ''\n if qry.strip == ''\n errors.add_to_base \"QC Inspection Type '#{inspection_type.qc_inspection_type_code}' does not have a filter context search.\"\n return nil\n end\n\n qry.gsub!('{business_object_id}', self.business_object_id.to_s)\n records = QcInspection.find_by_sql( qry )\n if records.nil? || records.empty?\n errors.add_to_base \"filter context search returned no values for business object id #{self.business_object_id}.\" \n nil\n else\n records.first\n end\n end",
"def by_type(type)\n (types['url'].find { |url| url['@type'] == type }).tap do |url|\n raise(StandardError, 'URL details are missing.') if url.nil?\n end['$']\n end",
"def type\n @type ||= calculate_type\n end",
"def type\n return nil if checktype.nil?\n checktype.name \n end",
"def get_component(result, type, data = 'long_name')\n result.fetch('address_components', [])\n .find { |component| component['types'].include?(type) }\n &.dig(data)\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def security_type\n SecurityType.find_by_type self[:type]\n end",
"def get_type(addr_results, type)\n addr_results.select { |comp| comp[\"types\"].index(type) != nil }.map { |comp| comp[\"long_name\"] }.first\n end",
"def type\n @attributes[:type]\n end",
"def type\n return @artist_data[\"type\"]\n end",
"def type\n _type rescue nil\n end",
"def get_entities(type)\n @entities[type.name]\n end",
"def type\n read_attribute(:type) || Figaro.env.meal_types.split.first\n end",
"def type2\n return @type2 || data.type2\n end",
"def identification_type_information(country)\n add_timestamp\n add_salt\n headers = { 'content-type' => 'application/json', 'signature' => signature('', 'get', \"/v1/identities/types?country=#{country}\"),\n 'salt' => salt, 'timestamp' => timestamp, 'access_key' => access_key }\n response, msg = rest_client.getCall(\"/v1/identities/types?country=#{country}\", headers)\n if response.present? && response.body.present? && JSON.parse(response.body)['status']['status'] == 'SUCCESS'\n JSON.parse(response.body)\n end\n rescue StandardError => e\n Rails.logger.error e\n nil\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def entity_type\n return @entity_type\n end",
"def find_by_type(type)\n find{|contact_detail|\n contact_detail[:type] == type\n }.try{|contact_detail|\n contact_detail[:value]\n }\n end",
"def type\n data['type'].to_sym\n end",
"def exp_type\n return data.exp_type\n end",
"def fetch_value(value, reflection)\n if reflection.macro == :has_one\n reflection.klass.find(value)\n else\n value\n end\n end",
"def type\n return :unknown unless properties['result_type']\n\n properties['result_type'].to_sym\n end",
"def get_type; raise NotImplementedError end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type_name\n self['type_name']\n end",
"def getassociated(type)\n self.forward_items_dataset.filter(\"content LIKE '%type\\\":\\\"#{type}%'\")\n end",
"def type\n @attributes.fetch('type', nil)\n end",
"def get_data_type\n get_field_config['type']\n end",
"def type_info(type, elem)\n scimfo = {\n user: {\n path: '/Users',\n name_attr: 'userName',\n origin_attr: 'origin'\n },\n group: {\n path: '/Groups',\n name_attr: 'displayName',\n origin_attr: 'zoneid'\n },\n client: {\n path: '/oauth/clients',\n name_attr: 'client_id'\n },\n user_id: {\n path: '/ids/Users',\n name_attr: 'userName',\n origin_attr: 'origin',\n },\n group_mapping: {\n path: '/Groups/External',\n name_attr: 'externalGroup',\n origin_attr: 'origin'\n }\n }\n\n type_info = scimfo[type]\n\n unless type_info\n raise ArgumentError, \"scim resource type must be one of #{scimfo.keys.inspect}\"\n end\n\n value = type_info[elem]\n\n unless value\n raise ArgumentError, \"scim schema element must be one of #{type_info.keys.inspect}\"\n end\n\n value\n end",
"def details_by_type_and_id(type, id)\n get(resource_path_for_entity_type(type) + \"/#{id}\")\n end",
"def expected_type\n @data[\"expected_type\"]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type_helper \n self.type \n end",
"def type(column); self[column]['type']; end",
"def extract_definition_from_type\n # If we have a specific occurrence of a variable, pull attributes from the reference.\n # IDEA set this up to be called from dc_specific_and_source_extract, the number of\n # fields changed by handle_specific_variable_ref may pose an issue.\n extract_information_for_specific_variable if @variable && @specific_occurrence\n\n if @entry.at_xpath('./cda:grouperCriteria')\n @definition ||= 'derived'\n return\n end\n # See if we can find a match for the entry definition value and status.\n entry_type = attr_val('./*/cda:definition/*/cda:id/@extension')\n handle_entry_type(entry_type)\n end",
"def type() end",
"def type\n read_attr :type, :to_sym\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end"
] | [
"0.58993053",
"0.57753056",
"0.57223517",
"0.5717632",
"0.5712089",
"0.56816196",
"0.5655481",
"0.56455487",
"0.5642565",
"0.5641809",
"0.56303185",
"0.56269944",
"0.5620288",
"0.5573142",
"0.555371",
"0.555273",
"0.554894",
"0.5547935",
"0.5541684",
"0.55293965",
"0.55293065",
"0.55293065",
"0.55293065",
"0.5512341",
"0.55039275",
"0.5503497",
"0.550295",
"0.5502038",
"0.5500217",
"0.5500217",
"0.54972774",
"0.5492943",
"0.5475194",
"0.5466665",
"0.5460074",
"0.5460074",
"0.5460074",
"0.5460074",
"0.5460074",
"0.5460074",
"0.5460074",
"0.5452107",
"0.5436678",
"0.54309875",
"0.5423513",
"0.54181",
"0.54181",
"0.54175675",
"0.5388294",
"0.5376006",
"0.5350702",
"0.5341536",
"0.5341311",
"0.53355306",
"0.53287864",
"0.53188914",
"0.5315942",
"0.5303902",
"0.5302453",
"0.5302453",
"0.5302453",
"0.5302453",
"0.5293621",
"0.5291373",
"0.5283813",
"0.5281931",
"0.5278591",
"0.5273921",
"0.5253277",
"0.52461714",
"0.52422667",
"0.52418244",
"0.52394134",
"0.5237804",
"0.5237148",
"0.52328664",
"0.52209026",
"0.5216451",
"0.5213065",
"0.52119035",
"0.52119035",
"0.52119035",
"0.5211592",
"0.5206634",
"0.5199518",
"0.5189949",
"0.51840246",
"0.5182889",
"0.5182849",
"0.51805633",
"0.51805633",
"0.51805633",
"0.5174149",
"0.5150442",
"0.5142935",
"0.5139424",
"0.5129195",
"0.51271725",
"0.51271725",
"0.51271725"
] | 0.5417332 | 48 |
Parse a single line of CSV data Parameters line [String] A single line of CSV data without any line terminators | def parse(line)
@io.rewind
@io.truncate(0)
@io << line
@io.rewind
@csv.shift
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_parse(validated_line)\n return unless validated_line\n row = validated_line.split(',')\n return unless row.any?\n if @headers.empty?\n @headers = row\n else\n @data_hash.merge!(row_to_hsh(row))\n @valid_rows << @data_hash\n end\n end",
"def parse_line_data(line)\n line.strip.gsub('\"', '').split ' = '\n end",
"def parse_csv_line(text_line)\n\tcolumns = text_line.split(\",\")\n\tvalues = []\n\tcolumns.each { |x| values << x.strip}\n\treturn values\nend",
"def parse_csv_line_ruby(line, options, header_size = nil)\n return [] if line.nil?\n\n line_size = line.size\n col_sep = options[:col_sep]\n col_sep_size = col_sep.size\n quote = options[:quote_char]\n quote_count = 0\n elements = []\n start = 0\n i = 0\n\n previous_char = ''\n while i < line_size\n if line[i...i+col_sep_size] == col_sep && quote_count.even?\n break if !header_size.nil? && elements.size >= header_size\n\n elements << cleanup_quotes(line[start...i], quote)\n previous_char = line[i]\n i += col_sep.size\n start = i\n else\n quote_count += 1 if line[i] == quote && previous_char != '\\\\'\n previous_char = line[i]\n i += 1\n end\n end\n elements << cleanup_quotes(line[start..-1], quote) if header_size.nil? || elements.size < header_size\n [elements, elements.size]\n end",
"def get_params_from(line)\n\tvalues = line.split(\",\")\n #let's remove whitespaces\n\tvalues.map { | value | value.strip } # Tip: you can also write it like this `values.map(&:strip)`\nend",
"def get_params_from(line)\n\tvalues = line.split(\",\")\n\tvalues.map { | value | value.strip } #strip removes the whitespaces. could be written like `values.map(&:split)`\nend",
"def parse(line, options, header_size = nil)\n # puts \"SmarterCSV.parse OPTIONS: #{options[:acceleration]}\" if options[:verbose]\n\n if options[:acceleration] && has_acceleration?\n # :nocov:\n has_quotes = line =~ /#{options[:quote_char]}/\n elements = parse_csv_line_c(line, options[:col_sep], options[:quote_char], header_size)\n elements.map!{|x| cleanup_quotes(x, options[:quote_char])} if has_quotes\n return [elements, elements.size]\n # :nocov:\n else\n # puts \"WARNING: SmarterCSV is using un-accelerated parsing of lines. Check options[:acceleration]\"\n return parse_csv_line_ruby(line, options, header_size)\n end\n end",
"def parse( line )\n info = line.split(',')\n return info\nend",
"def parse_line(line)\n ln, fn, sex, fav_color, dob = line.split(', ')\n LineParser.to_h(fn, ln, nil, sex, fav_color, parse_dob(dob))\n end",
"def parse_line(line)\n results = LineRegexp.match(line)\n if results \n @elements[:line] = results[-1]\n results[-1] # remaining line \n else\n @elements[:line] = line\n line \n end\n end",
"def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end",
"def parse_line(line)\n catch :line_parsed do\n UNDERSTOOD_ROWS.each do |record_type|\n if line.start_with?(record_type)\n send \"parse_#{record_type.downcase}_line\", line.chomp\n throw :line_parsed\n end\n end\n\n if line[0].eql?('/')\n parse_comment_line line.chomp\n throw :line_parsed\n end\n\n logger.error \"Can't understand line: #{line.chomp.inspect}\"\n end\n end",
"def parse_csv_line(text_line)\n # Split the text_line by comma\n columns = text_line.split(\",\")\n # But some of the values are padded with spaces\n # And add the cleaned up values to the new array (called values)\n # strip --> predefined string function which trims spaces\n values = []\n columns.each {|x| values << x.strip}\n return values\n\nend",
"def parse( line )\r\n line.split(';')\r\nend",
"def process line\n return unless line.gsub!(/^INSERT INTO `\\w+` VALUES \\(/,\"\")\n warn \"bad ending\" unless line.gsub!(/\\);?$/, '')\n line.split(/\\),\\(/).each do |tuple|\n begin\n QUOTED_QUOTE_RE.gsub!(tuple, \"''\")\n emit FasterCSV.parse_line(tuple, :quote_char => \"'\")\n rescue FasterCSV::MalformedCSVError => e\n warn \"#{e}: #{tuple}\"\n end\n \n end\n end",
"def parse_line(line)\n line.gsub(/;.*$/, \"\").strip.scan(/\"[^\"]*\"|[.:]?\\w+|-?\\d+/).map { |e|\n if e[0] == '\"'\n e[1..-2]\n else\n e\n end\n }\nend",
"def parse(line)\n res='unknown'\n raw=line.split(':')\n res=raw[1] if raw[1]!=nil\n res.strip\n end",
"def preprocess_line line\n line.split(/,/).collect { |l| l.strip }\n end",
"def parse_line(line)\n return [] if line.nil? or line.empty?\n line.chomp(\"\\n\").split(\"\\t\")\n end",
"def parse_line(line)\n line_arr = line.split(':')\n type = line_arr.first.downcase\n days = line_arr.last.split(',')\n [type, days]\n end",
"def parse_csv(csvstr)\n\treturn CSV.parse(csvstr)\nend",
"def read_parameters_from_csv(csv)\r\n\t\tbegin\r\n\t\t\ttemp = CSV.read(csv)\r\n\t\trescue Exception\r\n\t\t\traise ArgumentError, \"It wasn't possible to read from #{csv} file.\"\r\n\t\tend\r\n\t\ttemp.each_with_index do |row,index|\r\n\t\t\t@actual_parameters[index] = row[0].split(';')\r\n\t\tend\r\n\tend",
"def parse(line)\n row = line.to_s\n row.chomp!\n row.strip!\n return unless match = regexp.match(row)\n\n data = {}\n names.each_with_index { |field, index| data[field] = match[index + 1] } # [0] == line\n data\n end",
"def parse(line)\n row = line.to_s\n row.chomp!\n row.strip!\n return unless match = regexp.match(row)\n\n data = {}\n names.each_with_index { |field, index| data[field] = match[index + 1] } # [0] == line\n data\n end",
"def parse(lineno, line)\n tokens = GedLine.new *line.chomp.strip.split(/\\s/)\n parse_line(lineno, tokens)\n end",
"def parse_input(data)\n par = data.split(',')\n { dsn: par[0], sql_name: par[1], params: par[2..100] }\n end",
"def parse_line(line)\n is = new\n line =~ /(.+)\\s+<-\\s+(.+?)\\s+\\((\\d+\\.\\d)(?:\\/(\\d+))?,\\s+(\\d+\\.\\d)\\)/\n consequent, antecedent, support, transactions, confidence = $1, $2, $3, $4, $5\n is.consequent = consequent \n is.antecedent = antecedent.split(/\\s+/)\n is.support = support.to_f\n is.num_antecedent_transactions = transactions ? transactions.to_i : nil\n is.confidence = confidence.to_f\n is\n end",
"def get_values(line)\n unless line.instance_of?(Array)\n line = line.split(\";\")\n end\n if line.length < 3\n return nil\n end\n return LineValues.new(line)\n end",
"def read(string)\n lines = string.split(\"\\n\")\n header = lines[0]\n attributes = header.split(',').map! { |v| v.to_sym }\n # Struct.new('CSVEntry', *attributes)\n ret = []\n lines.drop(1).each do |line|\n values = line.split(',')\n opts = {}\n values.each_with_index do |val, idx|\n opts[attributes[idx]] = val\n end\n ret << Struct::CSVEntry.new(opts)\n end\n\n ret\n end",
"def import_line(line)\n line_array = line.split(\"\\t\") #? name\n\n # destructuring\n @name, @cuisine, @price = line_array\n\n return self # returns the OBJECT\n end",
"def parse_csv(filename)\n @file=CSV.read(filename)\n # Read order of headers\n headers = @file.shift\n @file.each do |line|\n next if line.length==0 || (line.length==1 && line[0]==nil)\n # Read fields from line based on headers\n value=ReturnValue.new( line[headers.index('label')],\n line[headers.index('name') || headers.index('label')],\n line[headers.index('type')],\n line[headers.index('unit')],\n line[headers.index('per_unit')],\n line[headers.index('default')] )\n @values.push value\n end\n validate\n end",
"def parse(line)\n line = line.gsub('(', '')\n line = line.gsub(')', '')\n tokens = line.split(',')\n\n start_row, start_col = tokens[1].split(':')\n end_row, end_col = tokens[2].split(':')\n\n {\n id: tokens[0],\n end_row: end_row.to_i,\n end_col: end_col.to_i,\n start_row: start_row.to_i,\n start_col: start_col.to_i\n }\n end",
"def parse_line(line, tags, values, open_tags)\n if line.match(TAG)\n tags = handle_adding_tag($2, tags)\n values = handle_add_to_top_open_tag(get_tag($2), open_tags, values)\n values = handle_add_line_to_value(\"\", $2, values)\n elsif line.match(OPEN_TAG)\n open_tags.push($2)\n tags = handle_adding_tag($2, tags)\n elsif line.match(CLOSE_TAG)\n values, open_tags = handle_close_tag($2, values, open_tags)\n elsif line.match(VALUE_TEXT)\n values = handle_add_to_top_open_tag($1, open_tags, values)\n elsif line.match(BRACE_TEXT)\n values = handle_add_to_top_open_tag($1, open_tags, values)\n else\n puts \"Error: didn't match '#{line}'\"\n exit 1\n end\n \n whole = $1\n if line.sub(whole, '') != nil and line.sub(whole, '') != \"\"\n return parse_line(line.sub(whole,''), tags, values, open_tags)\n else \n return tags, values, open_tags\n end\n end",
"def parse line\n normalize(@lexer.tokenize(line)).select { |t| t.is_a? String }\n end",
"def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end",
"def parse(args={})\n csv_args = {:skip_blanks=>true,:col_sep=>\",\"}\n csv_args[:col_sep] = args[:col_sep] if args[:col_sep]\n args[:value_filter] ||= Csv2sql.method :default_value_filter\n i = 0\n CSV.foreach(@filename,csv_args) do |row|\n values = row\n #values_filter is for whole row\n #value_filter is for single value\n values = args[:values_filter].call(row, i) if args[:values_filter]\n if values\n if args[:value_filter]\n j = -1\n values = row.map do |value|\n j += 1\n args[:value_filter].call(value,i,j)\n end\n end\n yield values if values\n end\n i += 1\n end\n end",
"def read_input_line line_in, line_number\n\t\tinput_params = line_in.split(\" \")\n\t\tunless input_params.empty? \n\t\t\tbegin\t \n\t\t\t\tcase input_params[0]\n\t\t\t\twhen \"Driver\"\n\t\t\t\t\tself.handle_driver_command input_params\t\t\n\t\t\t\twhen \"Trip\"\n\t\t\t\t\tself.handle_trip_command input_params\t\t\n\t\t\t\telse\n\t\t\t\t\tputs \"#{input_params[0]} id not a supported command\"\n\t\t\t\tend\n\t\t\trescue => err\n\t\t\t puts \"line #{line_number} not parsed, Incorrect input format #{line_in} - #{err}\"\n\t\t\t err\n\t\t\tend\t\t\t\n\t\tend\n\tend",
"def parse_csv\n raise InvalidStateError, \"#{state.inspect} is not a valid Data state for method 'to_csv'\" unless state == :raw\n\n file_options = @options[:file_options]\n parse_options = @options[:parse_options]\n\n begin\n csv = CSVWrapper.parse(@content, parse_options)\n csv = csv.drop(1) if file_options[:has_headers] == true # drop the first row if it is a header\n rescue => e\n Logger.new(@options).print(@path, :parse, e)\n end\n\n @state = :parsed\n Data.new(@path, csv, @state, @options)\n end",
"def parse(v)\n row[v[0]..v[1]].strip rescue nil\n end",
"def parse_entry(line)\n\n return nil if line.nil? || line.length <= 0\n meta,msg = line.split(' : ',2)\n msg = msg.chomp unless msg.nil?\n\n parts=meta.split(' ')\n\n fields=[]\n\n unless parts.length < 3\n fields_str=parts[2][1..-2]\n fields = fields_str.split(',')\n end\n\n Entry.new(parts[0], parts[1], fields, msg, line)\n end",
"def parse_line(line)\n return nil unless valid?(line)\n\n # it isn't a tag if it doesnt begin with #\n return M3U8ParsedTag.new(nil, nil, line) unless line[0] == '#'\n\n # is it an idependent tag?\n return M3U8ParsedTag.new(line[1..-1]) if independent_tag?(line)\n return nil unless (pos = line.index(':'))\n\n # is it a VALUE tag?\n tag, attr_or_val = [line[1..pos - 1], line[pos + 1..-1]]\n return M3U8ParsedTag.new(tag, nil, attr_or_val) if value_tag?(line[0..pos - 1])\n return M3U8ParsedTag.new(tag, attr_or_val) if attribute_tag?(line[0..pos - 1])\n\n # I don't know wtf it is!\n nil\n end",
"def parse_status_line(line, header)\n split_line = line.split(',').map(&:strip)\n if split_line.first == '' && split_line.length == 1 # Empty line\n nil\n else\n { pxname: split_line[header.index('pxname')],\n svname: split_line[header.index('svname')],\n status: split_line[header.index('status')] }\n end\n end",
"def parse_header(header_line)\n entries = delete_special_chars(header_line)\n # switch entries for geo coordinates since latitude comes before longitude\n geo_coordinate = Entity::Coordinate.new(entries[6].to_f, entries[5].to_f)\n @grid_data = Entity::GridPoint.new(entries[8].to_f, entries[9].to_f,\n entries[12].to_f, entries[11].to_f)\n # special case for multi word locations\n station_name = entries[0].sub(\"_\", \" \")\n @station = Entity::Station.new(station_name, entries[3], entries[13].to_f,\n geo_coordinate)\n nil\n end",
"def parse_line(delim , line)\n temp_array = Array.new #Array to hold data\n index = 0 #Position of array index\n token = \"\" #To hold the string\n grouping = false #Grouping characters flag\n\n #Parse line with delimeter\n line.each_char do |char|\n #Grouping Block \n if char == \"\\\"\" and !grouping\n token += char\n grouping = true\n elsif char == \"\\\"\" and grouping \n token += char\n grouping = false\n elsif char == delim and !grouping \n temp_array.push(clean(token)) \n token = \"\" \n else\n token += char\n end\n end \n \n #Store last token on line\n temp_array.push(clean(token))\n \n return temp_array\nend",
"def process_line(line)\n return true if line.empty?\n\n chunks = line.split(SPLIT_PATTERN, fmt.length)\n enough_fields?(line) # can raise exception\n\n point = { path: extract_path(chunks),\n value: extract_value(chunks) }\n\n tags = line_tags(chunks)\n\n point.tap do |p|\n p[:tags] = tags unless tags.empty?\n p[:ts] = extract_ts(chunks) if fmt.include?('t')\n p[:source] = extract_source(chunks) if fmt.include?('s')\n p[:interval] = options[:interval] || 'm' if fmt.include?('d')\n end\n end",
"def parse_line_break; end",
"def parse(use_line)\n load_properties(use_line.split(\",\"))\n self\n end",
"def parse_decl_line line\n result = {}\n until line.empty?\n # Peel a key off our line.\n line =~ /^(; )?(\\w+): / or raise \"Can't parse: #{line}\"\n key, line = $2, $POSTMATCH\n \n # Peel a value off our line.\n case line\n when /^([^;\"]+)/\n result[key], line = $1, $POSTMATCH\n when /^\"([^\"]*(\"\"[^\"]*)*)\"/\n str, line = $1, $POSTMATCH\n result[key] = str.gsub(/\"\"/, '\"')\n else\n raise \"Can't parse argument: #{line}\"\n end\n end\n result\n end",
"def parse_line(line)\n # Remove comment text\n line = strip_comments(line)\n\n # Read key/value pair if one exists in this line\n (key, value) = line.split(\"=\", 2)\n\n if key && value\n # Remove any extra whitespace or line endings\n # and handle any type boolean type conversions\n key = key.strip\n value = convert_booleans(value.strip)\n\n # Save the configuration values in a hash\n @config[key] = value\n end\n end",
"def parse_line(line)\n if (line.include?(';'))\n arr = line.split(';')\n tmp = arr[0].to_i\n resonance = arr[1].delete('[').delete(']').split(',').map{|x| x.to_f}\n [tmp, arr[2].to_i, resonance]\n else\n false\n end\n end",
"def process_line(line)\n @line = line\n if line =~ /^=/ then\n process_heading_line(line)\n elsif (listtype = special_list_line_type(line)) then\n special_list_line(listtype, line)\n elsif line =~ /^\\s*:/ then\n special_list_continuation_line(line)\n else\n @interp.normal_line(line)\n end\n end",
"def parse_blank_line; end",
"def csvfield!(str)\r\n ret = \"\"\r\n str.sub!(/^\\s*/,\"\")\r\n if str[0,1]==\"\\\"\"\r\n str[0,1] = \"\"\r\n escaped = false\r\n fieldbytes = 0\r\n str.scan(/./) do |s|\r\n fieldbytes += s.length\r\n break if s==\"\\\"\" && !escaped\r\n if s==\"\\\\\" && !escaped\r\n escaped = true\r\n else\r\n ret += s\r\n escaped = false\r\n end\r\n end\r\n str[0,fieldbytes] = \"\"\r\n if !str[/^\\s*,/] && !str[/^\\s*$/]\r\n raise _INTL(\"Invalid quoted field (in: {1})\\r\\n{2}\",str,FileLineData.linereport)\r\n end\r\n str[0,str.length] = $~.post_match\r\n else\r\n if str[/,/]\r\n str[0,str.length] = $~.post_match\r\n ret = $~.pre_match\r\n else\r\n ret = str.clone\r\n str[0,str.length] = \"\"\r\n end\r\n ret.gsub!(/\\s+$/,\"\")\r\n end\r\n return ret\r\n end",
"def parse_line(line)\n host_ip, date, method_file_protocol, http_code, _ = @line_regex.match(line).captures\n file = @mfp_regex.match(method_file_protocol).captures[0]\n ip_token = host_ip.split(':')[1]\n\n date = Time.strptime(date, '%d/%b/%Y:%H:%M:%S %z').iso8601\n query_params = CGI::parse(URI(file).query)\n\n return {\n access_date: date,\n ip_token: ip_token,\n page_number: query_params[\"seq\"] || -1,\n http_code: http_code,\n volume_id: query_params[\"id\"]\n }\n end",
"def csv_parse(arg, no_raise: true, no_empty: true, utf8: true, **opt)\n return if arg.nil? || arg.is_a?(Puma::NullIO)\n CSV.parse(arg, **CSV_DEFAULTS, **opt).map { |row|\n row = row.to_h\n next if no_empty && row.values.all?(&:nil?)\n utf8 ? row.transform_values! { |v| force_utf8(v) } : row\n }.compact\n rescue => error\n Log.info { \"#{__method__}: #{error.class}: #{error.message}\" }\n re_raise_if_internal_exception(error)\n raise error unless no_raise\n end",
"def _parse_line(line, config_hash, overrides)\n line.strip!\n line = _strip_comment(line)\n\n if line.empty?\n # Nothing to do here\n return\n end\n\n section = _get_section_title(line)\n if section\n _process_section(section, config_hash)\n return\n end\n\n key_value_hash = _get_key_value_hash(line)\n if key_value_hash\n unless $_current_section\n raise 'Key-value pair must be part of a section'\n end\n _process_key_value(key_value_hash, config_hash, overrides)\n return\n end\n\n raise 'Malformed config file: ' << line\n end",
"def readline(sep=$/) end",
"def readline(sep=$/) end",
"def parse_line( line )\n\tline.chomp!\n\tvalues = []\n\t#BEGIN_STUDENT\n\twords = line.split(',')\n words.each do |word|\n\t\tvalues += [word]\n end\n\treturn values\n\t#END_STUDENT\nend",
"def parse_contents(stream, line = nil)\n # parse_contents will parse one line and apply headers, formats methods and error handle as appropriate\n current_line = line.present? ? line : 1\n all_errors = []\n\n @csv_options[:encoding] = @encoding\n\n begin\n row = LineCSV.parse_line(stream, @csv_options)\n rescue LineCSV::MalformedCSVError => e\n build_exception_messages(e, stream, current_line)\n end\n\n if row\n if current_line <= 1 && @csv_header\n # this conditional should be refactored somewhere\n row = row.reject { |col| col.nil? || col.empty? }\n validate_header(row)\n @col_counts << row.size\n else\n build_formats(row)\n @col_counts << row.reject { |col| col.nil? || col.empty? }.size\n @expected_columns = row.size unless @expected_columns != 0\n build_errors(:blank_rows, :structure, current_line, nil, stream.to_s) if row.reject { |c| c.nil? || c.empty? }.size == 0\n # Builds errors and warnings related to the provided schema file\n if @schema\n @schema.validate_row(row, current_line, all_errors, @source, @validate)\n @errors += @schema.errors\n all_errors += @schema.errors\n @warnings += @schema.warnings\n else\n build_errors(:ragged_rows, :structure, current_line, nil, stream.to_s) if !row.empty? && row.size != @expected_columns\n end\n end\n end\n @data << row\n end",
"def initialize line\n\n attributes = [:icao, :latitude, :longitude]\n\n line_split = line.strip.split(\":\")\n\n attributes.each_with_index.map { |attribute, index|\n instance_variable_set(\"@#{attribute}\", line_split[index]) if self.respond_to?(attribute)\n }\n end",
"def parse_line(line)\n matrix(line)\n .each_slice(3)\n .map(&:join)\n end",
"def parse(line)\n @pattern, *@owners = line.split(/\\s+/)\n @whitespace = line.split('@').first.count(' ') - 1\n @spec = parse_spec(@pattern)\n end",
"def parse_csv(csv_file)\r\n\t\t\t# Fixed errors due to a Byte-Order-Mark (BOM) at the very beginning of some CSV files\r\n\t\t\t# http://stackoverflow.com/questions/23011713/illegal-quoting-error-with-ruby-csv-parsing\r\n\t\t\tparsed_csv = []\r\n\t\t\tbegin\r\n\t\t \t\tparsed_csv = CSV.read(csv_file, :encoding => 'bom|utf-8')\r\n\t\t\trescue ArgumentError\r\n\t\t \t\tbegin\r\n\t\t \t\tparsed_csv = CSV.read(csv_file, :encoding => 'bom|utf-8:ISO-8859-1')\r\n\t\t \t\trescue ArgumentError\r\n\t\t \t\traise ParserError, \"There was an error in reading the CSV encoding.\"\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\treturn parsed_csv\r\n\t\tend",
"def parse_csv_row(csv_row)\n {\n s_no: csv_row['Sr. No'],\n ticket_no: csv_row['Ticket No'],\n email: csv_row['Email'],\n name: csv_row['Name'],\n new_eth_address: csv_row['New Ethereum Add']\n }\n end",
"def\tparse_file\n CSV.foreach(@file) do |row|\n begin\n rid, price, item = row[0].strip.to_i, row[1].strip.to_f, row[2..-1].map(&:strip).join('-').downcase\n validate(rid, price, item) ? load(rid, price, item) : puts(\"Escaping invalid row: #{row}\")\n rescue StandardError \n puts \"Escaping incorrect row: #{row}\"\n end\n end\n end",
"def process_line(line)\n # skip current line unless in correct format:\n # all restaurant IDs are integers, all item names are lower case letters and underscores,\n # and the price is a decimal number, all separated by commas with any surrounding whitespace\n return unless line =~ /^\\d+\\s*,\\s*\\d+\\.\\d{2}\\s*,\\s*([a-z_]+\\s*,\\s*)*[a-z_]+$/\n entry_items = line.gsub(/\\s+/,'').split(',')\n\n restaurant_id = entry_items.shift\n entry_price = entry_items.shift\n\n encoded_entry = encode_entry(entry_items)\n return unless encoded_entry > 0 #if encoded_entry equals 0 then no items matched the desired so why bother\n\n update_min_entry_price(restaurant_id, entry_price, encoded_entry)\n end",
"def parse_csv(csv_file)\n\n # Loop through all entries in CSV file\n CSV.foreach(csv_file, :quote_char => \"\\\"\") do |row|\n next if row[0] == \"From\" && row[1] == \"To\"\n next if row[0].nil?\n\n # [0, 1] refers to the 2 addresses in the csv file\n [0, 1].each do |i|\n add_location(row[i])\n end\n\n add_journey(row)\n end\nend",
"def parse_input_string(tsv_string)\n rows = tsv_string.split(/\\r\\n/)\n row_raw_data = rows.map do |row|\n row.gsub!(/\"/, '')\n row.split(\"\\t\")\n end\n\n @header_row = row_raw_data[0]\n @data_rows = row_raw_data[1..-1]\n\n @header_row.each.with_index do |col_key, i|\n if STATIC_KEYS.include?(col_key)\n @header_object[col_key] = i\n else\n date = parse_date(col_key)\n @header_row[i] = date\n end\n end\n\n format_data\n end",
"def parse_line(line)\n raise Puppet::DevError, \"No record types defined; cannot parse lines\" unless records?\n\n @record_order.each do |record|\n # These are basically either text or record lines.\n method = \"handle_#{record.type}_line\"\n if respond_to?(method)\n if result = send(method, line, record)\n record.send(:post_parse, result) if record.respond_to?(:post_parse)\n return result\n end\n else\n raise Puppet::DevError,\n \"Somehow got invalid line type #{record.type}\"\n end\n end\n\n nil\n end",
"def parse_line(line)\n line_array = line.split\n if line_array.length < 2\n nil\n elsif line_array[0] == 'Driver'\n driver = Driver.new(line_array[1])\n @drivers[driver.driver_hash[:name]] = driver\n elsif line_array[0] == 'Trip'\n driver = @drivers[line_array[1]]\n begin\n driver.add_trip(Trip.new(line_array))\n rescue => e\n p e\n end\n end\n end",
"def parse(line)\n cmd, arg_string = line.downcase.split(' ')\n [cmd, *arg_string.to_s.split(',')]\n end",
"def parse(input)\n rownum = 0\n @header = nil if first_line_is_header\n lines = input.each_line.to_a\n lines.each do |line|\n line = line.encode('utf-8')\n rownum += 1\n\n next if rownum <= skip_initial_rows\n next if rownum > lines.size - skip_trailing_rows\n\n values = line.chomp.split(separator)\n\n if first_line_is_header and @header.nil?\n @header = values\n next\n end\n\n begin\n @entries << make_entry(values)\n rescue RuntimeError => e\n raise ParseStreamError.new(\"line #{rownum}: #{e.message}\", e, rownum, line)\n end\n end\n end",
"def parse_parameters; end",
"def parse_first_header(line)\n\n # split the line into: METHOD URI PROTOCOL\n # eg: GET / HTTP/1.1\n parsed = line.split(' ')\n\n # a correct request has three parts\n return bad_parsing unless parsed.size == 3\n\n @http_request_method, uri, @http_protocol = parsed\n\n # optional query string\n @http_request_uri, @http_query_string = uri.split('?')\n end",
"def parse_imports(params)\n data = params[:rawdata]\n rows = data.split(/[\\n\\r]+/)\n rowsandcolumns = []\n\n\n rows.each do |row|\n columns = row.split(\"\\t\")\n rowsandcolumns.push columns\n end\n\n @data = rowsandcolumns\n end",
"def parse_line(line, tags, values, open_tags)\n if line.match(TAG)\n tags = handle_adding_tag($1, tags)\n elsif line.match(OPEN_TAG)\n open_tags.push($1)\n tags = handle_adding_tag($1, tags)\n elsif line.match(CLOSE_TAG)\n open_tags = handle_close_tag($1, open_tags)\n end\n \n values = handle_add_line_to_values(line, values, open_tags)\n \n return tags, values, open_tags\n end",
"def process_line_of_tsv_in_this_pipe line\n parts = line.strip.split(\"\\t\")\n case parts.size\n when 2\n timestamp = Time.now\n key, value = parts\n when 3\n key, value = parts[0..1]\n timestamp = Time.parse(parts.last)\n else\n error(\"Each line of input must be a tab separated row consisting of 2 columns (key, value) or 3 columns (timestamp, key, value)\")\n return\n end\n send_data(key, value, timestamp)\n end",
"def parse_line row,init=true\n parse_init if init\n dbg[:parse]= false\n @doc_src = read_w2tags(row).split(\"\\n\") << \",/\"\n #@doc_src = row.delete(\"\\r\").split(\"\\n\") << \",/\"\n while (@row= @doc_src.shift) do #;p \"row:#{@row}\"\n parse_row\n end\n @doc_out\n end",
"def parse_header_line(header_str)\n @headers = header_str.split(',')\n @headers.map! do |h|\n h.gsub!('\"','')\n h.strip!\n h.underscore.to_sym\n end\n @headers\n end",
"def parseCSV(csvfile)\n begin\n if csvfile != nil && csvfile != \"\"\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end",
"def parse_line(line)\n # If the previous line didn't and a logical line, we're not going to start one. If it did,\n # we're indeed going to start a new logical line\n @state[:ll_start] = @state[:ll_end]\n\n # We will start with the assumption that we're going to end the current logical line. We may layer\n # find out that we did not, in fact, do so.\n @state[:ll_end] = true\n\n # Reset the line continuator flag the the last line may have set to true\n @state[:line_continuator] = false\n\n # Find the first non-(space/tab) character\n index = 0\n while index < line.length && [\" \", \"\\t\"].include?(line[index])\n index += 1\n end\n @state[:indent_string] = line[0...index]\n\n # Iterate over the line's characters as long as there are any. We use different iteration\n # methods depending on whether we're inside a string or not\n index = 0\n while index < line.length\n if @state[:in_string].nil?\n index = parse_characters_normal(line, index)\n else\n index = parse_characters_in_string(line, index)\n end\n end\n\n # We have reached the end of the line. Decide whether or not the logical line ends here.\n @state[:ll_end] = @state[:in_string].nil? && @state[:open_braces] == 0 && !@state[:line_continuator]\n end",
"def parse(csv_row)\n @transformer ? parse_transform(csv_row) : raw_value(csv_row)\n end",
"def split_first_line(line)\n title, date, tags = line.split('|')\n tags = tags.strip.split(',')\n return title, date, tags\nend",
"def parse_line\n s0 = @scanner.pos\n match_spaces\n s2 = parse_te\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s4 = @scanner.pos\n s5 = parse_fugou\n if s5 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n s6 = parse_from\n if s6 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n @reported_pos = s4\n s4 = transform_teban_fugou_from(s2, s5, s6)\n end\n end\n if s4 == :failed\n s4 = @scanner.pos\n s5 = []\n s6 = match_regexp(/[^\\r\\n ]/)\n while s6 != :failed\n s5 << s6\n s6 = match_regexp(/[^\\r\\n ]/)\n end\n @reported_pos = s4\n s4 = s5.join\n end\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s6 = parse_time\n s6 = nil if s6 == :failed\n match_str('+')\n if parse_nl == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'move' => s4, 'time' => s6 }\n end\n end\n end\n s0\n end",
"def row_from_csv(csv, line:)\n row_args = %i[timestamp speaker settings content].each_with_object({}) do |key, args|\n args[key] = csv[@key_map[key]]\n args\n end\n\n Row.new(line_number: line, **row_args)\n end",
"def parseCSV(csvfile)\n begin\n if csvfile != nil\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end",
"def parse_line line\n cmd, *args = line.split(/\\s+/)\n case cmd\n when 'v' then add_vertex args\n when 'f' then add_face args\n end\n end",
"def parse(station_object, parameter_object, data)\n # Number stations\n nstn = 1\n # Number parameters\n nparams = parameter_object.length\n\n # Split lines into array\n data = data.split(/\\n/)\n\n # Get and clean data\n data = data[(8 + nstn + nparams)..data.length]\n data = data.join.tr(\"\\s+\", \"\")\n data = data.tr(\"#\", \"\")\n\n # Parse into array and then hash with var name\n data = CSV.parse(data, {:skip_blanks => true})\n header = data.shift.map {|i| i.to_s.intern }\n string_data = data.map {|row| row.map {|cell| cell.to_i } }\n data = string_data.map {|row| Hash[*header.zip(row).flatten] }\n \n return data\n end",
"def parse_details(line)\n @id, blob = line.split(\":\")\n @fullname, @date, @parent_id = blob.split(\",\")\n @owner, @name = fullname.split(\"/\")\n end",
"def parse_line(line)\n begin\n @loggie.write(\"#{line}\\n\")\n line = line.split(\" \")\n if line[9] == 'voice'\n return Message.new(line[12],line[15],'started.',line[0].to_f,GROUP,line[8])\n elsif line[9] == 'end'\n return Message.new(line[14],line[17].gsub(',',''),'ended.',line[0].to_f,GROUP,line[8])\n elsif line[7] == \"audio\"\n led(\"rx\", line[-2].split('/')[0].to_i / 141.0)\n return \"audio\"\n elsif line[6] == 'group'\n return Message.new(line[4],line[7],line.last,line[0].to_f,GROUP,\"RF\")\n elsif line =~ /Call from/\n return Message.new(line[4],line[6],line.last,line[0].to_f,PRIV,\"RF\")\n end\n rescue => e\n @@logger.debug(e.inspect)\n @@logger.debug(e.backtrace)\n exit 1\n end\n end",
"def parse(v)\n row[v].strip rescue nil\n end",
"def parse_entry(log_entry)\n @column = {}; i = 1;\n if attributes = log_entry.match(regexp)\n @args.each {|f| @column[f] = attributes[i]; i += 1}\n parse_datetime! if @column[:time]\n parse_request! if @column[:request]\n end\n @column\n end",
"def parse(line)\n raise EntryFileError, \"Do not know how to parse the entries in #{File.basename(@data_file)}!\"\n end",
"def parse_csv(file)\n\t\tdata = []\n\t\t# Break open CSV and go through rows\n\t\tbegin\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'UTF-8')\n\t\trescue\n\t\t\t# Convert to UTF-8 if necessary\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'Windows-1252:UTF-8')\n\t\tend\n\t\tdata\n\tend",
"def load_raw_line opts = OPTS_REGEX.keys\n self.raw_line.chomp!\n opts.each do |xfield|\n pattern = OPTS_REGEX[xfield]\n did_set = raw_setter xfield, pattern\n #puts did_set\n end\n end",
"def parse _line, _next_lines\n raise NotImplementedError, self\n end",
"def pbGetCsvRecord(rec,lineno,schema)\r\n record = []\r\n repeat = false\r\n start = 0\r\n if schema[1][0,1]==\"*\"\r\n repeat = true\r\n start = 1\r\n end\r\n begin\r\n for i in start...schema[1].length\r\n chr = schema[1][i,1]\r\n case chr\r\n when \"i\" # Integer\r\n record.push(csvInt!(rec,lineno))\r\n when \"I\" # Optional integer\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\-?\\d+$/]\r\n raise _INTL(\"Field {1} is not an integer\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_i)\r\n end\r\n when \"u\" # Positive integer or zero\r\n record.push(csvPosInt!(rec,lineno))\r\n when \"U\" # Optional positive integer or zero\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\d+$/]\r\n raise _INTL(\"Field '{1}' must be 0 or greater\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_i)\r\n end\r\n when \"v\" # Positive integer\r\n field = csvPosInt!(rec,lineno)\r\n raise _INTL(\"Field '{1}' must be greater than 0\\r\\n{2}\",field,FileLineData.linereport) if field==0\r\n record.push(field)\r\n when \"V\" # Optional positive integer\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\d+$/]\r\n raise _INTL(\"Field '{1}' must be greater than 0\\r\\n{2}\",field,FileLineData.linereport)\r\n elsif field.to_i==0\r\n raise _INTL(\"Field '{1}' must be greater than 0\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_i)\r\n end\r\n when \"x\" # Hexadecimal number\r\n field = csvfield!(rec)\r\n if !field[/^[A-Fa-f0-9]+$/]\r\n raise _INTL(\"Field '{1}' is not a hexadecimal number\\r\\n{2}\",field,FileLineData.linereport)\r\n end\r\n record.push(field.hex)\r\n when \"X\" # Optional hexadecimal number\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^[A-Fa-f0-9]+$/]\r\n raise _INTL(\"Field '{1}' is not a hexadecimal number\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.hex)\r\n end\r\n when \"f\" # Floating point number\r\n record.push(csvFloat!(rec,lineno))\r\n when \"F\" # Optional floating point number\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\-?^\\d*\\.?\\d*$/]\r\n raise _INTL(\"Field {1} is not a floating point number\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_f)\r\n end\r\n when \"b\" # Boolean\r\n record.push(csvBoolean!(rec,lineno))\r\n when \"B\" # Optional Boolean\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif field[/^1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|[Tt]|[Yy]$/]\r\n record.push(true)\r\n else\r\n record.push(false)\r\n end\r\n when \"n\" # Name\r\n field = csvfield!(rec)\r\n if !field[/^(?![0-9])\\w+$/]\r\n raise _INTL(\"Field '{1}' must contain only letters, digits, and\\r\\nunderscores and can't begin with a number.\\r\\n{2}\",field,FileLineData.linereport)\r\n end\r\n record.push(field)\r\n when \"N\" # Optional name\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^(?![0-9])\\w+$/]\r\n raise _INTL(\"Field '{1}' must contain only letters, digits, and\\r\\nunderscores and can't begin with a number.\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field)\r\n end\r\n when \"s\" # String\r\n record.push(csvfield!(rec))\r\n when \"S\" # Optional string\r\n field = csvfield!(rec)\r\n record.push((nil_or_empty?(field)) ? nil : field)\r\n when \"q\" # Unformatted text\r\n record.push(rec)\r\n rec = \"\"\r\n when \"Q\" # Optional unformatted text\r\n if nil_or_empty?(rec)\r\n record.push(nil)\r\n else\r\n record.push(rec)\r\n rec = \"\"\r\n end\r\n when \"e\" # Enumerable\r\n record.push(csvEnumField!(rec,schema[2+i-start],\"\",FileLineData.linereport))\r\n when \"E\" # Optional enumerable\r\n field = csvfield!(rec)\r\n record.push(checkEnumFieldOrNil(field,schema[2+i-start]))\r\n when \"y\" # Enumerable or integer\r\n field = csvfield!(rec)\r\n record.push(csvEnumFieldOrInt!(field,schema[2+i-start],\"\",FileLineData.linereport))\r\n when \"Y\" # Optional enumerable or integer\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif field[/^\\-?\\d+$/]\r\n record.push(field.to_i)\r\n else\r\n record.push(checkEnumFieldOrNil(field,schema[2+i-start]))\r\n end\r\n end\r\n end\r\n break if repeat && nil_or_empty?(rec)\r\n end while repeat\r\n return (schema[1].length==1) ? record[0] : record\r\n end",
"def process_line(line)\n line.split ' '\n end",
"def recordize line\n line.split(\"\\t\") rescue nil\n end"
] | [
"0.7076647",
"0.7044287",
"0.7040002",
"0.67581344",
"0.6651798",
"0.6603432",
"0.65326625",
"0.6532377",
"0.65091497",
"0.64363515",
"0.63538975",
"0.633257",
"0.6325488",
"0.62858653",
"0.61814755",
"0.6142592",
"0.61063075",
"0.60993636",
"0.60749173",
"0.6049596",
"0.6035788",
"0.6030719",
"0.59979016",
"0.59797233",
"0.5958483",
"0.59527093",
"0.5926947",
"0.5896",
"0.58898115",
"0.5869554",
"0.58509254",
"0.57973325",
"0.57954663",
"0.57654804",
"0.5762319",
"0.57538503",
"0.5724369",
"0.57240087",
"0.5722621",
"0.5717816",
"0.5707435",
"0.5699434",
"0.5691043",
"0.5688788",
"0.5647166",
"0.56445456",
"0.564166",
"0.5625164",
"0.56159383",
"0.56119835",
"0.5611216",
"0.5606804",
"0.5578737",
"0.55637604",
"0.5556375",
"0.55527776",
"0.553573",
"0.553573",
"0.5533144",
"0.553183",
"0.55291504",
"0.55263263",
"0.5525687",
"0.5493704",
"0.5464069",
"0.54606676",
"0.54578376",
"0.5455584",
"0.5452954",
"0.5433703",
"0.5429811",
"0.54157966",
"0.54147375",
"0.5413693",
"0.5405195",
"0.5404532",
"0.54006606",
"0.5400272",
"0.539882",
"0.53959256",
"0.53920436",
"0.5391667",
"0.538977",
"0.53861755",
"0.5379582",
"0.53663325",
"0.53602856",
"0.53582346",
"0.5342007",
"0.53414345",
"0.53365564",
"0.53345305",
"0.53340244",
"0.5328871",
"0.5304249",
"0.5300966",
"0.5297013",
"0.52871054",
"0.52740943",
"0.52700436"
] | 0.67853737 | 3 |
Return the supplied array as a single line CSV string | def to_csv(array)
@io.rewind
@io.truncate(0)
@csv << array
@io.rewind
@io.string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv(array)\n nilfix = array.map { |s| blank(s) ? \"\" : s }\n quoted = nilfix.map { |s| '\"' + s.gsub('\"',\"'\") + '\"' }\n return quoted.join(',')\nend",
"def csv(rows)\n rows.map { |r| r.join(';') }.join(\"\\n\")\n end",
"def save_as_csv(array)\n final_array = array\n CSV.open(\"emails94.csv\", \"w\") do |csv|\n csv << [\"Nom des Mairies\", \"Emails des Mairies\"]\n final_array.each do |x|\n\n csv << [x.keys.join, x.values.join]\n end\n end\n end",
"def csv_write(filename,a)\n csv_str = \"\";\n for i in 0..a.size-1 do\n for j in 0..a[i].size-2 do\n csv_str = csv_str + \"\\\"\" + a[i][j].to_s + \"\\\",\"\n end;\n csv_str = csv_str + \"\\\"\" + a[i][j+1].to_s + \"\\\"\\n\";\n end;\n File.write(filename,csv_str);\nend",
"def array_to_csvstring(ar)\n word_string = String.new\nar.each{|k,v| word_string << \"#{k}=#{v}_\"}\nreturn word_string[0...-1]\nend",
"def array_to_csvstring(ar)\n word_string = String.new\nar.each{|k,v| word_string << \"#{k}=#{v}_\"}\nreturn word_string[0...-1]\nend",
"def to_csv\n str = ''\n str << ( columns.join(\",\") + \"\\n\" )\n rows.each { |row|\n next if is_hr(row) || !row_visible(row)\n str << ( row.map{|x|\n x = x.to_s\n x.gsub(/[\\r\\n]/, ' ').gsub(/\\s+/, ' ').gsub('\"', '\"\"')\n }.map{|x| \"\\\"#{x}\\\"\" }.join(\",\") + \"\\n\" )\n }\n str\n end",
"def csvString\n resultColumns = self.generateResultColumns\n headers = resultColumns[:columns].keys\n # Start off instantiating the csv string with the header values\n csvString = headers.map{|s| self.filterValue(s)}.join(@options[:delimiter])\n\n # Now iterate over each row, sticking its value under each header\n (0..resultColumns[:maxRowIndex]).each do |rowIndex|\n csvString << \"\\r\\n\"\n csvString << headers.map{ |header|\n self.filterValue(resultColumns[:columns][header][rowIndex])\n }.join(@options[:delimiter])\n end\n return csvString\n end",
"def to_csv(array2d,filename=nil)\n fp = File.open(filename,'w') if filename\n array2d.each { |x| \n (fp || STDOUT).puts Array(x)*','\n }\n fp.close if fp\n end",
"def encode_array(arr)\n arr.join ','\n end",
"def array_to_lines(array, delimiter = '<br />')\n array.blank? ? nil : array * delimiter\n end",
"def to_csv\n csvString = LineCounter.columnNames.join(',') + \"\\n\"\n self.each { |result| csvString += result.to_a.join(',') + \"\\n\"}\n csvString\n end",
"def add_to_csv(arr)\n\t\t\t\t\t\tCSV.open(\"location-emails.csv\", \"a+\") do |csv|\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcsv << arr\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\nend",
"def to_csv\n self.find.map {|row| row.join(',')}.join(\"\\n\")\n end",
"def to_s\r\n to_csv\r\n end",
"def question_to_csv(array)\n #mete las preguntas y respuestas a el array\n @model.ask_csv(array[0],array[1])\n end",
"def csv_string\n CSV.generate do |csv|\n header.write_header csv\n records.each {|r| r.write_record csv}\n end\n end",
"def notes_to_char_string_csv\n notes_to_char_string_array.join(',')\n end",
"def orders_to_csv\n orders.map { |order| order.id}.join(\", \")\n end",
"def csv\n @name + \",r,\" + @foods.join(\",\")\n end",
"def csvize(value)\n [value].join(\",\")\nend",
"def to_csv\n CSV.generate { |csv| to_a.each { |r| csv << r } }\n end",
"def output\n CSV.open(\"test.csv\", \"wb\") do |csv|\n csv << [\"name\",\"type\",\"value\",\"date\"]\n @array_csv.each do |element|\n csv << element\n puts element.inspect\n end\n end\n end",
"def array_to_string(value)\n result = ''\n value.each { |value| result += to_cli_value(value) + ',' }\n result = '[' + result.chomp(',') + ']'\n end",
"def entry_to_csv index\n\t\tcsv_string = \"\\\"\" + @year + \"\\\",\\\"\" + @edition + \"\\\",\" + contents[index].to_csv\n\t\treturn csv_string\n\tend",
"def to_csv(filename, label_array, data_array)\n CSV.open(filename, \"wb\") do |csv|\n csv << label_array\n data_array.each { |d| csv << d }\n end\n end",
"def csv_from_row(op, row)\n res = \"\"\n until row.empty?\n entry = row.shift.to_s\n if /[,\"]/ =~ entry\n entry = entry.gsub(/\"/, '\"\"')\n res << '\"' << entry << '\"'\n else\n res << entry\n end\n res << \",\" unless row.empty?\n end\n op << res << CRLF\nend",
"def print_array(array)\n puts '[' + array.join(',') + ']'\nend",
"def to_csv(a_separateur = ';')\n @nom + a_separateur + @devises_conversion.map(&:to_csv).join(a_separateur)\n end",
"def to_s\n # @rows.join(\"\\n\")\n end",
"def to_csv(headers=nil)\n headers = Item.csv_headers if headers.nil?\n values = []\n headers.each do |h|\n values << '\"' + self.send(h).to_s + '\"'\n end\n return values.join(\"\\t\")\n end",
"def writeCSVFile(dataArray, fileName)\n\t# Create file handle\n\toutFile = File.new(fileName, 'w');\n\t\n\t# Loop through and output each piece of data\n\tdataArray.each_index do |i|\n\t\toutFile.print(\"#{dataArray[i]}\")\n\t\t\n\t\t# This check is so that we do not have an extra comma at the end\n\t\tif (i < dataArray.length() - 1)\n\t\t\toutFile.print(\", \");\n\t\tend\n\tend\n\toutFile.puts();\n\t\n\toutFile.close();\nend",
"def to_csv_array\n base_url = \"http://www.lincomp.ch\"\n c = Cart.new\n c.add_product(self)\n shipped_price = (taxed_price.rounded + c.shipping_cost.rounded)\n availability = \"48h\"\n if stock < 1\n availability = \"ask\"\n end\n unless product_pictures.main.empty?\n image_link = base_url + product_pictures.main.first.file.url unless product_pictures.main.first.file.blank?\n end\n unless attachments.empty?\n factsheet_link = base_url + attachments.first.file.url unless attachments.first.file.blank?\n end\n unless categories.empty?\n categories_arr = [] \n categories.each do |c|\n categories_arr << c.fully_qualified_name\n end\n categories_string = categories_arr.join(\"|\")\n end\n\n # We use string interpolation notation (#{foo}) so that nil errors are already\n # handled gracefully without any extra work.\n [\"#{id}\", \"#{manufacturer}\" ,\"#{manufacturer_product_code}\", \"#{name}\",\\\n \"#{description}\", \"#{price.rounded}\", \"#{taxed_price.rounded}\", \"#{shipped_price}\",\\\n \"#{taxes}\", \"#{c.shipping_cost.rounded}\", \"#{stock}\", \"#{availability}\", \"#{weight}\",\\\n \"#{base_url}/products/#{self.id}\",\"#{image_link}\",\"#{factsheet_link}\",\"#{ean_code}\",\\\n \"#{categories_string}\",\"#{c.total_taxed_shipping_price.rounded}\"]\n end",
"def csv_row\n [\n hub_id,\n tag_id,\n \"%2.2f\" % temperature,\n ACCELERATION_FORMAT % x_acceleration,\n ACCELERATION_FORMAT % y_acceleration,\n ACCELERATION_FORMAT % z_acceleration,\n rssi,\n timestamp.to_i\n ].join(\",\")\n end",
"def csv\n @name + \",b,\" + @calories.to_s\n end",
"def array_to_string(arr)\n arr.map { |e| \"'#{sanitize(e)}'\" }.join(\",\")\n end",
"def to_s\n [line1, line2, \"#{city}, #{state} #{zip}\"].compact.join(\", \")\n end",
"def printArray(array)\n array.flatten!\n string = \"\"\n array.each {|letter| string << \"#{letter},\"}\n string.chomp(\",\")\nend",
"def display\n array = stringify_rows\n print_line_seperator\n array.each do |row|\n puts \"|\" << row.join( \"|\" ) << \"|\"\n print_line_seperator\n end\nend",
"def csv\n\t\tc = \"#{entrytime},#@entrytype,#@extcmd,#@host,#@service,\"\n\t\tc += \"#@attempt,#@rc,#@state,#@hardsoft,\\\"#@msg\\\",\"\n\t\tc += \"#@contact,#@command,#@ack_author,#@ack_data,\"\n\t\tc\n\tend",
"def csv(opts = {})\n Squib.csv(opts)\n end",
"def csv_to_s(rows, cols: nil)\n \"\".tap do\n f = CSV.new(StringIO.new(_1))\n csv_write0(f, rows, cols:)\n end\n end",
"def to_csv(seperator=',')\n report = @report || generate_report\n report.map{ |row| row.join(seperator) }.join(\"\\n\")\n end",
"def to_s\n [@rows.collect { |row| row.inspect }].join(\"\\n\")\n end",
"def export_data(array, name = \"data\")\n CSV.open(\"public/data/\" + name + \"_\" + Time.now.strftime(\"%m_%d_%Y_%H:%M:%S\") + \".csv\", \"w\") do |csv|\n csv << array\n end\n end",
"def export_data(array, name = \"data\")\n CSV.open(\"public/data/\" + name + \"_\" + Time.now.strftime(\"%m_%d_%Y_%H:%M:%S\") + \".csv\", \"w\") do |csv|\n csv << array\n end\n end",
"def to_s\n array = []\n array << @header.to_s if @header\n # add a blank line after header\n array << \"\"\n @entries.each do |entry|\n array << entry.to_s\n end\n array.join(\"\\n\")\n end",
"def line_for(column_values)\n column_values.map {|value| value_for(value) }.join('\",\"')\n end",
"def stringify(arr)\n arr.map { |s| s.to_s }.join(\"<br>\")\n end",
"def to_csv_row\n [@id, @name, @address]\n end",
"def write(arr)\n starting_id = read.length\n CSV.open('contacts.csv', 'a') do |csv|\n csv << arr.unshift(starting_id)\n end\n end",
"def savedata(array)\n CSV.open('scraper.csv', 'a') do |csv|\n csv << array\n end\nend",
"def to_s\n @csv_out_data\n end",
"def to_s\n @csv_out_data\n end",
"def to_csv\n map {|row|\n row.map {|f|\n f =~ /[[:punct:]]/ ? '\"' + f.gsub(/\"/, '\"\"') + '\"' : f }.\n join(\",\")}.\n join(\"\\n\")\n end",
"def to_csv\n # id.to_s << \",\" << last_name << \",\" << first_name << \",\" << email << \",\" << birthdate.to_s\n end",
"def to_csv\n @csv ||= format_csv\n end",
"def getCsvText\r\n sep = \"|\"\r\n t = \"\"\r\n \r\n t << \"Question Number\" + sep \r\n questions.size.times do |i| \r\n t << (i + 1).to_s + sep \r\n end\r\n t << \"Points\"\r\n t << \"\\n\"\r\n \r\n t << \"Correct Answer\" + sep\r\n for question in questions \r\n t << correctAnswerText(question).to_s + sep \r\n end \r\n t << \"\\n\"\r\n \r\n for user in users \r\n t << user.getName + sep\r\n for question in questions \r\n t << answerText(user, question) + sep\r\n end \r\n t << getPoints(user).to_s\r\n t << \"\\n\" \r\n end\r\n return t \r\nend",
"def export_csv\n export_string = \"#{@id},#{type_string},#{@name.gsub(/[\\,,\\s]/,\"\")},\"\n @details.each{|k,v| export_string << \"#{k}=#{v};\".gsub(/[\\,,\\s]/,\"\") }\n export_string\n end",
"def export_csv\n export_string = \"#{@id},#{type_string},#{@name.gsub(/[\\,,\\s]/,\"\")},\"\n @details.each{|k,v| export_string << \"#{k}=#{v};\".gsub(/[\\,,\\s]/,\"\") }\n export_string\n end",
"def to_s\n to_a.join(',')\n end",
"def to_csv\n value.to_csv\n end",
"def array_string(array, **opt)\n list_separator = opt[:list_separator] || LIST_SEPARATOR\n normalized_list(array, **opt).join(list_separator)\n end",
"def to_s\n rows.empty? ? '' : rows.collect { |row| row_output_string(row) }.join(\"\\n\")\n end",
"def convert_to_csv(obj_array)\n CSV.generate(headers: true) do |csv|\n csv << obj_array.first.keys\n\n obj_array.each do |object|\n csv << object.values\n end\n end\n end",
"def to_s\n @lines.map { |line| line.to_s }.join(\"\\n\") \n end",
"def to_csv(options = Hash.new)\n options = options.merge(:force_quotes => true)\n # override only if first element actually has as_csv method\n return old_to_csv(options) unless self.first.respond_to? :as_csv\n # use keys from first row as header columns\n out = first.as_csv.keys.collect{|k| k.to_s.titleize }.to_csv(options)\n # collect all entries as CSV, ensure that no line break is present within values\n self.each { |r| out << r.as_csv.values.to_csv(options).gsub(/\\r?\\n/, ' ').strip! + \"\\n\" }\n # Force encoding to UTF-16LE and add Byte Order Mark for Excel compatibility\n (BOM + out).force_encoding(\"UTF-8\")\n end",
"def to_s\n self.to_a.map{ |row| row.join(' ') }.join(\"\\n\")\n end",
"def to_s(sep=\"\\t\")\n map do |row|\n row.join(sep)\n end.join(\"\\n\")\n end",
"def write_to_csv(result_arr)\n\tprint \"Please enter the file you would like to write the gene data to: \"\n\t#example: 'BRCA1_DATA'\n\tfile_name = gets.strip.to_s \n\tCSV.open(\"#{file_name}.csv\", 'wb') do |csv|\n\t\tcsv << ['CAID', 'Protein Changes', 'Clinical Significance', 'Review Status', 'Allele freq', 'Last Evaluated']\n\t\tfor elem in result_arr\n\t\t\tif elem[2] == nil \n\t\t\t\tcsv << [elem[0], elem[1], \"N/A\", elem[3], elem[4], elem[5]]\n\t\t\telse\n\t\t\t\tcsv << [elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]]\n\t\t\tend\n\t\tend\n\tend\nend",
"def my_join(array, separator)\n\tarray_string = \" \"\n\tarray.each{ |a| array_string << a + separator }\n\treturn array_string\nend",
"def to_s\n out = Array.new\n out.push \"file='#{@file}'\"\n out.push \"line='#{@line}'\"\n out.push \"name='#{@name}'\"\n out.push \"arg='#{@arg}'\"\n out.push \"params='#{@params}'\"\n out.push \"initrd='#{@initrd}'\"\n out.push \"type='#{@type}'\"\n return out.join(\", \")\n end",
"def to_s\n @out.join\n end",
"def array_to_sentence_string(array, connector = T.unsafe(nil)); end",
"def to_s\n lines.join(\"\\n\")\n end",
"def write_rows file_name, names, values\n header = names.join(',') + \"\\n\"\n body = values.map {|row| row.join(',') }.join($/)\n File.open(file_name + \".csv\", 'w') { |f| f.write(header + body) }\nend",
"def save_students\n# open the file to save\n file = File.open(\"students.csv\", \"w\")\n# iterate over the array of students\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv_line = student_data.join(\",\")\n file.puts csv_line\n end\n file.close\nend",
"def convert_to_csv(records_array)\n CSV.generate(headers: true) do |csv|\n csv << ATTRIBUTES_TO_SELECT\n\n records_array.each do |info|\n csv << info.attributes\n .slice(*ATTRIBUTES_TO_SELECT)\n .values\n end\n end\n end",
"def to_s\n r = []\n each do |e|\n r << e\n end\n '[' + r.join(', ') + ']'\n end",
"def save_as_csv\n CSV.open(\"db/emails.csv\", \"wb\") do |csv|\n for i in 0...@ville_name_array.length\n csv << [@ville_name_array[i], @ville_email_array[i]]\n end\n end\n end",
"def to_s\n data.map { |ar| ar.map { |v| v.to_s.gsub(/\\t|\\n|\\r/,' ') }.join \"\\t\" }.join( $/ )\n end",
"def array_to_r_vector(array, options = {})\n options = {:string_vals => false}.merge(options)\n str = \"c(\"\n\n if options[:string_vals]\n array.each {|ret| str << '\\'' << ret.to_s << '\\'' << \",\"}\n else\n array.each {|ret| str << ret.to_s << \",\"}\n end\n\n str.chomp!(\",\")\n str << \")\"\n end",
"def quote_array(value)\n \"(#{value.map { |entry| quote_value(entry) }.join(', ')})\"\n end",
"def to_csv(created_at, updated_at)\n csv = Array.new\n csv.push id.to_s\n csv.push last_name.gsub(/\\\\/, \"\")\n csv.push first_name ? first_name.gsub(/\\\\/, \"\") : NULL\n csv.push fed\n csv.push title || NULL\n csv.push gender\n csv.push born ? born.to_s : NULL\n csv.push rating ? rating.to_s : NULL\n csv.push NULL # ICU ID\n csv.push created_at\n csv.push updated_at\n csv.join(\",\")\n end",
"def datarows=(array)\n self[:datarows] = array.join(\",\")\n end",
"def to_csv\n \"#{@key},#{@expected},#{@type}\"\n end",
"def export_to_csv(file_name, arr)\n puts \"Exporting list...\"\n csv_headers = [\"CLS URN:\", \"Lead2Lease Count:\"]\n CSV.open(file_name, \"wb\") do |csv|\n csv << csv_headers\n end\n i = 0\n while i < arr.length\n CSV.open(file_name, \"a+\") do |csv|\n formatted = []\n if arr[i].get_count > 0\n formatted.push(arr[i].name, arr[i].get_count)\n csv << formatted\n end\n end\n i = i+1\n end\n puts \"Lead2Lease list exported!\"\nend",
"def to_s\n\t\t\t\t'[' << map(&:to_s).join(', ') << ']'\n\t\t\tend",
"def to_s\n @data.map(&:to_s).join(\"\\n\")\n end",
"def to_sentence(array)\n if array.respond_to?(:to_sentence)\n array.to_sentence\n else\n array.join(\", \")\n end\n end",
"def write_line(arr)\n @sheet.row(@current_row).concat arr\n next_row\n end",
"def c(array = [])\n str = \"\"\n\n for a in array\n str += a + \" \"\n end\n\n str.strip\n end",
"def try_join_arr(val)\n val.join(\"\\n\") rescue val\n end",
"def convert_hash_array_to_csv(hash_array)\r\n\t\t\tcsv_string = CSV.generate do |csv|\r\n\t\t\t\tcsv << hash_array.first.keys # adds the attributes name on the first line\r\n\t\t \thash_array.each do |hash|\r\n\t\t \t\tcsv << hash.values\r\n\t\t \tend\r\n\t\t\tend\r\n\t\t\treturn CSV.parse(csv_string, :encoding => 'bom|utf-8')\r\n\t\tend",
"def to_s\n to_data.map(&:to_s).join(\"\\n\")\n end",
"def build_csv(file_name)\n\t\t\t\t\t\tarr = [\"Location URN\", \"Email List\"]\n\t\t\t\t\t\t\t\tCSV.open(file_name, \"wb\") do |csv|\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcsv << arr\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\nend",
"def to_s\n @merged_collection_list.to_csv\n end",
"def generate_csv\n csv_string = CSV.generate do |csv|\n csv << [\"Sl no.\",\"Scheme\",\"IP no.\", \"Patient name\", \"UHID no.\", \"Reg no.\", \"DOA\", \"DOS\", \"DOD\", \"Plan of treatment\", \"Approved Amount\",\"Claim Amount\", \"TDS\",\"Net Amount\",\"Hospital charges\",\"Medicine charges\",\"Implant charges\"]\n sl_no = 1\n @claims.each do |claim|\n csv <<[sl_no,\"#{claim.scheme rescue \"\"}\",\"#{claim.ip_no rescue \"\"}\",\"#{claim.patient_name rescue \"\"}\",\"#{claim.uhid_no rescue \"\"}\",\"#{claim.reg_no rescue \"\"}\",\"#{claim.date_of_admission}\",\"#{claim.date_of_surgery}\",\"#{claim.date_of_discharge}\",\"#{claim.plan_of_treatment rescue \"\"}\",(claim.approved_amount rescue 0.0),(claim.claim_amount rescue 0.0),(claim.tds_amount rescue 0.0),(claim.net_amount rescue 0.0),(claim.hospital_charge rescue 0.0),(claim.medicine_charge rescue 0.0),(claim.implant_charge rescue 0.0)]\n sl_no +=1\n end\n end\n csv_string\n end",
"def to_csv\n self.all.to_promise.then do |all|\n io = StringIO.new\n io << (attrs.join(',') + \"\\n\")\n all.each do |model|\n line = model.to_csv(attrs: attrs, tab_sub: CSV_TAB_SUB, cr_sub: CSV_CR_SUB, nl_sub: CSV_NL_SUB, comma_sub: CSV_COMMA_SUB) # send(attr).to_s.gsub(',', COMMA_SUB)\n io << (line + \"\\n\")\n end\n io.string.to_promise\n end\n end",
"def to_joined_str (item)\n if (item.class == Array) then\n item.join(\", \")\n else\n item.to_s\n end\nend"
] | [
"0.7749197",
"0.75764453",
"0.7026806",
"0.68263113",
"0.67877656",
"0.67877656",
"0.67139345",
"0.66098017",
"0.66019064",
"0.6571392",
"0.650231",
"0.64866585",
"0.6443145",
"0.6411524",
"0.63872844",
"0.6382767",
"0.635947",
"0.63576275",
"0.6352149",
"0.63205427",
"0.6306147",
"0.6305133",
"0.6296461",
"0.6275687",
"0.62600124",
"0.6259285",
"0.62451607",
"0.62387836",
"0.6236677",
"0.62215",
"0.62164545",
"0.6214443",
"0.62089",
"0.62034976",
"0.6198367",
"0.6196767",
"0.6195194",
"0.6166434",
"0.6166266",
"0.6163958",
"0.61435854",
"0.61337996",
"0.6131661",
"0.6127189",
"0.61160976",
"0.61160976",
"0.61080205",
"0.6104244",
"0.6101564",
"0.6095468",
"0.60926527",
"0.60919225",
"0.6073545",
"0.6073545",
"0.605962",
"0.6024706",
"0.6019182",
"0.6012863",
"0.599374",
"0.599374",
"0.59886885",
"0.5986419",
"0.598081",
"0.596634",
"0.5964838",
"0.5943155",
"0.59430164",
"0.59325755",
"0.5919027",
"0.5914734",
"0.59102166",
"0.5910145",
"0.5910022",
"0.58954126",
"0.5894222",
"0.5883743",
"0.5882743",
"0.5877767",
"0.5872519",
"0.5869368",
"0.58685005",
"0.5860878",
"0.58532894",
"0.58375186",
"0.5828056",
"0.5827908",
"0.5827638",
"0.5827551",
"0.5827492",
"0.58258134",
"0.58236325",
"0.58096206",
"0.58041686",
"0.5797278",
"0.57875925",
"0.57718956",
"0.57715315",
"0.5750928",
"0.574354",
"0.57405055"
] | 0.7778386 | 0 |
Compiles a TypeScript file to JavaScript. | def compile_file(filepath, options={})
options = options.clone
if options[:output]
output_filename = options[:output]
elsif options[:output_dir]
filename = File.basename(filepath).gsub(/[.]ts$/, '.js')
output_filename = File.join(options[:output_dir], filename)
else
output_filename = filepath.gsub(/[.]ts$/, '.js')
end
args = [filepath] + flatten_options(options)
stdout, stderr, wait_thr = node_compile(*args)
if wait_thr.nil?
success = stdout.empty? and stderr.empty?
else
success = wait_thr.value == 0
end
if success
result = {
:js => output_filename,
:stdout => stdout,
}
if options[:source_map]
result[:source_map] = output_filename + '.map'
end
return result
else
raise TypeScript::Error, ( stderr.empty? ? stdout : stderr )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compileTS ( file )\n puts \"Compiling #{file}\"\n result = TypeScript::Node.compile_file( file )\n fail result.stderr if result.exit_status != 0\n result.js\n end",
"def compile(source, *tsc_options)\n js_file = Tempfile.new(%w(typescript-node .ts))\n begin\n js_file.write(source)\n js_file.close\n result = compile_file(js_file.path, *tsc_options)\n if result.success?\n result.js\n else\n raise result.stderr + result.stdout\n end\n ensure\n js_file.unlink\n end\n end",
"def compile_file(source_file, *tsc_options)\n Dir.mktmpdir do |output_dir|\n output_file = File.join(output_dir, 'out.js')\n stdout, stderr, exit_status = tsc(*tsc_options, '--out', output_file, source_file)\n\n output_js = File.exists?(output_file) ? File.read(output_file) : nil\n CompileResult.new(\n output_js,\n exit_status,\n stdout,\n stderr,\n )\n end\n end",
"def compile(script, options = {})\n script = script.read if script.respond_to?(:read)\n\n if options.key?(:bare)\n elsif options.key?(:no_wrap)\n options[:bare] = options[:no_wrap]\n else\n options[:bare] = false\n end\n\n result = Source.context.call(\"RubyTypeScriptCompiler\", Source.lib_contents, script, options)\n\n result['log'].each do |lines|\n JSON.parse(lines).collect { |k, v| v }.each do |message|\n puts \">> #{ message }\"\n end\n end\n\n return result['output']\n end",
"def processJS ( &compile )\n reporter = Jshintrb::Reporter::Default.new\n\n # Executes JSHint on a file and returns its content\n def jsHint ( file )\n puts \"JSHinting #{file}\"\n errors = Jshintrb.lint( File.read(file) )\n if errors.length > 0\n puts\n errors.map do |err|\n puts (\" line %d, column %d: %s\\n\" +\n \" %s\\n\" +\n \" %s^\\n\") % [\n err['line'], err['character'], err['reason'],\n err['evidence'],\n \"~\" * (err['character'] - 1)\n ]\n end\n fail \"JSHint failed\"\n end\n\n File.read(file)\n end\n\n # Compiles a typescript file\n def compileTS ( file )\n puts \"Compiling #{file}\"\n result = TypeScript::Node.compile_file( file )\n fail result.stderr if result.exit_status != 0\n result.js\n end\n\n puts \"Compiling JavaScript...\"\n Dir.glob('js/**/*').map do |file|\n next unless File.file?( file )\n\n compileTo = \"target/resources/#{file.chomp(File.extname(file))}.js\"\n FileUtils.mkpath( File.dirname(compileTo) )\n\n if ( File.extname(file) == \".ts\" )\n next if File.basename(file).start_with?(\"_\")\n content = compileTS( file )\n else\n content = jsHint( file )\n end\n\n puts \" Compiling to #{compileTo}\"\n\n File.open(compileTo, 'w') do |out|\n out.write( compile.call( content ) )\n end\n end\nend",
"def compile(path)\n content = File.read(path)\n %{\n var template = Hogan.compile(#{content.to_json});\n module.exports = (function(data){ return template.render(data); });\n }\n end",
"def run(content, params = {})\r\n ::TypeScript.compile(content)\r\n end",
"def compile(script, options = {})\n script = script.read if script.respond_to?(:read)\n\n unless options.key?(:bare)\n options[:bare] = false\n end\n\n format = options[:format] == :map ? 'sourceMap' : 'js'\n options.delete(:format)\n Source.context.call(\"(function() { return root.CoffeeScript.#{ format }(root.CoffeeScript.compile(root.CoffeeScript.parse.apply(this, arguments))) })\", script, options)\n end",
"def generate_output(inputs, output)\n inputs.each do |input|\n begin\n raise error (\"I need a file to compile\") if not input.respond_to?(:read)\n\n #puts \"tsc: #{input.path} \" << options.join(\" \")\n\n #Using compile_file because it gives us better error messages\n result = TypeScript::Node::compile_file(input.fullpath, options)\n if result.success?\n output.write(result.js)\n else\n raise result.stderr\n end\n rescue ExecJS::Error => error\n raise error, \"Error compiling #{input.path}. #{error.message}\"\n rescue RuntimeError => e\n raise e, \"Error compiling #{input.path}. #{e.message}\"\n end\n end\n end",
"def compile(script, options = {})\n script = script.read if script.respond_to?(:read)\n\n # if options.key?(:bare)\n # elsif options.key?(:no_wrap)\n # options[:bare] = options[:no_wrap]\n # else\n # options[:bare] = false\n # end\n\n\n Source.context.eval(\"jade.compile(#{script.to_json}, #{options.to_json}).toString()\")\n rescue ExecJS::ProgramError => e\n raise %(Error compiling tilt-jade template '#{options[:filename]}': #{e.message})\n end",
"def compile(script, options = {})\n script = script.read if script.respond_to?(:read)\n error, data = Source.context.call('compile', script)\n\n if error\n raise ParseError, error['message']\n else\n data\n end\n end",
"def compile\n\n if all_files.join().match(/\\.coffee/) and !@has_coffee\n error \"Cannot compile coffeescript\".red\n error \"Add \".white + \"gem 'coffee-script'\".yellow + \" to your Gemfile.\"\n end\n\n if @options[:uglify] and !@uglifier\n error \"Cannot uglify javascript\".red\n error \"Add \".white + \"gem 'uglifier'\".yellow + \" to your Gemfile.\"\n end\n\n begin\n js = Stitch::Package.new(:dependencies => dependencies, :paths => @options[:paths]).compile\n js = @uglifier.compile(js) if @uglifier\n js\n rescue StandardError => e\n error \"Stitch failed to compile\".red\n error e\n false\n end\n end",
"def compile_js source, dest\r\n case COMPILER\r\n when 'closure'\r\n compilation_level = 'SIMPLE_OPTIMIZATIONS' #WHITESPACE_ONLY | SIMPLE_OPTIMIZATIONS | ADVANCED_OPTIMIZATIONS\r\n sh \"java -jar closure-compiler/compiler.jar --compilation_level #{compilation_level} --js_output_file #{dest} --js #{source}\"\r\n when 'yui'\r\n sh \"java -jar yuicompressor/build/yuicompressor-2.4.2.jar --charset UFT-8 -o #{dest} #{source}\"\r\n when 'ms'\r\n sh \"AjaxMin/AjaxMin -enc:in UFT-8 #{source} -out #{dest}\"\r\n when 'uglify'\r\n sh \"uglifyjs/uglifyjs --ascii --unsafe -o #{dest} #{source}\"\r\n end\r\nend",
"def compile_to_ruby\n statements.collect { |s| s.compile_to_ruby }.join(\"\\n\")\n end",
"def compile(file, options = {})\n return unless write?\n # Any options passed in from an interface will be passed to the compiler and to\n # the templates being compiled\n options[:initial_options] = options\n Origen.file_handler.preserve_state do\n begin\n file = Origen.file_handler.clean_path_to_template(file)\n Origen.generator.compile_file_or_directory(file, options)\n rescue\n file = Origen.file_handler.clean_path_to(file)\n Origen.generator.compile_file_or_directory(file, options)\n end\n end\n end",
"def compile\n compile_body\n compile_head\n \n builder = ScriptBuilder.new @template\n builder.build_for_page @filename\n end",
"def tcompile source\n tc = VishCompiler.new\n tc.source = source\n tc.default_optimizers[:tail_call] = true\n tc.run\n tc\nend",
"def compile()\n self._compiled = <<\"JAVASCRIPT\"\n(function(repl) {\n try {\n var rc;\n #{code.join(' ')}\n repl.rc_ok(rc);\n } catch(e) {\n repl.rc_fail(e.name, e.message ? e.message : e);\n };\n})(#{replid});\nJAVASCRIPT\n self._code = []\n end",
"def compile(script, filename=nil, linenum=nil)\n delegate.compile(script, filename, linenum)\n end",
"def coffee2js(code)\n\trnd= ('a'..'z').to_a.shuffle[0,8].join\n\t#`rm /tmp/coffee_#{rnd}`\n\t`touch /tmp/coffee_#{rnd}`\n\tf=File.open \"/tmp/coffee_#{rnd}\",\"w\"\n\tf.write code\n\tf.close\n\t`cat /tmp/coffee_#{rnd}|coffee -sc` # \"Compiled\" coffee to js will be the output.\nend",
"def compile(script, filename=nil, linenum=nil)\n filename ||= 'none'\n linenum ||= 1\n native_compile(script, filename, linenum)\n end",
"def compile_file(path)\n path = \"#{path}.rb\" unless path =~ /\\.rb\\Z/\n res = RubyVM::InstructionSequence.compile_file(path)\n data = Marshal.dump(res.to_a)\n rbc_path = path + \"c\"\n File.open(rbc_path, \"w+\") {|f| f.write data }\n rescue NotImplementedError\n # Ruby bug with terminated objects\n false\n end",
"def transpile(code, options = {})\n @js_code = code\n Node.exec(generate_source(options))\n end",
"def compile(script, filename=nil, linenum=nil)\n raise NotImplementedError\n end",
"def compile_file(ctx, source)\n compile_string(ctx, File.read(source))\n rescue StandardError => e\n puts \"Error compiling file: #{source}\"\n raise e\n end",
"def compile_coffeescript source_path, destination_path\n # Jasmine testing directories\n Dir.mkdir(File.dirname(File.expand_path(destination_path, __FILE__))) unless File.exists?(File.dirname(File.expand_path(destination_path, __FILE__)))\n \n # Compile coffee script from the project into the test directory\n root = File.expand_path(source_path, __FILE__)\n destination_dir = File.expand_path(destination_path, __FILE__)\n glob = File.expand_path(\"**/*.js.coffee\", root)\n Dir.glob(glob).each do |srcfile|\n srcfile = Pathname.new(srcfile)\n destfile = srcfile.sub(root, destination_dir).sub(\".coffee\", \"\")\n FileUtils.mkdir_p(destfile.dirname)\n File.open(destfile, \"w\") {|f| f.write(CoffeeScript.compile(File.new(srcfile)))}\n end\n end",
"def compile_to_ruby\n \"\"\n end",
"def compile(script, filename=nil, linenum=nil, global=nil)\n filename ||= 'none'\n linenum ||= 1\n native_compile(script, filename, linenum, global)\n end",
"def compile(script, filename=nil, linenum=nil)\n filename ||= 'none'\n linenum ||= 1\n @compiled_scripts[filename] = native_compile(script, filename, linenum)\n end",
"def compile(source)\n ast = transformer.apply(parser.parse(source))\n ast.compile\n end",
"def compile(name, source, jst = true)\n runtime.call('HamlCoffeeAssets.compile', name, source, jst, HamlCoffee.namespace, HamlCoffee.format, HamlCoffee.uglify, HamlCoffee.basename,\n HamlCoffee.escapeHtml, HamlCoffee.escapeAttributes, HamlCoffee.cleanValue,\n HamlCoffee.customHtmlEscape, HamlCoffee.customCleanValue,\n HamlCoffee.customPreserve, HamlCoffee.customFindAndPreserve,\n HamlCoffee.preserveTags, HamlCoffee.selfCloseTags,\n HamlCoffee.context)\n end",
"def compile(file)\n Liquid::Template.parse load(file)\n end",
"def source\n source = source_compiler['jison.js'].to_s\n source_compiler.each_logical_path do |logical_path|\n next if logical_path == 'jison.js'\n src = source_compiler[logical_path].to_s\n logical_path.sub! /\\.js$/, ''\n source.concat \"require.def('#{logical_path}',{factory:function(require,exports,module){#{src}}});\"\n end\n source + \"var Dock = require('dock').Dock;\"\n end",
"def compile_code(*jsstmts)\n code *jsstmts\n compile\n end",
"def compile_fixture file\n response = @server.({'PATH_INFO' => file})\n response[0].should eql 200\n ExecJS.compile(\"var window = {}; #{response[2].to_s}\")\n end",
"def compile_coffee_to_js\n files = ['level_core', 'path_core', 'deadlock_core']\n files.each do |file|\n if File.exist?(\"lib/assets/#{file}.js\")\n File.delete(\"lib/assets/#{file}.js\")\n end\n compile_file_coffee_to_js(\"app/assets/javascripts/game/models/#{file}.js.coffee\", \"lib/assets/#{file}.js\")\n end\nend",
"def compile_js_files(file, prod=true)\n\t# use development style options for now, even in production\n\tif prod\n\t\toptions = {:output => {:comments => :none }}\n\t\tFile.open(file, \"w\") { |f| f.write(Uglifier.compile(concat_js_files, options)) }\n\telse\n\t\t#options = {:output => {:comments => :all, :beautify => true, :preserve_line => true}}\n\t\tFile.open(file, \"w\") { |f| f.write(concat_js_files) }\n\tend\n\n\tputs \" \\e[32mwrite #{file}\\e[0m\"\nend",
"def compile_file(file, compiled)\n if CodeLoader.save_compiled?\n Compiler.compile file, compiled\n else\n Compiler.compile_file file\n end\n end",
"def runtime\n @runtime ||= ExecJS.compile(source)\n end",
"def runtime\n @runtime ||= ExecJS.compile(source)\n end",
"def runtime\n @runtime ||= ExecJS.compile(source)\n end",
"def compile(source_name, py_file, pyc_file = nil)\n pyc_file ||= py_file\n\n source_name =~ /\\.py$/ or raise\n base = $`\n pyofile = base + '.pyo'\n\n cp(py_file, source_name)\n command = format('python2.2 -OO -c \\'%s\\'',\n format('import py_compile; py_compile.compile(\"%s\")', source_name))\n sh(command)\n rm(source_name)\n\n # Not sure if .pyo files are recognized,\n # so let's rename as .pyc.\n mv(pyofile, pyc_file)\n end",
"def coffeescript\n File.read CoffeeScript::Source.path\n end",
"def compile\n end",
"def compile\n File.chmod(0o755, start_script(root))\n augment_classpath_content\n end",
"def compile(path)\n files = getFilesInDirCompiler(path)\n filesWithLines = getFilesWithLinesCompiler(files)\n classNames = getClassNames(filesWithLines)\n functionInfo = getFunctionNameTypesFiles(filesWithLines)\n compilerInfo = [classNames, functionInfo]\n\n for i in 0..filesWithLines.size-1\n fSize = filesWithLines[i][0].size\n\n #renaming the\n compiledFileName = filesWithLines[i][0][0, fSize-5]+\".vm\"\n compiledFileXMLName = filesWithLines[i][0][0, fSize-5]+\"Out.xml\"\n tokensFileName = filesWithLines[i][0][0, fSize-5]+\"TOut.xml\"\n lines = filesWithLines[i][1]\n lines = getLines(lines)\n tokens = tokenize(lines)\n\n writeCompiledFile(tokens, compilerInfo, compiledFileName)\n writeCompiledXMLFile(tokens, classNames, compiledFileXMLName)\n writeTokensXMLFile(tokens, tokensFileName)\n puts filesWithLines[i][0] + \" was tokenized and compiled\" +\"\\n\"\n end\nend",
"def file_coffee(name)\n source = \"#{name}.coffee\"\n file \"#{name}.js\" => source do\n sh \"coffee -c #{source}\"\n end\nend",
"def compile\n exe_file = File.join(@temp_dir, 'exe')\n result = TTY::Command.new(printer: :quiet).run!('gcc', '-o', exe_file, @src_file)\n [exe_file, result]\n end",
"def compile_jst(paths)\n compiled = paths.map do |path|\n template_name = File.basename(path, File.extname(path))\n contents = File.read(path).gsub(/\\n/, '').gsub(\"'\", '\\\\\\\\\\'')\n \"window.JST.#{template_name} = #{Jammit.template_function}('#{contents}');\"\n end\n compiler = Jammit.include_jst_script ? File.read(DEFAULT_JST_SCRIPT) : '';\n [JST_START, compiler, compiled, JST_END].flatten.join(\"\\n\")\n end",
"def compile\n Tipsy::Runners::Compiler.new(@args, @site)\n end",
"def compile_file_from_path(filepath, options={})\n defaults = {:strict => true, :compress => false}\n options = defaults.merge options\n \n ext = filepath.split('/')[-1].split('.')[-1]\n if ext != 'wml'\n puts ext\n if options[:strict]\n raise Exception, \"Invalid extension for (#{filepath}). Must be .wml.\"\n else\n return\n end\n end\n \n file = File.open(filepath, 'rb')\n data = file.read\n \n html = Compiler.new(:text => data, :compress => options[:compress]).output\n \n temp = filepath.split('/')\n temp.pop()\n filename = temp.join('/') << '/' << filepath.split('/')[-1].split('.')[0] << '.html'\n File.open(filename, 'wb') {|f| f.write(html) }\nend",
"def compile_jasmine_javascripts\n puts \"Compiling jasmine coffee scripts into javascript...\"\n root = File.expand_path(\"../../models\", __FILE__)\n destination_dir = File.expand_path(\"../../generated/specs\", __FILE__)\n\n glob = File.expand_path(\"**/*.js.coffee\", root)\n\n Dir.glob(glob).each do |srcfile|\n srcfile = Pathname.new(srcfile)\n destfile = srcfile.sub(root, destination_dir).sub(\".coffee\", \"\")\n FileUtils.mkdir_p(destfile.dirname)\n File.open(destfile, \"w\") {|f| f.write(CoffeeScript.compile(File.new(srcfile)))}\n end\n end",
"def compile(file_or_dir, options = {})\n options = {\n check_for_changes: true,\n sub_template: false,\n collect_stats: true,\n ignore_blank_lines: true\n }.merge(options)\n @scope = options[:scope]\n # Doing here so the output_directory (requiring target load) doesn't get hit if\n # it is already defined\n options[:output_directory] ||= output_directory\n @check_for_changes = options[:check_for_changes]\n @options = options\n if options[:sub_template]\n block = options.delete(:block)\n if is_erb?(file_or_dir)\n run_erb(file_or_dir, options, &block)\n else\n f = File.open(file_or_dir)\n content = f.read\n f.close\n insert(content)\n end\n else\n Origen.file_handler.resolve_files(file_or_dir, ignore_with_prefix: '_', import: :template) do |file|\n compile_file(file, options)\n end\n end\n end",
"def javac(*args)\n options = Hash === args.last ? args.pop : {}\n rake_check_options options, :classpath, :sourcepath, :output, :javac_args, :name\n\n files = args.flatten.each { |f| f.invoke if f.respond_to?(:invoke) }.map(&:to_s).\n collect { |arg| File.directory?(arg) ? FileList[\"#{File.expand_path(arg)}/**/*.java\"] : File.expand_path(arg) }.flatten\n name = options[:name] || Dir.pwd\n\n cmd_args = []\n cp = classpath_from(options)\n cmd_args << '-classpath' << cp.join(File::PATH_SEPARATOR) unless cp.empty?\n cmd_args << '-sourcepath' << [options[:sourcepath]].flatten.join(File::PATH_SEPARATOR) if options[:sourcepath]\n cmd_args << '-d' << File.expand_path(options[:output].to_s) if options[:output]\n cmd_args += options[:javac_args].flatten if options[:javac_args]\n cmd_args += files\n unless Buildr.application.options.dryrun\n mkdir_p options[:output] if options[:output]\n info \"Compiling #{files.size} source files in #{name}\"\n trace (['javac'] + cmd_args).join(' ')\n Java.load\n ::Java::com.sun.tools.javac.Main.compile(cmd_args.to_java(::Java::java.lang.String)) == 0 or\n fail 'Failed to compile, see errors above'\n end\n end",
"def mkcompiler source=''\n VishCompiler.new source\nend",
"def run(content, params = {})\n # Add filename to load path\n Uglifier.new(params).compile(content)\n end",
"def compile_file(file, options = {})\n @current_file = Pathname.new(file)\n # This is used when templates are compiled through a test program, but can\n # be problematic when used to compile files standalone. In practice this may\n # not be an issue except when testing Origen and generating and compiling within\n # the same thread, but clearing this here doesn't seem to do any harm.\n Origen.file_handler.default_extension = nil\n begin\n Origen.log.info \"Compiling... #{relative_path_to(file)}\" unless options[:quiet]\n rescue\n Origen.log.info \"Compiling... #{file}\" unless options[:quiet]\n end\n Origen.log.info \" Created... #{relative_path_to(output_file(file, options))}\" unless options[:quiet]\n stats.completed_files += 1 if options[:collect_stats]\n if is_erb?(file)\n output = run_erb(file, options)\n f = output_file(file, options).to_s\n if output.is_a?(Pathname)\n FileUtils.mv output.to_s, f\n else\n File.open(f, 'w') { |out| out.puts output }\n end\n else # Just copy it across\n out = output_file(file, options)\n # Delete the target if it already exists, this prevents permission denied errors when copying\n FileUtils.rm_f(out.to_s) if File.exist?(out.to_s)\n FileUtils.cp(file.to_s, out.dirname.to_s)\n end\n if options[:zip]\n `gzip -f -9 #{output_file(file, options)}`\n else\n if @check_for_changes\n check_for_changes(output_file(file, options), reference_file(file, options),\n comment_char: Origen.app.tester ? Origen.app.tester.program_comment_char : nil,\n compile_job: true, ignore_blank_lines: options[:ignore_blank_lines])\n end\n end\n end",
"def compile(arg, is_file, op, level, type)\n self.op = op.blank? ? DEFAULT_SERVICE : op\n self.level = level.blank? ? DEFAULT_LEVEL : level\n self.format_type = type.blank? ? DEFAULT_TYPE : type\n self.file = \"\"\n value = true\n\n begin\n if is_file\n js_code = read_file(arg)\n self.file = arg\n else\n js_code = arg\n end\n resp, data = post_to_cc(create_json_request(js_code))\n\n if $debug\n puts \"#DEBUG data \\n\"\n p data\n puts \"\\n\"\n end\n\n rescue StandardError => e\n return e\n end\n\n parse_json_output(data)\n end",
"def compile\n Dir.chdir(build_path) do\n do_compile\n end\n end",
"def compile(name)\n Rule::Compile.build(file(name))\n end",
"def compile_to_c\n statements.collect { |s| s.compile_to_c }.join(\"\\n\")\n end",
"def compile\n lexer = Bolverk::ASM::Lexer.new(@stream)\n tokens = lexer.scan\n\n parser = Bolverk::ASM::Parser.new(tokens)\n parse_tree = parser.parse\n\n generator = Bolverk::ASM::Generator.new(parse_tree)\n source = generator.generate\n\n return source\n end",
"def c src, options = {}\n options = {\n :expand_types => true,\n }.merge options\n self.generate src, options\n end",
"def compile_js_sources(base_dir, definitions)\n chdir(base_dir) do\n definitions.each do |definition|\n\n jscompressor = :uglifyjs\n\n sources = definition['inputs'].join(' ')\n\n sh %{cat #{sources} > #{definition['output']}.tmp}\n sh %{#{jscompressor} #{definition['output']}.tmp > #{definition['output']}}\n rm definition['output'] + '.tmp'\n end\n end\nend",
"def compile(path)\n\tif isExecutable(path) and not $link\n\t\t$keep = true\n\t\treturn path\n\tend\n\t\n\tbinaryPath = File.join($testDir, File.basename($link ? $source[0] : path, File.extname(path)))\n\n\tcompilerOutput = Tempfile.new(\"compiler\")\n\n# FIXME: If $link is true, it will only check the extension of the first argument.\n\tif File.extname($link ? $source[0] : path) == \".c\"\n\t\tsystem \"gcc -O2 -o \\\"#{binaryPath}\\\" #{path} &> #{compilerOutput.path}\"\n\telsif File.extname($link ? $source[0] : path) == \".cpp\"\n\t\tsystem \"g++ -O2 -o \\\"#{binaryPath}\\\" #{path} &> #{compilerOutput.path}\"\n\telse\n\t\t$stderr.puts \"This program only works with C or C++ source code.\"\n\t\texit 1\n\tend\n\n\tcompilerMessages = compilerOutput.read\n\n\tunless compilerMessages.empty?\n\t\tunless File.exists?(binaryPath)\n\t\t\t$stderr.puts red(\"Couldn't compile #{path}.\")\n\t\tend\n\t\t$stderr.puts yellow(\"Compiler output for #{path}:\")\n\t\t$stderr.puts compilerMessages\n\tend\n\n\tcompilerOutput.close\n\tcompilerOutput.unlink\n\n\tunless File.exists?(binaryPath)\n\t\tcleanup\n\t\texit 1\n\tend\n\n\treturn binaryPath\nend",
"def compile_to_c\n \"\"\n end",
"def source_compiler\n @source_compiler ||= Sprockets::Environment.new.tap do |env|\n env.append_path File.expand_path(\"./js\", File.dirname(__FILE__))\n end\n end",
"def js\n puts 'Compressing JS files...'\n `java -jar ./_scripts/yuicompressor-2.4.2.jar ../www/_res/js/uncompressed/main.js -o ../www/_res/js/main.js`\n # --nomunge\nend",
"def compile(filename)\n check_cookie\n Native::magic_compile(@cookie, filename);\n end",
"def compile_jasmine_javascripts\n puts \"Compiling jasmine coffee scripts into javascript...\"\n root = File.expand_path(\"../../../../spec/javascripts/coffee\", __FILE__)\n destination_dir = File.expand_path(\"../../generated/specs\", __FILE__)\n\n glob = File.expand_path(\"**/*.js.coffee\", root)\n\n Dir.glob(glob).each do |srcfile|\n srcfile = Pathname.new(srcfile)\n destfile = srcfile.sub(root, destination_dir).sub(\".coffee\", \"\")\n FileUtils.mkdir_p(destfile.dirname)\n File.open(destfile, \"w\") {|f| f.write(CoffeeScript.compile(File.new(srcfile)))}\n end\n end",
"def uglify(file)\n #'hello world'\n template = Tilt.new(File.join('views',file)).render(self)\n Uglifier.compile(template)\n #Uglifier.compile(ERB.new(File.read(File.join('views', file))).result(binding).force_encoding('UTF-8').gsub(/^#.*?\\n/,''))\n end",
"def compile_exec()\n compile\n exec\n end",
"def closurize(requires, includes, dest_file, format)\n\t\t\tcmds = [\"python #{TASKS_JAVASCRIPT_DIR}/calcdeps.py\"]\n\t\t\tcmds << \"-i #{requires}\"\n\t\t\tincludes.each do |dir|\n\t\t\t\t\tcmds << \"-p #{dir}\"\n\t\t\tend\n\t\t\tcmds << \"-o #{format}\"\n\t\t\tcmds << \"-c #{TASKS_JAVASCRIPT_DIR}/compiler.jar\"\n\n\t\t\tmkdir_p File.dirname(dest_file)\n\t\t\tcmds << \"--output_file=#{dest_file}\" if format != 'list'\n\t\t\tsh cmds.join(\" \")\n\n\t\t\tputs(\"Compiled javascript in [#{format}] mode\")\n\tend",
"def jsHint ( file )\n puts \"JSHinting #{file}\"\n errors = Jshintrb.lint( File.read(file) )\n if errors.length > 0\n puts\n errors.map do |err|\n puts (\" line %d, column %d: %s\\n\" +\n \" %s\\n\" +\n \" %s^\\n\") % [\n err['line'], err['character'], err['reason'],\n err['evidence'],\n \"~\" * (err['character'] - 1)\n ]\n end\n fail \"JSHint failed\"\n end\n\n File.read(file)\n end",
"def compile_package_task(input, output=input)\n js_tasks = SproutCore::Compiler::Preprocessors::JavaScriptTask.with_input \"packages/#{input}/lib/**/*.js\", \".\"\n SproutCore::Compiler::CombineTask.with_tasks js_tasks, \"#{SproutCore::Compiler.intermediate}/#{output}\"\nend",
"def compile_package_task(input, output=input)\n js_tasks = SproutCore::Compiler::Preprocessors::JavaScriptTask.with_input \"packages/#{input}/lib/**/*.js\", \".\"\n SproutCore::Compiler::CombineTask.with_tasks js_tasks, \"#{SproutCore::Compiler.intermediate}/#{output}\"\nend",
"def evaluate(scope, locals, &block)\n if ::Requirejs::BuildConfig.new(file).exists?\n compiler = ::Requirejs::Compiler.new(scope: scope, data: data, file: file)\n @output ||= compiler.exec\n else\n @output ||= data\n end\n end",
"def compile(files, file)\n\n # setup the output buffer with the base file\n output_buffer = File.read(File.path(file))\n\n # loop through import files and substitute imports\n files.each do |key, import_file|\n output_buffer = import(output_buffer, key, import_file)\n end\n\n File.open(output_filename(file), 'w') do |file|\n file.write(output_buffer)\n end\n end",
"def _inter source\n c = compile source\n cifrom c\nend",
"def path_to_javascript(source, options = T.unsafe(nil)); end",
"def code_gen(destination = nil, syntax)\n code = syntax == :scss ? @tree.to_scss : @tree.to_sass\n return code unless destination\n if destination.is_a?(String)\n open_file(destination, 'w') { |file| file.write(code) }\n else\n destination.write(code)\n end\n end",
"def compile force:nil, production:nil\n @production = production || false\n method_name = 'compile_%s' % @source.to_s.split('.').last.downcase\n\n if respond_to?(method_name, true)\n (!force && cached) || ( process_erb; send(method_name))\n else\n @source.read\n end\n end",
"def compile(filename)\n # First pass - define labels\n elements.each do |codeline|\n codeline.register_labels\n @@position += codeline.size\n end\n\n # Second pass - write to binary file\n File.open(filename, 'wb') do |f|\n elements.each do |codeline|\n f.write codeline.to_bin\n end\n end\n end",
"def compile_templates\n puts \"Compiling Templates\"\n js = V8::Context.new\n js.eval \"window = {}\"\n js.load File.join(APP_ROOT, \"public\", \"javascripts\", \"jade.js\")\n js.load File.join(APP_ROOT, \"public\", \"javascripts\", \"formtacular.js\")\n js.eval \"var jade = require('jade')\"\n js.eval \"templates = {}\"\n Dir[File.join(APP_ROOT, \"app\", \"views\", \"**\", \"*.jade\")].each do |file|\n begin\n chunks = (file.sub(/^#{APP_ROOT}\\/app\\/views/, \"\")).split(\"/\").slice(1..-1)\n (chunks.length - 1).times do |i|\n scrpt = <<-EOS\n if (templates.#{chunks.slice(0..i).join(\".\")} == undefined) {\n templates.#{chunks.slice(0..i).join(\".\")} = {};\n };\n EOS\n js.eval scrpt\n end\n chunks[-1] = chunks[-1].sub(/\\.jade$/, \"\")\n js['template_text'] = File.read(file)\n js.eval \"templates.#{chunks.join(\".\")} = jade.compile(template_text)\"\n rescue\n raise \"ERROR IN TEMPLATE: #{file} (#{$!})\"\n end\n end\n File.open(File.join(APP_ROOT, \"public\", \"javascripts\", \"rocket_templates.js\"), \"w\") {|f| f.write recursive_object_dump(js[\"templates\"], \"templates\")}\n puts \"Finished compiling templates.\"\n end",
"def compile\n Milkrun.say \"Cleaning and assembling a new #{task} build\"\n `./gradlew clean assemble#{task}`\n @assembled = true\n Milkrun.say \"Package built to #{path}\"\n path\n end",
"def main\n\n begin\n\n raise \"Usage: #{$0} source_file target_file\" unless ARGV.length == 2\n\n myAcDc = AcDcCompiler.new(ARGV)\n myAcDc.get_input\n myAcDc.parse\n myAcDc.optimize\n myAcDc.code_generate \n rescue Exception => e # Compile failed.\n puts e.message\n end\n \nend",
"def generate_c_source( dir, filename = self.name + '.c' )\r\n # TODO\r\n puts \"generating \" + dir + '/' + filename\r\n end",
"def compile_file(filename = @filename)\n\t\t\tcached = @controller.cached_tilts[filename]\n\t\t\treturn cached if @cache && cached\n\n\t\t\tcompiled = Tilt.new(filename, nil, @tilt_options)\n\t\t\t@controller.cached_tilts[filename] ||= compiled if @cache\n\t\t\tcompiled\n\t\tend",
"def compile(mod); end",
"def compile\n read_yml if File.exists?(@project)\n\n default_options = {}\n other_options = {}\n\n @compile_options.each do |k,v| \n if /default/.match(k)\n default_options[k] = v\n else\n other_options[k] = v\n end\n end\n\n command = \"#{@flex_sdk_bin}#{@compiler}\"\n other_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n default_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n command += \" #{@document_class}.as\"\n\n# puts command\n# TextMate.exit_show_html\n\n @command = command\n#TextMate.exit_show_html\n if process_output command\n# load_debugger\n display_web_player #unless ARGV[0] = \"--display\"\n# display_player\n end\nend",
"def call(template)\n Jason.compile(template.source)\n end",
"def compiled_coffeescript?\n return false unless extname == '.js'\n\n # CoffeeScript generated by > 1.2 include a comment on the first line\n if lines[0] =~ /^\\/\\/ Generated by /\n return true\n end\n\n if lines[0] == '(function() {' && # First line is module closure opening\n lines[-2] == '}).call(this);' && # Second to last line closes module closure\n lines[-1] == '' # Last line is blank\n\n score = 0\n\n lines.each do |line|\n if line =~ /var /\n # Underscored temp vars are likely to be Coffee\n score += 1 * line.gsub(/(_fn|_i|_len|_ref|_results)/).count\n\n # bind and extend functions are very Coffee specific\n score += 3 * line.gsub(/(__bind|__extends|__hasProp|__indexOf|__slice)/).count\n end\n end\n\n # Require a score of 3. This is fairly arbitrary. Consider\n # tweaking later.\n score >= 3\n else\n false\n end\n end",
"def compile(template_name, compiled_content)\n self.kramdown_source.compile(template_name, compiled_content)\n end",
"def script_source(file_name)\n Template.new(LUA_PATHNAME).render(script_path(file_name))\n end",
"def compile(infile, outfile, asm)\n\n File.open(infile, 'r') do |input|\n File.open(outfile, 'wb') do |out|\n compiler = Compiler.new(input, asm)\n out.print(compiler.compile)\n end\n end\n\nrescue ParseError => e\n error(\"[error] #{e.message}\")\n error(\"[context] #{e.context}\")\n # error(\"Aborting!\")\n error(e.caller)\n exit(1)\nend",
"def cleancode(arg, file, level, type)\n ['errors', 'warnings', 'compiled_code'].each do |x|\n str = JSCompiler.compile(arg, file, x, level, type)\n return str unless str.eql?(\"No \" + x)\n end\n end",
"def compile(template_source)\n # if RUBY_VERSION >= '1.9'\n # template_source=template_source.sub(/\\A#coding:.*\\n/, '') \n # end\n # ::ERB.new(\"<% __in_erb_template=true %>#{template_source}\", nil, \"-\", '@output_buffer')\n\n Erubis::Eruby.new(template_source.utf_or_die!)\n \n end",
"def render compiler, opt=@options\n template = File.read(opt[:template])\n renderer = ERB.new(template)\n output = renderer.result(binding)\nFile.write(opt[:ofile], output)\n FileUtils.chmod('+x', opt[:ofile])\nend",
"def compile!\n new_version = generate_version\n new_abs_path = abs_path(new_version)\n return @compiled_path = current_file_path if @compile_files.empty?\n\n FileUtils.mkdir_p @min_dir unless File.exist?(@min_dir)\n js? ? compile_js!(new_abs_path) : compile_css!(new_abs_path)\n\n if not_changed?(new_abs_path, current_abs_path)\n puts \"file not changed, use current file (#{current_file_path})\"\n FileUtils.rm_rf new_abs_path\n @compiled_path = current_file_path\n else\n puts \"new file version (#{file_path(new_version)}) created\"\n @compiled_path = file_path(new_version)\n end\n end",
"def compile\n return if changed_ruby_files.empty?\n\n errors = changed_ruby_files.each_with_object([]) do |file, es|\n output = `ruby -cw \"#{file}\" 2>&1`\n next if output == \"Syntax OK\\n\"\n\n es << output\n end\n heading('Ruby Warnings', errors.join) unless errors.empty?\n end"
] | [
"0.8419428",
"0.7679755",
"0.73445517",
"0.708651",
"0.6729183",
"0.6598666",
"0.65209705",
"0.6261103",
"0.60851264",
"0.6068642",
"0.5991296",
"0.59836286",
"0.59097636",
"0.5909609",
"0.5902206",
"0.5898093",
"0.5832379",
"0.58244824",
"0.5816169",
"0.5814589",
"0.5757938",
"0.5753424",
"0.57361",
"0.57000554",
"0.5691088",
"0.56234753",
"0.56215733",
"0.56087106",
"0.56047046",
"0.5597065",
"0.5560712",
"0.5552754",
"0.5511035",
"0.5506444",
"0.5497132",
"0.5448652",
"0.5428161",
"0.5427972",
"0.54183733",
"0.54183733",
"0.54183733",
"0.54168797",
"0.5413344",
"0.5405685",
"0.54003227",
"0.53835344",
"0.5365845",
"0.53644204",
"0.53544766",
"0.5347106",
"0.5331199",
"0.5315499",
"0.53063565",
"0.5300597",
"0.5286447",
"0.52807033",
"0.5266289",
"0.5260786",
"0.5255832",
"0.52451944",
"0.5219045",
"0.52099144",
"0.5179659",
"0.5178828",
"0.5169339",
"0.5156907",
"0.5153156",
"0.515032",
"0.51338714",
"0.5132313",
"0.51240915",
"0.51225054",
"0.5112684",
"0.50838166",
"0.5065033",
"0.5065033",
"0.50639874",
"0.50321937",
"0.50273055",
"0.502339",
"0.50099725",
"0.50058097",
"0.50024146",
"0.49752632",
"0.49295565",
"0.49255246",
"0.491848",
"0.4895736",
"0.4892592",
"0.48917",
"0.4889844",
"0.48740003",
"0.48661563",
"0.48424575",
"0.48314127",
"0.48292038",
"0.4822476",
"0.48101228",
"0.4808568",
"0.47869006"
] | 0.7481742 | 2 |
GET /offers GET /offers.json | def index
@offers = Offer.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @offers = Offer.all\n\n render json: @offers\n end",
"def get_offers\n unless get_connection_object.headers.has_key?(\"X-Auth-Token\")\n raise \"Please authenticate() to see your offers\"\n end\n get('offer')\n end",
"def index\n @offers = Offer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def offers\n authenticated_post(\"offers\").body\n end",
"def index\n @offers = Offer.all\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n format.html { @offers }\n end\n end",
"def offers\n return nil unless have_key?\n url = \"/v1/offers\"\n #Hashie::Mash.new(\n self.class.post(url, :headers => headers_for(url)).parsed_response\n end",
"def index\n @offers = Offer.all\n @offer_codes = OfferCode.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def get(params = {})\n client.get(\"/v1/shopping/hotels/#{@hotel_id}/hotel-offers\", params)\n end",
"def show\n render json: @offer\n end",
"def show\n render json: @offer\n end",
"def index\n\n @offers = Offer.order(:id)\n\n render( {json: @offers}.merge set_render_options )\n\n end",
"def index\n @offers = getmydata(\"Offer\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @public_offers = @club.public_offers\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @offers = Offer.all\n \n end",
"def show\n @breadcrumb = 'read'\n @offer = Offer.find(params[:id])\n @items = @offer.offer_items.paginate(:page => params[:page], :per_page => per_page).order('id')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def index\n @accepted_offers = AcceptedOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @accepted_offers }\n end\n end",
"def show\n @breadcrumb = 'read'\n @sale_offer = SaleOffer.find(params[:id])\n @items = @sale_offer.sale_offer_items.paginate(:page => params[:page], :per_page => per_page).order('id')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_offer }\n end\n end",
"def index\n if params[:for_applicant]\n @offers = current_user.applicant.offers\n elsif params[:for_positions]\n @offers = []\n current_user.positions.each { |offer| @offers << offer }\n else\n @offers = Offer.all\n end\n\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n @offer_quizzes = @offer.quizzes\n @offer_packages = @offer.packages\n @quizzes = Quiz.excluding(@offer.quizzes)\n @packages = Package.excluding(@offer.packages)\n @offer_users = @offer.offer_users\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def getOffers\n if current_contractor || current_user\n offers_per_post = Offer.where(post_id: params[:post_id])\n @offers = offers_per_post.order(created_at: :asc).limit(10)\n\n render json: @offers.as_json(include: [{contractor: { methods: [:avatar_url] }}, :post,])\n end\n end",
"def index\n @offers = Offer.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers.to_json, :callback => params[:callback] }\n end\n end",
"def index\n @shop_platinum_offers = Shop::PlatinumOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_platinum_offers }\n end\n end",
"def index\n if params[:event_id].blank?\n @offerings = Offering.all\n else\n @offerings = Offering.find_all_by_event_id params[:event_id]\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offerings }\n end\n end",
"def new\n @offers = Offer.all\n @price = Price.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @price }\n end\n end",
"def index\n @category_offers = CategoryOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @category_offers }\n end\n end",
"def response(env)\n uid = env.params['uid']\n if uid.nil?\n [200, {}, erb(:default, :locals => {:uid => nil, :pub0 => nil, :page => nil})]\n else\n pub0 = env.params['pub0']\n page = env.params['page']\n begin\n\n offers = Application.offersService.getOffers(uid, pub0, page)\n [200, {}, erb(:offers, :locals => {:offers => offers, :uid => uid, :pub0 => pub0, :page => page})]\n rescue Exception => error\n [200, {}, erb(:error, :locals => {:errorMsg => error.message, :uid => uid, :pub0 => pub0, :page => page})]\n end\n end\n end",
"def new\n @offer = Offer.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def new\n @offer = Offer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def new\n @offer = Offer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def new\n @offer = Offer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def offers; global.offers end",
"def show\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientsOffers }\n end\n end",
"def index\n if backend_request?\n @shop_resource_offers = Shop::ResourceOffer.all\n else \n @shop_resource_offers = Shop::ResourceOffer.where([\"(started_at is null or started_at < ?) and (ends_at is null or ends_at > ?)\", Time.now, Time.now])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_resource_offers }\n end\n end",
"def index\n @offerers = Offerer.all\n end",
"def show\n @accepted_offer = AcceptedOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @accepted_offer }\n end\n end",
"def list\n offers = []\n if params[:product_id]\n product = Product.find(params[:product_id])\n if product && (product.sold_status != Product.SOLD_SOLD || params[:allow_sold])\n if product.user.id == @current_user.id && params[:include_offers_made_by_other_users] == \"true\"\n product.offers.each do |offer|\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: product.user.id\n },\n thumbnail: product.thumbnail,\n product_id: product.id,\n product_name: product.product_name,\n product_price: product.price\n },\n product_name: product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n elsif product.user.id != @current_user.id && params[:include_offers_made_by_current_user] == \"true\"\n offer = Offer.find_by(product_id: product.id, user_id: @current_user.id)\n if offer\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: product.user.id,\n\t\t\t\t username: product.user.username\n },\n thumbnail: product.thumbnail,\n product_id: product.id,\n product_name: product.product_name,\n product_price: product.price\n },\n product_name: product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n end\n else\n render status: 404, json: {error: true}\n end\n else\n if params[:include_offers_made_by_current_user] == \"true\"\n @current_user.offers.each do |offer|\n if (offer.product.sold_status != Product.SOLD_SOLD || params[:allow_sold])\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: offer.product.user.id,\n\t\t\t\t username: offer.product.user.username\n },\n thumbnail: offer.product.thumbnail,\n product_id: offer.product.id,\n product_name: offer.product.product_name,\n product_price: offer.product.price\n },\n product_name: offer.product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n end\n end\n if params[:include_offers_made_by_other_users] == \"true\"\n @current_user.products.each do |product|\n if (product.sold_status != Product.SOLD_SOLD || params[:allow_sold])\n product.offers.each do |offer|\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: product.user.id,\n username: product.user.username\n },\n thumbnail: product.thumbnail,\n product_id: product.id,\n product_name: product.product_name,\n product_price: product.price\n },\n product_name: product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n end\n end\n end\n end\n render status: 200, json: {offers: offers}\n end",
"def show\n @ms_offer = MsOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ms_offer }\n end\n end",
"def read\n offer = Offer.find(params[:id])\n if offer\n if @current_user.id == offer.user.id || @current_user.id == offer.product.user.id\n render status: 200, json: {\n offer_id: offer.id,\n product: {\n product_id: offer.product.id,\n product_name: offer.product.product_name,\n product_type: offer.product.product_type,\n product_sold_status: offer.product.sold_status,\n price: offer.product.price,\n description: offer.product.description,\n thumbnail: offer.product.thumbnail,\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n else\n render status: 472, json: {error: true}\n end\n else\n render status: 404, json: {error: true}\n end\n end",
"def index\n @offer_codes = OfferCode.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offer_codes }\n end\n end",
"def show\n @shop_resource_offer = Shop::ResourceOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_resource_offer }\n end\n end",
"def index\n @aid_offers = AidOffer.all\n end",
"def show\n @shop_bonus_offer = Shop::BonusOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_bonus_offer }\n end\n end",
"def index\n @general_offers = GeneralOffer.all\n end",
"def show\n offer = Offer.find params[:id]\n @offer = render_to_string partial: 'offers/offer.json', locals: { offer: offer }\n respond_to do |format|\n format.html { render layout: false }\n end\n end",
"def index\n @auto_offers = AutoOffer.all\n end",
"def index\n @offers = Offer.search_offers(params[:keyword],\n params[:pick_up_point], params[:drop_off_point],\n params[:vancancy_lower_limit], params[:vancancy_upper_limit],\n params[:cost_lower_limit], params[:cost_upper_limit])\n end",
"def show\n @shop_fb_credit_offer = Shop::FbCreditOffer.find(params[:id])\n\n @prices = []\n\n JSON.parse(@shop_fb_credit_offer.prices).each do |o|\n @prices << o\n end\n\n respond_to do |format|\n format.html { render layout: 'empty' }\n format.json { render json: @shop_fb_credit_offer }\n end\n end",
"def show\n @public_offer = PublicOffer.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @public_offer }\n end\n end",
"def index\n if api_request?\n @shop_special_offers = Shop::SpecialOffer.buyable_by_character(current_character)\n else\n @shop_special_offers = Shop::SpecialOffer.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: include_root(@shop_special_offers, :special_offer) }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n checkaccountobject(\"offers\",@offer)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def won_offers(options={})\n won_status.offers.all(options)\n end",
"def new\n @offer = Offer.new\n @user = current_user\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def index\n \n if user_signed_in?\n \n if current_user.is_admin\n \n @offers = Offer.all\n\n else\n\n redirect_to root_path\n\n end\n\n else\n\n redirect_to root_path\n\n end\n\n end",
"def show\n @offer_customer = OfferCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer_customer }\n end\n end",
"def offers(location = @location, publisher = @publisher)\n raise ArgumentError, \"No location specified\" unless location\n raise ArgumentError, \"No publisher specified\" unless publisher\n\n url = build_url(location, 'publishers', publisher, 'artifacttypes', 'vmimage', 'offers')\n\n JSON.parse(rest_get(url)).map{ |element| element['name'] }\n end",
"def index\n @special_offers = SpecialOffer.all\n end",
"def index\n @shop_fb_credit_offers = Shop::FbCreditOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_fb_credit_offers }\n end\n end",
"def index\n @offers = Offer.where(customer: current_user.customer)\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def show\n @job_offer = JobOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_offer }\n end\n end",
"def index\n @offers = Offer.search(params[:search])\nend",
"def offers\n @offers ||= offer_map.values.map { |v| v[:offer] }\n end",
"def show \n # @offer = Offer.find(params[:id])\nend",
"def create\n @offer = Offer.new(offers_params)\n\n respond_to do |format|\n if @offer.save\n format.jsonapi { render jsonapi: @offer, status: :created }\n else\n format.jsonapi { render jsonapi: @offer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def buyers\n result = get_buyers(params, false)\n render json: result, status: 200\n end",
"def new\n @shop_resource_offer = Shop::ResourceOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_resource_offer }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n \n @venue_name= Venue.find(@offer.venue_id).venue_name\n @offer_opinions = @offer.opinions\n if @offer_opinions.first\n @offer_opinions = Opinion.all_offer_opinions(@offer.id)\n #@offer_opinions = @offer_opinions.joins('LEFT OUTER JOIN users ON users.id = opinions.user_id').select('title, description, points, username')\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def index\n @project_offers = Project::Offer.all\n end",
"def new\n @ms_offer = MsOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ms_offer }\n end\n end",
"def show\n @shop_platinum_offer = Shop::PlatinumOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_platinum_offer }\n end\n end",
"def new\n @accepted_offer = AcceptedOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accepted_offer }\n end\n end",
"def show\n @offer_code = OfferCode.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer_code }\n end\n end",
"def index\n @course_offers = CourseOffer.all\n end",
"def index\n @shop_bonus_offers = Shop::BonusOffer.order('resource_id asc, currency asc, price asc')\n \n respond_to do |format|\n format.html # index.html.erb\n format.json do\n @shop_bonus_offers.each do |offer|\n offer[:resource_effect] = offer.effect_for_character(current_character) \n end\n \n render json: @shop_bonus_offers\n end\n end\n end",
"def offers \n @host.offers.create(offer_params) if request.post?\n @offers = @host.offers\n end",
"def lost_offers(options={})\n lost_status.offers.all(options)\n end",
"def index\n @base_offer = BaseOffer.new\n @base_offers = BaseOffer.all\n end",
"def show\n @shop_special_offer = Shop::SpecialOffer.find_by_id(params[:id])\n raise NotFoundError.new('offer not found') if @shop_special_offer.nil?\n\n if api_request? && !current_character.purchases.where('external_offer_id = ? and redeemed_at is not null', @shop_special_offer.external_offer_id).empty?\n raise NotFoundError.new('offer not found')\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_special_offer }\n end\n end",
"def new\n @offer = Offer.new\n if can? :manage, @offer\n @venue_names = current_user.venues.pluck(:venue_name)\n #@venue_names = current_user.venues.select('venues.id, venue_name')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n else\n redirect_to offers_path\n end\n end",
"def new\n @clientsOffers = ClientsOffers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clientsOffers }\n end\n end",
"def new\n @offer_customer = OfferCustomer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer_customer }\n end\n end",
"def show\n render json: Agent.find(params[:id]).buyers\n end",
"def index\n @help_offers = @job_request.help_offers\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @help_offers }\n end\n end",
"def show\n @product_offer = ProductOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_offer }\n end\n end",
"def index\n authorize Offer\n\n @offers = if params[:q]\n policy_scope(Offer).search params[:q], fields: [:name]\n else\n policy_scope(Offer)\n end.select do | offer |\n offer.expire == nil || !(offer.booked?) || (offer.booked? && offer.customer == current_user.id)\n end\n @booked = Offer.all.where(\"expire > ? AND customer = ?\", Time.now, current_user.id)\n end",
"def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end",
"def offer\n @offer ||= params[:id].present? ? Offer.find(params[:id]) : Offer.find_by(listing_id: params[:listing_id])\n end",
"def show\n \n @offering = Offering.find_by_id(params[:id])\n @resource = Resource.find @offering.resource_id\n @question = Question.new\n @negociation = Negociation.new\n @questions = @offering.questions\n @event = Event.find @offering.event_id\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offering }\n end\n end",
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def new\n @shop_bonus_offer = Shop::BonusOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_bonus_offer }\n end\n end",
"def show\n render json: @pricing\n end",
"def show\n render json: @email_price_list\n end",
"def scrape_offers_for(item)\n return [] unless valid_offers_url?(item.more_offers_url)\n root = Nokogiri::HTML(get_more_offers_page(item.more_offers_url))\n scraped_offers = scrape_offers(root)\n publish(:on_offers_scrapped_for, item, scraped_offers)\n scraped_offers\n end",
"def index\n @offerte_regels = OfferteRegel.all\n end",
"def index\n client = find_client(request.headers[\"X-CLIENT-TOKEN\"], request.headers[\"X-CLIENT-EMAIL\"])\n @appointments = client.appointments.includes(:stylist).includes(:offerings).order(\"created_at DESC\")\n respond_to do |f|\n f.json {\n render :json => @appointments\n }\n end\n end",
"def list_endpoints\n render json: @endpoints, status: 200\n end"
] | [
"0.8171875",
"0.7944721",
"0.79157716",
"0.79029083",
"0.7764754",
"0.76819086",
"0.7671478",
"0.7586528",
"0.7481807",
"0.7481807",
"0.7466798",
"0.74593174",
"0.7443136",
"0.7368404",
"0.73248607",
"0.7323364",
"0.727816",
"0.7111794",
"0.70934635",
"0.70629996",
"0.70342314",
"0.69278336",
"0.69216377",
"0.6909375",
"0.6854069",
"0.6830361",
"0.68179333",
"0.68090415",
"0.6783584",
"0.6783584",
"0.6783584",
"0.678181",
"0.67570424",
"0.67471576",
"0.6746282",
"0.6736924",
"0.67006797",
"0.66957724",
"0.6669606",
"0.66637576",
"0.66555303",
"0.6652437",
"0.6636182",
"0.6632018",
"0.6625163",
"0.6623001",
"0.6613954",
"0.66076446",
"0.65794635",
"0.65770763",
"0.6565777",
"0.6534047",
"0.65305525",
"0.6528381",
"0.65265554",
"0.65046334",
"0.64607817",
"0.64542514",
"0.6431345",
"0.64211226",
"0.6415941",
"0.6402201",
"0.6347079",
"0.63454354",
"0.6334979",
"0.6320717",
"0.6317981",
"0.63089156",
"0.63082916",
"0.6289676",
"0.6286114",
"0.62814355",
"0.6280918",
"0.625472",
"0.62504566",
"0.62423635",
"0.62213683",
"0.62160456",
"0.6201632",
"0.620109",
"0.61881244",
"0.61746687",
"0.6165437",
"0.61626476",
"0.61553407",
"0.6140222",
"0.61392087",
"0.6135877",
"0.6135123",
"0.6128391",
"0.612714",
"0.61214304",
"0.6116663",
"0.611106",
"0.61106086",
"0.6106476",
"0.610159"
] | 0.73937756 | 14 |
GET /offers/1 GET /offers/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @offers = Offer.all\n\n render json: @offers\n end",
"def index\n @offers = Offer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @offers = Offer.all\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n format.html { @offers }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def show\n render json: @offer\n end",
"def show\n render json: @offer\n end",
"def get(params = {})\n client.get(\"/v1/shopping/hotels/#{@hotel_id}/hotel-offers\", params)\n end",
"def show\n @breadcrumb = 'read'\n @offer = Offer.find(params[:id])\n @items = @offer.offer_items.paginate(:page => params[:page], :per_page => per_page).order('id')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def index\n @offers = Offer.all\n @offer_codes = OfferCode.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @offers = getmydata(\"Offer\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def get_offers\n unless get_connection_object.headers.has_key?(\"X-Auth-Token\")\n raise \"Please authenticate() to see your offers\"\n end\n get('offer')\n end",
"def index\n\n @offers = Offer.order(:id)\n\n render( {json: @offers}.merge set_render_options )\n\n end",
"def offers\n authenticated_post(\"offers\").body\n end",
"def index\n @public_offers = @club.public_offers\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @offers = Offer.all\n end",
"def index\n @offers = Offer.all\n end",
"def index\n @offers = Offer.all\n end",
"def index\n @offers = Offer.all\n end",
"def index\n @offers = Offer.all\n \n end",
"def offers\n return nil unless have_key?\n url = \"/v1/offers\"\n #Hashie::Mash.new(\n self.class.post(url, :headers => headers_for(url)).parsed_response\n end",
"def index\n @accepted_offers = AcceptedOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @accepted_offers }\n end\n end",
"def show\n @breadcrumb = 'read'\n @sale_offer = SaleOffer.find(params[:id])\n @items = @sale_offer.sale_offer_items.paginate(:page => params[:page], :per_page => per_page).order('id')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_offer }\n end\n end",
"def new\n @offers = Offer.all\n @price = Price.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @price }\n end\n end",
"def new\n @offer = Offer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def new\n @offer = Offer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def new\n @offer = Offer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def show\n @accepted_offer = AcceptedOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @accepted_offer }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n @offer_quizzes = @offer.quizzes\n @offer_packages = @offer.packages\n @quizzes = Quiz.excluding(@offer.quizzes)\n @packages = Package.excluding(@offer.packages)\n @offer_users = @offer.offer_users\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def show\n @shop_resource_offer = Shop::ResourceOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_resource_offer }\n end\n end",
"def new\n @offer = Offer.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def show\n @shop_bonus_offer = Shop::BonusOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_bonus_offer }\n end\n end",
"def show\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientsOffers }\n end\n end",
"def index\n @shop_platinum_offers = Shop::PlatinumOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_platinum_offers }\n end\n end",
"def index\n if params[:event_id].blank?\n @offerings = Offering.all\n else\n @offerings = Offering.find_all_by_event_id params[:event_id]\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offerings }\n end\n end",
"def read\n offer = Offer.find(params[:id])\n if offer\n if @current_user.id == offer.user.id || @current_user.id == offer.product.user.id\n render status: 200, json: {\n offer_id: offer.id,\n product: {\n product_id: offer.product.id,\n product_name: offer.product.product_name,\n product_type: offer.product.product_type,\n product_sold_status: offer.product.sold_status,\n price: offer.product.price,\n description: offer.product.description,\n thumbnail: offer.product.thumbnail,\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n else\n render status: 472, json: {error: true}\n end\n else\n render status: 404, json: {error: true}\n end\n end",
"def show\n offer = Offer.find params[:id]\n @offer = render_to_string partial: 'offers/offer.json', locals: { offer: offer }\n respond_to do |format|\n format.html { render layout: false }\n end\n end",
"def show\n @public_offer = PublicOffer.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @public_offer }\n end\n end",
"def show\n @ms_offer = MsOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ms_offer }\n end\n end",
"def index\n if params[:for_applicant]\n @offers = current_user.applicant.offers\n elsif params[:for_positions]\n @offers = []\n current_user.positions.each { |offer| @offers << offer }\n else\n @offers = Offer.all\n end\n\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n checkaccountobject(\"offers\",@offer)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def index\n @offers = Offer.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers.to_json, :callback => params[:callback] }\n end\n end",
"def index\n @category_offers = CategoryOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @category_offers }\n end\n end",
"def show \n # @offer = Offer.find(params[:id])\nend",
"def show\n @offer_customer = OfferCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer_customer }\n end\n end",
"def getOffers\n if current_contractor || current_user\n offers_per_post = Offer.where(post_id: params[:post_id])\n @offers = offers_per_post.order(created_at: :asc).limit(10)\n\n render json: @offers.as_json(include: [{contractor: { methods: [:avatar_url] }}, :post,])\n end\n end",
"def index\n if backend_request?\n @shop_resource_offers = Shop::ResourceOffer.all\n else \n @shop_resource_offers = Shop::ResourceOffer.where([\"(started_at is null or started_at < ?) and (ends_at is null or ends_at > ?)\", Time.now, Time.now])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_resource_offers }\n end\n end",
"def index\n @general_offers = GeneralOffer.all\n end",
"def show\n @shop_platinum_offer = Shop::PlatinumOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_platinum_offer }\n end\n end",
"def index\n @offerers = Offerer.all\n end",
"def show\n @job_offer = JobOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_offer }\n end\n end",
"def response(env)\n uid = env.params['uid']\n if uid.nil?\n [200, {}, erb(:default, :locals => {:uid => nil, :pub0 => nil, :page => nil})]\n else\n pub0 = env.params['pub0']\n page = env.params['page']\n begin\n\n offers = Application.offersService.getOffers(uid, pub0, page)\n [200, {}, erb(:offers, :locals => {:offers => offers, :uid => uid, :pub0 => pub0, :page => page})]\n rescue Exception => error\n [200, {}, erb(:error, :locals => {:errorMsg => error.message, :uid => uid, :pub0 => pub0, :page => page})]\n end\n end\n end",
"def index\n @aid_offers = AidOffer.all\n end",
"def index\n @auto_offers = AutoOffer.all\n end",
"def new\n @offer = Offer.new\n @user = current_user\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n end",
"def show\n @shop_fb_credit_offer = Shop::FbCreditOffer.find(params[:id])\n\n @prices = []\n\n JSON.parse(@shop_fb_credit_offer.prices).each do |o|\n @prices << o\n end\n\n respond_to do |format|\n format.html { render layout: 'empty' }\n format.json { render json: @shop_fb_credit_offer }\n end\n end",
"def new\n @shop_resource_offer = Shop::ResourceOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_resource_offer }\n end\n end",
"def offer\n @offer ||= params[:id].present? ? Offer.find(params[:id]) : Offer.find_by(listing_id: params[:listing_id])\n end",
"def offers; global.offers end",
"def index\n @special_offers = SpecialOffer.all\n end",
"def index\n if api_request?\n @shop_special_offers = Shop::SpecialOffer.buyable_by_character(current_character)\n else\n @shop_special_offers = Shop::SpecialOffer.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: include_root(@shop_special_offers, :special_offer) }\n end\n end",
"def new\n @accepted_offer = AcceptedOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accepted_offer }\n end\n end",
"def show\n @shop_special_offer = Shop::SpecialOffer.find_by_id(params[:id])\n raise NotFoundError.new('offer not found') if @shop_special_offer.nil?\n\n if api_request? && !current_character.purchases.where('external_offer_id = ? and redeemed_at is not null', @shop_special_offer.external_offer_id).empty?\n raise NotFoundError.new('offer not found')\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_special_offer }\n end\n end",
"def show\n @offer = Offer.find params[:id]\n render layout: nil\n end",
"def index\n @offer_codes = OfferCode.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offer_codes }\n end\n end",
"def index\n @base_offer = BaseOffer.new\n @base_offers = BaseOffer.all\n end",
"def show\n @offer_code = OfferCode.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer_code }\n end\n end",
"def show\n @offer = Offer.find(params[:id])\n \n @venue_name= Venue.find(@offer.venue_id).venue_name\n @offer_opinions = @offer.opinions\n if @offer_opinions.first\n @offer_opinions = Opinion.all_offer_opinions(@offer.id)\n #@offer_opinions = @offer_opinions.joins('LEFT OUTER JOIN users ON users.id = opinions.user_id').select('title, description, points, username')\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer }\n end\n end",
"def show\n @product_offer = ProductOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_offer }\n end\n end",
"def list\n offers = []\n if params[:product_id]\n product = Product.find(params[:product_id])\n if product && (product.sold_status != Product.SOLD_SOLD || params[:allow_sold])\n if product.user.id == @current_user.id && params[:include_offers_made_by_other_users] == \"true\"\n product.offers.each do |offer|\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: product.user.id\n },\n thumbnail: product.thumbnail,\n product_id: product.id,\n product_name: product.product_name,\n product_price: product.price\n },\n product_name: product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n elsif product.user.id != @current_user.id && params[:include_offers_made_by_current_user] == \"true\"\n offer = Offer.find_by(product_id: product.id, user_id: @current_user.id)\n if offer\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: product.user.id,\n\t\t\t\t username: product.user.username\n },\n thumbnail: product.thumbnail,\n product_id: product.id,\n product_name: product.product_name,\n product_price: product.price\n },\n product_name: product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n end\n else\n render status: 404, json: {error: true}\n end\n else\n if params[:include_offers_made_by_current_user] == \"true\"\n @current_user.offers.each do |offer|\n if (offer.product.sold_status != Product.SOLD_SOLD || params[:allow_sold])\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: offer.product.user.id,\n\t\t\t\t username: offer.product.user.username\n },\n thumbnail: offer.product.thumbnail,\n product_id: offer.product.id,\n product_name: offer.product.product_name,\n product_price: offer.product.price\n },\n product_name: offer.product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n end\n end\n if params[:include_offers_made_by_other_users] == \"true\"\n @current_user.products.each do |product|\n if (product.sold_status != Product.SOLD_SOLD || params[:allow_sold])\n product.offers.each do |offer|\n offers << {\n offer_id: offer.id,\n product: {\n user: {\n user_id: product.user.id,\n username: product.user.username\n },\n thumbnail: product.thumbnail,\n product_id: product.id,\n product_name: product.product_name,\n product_price: product.price\n },\n product_name: product.product_name,\n user: {\n user_id: offer.user.id,\n\t\t\t\t username: offer.user.username,\n first_name: offer.user.first_name,\n last_name: offer.user.last_name\n },\n conversation: offer.conversation ? {id: offer.conversation.id} : nil,\n offer_status: offer.offer_status,\n price: offer.price,\n created_at: offer.created_at.strftime(\"%-m/%-d/%Y\")\n }\n end\n end\n end\n end\n end\n render status: 200, json: {offers: offers}\n end",
"def new\n @ms_offer = MsOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ms_offer }\n end\n end",
"def show\n \n @offering = Offering.find_by_id(params[:id])\n @resource = Resource.find @offering.resource_id\n @question = Question.new\n @negociation = Negociation.new\n @questions = @offering.questions\n @event = Event.find @offering.event_id\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offering }\n end\n end",
"def create\n @offer = Offer.new(offers_params)\n\n respond_to do |format|\n if @offer.save\n format.jsonapi { render jsonapi: @offer, status: :created }\n else\n format.jsonapi { render jsonapi: @offer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @shop_bonus_offer = Shop::BonusOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_bonus_offer }\n end\n end",
"def show\n @offering = Offering.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offering }\n end\n end",
"def index\n @shop_bonus_offers = Shop::BonusOffer.order('resource_id asc, currency asc, price asc')\n \n respond_to do |format|\n format.html # index.html.erb\n format.json do\n @shop_bonus_offers.each do |offer|\n offer[:resource_effect] = offer.effect_for_character(current_character) \n end\n \n render json: @shop_bonus_offers\n end\n end\n end",
"def new\n @clientsOffers = ClientsOffers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clientsOffers }\n end\n end",
"def index\n @project_offers = Project::Offer.all\n end",
"def offer_page(page = 1)\n #get all offers\n if page == 1 && has_first_page_of_full_offers\n self.offers \n else\n products = self.class.find(:item_id => self.asin, \n :response_group => \"OfferListings\",\n :merchant_id => \"All\",\n :condition => \"All\",\n :offer_page => page)\n\n if products\n product = products[0] \n self.offer_pages = self.class.offer_pages_for(product)\n product.offers\n else\n []\n end\n end\n end",
"def show\n render json: Agent.find(params[:id]).buyers\n end",
"def new\n @offer_customer = OfferCustomer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer_customer }\n end\n end",
"def new\n @shop_special_offer = Shop::SpecialOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_special_offer }\n end\n end",
"def index\n @shop_fb_credit_offers = Shop::FbCreditOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_fb_credit_offers }\n end\n end",
"def manage_offer\n @offer = @host.offers.find(params[:id])\n end",
"def index\n @offers = Offer.search_offers(params[:keyword],\n params[:pick_up_point], params[:drop_off_point],\n params[:vancancy_lower_limit], params[:vancancy_upper_limit],\n params[:cost_lower_limit], params[:cost_upper_limit])\n end",
"def show\n render json: @pricing\n end",
"def new\n @offer = Offer.new\n if can? :manage, @offer\n @venue_names = current_user.venues.pluck(:venue_name)\n #@venue_names = current_user.venues.select('venues.id, venue_name')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n else\n redirect_to offers_path\n end\n end",
"def index\n @offers = Offer.where(customer: current_user.customer)\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def show\n @essay = Essay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @essay }\n end\n end",
"def update\n respond_to do |format|\n if @offer.update(offers_params)\n format.jsonapi { render :show, status: :ok, location: @offer }\n else\n format.jsonapi { render jsonapi: @offer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @vessel = Vessel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vessel }\n end\n end",
"def create\n @offer = Offer.new(offer_params)\n\n respond_to do |format|\n if @offer.save\n format.jsonapi { render :show, status: :created, location: @offer }\n else\n format.jsonapi { render jsonapi: @offer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @shop_platinum_offer = Shop::PlatinumOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_platinum_offer }\n end\n end",
"def set_offer\n @offer = Offer.find(params[:id])\n end",
"def set_offer\n @offer = Offer.find(params[:id])\n end",
"def set_offer\n @offer = Offer.find(params[:id])\n end",
"def index\n @offers = Offer.search(params[:search])\nend",
"def index\n \n if user_signed_in?\n \n if current_user.is_admin\n \n @offers = Offer.all\n\n else\n\n redirect_to root_path\n\n end\n\n else\n\n redirect_to root_path\n\n end\n\n end",
"def index\n @offers = Offer.newer_first\n end",
"def won_offers(options={})\n won_status.offers.all(options)\n end",
"def show\n @local_offer = LocalOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @local_offer }\n end\n end"
] | [
"0.7893452",
"0.7734393",
"0.76324385",
"0.7481251",
"0.7394545",
"0.7394545",
"0.73184246",
"0.7309764",
"0.72893107",
"0.72650313",
"0.7260039",
"0.72340804",
"0.7228739",
"0.72237456",
"0.71911067",
"0.71911067",
"0.71911067",
"0.71911067",
"0.71791774",
"0.7166139",
"0.7083678",
"0.7045825",
"0.6914751",
"0.6910557",
"0.6910557",
"0.6910557",
"0.6883007",
"0.68693906",
"0.68681985",
"0.6867413",
"0.68522686",
"0.6847046",
"0.6845456",
"0.681817",
"0.680954",
"0.67830443",
"0.67806697",
"0.67750555",
"0.67451155",
"0.67203206",
"0.66741914",
"0.6635292",
"0.6631235",
"0.66182816",
"0.6612149",
"0.66047055",
"0.65950644",
"0.6589422",
"0.6548254",
"0.6536184",
"0.65312934",
"0.65280575",
"0.6524745",
"0.65179366",
"0.6469483",
"0.6464563",
"0.6431625",
"0.6406943",
"0.63987625",
"0.63976395",
"0.6378094",
"0.6374538",
"0.63406223",
"0.63328373",
"0.63325363",
"0.6331919",
"0.63308525",
"0.63215524",
"0.63212305",
"0.63088375",
"0.6301514",
"0.62789303",
"0.6272164",
"0.62332237",
"0.6232876",
"0.6217999",
"0.62173826",
"0.62147695",
"0.6209059",
"0.6196952",
"0.61935544",
"0.6181759",
"0.6175685",
"0.61650723",
"0.61634755",
"0.6155079",
"0.6151077",
"0.61396194",
"0.6136377",
"0.61319035",
"0.61115915",
"0.61045104",
"0.60923135",
"0.6083651",
"0.6083651",
"0.6083651",
"0.6075369",
"0.60700166",
"0.6066723",
"0.60612416",
"0.6058473"
] | 0.0 | -1 |
Crawl Method which will hit the provided service and fetch the offers. This method will filter out the merchants and offers from the set of links fetched. A merchant is created with its respective offer. | def crawl
Offer.fetch_offers
redirect_to offers_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape_offers_for(item)\n return [] unless valid_offers_url?(item.more_offers_url)\n root = Nokogiri::HTML(get_more_offers_page(item.more_offers_url))\n scraped_offers = scrape_offers(root)\n publish(:on_offers_scrapped_for, item, scraped_offers)\n scraped_offers\n end",
"def parse_offers(locator)\n page.all(:css, locator).each do |offer_sections|\n offer_sections.all(:css, 'a').each do |offer_item|\n raw_url = offer_item['href']\n link = URI.parse(raw_url)\n offer_id = offer_id_from_url(link)\n offer = OfferFactory.make_offer(offer_id)\n if offer_id\n @offer_map[offer_id] = { click_url: link, offer: offer }\n else\n raise \"Error parsing the offer URL from the offerwall. Expected \" \\\n \"Offer ID, but got #{offer_id}. The URL parsed was #{raw_url}\"\n end\n end\n end\n end",
"def offers_parser\n SpinningCursor.run { message 'Done!' }\n\n parsed_offers = PageScrapper.page_scrapper.css('div#tab_specials_content a') # 40 deals\n SpinningCursor.stop\n parsed_offers\n end",
"def parse_from_website\n log 'Parsing from Website:'\n offer_links = HomepageParser.new(get_body_from('/leistungen/alle-leistungen-2016/index.html')).offer_links\n offer_links.each do |offer_link|\n create_and_parse_offer(offer_link)\n end\n log\n end",
"def fetch_products_with_crawler\n crawler_items.each do |crawler_item|\n products.create_from_crawler crawler_item\n end\n end",
"def offers\n return nil unless have_key?\n url = \"/v1/offers\"\n #Hashie::Mash.new(\n self.class.post(url, :headers => headers_for(url)).parsed_response\n end",
"def pull_offers(keyword, indeed_offers)\n puts \"Pulling result cards from the \\\"#{keyword}\\\" search\"\n domain = 'https://www.indeed.com.mx/'\n url = \"trabajo?q=#{keyword}&remotejob=032b3046-06a3-4876-8dfd-474eb5e7ed11\"\n html_content = open(domain + url).read\n doc = Nokogiri::HTML(html_content)\n # This var verifies if there are multiple pages of results\n next_page_button = doc.search('path')\n next_page_button = next_page_button.search('*[d=\"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z\"]').text\n unless next_page_button.empty?\n # If there are multiple pages it will iterate though all of the result pages\n gather_offers_per_page(doc, indeed_offers)\n current_page = 1\n while next_page_button.empty? == true\n next_page = \"&start=#{current_page}0\"\n html_content = open(domain + url + next_page).read\n doc = Nokogiri::HTML(html_content)\n # This var verifies if there are multiple pages of results\n gather_offers_per_page(doc, indeed_offers)\n current_page += 1\n next_page_button = doc.search('path')\n next_page_button = next_page_button.search('*[d=\"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z\"]')\n end\n else\n gather_offers_per_page(doc, indeed_offers)\n end\n end",
"def gather_offers_per_page(doc, indeed_offers)\n # Gathers all the cards on the page and collects info from each owne of them\n puts \"Pulling information from each card offer per page\"\n doc.search('.jobsearch-SerpJobCard').each do |job_card|\n # If offer already exists none will be created\n unless Offer.where(external_id: job_card['data-jk']).present?\n\n puts \"Getting information from offer #{job_card['data-jk']}, #{job_card.search('h2').text}\"\n new_offer_hash = {\n external_id: job_card['data-jk'],\n company: job_card.search('.company').text,\n title: job_card.search('h2').text,\n salary: \"\", # unrefined text, not suited for ranges yet\n category: \"Software Development\",\n position: '',\n job_type: \"\",\n tags: [],\n location: job_card.search('.location').text,\n listing_url: \"https://www.indeed.com.mx/ver-empleo?jk=#{job_card['data-jk']}\",\n candidate_required_location: \"Mexico\",\n source: 'indeed'\n }\n collect_salary(job_card, new_offer_hash)\n scrape_individual_offer(new_offer_hash, \"ver-empleo?jk=#{job_card['data-jk']}\")\n # Save each job with complete information into a list of all the offers from indeed\n\n puts 'create a new offer test'\n\n new_offer = Offer.where(external_id: new_offer_hash['id'].to_s, source: 'indeed').first_or_initialize\n copy_offer_variables(new_offer, new_offer_hash)\n new_offer.source = 'indeed'\n new_offer_hash[:tags].each do |tag_name|\n new_offer.tags << Tag.find_by(name: tag_name)\n end\n new_offer.save!\n end\n end\n end",
"def populate_offers_living_social\n testing = \"true\"\n if testing != \"true\"\n division_request = \"http://www.livingsocial.com/services/city/v2/cities\"\n @division_response = `curl \"#{division_request}\"`\n @division_response = JSON.parse(@division_response)\n else\n @division_response = {\"divisions\"=>[{\"id\"=>\"26\"}, {\"id\"=>\"864\"}]}\n end\n\n @division_response['divisions'].each do |division|\n @division_deals_request = \"http://monocle.livingsocial.com/v2/deals?city=#{URI::escape(division['id'])}&api-key=2574AD58578A419596D95D4D0549A9CF&full=1\"\n @division_deals_response = `curl \"#{@division_deals_request}\"`\n @division_deals_response = JSON.parse(@division_deals_response)\n\n @division_deals_response['deals'].each do |deal|\n if deal['sold_out'].to_s.match(/false/i)\n @offer = Offer.find_by_deal_url deal['url']\n @offer.destroy if @offer.present?\n @offer = Offer.new\n @offer.deal_id = deal['id']\n @offer.deal_end = deal['offer_ends_at']\n @offer.deal_start = deal['offer_starts_at']\n @offer.deal_source = \"livingsocial\"\n @offer.merchant_type = ''\n @offer.deal_header = deal['long_title']\n @offer.merchant_name = deal['merchant_name']\n\n @offer.division_id = division['id']\n @offer.large_image_url = deal['images'][0]['size220']\n @offer.status = \"open\"\n @offer.deal_url = deal['url']\n @offer.redemption_location = deal['locations'][0].present? ? (deal['locations'][0]['city'] ) : (\"Online Deal\")\n\n deal['options'].each do |option|\n @offer_option = @offer.offer_options.build\n \n @offer_option.value_currency = deal['currency_code']\n @offer_option.value_amount = option['original_price']\n @offer_option.price_currency = deal['currency_code']\n @offer_option.price_amount = option['price']\n\n if option['savings'].blank?\n @offer_option.discount_amount = option['original_price'].to_f - option['price'].to_f\n else\n @offer_option.discount_amount = option['savings'].to_f\n end\n\n if option['discount'].blank?\n @offer_option.discount_percent = ((100.0 * (@offer_option.value_amount.to_f - @offer_option.price_amount.to_f))/\n @offer_option.value_amount.to_f).to_i\n else\n @offer_option.discount_percent = option['discount'].to_i\n end\n \n @offer_option.price_amount = \"$\" + option['price'].to_s\n @offer_option.discount_amount = \"$\" + sprintf(\"%0.02f\", @offer_option.discount_amount).to_s\n @offer_option.discount_currency = deal['currency_code']\n @offer_option.offer_id = @offer.id\n @offer.update_trend_score(deal['orders_count'])\n @offer.save\n end\n \n deal['locations'].each do |location|\n @offer_redemption_location = @offer.offer_redemption_locations.build\n @offer_redemption_location.redemption_neighborhood = location['city']\n \n @offer_redemption_location.redemption_street_address1 = location['address1']\n @offer_redemption_location.redemption_street_address2 = location['address2']\n @offer_redemption_location.redemption_city = location['city']\n @offer_redemption_location.redemption_state = location['state']\n \n if Offer::States::List.include?(@offer_redemption_location.redemption_state)\n @offer_redemption_location.redemption_country = deal['county_code']\n else\n @offer_redemption_location.redemption_country = \"NONUS\"\n end\n\n @offer_redemption_location.redemption_zip_code = location['postal_code']\n @offer_redemption_location.redemption_lat = location['latlng'][0]\n @offer_redemption_location.redemption_lng = location['latlng'][1]\n @offer_redemption_location.redemption_phone_number = location['phone']\n @offer_redemption_location.update_woeid\n @offer_redemption_location.offer_option_id = @offer_option.id\n @offer.save\n end\n \n @offer.category_id = deal['categories'][0].to_s + '-' + deal['categories'][1].to_s\n p @offer.category_id\n @offer.get_snapgadget_category_id_living_social\n @offer.save\n end\n end\n end\n\n end",
"def scrape\n scraped_articles=[]\n scraped_articles=scrape_articles(false)\n # Iterate through the API List\n scraped_articles['response']['docs'].each do |item|\n process_item (item)\n end\n end",
"def scrape\n setup_capybara\n\n categories = []\n each_category do |name, href|\n categories << { name: name, url: href }\n end\n\n categories.map do |category|\n cat = Category.new(category[:name], [])\n each_course category[:url] do |name, type|\n cat.courses << Course.new(name, type)\n end\n cat\n end\n end",
"def offers\n authenticated_post(\"offers\").body\n end",
"def fetch_products\n if Settings.ebay.try(:crawler)\n fetch_products_with_crawler\n else\n fetch_products_with_api\n end\n end",
"def scrape_campaigns\n # Initialize crawler\n more_campaigns = true\n campaign_page = 0\n transalt_campaigns = []\n\n puts \"Scraping campaigns...\"\n # Collect all campaigns\n while more_campaigns do\n puts \"Scraping ?page=#{campaign_page}\"\n scraper = CampaignCrawler.new(campaign_page)\n output = scraper.crawl\n\n transalt_campaigns = transalt_campaigns + output['campaigns']\n\n output['campaigns'].empty? ? (more_campaigns = false) : campaign_page +=1\n end\n\n puts \"Scraped #{campaign_page} pages\\n\\n\"\n\n transalt_campaigns\n end",
"def crawl\n update_all_feeds\n fetch_and_store_articles\n end",
"def initialize merchant_url, *args\n @options = args.extract_options!\n @url = merchant_url\n @merchant_url = self.class.format_url @url\n @host_provider = URI(@merchant_url).host\n @errors = []\n case self.class.who_is_merchant(@merchant_url)\n when RegisteredMerchantList::REGISTERED_MERCHANT[:amazon]\n \tfind_product_amazon @merchant_url\n\n when RegisteredMerchantList::REGISTERED_MERCHANT[:cjunction][:bestbuy]\n \tfind_product_cj @merchant_url\n\n when RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:rakuten]\n find_product_rakuten @merchant_url, @options[:linkshare][:token], RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:mid]\n\n when RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:tiger_direct]\n find_product_tiger_direct @merchant_url, @options[:linkshare][:token], RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:mid]\n\n else\n @product_name = nil\n @description = nil\n @list_price = nil\n @currency_code = nil\n @expiry_date = nil\n @image_url = nil\n @details_url = nil\n @final_price = nil\n @categories = nil\n @errors << \"Unable to retrive from api\"\n end\n end",
"def scrape_individual_offer(offer_object, url)\n puts \"Pulling details from posting #{url}\"\n domain = 'https://www.indeed.com.mx/'\n html_content = open(domain + url).read\n doc = Nokogiri::HTML(html_content)\n description = doc.search('.jobsearch-jobDescriptionText')\n offer_object[:description] = description # unrefined but workable\n collect_posting_date(doc, offer_object)\n collect_job_type(description.text.downcase, offer_object)\n collect_tags_indeed(description.text.downcase, offer_object)\n sleep 0.7\n end",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def index\n @offers = Offer.search_offers(params[:keyword],\n params[:pick_up_point], params[:drop_off_point],\n params[:vancancy_lower_limit], params[:vancancy_upper_limit],\n params[:cost_lower_limit], params[:cost_upper_limit])\n end",
"def offer_page(page = 1)\n #get all offers\n if page == 1 && has_first_page_of_full_offers\n self.offers \n else\n products = self.class.find(:item_id => self.asin, \n :response_group => \"OfferListings\",\n :merchant_id => \"All\",\n :condition => \"All\",\n :offer_page => page)\n\n if products\n product = products[0] \n self.offer_pages = self.class.offer_pages_for(product)\n product.offers\n else\n []\n end\n end\n end",
"def crawl\n if not @crawling\n @completed = false\n @located_products = []\n \n @thread = Thread.new { \n traverse(@base_url) \n @crawling = false\n @completed = true\n }\n\n @crawling = true\n else\n raise \"Already crawling. Stop current crawl job before starting another.\"\n end\n end",
"def crawl\n recursive_explore([@origin_url],1)\n end",
"def filterProviderOffer(links)\n useless_links = links.pop #take the offers\n links.delete(useless_links)\n links\n end",
"def find_links_to(url, &block)\n url, selector = if url.kind_of? Array\n [url[1], url[0]]\n else\n [url, 'a']\n end\n \n links = (@data/selector).find_all do |link|\n link[:href].match(strip_url_params(url)) if link and link[:href]\n end\n \n links = links.compact.collect { |link| [link[:href], link.inner_text] }.uniq[0..@_hits - 1]\n \n links.collect do |link|\n yield link[0]\n end\n end",
"def all_new_ads(url=nil)\n\tsite = 'http://saudi.dubizzle.com'\n\turl = site+\"/ar/items-for-sale/search/\" if(url==nil)\n\tproceed = true\n\twhile proceed\n \t\tputs \"Fetching the ads from \"+url\n\t\tdoc = Nokogiri::HTML(open(url))\n\t\tnothing_found = doc.css('d-no-results__heading')\n\t\tif(nothing_found.children && nothing_found.children.length>0)\n\t\t\treturn\n\t\tend\n\t\tcontents = doc.at_css('.d-listing').css('.d-listing__item')\n\t\tputs 'found '+contents.length.to_s+' items to scan.'\n\t\tcontents.each do |item|\n\t\t text = item.children[1].children[1].children[1].attributes[\"href\"].value\n\t\t text = site+text\n\n\t\t if(@existing.index(text)!=nil)\n\t\t\tputs 'stopping after getting already known url'\n\t\t\tproceed = false\n\t\t\tbreak\n\t\t else\n\t\t @ads.push(text)\n\t\t end\n\t\tend\n\t\tif(doc.css('.u-pager__item--next').children[1] == nil)\n\t\t\tputs 'Completed scanning for lists, proceeding to scrape individual items'\n\t\t\treturn\n\t\tend\n\t\turl = site+doc.css('.u-pager__item--next').children[1].attribute('href').value\n\t\tputs 'now crawling to next page for items'\n\tend\n\t# all_new_ads(next_page_url)\n end",
"def getToolsSpider( url, pages, country, save)\n params = Hash.new\n params['url'] = url\n params['pages'] = pages\n params['country'] = country\n params['save'] = save\n return doCurl(\"get\",\"/tools/spider\",params)\n end",
"def scrape\n\n\t\tcustomer_api = Bigcommerce::Customer\n\t\tcustomer_count = customer_api.count.count\n\n\t\t#Bigcommerce api gives 50 items at once\n\t\tlimit = 50\n\t\tcustomer_pages = (customer_count/limit) + 1\n\n\t\tpage_number = 1\n\n\t\t# Loop through pages - each with 50 items\n\t\tcustomer_pages.times do \n\n\t\t\tcustomers = customer_api.all(page: page_number)\n\n\t\t\tcustomers.each do |c|\n\n\t\t\t\tinsert_sql(c, 1)\n\t\t\t\t\n\t\t\tend\n\n\t\t\tpage_number += 1\n\t\tend\n\n\tend",
"def filter_sellers\n params[:q] ||= {}\n params[:q][:visible] ||= '0'\n params[:q][:popular] ||= '0'\n params[:q][:main_category_id] ||= nil\n params[:q][:account_code] ||= nil\n\n @seller = if params[:list_type].chomp('s') == BuybidCommon::BusinessNames::AUCTION\n Buybid::Seller.auction\n elsif params[:list_type].chomp('s') == BuybidCommon::BusinessNames::SHOP\n Buybid::Seller.shop\n elsif params[:list_type].chomp('s') == BuybidCommon::BusinessNames::PARTNER\n Buybid::Seller.partner\n elsif params[:list_type].chomp('s') == BuybidCommon::BusinessNames::STORE\n Buybid::Seller.store\n else\n Buybid::Seller.all\n end\n\n # set default sort in created at with desc\n params[:q][:s] ||= 'created_at desc'\n \n #================================\n @q = @seller.ransack(params[:q])\n @sellers = @q.result.all\n #================================\n \n if params[:q][:account_code].present?\n @sellers = @sellers.where(account_code: params[:q][:account_code])\n end\n\n # filter with visible\n if params[:q][:visible] == '1'\n @sellers = @sellers.visible\n elsif params[:q][:visible] == '2'\n @sellers = @sellers.not_visible\n end\n\n # filter with popular\n if params[:q][:popular] == '1'\n @sellers = @sellers.popular\n elsif params[:q][:popular] == '2'\n @sellers = @sellers.not_popular\n end\n\n # filter with main category id\n if params[:q][:main_category_id].present?\n @sellers = @sellers.where(main_category_id: params[:q][:main_category_id])\n end\n\n @sellers = @sellers.page(params[:page]).per(params[:per_page])\n @sellers_count = @sellers.where(is_deleted: 0).to_a.count\n end",
"def get_offers\n unless get_connection_object.headers.has_key?(\"X-Auth-Token\")\n raise \"Please authenticate() to see your offers\"\n end\n get('offer')\n end",
"def crawl\n # TODO flush the page cache. We cache the crawled pages.\n begin\n account_detail_page #This will get us as far as we want to go, through several pages\n rescue *ERRORS_TO_RESCUE_FROM => e\n errors[:message] = e.message\n errors[:page_url] = e.page.uri\n errors[:page_body] = e.page.body\n return nil\n end\n end",
"def index\n # byebug\n # @offers = Offer.all\n\n @radius = 100\n # Get branch_offices with offers within a radius of 0.15km from user.address(home)\n @near_offices = BranchOffice.includes(:offers).near([current_user.latitude, current_user.longitude], @radius)\n .select { |b| !b.offers.empty? }\n if params[:user_id].present?\n @offers = Offer.includes(:users_to_offers).where(users_to_offers: { user_id: current_user.id, code_used: true })\n else\n # Get offers from the array of branches\n @offers = []\n @near_offices.each do |office|\n office.offers.each { |offer| @offers.push(offer) }\n end\n end\n\n # if params[:category] != \"\" && params[:category].present?\n # category = OFFER_CATEGORIES.find_index(params[:category].to_sym)\n # @offers = Offer.search_by_category(category)\n # else\n # # @offers = @near_offices.map { |office| office.offers[0]}\n # @offers = []\n # @near_offices.each do |office|\n # office.offers.each { |offer| @offers.push(offer) }\n # end\n # end\n\n if params[:level] != \"\" && params[:level].present?\n @offers = Offer.search_by_level(params[:level])\n else\n @offers = []\n @near_offices.each do |office|\n office.offers.each { |offer| @offers.push(offer) }\n end\n end\n\n # @offers.each do |offer|\n # offer.due_date_changes\n # end\n\n @user_address = [ lat: current_user.latitude, lng: current_user.longitude ]\n\n # @radius = 100000000000000000\n\n # # Get branch_offices with offers within a radius of 0.15km from user.address(home)\n # @near_offices = BranchOffice.includes(:offers).near([current_user.latitude, current_user.longitude], @radius)\n # .select { |b| !b.offers.empty? }\n\n # # Get offers from the array of branches\n # @near_offers = @near_offices.map { |office| office.offers[0]}\n\n\n # Expose a json with data to be rendered\n @branches_to_show = @near_offices.map do |office|\n {\n lat: office.latitude,\n lng: office.longitude,\n infoWindow: render_to_string(partial: \"info_window\", locals: { branch_office: office, partner: office.partner })\n }\n end\n\n # @branches_to_show = @offers.map do |offer|\n # {\n # lat: offer.branch_office.latitude,\n # lng: offer.branch_office.longitude,\n # infoWindow: render_to_string(partial: \"info_window\", locals: { branch_office: offer.branch_office, partner: offer.branch_office.partner })\n # }\n # end\n\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(@default_author, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def crawl\n # Request the url with the method, url and the parameters data\n response = rest_route.crawler.submit(rest_route.method, url, data)\n code = response.code unless response.nil?\n log \"Response #{code} for #{self}\"\n\n # Then, handle the result and return the response.\n rest_route.crawler.handle_rest_fuzzer_results(self, response)\n response\n end",
"def retrieve_links(search_service, site, page)\n term = search_service.and_query(\"site:#{site}\", name, page)\n result = extract_first_result(search_service, query_bing(search_service, term))\n unless (result.nil? || result.url.nil?)\n enhance_with_bing(page, result)\n end\n end",
"def scrape(url)\n\t\n $log.info \"START #{__FILE__}.#{__method__}\"\n\t\n \n def initialize \n super ARGV[0],\"groupon\"\n end\n \n begin\n html = open(url)\n doc = Nokogiri::HTML(html.read)\n doc.encoding = \"utf-8\"\n $log.info \"Open url : #{url}\"\n\n $log.info \"Fetching from : #{url}\"\n \n title \t\t= doc.at_xpath($deal_config[$site_name][\"title\"])\n deal_url\t= URI.parse(url)\n price \t\t= doc.at_xpath($deal_config[$site_name][\"price\"])\n location \t= doc.at_xpath($deal_config[$site_name][\"location\"])\n sold \t\t= doc.at_xpath($deal_config[$site_name][\"sold\"])\n items\t\t= doc.at_xpath($deal_config[$site_name][\"items\"])\n category\t= doc.at_xpath($deal_config[$site_name][\"category\"])\n deal_thumb\t= doc.at_xpath($deal_config[$site_name][\"deal_thumb\"])['src']\n description = doc.at_xpath($deal_config[$site_name][\"description\"]) \n discount = doc.at_xpath($deal_config[$site_name][\"discount\"])\n expiry = doc.at_xpath($deal_config[$site_name][\"expiry\"])['value'] \n city = doc.at_xpath($deal_config[$site_name][\"location_city\"])\n\n # check if there is an imagemap\n # if so, insert latitude and longitude\n # else try geocoding\n image_map = doc.at_xpath($deal_config[$site_name][\"image_map\"])\n lat = nil\n long = nil\n if !image_map.nil? && image_map.to_s != \"\"\n uri = URI.parse(URI.encode(image_map['src']))\n uri_params = CGI.parse(uri.query)\n if !uri_params[\"center\"].nil?\n lat, long = uri_params[\"center\"][0].chomp.split(',')\n end\n \n else\n # geocode address\n loc=GeoKit::Geocoders::MultiGeocoder.geocode(location.content.to_s.strip) \n if !loc.success\n #if loc.lat.nil?\n lat = nil \n long = nil\n elsif loc.success\n lat = loc.lat\n long = loc.lng\n end\n end\n \t\t\n $arr_deals << Deal.new(title, deal_url, deal_thumb, price, location, sold, items, category, description, lat, long, discount)\n \n # set the following to site name\n $arr_deals[-1].author = $deal_config[$site_name][\"author\"]\n \n # specialized code for expiry\n time = Time.now + expiry.to_i/1000\n $arr_deals[-1].expiry = time.strftime(\"%Y-%m-%d %H:%M:%S\")\n \n # add city to location 20120328\n cit = city.content.to_s.strip\n $arr_deals[-1].location += \", #{cit}\"\n # puts $arr_deals[-1].location\n \n # print ...\n #\t\tputs \"#{$arr_deals[-1].title} \\n\"\n #\t\tputs \"#{$arr_deals[-1].price} \\n\"\n #\t\tputs \"#{$arr_deals[-1].sold} \\n\"\n # \tputs \"#{$arr_deals[-1].items} \\n\"\n #\t\tputs \"#{$arr_deals[-1].location} \\n\"\n #\t\tputs \"#{$arr_deals[-1].deal_url} \\n\"\n #\t\tputs \"#{$arr_deals[-1].deal_thumb} \\n\"\n #\t\tputs \"#{$arr_deals[-1].category} \\n\"\n #\t\tputs \"#{$arr_deals[-1].description} \\n\"\n #\t\tputs \"#{$arr_deals[-1].latitude} \\n\"\n #\t\tputs \"#{$arr_deals[-1].longitude} \\n\"\n #\t\tputs \"#{$arr_deals[-1].discount} \\n\"\n\n $insert_number += 1\n puts \"inserting deal #{$insert_number}...\"\n $db.insert_deal($arr_deals[-1])\n \n $log.info \"Successfully retrieved data : #{url}\"\n\n rescue Exception=>e\n\t\n print \"Could not retrieve values. Maybe the site has changed?\"\n $log.error e.to_s\n puts e.to_s\n\t\t\n end\n\t\n $log.info \"END #{__FILE__}.#{__method__}\"\n\t\n end",
"def crawl(seed, options = {})\n f = Frontier.new(seed, :max_allowed_to_pass => options[:max_pages], :allow_ssl => options[:include_ssl], :filter => options[:filter])\n bad_uris = []\n\n while crawl_uri = f.dequeue\n uri = crawl_uri.uri\n parent_uri = crawl_uri.parent_uri\n \n start_time = Time.now\n page_links = fetch_page_links(uri)\n duration = Time.now - start_time\n\n if page_links\n page_links.each do |link|\n begin\n result = f.process link, :parent_uri => uri\n #if !result\n # puts \"\\x1B[33mProcessed #{link}: #{result}\\x1B[0m\"\n #end\n rescue Exception => ex\n log \"[An unknown error occurred]\"\n raise\n end\n end\n log \"#{f.passed.count} - #{parent_uri || 'root'} -> #{uri} (#{sprintf('%.2f',duration)} sec; queued: #{f.count})\"\n else\n bad_uris << uri\n log \"#{f.passed.count} - #{parent_uri || 'root'} -> #{uri} (#{sprintf('%.2f',duration)} sec; queued: #{f.count}) [Error fetching links]\"\n end\n\n sleep options[:crawl_rate] || 1\n end\n\n log \"Done.\"\n\n generate_sitemap(options[:generate_sitemap], f.passed - bad_uris) if options[:generate_sitemap]\n end",
"def scrap\n\t\turl = 'https://sg.carousell.com/search/products/?query=' + @input\n \tpage = @agent.get(url)\n\t\t@searchData = Nokogiri::HTML(page.body)\n\tend",
"def process_page page_url\n page = SuperCrawler::Scrap.new(page_url) # Scrap the current page\n\n current_page_links = page.get_links # Get current page internal links\n new_links = current_page_links - @links # Select new links\n\n new_links.each { |link| @links_queue.push(link) } # Add new links to the queue\n @links += new_links # Add new links to the links list\n @crawl_results << { # Provide current page crawl result as a hash\n url: page.url, # The crawled page\n links: current_page_links, # Its internal links\n assets: page.get_assets # Its assets\n }\n\n SuperCrawler::Render.log_status( page_url, @crawl_results.length, @links.length ) if @option_debug # Display site crawling status\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(item.dc_creator, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def get_cards\n @doc = Nokogiri::HTML(open(@url))\n card_links = @doc.css(\"div.snap-feat\")\n id = 0\n\n card_links.collect do |card|\n id += 1\n c = Cards::CreditCard.new(card.css(\"h3 a.detail-tog\").text)\n c.id = id\n c.offer = card.css(\"div.wrap div.col p\").first.text\n c.fees = card.css(\".hide .col p\").first.text\n c.credit_needed = card.css(\"a.card-snapshot-credit-tip\").text.strip\n c.href = card.css(\".bot-links a.lrn-more\").attr(\"href\").value\n c.apply_link = card.css(\"div.last div.wrap a\").attr(\"href\").value\n c\n end\n end",
"def offers \n @host.offers.create(offer_params) if request.post?\n @offers = @host.offers\n end",
"def run\n scraper = ThreatDetector::Scraper.new options\n\n fetch_feeds.map do |item|\n next unless valid_feed?(item)\n\n scraper.for(item['name'], item['url'])\n scraper.parse_and_save_entries\n\n yield(item, scraper) if block_given?\n item.slice('name', 'url', 'source')\n end.compact\n end",
"def crawl(options = {})\n unless @proxy_addr.nil? || @proxy_port.nil?\n @agent.set_proxy @proxy_addr, @proxy_port\n end\n\n @errors = []\n i = 0\n each_url do |url, handler, default_data|\n break if options[:max_urls] && i >= options[:max_urls]\n begin\n if @random_proxy == true\n proxy = ip_cycle\n @proxy_addr = proxy[:ip]\n @proxy_port = proxy[:port]\n @agent.set_proxy @proxy_addr, @proxy_port\n end\n page = @agent.get(url)\n Spidey.logger.info \"Handling #{url.inspect} - Proxy:#{@proxy_addr}:#{@proxy_port}\"\n send handler, page, default_data\n rescue => ex\n add_error url: url, handler: handler, error: ex\n end\n sleep request_interval if request_interval > 0\n i += 1\n end\n end",
"def perform\n if perform_crawl?\n if get_page\n store_page\n normalize_links\n filter_links\n continue_crawl\n end\n else\n # puts \"Depth limit reached for #{@url}\"\n end\n end",
"def index\n @offers = Offer.where(company_id: params[:company_id]) \n if params[:search].present?\n @q = @company.offers.near(params[:search], 200, :order => 'distance' ).ransack(params[:q])\n @offers = @q.result(:distinct => true)\n else \n @q = @company.offers.ransack(params[:q])\n @offers = @q.result(:distinct => true)\n end\n end",
"def scrape_details(partner_urls)\n\t\tcsv_data = []\n\t\tcsv_data << [\"City\",\"Partner Name\",\"Address\",\"Latitude\",\"Longitude\",\"Avarage Rating\",\"Phone Number\"]\n\n\t\tpartner_urls.each do |url|\n\t\t\tp 'Started scraping '+ url\n\t\t\tscrap_page = @mechanize.get(url)\n\t\t\tpartner_name = scrap_page.at('.studio-info .studio-name h2').text.strip\n\t\t\taddress = scrap_page.at('.list-unstyled.studio-details li p').text.strip\n\t\t\tlat_lng = scrap_page.search('.studio-sidebar script')[0].children.to_s.split(\"LatLng\")[1].split(\"'\")\n\t latitude = lat_lng[1].strip\n\t longitude = lat_lng[3].strip\n #For some partners raring is not available\n\t if rating = scrap_page.search(\".rating\")\n\t \t\t average_rating = rating[0].text.strip if rating[0]\n\t \telse\n average_rating = 0\n\t \tend\n\t phone = get_partner_phone_no(scrap_page)\n\t\t\tcsv_data << [@city.capitalize, partner_name, address,latitude,longitude,average_rating,phone]\n\t\tend\n return csv_data\n\tend",
"def scrape\n google_url = create_google_url\n google_data = Scrubyt::Extractor.define do\n fetch google_url\n\n link_title \"//a[@class='l']\", :write_text => true do\n link_url\n end\n end\n google_data.to_hash.map {|r| r[:link_url]}\n end",
"def offer_map\n return @offer_map unless @offer_map.nil?\n\n if no_more_offers?\n raise \"The offerwall didn't have any more offers to render. We got \" \\\n \"the 'Come back later for more offers.' message. You may have to \" \\\n \"create more offers to run your test.\"\n end\n\n Util.wait_for(60,1) do\n page.has_css?('#offers')\n end\n\n @offer_map = {}\n\n # Offers under marquee-offers would never overlap with the offers from\n # offer-item. This is ensured via offer filtering on TJS. Hence, we need\n # to parse for them seperately to be able to make assertions about\n # marquee/premium offers.\n parse_offers('#marquee-offers')\n parse_offers('#offers')\n\n @offer_map\n end",
"def scrape\n article_urls = Extractors::GoogleNewsRss.new(query: @query).extract\n\n transformed_articles = []\n\n article_urls.each do |article_url|\n payload = Extractors::Article.new(url: article_url).extract\n article_transformer = Transformers::Article.new(url: article_url, payload: payload)\n\n begin\n transformed_article = article_transformer.transform\n transformed_articles << transformed_article\n yield transformed_article if block_given?\n rescue Transformers::ScrapePatternNotDefined => e\n raise e unless block_given?\n yield e\n end\n end\n\n transformed_articles\n end",
"def crawl_link(urls, blocks={})\n \n qless_job = TestBatchJob.new(urls, opts=@opts, ccmq=@ccmq, blocks=blocks)\n CloudCrawler::BatchCurlJob.perform(qless_job)\n while qless_job = qless_job.queue.pop\n qless_job.perform\n end\n \n return @page_store.size\n end",
"def links\n return unless success? and body\n\n doc = Nokogiri::HTML(@body)\n \n links = []\n\n doc.css('div.list-lbc a').each do |a|\n link = {\n :url => a['href'],\n :title => a.css('div.title').first.content.strip\n }\n\n link[:ad_id] = link[:url][/^http:\\/\\/www.leboncoin.fr\\/locations\\/(\\d+).*/,1]\n links << link\n yield link if block_given?\n end\n\n links\n end",
"def select_options(offer)\n puts \"basepage select options\"\n @offer = offer.first\n begin\n @steps_loc = get_locators()\n puts \"steps_loc loc\"\n puts @steps_loc\n puts \"loc done\"\n rescue => e\n e.display\n end\n begin\n pages = get_pattern\n puts \"pages\"\n puts pages\n puts \"pages done\"\n Rails.logger.info pages\n pages.each do |page|\n puts \"page\"\n puts page\n puts \"page\"\n page.each do |step|\n puts \"step\"\n puts step\n puts \"step\"\n begin\n case step\n when \"Product\", \"Brandpseudo\"\n select_product\n when \"Kit\"\n select_kit\n when \"Gift\"\n select_gift\n when \"Supply\"\n select_supply\n when \"Fragrance\"\n select_fragrance\n when \"Shade\"\n select_shade\n when \"Formula\"\n select_formula\n when \"Pack\"\n select_pack\n when \"Duo\"\n select_duo\n end \n rescue => e\n e.display\n end\n end #of step execution\n end #of sas module selection \n # click_if_exists(:css, '#checkout.marketing-button-next')\n rescue => e\n e.display\n # TODO handle other situations\n end\n\n page = T5::Cart.new(@campaign_configuration)\n page.browser = @browser\n return page.adapt\n end",
"def sitelinks(params, additional_headers = {})\n perform_request(self, @token, 'sitelinks', 'get', params, additional_headers)\n end",
"def parse(max_apts = 100)\n @mech.get(@url) do |page|\n i = 0\n page.links.each do |link|\n next if link.href == nil\n next if i >= max_apts\n next unless links_to_apt?(link)\n\t\t\t\tnext if Apartment.find_by_url(link.href)\n @apts << AptDetailsPage.new(link.href, link.to_s).parse\n sleep 0.1 # Don't hit CL too quickly\n i += 1\n end\n end\n self\n end",
"def crawl\n\t\t\tuntil @links_to_visit.empty? do\n\t\t\t\tbegin\n\t\t\t\t\t# Get link\n\t\t\t\t\turl_server\n\t\t\t\t\tnext unless robot_safe? @url\n\t\t\t\t\tif @url.include? '#'\n\t\t\t\t\t\tprint \"... Anchor link found, skipping...\"\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\t# Parse robots.txt, then download document if robot_safe\n\t\t\t\t\tfetch_http(@url)\n\t\t\t\t\t# Store raw HTML in variable to read/reread as needed\n\t\t\t\t\t# Then call any processing modules you need for the current document\n\t\t\t\t\tris(@document)\n\t\t\t\trescue\n\t\t\t\t\tputs \"\"\n\t\t\t\t\tputs \"I died on #{@url}\"\n\t\t\t\t\t$stderr.puts $!\n\t\t\t\t\t@errors[@url] = $!\n\t\t\t\t\tnext\n\t\t\t\tensure\n\t\t\t\t\t# Stuff you want to make sure gets printed out\n\t\t\t\t\tputs \" done!\"\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tputs \"Visited #{@visited_links.size} links.\"\n\t\tend",
"def scrape\n\t\turi = URI.parse(@url)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\thttp.use_ssl = false\n\t\t#Make a GET request to the given url\n\t\tresponse = http.send_request('GET', @request_url)\n\t\t# Parse the response body\n\t\tforecast = JSON.parse(response.body)\n\t\tforecast[\"response\"][\"results\"].each do |article|\n\t\t\tif date_valid?(article[\"webPublicationDate\"])\n\t\t\t\tcreate_article(article[\"type\"], article[\"sectionId\"],\n\t\t\t\t\tarticle[\"webTitle\"], article[\"webPublicationDate\"],\n\t\t\t\t\tarticle[\"id\"], article[\"webUrl\"], article[\"apiUrl\"],\n\t\t\t\t\tarticle[\"sectionName\"])\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(get_author(item), item.title, item.description,\\\n\t\t\t\t\t\tget_images(item), @source_name, item.pubDate.to_date,\\\n\t\t\t\t\t\titem.link, get_image_length(item))\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def offers; global.offers end",
"def crawl\n completed = {}\n to_crawl = [Spidey::Page.new(@initial_url)]\n\n while page = to_crawl.shift do\n break if page.depth == @max_depth\n\n if !completed.has_key?(page.uri.to_s)\n STDERR.puts \"Fetching #{page.uri.to_s}\" if Spidey.log_requests\n page.scan.links.each do |link|\n to_crawl << Spidey::Page.new(@initial_url.merge(link), page.depth + 1)\n end\n completed[page.uri.to_s] = page\n end\n end\n\n completed\n end",
"def fetch(url)\n response = Curl::Easy.http_get(url)\n results = parse_seo(response.body_str)\n results.update({\n :url => url,\n :robots => extract_robots(url),\n :headers => response.headers,\n :cookies => response.cookies,\n :size => response.downloaded_bytes,\n :speed => response.download_speed })\n end",
"def place_offers_with\n publishers = []\n if publishing_group\n if place_offers_with_group\n publishers = publishing_group.publishers\n else place_all_group_offers\n publishers = publishing_group.publishers.collect do |pub|\n pub if pub.place_all_group_offers?\n end.compact # remove nils\n publishers << self # we also need to include self\n end\n end\n publishers.empty? ? [self] : publishers.uniq\n end",
"def get_buylinks( params )\n xml = LastFM.get( \"track.getBuylinks\", params )\n [:physical, :download].each_with_object([]) do |type, buylinks|\n xml.find(\"affiliations/#{type}s/affiliation\").each do |buylink|\n buylinks << LastFM::Buylink.from_xml( buylink, :type => type )\n end\n end\n end",
"def scrape_course_info\n counter = 1\n @all_providers.each do |provider|\n\n provider[:courses].each do |url|\n unparsed_page = HTTParty.get(url)\n parsed_page = Nokogiri::HTML(unparsed_page)\n\n # try to scrape provider info from course pages\n if (provider[:website].empty? || provider[:number].empty? || provider[:email].empty?)\n provider[:website] = parsed_page.css('[id=\"ProviderWebsite\"]').text\n if !parsed_page.css('[id=\"contact_Phone\"]')[-1].nil?\n provider[:number] = parsed_page.css('[id=\"contact_Phone\"]')[-1].text\n end\n if !parsed_page.css('[class=\"contact-email\"]')[-1].nil?\n provider[:email] = parsed_page.css('[class=\"contact-email\"]')[-1].text\n end\n end\n\n # pages with multiple options have to be treated differently\n options = parsed_page.css('a.academic-year-link-active').children[1].text.strip[0..1].strip\n\n # get each option's url, parse it, then pass the url and parsed page to add_courses\n if !(options.eql? \"1\")\n options = parsed_page.css(\"[class='course-option course-option--link']\")\n option_urls = Array.new\n options.each do |option|\n option_urls << @base_url ++ option.attributes[\"href\"].value\n end\n option_urls.each do |option_url|\n unparsed_option_page = HTTParty.get(option_url)\n parsed_option_page = Nokogiri::HTML(unparsed_option_page)\n add_courses(option_url, counter, parsed_option_page)\n end\n end\n\n # if only one option, pass straight to add_courses\n if (options.eql? \"1\")\n add_courses(url, counter, parsed_page)\n end\n\n counter += 1\n #if counter >10\n # break\n #end\n end\n #if counter >10\n # break\n #end\n end\n end",
"def continue_crawl\n # puts \"I am on #{@url} (#{@links.size} links)-> I want to navigate to #{@links.map{|l| l['href']}}\" #links - Array\n\n @links.each_with_index do |link, i|\n href = link[\"href\"]\n next if href.blank? or (href.split('/').last && href.split('/').last.starts_with?(\"#\"))\n if not href.starts_with?(\"htt\")\n href = href[1..-1] if href.starts_with?('/')\n href = @stored_page.domain + '/' + href\n end\n if page_found = Page.find_by_address_and_crawler_id(href, @crwlr.id)\n #puts \"Loop for #{href}\"\n if @stored_page #Page\n @stored_page.pages << page_found\n end\n else\n #puts \"Adding job for CID: #{@crwlr.id} HREF: #{href} SPID: #{@stored_page.id} #{} #{} #{}\"\n @stack.enqueue Crawl.new(@crwlr.id, href, @depth+1, @stack, @stored_page.id, @options)\n end\n end\n end",
"def scrape\n open(@url) do |rss|\n feed = RSS::Parser.parse(rss)\n\n feed.items.each do |item|\n # Remove the p tag and retrieve image url from the description\n # if it exists\n p_tag = item.description[%r{<p>.*</p>}]\n if p_tag\n item.description.slice! p_tag\n img_url = p_tag.match(/src=\"(?<img>[^\"]*)\"/)[:img]\n else\n img_url = nil\n end\n\n # Sanitize HTML\n item.title = CGI.unescapeHTML(item.title)\n item.description = CGI.unescapeHTML(item.description)\n\n @articles.push(\n title: item.title,\n summary: item.description,\n image_url: img_url,\n source: @source,\n url: item.link,\n pub_date: item.pubDate.to_s,\n guid: item.guid.content\n )\n end\n end\n end",
"def scrape_contacts; end",
"def parse!\n init_url\n response = HTTParty.get(@url)\n pattern = /<a (href\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^'\">\\s]+)))*>(.*?)<\\/a>/i\n body = response.body\n while pattern =~ body\n @uri=$1\n @obj=$+\n clean!\n @items[\"#{@uri}\"] = @obj\n body = $~.post_match\n end\n end",
"def offers_by_condition\n @offer_hash = {}\n offer_page = 1\n \n offers = offer_page(offer_page)\n while offer_page <= offer_pages\n offers.each do |o|\n @offer_hash[o.condition.downcase] ||= {}\n @offer_hash[o.condition.downcase][o.sub_condition] ||= []\n @offer_hash[o.condition.downcase][o.sub_condition] << o\n end\n\n offer_page += 1\n offers = offer_page(offer_page)\n end\n\n @offer_hash\n end",
"def start_crawling(url, &block)\n Grell.logger.info \"GRELL Started crawling\"\n @collection = PageCollection.new(@add_match_block)\n @collection.create_page(url, nil)\n\n while !@collection.discovered_pages.empty?\n crawl(@collection.next_page, block)\n @manager.check_periodic_restart(@collection)\n end\n\n Grell.logger.info \"GRELL finished crawling\"\n end",
"def get_data_feeds(merchant_id)\n uri = build_uri_for(@provider, {id: merchant_id})\n http = initialize_http(uri)\n\n request = Net::HTTP::Get.new(uri.request_uri)\n JSON( http.request(request).body )['Items'] \n end",
"def scrape\n end",
"def crawl\n $list.regions.each do |r|\n url = \"http://\" << r.name << :query\n puts r.name\n peel(url)\n end\n end",
"def get_trip_offers(active=true, limit=3)\n dputs __method__.to_s\n if active\n trip_offer_req = setup_http_request($active_trip_offers, @cookie, {:url_arg => [1]})\n obj_ = $active_trip_offers\n page_regex = $active_trip_offers[:url].gsub(\"?\",\"\\\\?\").gsub(\"/\", \"\\\\/\") % \"\"\n page_url = $active_trip_offers[:url]\n else\n trip_offer_req = setup_http_request($inactive_trip_offers, @cookie, {:url_arg => [1]})\n obj_ = $inactive_trip_offers\n page_regex = $inactive_trip_offers[:url].gsub(\"?\",\"\\\\?\").gsub(\"/\", \"\\\\/\") % \"\"\n page_url = $inactive_trip_offers[:url]\n end\n res = @http.request(trip_offer_req)\n trips = {}\n trips = list_trip_offers(CGI.unescapeHTML(res.body.force_encoding(\"utf-8\")))\n pages = res.body.scan(/<a href=\"#{page_regex}(\\d+)/).flatten.uniq\n # in case we got something like 1, 2, 3,4,5,6,7,8,9,21\n pages.map!(&:to_i)\n if not pages.empty?\n if pages.length >= 2\n diff = pages[-2..-1].inject(:-).abs\n if diff > 1\n pages += 1.upto(diff).map{|d| d + pages[-2]}.to_a\n pages.sort!\n pages.slice!(limit..-1)\n end\n end\n pages.map{|p|\n # Using $active_trip_offers for the method, but specify the URL\n trip_offer_req = setup_http_request(obj_, @cookie, {:url => page_url, :url_arg => [p]})\n res = @http.request(trip_offer_req)\n trips = trips.merge(list_trip_offers(res.body))\n }\n end\n trips\n end",
"def offers\n @offers ||= offer_map.values.map { |v| v[:offer] }\n end",
"def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('.zone_B_with_ads')\n allUrl = links.css('div.tile__content a.tile__read_more').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n #puts i\n end\nend",
"def index\n session[:trail] = 'insider'\n Offer.initialize_unique_offers_list\n @preferred_deal_offer = Offer.preferred_deal(current_user)\n @special_offer = Offer.special_offer_of_the_day(current_user)\n @you_deserve_it_offer = Offer.you_deserve_it_offer(current_user)\n @trending_deal = Offer.trending_deals(current_user)\n @deal_trackers = Tracker.shared_to_me(current_user, Offer.to_s).order('created_at DESC')\n @snap_add = Offer.snap_add(@user_profile).sample\n @all_suggestions_execpt_friends = Suggestion.all_except_friends_suggestions(current_user)\n @friends_suggestions = Suggestion.friends_suggestions(current_user)\n @suggestion_trackers = Tracker.shared_to_me(current_user, Suggestion.to_s).order('created_at DESC')\n @minor_categories = Category.get_sorted_minor_categories('lifestyle')\n #@insider_do_better_offer = Offer.insider_do_better_offer(current_user)\n logger.debug \"*******\"\n logger.debug @preferred_deal_offer.class\n logger.debug @special_offer.class\n logger.debug @you_deserve_it_offer.class\n logger.debug @trending_deal.class\n logger.debug @deal_trackers.map(&:id)\n logger.debug \"*******\"\n end",
"def get_reviews\n\t\ta = Mechanize.new\n\t\ta.user_agent_alias = 'Linux Firefox'\n\n\t\tcurr_page = 415\n\t\tproduct_id = 1\n\t\ttotal_pages = nil\n\t\treached_end = false\n\n\t\twhile !reached_end\n\n\t\t\treview_url = \"/ref=cm_cr_arp_d_viewopt_rvwer?ie=UTF8&reviewerType=all_reviews&showViewpoints=1&sortBy=helpful&pageNumber=\" + curr_page.to_s\n\t\t\turl = self.url.to_s + review_url\n\t\t\ttotal_pages = 482\n\t\t\t#url = 'https://www.amazon.com/GermGuardian-AC4825-Cleaning-Sanitizer-Reduction/product-reviews/B004VGIGVY/ref=cm_cr_arp_d_viewopt_rvwer?ie=UTF8&reviewerType=all_reviews&showViewpoints=1&sortBy=helpful&pageNumber=1'\n\n\t\t\tp = a.get(url)\n\t\t\t#puts pp p\n\t\t\t#if !total_pages\n\t\t\t#\ttotal_pages = p.search('.page-button').last.text if p.search('.page-button')\n\t\t\t#end\n\n\t\t\treviews = p.search('.a-section .review')\n\t\t\treviews.each do |review|\n\t\t\t\tdate_submitted = convert_date(review.search('.review-date').text)\n\t\t\t\tscore = review.search('.review-rating').text.partition(' ').first.to_f\n\t\t\t\tusername = review.search('.author').text\n\t\t\t\tverified_purchase = p.search('.a-icon-text-separator').count > 1 ? true : false\n\t\t\t\ttitle = review.search('.review-title').text\n\t\t\t\ttext = review.search('.review-text').text\n\t\t\t\tnum_comments = review.search('.review-comment-total')[0].text\n\t\t\t\tnum_helpful_votes = convert_votes(review.search('.review-votes').text.squish)\n\t\t\t\tcomments_url = review.search('.review-title')[0]['href']\n\n\t\t\t\tReview.find_or_create_by(product_id: product_id, date_submitted: date_submitted, score: score, username: username, verified_purchase: verified_purchase,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle: title, text: text, num_comments: num_comments, num_helpful_votes: num_helpful_votes,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcomments_url: comments_url)\n\t\t\t\tputs 'Saving review ' + title.to_s\n\t\t\tend\n\n\t\t\tif curr_page == total_pages\n\t\t\t\treached_end = true\n\t\t\tend\n\n\t\t\tputs 'Done with page ' + curr_page.to_s\n\t\t\tcurr_page = curr_page + 1\n\t\t\tsl = rand(7..11)\n\t\t\tputs 'sleeping ' + sl.to_s\n\t\t\tsleep(sl)\n\t\tend\n\tend",
"def read_scrapers scrapers, related_scrapers, response\n \n logger.info(\"Trying to find #{scrapers.length} scrapers\") if scrapers.length > 0\n \n # create and yield all scrapers found\n scrapers.each_pair do |name, scraper_setup|\n response.query(scraper_setup[:item_path]).each do |item_scope|\n \n scraper = related_scrapers[name].deep_clone\n scraper_fields = perform_data_requests(response, scraper_setup[:fields],item_scope)\n\n # TODO it should make request fields into sets (eg, no repeated fields)\n scraper.requests.each do |request| \n request.fields.merge!(scraper_fields)\n end\n \n # yield the finished scraper\n logger.info(\"Yielding a #{scraper.name} scraper found with #{scraper_setup[:item_path]}\")\n yield scraper\n end\n end\n\n end",
"def perform(share_id)\n\t\t#Retrieve the IDs for each whitelist api connection\n\t\twac_ids = WhitelistApiConnection.where(\"share_id = ?\", share_id).pluck(\"id\")\n\t\t#Retrieve all of the APIs with active pulls on this share from the database.\n\t\tapis = Api.joins(:whitelist_api_connections).where(\"share_id = ?\", share_id).uniq\n\t\t#puts \"API count: \" + apis.count.to_s\n\t\t#Iterate through each API\n\t\tapis.each do |ananke_api|\n\t\t\t#puts \"API Id: \" + ananke_api.id.to_s\n\t\t\traise ArgumentError, \"Api must be a corporation API.\" if ananke_api.ananke_type != 1\n\t\t\traise ArgumentError, \"Api must be active.\" if ananke_api.active != true\n\n\t\t\t#Construct an eve api with the eve gem\n\t\t\teve_api = Eve::API.new(:key_id => ananke_api.key_id, :v_code => ananke_api.v_code)\n\n\t\t\t#Query the API\n\t\t\tresult = eve_api.corporation.contact_list\n\n\t\t\t#Iterate through each contact\n\t\t\tresult.corporateContactList.each do |contact|\n\t\t\t\tcontact_type = 0\n\t\t\t\t#Process the contact's contactTypeID\n\t\t\t\tif contact.contactTypeID == 2\n\t\t\t\t\tcontact_type = 2\n\t\t\t\telsif contact.contactTypeID == 16159\n\t\t\t\t\tcontact_type = 1\n\t\t\t\telsif contact.contactTypeID >= 1370 && contact.contactTypeID <= 1390\n\t\t\t\t\tcontact_type = 4\n\t\t\t\telse\n\t\t\t\t\tcontact_type = 3\n\t\t\t\tend\n\n\t\t\t\tif contact.standing >= ananke_api.whitelist_standings\n\t\t\t\t\twhitelist_entity = Whitelist.where(\"name = ? AND share_id = ?\", contact.contactName, share_id)[0]\n\t\t\t\t\t#If this contact does not exist on the whitelist. \n\t\t\t\t\tif whitelist_entity.nil? == true\n\t\t\t\t\t\t#Create a whitelist entity from it\n\t\t\t\t\t\tnew_entity = Whitelist.create(name: contact.contactName, entity_type: contact_type, source_type: 1, source_share_user: ananke_api.share_user.id, standing: contact.standing, share_id: share_id)\n\n\t\t\t\t\t\t#and create a connection between that entity and the source API\n\t\t\t\t\t\tananke_api.whitelist_api_connections.create(whitelist_id: new_entity.id, share_id: share_id)\n\t\t\t\t\t\t#No need to remove the new wac's id from the wac_ids array because it was never there.\n\t\t\t\t\telse\n\t\t\t\t\t\t#Check the entity's standings and see if they've changed.\n\t\t\t\t\t\tif contact.standing != whitelist_entity.standing\n\t\t\t\t\t\t\t#If they've changed, update them with the new data from the API\n\t\t\t\t\t\t\twhitelist_entity.standing = contact.standing\n\t\t\t\t\t\tend\n\t\t\t\t\t\t#Remove the wac's id from the wac_ids array.\n\t\t\t\t\t\twac = whitelist_entity.whitelist_api_connections.where(\"api_id = ?\", ananke_api.id)[0]\n\t\t\t\t\t\twac_ids.delete_if{|list_id| \n\t\t\t\t\t\t\tlist_id == wac.id\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif contact.standing < ananke_api.whitelist_standings\n\t\t\t\t\twhitelist_entity = Whitelist.where(\"name = ? AND share_id = ?\", contact.contactName, share_id)[0]\n\t\t\t\t\t#If this contact is already on the whitelist\n\t\t\t\t\tif whitelist_entity.nil? == false\n\t\t\t\t\t\tconnection_api_ids = whitelist_entity.apis.pluck(\"api_id\")\n\n\t\t\t\t\t\t#If this contact does not have a connection with this api\n\t\t\t\t\t\tif connection_api_ids.include?(ananke_api.id) == true\n\t\t\t\t\t\t\t#Destroy the connection between this API and the whitelist entity\n\t\t\t\t\t\t\twac = whitelist_entity.whitelist_api_connections.where(\"api_id = ?\", ananke_api.id)[0]\n\t\t\t\t\t\t\twac.destroy!\n\t\t\t\t\t\t\t#Remove the wac's id from the wac_ids array.\n\t\t\t\t\t\t\twac_ids.delete_if{|id| id == wac.id}\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tWhitelistLog.create(entity_name: ananke_api.main_entity_name, source_share_user: ananke_api.share_user.id, source_type: 2, addition: true, entity_type: 5, date: Date.today, time: Time.now, share_id: share_id)\n\t\t\t#Generate a whitelist_log entry for this pull\n\t\tend\n\t\t#Delete any whitelist api connections (wacs) that remain.\n\t\t#This should result in the removal of api sourced whitelist entities that are no longer supported by any APIs.\n\t\tif wac_ids.empty? == false\n\t\t\twac_ids.each do |wac|\n\t\t\t\tWhitelistApiConnection.where(\"id = ?\", wac)[0].destroy\n\t\t\tend\n\t\tend\n\tend",
"def crypto_scrapper ()\r\n url = \"https://coinmarketcap.com/all/views/all/\"\r\n page_inspect = URI.open(url)\r\n page_inspected = Nokogiri::HTML(page_inspect)\r\n page_inspected.xpath('//a[contains(@href, \"/currencies\")]').each do |crypto|\r\n \r\n crypto = crypto.text\r\n B << crypto\r\n end\r\n #puts B.to_s\r\nend",
"def fetch_contacts!\n create_agent\n prepare\n scrape_contacts\n end",
"def get_links(url)\n # catch 404 error from host\n\n doc = Nokogiri::HTML(open(url))\n # find internal links on page\n doc.css('#tagCloud a').each do |link|\n link = link.attr('href')\n # If link correspond to a recipe we add it to recipe to scraw\n if link.include?(ALLOWED_URLS[@host]) && !@crawled_urls.include?(url)\n @to_crawl_urls << link\n end\n end\n @to_crawl_urls.delete url\n @crawled_urls << url\n @to_crawl_urls.uniq!\n rescue OpenURI::HTTPError\n @to_crawl_urls.delete url\n warn \"#{url} cannot be reached\"\n end",
"def parse_page_all_reviews_in_page all_reviews_urls\n\tall_reviews_details=[]\n\tfor single_review_url in all_reviews_urls\n\t\tfull_url = \"http://amazon.com\"+ single_review_url\n\t\tparse_single_review = Nokogiri::HTML(open(full_url))\n\t\tsingle_review_details={}\n\t\tparse_single_review.css('html body span span span').each do |i|\t\n\t\t\tif i.text =~ /.* \\d*, \\d*.*By .*/\n\t\t\t\tsingle_review_details[:date_author] = i.text\n\t\t\telsif i.text =~ /Amazon Verified Purchase/\n\t\t\t\tsingle_review_details[:amazon_verified] = i.text\n\t\t\telsif i.text =~ /\\d* out of \\d* found this helpful/\n\t\t\t\tsingle_review_details[:found_helpful] = i.text\n\t\t\telse \n\t\t\t\tsingle_review_details[:review_body] = i.text\n\t\t\tend\t \n\t\tend\n\t\tparse_single_review.css('html body span').each do |i|\t\n\t\t\tif i.text =~ /Customer rating \\d.\\d\\/\\d.\\d/\n\t\t\t\ttemp = i.text.match(/Customer rating \\d.\\d\\/\\d.\\d/)\n\t\t\t\tsingle_review_details[:user_rating] = temp[0]\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tall_reviews_details.push(single_review_details)\n\tend\n\t# save all reviews data in xml format\n\tbuilder = Nokogiri::XML::Builder.new do |xml|\n\txml.root {\n\t\tfor review_details in all_reviews_details \n\t\t xml.review {\n\t\t xml.user_rating\treview_details[:user_rating]\n\t\t xml.date_author\treview_details[:date_author]\n\t\t xml.amazon_verified review_details[:amazon_verified]\n\t\t xml.found_helpful\treview_details[:found_helpful]\n\t\t xml.review_body review_details[:review_body]}\n\t\tend\n\t}\n\tend\n\tmy_local_file = open(\"result.xml\", \"w\") \n\tmy_local_file.write(builder.to_xml)\n\tmy_local_file.close\n\tputs \" Reviews Saved @ result.xml\"\nend",
"def get_links(url)\n @driver.get(url)\n data = @driver.execute_script(\"return document.getElementsByTagName('html')[0].innerHTML\")\n\n Nokogiri::HTML(data).css(\"a\").map do |link|\n if (href = link.attr(\"href\"))\n res = Link.new\n\n begin\n res.href = self.build_careers_page_url(url, href.strip).to_s\n rescue\n res.href = nil\n end\n res.text = link.text\n res\n end\n end.compact.reject do |link|\n link.href.nil?\n end.uniq\n end",
"def fetch_and_store!\n # Get links from page\n # Download files from links concurrently\n download self.extract!\n end",
"def index\n @core_sellers = Core::Seller.find_mine(params).paginate(page: params[:page])\n end",
"def crawl_site(url = @urls.first, &block)\n assert_type(url, Wgit::Url)\n\n doc = crawl_url(url, &block)\n return nil if doc.nil?\n\n host = url.to_base\n alt_url = url.end_with?('/') ? url.chop : url + '/'\n crawled = [url, alt_url]\n externals = doc.external_links\n internals = get_internal_links(doc)\n\n return doc.external_links.uniq if internals.empty?\n\n loop do\n crawled.uniq!\n internals.uniq!\n\n links = internals - crawled\n break if links.empty?\n\n links.each do |link|\n orig_link = link.dup\n doc = crawl_url(\n link, follow_external_redirects: false, host: host, &block\n )\n\n crawled.push(orig_link, link) # Push both in case of redirects.\n next if doc.nil?\n\n internals.concat(get_internal_links(doc))\n externals.concat(doc.external_links)\n end\n end\n\n externals.uniq\n end",
"def scrap_all_pages\n Shop.find(:all).each {|item|\n @g_template = item.template\n @g_shopid = item.id\n\n scrap_data_from_page(item.home_page_link)\n }\nend",
"def scrap_all_pages\n Shop.find(:all).each {|item|\n @g_template = item.template\n @g_shopid = item.id\n\n scrap_data_from_page(item.home_page_link)\n }\nend",
"def scrap_all_pages\n Shop.find(:all).each {|item|\n @g_template = item.template\n @g_shopid = item.id\n\n scrap_data_from_page(item.home_page_link)\n }\nend",
"def scrap_all_pages\n Shop.find(:all).each {|item|\n @g_template = item.template\n @g_shopid = item.id\n\n scrap_data_from_page(item.home_page_link)\n }\nend",
"def scraper(url2)\n dataUrl = Nokogiri::HTML(open(url2))\n linksUrl = dataUrl.css('div#leftContainer')\n \n linksUrl.each do |review|\n arr = []\n # name\n arr << review.css('span.fn').text.strip\n # neighborhood\n #arr << review.css('span.neighborhood').text.strip\n # street-address\n arr << review.css('div.h5').first.text.strip.split(\"Send\").first\n # street-address\n #arr << review.css('span.locality').text.strip\n # price rating\n arr << review.css('span.pricerange').text.strip\n # rating\n arr << review.css('span.value').text.strip\n #blurb\n arr << review.css('span#blurb').text.strip\n\n return arr\n end \nend",
"def used_offers\n if @used_offers.nil?\n @used_offers = []\n self.offers.each do |o|\n if o.condition.downcase == \"used\"\n @used_offers << o\n end\n end\n @used_offers.sort!{|a,b| a.price.amount <=> b.price.amount}\n end\n @used_offers\n end",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend"
] | [
"0.6432751",
"0.6138299",
"0.5883554",
"0.5861007",
"0.57116294",
"0.5688116",
"0.56359416",
"0.55497795",
"0.5473344",
"0.544266",
"0.5442365",
"0.538268",
"0.53784615",
"0.53584105",
"0.53509974",
"0.53274655",
"0.53165084",
"0.5311219",
"0.5311219",
"0.5311219",
"0.5311219",
"0.5287322",
"0.52755064",
"0.52311057",
"0.5221006",
"0.5211094",
"0.5209038",
"0.5197976",
"0.5180354",
"0.5156956",
"0.51391816",
"0.5129338",
"0.5125546",
"0.51160735",
"0.51138675",
"0.5111949",
"0.510577",
"0.50694984",
"0.5069374",
"0.5053811",
"0.50525385",
"0.502668",
"0.5023966",
"0.5022178",
"0.50183606",
"0.49787763",
"0.49751803",
"0.4966912",
"0.49654797",
"0.49644116",
"0.49641404",
"0.49448398",
"0.49431786",
"0.49424985",
"0.49424684",
"0.49365836",
"0.49204823",
"0.49120945",
"0.48975202",
"0.48941132",
"0.48885885",
"0.48855236",
"0.48773602",
"0.48684523",
"0.48315415",
"0.483128",
"0.48241463",
"0.48181736",
"0.48167914",
"0.48095167",
"0.48034278",
"0.4801389",
"0.47973585",
"0.47812968",
"0.4772792",
"0.47677597",
"0.47610223",
"0.4752983",
"0.4748089",
"0.4745519",
"0.4735949",
"0.47236595",
"0.4720156",
"0.47174668",
"0.47133917",
"0.47088626",
"0.47062415",
"0.4689951",
"0.4680547",
"0.46795928",
"0.46787187",
"0.46787187",
"0.46787187",
"0.46787187",
"0.46772674",
"0.4672966",
"0.46714398",
"0.46714398",
"0.46714398",
"0.46714398"
] | 0.70724845 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_offer
@offer = Offer.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def call\n setup_context\n super\n end"
] | [
"0.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
"0.5312988",
"0.529798",
"0.52968603",
"0.52962637",
"0.52577317",
"0.5244704",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5233461",
"0.52322435",
"0.5227552",
"0.52224743",
"0.5217851",
"0.521241",
"0.52069896",
"0.5206555",
"0.5176617",
"0.51738507",
"0.51725876",
"0.51660734",
"0.51605034",
"0.51571786",
"0.5152762",
"0.5152164",
"0.5151477",
"0.5145819",
"0.51408994",
"0.5134412",
"0.5114031",
"0.5113695",
"0.5113695",
"0.5108603",
"0.5107358",
"0.5090405",
"0.50889385",
"0.50817686",
"0.5081617",
"0.50658226",
"0.50551206",
"0.5051746",
"0.5049091",
"0.5049091",
"0.5034681",
"0.5024972",
"0.5021291",
"0.5016024",
"0.50134826",
"0.50008893",
"0.50000244",
"0.4999155",
"0.49907947",
"0.49907947",
"0.49853387",
"0.49796683",
"0.4979596",
"0.49778128",
"0.49673793",
"0.49662578",
"0.49587822",
"0.4956063",
"0.49550167",
"0.49523485",
"0.4951614",
"0.49452996",
"0.49442068",
"0.49336892",
"0.49306205",
"0.49264124",
"0.49259305",
"0.4925823",
"0.49229056",
"0.4918999",
"0.49171805",
"0.49167436",
"0.4916559",
"0.49153692",
"0.49148256"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def offer_params
params.require(:offer).permit(:merchant_id, :title, :description, :url, :expires_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def list_params\n params.permit(:name)\n end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.6292164",
"0.62917984",
"0.62836355",
"0.6242686",
"0.6241917",
"0.62210834",
"0.6214862",
"0.62125784",
"0.619428",
"0.617912",
"0.617705",
"0.61735916",
"0.6163706",
"0.61532795",
"0.6152666",
"0.6148062",
"0.6123372",
"0.61180484",
"0.61088324",
"0.6106139",
"0.60925204",
"0.608326",
"0.60711503",
"0.606551",
"0.60216546",
"0.6018924",
"0.6015004",
"0.60106766",
"0.6008301",
"0.6008301",
"0.60028726",
"0.60020626",
"0.5999236",
"0.59931505",
"0.5993037",
"0.59917194",
"0.5982164",
"0.5968051",
"0.5960277",
"0.5960268",
"0.5960012",
"0.59594494",
"0.5954652",
"0.5954304",
"0.59440255",
"0.59404963",
"0.59404963",
"0.59401006",
"0.593522",
"0.5932182",
"0.5925528",
"0.5924541",
"0.5918796",
"0.59123147",
"0.5910144",
"0.5909186",
"0.5907257",
"0.5899382",
"0.5897783",
"0.58972496",
"0.58958495",
"0.58948576",
"0.5892734",
"0.5888056",
"0.58843875",
"0.58818483",
"0.5873746",
"0.58700997",
"0.5870056",
"0.5869255",
"0.58668107",
"0.58662325",
"0.5865003",
"0.5862908",
"0.5862406",
"0.58614665",
"0.5859661",
"0.585562",
"0.5855185",
"0.58523446",
"0.58504915"
] | 0.0 | -1 |
GET /instances GET /instances.json | def index
respond_to do |format|
format.html
format.json { render json: InstancesDatatable.new(view_context) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instances\n instances = []\n JSON.parse(resource['/instances'].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n return instances\n end",
"def instances\n IbmCloudRest.get \"#{@uri}/instances\"\n end",
"def index\n @instances = Instance.all\n render json: @instances\n end",
"def index\n @instances = Instance.all\n render :json => @instances\n end",
"def describe_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n params = pathlist(\"InstanceId\", options[:instance_id])\n return response_generator(:action => \"DescribeInstances\", :params => params)\n end",
"def list_instances_detail()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/instances/detail\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n instances = CloudDB.symbolize_keys(JSON.parse(response.body)[\"instances\"])\n return instances\n end",
"def index\n page = params[:page]\n per_page = (params[:per_page] || 10).to_i\n if page\n entities = _all_instances_query.page(page).per(per_page)\n render json: entities, entity: _get_class,\n meta: { total_pages: entities.total_pages, total_count: entities.total_count }\n else\n entities = _all_instances_query\n respond_with entities, entity: '_get_class'\n end\n end",
"def get_instance_data\n JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def list_instances()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/instances\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n instances = CloudDB.symbolize_keys(JSON.parse(response.body)[\"instances\"])\n return instances\n end",
"def index\n @instances = Instance.all\n end",
"def index\n @instances = Instance.all\n end",
"def instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving active instances\"\n fetch_instances\n end",
"def list_instances(request_id)\n instances = []\n JSON.parse(resource[\"/requests/#{request_id}\"].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n end",
"def list_instances\n puts \"OK, Listing instances..\"\n\n response = RestClient.post( \n $uri,\n 'Version' => '2010-12-30',\n 'ACSAccessKeyId' => $ACSAccessKeyId,\n 'Format' => 'json',\n 'Timestamp' => $current_time,\n 'Rndguid' => $rndguid,\n 'Signature' => calculate_signature($api_private_key, $rndguid, $current_time),\n 'Action' => \"list-instances\")\n\n puts response\n puts response.code\nend",
"def describe_instances\n return { reservations: [] } unless configured?\n\n @client.describe_instances.to_h\n end",
"def list_instances()\n response = dbreq(\"GET\",lbmgmthost,\"#{lbmgmtpath}/instances\",lbmgmtport,lbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n instances = CloudDB.symbolize_keys(JSON.parse(response.body)[\"instances\"])\n return instances\n end",
"def list_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_instances_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::BareMetalSolution::V2::ListInstancesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def instance\n perform_request_with_object(:get, '/api/v1/instance', {}, Mastodon::Instance)\n end",
"def instance_data\n @instance_data ||= JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def get_instances\n instances = [ ]\n get_clouds.each do |cloud|\n instances += cloud.instances.index(:filter => [], :view => 'tiny')\n end\n instances\n end",
"def get_cloud_instances(cloud_id)\n http_get_request(Scalarium.clouds_url+\"/#{cloud_id}/instances\") \n end",
"def instance\n perform_request_with_object(:get, '/api/v1/instance', {},\n Mastodon::Instance)\n end",
"def instances\n @instances ||= aws_client.instances(filters: instance_filters).map do |instance|\n OpenStruct.new(\n with_tags(instance, private_ip: instance.private_ip_address,\n public_ip: instance.public_ip_address,\n instance: instance.instance_id)\n )\n end\n end",
"def list_instances token: nil\n instances.list_instances parent: project_path, page_token: token\n end",
"def init_instances\n instances = []\n next_token = nil\n all_records_retrieved = false\n\n until all_records_retrieved\n response = @@client.describe_instances({\n next_token: next_token\n })\n next_token = response.next_token\n all_records_retrieved = next_token.nil? || next_token.empty?\n instances << response.reservations.map { |r| r.instances }\n end\n\n instances.flatten\n end",
"def monitor_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n raise ArgumentError, \"No :instance_id provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n params = pathlist(\"InstanceId\", options[:instance_id])\n return response_generator(:action => \"MonitorInstances\", :params => params)\n end",
"def active_instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving running instances\"\n fetch_instances ['ACTIVE']\n end",
"def index\n @instances = Instance.page params[:page]\n authorize! :read, @instances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instances }\n end\n end",
"def index\n @instances = Instance.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @instances }\n end\n end",
"def getPAYGInstances\n self.class.get('/v1/payAsYouGo/bareMetals/instances', @options)\n end",
"def run_instances(num_vms, opts, roles, disks)\n # Make a copy (the options are a simple hash so shallow copy does the\n # trick) to not modify the original.\n options = opts.clone\n options['num_vms'] = num_vms.to_s\n\n uri = URI(\"http://#{@ip}:#{SERVER_PORT}/instances\")\n headers = {'Content-Type' => 'application/json',\n 'AppScale-Secret' => @secret}\n request = Net::HTTP::Post.new(uri.path, headers)\n\n request.body = JSON.dump(options)\n\n run_result = JSON.parse(make_call(request, uri))\n Djinn.log_debug(\"[IM] Run instances info says [#{run_result}]\")\n operation_id = run_result['operation_id']\n\n vm_info = {}\n loop {\n begin\n describe_result = describe_operation(operation_id)\n rescue Djinn::FailedNodeException => error\n Djinn.log_warn(\n \"[IM] Error describing run instances operation #{operation_id}. \" \\\n \"Error: #{error.message}\")\n next\n end\n Djinn.log_debug(\"[IM] Describe run operation has vm_info \" \\\n \"#{describe_result['vm_info'].inspect}.\")\n\n if describe_result['state'] == 'success'\n vm_info = describe_result['vm_info']\n break\n elsif describe_result['state'] == 'failed'\n raise AppScaleException.new(describe_result['reason'])\n end\n Kernel.sleep(SMALL_WAIT)\n }\n\n # ip:role:instance-id\n instances_created = []\n vm_info['public_ips'].each_index { |index|\n tmp_roles = roles[index]\n tmp_roles = 'open' if roles[index].nil?\n instances_created << {\n 'public_ip' => vm_info['public_ips'][index],\n 'private_ip' => vm_info['private_ips'][index],\n 'roles' => tmp_roles,\n 'instance_id' => vm_info['instance_ids'][index],\n 'disk' => disks[index],\n 'instance_type' => options['instance_type']\n }\n }\n\n instances_created\n end",
"def get_instances_description\n instances\n end",
"def get_by_id(id)\n self.class.get(\"/aldebaran-instances/instances/#{id}\", :basic_auth => @auth)\n end",
"def instances(arg)\n case arg\n when Range\n minimum_instances arg.first\n maximum_instances arg.last\n when Fixnum\n minimum_instances arg\n maximum_instances arg\n when Hash\n nodes(arg)\n else\n raise SpecException.new(\"Don't know how to handle instances cloud input #{arg}\")\n end\n end",
"def list_instances token: nil\n execute do\n instances.list_instances(\n project_path,\n page_token: token\n )\n end\n end",
"def show\n @instance = Instance.find(params[:id])\n render :json =>@instance\n end",
"def all_instances\n Puppet.debug(\"all_instances - cached instances is: #{cached_instances}\")\n Puppet.debug(\"all_instances - cached instances object id: #{cached_instances.object_id}\")\n # return cache if it has been created, this means that this function will only need\n # to be loaded once, returning all instances that exist of this resource in vsphere\n # then, we can lookup our version by name/id/whatever. This saves a TON of processing\n return cached_instances unless cached_instances.nil?\n\n # Want to return an array of instances\n # each hash should have the same properties as the properties\n # of this \"type\"\n # remember the keys should be symbols, aka :ntp_servers not 'ntp_servers'\n # This is a tracking hash which will contain info about each host and NTP server relationships\n cmd = <<-EOF\n $ntp_servers_hash = @{}\n $hosts = #{powercli_get_online_hosts}\n foreach($h in $hosts) {\n $servers = Get-VMHostNtpServer -VMHost $h\n if ($servers) {\n $ntp_servers_hash[$h.Name] = @($servers)\n } else {\n $ntp_servers_hash[$h.Name] = @()\n }\n }\n $ntp_servers_hash | ConvertTo-Json\n EOF\n\n ntpservers_stdout = powercli_connect_exec(cmd)[:stdout]\n # json parse expects a json string, powershell does not stdout with quotes\n # we might be able to remove this line because powershell exits with a viable ruby array already:\n # [\n # \"time1.dev.encore.tech\",\n # \"time2.dev.encore.tech\"\n # ]\n # what happens if this returns null??\n ntpservers_hash = JSON.parse(ntpservers_stdout)\n\n # create instance hash - this contains info about ONE host at a time\n # the values should match the data \"shape\" (ie have the same fields) as our\n # type.\n # the key, should be the title/namevar so we can do a lookup in our\n # read_instance function\n cached_instances_set({})\n ntpservers_hash.each do |esx_host, ntp_servers_array|\n cached_instances[esx_host] = {\n ensure: :present,\n esx_host: esx_host,\n ntp_servers: ntp_servers_array,\n }\n end\n Puppet.debug(\"all_instances - cached instances is at end: #{cached_instances}\")\n Puppet.debug(\"all_instances - cached instances object_id at end: #{cached_instances.object_id}\")\n cached_instances\n end",
"def instances_list\n return [] unless configured?\n\n @service.fetch_all do |token|\n @service.list_instances(@gcp_config['project'], @gcp_config['zone'], page_token: token)\n end.map(&:name)\n end",
"def instances\n @instances ||= []\n end",
"def instances(type)\n @instances[type]\n end",
"def list_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_instances_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Notebooks::V1::ListInstancesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def describe_container_instances(params={})\n if instances = params.delete('containerInstances')\n params.merge!(Fog::AWS.indexed_param('containerInstances.member', [*instances]))\n end\n\n request({\n 'Action' => 'DescribeContainerInstances',\n :parser => Fog::Parsers::AWS::ECS::DescribeContainerInstances.new\n }.merge(params))\n end",
"def show\n @instance = Instance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def available_instances\n @available_instances ||= {}\n end",
"def get_pvm_instances\n pvm_instances = get(\"cloud-instances/#{guid}/pvm-instances\")[\"pvmInstances\"] || []\n\n pvm_instances.map do |pvm_instance|\n get_pvm_instance(pvm_instance[\"pvmInstanceID\"])\n end\n end",
"def fetch_instance(shortname = :all, options = {})\n return instances if instances && !options[:force]\n\n fetch_stack\n unless instance_list\n self.instance_list = self.instances =\n aws_client.describe_instances(stack_id: stack[:stack_id])[:instances]\n end\n\n if shortname != :all\n fetch_layer(shortname, force: true)\n self.instances = []\n\n layers.each do |layer|\n instance = aws_client.describe_instances(\n layer_id: layer[:layer_id])\n self.instances << instance[:instances]\n end\n\n self.instances.flatten!\n end\n end",
"def index\n account = Account.find(params[:account_id])\n @instances = obtain_instances(account.id, account.account_regions.first.region)\n\n @servers = {}\n @instances.each do |instance|\n @servers[instance.instance_id] = Server.find_by(instance_id: instance.instance_id) || @account.servers.create(instance_id: instance.instance_id)\n end\n rescue => e\n render text: e.message\n end",
"def my_instance_id\n Net::HTTP.get(URI('http://169.254.169.254/1.0/meta-data/instance-id'))\n end",
"def get_instance instance_id\n instances.get_instance name: instance_path(instance_id)\n end",
"def new\n @flavours = @provider.get_flavors\n puts \"getting the flavors #{@flavours.inspect}\"\n @images = @provider.get_images\n puts \"getting the flavors #{@images.inspect}\"\n @instance = @provider.instances.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end",
"def instances()\n return @instances\n end",
"def aws_instance_get(opts)\n AWS::EC2.new.instances[opts[:instance_id]]\n end",
"def vm_instances\n @conn.vminstances\n end",
"def all_instances\n Puppet.debug(\"all_instances - cached instances is: #{cached_instances}\")\n Puppet.debug(\"all_instances - cached instances object id: #{cached_instances.object_id}\")\n # return cache if it has been created, this means that this function will only need\n # to be loaded once, returning all instances that exist of this resource in vsphere\n # then, we can lookup our version by name/id/whatever. This saves a TON of processing\n return cached_instances unless cached_instances.nil?\n\n # Fetch the current status of the portgroup\n cmd = <<-EOF\n $portgroup_hash = @{}\n $hosts = #{powercli_get_online_hosts}\n foreach($h in $hosts) {\n # We silently continue on errors otherwise PowerCLI creates an error if the\n # portgroup does not exist on the host which pollutes our $portgroup_hash return object\n $pg = Get-VirtualSwitch -Host $h -Standard -Name #{resource[:vswitch_name]} | Get-VirtualPortGroup -Name #{resource[:portgroup]} -ErrorAction SilentlyContinue\n if ($pg) {\n $obj_hash = @{}\n $obj_hash.Add('portgroup', $pg.Name)\n $obj_hash.Add('vlan', $pg.VLanId)\n $obj_hash.Add('vswitch_name', $pg.VirtualSwitchName)\n $portgroup_hash[$h.Name] = @($obj_hash)\n } else {\n # create empty hashtable\n $obj_hash = @{}\n $portgroup_hash[$h.Name] = @($obj_hash)\n }\n }\n $portgroup_hash | ConvertTo-Json\n EOF\n\n portgroups_stdout = powercli_connect_exec(cmd)[:stdout]\n\n unless portgroups_stdout.empty?\n portgroups_hash = JSON.parse(portgroups_stdout)\n cached_instances_set({})\n portgroups_hash.each do |esx_host, pg_array|\n # Extracting hash from array object\n pg_hash = pg_array[0]\n cached_instances[esx_host] = {\n ensure: :present,\n esx_host: esx_host,\n vswitch_name: pg_hash['vswitch_name'],\n vlan: pg_hash['vlan'],\n portgroup: pg_hash['portgroup'],\n }\n end\n end\n Puppet.debug(\"all_instances - cached instances is at end: #{cached_instances}\")\n Puppet.debug(\"all_instances - cached instances object_id at end: #{cached_instances.object_id}\")\n cached_instances\n end",
"def show\n #@instance = Instance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def start_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n raise ArgumentError, \"No :instance_id provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n params = {}\n params.merge!(pathlist(\"InstanceId\", options[:instance_id]))\n return response_generator(:action => \"StartInstances\", :params => params)\n end",
"def instances\n end",
"def index\n\n credentials = Aws::Credentials.new('AKIAJ2JD2EKKFVDSR37A', 'cnZUnzuyYPqUevEPb045VJUnW55VR+rUCQrplzd/')\n ec2 = Aws::EC2::Client.new(\n region: \"us-east-1\",\n credentials: credentials\n )\n #i = ec2.instances.create(:image_id => \"ami-e3106686\")\n resp = ec2.run_instances({\n dry_run: true,\n image_id: \"ami-e3106686\", # required\n min_count: 1, # required\n max_count: 1, # required\n instance_type: \"t1.micro\", # accepts t1.micro, m1.small, m1.medium, m1.large, m1.xlarge, m3.medium, m3.large, m3.xlarge, m3.2xlarge, m4.large, m4.xlarge, m4.2xlarge, m4.4xlarge, m4.10xlarge, t2.micro, t2.small, t2.medium, t2.large, m2.xlarge, m2.2xlarge, m2.4xlarge, cr1.8xlarge, i2.xlarge, i2.2xlarge, i2.4xlarge, i2.8xlarge, hi1.4xlarge, hs1.8xlarge, c1.medium, c1.xlarge, c3.large, c3.xlarge, c3.2xlarge, c3.4xlarge, c3.8xlarge, c4.large, c4.xlarge, c4.2xlarge, c4.4xlarge, c4.8xlarge, cc1.4xlarge, cc2.8xlarge, g2.2xlarge, cg1.4xlarge, r3.large, r3.xlarge, r3.2xlarge, r3.4xlarge, r3.8xlarge, d2.xlarge, d2.2xlarge, d2.4xlarge, d2.8xlarge\n placement: {\n tenancy: \"default\", # accepts default, dedicated\n },\n\n block_device_mappings: [\n {\n virtual_name: \"String\",\n device_name: \"String\",\n ebs: {\n snapshot_id: \"String\",\n volume_size: 1,\n delete_on_termination: true,\n volume_type: \"standard\", # accepts standard, io1, gp2\n iops: 1,\n encrypted: true,\n },\n\n },\n ],\n monitoring: {\n enabled: true, # required\n },\n disable_api_termination: true,\n instance_initiated_shutdown_behavior: \"stop\", # accepts stop, terminate\n network_interfaces: [\n {\n delete_on_termination: true,\n private_ip_addresses: [\n {\n private_ip_address: \"172.31.2.177\", # required\n primary: true,\n },\n ],\n secondary_private_ip_address_count: 1,\n associate_public_ip_address: true,\n },\n ],\n ebs_optimized: true,\n })\n @ec2_instances = Ec2Instance.all\n end",
"def describe_all_instances\n @os_aws.describe_all_instances\n end",
"def info(type, instance_id, options={})\n args = {type: type, instanceId: instance_id}.merge(options)\n get('cloudInstanceInfo', args)\n end",
"def index\n @app_instances = AppInstance.all\n end",
"def cached_instances\n # Puppet.debug(\"cached_instances - object id: #{PuppetX::PowerCLI::Helper.instance.object_id}\")\n # Puppet.debug(\"cached_instances - resource.type: #{resource.type}\")\n PuppetX::PowerCLI::Helper.instance.cached_instances[resource.type]\n end",
"def show\n @instance = Instance.find(params[:id])\n @flavor = Flavor.find_by_flavor_id(@instance.flavor_id)\n @image = Image.find_by_image_id(@instance.image_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def instances\n @instances ||= begin\n instances_channel = channel(\n Admin::V2::BigtableInstanceAdminClient::SERVICE_ADDRESS\n )\n Admin::V2::BigtableInstanceAdminClient.new(\n credentials: instances_channel,\n timeout: timeout,\n client_config: client_config,\n lib_name: \"gccl\",\n lib_version: Google::Cloud::Bigtable::VERSION\n )\n end\n end",
"def index\n @docker_instances = DockerInstance.all\n @docker_instance = DockerInstance.new\n end",
"def show\n @instance_type = InstanceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance_type }\n end\n end",
"def terminate_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n raise ArgumentError, \"No :instance_id provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n params = pathlist(\"InstanceId\", options[:instance_id])\n return response_generator(:action => \"TerminateInstances\", :params => params)\n end",
"def get_images\n images = get(\"cloud-instances/#{guid}/images\")[\"images\"] || []\n\n images.map do |image|\n get_image(image[\"imageID\"])\n end.compact\n end",
"def instances; end",
"def instances; end",
"def get_instances(role: nil, username: nil, bastion: nil)\n puts \"Getting instances for role: #{role}\"\n servers = []\n instances_for_role(role).each do |res|\n res[:instances].each do |inst|\n servers << \"#{username}@#{inst[:private_ip_address]}\"\n end\n end\n\n puts \" - #{servers.join(', ')}\"\n servers\n end",
"def instances_status\n @instances.each do |i_id, meta|\n status = AWS::CLI_Interface.ec2_instance_status(i_id)\n output = \"#{meta['name']} (#{i_id})\".colorize(color: :white, background: :blue) +\n \" : \".colorize(:yellow) +\n \"#{status[:label]}\".colorize(color: :white, background: status[:color])\n\n if meta.has_key? 'timeout'\n output += \" : \".colorize(:yellow)\n output += \"Timeout: #{meta['timeout']}\".colorize(color: :black, background: :light_yellow)\n end\n\n Logging.log output\n end\n end",
"def instances\n @instances ||= init_instances.reject(&:terminated?)\n end",
"def show\n @server_instance = ServerInstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @server_instance }\n end\n end",
"def aws_read_instances\n list = JSON.parse( IO.read( aws_instances_json ), :symbolize_names => true )\n list.each do |inst|\n inst[:roles] = ( inst[:roles] || [] ).map { |r| r.to_sym }\n end\n @aws_instances = list.sort { |p,n| p[:name] <=> n[:name] }\n end",
"def get_pcloud_instance\n get(\"cloud-instances/#{guid}\")\n end",
"def instance_get(path)\n result = $evm.instance_get(path)\n # Returns Hash\n $evm.log('info',\"Instance:<#{path}> properties:<#{result.inspect}>\") if @debug\n return result\n end",
"def lookup_instance_id\n metadata_endpoint = 'http://169.254.169.254/latest/meta-data/'\n instance_id = Net::HTTP.get( URI.parse( metadata_endpoint + 'instance-id' ) )\n end",
"def aws_write_instances\n File.open( aws_instances_json, 'w' ) do |fout|\n aws_dump_instances( fout )\n end\n end",
"def me\n require 'open-uri'\n begin\n instance_id = open('http://169.254.169.254/latest/meta-data/instance-id').read\n instance instance_id\n rescue OpenURI::HTTPError => e\n nil\n end\n end",
"def instance_list(next_token=nil)\n self.ec2_client.describe_instances(\n {\n filters: [\n {\n name: \"tag:Branch\",\n values: [\"*\"],\n },\n {\n name: \"instance-state-name\",\n values: [\"running\"],\n }\n ],\n next_token: next_token\n })\n end",
"def list_of_instances(keyp=nil)\n tmp_key = (keyp ? keyp : nil)\n \n unless @describe_instances\n tmpInstanceList = remote_base.describe_instances(options).select {|a| a if (tmp_key.nil? || tmp_key.empty? ? true : a[:keypair] == tmp_key) }\n has_master = !tmpInstanceList.select {|a| a[:name] == \"master\" }.empty? \n if has_master\n @describe_instances = tmpInstanceList\n else\n @id = 0\n running = select_from_instances_on_status(/running/, tmpInstanceList)\n pending = select_from_instances_on_status(/pending/, tmpInstanceList)\n terminated = select_from_instances_on_status(/shutting/, tmpInstanceList)\n \n running = running.map do |inst|\n inst[:name] = (@id == 0 ? \"master\" : \"node#{@id}\")\n @id += 1\n inst\n end.sort_by {|a| a[:index] }\n \n @describe_instances = [running, pending, terminated].flatten\n end\n end\n @describe_instances\n end",
"def get_instances(incl_stopped=false)\n \n instances = @ec2.describe_instances\n instances = instances.select { |x| x[:aws_groups].include? @group_name }\n \n if(instances.length == 0)\n raise CaTPAWS::EC2::Error::InstanceRetrieval, \"No instances found in this group\"\n end \n \n unless (incl_stopped)\n instances = instances.select {|x| x[:aws_state_code].to_i <= 16}\n end\n @instances = instances\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def show\n @instance_action = InstanceAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance_action }\n end\n end",
"def call_describe_instances\n\t`ec2-describe-instances >> #{EC2_DESCRIBE_INSTANCES_OUTPUT}`\nend",
"def db_instances(region)\n logger.info(\"fetching db instances of region #{region}\")\n rds_client = get_rds_client(region)\n next_token = nil\n rds_instances = []\n\n loop do\n options = { marker: next_token }\n resp = rds_client.describe_db_instances(options)\n rds_instances += resp.db_instances\n next_token = resp.marker\n break unless next_token\n end\n rds_instances\n end",
"def get_instances\n all_instances = Array.new()\n @groups.values.each do |instances|\n instances.each do |instance|\n all_instances << instance\n end\n end\n all_instances\n end",
"def get_role_instances(cloud_id, role_id)\n http_get_request(Scalarium.clouds_url+\"/#{cloud_id}/roles/#{role_id}/instances\")\n end",
"def get_instance instance_id\n execute do\n instances.get_instance(\n instance_path(instance_id)\n )\n end\n end",
"def create_instances(count)\n result = client.run_instances(AwsForm.map(params.merge(count: count)))\n instance_ids = result.instances.map(&:instance_id)\n ret = wait_for_create(instance_ids)\n # need to make sure add_tags is done after after wait_until or can have error that instance ids dont exist\n add_tags?(instance_ids, with_dtk_tag: true)\n IamInstanceProfile.set_iam_instance_profiles(self, instance_ids, params.iam_instance_profile) unless params.iam_instance_profile.nil?\n ret\n end",
"def id_instances\n @id_instances ||= Hash[instances.map { |i| [i.instance_id, i] }]\n end",
"def populate\n response = @connection.dbreq(\"GET\",@lbmgmthost,\"#{@lbmgmtpath}/instances/#{CloudDB.escape(@id.to_s)}\",@lbmgmtport,@lbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n data = JSON.parse(response.body)['instance']\n @id = data[\"id\"]\n @name = data[\"name\"]\n @hostname = data[\"hostname\"]\n @created = data[\"created\"]\n @updated = data[\"updated\"]\n @flavor_id = data[\"flavor\"][\"id\"]\n @volume_size = data[\"volume\"][\"size\"]\n @status = data[\"status\"]\n true\n end",
"def list\n attrcheck = { 'compartment' => @options[:compartment] }\n @validate.validate(@options, attrcheck)\n opts = {}\n opts[:availability_domain] = @options[:availability_domain] if @options[:availability_domain]\n opts[:display_name] = @options[:display_name] if @options[:display_name]\n BmcAuthenticate.new(@options)\n request = OracleBMC::Core::ComputeClient.new\n request = request.list_instances(@options[:compartment], opts)\n request.data\n end",
"def get_docker_instance_list(options)\n message = \"Information:\\tListing docker images\"\n command = \"docker ps\"\n output = execute_command(options,message,command)\n instances = output.split(/\\n/)\n return instances\nend",
"def active_instances; end",
"def show\n render json: @instance\n end",
"def in_service_instances\n instances([{name: :lifecycle_state, value: \"InService\"}])\n end",
"def aws_dump_instances( fout = $stdout )\n fout.puts '['\n rows = @aws_instances.sort { |p,n| p[:name] <=> n[:name] }\n rows.each_with_index do |row, i|\n fout.puts( \" \" + JSON.generate( row, :space => ' ', :object_nl => ' ' ) +\n ( ( i == ( rows.length - 1 ) ) ? '' : ',' ) )\n end\n fout.puts ']'\n end",
"def loaded_instances(type)\n @instances[type].keys\n end",
"def index\n @instance_types = InstanceType.all\n end"
] | [
"0.8298414",
"0.7888994",
"0.7575153",
"0.7551725",
"0.7366865",
"0.7276911",
"0.72706306",
"0.7262274",
"0.71395165",
"0.70884764",
"0.70884764",
"0.7082083",
"0.6975288",
"0.69422376",
"0.69419104",
"0.68218666",
"0.67669797",
"0.67655206",
"0.6760263",
"0.67555255",
"0.67318463",
"0.6717446",
"0.6699296",
"0.66728675",
"0.6659762",
"0.6614021",
"0.6558822",
"0.65042585",
"0.6487484",
"0.6480149",
"0.6472685",
"0.6463241",
"0.64492816",
"0.6443129",
"0.64387596",
"0.6437489",
"0.6437203",
"0.64284736",
"0.6406146",
"0.6405464",
"0.6401748",
"0.63456863",
"0.6308029",
"0.6278657",
"0.6238052",
"0.6225522",
"0.62123305",
"0.61841756",
"0.6168554",
"0.61494446",
"0.6146404",
"0.6144076",
"0.611044",
"0.6095676",
"0.60955065",
"0.6087819",
"0.6084278",
"0.6069924",
"0.60670835",
"0.60633576",
"0.60032743",
"0.598355",
"0.59327227",
"0.5928905",
"0.5922461",
"0.59134465",
"0.5908806",
"0.5898364",
"0.58923316",
"0.58923316",
"0.58819646",
"0.5881668",
"0.5880309",
"0.5877517",
"0.5874342",
"0.58519316",
"0.5849197",
"0.58199024",
"0.58169454",
"0.58085793",
"0.58069986",
"0.5804653",
"0.5795274",
"0.5787248",
"0.57796144",
"0.5770494",
"0.5762661",
"0.5761037",
"0.5735026",
"0.5725348",
"0.57175195",
"0.5711352",
"0.5708319",
"0.5696877",
"0.56890357",
"0.56845826",
"0.56786275",
"0.5666857",
"0.5661496",
"0.56524426",
"0.5643214"
] | 0.0 | -1 |
General handler utility functions This is a template method that is used to escape results values (returned in execute) that would cause the XML to be invalid. This method is not necessary if values do not contain character that have special meaning in XML (&, ", ), however it is a good practice to use it for all return variable results in case the value could include one of those characters in the future. This method can be copied and reused between handlers. | def escape(string)
# Globally replace characters based on the ESCAPE_CHARACTERS constant
string.to_s.gsub(/[&"><]/) { |special| ESCAPE_CHARACTERS[special] } if string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml_escape(input); end",
"def escape_xml(value)\n value.to_s.gsub(/[&<>\"']/) { |s| ESCAPE_TABLE[s] } # or /[&<>\"']/\n end",
"def xml_escape(input)\n return input.to_s.to_xs\n end",
"def escape(val)\n return val\n end",
"def escape_xml(string) \n string.gsub(/[&<>\\'\\\"]/) do | match |\n case match\n when '&' then '&'\n when '<' then '<'\n when '>' then '>'\n when '\"' then '"'\n when \"'\" then '''\n end\n end \n end",
"def test_output_escaping\n\t\ttext = '<bad-script>if (a < b || b > c) { return \"text\"; }<stop/>return \">>>snip<<<\";</bad-script>'\n node = LibXML::XML::Parser.string(text).parse.root\n\t\tassert_equal text, node.to_s\n\n\t\ttext_noenc = '<bad-script>if (a < b || b > c) { return \"text\"; }<stop/>return \">>>snip<<<\";</bad-script>'\n\t\tnode.output_escaping = false\n\t\tassert_equal text_noenc, node.to_s\n\n\t\tnode.output_escaping = true\n\t\tassert_equal text, node.to_s\n\n\t\tnode.output_escaping = nil\n\t\tassert_equal text_noenc, node.to_s\n\n\t\tnode.output_escaping = true\n\t\tassert_equal text, node.to_s\n end",
"def escape(value)\n end",
"def test_output_escaping_sanity\n\t\ttext = '<bad-script>if (a < b || b > c) { return \"text\"; }<stop/>return \">>>snip<<<\";</bad-script>'\n node = LibXML::XML::Parser.string(text).parse.root\n\t\taffected = node.find('//text()')\n\n\t\tcheck_escaping = lambda do |flag|\n\t\t\tassert_equal('bad-script', node.name)\n\t\t\tassert_equal(flag, node.output_escaping?)\n\t\t\taffected.each do |x|\n\t\t\t\tassert_equal(flag ? 'text' : 'textnoenc', x.name)\n\t\t\t\tassert_equal(flag, x.output_escaping?)\n\t\t\tend\n\t\tend\n\n\t\tnode.output_escaping = false\n\t\tcheck_escaping[false]\n\n\t\tnode.output_escaping = true\n\t\tcheck_escaping[true]\n\n\t\tnode.output_escaping = nil\n\t\tcheck_escaping[false]\n\n\t\tnode.output_escaping = true\n\t\tcheck_escaping[true]\n\n\t\taffected.first.output_escaping = true\n\t\taffected.last.output_escaping = false\n\t\tassert node.output_escaping?.nil?\n end",
"def consume_escaped; end",
"def escape_xml(string)\n string.gsub!(\"&\", \"&\")\n string.gsub!(\"<\", \"<\")\n string.gsub!(\">\", \">\")\n string.gsub!(\"'\", \"'\")\n string.gsub!(\"\\\"\", \""\")\n\n return string\n end",
"def escape_xml(xml_in) \n return xml_in.gsub(/&/,'&').gsub(/</,'<')\n end",
"def clean_value\n if (type == :string || type == :text) && !Axlsx.trust_input\n Axlsx.sanitize(::CGI.escapeHTML(@value.to_s))\n else\n @value.to_s\n end\n end",
"def escape_xml_data(xml_data)\n xml_data = xml_data.gsub(\"\\n\", \"\")\n xml_data = xml_data.gsub(\"\\n\", \"\")\n xml_data = xml_data.gsub(/[\\>]([ ])*[\\<]/, \"><\")\n return xml_data\n\n end",
"def get_handler_xml_results(args = {})\r\n results = \"<results>\"\r\n args.each do |key,value|\r\n results << %|<result name=\"#{escape(key.to_s)}\">#{escape(value.to_s)}</result>|\r\n end\r\n results << \"</results>\"\r\n return results\r\n end",
"def parse_value_rexml(value, ns_strs, language)\n # Fixme\n end",
"def parse_escaped_chars; end",
"def xml_attr_escape\n replacements = {\"<\" => \"<\", \">\" => \">\", \"&\" => \"&\", \"\\\"\" => \""\", \"'\" => \"'\"}\n gsub(/([<>&\\'\\\"])/) { replacements[$1] }\n end",
"def xp str\n\t\treturn Mandar::Tools::Escape.xpath str\n\tend",
"def page_meta_escape_value(val)\n val.to_s.gsub(\"<\", \"<\").gsub(\">\", \">\")\n end",
"def uri_escape\n str = xml_escape.gsub(/\\+/, '+')\n str = str.gsub(/\\s/, '+')\n end",
"def _reduce_493(val, _values, result)\n result = \"&#{value(val[1])}\".to_sym\n \n result\nend",
"def escape(string); end",
"def escape(str); end",
"def xml_sanitize(str)\n str.gsub(/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/, \"?\")\nend",
"def xml_sanitize(str)\n str.gsub(/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/, \"?\")\nend",
"def test_sql_escaped\n exc_handler = HumanParseExceptionHandler.new\n new_str = exc_handler.get_human_result_for_string(\"fo'ob\\\"ar\",\"ParseException\")\n assert_equal(false, new_str)\n end",
"def protectXML(content)\n content.gsub('&','&').gsub('<','<').gsub('>','>')\n end",
"def create_escape_value(value)\n if value.is_a?(String) || value.is_a?(Symbol)\n \"#{sanitize_escape_sequences(value.to_s)}\"\n else\n value\n end\n end",
"def e(value)\n CGI.escape(value)\n end",
"def _reduce_555(val, _values, result)\n result = \"&#{value(val[1])}\".to_sym\n \n result\nend",
"def esc(str)\n str = str.to_s.gsub(\"&\", \"&\")\n str = str.gsub(\"\\\"\", \"'\")\n str = str.gsub(\"\\\"\", \""\")\n str = str.gsub(\"<\", \"<\")\n str.gsub(\">\", \">\")\nend",
"def escape(value)\n value.nil? ? nil : value.shellescape\n end",
"def html_escape(clean_me)\n clean_me.to_s.gsub(/[&\"<>]/) do |special|\n { '&' => '&',\n '>' => '>',\n '<' => '<',\n '\"' => '"' }[special]\n end\n end",
"def escape_content\n content.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\") \n end",
"def _reduce_583(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def escaped_value(item)\n result = item.is_a?(Symbol) ? item.to_s : item\n result = result.to_json unless result.is_a?(String)\n # noinspection RubyMismatchedArgumentType\n Rack::Utils.escape(result)\n end",
"def to_soap_value\n CGI.escapeHTML self\n end",
"def unicode_esc!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n \n # - - - - main rule block - - - -\n # at line 309:9: '\\\\\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT\n match( 0x5c )\n match( 0x75 )\n hex_digit!\n hex_digit!\n hex_digit!\n hex_digit!\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n end",
"def unescape_xml(text)\n CGI.unescape_html text\n end",
"def escape_special_chars(data)\n data = data.dup\n data.gsub! /&/n , \"&\"\n data.gsub! /\\\"/n , \""\"\n data.gsub! />/n , \">\"\n data.gsub! /</n , \"<\"\n data.gsub! /'/ , \"'\"\n return data\n end",
"def escape_xml(text)\n text.encode(xml: :text)\n end",
"def _reduce_585(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_585(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_582(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_582(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_582(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_587(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def /(val)\n data / Reg.clean_value(val)\n end",
"def _reduce_511(val, _values, result)\n result = \"&#{value(val[1])}\".to_sym\n \n result\nend",
"def resolve_xml_entities(text)\r\n result=text\r\n result.gsub!(\"<\", \"<\")\r\n result.gsub!(\">\", \">\")\r\n result.gsub!(\"&\", \"&\")\r\n result\r\n end",
"def parse_smart_quotes; end",
"def escape(value)\n _escape(value.to_s.to_str)\n rescue ArgumentError\n _escape(value.to_s.to_str.force_encoding(Encoding::UTF_8))\n end",
"def escape_value(connection, value)\n connection.quote(value)\n end",
"def _reduce_580(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_580(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_580(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def xml?; end",
"def xml?; end",
"def clean_param(leave_slashes: false)\n return unless @val\n\n val = @val.to_s.strip\n val.gsub!(/\\\\(.)/, \"\\\\1\") unless leave_slashes\n val\n end",
"def sanitize(options={})\n coder = HTMLEntities.new()\n \n #lowercase it\n encoded = self.downcase()\n \n #convert special chars to html entities\n encoded = coder.encode(encoded, :named)\n \n #replace spaces by _ (underscore)\n encoded = encoded.gsub(/\\s+/i, '_')\n \n while ((found = encoded.match(/&([^&;]+);/i)))\n #char without accent, is the first in the html entity definition\n char = found[1][0]\n \n char_ord = coder.decode(found[0]).ord()\n if ( (char_ord >= 192 && char_ord <= 214) ||\n (char_ord >= 216 && char_ord <= 223) ||\n (char_ord >= 224 && char_ord <= 246) ||\n (char_ord >= 248 && char_ord <= 255)\n )\n #valid character\n else\n char = \"_\"\n end\n \n #replace encoded\n encoded = encoded.gsub(/#{ Regexp.escape(found[0]) }/, char)\n end\n \n return encoded\n end",
"def escape_quotes(unfiltered)\n unfiltered.to_s.gsub(/'/, \"''\")\n end",
"def rdf_string_prep value\n return unless value.present?\n # the next two steps have been moved here from `export_rdf.rake`\n value.gsub!(\"\\r\\n\", '') # remove CrLf\n value.gsub!(\"\\\\\", '') # remove \"\\\" to avoid illegal control characters\n return value unless value =~ SINGLE_QUOTE_REGEXP\n value.strip!\n # replace initial or final \"'\" with \"\\'\"\n value.gsub(%r{^'|'$}, %q{\\\\\\'})\n end",
"def xpath_sanitize(text)\n # If there's nothing to escape, just wrap text in single-quotes\n if !text.include?(\"'\")\n return \"'#{text}'\"\n else\n result = text.gsub(/'/, %{', \"'\", '})\n return \"concat('#{result}')\"\n end\n end",
"def _reduce_603(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n\n result\nend",
"def cgi_escape(input); end",
"def quote(value); end",
"def _reduce_610(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n\n result\nend",
"def force_correct_attribute_escaping!(node)\n return unless Nokogiri::VersionInfo.instance.libxml2?\n\n node.attribute_nodes.each do |attr_node|\n next unless LibxmlWorkarounds::BROKEN_ESCAPING_ATTRIBUTES.include?(attr_node.name)\n\n tag_name = LibxmlWorkarounds::BROKEN_ESCAPING_ATTRIBUTES_QUALIFYING_TAG[attr_node.name]\n next unless tag_name.nil? || tag_name == node.name\n\n #\n # this block is just like CGI.escape in Ruby 2.4, but\n # only encodes space and double-quote, to mimic\n # pre-2.9.2 behavior\n #\n encoding = attr_node.value.encoding\n attr_node.value = attr_node.value.gsub(/[ \"]/) do |m|\n \"%\" + m.unpack(\"H2\" * m.bytesize).join(\"%\").upcase\n end.force_encoding(encoding)\n end\n end",
"def escape(string)\n #This is a stub, used for indexing\n end",
"def xml_unescape(extra_entities=nil)\n @@xhtml_entity_replacements ||= {\n 'nbsp' => 160,\n 'iexcl' => 161,\n 'cent' => 162,\n 'pound' => 163,\n 'curren' => 164,\n 'yen' => 165,\n 'brvbar' => 166,\n 'sect' => 167,\n 'uml' => 168,\n 'copy' => 169,\n 'ordf' => 170,\n 'laquo' => 171,\n 'not' => 172,\n 'shy' => 173,\n 'reg' => 174,\n 'macr' => 175,\n 'deg' => 176,\n 'plusmn' => 177,\n 'sup2' => 178,\n 'sup3' => 179,\n 'acute' => 180,\n 'micro' => 181,\n 'para' => 182,\n 'middot' => 183,\n 'cedil' => 184,\n 'sup1' => 185,\n 'ordm' => 186,\n 'raquo' => 187,\n 'frac14' => 188,\n 'frac12' => 189,\n 'frac34' => 190,\n 'iquest' => 191,\n 'Agrave' => 192,\n 'Aacute' => 193,\n 'Acirc' => 194,\n 'Atilde' => 195,\n 'Auml' => 196,\n 'Aring' => 197,\n 'AElig' => 198,\n 'Ccedil' => 199,\n 'Egrave' => 200,\n 'Eacute' => 201,\n 'Ecirc' => 202,\n 'Euml' => 203,\n 'Igrave' => 204,\n 'Iacute' => 205,\n 'Icirc' => 206,\n 'Iuml' => 207,\n 'ETH' => 208,\n 'Ntilde' => 209,\n 'Ograve' => 210,\n 'Oacute' => 211,\n 'Ocirc' => 212,\n 'Otilde' => 213,\n 'Ouml' => 214,\n 'times' => 215,\n 'Oslash' => 216,\n 'Ugrave' => 217,\n 'Uacute' => 218,\n 'Ucirc' => 219,\n 'Uuml' => 220,\n 'Yacute' => 221,\n 'THORN' => 222,\n 'szlig' => 223,\n 'agrave' => 224,\n 'aacute' => 225,\n 'acirc' => 226,\n 'atilde' => 227,\n 'auml' => 228,\n 'aring' => 229,\n 'aelig' => 230,\n 'ccedil' => 231,\n 'egrave' => 232,\n 'eacute' => 233,\n 'ecirc' => 234,\n 'euml' => 235,\n 'igrave' => 236,\n 'iacute' => 237,\n 'icirc' => 238,\n 'iuml' => 239,\n 'eth' => 240,\n 'ntilde' => 241,\n 'ograve' => 242,\n 'oacute' => 243,\n 'ocirc' => 244,\n 'otilde' => 245,\n 'ouml' => 246,\n 'divide' => 247,\n 'oslash' => 248,\n 'ugrave' => 249,\n 'uacute' => 250,\n 'ucirc' => 251,\n 'uuml' => 252,\n 'yacute' => 253,\n 'thorn' => 254,\n 'yuml' => 255,\n 'quot' => 34,\n 'apos' => 39, # Wasn't present in the HTML entities set, but is defined in XML standard\n 'amp' => 38,\n 'lt' => 60,\n 'gt' => 62,\n 'OElig' => 338,\n 'oelig' => 339,\n 'Scaron' => 352,\n 'scaron' => 353,\n 'Yuml' => 376,\n 'circ' => 710,\n 'tilde' => 732,\n 'ensp' => 8194,\n 'emsp' => 8195,\n 'thinsp' => 8201,\n 'zwnj' => 8204,\n 'zwj' => 8205,\n 'lrm' => 8206,\n 'rlm' => 8207,\n 'ndash' => 8211,\n 'mdash' => 8212,\n 'lsquo' => 8216,\n 'rsquo' => 8217,\n 'sbquo' => 8218,\n 'ldquo' => 8220,\n 'rdquo' => 8221,\n 'bdquo' => 8222,\n 'dagger' => 8224,\n 'Dagger' => 8225,\n 'permil' => 8240,\n 'lsaquo' => 8249,\n 'rsaquo' => 8250,\n 'euro' => 8364,\n 'fnof' => 402,\n 'Alpha' => 913,\n 'Beta' => 914,\n 'Gamma' => 915,\n 'Delta' => 916,\n 'Epsilon' => 917,\n 'Zeta' => 918,\n 'Eta' => 919,\n 'Theta' => 920,\n 'Iota' => 921,\n 'Kappa' => 922,\n 'Lambda' => 923,\n 'Mu' => 924,\n 'Nu' => 925,\n 'Xi' => 926,\n 'Omicron' => 927,\n 'Pi' => 928,\n 'Rho' => 929,\n 'Sigma' => 931,\n 'Tau' => 932,\n 'Upsilon' => 933,\n 'Phi' => 934,\n 'Chi' => 935,\n 'Psi' => 936,\n 'Omega' => 937,\n 'alpha' => 945,\n 'beta' => 946,\n 'gamma' => 947,\n 'delta' => 948,\n 'epsilon' => 949,\n 'zeta' => 950,\n 'eta' => 951,\n 'theta' => 952,\n 'iota' => 953,\n 'kappa' => 954,\n 'lambda' => 955,\n 'mu' => 956,\n 'nu' => 957,\n 'xi' => 958,\n 'omicron' => 959,\n 'pi' => 960,\n 'rho' => 961,\n 'sigmaf' => 962,\n 'sigma' => 963,\n 'tau' => 964,\n 'upsilon' => 965,\n 'phi' => 966,\n 'chi' => 967,\n 'psi' => 968,\n 'omega' => 969,\n 'thetasym' => 977,\n 'upsih' => 978,\n 'piv' => 982,\n 'bull' => 8226,\n 'hellip' => 8230,\n 'prime' => 8242,\n 'Prime' => 8243,\n 'oline' => 8254,\n 'frasl' => 8260,\n 'weierp' => 8472,\n 'image' => 8465,\n 'real' => 8476,\n 'trade' => 8482,\n 'alefsym' => 8501,\n 'larr' => 8592,\n 'uarr' => 8593,\n 'rarr' => 8594,\n 'darr' => 8595,\n 'harr' => 8596,\n 'crarr' => 8629,\n 'lArr' => 8656,\n 'uArr' => 8657,\n 'rArr' => 8658,\n 'dArr' => 8659,\n 'hArr' => 8660,\n 'forall' => 8704,\n 'part' => 8706,\n 'exist' => 8707,\n 'empty' => 8709,\n 'nabla' => 8711,\n 'isin' => 8712,\n 'notin' => 8713,\n 'ni' => 8715,\n 'prod' => 8719,\n 'sum' => 8721,\n 'minus' => 8722,\n 'lowast' => 8727,\n 'radic' => 8730,\n 'prop' => 8733,\n 'infin' => 8734,\n 'ang' => 8736,\n 'and' => 8743,\n 'or' => 8744,\n 'cap' => 8745,\n 'cup' => 8746,\n 'int' => 8747,\n 'there4' => 8756,\n 'sim' => 8764,\n 'cong' => 8773,\n 'asymp' => 8776,\n 'ne' => 8800,\n 'equiv' => 8801,\n 'le' => 8804,\n 'ge' => 8805,\n 'sub' => 8834,\n 'sup' => 8835,\n 'nsub' => 8836,\n 'sube' => 8838,\n 'supe' => 8839,\n 'oplus' => 8853,\n 'otimes' => 8855,\n 'perp' => 8869,\n 'sdot' => 8901,\n 'lceil' => 8968,\n 'rceil' => 8969,\n 'lfloor' => 8970,\n 'rfloor' => 8971,\n 'lang' => 9001,\n 'rang' => 9002,\n 'loz' => 9674,\n 'spades' => 9824,\n 'clubs' => 9827,\n 'hearts' => 9829,\n 'diams' => 9830,\n }\n gsub(/&(?:([a-zA-Z]+)|#([0-9]+)|#x([a-fA-F0-9]+));/) {\n if $1 then\n v = @@xhtml_entity_replacements[$1]\n # Nonstandard entity\n unless v\n if extra_entities.is_a? Proc\n v = extra_entities.call($1)\n # Well, we expect a Hash here, but any container will do.\n # As long as it's not a nil.\n elsif extra_entities\n v = extra_entities[$1]\n end\n end\n raise \"Unknown escape #{$1}\" unless v\n elsif $2\n v = $2.to_i\n else\n v = $3.hex\n end\n # v can be a String or an Integer\n if v.is_a? String then v else [v].pack('U') end\n }\n end",
"def smart_quote_entity(el); end",
"def _reduce_541(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_609(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n\n result\nend",
"def safe_escape(uri); end",
"def test_values_with_apostrophes\n doc = Document.new(%q#<tag h1=\"1'2'\" h2='1\"2'/>#)\n s = doc.to_s\n assert(s =~ /h1='1'2''/)\n assert(s =~ /h2='1\"2'/)\n end",
"def my_html_escape(org_value)\n '' if org_value.nil?\n ERB::Util.html_escape(org_value). # Standard-Escape kann kein NewLine-><BR>\n gsub(/\\n/, '<br>'). # Alle vorkommenden NewLine ersetzen\n gsub(/\\r/, '') # Alle vorkommenden CR ersetzen, führt sonst bei Javascript zu Error String not closed\n end",
"def _reduce_520(val, _values, result)\n result = \"&#{value(val[1])}\".to_sym\n \n result\nend",
"def _reduce_584(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_584(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def _reduce_584(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def name_parse_special_characters(val)\n use_this = val.dup\n\n # Ensure that we don't have special characters at end of name\n while [\"!\",\"/\",\"*\"].include?(use_this.to_s[-1,1]) do\n # Will this node contain escaped XML?\n if use_this.to_s[-1,1] == '!'\n @escape_xml = false\n use_this.chop!\n end\n\n # Will this be a self closing node?\n if use_this.to_s[-1,1] == '/'\n @self_closing = true\n use_this.chop!\n end\n\n # Will this node contain a collection of sibling nodes?\n if use_this.to_s[-1,1] == '*'\n @content_type = \"collection\"\n use_this.chop!\n end\n end\n\n return use_this\n end",
"def _reduce_607(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n\n result\nend",
"def _reduce_607(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n\n result\nend",
"def exception_on_syntax_error; end",
"def _wp_specialchars(string, quote_style = :ENT_NOQUOTES, charset = false, double_encode = false)\n string = string.to_s\n\n return '' if string == ''\n\n # Don't bother if there are no specialchars - saves some processing\n return string unless string =~ /[&<>\"']/\n\n \t# Account for the previous behaviour of the function when the $quote_style is not an accepted value\n if quote_style.blank?\n quote_style = :ENT_NOQUOTES\n elsif ![0, 2, 3, 'single', 'double' ].include? quote_style\n quote_style = :ENT_QUOTES\n end\n\n # TODO continue implement function _wp_specialchars\n\t # Store the site charset as a static to avoid multiple calls to wp_load_alloptions()\n\t unless charset\n\t \t# static $_charset = null;\n\t# \tif ( ! isset( $_charset ) ) {\n\t# \t\t$alloptions = wp_load_alloptions();\n\t# \t\t$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';\n\t# \t}\n\t# \t$charset = $_charset;\n charset = get_option('blog_charset')\n\t end\n\n charset = 'UTF-8' if ['utf8', 'utf-8', 'UTF8'].include?(charset)\n\n\t_quote_style = quote_style\n\n\tif quote_style == 'double'\n\t\tquote_style = :ENT_COMPAT\n\t\t_quote_style = :ENT_COMPAT\n\t elsif quote_style == 'single'\n\t\tquote_style = :ENT_NOQUOTES\n\tend\n\n\tunless double_encode\n\t\t# Guarantee every &entity; is valid, convert &garbage; into &garbage;\n\t\t# This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable.\n\t\tstring = wp_kses_normalize_entities(string)\n\tend\n\n string = h(string)\n\t# TODO string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode )\n\n\t# Back-compat.\n\tif 'single' == _quote_style\n\t\tstring = string.gsub(\"'\", ''')\n end\n\n string\n end",
"def _reduce_601(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n\n result\nend",
"def uri_escape(input); end",
"def htmlEscape(string)\n return string.gsub('&', '&').gsub('>', '>').gsub('<', '<')\nend",
"def convert_escape_characters(*args, &block)\n maatsf_convert_escape_characters(super(*args, &block))\n end",
"def test_entity_replacement\n\tt = NQXML::Tokenizer.new('')\n\n\t# add a method that lets us set the internal entity hash\n\tclass << t\n\t def testSetInternalEntities(h); @internalEntities = h; end\n\tend\n\n\tt.testSetInternalEntities({ # as if we saw <!ENTITY...> tags\n\t 'a' => '&b;',\n\t 'b' => '&foo;',\n\t 'foo' => '&bar;',\n\t 'bar' => 'bletch',\n\t 'ugly' => 'An ampersand (&) may be escaped' +\n\t\t\t' numerically (&#38;) or with a general' +\n\t\t\t' entity (&amp;).'\n\t})\n\n\tassert_equal('x <&> x', t.replaceAllRefsButParams('x <&> x'))\n\tassert_equal('x \"\\' x', t.replaceAllRefsButParams('x "' x'))\n\tassert_equal('x A x', t.replaceAllRefsButParams('x A x'))\n\tassert_equal('x A x', t.replaceAllRefsButParams('x A x'))\n\tassert_equal('&&', t.replaceAllRefsButParams('&&'))\n\n\tassert_equal('&', t.replaceAllRefsButParams('&'))\n\tassert_equal('&', t.replaceAllRefsButParams('&'))\n\n\tassert_equal('bletch', t.replaceAllRefsButParams('&bar;'))\n\tassert_equal('bletch', t.replaceAllRefsButParams('&foo;'))\n\tassert_equal('bletch', t.replaceAllRefsButParams('&b;'))\n\tassert_equal('bletch', t.replaceAllRefsButParams('&a;'))\n\n\tassert_equal('An ampersand (&) may be escaped' +\n\t\t ' numerically (&) or with a general' +\n\t\t ' entity (&).', t.replaceAllRefsButParams('&ugly;'))\n\n\t# Make sure unknown entities raise an error\n\texpect_error('x &huh; x', /entity reference '&huh;' is undefined/)\n end",
"def _reduce_542(val, _values, result)\n identifier = val[1].to_sym\n\n self.env[identifier] = :lvar\n result = \"&#{identifier}\".to_sym\n \n result\nend",
"def encode_string_ex; end",
"def escape_value(value)\n value = value.to_s.dup\n value.gsub!(%r{\\\\([0nrt])}, '\\\\\\\\\\1')\n value.gsub!(%r{\\n}, '\\n')\n value.gsub!(%r{\\r}, '\\r')\n value.gsub!(%r{\\t}, '\\t')\n value.gsub!(%r{\\0}, '\\0')\n value\n end",
"def ascii_quotes\n value = self.gsub(/'/, \"'\").gsub(/\"/, \""\")\n return value\n end",
"def escape_value(value)\n CGI.escape(value.to_s).gsub('%20', '+')\n end",
"def normalizeAttributeValue(str)\n\t return nil if str.nil?\n\t val = str.dup\n\t result = ''\n\t until val.empty?\n\t\tpos = val =~ /[&\\s<]/m\n\t\tif pos.nil?\n\t\t result << val\n\t\t return result\n\t\tend\n\t\tresult << $`\n\t\tval = val[pos .. -1]\n\t\tif val =~ /\\A&#x([0-9a-f]*);/ni\n\t\t result << $1.hex.chr\n\t\t val = $'\n\t\telsif val =~ /\\A&#([0-9]*);/n\n\t\t result << $1.to_i.chr\n\t\t val = $'\n\t\telsif val =~ /\\A&([^&;]*);/n\n\t\t ref = $1\n\t\t case ref\n\t\t when 'amp'; result << '&'\n\t\t when 'lt'; result << '<'\n\t\t when 'gt'; result << '>'\n\t\t when 'quot'; result << '\"'\n\t\t when 'apos'; result << '\\''\n\t\t else\n\t\t\treplacement = @internalEntities[ref]\n\t\t\tif replacement.nil?\n\t\t\t str = \"entity reference '#{ref}' is undefined\"\n\t\t\t raise ParserError.new(str, self)\n\t\t\tend\n\t\t\tif !replacement.index('<').nil?\n\t\t\t str = \"attribute values may not contain '<'\"\n\t\t\t raise ParserError.new(str, self)\n\t\t\tend\n\t\t\tresult << normalizeAttributeValue(replacement)\n\t\t end\n\t\t val = $'\n\t\telsif val =~ /\\A\\s+/m\n\t\t result << ' '\n\t\t val = $'\n\t\telsif val[0] == ?<\n\t\t\tstr = \"attribute values may not contain '<'\"\n\t\t raise ParserError.new(str, self)\n\t\tend\n\t end\n\t return result\n\tend",
"def html_escape(str)\r\n str.gsub('&', '&').str('<', '<').str('>', '>').str('\"', '"')\r\nend",
"def test_encoding\n\tassert_equal('x & x', NQXML.encode('x & x'))\n\tassert_equal('x ' x', NQXML.encode('x \\' x'))\n\tassert_equal('x <"> x', NQXML.encode('x <\"> x'))\n end",
"def html_safe_value\n sanitize(@values.join(' '), tags: %w[sub sup i em])\n end",
"def entity_gsub!(chars)\n mapping = {\n '&' => '&',\n '<' => '<',\n '>' => '>',\n '\"' => '"',\n \"'\" => '''\n }\n re = /&(?!amp;)|[<>'\"]/\n chars.gsub!(re, mapping)\n chars\n end",
"def escape_value(v) \n if v.nil?\n # Nulls (nil)\n return \"NULL\"\n elsif v.kind_of? Integer or v.kind_of? Float\n # Integers / Floats\n return v.to_s\n else\n # Everything Else\n return \"'#{@mysql.escape(v.to_s)}'\" \n end\n end"
] | [
"0.6585935",
"0.63006413",
"0.61464334",
"0.60993546",
"0.60156065",
"0.59818316",
"0.59091586",
"0.5875468",
"0.5798132",
"0.5761985",
"0.5635786",
"0.5635254",
"0.56275445",
"0.5520037",
"0.55145216",
"0.54980874",
"0.5495125",
"0.54699206",
"0.5469752",
"0.5449368",
"0.543977",
"0.5416264",
"0.5398755",
"0.53969073",
"0.53969073",
"0.53741676",
"0.53449684",
"0.5273939",
"0.5273857",
"0.5252503",
"0.5235058",
"0.5216282",
"0.52019566",
"0.5183923",
"0.5182131",
"0.51770616",
"0.51757735",
"0.51722354",
"0.5160083",
"0.51581097",
"0.5154941",
"0.5145966",
"0.5145966",
"0.5137061",
"0.5137061",
"0.5137061",
"0.511532",
"0.51058334",
"0.51052827",
"0.50965935",
"0.50946444",
"0.5091285",
"0.5082851",
"0.507769",
"0.507769",
"0.507769",
"0.5076574",
"0.5076574",
"0.50689924",
"0.5063703",
"0.50561994",
"0.5053477",
"0.5048916",
"0.5048139",
"0.5042266",
"0.50325495",
"0.5028346",
"0.5026526",
"0.50249004",
"0.5022455",
"0.5018181",
"0.5013533",
"0.5011007",
"0.5007128",
"0.50041",
"0.5003038",
"0.4991358",
"0.4990981",
"0.4990981",
"0.4990981",
"0.49850163",
"0.49687213",
"0.49687213",
"0.49595806",
"0.4958442",
"0.49530253",
"0.49513978",
"0.49503905",
"0.49477252",
"0.4944549",
"0.4938721",
"0.49312773",
"0.4928392",
"0.49265465",
"0.4913496",
"0.49023283",
"0.49003583",
"0.48896924",
"0.48823088",
"0.48806778",
"0.48765925"
] | 0.0 | -1 |
TODO: cleanup unnecessary error stuffs | def matches?(block)
old_to = @stream.dup
# Obtain a filehandle to replace (works with Readline)
@stream.reopen File.open(File.join(Dir.tmpdir, "should_output_#{$$}"), "w+")
# Execute
block.call
# Restore
out = @stream.dup
@stream.reopen old_to
# Grab the data
out.rewind
@data = out.read
# Match up
case @expected
when Regexp
@data.should =~ @expected
else
@data.should == @expected
end
# Clean up
ensure
out.close if out and !out.closed?
# STDIO redirection will break else
begin
@stream.seek 0, IO::SEEK_END
rescue Errno::ESPIPE, Errno::EPIPE
# Ignore
end
FileUtils.rm out.path if out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def original_error; end",
"def original_error; end",
"def recover_from(_error); end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def load_error; end",
"def continued_exception; end",
"def recover_from(_error)\n end",
"def errorhandling\n end",
"def catch_exceptions; end",
"def api_error; end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def error?; end",
"def error?; end",
"def error?; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exceptions; end",
"def load_error=(_arg0); end",
"def error(exception) nil ; end",
"def handle_perform_error(_e); end",
"def parse_failure_cause; end",
"def storage_failure; end",
"def check_errors;\n end",
"def storage_failure=(_arg0); end",
"def ioerr; end",
"def refutal()\n end",
"def underlying_exception; end",
"def errno; end",
"def original_exception; end",
"def errors=(_); end",
"def errors=(_arg0); end",
"def errors=(_arg0); end",
"def errors=(_arg0); end",
"def errors=(_arg0); end",
"def schubert; end",
"def probers; end",
"def run_failed; end",
"def error\n end",
"def exception_on_syntax_error=(_arg0); end",
"def error\n\t\traise StandardError\n\tend",
"def failures; end",
"def failures; end",
"def failures; end",
"def rescue_from(exception); end",
"def error_poslook_crash error, error_location; end",
"def write_error_info\n end",
"def diagnostic; end",
"def error=(_arg0); end",
"def error=(_arg0); end",
"def error=(_arg0); end",
"def error_message; end",
"def parse_error(error, req); end",
"def exception_on_syntax_error; end",
"def missing?; end",
"def cause; end",
"def cause; end",
"def client_error?; end",
"def server_errors; end",
"def error\n end",
"def continued_exception=(_arg0); end",
"def miss_reason; end",
"def check_errors;\n end",
"def missing; end",
"def server_error?; end",
"def checks; end",
"def wrapped_exception; end",
"def error\n nil\n end",
"def linkparser_error ; @lp_error; end",
"def error\n nil\n end",
"def error(nvae)\n end",
"def do_failure; end",
"def onerror(&blk); super; end",
"def stacktrace; end",
"def issn; end",
"def fatal; end",
"def unrecognized_option(err); end",
"def fatal?; end",
"def fatal?; end",
"def handle; end",
"def unsuccessful\n end",
"def error(string); end",
"def error(string); end"
] | [
"0.67001045",
"0.6503747",
"0.6503747",
"0.6468239",
"0.641984",
"0.641984",
"0.641984",
"0.641984",
"0.641984",
"0.641984",
"0.641984",
"0.6285848",
"0.6181625",
"0.6128032",
"0.6105435",
"0.6058286",
"0.6023351",
"0.5987944",
"0.5981237",
"0.5981237",
"0.5981237",
"0.59720355",
"0.59720355",
"0.59720355",
"0.59720355",
"0.59720355",
"0.59720355",
"0.59720355",
"0.59720355",
"0.59720355",
"0.5966714",
"0.5966714",
"0.5966714",
"0.5966714",
"0.5966714",
"0.59657115",
"0.5938619",
"0.5927609",
"0.5923831",
"0.58663833",
"0.5819317",
"0.58106947",
"0.5808307",
"0.5792417",
"0.5739743",
"0.5737099",
"0.57321817",
"0.5729636",
"0.56960356",
"0.5693408",
"0.5693408",
"0.5693408",
"0.5693408",
"0.5676557",
"0.5647874",
"0.56371105",
"0.5632586",
"0.5628393",
"0.5605279",
"0.5605064",
"0.5605064",
"0.5605064",
"0.55770296",
"0.5570503",
"0.5569962",
"0.5569762",
"0.556817",
"0.556817",
"0.556817",
"0.5559251",
"0.5530894",
"0.5525378",
"0.5515971",
"0.5489722",
"0.5489722",
"0.54512894",
"0.54509133",
"0.5436741",
"0.54348797",
"0.5412364",
"0.53984666",
"0.5392296",
"0.53890073",
"0.5387998",
"0.5376743",
"0.5365179",
"0.5354516",
"0.5347194",
"0.53403515",
"0.53403324",
"0.5339364",
"0.53381443",
"0.5318991",
"0.5318282",
"0.5307207",
"0.53046024",
"0.53046024",
"0.5288304",
"0.5276464",
"0.5247145",
"0.5247145"
] | 0.0 | -1 |
TODO support multiple viewports | def initialize(vk, viewport: { }, scissor: { })
@vk = vk
@shader_stages = []
@layouts = []
@constant_ranges = []
@descriptors = []
@input = {
topology: :triangles,
primitive_restart: false
}
@viewport = {
left: 0,
top: 0,
width: 640,
height: 480,
min_depth: 0,
max_depth: 1
}.merge(viewport)
@scissor = {
left: 0,
top: 0,
width: 0xffffffff,
height: 0xffffffff
}.merge(scissor)
@rasterizer = {
depth_clamp: false,
discard_all: false,
polygon_mode: :fill,
line_width: 1.0,
cull_mode: :back,
front_face: :counter_clockwise,
depth_bias: false,
depth_bias_clamp: 0,
depth_bias_constant: 0,
depth_bias_slope: 0
}
@multisampling = {
sample_shading: false,
samples: 1,
min_sample_shading: 0.2,
sample_mask: nil,
alpha_to_coverage: false,
alpha_to_one: false
}
@blending = {
enabled: true,
color_writes: [ :red, :green, :blue, :alpha ],
src_color: :src_alpha,
dst_color: :one_minus_src_alpha,
src_alpha: :one,
dst_alpha: :zero,
color_op: :add,
alpha_op: :add
}
@binding_descriptions = []
@attribute_descriptions = []
@dynamic_states = []
@specialization_constants = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_viewport\r\n # Make viewports\r\n @viewport1 = Viewport.new(0, 0, 640, 320)\r\n @viewport2 = Viewport.new(0, 0, 640, 480)\r\n @viewport3 = Viewport.new(0, 0, 640, 480)\r\n @viewport4 = Viewport.new(0, 0, 640, 480)\r\n @viewport2.z = 101\r\n @viewport3.z = 200\r\n @viewport4.z = 5000\r\n end",
"def update_viewports\r\n # Set screen color tone and shake position\r\n @viewport1.tone = $game_screen.tone\r\n @viewport1.ox = $game_screen.shake\r\n # Set screen flash color\r\n @viewport4.color = $game_screen.flash_color\r\n # Update viewports\r\n @viewport1.update\r\n @viewport2.update\r\n @viewport4.update\r\n end",
"def update_viewports\r\n # Set screen color tone and shake position\r\n @viewport1.tone = $game_screen.tone \r\n @viewport1.ox = $game_screen.shake\r\n # Set screen flash color\r\n @viewport3.color = $game_screen.flash_color \r\n # Update viewports\r\n @viewport1.update \r\n @viewport3.update\r\n end",
"def viewport\n return @viewport\n end",
"def viewport\n viewport_offset.merge(viewport_size)\n end",
"def setviewport(*)\n super\n end",
"def viewport2=(vw)\n @graphic.viewport = vw\n end",
"def viewport=(viewport)\n super(viewport)\n @view_x = viewport.rect.x\n @view_y = viewport.rect.y\n end",
"def port\n @presenter.port\n end",
"def viewForZoomingInScrollView(scrollView)\n @view\n end",
"def viewport\n @viewport ||= Game.bounds\n end",
"def create_picture_viewport\n @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)\n @viewport2.z = 99\n end",
"def color; return @viewport.color; end",
"def make_view_from(options = {})\n o = {}\n o.merge! options\n options.each do |k, v| o[k.to_sym] = v unless k.kind_of? Symbol\n end\n \n # Set defaults\n [\n [ :altitude, 0 ],\n [ :altitudeMode, :relativeToGround ],\n [ :latitude, 0 ],\n [ :longitude, 0 ],\n [ :tilt, 0 ],\n [ :heading, 0 ],\n [ :extrude, 0 ],\n ].each do |a|\n o[a[0]] = a[1] unless o.has_key? a[0]\n end\n \n p = point o[:longitude], o[:latitude], o[:altitude], o[:altitudeMode], o[:extrude]\n \n if o.has_key? :roll then\n view = Kamelopard::Camera.new p\n else\n view = Kamelopard::LookAt.new p\n end\n \n [ :altitudeMode, :tilt, :heading, :timestamp, :timespan, :timestamp, :range, :roll, :viewerOptions ].each do |a|\n view.method(\"#{a.to_s}=\").call(o[a]) if o.has_key? a\n end\n \n view\n end",
"def create_main_viewport\n @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)\n @viewport1.z = 1\n end",
"def create_viewport\n @viewport = Viewport.create(:main, 500)\n @viewport.extend(Viewport::WithToneAndColors)\n @viewport.shader = Shader.create(:map_shader)\n rc = @viewport.rect\n @viewport_sub = Viewport.new(rc.x, rc.y + rc.height - 48, rc.width, 48)\n end",
"def source_pts=(_arg0); end",
"def source_pts; end",
"def create_viewport\n @viewport = Viewport.create(:main, @message_window.z - 1)\n @viewport.extend(Viewport::WithToneAndColors)\n @viewport.shader = Shader.create(:map_shader)\n end",
"def setwsviewport(*)\n super\n end",
"def viewport=(viewport)\n instance_variables.each do |varname|\n ivar = instance_variable_get(varname)\n ivar.viewport = viewport if ivar.is_a?(Sprite) rescue next\n end\n end",
"def draw(viewport)\n viewport.map! { |p| p / @tile_size }\n x0, x1, y0, y1 = viewport.map(&:to_i)\n\n # restrict to prevent re-rendering\n x0 = 0 if x0.negative?\n x1 = @width - 1 if x1 >= @width\n y0 = 0 if y0.negative?\n y1 = @height - 1 if y1 >= @height\n\n (x0..x1).each do |x|\n (y0..y1).each do |y|\n @layers[:tile_layers].each do |_, tiles|\n next unless tiles[y][x]\n\n tiles[y][x].draw(x * @tile_size, y * @tile_size) if tiles[y][x].id != 0\n # tiles[y][x].x = x\n # tiles[y][x].y = y\n end\n end\n end\n end",
"def viewport_size\n @viewport_size ||= {w: part_layout.w.to_i, h: part_layout.h.to_i}\n end",
"def create_shop_viewports\n @shop_viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)\n @item_number_viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)\n @item_number_viewport.z = @shop_viewport.z + 1\n end",
"def inqviewport\n inquiry %i[double double double double] do |*pts|\n super(*pts)\n end\n end",
"def rendered_views=(_arg0); end",
"def initialize(viewport, type, x, y, visible = true)\n super(viewport)\n self.visible = visible\n #self.bitmap = Bitmap.new(32,32)\n @wait = 6\n @pattern = [0,1,2,3]\n @p_index = 0 #pattern index\n @type = type\n @x = x; @y = y # Denotes map's tile x/y\n self.zoom_x = 0\n self.zoom_y = 0\n @anim = false\n self.z = 20000\n\n moveto(@x, @y)\n refresh \n end",
"def isInView?(x)\n if x + 8 > @camX and x + 8 < @camX + @width\n return true\n else\n return false\n end\n end",
"def render\n Vedeu::Output::Viewport.render(current)\n end",
"def visibilities=(_arg0); end",
"def layer\n self.view\n end",
"def set_view_position r,c\n return false if r < 0 or c < 0\n # 2010-02-04 19:29 TRYING -2 for borders\n $log.debug \" set_view if #{r} +1+ #{@height} - #{@border_width} )} >=#{@child.height} \"\n # 2010-02-12 15:33 XXX made > into >= and added +1 since -1 in set_buffering\n # testscrollp was crashing out when child height exceeded\n if r+ (@height+1-@border_width) >= @child.height\n # basically r + (:bottom - :screen_top) < @child.height\n #if r+ (@height) >= @child.height\n $log.debug \" set_view_position : trying to exceed ht #{r} + #{@height} > #{@child.height} returned false\"\n return false\n end\n # testscrollp was printing junk on right end. Why the 1? \n if c+ (@width+1-@border_width) >=@child.width\n #if c+ (@width) >=@child.width\n $log.debug \" set_view_position : trying to exceed width #{c} + #{@width} . returned false\"\n return false\n end\n $log.debug \" VP row #{@row} col #{@col}, now will be #{r} , #{c} \"\n row(r) # commnting off 2010-02-06 22:47 \n col(c) # commnting off 2010-02-06 22:47 \n # next call sets pminrow and pmincol \n $log.debug \" VP setting child buffer pmin to #{r} #{c} \"\n @child.get_buffer().set_pad_top_left(r, c)\n # replaced this on 2010-02-26 11:49 HOPE IT WORKS XXX\n #@child.fire_property_change(\"row\", r, r) # XXX quick dirty, this should happen\n @child.repaint_required(true)\n @repaint_required = true\n #fire_handler :PROPERTY_CHANGE, self\n fire_state_changed\n return true\n end",
"def viewpoint\n return @viewpoint\n end",
"def update_view\n end_offsets = []\n color_sign = ((@color == :black) ? -1 : 1)\n \n end_offsets = []\n \n @legal_moves = end_offsets\n if color == :black\n if @coordinates.first == 6\n end_offsets << [5, @coordinates.last]\n end_offsets << [4, @coordinates.last]\n else\n end_offsets << [@coordinates.first + color_sign, @coordinates.last] unless @board.tiles[@coordinates.first + color_sign, @coordinates.last] \n end\n else\n if @coordinates.first == 1\n end_offsets << [2, @coordinates.last]\n end_offsets << [3, @coordinates.last]\n else\n end_offsets << [@coordinates.first + color_sign, @coordinates.last] unless @board.tiles[@coordinates.first + color_sign, @coordinates.last]\n end\n end\n # p \"updateview\"\n # p @board\n # p @coordinates.last + 1\n # # p @board.tiles[1,0]\n # p @board.tiles[@coordinates.first - 1][@coordinates.last + 1]\n \n if inside_bounds?([@coordinates.first + color_sign, @coordinates.last - 1])\n left_corner = @board.tiles[@coordinates.first + color_sign][@coordinates.last - 1]\n if (!left_corner.nil? && left_corner.color != color)\n end_offsets << left_corner.coordinates\n end\n end\n\n if inside_bounds?([@coordinates.first + color_sign, @coordinates.last + 1])\n # p [@coordinates.first + color_sign, @coordinates.last + 1]\n # if !@board.tiles[@coordinates.first + color_sign, @coordinates.last + 1].nil?\n \n # p \"right corner: #{@board.tiles[@coordinates.first + color_sign][@coordinates.last + 1]}\"\n right_corner = @board.tiles[@coordinates.first + color_sign][@coordinates.last + 1]\n if (!right_corner.nil? && right_corner.color != color)\n end_offsets << right_corner.coordinates\n end\n end\n @legal_moves = end_offsets\n \n end",
"def view_x\n return 0 if @viewport.nil? || @view_x.nil?\n return @view_x\n end",
"def reshape(width, height)\n h = height.to_f / width.to_f\n GL.Viewport(0, 0, width, height)\n GL.MatrixMode(GL::PROJECTION)\n GL.LoadIdentity()\n GL.Frustum(-100.0, 100.0, -h*100, h*100, 5.0, 60.0)\n GL.MatrixMode(GL::MODELVIEW)\n GL.LoadIdentity()\n GL.Translate(0.0, 0.0, -40.0)\n end",
"def switch_view(what=nil)\n $log.debug(\"before: \"+@view.to_s) if $log\n if what == nil\n case @view\n when :world_map\n @view = :current_map\n change_map(@player.x, @player.y)\n\n @player.move_to(@map.width/2,3)\n when :current_map\n @view = :world_map\n @map = @world_map\n @player.move_to(@world_map.x, @world_map.y)\n @creatures = []\n end\n end\n $log.debug(\"after: \"+@view.to_s) if $log\n end",
"def viewport=(v)\n r = v.nil? ? Rect.new(0, 0, Graphics.width, Graphics.height) : v.rect\n b = r != vrect\n ret = @sprite.viewport = v\n self.bitmap = @bitmap if b\n return ret\n end",
"def get_view\n @level = params[:game][:level]\n @size = 5\n if params[:game][:size] == '10x10'\n @size = 10\n end\n end",
"def visibilities; end",
"def view_corner(view, index, distance, transform)\n ray = view.pickray(view.corner(index))\n if ray\n pt = ray[0].offset ray[1], distance\n else\n pt = view.camera.eye\n end\n pt.transform transform\nend",
"def create_viewport\n @viewport = Viewport.create(:main, 1)\n end",
"def _view; end",
"def viewport_offset\n @viewport_offset ||= {x: part_layout.x.to_i, y: part_layout.y.to_i}\n end",
"def draw(view)\r\n # puts \"draw state = #{@state}\"\r\n # Show the current input point\r\n if (@ip.valid? && @ip.display?)\r\n @ip.draw(view)\r\n @drawn = true\r\n end\r\n\r\n # show the wall base outline\r\n if (@state == STATE_PICK_NEXT)\r\n\t\t#puts \"wall width3: \" + @wall.width.to_s + \" \" + @wall.width.class.to_s\r\n (@offset_pt0, @offset_pt1) = MM_HouseBuilder.draw_outline(view, @pts[0], @pts[1], @wall.width, @wall.justify, \"gray\")\r\n @drawn = true\r\n end\r\nend",
"def compute_field_of_view(ux,uy,vx,vy)\n\n # --- Near plan :\n near_left_x = ux * ( @near - @center ) - vx * @near_fov_width\n near_left_y = uy * ( @near - @center ) - vy * @near_fov_width\n near_right_x = ux * ( @near - @center ) + vx * @near_fov_width\n near_right_y = uy * ( @near - @center ) + vy * @near_fov_width\n\n # --- Far plan :\n far_left_x = ux * ( @far - @center ) - vx * @far_fov_width\n far_left_y = uy * ( @far - @center ) - vy * @far_fov_width\n far_right_x = ux * ( @far - @center ) + vx * @far_fov_width\n far_right_y = uy * ( @far - @center ) + vy * @far_fov_width\n\n # --- Rotation center :\n center_x = 0#ux * ( @center )\n center_y = 0#uy * ( @center )\n\n [ [ [ near_left_x, near_left_y ],\n [ near_right_x, near_right_y ],\n [ far_right_x, far_right_y ],\n [ far_left_x, far_left_y ] ],\n\n [ center_x, center_y ] ]\n end",
"def port\n @port ||= presenter.port\n end",
"def draw(view)\r\n # Show the current input point\r\n if (@ip.valid? && @ip.display?)\r\n @ip.draw(view)\r\n @drawn = true\r\n end \r\n\r\n # draw the outline of the wall\r\n MM_HouseBuilder.draw_outline(view, @wall.origin, @wall.endpt, @wall.width, @wall.justify, \"gray\")\r\n vec = @end_pt - @start_pt\r\n # draw the outline of each door and window\r\n @wall.objects.each do |obj|\r\n vec.length = obj.center_offset - obj.width/2\r\n obj_start = @wall.origin + vec\r\n vec.length = obj.width\r\n obj_end = obj_start + vec\r\n MM_HouseBuilder.draw_outline(view, obj_start, obj_end, @wall.width, @wall.justify, \"gray\")\r\n end\r\n MM_HouseBuilder.draw_outline(view, @start_pt, @end_pt, @wall.width, @wall.justify, \"orange\", 2)\r\n @drawn = true\r\nend",
"def connected_ports; end",
"def project_to_plane\n end",
"def setObjectViewDistance _args\n \"setObjectViewDistance _args;\" \n end",
"def copy_vassal_view(view)\n # Copy this view to a new one. Both views needs to point to the same\n # buffer.\n new_view = CSTE::View.new(\n view.buffer, view.init_col, view.init_line, view.cols, view.lines)\n\n # This container is the lord of those views.\n view.lord = self\n new_view.lord = self\n\n return new_view\n end",
"def zoom\n end",
"def gl_view\n #---------------------------------------------------------\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/glenable\n glEnable(GL_TEXTURE_2D) # enables two-dimensional texturing to perform\n #---------------------------------------------------------\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/gldepthfunc\n # https://www.youtube.com/watch?v=uJzXDkgm5Fw\n glEnable(GL_DEPTH_TEST)\n # If enabled, do depth comparisons and update the depth buffer.\n #---------------------------------------------------------\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/glmatrixmode\n glMatrixMode(GL_PROJECTION)\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/glloadidentity\n glLoadIdentity # * HAS TOO * be loaded in order after glMatrixMode setting...\n #---------------------------------------------------------\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/gluperspective\n gluPerspective(@fov, @ratio, @near, @far)\n #---------------------------------------------------------\n # Camera placement and viewing arangements:\n # The modelview matrix is where camera object information is stored.\n glMatrixMode(GL_MODELVIEW); glLoadIdentity # same as with before matrix ^\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/glulookat\n gluLookAt(@x,@y,@z, # Camera Location // eye\n @tx,@ty,@tz, # Viewing Target Location // direction\n # Vector Direction of Movement. // up\n @vert_orintation[0], @vert_orintation[1], @vert_orintation[2]\n ) # Defining the Viewing perspective is done in this block.\n #---------------------------------------------------------\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/glrotatef\n # glRotatef(angle, X axis scale, Y axis scale, Z axis scale)\n glRotatef(@angle[0], @vert_orintation[0], @vert_orintation[1], @vert_orintation[2])\n end",
"def view_params\n params.require(:view).permit(:name, :center_lat, :center_lng, :zoom, :presenter_id, :basemap, :view_3d_mode)\n end",
"def initialize(x, y, width, height, views)\n super(x, y, width, height, 8, 24, true, 24, 2)\n @row_max = 1\n @column_max = views.size\n \n @viewsList = []\n window_update(views)\n self.index = 0\n end",
"def initialize(x, y, width, height, views)\n super(x, y, width, height, 8, 24, true, 24, 2)\n @row_max = 1\n @column_max = views.size\n \n @viewsList = []\n window_update(views)\n self.index = 0\n end",
"def setViewDistance _args\n \"setViewDistance _args;\" \n end",
"def viewpoint=(value)\n @viewpoint = value\n end",
"def mx_vlan_ports\r\n MXVLANPortsController.instance\r\n end",
"def setperspectiveprojection(*)\n super\n end",
"def update_memory!(mem)\n map = @game.map\n \n x_s = @x-@vision\n y_s = @y-@vision\n @fov = linecast(map.tiles.get_values(x_s,y_s,2*@vision,2*@vision))\n mem.ins_values(x_s, y_s, @fov, false)\n end",
"def getViewObject(ixNet, viewName)\r\n views = @ixNet.getList('/statistics', 'view')\r\n viewObj = ''\r\n editedViewName = '::ixNet::OBJ-/statistics/view:\\\"' + viewName + '\\\"'\r\n for view in views\r\n if editedViewName == view then\r\n viewObj = view\r\n break\r\n end\r\n end\r\n return viewObj\r\nend",
"def resize_gl\n\n\t\tview_rectangle = bounds\n\n\t\t# Ensures camera knows size changed :\n\t\tif (@camera.view_height != view_rectangle.size.height) or (@camera.view_width != view_rectangle.size.width)\tthen\n\n\t\t\t@camera.view_height = view_rectangle.size.height\n\t\t\t@camera.view_width = view_rectangle.size.width\n\n\t\t\tglViewport(0, 0, @camera.view_width, @camera.view_height)\n\t\t\tupdate_projection\n\n\t\t\tupdate_info_string\n\n\t\tend\n\n\tend",
"def nextFrame(view)\n # Compute how long it took to display the last frame. This will\n # be used to compute how much to move or turnfor the next frame.\n time = view.last_refresh_time\n time_delay = 0\n if( time < 0.04 )\n time_delay = 0.04 - time\n time = 0.04\n end\n \n if( (@keys & (LEFT_ARROW | RIGHT_ARROW)) != 0 )\n self.send(self.lr_function, view, time)\n end\n if( (@keys & (UP_ARROW | DOWN_ARROW)) != 0 )\n self.send(self.ud_function, view, time)\n end\n \n # update the camera parameters\n @rep.update(view.camera) if @rep\n\n view.show_frame time_delay\n self.show_height\n \n true\nend",
"def connect_pos_reference (port, dof)\n @port = port\n case dof\n when :SURGE\n @port.connect_to do |sample, _|\n @window.surge_pose.update(sample.linear[0], \"Ref\")\n @window.pred_surge_pose.update(sample.linear[0], \"Ref\")\n end \n when :SWAY\n @port.connect_to do |sample, _|\n @window.sway_pose.update(sample.linear[1], \"Ref\")\n @window.pred_sway_pose.update(sample.linear[1], \"Ref\")\n end \n when :HEAVE\n @port.connect_to do |sample, _|\n @window.heave_pose.update(sample.linear[2], \"Ref\")\n @window.pred_heave_pose.update(sample.linear[2], \"Ref\")\n end\n \n when :YAW\n @port.connect_to do |sample, _|\n @window.yaw_pose.update(sample.angular[2]*180/Math::PI, \"Ref\")\n @window.pred_yaw_pose.update(sample.angular[2]*180/Math::PI, \"Ref\")\n end\n end\n end",
"def create_graphics\n create_viewport\n end",
"def camera\n end",
"def camera\n end",
"def xview_moveto(fraction)\n execute_only(:xview, :moveto, fraction)\n end",
"def loc_view\n \n end",
"def recall_map_view\n settings.map_view\n end",
"def initialize(viewport, team, direction)\n super(viewport)\n #>Stockage de l'équipe\n @team = team\n bmp = ::RPG::Cache.interface(Files[0])\n #>Positionnement automatique\n ox, x = (direction ? [bmp.width, 320] : [0, 0])\n set_position(x, 0)\n push(0, 0, bmp, ox: ox).mirror = direction\n @resources = Array.new(4) { |i| ::RPG::Cache.interface(Files[1+i]) }\n @ball_base_index = @stack.size\n base_offset = Offset\n if direction\n base_x = (bmp.width - base_offset * 6) / 2 - base_offset\n base_offset *= -1\n else\n base_x = bmp.width - (bmp.width - base_offset * 6) / 2\n end\n 6.times do |i|\n base_x -= base_offset\n push(base_x, 0, nil, ox: ox)\n end\n redraw\n end",
"def draw_grid\n case view\n when :south_east\n size_y.times do |y|\n size_x.times do |x|\n draw_tile(x, y, x, y)\n end\n end\n when :south_west\n size_x.times do |y|\n size_y.times do |x|\n draw_tile(x, y, size_x - 1 - y, x)\n end\n end\n when :north_west\n size_y.times do |y|\n size_x.times do |x|\n draw_tile(x, y, size_x - 1 - x, size_y - 1- y)\n end\n end\n when :north_east\n size_x.times do |y|\n size_y.times do |x|\n draw_tile(x, y, y, size_y - 1 - x)\n end\n end\n else\n throw Exception.new(\"view was out of bounds!\")\n end\n\n end",
"def yview_moveto(fraction)\n execute_only(:yview, :moveto, fraction)\n end",
"def view\n Rubyplot::Plotspace.new(self).view!\n end",
"def draw(view)\n if( @ip1.valid? )\n if( @ip1.display? )\n @ip1.draw(view)\n @drawn = true\n end\n \n if( @ip2.valid? )\n @ip2.draw(view) if( @ip2.display? )\n \n # The set_color_from_line method determines what color\n # to use to draw a line based on its direction. For example\n # red, green or blue.\n view.set_color_from_line(@ip1, @ip2)\n self.draw_geometry(@ip1.position, @ip2.position, view)\n @drawn = true\n end\n end\nend",
"def view_to_s(view)\n out = \"\\n\"\n out << \" VIEW class:o #{view.class.name} object_id: #{view.object_id}\\n\"\n out << \" RECTANGLE left: #{view.origin.y}, top: #{view.origin.y}, width: #{view.size.width}, height: #{view.size.height}\\n\"\n out << \" SUPERVIEW class: #{view.superview.class.name} object_id: #{view.superview.object_id} \\n\" if view.superview\n out << \" SUBVIEWS count: #{view.subviews.length}\\n\"\n out\n end",
"def show_volume_faces(view, entities)\n model = view.model\n material = self.get_frustum_material\n bounds = model.bounds\n bounds.add view.camera.eye\n length = bounds.diagonal\n transform = CameraRep.get_transform_from_view(view).inverse\n pts = (0..3).collect {|i| self.view_corner view, i, length, transform}\n face = entities.add_face ORIGIN, pts[0], pts[2]\n face.material = material\n face = entities.add_face ORIGIN, pts[2], pts[3]\n face.material = material\n face = entities.add_face ORIGIN, pts[3], pts[1]\n face.material = material\n face = entities.add_face ORIGIN, pts[1], pts[0]\n face.material = material\nend",
"def create_viewport\n # Main viewport\n # @type [LiteRGSS::Viewport]\n @viewport = Viewport.create(:main, 10_000)\n end",
"def draw(view)\r\n @drawn = false\r\n \r\n # Show the current input point\r\n if( @ip.valid? && @ip.display? )\r\n @ip.draw(view)\r\n @drawn = true\r\n end\r\n\r\n case @state\r\n when STATE_PICK\r\n # do nothing\r\n when STATE_PICK_NEXT\r\n # just draw a line from the start to the end point\r\n view.set_color_from_line(@ip1, @ip)\r\n inference_locked = view.inference_locked?\r\n view.line_width = 3 if inference_locked\r\n view.draw(GL_LINE_STRIP, @pts[0], @pts[1])\r\n view.line_width = 1 if inference_locked\r\n @drawn = true\r\n else\r\n # draw a rectangle\r\n view.drawing_color = \"black\"\r\n view.draw(GL_LINE_STRIP, @pts)\r\n @drawn = true\r\n end\r\nend",
"def toScreen(vec)\n @view__.to_parent(vec.getInternal__).toVector\n end",
"def initialize(viewport)\n super(viewport)\n set_bitmap(FILENAME, :interface)\n set_z(4)\n end",
"def reshape(width, height)\n h = height.to_f / width.to_f\n glViewport(0, 0, width, height)\n glMatrixMode(GL_PROJECTION)\n glLoadIdentity()\n glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0)\n glMatrixMode(GL_MODELVIEW)\n glLoadIdentity()\n glTranslatef(0.0, 0.0, -40.0)\n end",
"def view_flow=(_arg0); end",
"def refresh_view?\n cursor.visible? && cursor.ox >= width || cursor.oy >= height\n end",
"def print_all(vm, ports)\n @env.ui.info(I18n.t(\"port_command.details\"))\n @env.ui.info(\"\")\n ports.each do |host, guest|\n @env.ui.info(\"#{guest.to_s.rjust(6)} (guest) => #{host} (host)\")\n @env.ui.machine(\"forwarded_port\", guest, host, target: vm.name.to_s)\n end\n return 0\n end",
"def select_port_for_transform(port, from, to)\n if port.respond_to?(:name)\n if model.find_output_port(port.name) != port\n raise ArgumentError, \"#{port.name} is not an output port of #{self}\"\n end\n port = port.name\n end\n\n if !(tr = model.transformer)\n tr = model.transformer do\n transform_output port, from => to\n end\n end\n\n if !(transform = tr.find_transform_of_port(port))\n transform = tr.transform_output(port, from => to)\n end\n select_frames(transform.from => from, transform.to => to)\n end",
"def random_view\n if GameController::USE_MEMCACHED\n xprev = Cache.get(\"scalability_test_random_view_x\")\n yprev = Cache.get(\"scalability_test_random_view_y\")\n if (xprev != nil && yprev != nil)\n xpos = xprev\n ypos = yprev\n else\n xpos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTX).to_i\n ypos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTY).to_i\n Cache.put(\"scalability_test_random_view_x\", xpos, 30)\n Cache.put(\"scalability_test_random_view_y\", ypos, 30)\n end\n else\n xpos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTX).to_i\n ypos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTY).to_i\n end\n if GameController::USE_MEMCACHED\n if Zone.MEMCACHED_ViewportSame(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H) \n @zonedata_str = Zone.MEMCACHED_LoadZoneXML\n else\n @zonedata = Zone.find_zones_in_view_xml(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H)\n @zonedata_str = Zone.MEMCACHED_SaveZoneXML(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H, @zonedata)\n end\n else\n @zonedata = Zone.find_zones_in_view_xml(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H)\n end\n #cache will be effective for 30 seconds\n respond_to do |format|\n format.xml { render :layout => false}\n end\n # redirect_to( :controller => \"users\", :action => \"index\" )\n end",
"def outports\n all_ports :out\n end",
"def pan_view( x = 1, do_display = DO_DISPLAY )\n old_left_column = @left_column\n pan_view_to( @left_column + x, do_display )\n @left_column - old_left_column\n end",
"def recall_map_view\n get :map_view\n end",
"def refresh_view?\n visible? && (ox >= bordered_width || oy >= bordered_height)\n end",
"def _layout(*_arg0); end",
"def test_port_range\n proxy = OpenShift::FrontendProxyServer.new\n \n range = proxy.port_range(500)\n\n assert_equal range.begin, @ports_begin\n assert_equal range.end, (@ports_begin + @ports_per_user)\n end",
"def current_open_ports\n tcp_ports = []\n udp_ports = []\n security_group.ip_permissions.each do |hsh|\n proto, from, to = hsh['ipProtocol'], hsh['fromPort'], hsh['toPort']\n case proto\n when 'tcp'\n tcp_ports.push Range.new(from, to).to_a\n when 'udp'\n udp_ports.push Range.new(from, to).to_a\n end\n end\n {tcp: tcp_ports.flatten, udp: udp_ports.flatten}\n end",
"def views(name = nil)\n raise NotImplementedError, \"views is an abstract method\"\n end",
"def view_assigns; end",
"def view_assigns; end",
"def go_out\n case @game.view\n when :current_map\n @game.switch_view\n# @current_memory = :world_map\n end\n end",
"def bounds_mapbox_url(viewport)\n w, s, e, n = viewport.bounds\n c_lon, c_lat = viewport.center\n data = [\n [w, n],\n [w, c_lat],\n [w, s],\n [c_lon, s],\n [e, s],\n [e, c_lat],\n [e, n],\n [c_lon, n],\n [c_lon, c_lat]\n ]\n\n mapbox_url(data, viewport)\nend"
] | [
"0.6157205",
"0.61425483",
"0.61122954",
"0.6106212",
"0.6054225",
"0.602673",
"0.59762543",
"0.59537005",
"0.5639804",
"0.5616005",
"0.55986047",
"0.5592303",
"0.55392796",
"0.55323905",
"0.55320287",
"0.5519079",
"0.55111146",
"0.5454252",
"0.5451369",
"0.5429732",
"0.54147357",
"0.5406306",
"0.54050225",
"0.5378466",
"0.5371039",
"0.5343909",
"0.53391993",
"0.5262973",
"0.52558994",
"0.5247906",
"0.52231675",
"0.5214312",
"0.5211019",
"0.52107245",
"0.5204774",
"0.52026016",
"0.5173875",
"0.5173043",
"0.5168392",
"0.5164679",
"0.5146439",
"0.5138176",
"0.5130139",
"0.5123828",
"0.5107757",
"0.50891185",
"0.507965",
"0.5077712",
"0.50402254",
"0.50324416",
"0.5025307",
"0.5022521",
"0.501508",
"0.5012534",
"0.49819583",
"0.4956195",
"0.4956195",
"0.49439982",
"0.49373567",
"0.4932522",
"0.4927288",
"0.49252775",
"0.4921435",
"0.4914962",
"0.49091616",
"0.49019834",
"0.4882448",
"0.4879144",
"0.4879144",
"0.48789442",
"0.48763695",
"0.48721272",
"0.48702884",
"0.4869972",
"0.48664004",
"0.48656914",
"0.48588568",
"0.48572743",
"0.48525947",
"0.484774",
"0.4846942",
"0.48460504",
"0.48448983",
"0.48435917",
"0.4838717",
"0.48352116",
"0.4826556",
"0.48240343",
"0.48232317",
"0.48076248",
"0.48053348",
"0.4804919",
"0.47961167",
"0.47936723",
"0.4779621",
"0.47786677",
"0.47784597",
"0.47783047",
"0.47783047",
"0.47782266",
"0.477727"
] | 0.0 | -1 |
Supported callback functions connection_established connected pose periodic Under working unlock lock active_change | def start
EM.run do
@__conn = EventMachine::WebSocketClient.connect(@__socket_url)
@__callbacks[:connection_established] &&
@__conn.callback do
instance_exec(&@__callbacks[:connection_established])
end
@__callbacks[:error] &&
@__conn.errback do |e|
instance_exec(e, &@__callbacks[:error])
end
@__conn.stream do |msg|
@__conn.close_connection if msg.data == "done"
event = JSON.parse(msg.data)[1]
case event['type']
when 'paired'
@__event_pool[:paired] = event
when 'connected'
break unless @__callbacks[:connected]
instance_exec(&@__callbacks[:connected])
@__event_pool[:connected] = event
when 'arm_synced'
@__event_pool[:arm_synced] = event
when 'unlocked'
puts("unlocked!")
@__event_pool[:unlocked] ||= false
@__event_pool[:unlocked] = true
when 'pose'
break unless @__callbacks[:pose]
pose = event['pose']
puts "this is pose: " + pose
#instance_exec(@__event_pool[:pose][:pose], :off, &@__callbacks[:pose]) if @__event_pool[:pose][:pose]
instance_exec(pose, :on, &@__callbacks[:pose])
@__event_pool[:pose] = event
when 'orientation'
break unless @__callbacks[:periodic]
e = OpenStruct.new({
:accel => OpenStruct.new({
:x => event['accelerometer'][0],
:y => event['accelerometer'][1],
:z => event['accelerometer'][2]
}),
:gyro => OpenStruct.new({
:x => event['gyroscope'][0],
:y => event['gyroscope'][1],
:z => event['gyroscope'][2]
}),
:orientation => OpenStruct.new(event['orientation'])
})
@__event_pool[:orientation] = e
instance_exec(e, &@__callbacks[:periodic])
end
end
@__conn.disconnect do
EM::stop_event_loop
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_connected\n end",
"def on_connected\n\t\t\t\t@@connected = true\n\t\t\t\twhile not @@ensure.empty?\n\t\t\t\t\tfunc = @@ensure.shift\n\t\t\t\t\tensured func[0], *func[1]\t# func[0] == function name, func[1] == arguments\n\t\t\t\tend\n\t\t\t\tpublish('zk_connected')\n\t\t\tend",
"def connection_completed\n\tend",
"def connection_established(*args)\n\tend",
"def client_connected\n end",
"def connection_completed\n end",
"def connected\n\t\tdo_send('CN1')\t# Connection command - initiate comms\n\t\n\t\t@polling_timer = schedule.every('60s') do\n\t\t\tlogger.debug \"Polling JVC\"\n\t\t\tdo_send('CN1')\t# Connection command\n\t\tend\n\tend",
"def on_activate\n MotionConcierge.fetch\n end",
"def connected\n\t\t#\n\t\t# Get current state of the projector\n\t\t#\n\t\tdo_poll\n\t\t\n\t\t#\n\t\t# Get the state every 50 seconds :)\n\t\t#\n\t\t@polling_timer = schedule.every('50s') do\n\t\t\tdo_poll\n\t\tend\n\tend",
"def connected?; end",
"def connected?; end",
"def connected?; end",
"def communicates?; !disconnected? end",
"def on_connect(&callback)\n @connect_cb = callback\n end",
"def reconnect!\n @active = true\n end",
"def post_init\n @connected = true\n end",
"def post_init\n @connected = true\n end",
"def disconnect!; true; end",
"def connection_established(pid, conn)\n @connections[pid.uuid] ||= conn\n __send__(conn.connected_callback, pid)\n @connections[pid.uuid].remote_pid || pid # looks like hack, but it is not.\n end",
"def on_open(&block)\n define_callback :connect, &block\n end",
"def connection_completed\n @connection_state = :connected\n @connection_state_callback.call if @connection_state_callback\n end",
"def on_connecting\n\t\t\t\t@@connected = false\n\t\t\t\tpublish('zk_connecting')\n\t\t\tend",
"def on_connection_established(&block)\n @on_connection_established_block = block\n end",
"def on_disconnected\n end",
"def disconnect!; end",
"def connect\n succeed # Triggers all callbacks for class\n end",
"def on_connected(&block)\n @on_connected_procs << block\n end",
"def disconnect; end",
"def disconnect; end",
"def still_connected?\n true\n end",
"def onConnectionStatusChanged(conn, new_status)\n puts :info, \"MQ connection state \" + @conn.status_text(new_status)\n\n if ((new_status & P2::CS_ROUTER_CONNECTED) != 0)\n # Когда соединились - запрашиваем адрес сервера-обработчика ?\n end\n end",
"def on_connection_success &block\n @connection_success_callback = block\n end",
"def state\n Cproton.pn_connection_state(@impl)\n end",
"def connection_successful\n @authenticating = false\n opened!\n\n exec_callback_yielding_self(:connect)\n end",
"def connection_status_done; end",
"def connection_completed\n# @keepalive = EM::PeriodicTimer.new(60) { send_data ' ' }\n start\n end",
"def connected_update(protocol_message)\n # ClientID validity is already checked as part of the incoming message processing\n client.auth.configure_client_id protocol_message.connection_details.client_id\n\n # Update the connection details and any associated defaults\n connection.set_connection_details protocol_message.connection_details\n\n connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial\n\n state_change = Ably::Models::ConnectionStateChange.new(\n current: connection.state,\n previous: connection.state,\n event: Ably::Realtime::Connection::EVENT(:update),\n reason: protocol_message.error,\n protocol_message: protocol_message\n )\n connection.emit :update, state_change\n end",
"def connected?; connection_state == :connected end",
"def establish_connection\n end",
"def wait_connection; end",
"def wait_connection; end",
"def connect!; end",
"def connect!; end",
"def preconnect(concurrent = nil)\n hold{}\n end",
"def on_open(event)\n logger.debug \"Connection openned as user: #{@user} on channel: #{@channel}.\"\n end",
"def disconnect\n\tend",
"def connection_completed\n @connected = true\n Skates.logger.debug {\n \"CONNECTED\"\n } # Very low level Logging\n end",
"def wait_until_open_confirmed; end",
"def switch_on(active_user, tag = nil)\n update(status: :active,current_user: active_user.id)\n mqtt_control_on\n socket_usage = SocketUsage.create!(user: active_user,\n el_socket: self, start_time: Time.now.utc,\n date: Date.today, start_tag: tag)\n\n active_user.last_usage = socket_usage.id\n active_user.save\n end",
"def connection_ended\n end",
"def connection_ended\n end",
"def on_connect(&callback)\n if block_given?\n @on_connect = callback\n elsif @on_connect\n @on_connect.call\n end\n end",
"def connected(protocol_message)\n # ClientID validity is already checked as part of the incoming message processing\n client.auth.configure_client_id protocol_message.connection_details.client_id\n\n # Update the connection details and any associated defaults\n connection.set_connection_details protocol_message.connection_details\n\n if connection.key\n if protocol_message.connection_id == connection.id\n logger.debug { \"ConnectionManager: Connection resumed successfully - ID #{connection.id} and key #{connection.key}\" }\n EventMachine.next_tick { connection.trigger_resumed }\n resend_pending_message_ack_queue\n else\n logger.debug { \"ConnectionManager: Connection was not resumed, old connection ID #{connection.id} has been updated with new connection ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}\" }\n nack_messages_on_all_channels protocol_message.error\n force_reattach_on_channels protocol_message.error\n end\n else\n logger.debug { \"ConnectionManager: New connection created with ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}\" }\n end\n\n reattach_suspended_channels protocol_message.error\n\n connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial\n end",
"def connection_completed\n ## start sending KEEP_ALIVE_MESSAGE\n puts 'sending keep_alive sending ...'\n EM::PeriodicTimer.new(KEEP_ALIVE_INTERVAL) { send_data KEEP_ALIVE_MESSAGE }\n end",
"def onConnectionStatusChanged(conn, new_status)\n state = \"MQ connection state \" + @conn.status_text(new_status)\n\n if ((new_status & P2::CS_ROUTER_CONNECTED) != 0)\n # Когда соединились - запрашиваем адрес сервера-обработчика\n end\n log.puts(state)\n end",
"def opened_sensor_activated\n @state = @state.opened\n end",
"def connect(*) end",
"def connect\n end",
"def disconnecting?; connection_state == :disconnecting end",
"def data_channel_open\n puts \"Data channel open!\"\n data_channel = $$.data_channel\n # send_message(\"ALIVE\")\nend",
"def closed_sensor_activated\n @state = @state.closed\n end",
"def connect; end",
"def connect\n\t\t@state = STATE_ONLINE\n\t\treturn true\n\tend",
"def waited_on_connect?\n @waited_on_connect\n end",
"def client_disconnected\n end",
"def callback\n\n end",
"def em_connect()\n @mutex.synchronize do\n @wscon = WebSocket::EventMachine::Client.connect(:uri => @wsuri)\n end\n @wscon.comm_inactivity_timeout = 60\n\n @wscon.onopen do\n @status = :open\n end\n\n @wscon.onmessage do |data|\n EM.defer do\n packet = JSON.load(data)\n if @status == :open\n if packet.has_key? \"error\"\n LogService.warn \"packet error: #{packet[\"type\"]}, #{packet[\"error\"]}\"\n end\n \n if @callbacks.has_key? packet[\"type\"]\n @callbacks[packet[\"type\"]].each do |c|\n c.call(packet[\"data\"])\n end\n end\n end\n end\n end\n\n @wscon.onclose do |code, reason|\n if @status == :closing\n @status = :closed\n elsif @status == :open || @status == :opening\n @status = :opening\n EM.add_timer(10) do\n em_connect()\n end\n end\n end\n end",
"def reconnect\n end",
"def post_connect_hooks; end",
"def post_connect_hooks; end",
"def on_reconnect(&callback)\n @reconnect_cb = callback\n end",
"def connect\n self.send({\n msg: :connect,\n version: @version,\n support: @support\n })\n\n #handle incoming response form the server\n self.onmessage = lambda do |event|\n\n res = JSON.parse(event.data)\n\n if res.has_key? 'session'\n #connection is successful - update session and record version\n @session = res['session'].to_s\n @@last_suc_version = @version\n\n else #there was a failed connection\n @version = res['version']\n #retry the send request with the version specified by the server\n self.send({\n msg: :connect\n version: @version,\n support: @support\n })\n end\n\n end\n end",
"def pre_connect\n\t\t\ttrue\n\t\tend",
"def on_client_connect(client)\n end",
"def callback\n\tend",
"def connect!\n end",
"def callback\n end",
"def activate\n update active: true\n end",
"def heartbeat\n end",
"def on_connect(obj=nil, &block)\n @on_connect_obj = obj\n @on_connect = Proc.new { |handle, obj_ptr|\n # On connect, we'll need to re-add all of our change handlers\n @listeners.each_pair do |pattern, (listener, proc)|\n begin\n next if status != :connected\n Klass.set_OnKeyChange_Handler(@handle, listener, pattern, proc, pointer_for(obj)) \n sleep @handler_sleep\n rescue\n Phidgets::Log.error(\"#{self.class}::on_connect\", $!.to_s)\n end\n end\n yield self, object_for(obj_ptr)\n }\n Klass.set_OnServerConnect_Handler(@handle, @on_connect, pointer_for(obj))\n sleep @handler_sleep\n end",
"def socket_connected\n post_init\n end",
"def on_ready\n end",
"def ssl_handshake_completed\n connected!\n end",
"def activate\n change, @active, @acknowledged = !@active, true, false\n update_timestamp if change\n change\n end",
"def event_new_connection(client)\n client.var[:last_ping] = Time.now # Initialize ping-timeout variable\n if @motd[EMPTY_ROOM]\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"motd #{EMPTY_ROOM}#{@motd[EMPTY_ROOM]}\")\n ) { |x| x == client }\n end\nend",
"def established?\n @connected == true\n end",
"def connection_closed\n end",
"def verify!\n reconnect! unless active?\n end",
"def connect\n unless @connected\n once('report_version', ->() do\n once('firmware_query', ->() do\n once('capability_query', ->() do\n once('analog_mapping_query', ->() do\n\n 2.times { |i| toggle_pin_reporting(i) }\n\n @connected = true\n emit('ready')\n end)\n query_analog_mapping\n end)\n query_capabilities\n end)\n end)\n\n until connected?\n read_and_process\n delay(0.5)\n end\n end\n\n self\n end",
"def client_connected\n puts \"client #{current_user.email} connected\"\n current_player = current_user.player || current_user.create_player\n current_player.is_online = true\n current_player.save\n coords = [\n current_player.left,\n current_player.top,\n current_player.id,\n current_player.last_direction\n ]\n send_message :starting_position, coords\n \n # Get an array of the other players, convert to hash keyed on player id\n players = Player.where 'user_id != ? and is_online = ?', current_user, true\n player_hash = {}\n players.each do |player|\n player_hash[player.id] = {\n user_name: player.user.email.sub(/@.+/, ''),\n is_moving: player.is_moving,\n last_direction: player.last_direction,\n left: player.left,\n top: player.top\n }\n end\n send_message :player_list, player_hash\n \n broadcast_message :player_enter, {\n user_name: current_user.email.sub(/@.+/, ''),\n id: current_player.id,\n last_direction: current_player.last_direction,\n left: current_player.left,\n top: current_player.top\n }\n end",
"def doge_control_signal\r\n end",
"def pro_activate\n set_activate\n end",
"def post_init\n puts \"connection established\"\n \n # store the eventmachine connection object id\n @connection.id = self.object_id\n end",
"def onconnect &blk\n @onconnect = blk unless blk.nil?\n @onconnect\n end",
"def reconnect!\n if active?\n disconnect\n end\n connect\n end",
"def _pt_session_state_ready msg, data\n protocol \"session/colorize:disable\" unless colorize?\n protocol \"session/identify:#{CLIENT_NAME}\"\n end",
"def update\n pulse = generate_pulse.resume\n @connections.values.each do |connection|\n connection.pulse(PulseEngine::Pulse.new) if pulse && !connection.nil?\n end\n end",
"def callbacks; end",
"def callbacks; end",
"def on_open(env)\n @subscription = @config.consumer(env).subscription(@config.channel(env))\n @subscription.on_message {|message, consumer| send_data message }\n @subscription.subscribe\n end"
] | [
"0.6536326",
"0.6221397",
"0.6164967",
"0.61196315",
"0.5916015",
"0.5872544",
"0.586732",
"0.5853808",
"0.5849928",
"0.5830136",
"0.5830136",
"0.5830136",
"0.57994324",
"0.5795651",
"0.5764433",
"0.5759912",
"0.5759912",
"0.5692927",
"0.5678233",
"0.56694436",
"0.56567425",
"0.5634596",
"0.56316984",
"0.5628739",
"0.56253695",
"0.5597595",
"0.5593481",
"0.5562322",
"0.5562322",
"0.55511874",
"0.5537204",
"0.5526797",
"0.55230886",
"0.55031025",
"0.54910076",
"0.54607344",
"0.5423321",
"0.54127073",
"0.5408201",
"0.5392822",
"0.5392822",
"0.53797865",
"0.53797865",
"0.5365359",
"0.53596246",
"0.5359586",
"0.53560466",
"0.5347617",
"0.5308919",
"0.53061855",
"0.53061855",
"0.5302892",
"0.52761805",
"0.52702147",
"0.52679217",
"0.5261755",
"0.52306134",
"0.5214578",
"0.5212128",
"0.52032137",
"0.5200483",
"0.51992536",
"0.5183912",
"0.5177823",
"0.51706094",
"0.51599944",
"0.51540047",
"0.5147594",
"0.51397234",
"0.51397234",
"0.51368564",
"0.5135433",
"0.5132314",
"0.51215273",
"0.51193255",
"0.51166075",
"0.51058173",
"0.50820184",
"0.5078488",
"0.50726545",
"0.50476325",
"0.5045747",
"0.5039189",
"0.5029249",
"0.5024764",
"0.50230885",
"0.50227135",
"0.50192726",
"0.501838",
"0.50166076",
"0.5014898",
"0.4997056",
"0.49952787",
"0.4994549",
"0.49926364",
"0.49922475",
"0.4990766",
"0.49896342",
"0.49896342",
"0.49877003"
] | 0.5656224 | 21 |
GET /medidas GET /medidas.json | def index
@medidas = Medida.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @medidas }
#format.pdf do
# pdf = MedidasPdf.new(@medidas, view_context)
# send_data pdf.render, filename: "medidas.pdf",
# type: "application/pdf",
# disposition: "inline"
#end
format.pdf {reporte_medidas(@medidas)}
format.xls {send_data @medidas.to_xls, :filename => 'reporte.xls' }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medida }\n end\n end",
"def show\n @unidade_medida = UnidadeMedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end",
"def show\n @relacion_articulo_medida = RelacionArticuloMedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relacion_articulo_medida }\n end\n end",
"def show\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medio }\n end\n end",
"def show\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end",
"def show\n @medzz = Medzz.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medzz }\n end\n end",
"def index\n @medalhas = Medalha.all\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def show\n @title = \"Current Medic\"\n @medic = Medic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medic }\n end\n end",
"def new\n @medida = Medida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medida }\n end\n end",
"def index\n @medicinas = Medicina.all\n end",
"def show\n @medicine = Medicine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicine }\n end\n end",
"def show\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mesasredonda }\n end\n end",
"def show\n @mencion = Mencion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mencion }\n end\n end",
"def index\n @title = \"Doctor List\"\n @medics = Medic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @medics }\n end\n end",
"def index\n @medications = Medication.all\n render json: @medications\n end",
"def show\n @medio_pago = MedioPago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medio_pago }\n end\n end",
"def show\n @materia = Materia.find(params[:id])\n\n render json: @materia\n end",
"def show\n @receita_medica = ReceitaMedica.find(params[:id])\n @item_receitas = @receita_medica.item_receitas.all\n respond_to do |format|\n format.html # show.html.erb \n format.json { render json: {\n :receita => @receita_medica, \n :medicamentos => @receita_medica.item_receitas.collect {|t| [t.medicamento.nome, t.posologia, t.quantidade]} } }\n end\n end",
"def show\n @medrecord = Medrecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medrecord }\n end\n end",
"def show\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medida }\n end\n end",
"def index\n @unidad_medidas = UnidadMedida.all\n end",
"def show\n @materia = Materia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @materia }\n end\n end",
"def index\n @medicos = Medico.all\n end",
"def show \n @dilemma = Dilemma.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dilemma }\n end \n end",
"def show\n respond_to do |format|\n format.html\n format.json { render json: @maudio}\n end\n end",
"def show\n @medicine_patient_relationship = MedicinePatientRelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicine_patient_relationship }\n end\n end",
"def show\r\n render json: @registro_medicion.to_json, status: :ok\r\n end",
"def index\n @medidores = Medidor.all\n end",
"def new\n @unidade_medida = UnidadeMedida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def show\n @mercado_metum = MercadoMetum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mercado_metum }\n end\n end",
"def show\n @mood = Mood.find(params[:id])\n respond_to do |format|\n format.any { render :json => @mood }\n end\n end",
"def show\n @dymmmy = Dymmmy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dymmmy }\n end\n end",
"def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def show\n\t\t@medical = Medical.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @medical }\n\t\tend\n\tend",
"def show\n @humanidades3 = Humanidades3.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @humanidades3 }\n end\n end",
"def medals\n # --- \"Medals\" tab: ---\n @tab_title = I18n.t('radiography.medals_tab')\n @medal_types = MedalType.all.sort_by_rank\n sm = SwimmerMedals.new( @swimmer )\n sm.retrieve_data\n @swimmer_medals_dao = sm.get_medals_dao\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def show\n @diemtrentuyen = Diemtrentuyen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @diemtrentuyen }\n end\n end",
"def show\n @mision = Mision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision }\n end\n end",
"def show\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mapeamento }\n end\n end",
"def show\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallarmorinfo }\n end\n end",
"def show\n @musique = Musique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @musique }\n end\n end",
"def meals\n get(\"/user/#{@user_id}/meals.json\")\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def new\n @title = \"New Medic\"\n @medic = Medic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medic }\n end\n end",
"def show\n @unidadmedida = Unidadmedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unidadmedida }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mood }\n end\n end",
"def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end",
"def show\n @publicidad = Publicidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @publicidad }\n end\n end",
"def show\n @humanidades1 = Humanidades1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @humanidades1 }\n end\n end",
"def show\n @medical_camp = MedicalCamp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medical_camp }\n end\n end",
"def new\n @medio = Medio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @medio }\n end\n end",
"def get_symptoms\n begin\n @desease = Desease.find(params[:id])\n\n @symptoms = @desease.symptoms\n render json: @symptoms\n rescue ActiveRecord::RecordNotFound => e\n render json: e, status: :unprocessable_entity\n end\n \n \n end",
"def index\n @medical_camps = MedicalCamp.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @medical_camps }\n end\n end",
"def show\n @mision_mision = MisionMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision_mision }\n end\n end",
"def show\n @jedi = Jedi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jedi }\n end\n end",
"def new\n @medicamento = Medicamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def show\n @musician = Musician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @musician }\n end\n end",
"def index\n @midias = Midia.all\n end",
"def show\n @micorpost = Micorpost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @micorpost }\n end\n end",
"def index\n @tipo_medidors = TipoMedidor.all\n end",
"def index\n @diciplinas = Diciplina.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @diciplinas }\n end\n end",
"def show\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medio }\n end\n end",
"def show\n @manga = Manga.find(params[:id])\n @chapters = @manga.ordered_chapters.page(params[:page]).per 15\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manga }\n end\n end",
"def show\n\t\t@pharmacy = Pharmacy.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @pharmacy }\n\t\tend\n\tend",
"def index\n @medic_patients = MedicPatient.all\n end",
"def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend",
"def show\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metodo }\n end\n end",
"def index\n @mediations = Mediation.all\n end",
"def show\n @humanidades2 = Humanidades2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @humanidades2 }\n end\n end",
"def show\n @metum = Metum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metum }\n end\n end",
"def show\n @medal = Medal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medal }\n end\n end",
"def new\n @medzz = Medzz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medzz }\n end\n end",
"def show\n @matricula = Matricula.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @matricula }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def index\n @mencions = Mencion.order(\"escuela_id\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mencions }\n end\n end",
"def show\n @momsg = Momsg.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @momsg }\n end\n end",
"def show\n @medicion = Medicion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medicion }\n end\n end",
"def show\n @moresmalltrial = Moresmalltrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmalltrial }\n end\n end",
"def show\n @mutacao = Mutacao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mutacao }\n end\n end",
"def show\n @publicaciones = Publicacione.find(params[:id])\n render json: @publicaciones, status: :ok\n end",
"def show\n @maptolinkedin = Maptolinkedin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @maptolinkedin }\n end\n end",
"def show\n @jornada = Jornada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jornada }\n end\n end",
"def show\n @mispronunciation = Mispronunciation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @mispronunciation }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n @immigrant = Immigrant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @immigrant }\n end\n end",
"def show\n @publicidade = Publicidade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @publicidade }\n end\n end",
"def index\n @dnas = Dna.all\n\n render json: @dnas\n end",
"def show\n @medium_mission = MediumMission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_mission }\n end\n end",
"def show\n @midia = Midia.find(params[:id])\n end",
"def index\n @medida_tallas = @fichatecnica.medida_tallas.all\n end",
"def set_medicina\n @medicina = Medicina.find(params[:id])\n end",
"def new\n @relacion_articulo_medida = RelacionArticuloMedida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relacion_articulo_medida }\n end\n end",
"def show\n @medication_report = MedicationReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medication_report }\n end\n end",
"def show\n @dynamique = Dynamique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dynamique }\n end\n end",
"def show\n @medusa_premis_representation_object = MedusaPremis::RepresentationObject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medusa_premis_representation_object }\n end\n end",
"def show\n @sklad = Sklad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sklad }\n end\n end",
"def show\n @mill = Mill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mill }\n end\n end"
] | [
"0.7509045",
"0.7208597",
"0.70045656",
"0.69494563",
"0.6893356",
"0.68416566",
"0.6809274",
"0.6748922",
"0.666699",
"0.66198754",
"0.6587202",
"0.6565434",
"0.65458614",
"0.65069896",
"0.6498332",
"0.64963955",
"0.6482404",
"0.6448348",
"0.64417076",
"0.6404297",
"0.64012915",
"0.63519835",
"0.6336591",
"0.63147336",
"0.6254659",
"0.6219316",
"0.6215034",
"0.6208096",
"0.61895096",
"0.6164207",
"0.6141582",
"0.61411834",
"0.61266965",
"0.6124355",
"0.61220276",
"0.6110151",
"0.61020976",
"0.60985315",
"0.60822",
"0.6081755",
"0.6080187",
"0.605954",
"0.6053192",
"0.60381997",
"0.60072935",
"0.6000832",
"0.5998454",
"0.5997862",
"0.599532",
"0.59868425",
"0.59821135",
"0.59719735",
"0.59717035",
"0.59693396",
"0.5965431",
"0.59606534",
"0.59543365",
"0.5951622",
"0.5944298",
"0.5943344",
"0.59400266",
"0.59343076",
"0.59334356",
"0.59330034",
"0.5930601",
"0.5928851",
"0.5922164",
"0.5921726",
"0.5920793",
"0.5917785",
"0.5917457",
"0.591673",
"0.5905158",
"0.5900305",
"0.59000474",
"0.5884337",
"0.5880684",
"0.5877262",
"0.5873167",
"0.5872151",
"0.58716404",
"0.58609384",
"0.5854829",
"0.585155",
"0.5850328",
"0.5848723",
"0.58444583",
"0.5843997",
"0.5840102",
"0.5840013",
"0.58347887",
"0.58299536",
"0.58251697",
"0.582305",
"0.581761",
"0.58174354",
"0.581586",
"0.5809582",
"0.5808292",
"0.58030534",
"0.5799704"
] | 0.0 | -1 |
GET /medidas/1 GET /medidas/1.json | def show
@medida = Medida.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @medida }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @unidade_medida = UnidadeMedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def show\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medio }\n end\n end",
"def show\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def show\n @relacion_articulo_medida = RelacionArticuloMedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relacion_articulo_medida }\n end\n end",
"def show\n @title = \"Current Medic\"\n @medic = Medic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medic }\n end\n end",
"def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end",
"def show\n @medzz = Medzz.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medzz }\n end\n end",
"def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end",
"def show\n @mencion = Mencion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mencion }\n end\n end",
"def show\n @medicine = Medicine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicine }\n end\n end",
"def show\n @medio_pago = MedioPago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medio_pago }\n end\n end",
"def new\n @medida = Medida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medida }\n end\n end",
"def show\n @materia = Materia.find(params[:id])\n\n render json: @materia\n end",
"def show\n @medrecord = Medrecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medrecord }\n end\n end",
"def show\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mesasredonda }\n end\n end",
"def show\n @materia = Materia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @materia }\n end\n end",
"def show\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medida }\n end\n end",
"def show\n @mercado_metum = MercadoMetum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mercado_metum }\n end\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def show\n @humanidades1 = Humanidades1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @humanidades1 }\n end\n end",
"def show\n\t\t@medical = Medical.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @medical }\n\t\tend\n\tend",
"def index\n @medalhas = Medalha.all\n end",
"def index\n @medications = Medication.all\n render json: @medications\n end",
"def show\n @medicine_patient_relationship = MedicinePatientRelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicine_patient_relationship }\n end\n end",
"def show\n @receita_medica = ReceitaMedica.find(params[:id])\n @item_receitas = @receita_medica.item_receitas.all\n respond_to do |format|\n format.html # show.html.erb \n format.json { render json: {\n :receita => @receita_medica, \n :medicamentos => @receita_medica.item_receitas.collect {|t| [t.medicamento.nome, t.posologia, t.quantidade]} } }\n end\n end",
"def index\n @title = \"Doctor List\"\n @medics = Medic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @medics }\n end\n end",
"def index\n @medicinas = Medicina.all\n end",
"def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def show\n @metum = Metum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metum }\n end\n end",
"def new\n @title = \"New Medic\"\n @medic = Medic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medic }\n end\n end",
"def show\n @mision = Mision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision }\n end\n end",
"def show\n @humanidades3 = Humanidades3.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @humanidades3 }\n end\n end",
"def show\n @mood = Mood.find(params[:id])\n respond_to do |format|\n format.any { render :json => @mood }\n end\n end",
"def show\n @musique = Musique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @musique }\n end\n end",
"def show\r\n render json: @registro_medicion.to_json, status: :ok\r\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def show\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medio }\n end\n end",
"def show\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mapeamento }\n end\n end",
"def show\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallarmorinfo }\n end\n end",
"def new\n @medio = Medio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @medio }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render json: @maudio}\n end\n end",
"def show\n @dymmmy = Dymmmy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dymmmy }\n end\n end",
"def new\n @unidade_medida = UnidadeMedida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def show\n @humanidades2 = Humanidades2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @humanidades2 }\n end\n end",
"def show\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metodo }\n end\n end",
"def show\n @music = Music.find_by_sql(\"SELECT * FROM Musics M Where M.id = \" + params[:id]).first()\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @music }\n end\n end",
"def show\n @momsg = Momsg.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @momsg }\n end\n end",
"def index\n @medicos = Medico.all\n end",
"def show\n @matricula = Matricula.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @matricula }\n end\n end",
"def show\n @moresmalltrial = Moresmalltrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmalltrial }\n end\n end",
"def new\n @medicamento = Medicamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def show\n @mill = Mill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mill }\n end\n end",
"def show\n @mision_mision = MisionMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision_mision }\n end\n end",
"def show\n @medicion = Medicion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medicion }\n end\n end",
"def show\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium }\n end\n end",
"def show\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium }\n end\n end",
"def show\n @micorpost = Micorpost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @micorpost }\n end\n end",
"def show\n @medium_mission = MediumMission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_mission }\n end\n end",
"def show\n @diemtrentuyen = Diemtrentuyen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @diemtrentuyen }\n end\n end",
"def show\n @medical_camp = MedicalCamp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medical_camp }\n end\n end",
"def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n end",
"def show\n @mispronunciation = Mispronunciation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @mispronunciation }\n end\n end",
"def show\n @mutacao = Mutacao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mutacao }\n end\n end",
"def show\n @unidadmedida = Unidadmedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unidadmedida }\n end\n end",
"def show\n @mi = Mi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mi }\n end\n end",
"def getmill\n\tformid = Windmill.where(windformid: params[:id])\n\tif formid.present?\n render json: formid.as_json(only:[:no])\n\telse\n\t\trender json: {massage: 'Windform not found'}\n\tend\nend",
"def show\n @monit = Monit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monit }\n end\n end",
"def show\n @mrj = Mrj.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mrj }\n end\n end",
"def show \n @dilemma = Dilemma.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dilemma }\n end \n end",
"def index\n @unidad_medidas = UnidadMedida.all\n end",
"def show\n @musician = Musician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @musician }\n end\n end",
"def show\n @medusa_premis_representation_object = MedusaPremis::RepresentationObject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medusa_premis_representation_object }\n end\n end",
"def show\n @dynamique = Dynamique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dynamique }\n end\n end",
"def new\n @medzz = Medzz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medzz }\n end\n end",
"def show\n @publicidad = Publicidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @publicidad }\n end\n end",
"def show\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ministerio }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @medication_report = MedicationReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medication_report }\n end\n end",
"def index\n @medidores = Medidor.all\n end",
"def show\n @immigrant = Immigrant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @immigrant }\n end\n end",
"def show\n @medhistory = Medhistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medhistory }\n end\n end",
"def show\n @missionmaker = Missionmaker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @missionmaker }\n end\n end",
"def show\n @medal = Medal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medal }\n end\n end",
"def show\n @mattress = Mattress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mattress }\n end\n end",
"def show\n @moresmallmobsquad = Moresmallmobsquad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallmobsquad }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def show\n @aliquotum = Aliquotum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aliquotum }\n end\n end",
"def new\n @remedio = Remedio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @remedio }\n end\n end",
"def show\n @jedi = Jedi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jedi }\n end\n end",
"def show\n @jamaat = Jamaat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jamaat }\n end\n end",
"def show\n @midia = Midia.find(params[:id])\n end",
"def show\n @jm_verse = JmVerse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def show\n @micrrapost = Micrrapost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @micrrapost }\n end\n end",
"def show\n @medidor = Medidor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medidor }\n end\n end",
"def show\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medicamento }\n end\n end",
"def show\n @monnaie = Monnaie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monnaie }\n end\n end",
"def show\n @mall = Mall.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mall }\n end\n end",
"def show\n @microfilm_reel = MicrofilmReel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microfilm_reel }\n end\n end"
] | [
"0.7510774",
"0.740872",
"0.72993684",
"0.72367114",
"0.7225734",
"0.7225199",
"0.7131402",
"0.7000157",
"0.6958874",
"0.6956784",
"0.69363207",
"0.6844287",
"0.6825304",
"0.677263",
"0.66992515",
"0.66816735",
"0.66404593",
"0.66384715",
"0.6624641",
"0.6611369",
"0.6602949",
"0.66028386",
"0.6598484",
"0.6586621",
"0.65783286",
"0.65733486",
"0.65526485",
"0.65471256",
"0.6544471",
"0.65418565",
"0.65277445",
"0.652508",
"0.65049154",
"0.65024674",
"0.6499398",
"0.6478502",
"0.6475101",
"0.6467383",
"0.6466319",
"0.6462349",
"0.64433515",
"0.64399326",
"0.6437713",
"0.6425906",
"0.64096504",
"0.6402686",
"0.6399878",
"0.63921946",
"0.63910156",
"0.6379906",
"0.63742036",
"0.6367449",
"0.63636374",
"0.6355563",
"0.63482785",
"0.63482785",
"0.6344494",
"0.6342553",
"0.6335859",
"0.6334701",
"0.63303685",
"0.6324076",
"0.63204765",
"0.63182014",
"0.6314243",
"0.6314067",
"0.6313061",
"0.62908244",
"0.62820286",
"0.62817293",
"0.6271519",
"0.62626463",
"0.6261066",
"0.6259521",
"0.62579924",
"0.62548345",
"0.62544894",
"0.62414134",
"0.62329215",
"0.62327904",
"0.62247753",
"0.62227994",
"0.6221628",
"0.62137216",
"0.6197773",
"0.61933595",
"0.6180427",
"0.6180427",
"0.61803395",
"0.6177612",
"0.6175198",
"0.6170231",
"0.61578506",
"0.61488676",
"0.614178",
"0.6133977",
"0.6126379",
"0.6121399",
"0.61186975",
"0.61131823"
] | 0.7767065 | 0 |
GET /medidas/new GET /medidas/new.json | def new
@medida = Medida.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @medida }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @unidade_medida = UnidadeMedida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def new\n @medicamento = Medicamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def new\n @title = \"New Medic\"\n @medic = Medic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medic }\n end\n end",
"def new\n @medio = Medio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @medio }\n end\n end",
"def new\n @remedio = Remedio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @remedio }\n end\n end",
"def new\n @medzz = Medzz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medzz }\n end\n end",
"def new\n @relacion_articulo_medida = RelacionArticuloMedida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relacion_articulo_medida }\n end\n end",
"def new\n @mencion = Mencion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mencion }\n end\n end",
"def new\n @medicine = Medicine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medicine }\n end\n end",
"def new\n @manga = Manga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manga }\n end\n end",
"def create\n @medida = Medida.new(params[:medida])\n\n respond_to do |format|\n if @medida.save\n format.html { redirect_to @medida, notice: 'Medida se ha creado con éxito.' }\n format.json { render json: @medida, status: :created, location: @medida }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @medrecord = Medrecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medrecord }\n end\n end",
"def new\n @publicidad = Publicidad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publicidad }\n end\n end",
"def new\n @medication = Medication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medication }\n end\n end",
"def new\n @publicidade = Publicidade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publicidade }\n end\n end",
"def new\n @medio_pago = MedioPago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medio_pago }\n end\n end",
"def new\n authorize! :new, @mesasredonda\n @mesasredonda = Mesasredonda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mesasredonda }\n end\n end",
"def new\n @requerimiento = Requerimiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @requerimiento }\n end\n end",
"def new\n @medida = Medida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @medida }\n end\n end",
"def new\n @momsg = Momsg.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @momsg }\n end\n end",
"def new\n @medicine_patient_relationship = MedicinePatientRelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medicine_patient_relationship }\n end\n end",
"def new\n @mill = Mill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mill }\n end\n end",
"def new\n @materia = Materia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @materia }\n end\n end",
"def create\n @unidade_medida = UnidadeMedida.new(params[:unidade_medida])\n\n respond_to do |format|\n if @unidade_medida.save\n format.html { redirect_to @unidade_medida, notice: 'Unidade medida foi criado com sucesso.' }\n format.json { render json: @unidade_medida, status: :created, location: @unidade_medida }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unidade_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @missionmaker = Missionmaker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @missionmaker }\n end\n end",
"def new\n @dilemma = Dilemma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dilemma }\n end\n end",
"def new\n @monit = Monit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monit }\n end\n end",
"def new\n @motivobaja = MotivoBaja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def new\n @metodo = Metodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @metodo }\n end\n end",
"def new\n @medium = Medium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium }\n end\n end",
"def new\n @mutacao = Mutacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mutacao }\n end\n end",
"def new\n @quest = Quest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end",
"def new\n @fiction = Fiction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fiction }\n end\n end",
"def create\n @medicamento = Medicamento.new(params[:medicamento])\n\n respond_to do |format|\n if @medicamento.save\n format.html { redirect_to @medicamento, notice: 'Medicamento was successfully created.' }\n format.json { render json: @medicamento, status: :created, location: @medicamento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medicamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n format.html { redirect_to @medio, :notice => 'Medio was successfully created.' }\n format.json { render :json => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @humanidades3 = Humanidades3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @humanidades3 }\n end\n end",
"def create\n @medida = Medida.new(params[:medida])\n\n respond_to do |format|\n if @medida.save\n format.html { redirect_to(@medida, :notice => 'Medida was successfully created.') }\n format.xml { render :xml => @medida, :status => :created, :location => @medida }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medida.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @pedido = Pedido.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pedido }\n end\n end",
"def new\n @diciplina = Diciplina.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @diciplina }\n end\n end",
"def new\n @lid = Lid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lid }\n end\n end",
"def new\n @demanda = Demanda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @demanda }\n end\n end",
"def new\n @idiom = Idiom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @idiom }\n end\n end",
"def new\n\t\t@pharmacy = Pharmacy.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @pharmacy }\n\t\tend\n\tend",
"def new\n @mision = Mision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mision }\n end\n end",
"def new\n @pageType = \"new\"\n @patient = Patient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end",
"def create\n @midia = Midia.new(midia_params)\n\n respond_to do |format|\n if @midia.save\n format.html { redirect_to @midia, notice: 'Um novo tipo de mídia foi criado com sucesso.' }\n format.json { render json: @midia, status: :created, location: @midia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @midia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @artigo = Artigo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @artigo }\n end\n end",
"def new\n @kid = Kid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kid }\n end\n end",
"def new\n @hasil = Hasil.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hasil }\n end\n end",
"def new\n @mi = Mi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mi }\n end\n end",
"def new\n @immigrant = Immigrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @immigrant }\n end\n end",
"def new\n @micorpost = Micorpost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @micorpost }\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def new\n @mlp = Mlp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mlp }\n end\n end",
"def new\n @mispronunciation = Mispronunciation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @mispronunciation }\n end\n end",
"def new\n @derpu = Derpu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @derpu }\n end\n end",
"def new\n @skid = Skid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skid }\n end\n end",
"def new\n @presenza = Presenza.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @presenza }\n end\n end",
"def new\n @ped = Ped.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ped }\n end\n end",
"def new\n @humanidades2 = Humanidades2.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @humanidades2 }\n end\n end",
"def new\n @foam = Foam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foam }\n end\n end",
"def new\n @mtype = Mtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mtype }\n end\n end",
"def new\n @detalle = Detalle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @detalle }\n end\n end",
"def new\n @diemtrentuyen = Diemtrentuyen.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @diemtrentuyen }\n end\n end",
"def new\n @mall = Mall.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mall }\n end\n end",
"def new\n @medicion = Medicion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @medicion }\n end\n end",
"def new\n @title = t('view.firms.new_title')\n @firm = Firm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @firm }\n end\n end",
"def new\n @id = Id.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @id }\n end\n end",
"def new\n @jedi = Jedi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jedi }\n end\n end",
"def new\n @humanidades1 = Humanidades1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @humanidades1 }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alley }\n end\n end",
"def new\n @patrocinio = Patrocinio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patrocinio }\n end\n end",
"def new\n @dish = Dish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dish }\n end\n end",
"def new\n @dish = Dish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dish }\n end\n end",
"def new\n @moose = Moose.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @moose }\n end\n end",
"def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n end",
"def new\n @farm = Farm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @farm }\n end\n end",
"def new\n @mrj = Mrj.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mrj }\n end\n end",
"def new\n @denuncia_tipo = DenunciaTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @denuncia_tipo }\n end\n end",
"def new\n @jam = Jam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jam }\n end\n end",
"def new\n @medio = Medio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @medio }\n end\n end",
"def new\n @marina = Marina.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @marina }\n end\n end",
"def new\n @pagamento = Pagamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pagamento }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end",
"def new\n @dymmmy = Dymmmy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dymmmy }\n end\n end",
"def new\n @micrrapost = Micrrapost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @micrrapost }\n end\n end",
"def new\n @sm = Sm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sm }\n end\n end",
"def new\n @periodismo = Periodismo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @periodismo }\n end\n end",
"def new\n @firm = Firm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @firm }\n end\n end",
"def new\n @musique = Musique.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @musique }\n end\n end",
"def new\n @slam = Slam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slam }\n end\n end",
"def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end",
"def new\n @medium_mission = MediumMission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium_mission }\n end\n end",
"def new\n @agronomiaquimica = Agronomiaquimica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def new\n @dato = Dato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dato }\n end\n end",
"def create\n @medalha = Medalha.new(medalha_params)\n\n respond_to do |format|\n if @medalha.save\n format.html { redirect_to @medalha, notice: 'Medalha was successfully created.' }\n format.json { render :show, status: :created, location: @medalha }\n else\n format.html { render :new }\n format.json { render json: @medalha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @jamaat = Jamaat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jamaat }\n end\n end",
"def new\n @monnaie = Monnaie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monnaie }\n end\n end",
"def new\n @precinct = Precinct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @precinct }\n end\n end",
"def new\n @flaw = Flaw.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flaw }\n end\n end"
] | [
"0.7673849",
"0.76505196",
"0.7626473",
"0.7541467",
"0.746644",
"0.74476576",
"0.74274206",
"0.74026173",
"0.73853487",
"0.736431",
"0.7359774",
"0.7297636",
"0.7295517",
"0.72739285",
"0.7269561",
"0.7235112",
"0.7203534",
"0.71738094",
"0.71652657",
"0.71181333",
"0.711339",
"0.71074677",
"0.70850164",
"0.7084465",
"0.7081275",
"0.707772",
"0.70739985",
"0.7065628",
"0.7058753",
"0.7055668",
"0.70497864",
"0.7049164",
"0.7047609",
"0.7043714",
"0.7040419",
"0.7039701",
"0.70367664",
"0.70364904",
"0.70356727",
"0.70323646",
"0.70227075",
"0.70212424",
"0.7017978",
"0.7012236",
"0.7009873",
"0.7002661",
"0.69950616",
"0.6991794",
"0.6991202",
"0.6982858",
"0.6976358",
"0.69734997",
"0.69732785",
"0.6972527",
"0.69716895",
"0.697118",
"0.6966053",
"0.69604236",
"0.6959344",
"0.6958557",
"0.6957146",
"0.6955118",
"0.69513226",
"0.69489205",
"0.6947139",
"0.6942891",
"0.69396627",
"0.6937781",
"0.6935948",
"0.69355184",
"0.69342965",
"0.69340724",
"0.6933883",
"0.6933883",
"0.6933486",
"0.6932523",
"0.6924082",
"0.6914551",
"0.6914011",
"0.69118214",
"0.69092816",
"0.6908614",
"0.6903028",
"0.6902422",
"0.69005924",
"0.68985015",
"0.6897161",
"0.68948764",
"0.6890668",
"0.688819",
"0.6887012",
"0.6886056",
"0.6885512",
"0.6878828",
"0.68766665",
"0.68726957",
"0.6872014",
"0.6871431",
"0.68712276",
"0.68699247"
] | 0.7999669 | 0 |
POST /medidas POST /medidas.json | def create
@medida = Medida.new(params[:medida])
respond_to do |format|
if @medida.save
format.html { redirect_to @medida, notice: 'Medida se ha creado con éxito.' }
format.json { render json: @medida, status: :created, location: @medida }
else
format.html { render action: "new" }
format.json { render json: @medida.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @medalha = Medalha.new(medalha_params)\n\n respond_to do |format|\n if @medalha.save\n format.html { redirect_to @medalha, notice: 'Medalha was successfully created.' }\n format.json { render :show, status: :created, location: @medalha }\n else\n format.html { render :new }\n format.json { render json: @medalha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unidade_medida = UnidadeMedida.new(params[:unidade_medida])\n\n respond_to do |format|\n if @unidade_medida.save\n format.html { redirect_to @unidade_medida, notice: 'Unidade medida foi criado com sucesso.' }\n format.json { render json: @unidade_medida, status: :created, location: @unidade_medida }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unidade_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medida = Medida.new(params[:medida])\n\n respond_to do |format|\n if @medida.save\n format.html { redirect_to(@medida, :notice => 'Medida was successfully created.') }\n format.xml { render :xml => @medida, :status => :created, :location => @medida }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medida.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def medida_params\n params.require(:medida).permit(:codigo, :nombre, :descripcion, :user_id)\n end",
"def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n format.html { redirect_to @medio, :notice => 'Medio was successfully created.' }\n format.json { render :json => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @medicamento = Medicamento.new(params[:medicamento])\n\n respond_to do |format|\n if @medicamento.save\n format.html { redirect_to @medicamento, notice: 'Medicamento was successfully created.' }\n format.json { render json: @medicamento, status: :created, location: @medicamento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medicamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @midia = Midia.new(midia_params)\n\n respond_to do |format|\n if @midia.save\n format.html { redirect_to @midia, notice: 'Um novo tipo de mídia foi criado com sucesso.' }\n format.json { render json: @midia, status: :created, location: @midia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @midia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unidad_medida.user_id = current_user.id\n respond_to do |format|\n if @unidad_medida.save\n format.html { redirect_to @unidad_medida, notice: 'Unidad medida was successfully created.' }\n format.json { render :show, status: :created, location: @unidad_medida }\n else\n format.html { render :new }\n format.json { render json: @unidad_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unidad_medida.user_id = current_user.id\n respond_to do |format|\n if @unidad_medida.save\n format.html { redirect_to @unidad_medida, notice: 'Unidad medida was successfully created.' }\n format.json { render :show, status: :created, location: @unidad_medida }\n else\n format.html { render :new }\n format.json { render json: @unidad_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medidor = Medidor.new(medidor_params)\n\n respond_to do |format|\n if @medidor.save\n format.html { redirect_to @medidor, notice: 'Medidor was successfully created.' }\n format.json { render :show, status: :created, location: @medidor }\n else\n format.html { render :new }\n format.json { render json: @medidor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relacion_articulo_medida = RelacionArticuloMedida.new(params[:relacion_articulo_medida])\n\n respond_to do |format|\n if @relacion_articulo_medida.save\n format.html { redirect_to @relacion_articulo_medida, notice: 'Relacion articulo medida was successfully created.' }\n format.json { render json: @relacion_articulo_medida, status: :created, location: @relacion_articulo_medida }\n else\n format.html { render action: \"new\" }\n format.json { render json: @relacion_articulo_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @remedio = Remedio.new(params[:remedio])\n\n respond_to do |format|\n if @remedio.save\n format.html { redirect_to @remedio, notice: 'Remedio was successfully created.' }\n format.json { render json: @remedio, status: :created, location: @remedio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @remedio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_medidor = TipoMedidor.new(tipo_medidor_params)\n\n respond_to do |format|\n if @tipo_medidor.save\n format.html { redirect_to @tipo_medidor, notice: 'Se ha creado un nuevo Tipo de Medidor.' }\n format.json { render :show, status: :created, location: @tipo_medidor }\n else\n format.html { render :new }\n format.json { render json: @tipo_medidor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medal = Medal.new(medal_params)\n\n respond_to do |format|\n if @medal.save\n format.html { redirect_to @medal, notice: 'Medal was successfully created.' }\n format.json { render :show, status: :created, location: @medal }\n else\n format.html { render :new }\n format.json { render json: @medal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medico = Medico.new(medico_params)\n\n respond_to do |format|\n if @medico.save\n format.html { redirect_to @medico, notice: \"Medico criado com SUCESSO.\" }\n format.json { render :show, status: :created, location: @medico }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @medico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @medida = Medida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medida }\n end\n end",
"def create\n @medida_talla = MedidaTalla.new(medida_talla_params)\n @medida_talla.fichatecnica_id = @fichatecnica.id\n respond_to do |format|\n if @medida_talla.save\n format.html { redirect_to fichatecnica_medida_tallas_path(@fichatecnica), notice: 'Medida talla was successfully created.' }\n format.json { render :show, status: :created, location: @medida_talla }\n else\n format.html { render :new }\n format.json { render json: @medida_talla.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unidadmedida = Unidadmedida.new(params[:unidadmedida])\n\n respond_to do |format|\n if @unidadmedida.save\n flash[:notice] = 'Unidadmedida was successfully created.'\n format.html { redirect_to(@unidadmedida) }\n format.xml { render :xml => @unidadmedida, :status => :created, :location => @unidadmedida }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unidadmedida.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def medalha_params\n params.require(:medalha).permit(:titulo)\n end",
"def create\n @ahmed = Ahmed.new(ahmed_params)\n\n respond_to do |format|\n if @ahmed.save\n format.html { redirect_to @ahmed, notice: 'Ahmed was successfully created.' }\n format.json { render :show, status: :created, location: @ahmed }\n else\n format.html { render :new }\n format.json { render json: @ahmed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mdistantmetastasi_params\n params.require(:mdistantmetastasi).permit(:id, :name)\n end",
"def create\n @receita_medica = ReceitaMedica.new(params[:receita_medica])\n @receita_medica.medico = current_user\n\n respond_to do |format|\n if @receita_medica.save\n format.html { redirect_to @receita_medica, notice: 'Receita medica was successfully created.' }\n format.json { render json: @receita_medica, status: :created, location: @receita_medica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @receita_medica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unidad_medida_params\n params.require(:unidad_medida).permit(:codigo, :nombre, :descripcion, :user_id, :empresa_id)\n end",
"def create\n @mdistantmetastasi = Mdistantmetastasi.new(mdistantmetastasi_params)\n\n respond_to do |format|\n if @mdistantmetastasi.save\n format.html { redirect_to @mdistantmetastasi, notice: 'Mdistantmetastasi was successfully created.' }\n format.json { render :show, status: :created, location: @mdistantmetastasi }\n else\n format.html { render :new }\n format.json { render json: @mdistantmetastasi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @account_medal = AccountMedal.new(account_medal_params)\n\n respond_to do |format|\n if @account_medal.save\n format.html { redirect_to @account_medal, notice: 'Account medal was successfully created.' }\n format.json { render :show, status: :created, location: @account_medal }\n else\n format.html { render :new }\n format.json { render json: @account_medal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medzz = Medzz.new(params[:medzz])\n\n respond_to do |format|\n if @medzz.save\n format.html { redirect_to @medzz, notice: 'Your Perscription was successfully submitted.' }\n format.json { render json: @medzz, status: :created, location: @medzz }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medzz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @apertura_moneda = AperturaMoneda.new(apertura_moneda_params)\n\n respond_to do |format|\n if @apertura_moneda.save\n format.html { redirect_to @apertura_moneda, notice: 'Apertura moneda was successfully created.' }\n format.json { render :show, status: :created, location: @apertura_moneda }\n else\n format.html { render :new }\n format.json { render json: @apertura_moneda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mantencioncorrectiva = Mantencioncorrectiva.new(mantencioncorrectiva_params)\n\n respond_to do |format|\n if @mantencioncorrectiva.save\n format.html { redirect_to @mantencioncorrectiva, notice: 'Mantencioncorrectiva was successfully created.' }\n format.json { render :show, status: :created, location: @mantencioncorrectiva }\n else\n format.html { render :new }\n format.json { render json: @mantencioncorrectiva.errors, status: :unprocessable_entity }\n end\n end\n end",
"def medida_talla_params\n params.require(:medida_talla).permit(:medida_id, :talla_id, :fichatecnica_id, :centimetros, :tolerancia)\n end",
"def create\n @marca = Marca.new(marca_params)\n if @marca.save\n render json: @marca\n else\n render json: @marca.errors, status: :unprocessable_entity \n end\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def create\n @mantenimiento = Mantenimiento.new(mantenimiento_params)\n\n respond_to do |format|\n if @mantenimiento.save\n format.html { redirect_to @mantenimiento, notice: 'Mantenimiento was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mantenimiento }\n else\n format.html { render action: 'new' }\n format.json { render json: @mantenimiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipoenfermedad = Tipoenfermedad.new(tipoenfermedad_params)\n\n respond_to do |format|\n if @tipoenfermedad.save\n format.html { redirect_to @tipoenfermedad, notice: 'Tipoenfermedad was successfully created.' }\n format.json { render :show, status: :created, location: @tipoenfermedad }\n else\n format.html { render :new }\n format.json { render json: @tipoenfermedad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @med = Med.new(med_params)\n @med.user = current_user\n\n respond_to do |format|\n if @med.save\n format.html { redirect_to meds_path, notice: 'Med was successfully created.' }\n format.json { render :show, status: :created, location: @med }\n else\n format.html { render :new }\n format.json { render json: @med.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n flash[:notice] = 'Medio was successfully created.'\n format.html { redirect_to(@medio) }\n format.xml { render :xml => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @medicion = Medicion.new(params[:medicion])\n\n respond_to do |format|\n if @medicion.save\n format.html { redirect_to(@medicion, :notice => 'Medicion was successfully created.') }\n format.xml { render :xml => @medicion, :status => :created, :location => @medicion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medicion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @medication = Medication.new(medication_params)\n\n respond_to do |format|\n if @medication.save\n format.html { redirect_to @medication, notice: 'Medication was successfully created.' }\n format.json { render :show, status: :created, location: @medication }\n else\n format.html { render :new }\n format.json { render json: @medication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @drama = current_user.dramas.build(drama_params)\n\n respond_to do |format|\n if @drama.save\n format.html { redirect_to @drama, notice: 'Drama was successfully created.' }\n format.json { render :show, status: :created, location: @drama }\n else\n format.html { render :new }\n format.json { render json: @drama.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @unidade_medida = UnidadeMedida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def create\n @medic_patient = MedicPatient.new(medic_patient_params)\n\n respond_to do |format|\n if @medic_patient.save\n format.html { redirect_to @medic_patient, notice: 'Medic patient was successfully created.' }\n format.json { render :show, status: :created, location: @medic_patient }\n else\n format.html { render :new }\n format.json { render json: @medic_patient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mencion = Mencion.new(params[:mencion])\n\n respond_to do |format|\n if @mencion.save\n format.html { redirect_to @mencion, notice: 'Mencion creada' }\n format.json { render json: @mencion, status: :created, location: @mencion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mencion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medrecord = Medrecord.new(params[:medrecord])\n\n respond_to do |format|\n if @medrecord.save\n format.html { redirect_to @medrecord, notice: 'Medrecord was successfully created.' }\n format.json { render json: @medrecord, status: :created, location: @medrecord }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medrecord.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manga = Manga.new(manga_params)\n\n respond_to do |format|\n if @manga.save\n format.html { redirect_to @manga, notice: 'Manga was successfully created.' }\n format.json { render :show, status: :created, location: @manga }\n else\n format.html { render :new }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @madness = Madness.new(madness_params)\n\n respond_to do |format|\n if @madness.save\n format.html { redirect_to @madness, notice: 'Madness was successfully created.' }\n format.json { render action: 'show', status: :created, location: @madness }\n else\n format.html { render action: 'new' }\n format.json { render json: @madness.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @milddew_imm = MilddewImm.new(milddew_imm_params)\n\n respond_to do |format|\n if @milddew_imm.save\n format.html { redirect_to @milddew_imm, notice: 'Milddew imm was successfully created.' }\n format.json { render :show, status: :created, location: @milddew_imm }\n else\n format.html { render :new }\n format.json { render json: @milddew_imm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medidor = Medidor.new(params[:medidor])\n\n respond_to do |format|\n if @medidor.save\n format.html { redirect_to(@medidor, :notice => 'Medidor was successfully created.') }\n format.xml { render :xml => @medidor, :status => :created, :location => @medidor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medidor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @materia = Materia.new(params[:materia])\n\n if @materia.save\n render json: @materia, status: :created, location: @materia\n else\n render json: @materia.errors, status: :unprocessable_entity\n end\n end",
"def create\n @pharma = Pharma.new(pharma_params)\n\n respond_to do |format|\n if @pharma.save\n format.html { redirect_to @pharma, notice: 'Pharma was successfully created.' }\n format.json { render :show, status: :created, location: @pharma }\n else\n format.html { render :new }\n format.json { render json: @pharma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meupedido = Meupedido.new(meupedido_params)\n\n respond_to do |format|\n if @meupedido.save\n format.html { redirect_to @meupedido, notice: 'Meupedido was successfully created.' }\n format.json { render :show, status: :created, location: @meupedido }\n else\n format.html { render :new }\n format.json { render json: @meupedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manteni = Manteni.new(manteni_params)\n\n respond_to do |format|\n if @manteni.save\n format.html { redirect_to @manteni, notice: 'Manteni was successfully created.' }\n format.json { render :show, status: :created, location: @manteni }\n else\n format.html { render :new }\n format.json { render json: @manteni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mannerism = Mannerism.new(mannerism_params)\n\n respond_to do |format|\n if @mannerism.save\n format.html { redirect_to @mannerism, notice: 'Mannerism was successfully created.' }\n format.json { render :show, status: :created, location: @mannerism }\n else\n format.html { render :new }\n format.json { render json: @mannerism.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medal = Medal.new(params[:medal])\n\n respond_to do |format|\n if @medal.save\n format.html { redirect_to(@medal, :notice => 'Medal was successfully created.') }\n format.xml { render :xml => @medal, :status => :created, :location => @medal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @medio_pago = MedioPago.new({ :medio_pago => params[:medio_pago], :odontologo_id => params[:odontologo_id] })\n #@medio_pago = MedioPago.new(params[:medio_pago])\n\n respond_to do |format|\n if @medio_pago.save\n format.html { redirect_to @medio_pago, notice: 'Medio pago was successfully created.' }\n format.json { render json: @medio_pago, status: :created, location: @medio_pago }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medio_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def medicion_params\n params.require(:medicion).permit(:fecha, :peso, :adpv, :adpvna, :ce, :mediciontipo_id)\n end",
"def create\n @mantenciondesviacion = Mantenciondesviacion.new(mantenciondesviacion_params)\n\n respond_to do |format|\n if @mantenciondesviacion.save\n format.html { redirect_to @mantenciondesviacion, notice: 'Mantenciondesviacion was successfully created.' }\n format.json { render :show, status: :created, location: @mantenciondesviacion }\n else\n format.html { render :new }\n format.json { render json: @mantenciondesviacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @saida = Saida.new(saida_params)\n\n respond_to do |format|\n if @saida.save\n format.html { redirect_to @saida, notice: 'Saida was successfully created.' }\n format.json { render :show, status: :created, location: @saida }\n else\n format.html { render :new }\n format.json { render json: @saida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medication = Medication.new(params[:medication])\n @medication.user_id = current_user.id\n @medication.pass = @medication.build_pass(serial_number: SerialNumberGenerator.generate,\n auth_token: AuthTokenGenerator.token)\n\n respond_to do |format|\n if @medication.save!\n format.html { redirect_to medications_path, notice: 'Medication was successfully created.' }\n format.json { render json: @medication, status: :created, location: @medication }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testmonial = Testmonial.new(testmonial_params)\n\n if @testmonial.save\n render json: @testmonial, status: :created\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end",
"def create\n @medicamento = Medicamento.new(params[:medicamento])\n\n respond_to do |format|\n if @medicamento.save\n flash[:notice] = 'Medicamento was successfully created.'\n format.html { redirect_to(@medicamento) }\n format.xml { render :xml => @medicamento, :status => :created, :location => @medicamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medicamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @meditation = Meditation.new(meditation_params)\n\n respond_to do |format|\n if @meditation.save\n format.html { redirect_to @meditation, notice: 'Meditation was successfully created.' }\n format.json { render :show, status: :created, location: @meditation }\n else\n format.html { render :new }\n format.json { render json: @meditation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @daw_matricula_promo = DawMatriculaPromo.new(daw_matricula_promo_params)\n\n respond_to do |format|\n if @daw_matricula_promo.save\n format.html { redirect_to @daw_matricula_promo, notice: 'Daw matricula promo was successfully created.' }\n format.json { render :show, status: :created, location: @daw_matricula_promo }\n else\n format.html { render :new }\n format.json { render json: @daw_matricula_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharmacy = Pharmacy.new(pharmacy_params)\n respond_to do |format|\n if @pharmacy.save\n format.json { render :show, status: :created, location: @pharmacy }\n else\n format.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @registro_medicion = Api::RegistroMedicion.new(registro_medicion_params)\r\n @registro_medicion.microcontrolador = Api::Microcontrolador.find_or_create_by(nivel: params[:nivel], area: params[:area])\r\n #TODO Mande que tipo de variable ambiental es\r\n\r\n @registro_medicion.variable_ambiental = Api::VariableAmbiental.where(tipo: params[:tipo]).first\r\n\r\n if @registro_medicion.save && Api::RegistroMedicionesHelper.verify(@registro_medicion, params[:promedio])\r\n render json: @registro_medicion.to_json, status: :ok\r\n else\r\n render :json => { :mssg => 'Hubo un error creando el registro medicion.' }, status: :unprocessable_entity\r\n end\r\n end",
"def create\n @dias_semanas_vaga = DiasSemanasVaga.new(dias_semanas_vaga_params)\n\n respond_to do |format|\n if @dias_semanas_vaga.save\n format.html { redirect_to @dias_semanas_vaga, notice: 'Dias semanas vaga was successfully created.' }\n format.json { render :show, status: :created, location: @dias_semanas_vaga }\n else\n format.html { render :new }\n format.json { render json: @dias_semanas_vaga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def medicamento_params\n params.require(:medicamento).permit(:nome, :id_uso)\n end",
"def create\n @diliveryman = Diliveryman.new(diliveryman_params)\n\n respond_to do |format|\n if @diliveryman.save\n format.html { redirect_to @diliveryman, notice: 'Diliveryman was successfully created.' }\n format.json { render :show, status: :created, location: @diliveryman }\n else\n format.html { render :new }\n format.json { render json: @diliveryman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thema = Thema.new(thema_params)\n\n respond_to do |format|\n if @thema.save\n format.html { redirect_to @thema, notice: 'Thema was successfully created.' }\n format.json { render action: 'show', status: :created, location: @thema }\n else\n format.html { render action: 'new' }\n format.json { render json: @thema.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @medicamento = Medicamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def create\n @madlib = Madlib.new(madlib_params)\n\n respond_to do |format|\n if @madlib.save\n format.html { redirect_to @madlib, notice: 'Madlib was successfully created.' }\n format.json { render :show, status: :created, location: @madlib }\n else\n format.html { render :new }\n format.json { render json: @madlib.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @metodologia = Metodologia.new(metodologia_params)\n\n respond_to do |format|\n if @metodologia.save\n format.html { redirect_to @metodologia, notice: 'Metodologia was successfully created.' }\n format.json { render action: 'show', status: :created, location: @metodologia }\n else\n format.html { render action: 'new' }\n format.json { render json: @metodologia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @musica = Musica.new(musica_params)\n\n respond_to do |format|\n if @musica.save\n format.html { redirect_to @musica, notice: 'Álbum publicada com sucesso!' }\n format.json { render :show, status: :created, location: @musica }\n else\n format.html { render :new }\n format.json { render json: @musica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @title = \"Medic Created\"\n @medic = Medic.new(params[:medic])\n\n respond_to do |format|\n if @medic.save\n if @medic.admin == true\n format.html { redirect_to @medic, notice: 'Medic Admin was successfully created.' }\n format.json { render json: @medic, status: :created, location: @medic }\n else\n format.html { redirect_to @medic, notice: 'Medic was successfully created.' }\n format.json { render json: @medic, status: :created, location: @medic }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @medic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @maling = Maling.new(maling_params)\n\n respond_to do |format|\n if @maling.save\n format.html { redirect_to @maling, notice: 'Maling was successfully created.' }\n format.json { render :show, status: :created, location: @maling }\n else\n format.html { render :new }\n format.json { render json: @maling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medida }\n end\n end",
"def midia_params\n params.require(:midia).permit(:nome)\n end",
"def create\n @maquinat = Maquinat.new(maquinat_params)\n\n respond_to do |format|\n if @maquinat.save\n format.html { redirect_to @maquinat, notice: 'Maquinat was successfully created.' }\n format.json { render :show, status: :created, location: @maquinat }\n else\n format.html { render :new }\n format.json { render json: @maquinat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @micorpost = Micorpost.new(params[:micorpost])\n\n respond_to do |format|\n if @micorpost.save\n format.html { redirect_to @micorpost, notice: 'Micorpost was successfully created.' }\n format.json { render json: @micorpost, status: :created, location: @micorpost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micorpost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @questao = Questao.new(questao_params)\n\n respond_to do |format|\n if @questao.save\n format.html { redirect_to @questao, notice: 'Questao was successfully created.' }\n format.json { render :show, status: :created, location: @questao }\n else\n format.html { render :new }\n format.json { render json: @questao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @matiawase = Matiawase.new(matiawase_params)\n\n respond_to do |format|\n if @matiawase.save\n format.html { redirect_to @matiawase, notice: 'Matiawase was successfully created.' }\n format.json { render action: 'show', status: :created, location: @matiawase }\n else\n format.html { render action: 'new' }\n format.json { render json: @matiawase.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @novedad_mecanica = @unidad.novedades_mecanicas.build(novedad_mecanica_params)\n\n respond_to do |format|\n if @novedad_mecanica.save\n format.html { redirect_to [@unidad,@novedad_mecanica], notice: 'Novedad mecanica was successfully created.' }\n format.json { render :show, status: :created, location: @novedad_mecanica }\n else\n format.html { render :new }\n format.json { render json: @novedad_mecanica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unidadmedidaingrediente = Unidadmedidaingrediente.new(params[:unidadmedidaingrediente])\n\n respond_to do |format|\n if @unidadmedidaingrediente.save\n flash[:notice] = 'Unidadmedidaingrediente was successfully created.'\n format.html { redirect_to(@unidadmedidaingrediente) }\n format.xml { render :xml => @unidadmedidaingrediente, :status => :created, :location => @unidadmedidaingrediente }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unidadmedidaingrediente.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @midsurvey = Midsurvey.new(midsurvey_params)\n\n respond_to do |format|\n if @midsurvey.save\n format.html { redirect_to final_path, notice: 'Midsurvey was successfully created.' }\n format.json { render :show, status: :created, location: @midsurvey }\n else\n format.html { render :new }\n format.json { render json: @midsurvey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @medio = Medio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @medio }\n end\n end",
"def create\n @medication = Medication.new(medication_params)\n\n if @medication.name.present?\n drug_sections = MedlinePlus.find_drug_by_name(@medication.name)\n # we expect drug to be an array of hashes [{title: \"Title\", body: \"Body\"}, ...]\n \n if drug_sections != nil\n drug_sections.each do |section|\n if section[:title] == \"Why is this medication prescribed?\"\n @medication.description = section[:body]\n elsif section[:title] == \"What side effects can this medication cause?\"\n @medication.side_effects = section[:body]\n end\n end\n end\n end\n \n respond_to do |format|\n if @medication.save\n format.html { redirect_to @medication, notice: 'Medication was successfully created.' }\n format.json { render :show, status: :created, location: @medication }\n else\n format.html { render :new }\n format.json { render json: @medication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medalha\n @medalha = Medalha.find(params[:id])\n end",
"def create\n @wedding = Wedding.new(wedding_params)\n\n respond_to do |format|\n if @wedding.save\n cookies.delete(:uidfu)\n cookies.delete(:arch_nombre)\n cookies.delete(:arch_email)\n cookies.delete(:arch_tel)\n format.html { redirect_to @wedding, notice: 'Se creó el matrimonio satisfactoriamente.' }\n format.json { render :show, status: :created, location: @wedding }\n else\n format.html { render :new }\n format.json { render json: @wedding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dm_especialidade = DmEspecialidade.new(dm_especialidade_params)\n\n respond_to do |format|\n if @dm_especialidade.save\n format.html { redirect_to @dm_especialidade, notice: 'Dm especialidade was successfully created.' }\n format.json { render :show, status: :created, location: @dm_especialidade }\n else\n format.html { render :new }\n format.json { render json: @dm_especialidade.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dharma_talk = DharmaTalk.new(dharma_talk_params)\n\n respond_to do |format|\n if @dharma_talk.save\n format.html { redirect_to @dharma_talk, notice: 'Dharma talk was successfully created.' }\n format.json { render :show, status: :created, location: @dharma_talk }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @dharma_talk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @dilemma = current_user.dilemmas.build(params[:dilemma])\n\n respond_to do |format|\n if @dilemma.save\n \n format.html { redirect_to @dilemma }\n format.json { render json: @dilemma, status: :created, location: @dilemma }\n flash[:success] = 'You have created a dilemma! Check Twitter and RT the link so your followers can see it'\n else\n format.html { render action: \"new\" }\n format.json { render json: @dilemma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @maudio = Maudio.new(maudio_params)\n #extract_metadata\n \n\n respond_to do |format|\n if @maudio.save\n format.html { redirect_to @maudio, notice: 'maudio was successfully created.' }\n format.json { render json: @maudio, status: :created, notice: 'maudio was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @maudio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @remedio = Remedio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @remedio }\n end\n end",
"def tipo_medidor_params\n params.require(:tipo_medidor).permit(:nombre, :codigo, :descripcion)\n end",
"def create\n @mata_matum = MataMatum.new(mata_matum_params)\n\n respond_to do |format|\n if @mata_matum.save\n format.html { redirect_to @mata_matum, notice: 'Mata matum was successfully created.' }\n format.json { render :show, status: :created, location: @mata_matum }\n else\n format.html { render :new }\n format.json { render json: @mata_matum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @marcialart = Marcialart.new(marcialart_params)\n\n respond_to do |format|\n if @marcialart.save\n format.html { redirect_to @marcialart, notice: 'Marcialart was successfully created.' }\n format.json { render :show, status: :created, location: @marcialart }\n else\n format.html { render :new }\n format.json { render json: @marcialart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medication_detail = MedicationDetail.new(medication_detail_params)\n\n respond_to do |format|\n if @medication_detail.save\n format.html { redirect_to @medication_detail, notice: 'Medication detail was successfully created.' }\n format.json { render :show, status: :created, location: @medication_detail }\n else\n format.html { render :new }\n format.json { render json: @medication_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tmedicion = Tmedicion.new(params[:tmedicion])\n\n respond_to do |format|\n if @tmedicion.save\n format.html { redirect_to(@tmedicion, :notice => 'Tmedicion was successfully created.') }\n format.xml { render :xml => @tmedicion, :status => :created, :location => @tmedicion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tmedicion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @medicine_instruction = MedicineInstruction.new(medicine_instruction_params)\n\n respond_to do |format|\n if @medicine_instruction.save\n flash[:notice] = 'Navodilo je bilo uspesno kreirano'\n format.html { redirect_to controller: :admins, action: :sifranti }\n else\n format.html { render :new }\n format.json { render json: @medicine_instruction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @responsavel = Responsavel.new(responsavel_params)\n\n if @responsavel.save\n render json: @responsavel, status: :created, location: @responsavel\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def new\n @relacion_articulo_medida = RelacionArticuloMedida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relacion_articulo_medida }\n end\n end"
] | [
"0.67229056",
"0.66952366",
"0.6500264",
"0.64886737",
"0.6481001",
"0.6388687",
"0.6354134",
"0.63438195",
"0.63438195",
"0.6328977",
"0.63096803",
"0.62992144",
"0.62935644",
"0.6271856",
"0.6208299",
"0.6199227",
"0.616915",
"0.61403954",
"0.61023295",
"0.60560876",
"0.60497475",
"0.6038229",
"0.6016662",
"0.5998815",
"0.5994727",
"0.59838927",
"0.59733903",
"0.59698147",
"0.59692043",
"0.5960644",
"0.5954707",
"0.5952534",
"0.5946594",
"0.59454083",
"0.59407413",
"0.5934763",
"0.59278303",
"0.5923316",
"0.58966756",
"0.5886419",
"0.58521014",
"0.5839583",
"0.5836456",
"0.58253133",
"0.58199465",
"0.5812122",
"0.5811451",
"0.57975006",
"0.57910186",
"0.57836884",
"0.5768375",
"0.57612836",
"0.575476",
"0.57504004",
"0.5750239",
"0.5739326",
"0.57339525",
"0.5732732",
"0.5718463",
"0.5716014",
"0.5702193",
"0.57015675",
"0.5699225",
"0.5697262",
"0.56950915",
"0.5678121",
"0.5675811",
"0.56573254",
"0.56505984",
"0.56492454",
"0.56346905",
"0.5631783",
"0.56153816",
"0.56084055",
"0.56075364",
"0.56063783",
"0.5603955",
"0.5601274",
"0.55954397",
"0.55950385",
"0.5594948",
"0.559384",
"0.55830234",
"0.5579624",
"0.55769074",
"0.55743134",
"0.55735654",
"0.55688345",
"0.5566244",
"0.5565416",
"0.55603963",
"0.55522496",
"0.5551127",
"0.5545688",
"0.5542353",
"0.554025",
"0.5528558",
"0.55276513",
"0.55256325",
"0.55186033"
] | 0.69736016 | 0 |
PUT /medidas/1 PUT /medidas/1.json | def update
@medida = Medida.find(params[:id])
respond_to do |format|
if @medida.update_attributes(params[:medida])
format.html { redirect_to @medida, notice: 'Medida se ha actualizado correctamente.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @medida.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @medida.update(medida_params)\n format.html { redirect_to @medida, notice: 'Unidad medida was successfully updated.' }\n format.json { render :show, status: :ok, location: @medida }\n else\n format.html { render :edit }\n format.json { render json: @medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n if @medio.update_attributes(params[:medio])\n format.html { redirect_to @medio, :notice => 'Medio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @unidade_medida = UnidadeMedida.find(params[:id])\n\n respond_to do |format|\n if @unidade_medida.update_attributes(params[:unidade_medida])\n format.html { redirect_to @unidade_medida, notice: 'Unidade medida foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unidade_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medalha.update(medalha_params)\n format.html { redirect_to @medalha, notice: 'Medalha was successfully updated.' }\n format.json { render :show, status: :ok, location: @medalha }\n else\n format.html { render :edit }\n format.json { render json: @medalha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n if @medida.update_attributes(params[:medida])\n format.html { redirect_to(@medida, :notice => 'Medida was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medida.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medidor.update(medidor_params)\n format.html { redirect_to @medidor, notice: 'Medidor was successfully updated.' }\n format.json { render :show, status: :ok, location: @medidor }\n else\n format.html { render :edit }\n format.json { render json: @medidor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @med.update(med_params)\n format.html { redirect_to meds_path, notice: 'Med was successfully updated.' }\n format.json { render :show, status: :ok, location: @med }\n else\n format.html { render :edit }\n format.json { render json: @med.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medicina.update(medicina_params)\n format.html { redirect_to @medicina, notice: 'Medicina was successfully updated.' }\n format.json { render :show, status: :ok, location: @medicina }\n else\n format.html { render :edit }\n format.json { render json: @medicina.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @med.update(med_params)\n format.html { redirect_to @med, notice: 'Med was successfully updated.' }\n format.json { render :show, status: :ok, location: @med }\n else\n format.html { render :edit }\n format.json { render json: @med.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unidad_medida.update(unidad_medida_params)\n format.html { redirect_to @unidad_medida, notice: 'Unidad medida was successfully updated.' }\n format.json { render :show, status: :ok, location: @unidad_medida }\n else\n format.html { render :edit }\n format.json { render json: @unidad_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @midia.update_attributes(midia_params)\n format.html { redirect_to @midia, notice: 'O tipo de mídia foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @midia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n if @medio.update_attributes(params[:medio])\n flash[:notice] = 'Medio was successfully updated.'\n format.html { redirect_to(@medio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n if @medicamento.update_attributes(params[:medicamento])\n format.html { redirect_to @medicamento, notice: 'Medicamento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medicamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medico.update(medico_params)\n format.html { redirect_to @medico, notice: \"Medico atualizado com SUCESSO.\" }\n format.json { render :show, status: :ok, location: @medico }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @medico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @relacion_articulo_medida = RelacionArticuloMedida.find(params[:id])\n\n respond_to do |format|\n if @relacion_articulo_medida.update_attributes(params[:relacion_articulo_medida])\n format.html { redirect_to @relacion_articulo_medida, notice: 'Relacion articulo medida was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @relacion_articulo_medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_medidor.update(tipo_medidor_params)\n format.html { redirect_to @tipo_medidor, notice: 'Se ha actualizado el Tipo de Medidor.' }\n format.json { render :show, status: :ok, location: @tipo_medidor }\n else\n format.html { render :edit }\n format.json { render json: @tipo_medidor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medalha\n @medalha = Medalha.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @medal.update(medal_params)\n format.html { redirect_to @medal, notice: 'Medal was successfully updated.' }\n format.json { render :show, status: :ok, location: @medal }\n else\n format.html { render :edit }\n format.json { render json: @medal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n if @remedio.update_attributes(params[:remedio])\n format.html { redirect_to @remedio, notice: 'Remedio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @remedio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @materia = Materia.find(params[:id])\n\n if @materia.update(params[:materia])\n head :no_content\n else\n render json: @materia.errors, status: :unprocessable_entity\n end\n end",
"def update\n @medicion = Medicion.find(params[:id])\n\n respond_to do |format|\n if @medicion.update_attributes(params[:medicion])\n format.html { redirect_to(@medicion, :notice => 'Medicion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medicion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @title = \"Details Updated\"\n @medic = Medic.find(params[:id])\n\n respond_to do |format|\n if @medic.update_attributes(params[:medic])\n format.html { redirect_to @medic, notice: \"Dr. #{@medic.proper_name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medicion\n @medicion = Medicion.find(params[:id])\n end",
"def update\n @unidadmedida = Unidadmedida.find(params[:id])\n\n respond_to do |format|\n if @unidadmedida.update_attributes(params[:unidadmedida])\n flash[:notice] = 'Unidadmedida was successfully updated.'\n format.html { redirect_to(@unidadmedida) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unidadmedida.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @medidor = Medidor.find(params[:id])\n\n respond_to do |format|\n if @medidor.update_attributes(params[:medidor])\n format.html { redirect_to(@medidor, :notice => 'Medidor was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medidor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @medio_pago = MedioPago.find(params[:id])\n\n respond_to do |format|\n if @medio_pago.update_attributes(params[:medio_pago])\n format.html { redirect_to @medio_pago, notice: 'Medio pago was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medio_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medicament\n @medicament = Medicament.find(params[:id])\n end",
"def update\n @medzz = Medzz.find(params[:id])\n\n respond_to do |format|\n if @medzz.update_attributes(params[:medzz])\n format.html { redirect_to @medzz, notice: 'Medzz was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medzz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medal = Medal.find(params[:id])\n\n respond_to do |format|\n if @medal.update_attributes(params[:medal])\n format.html { redirect_to(@medal, :notice => 'Medal was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mencion = Mencion.find(params[:id])\n\n respond_to do |format|\n if @mencion.update_attributes(params[:mencion])\n format.html { redirect_to @mencion, notice: 'Mencion actualizada' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mencion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medicoshorario\n @medicoshorario = Mh.find(params[:id])\n end",
"def set_medicina\n @medicina = Medicina.find(params[:id])\n end",
"def update\n @medication = Medication.find(params[:id])\n\n respond_to do |format|\n if @medication.update_attributes(params[:medication])\n format.html { redirect_to medications_path, notice: 'Medication was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manga = Manga.find(params[:id])\n\n respond_to do |format|\n if @manga.update_attributes(params[:manga])\n format.html { redirect_to @manga, notice: 'Manga was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n if @medicamento.update_attributes(params[:medicamento])\n flash[:notice] = 'Medicamento was successfully updated.'\n format.html { redirect_to(@medicamento) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medicamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @receita_medica = ReceitaMedica.find(params[:id])\n\n respond_to do |format|\n if @receita_medica.update_attributes(params[:receita_medica])\n format.html { redirect_to @receita_medica, notice: 'Receita medica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @receita_medica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medico\n @medico = Medico.find(params[:id])\n end",
"def set_medico\n @medico = Medico.find(params[:id])\n end",
"def update\n remedy = Remedy.find(params[:id])\n remedy.update(remedy_params)\n # render json: {remedyupdated: remedy}\n end",
"def update\n respond_to do |format|\n if @medication.update(medication_params)\n format.html { redirect_to @medication, notice: 'Medication was successfully updated.' }\n format.json { render :show, status: :ok, location: @medication }\n else\n format.html { render :edit }\n format.json { render json: @medication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_med\n @med = Med.find(params[:id])\n end",
"def set_med\n @med = Med.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @mdistantmetastasi.update(mdistantmetastasi_params)\n format.html { redirect_to @mdistantmetastasi, notice: 'Mdistantmetastasi was successfully updated.' }\n format.json { render :show, status: :ok, location: @mdistantmetastasi }\n else\n format.html { render :edit }\n format.json { render json: @mdistantmetastasi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @musico.update(musico_params)\n format.html { redirect_to @musico, notice: 'Musico was successfully updated.' }\n format.json { render :show, status: :ok, location: @musico }\n else\n format.html { render :edit }\n format.json { render json: @musico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @madness.update(madness_params)\n format.html { redirect_to @madness, notice: 'Madness was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @madness.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medida_talla.update(medida_talla_params)\n format.html { redirect_to fichatecnica_medida_tallas_path(@fichatecnica), notice: 'Medida talla was successfully updated.' }\n format.json { render :show, status: :ok, location: @medida_talla }\n else\n format.html { render :edit }\n format.json { render json: @medida_talla.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @manga.update(manga_params)\n format.html { redirect_to @manga, notice: 'Manga was successfully updated.' }\n format.json { render :show, status: :ok, location: @manga }\n else\n format.html { render :edit }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @muscle_mass.update(muscle_mass_params)\r\n format.html { redirect_to @muscle_mass, notice: 'Muscle mass was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @muscle_mass.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def show\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medida }\n end\n end",
"def update\n respond_to do |format|\n if @medical.update(medical_params)\n format.html { redirect_to @medical, notice: 'Medical was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @medical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medic_patient.update(medic_patient_params)\n format.html { redirect_to @medic_patient, notice: 'Medic patient was successfully updated.' }\n format.json { render :show, status: :ok, location: @medic_patient }\n else\n format.html { render :edit }\n format.json { render json: @medic_patient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def medida_params\n params.require(:medida).permit(:codigo, :nombre, :descripcion, :user_id)\n end",
"def update\n respond_to do |format|\n if @meditation.update(meditation_params)\n format.html { redirect_to @meditation, notice: 'Meditation was successfully updated.' }\n format.json { render :show, status: :ok, location: @meditation }\n else\n format.html { render :edit }\n format.json { render json: @meditation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medida = Medida.new(params[:medida])\n\n respond_to do |format|\n if @medida.save\n format.html { redirect_to @medida, notice: 'Medida se ha creado con éxito.' }\n format.json { render json: @medida, status: :created, location: @medida }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medida.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mario.update(mario_params)\n format.html { redirect_to @mario, notice: 'Mario was successfully updated.' }\n format.json { render :show, status: :ok, location: @mario }\n else\n format.html { render :edit }\n format.json { render json: @mario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medal\n @medal = Medal.find(params[:id])\n end",
"def set_medal\n @medal = Medal.find(params[:id])\n end",
"def update\n @marmita = Marmita.find(params[:id])\n\n respond_to do |format|\n if @marmita.update_attributes(params[:marmita])\n format.html { redirect_to(@marmita, :notice => 'Marmita was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @marmita.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_medicine\n @medicine = Medicine.find(params[:id])\n end",
"def set_medicine\n @medicine = Medicine.find(params[:id])\n end",
"def set_medicine\n @medicine = Medicine.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @musica.update(musica_params)\n format.html { redirect_to @musica, notice: 'Álbum atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @musica }\n else\n format.html { render :edit }\n format.json { render json: @musica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @currentmedical.update(currentmedical_params)\n format.html { redirect_to @currentmedical, notice: 'Currentmedical was successfully updated.' }\n format.json { render :show, status: :ok, location: @currentmedical }\n else\n format.html { render :edit }\n format.json { render json: @currentmedical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medrecord = Medrecord.find(params[:id])\n\n respond_to do |format|\n if @medrecord.update_attributes(params[:medrecord])\n format.html { redirect_to @medrecord, notice: 'Medrecord was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medrecord.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @momsg = Momsg.find(params[:id])\n\n respond_to do |format|\n if @momsg.update_attributes(params[:momsg])\n format.html { redirect_to @momsg, notice: 'Momsg was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @momsg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_mdistantmetastasi\n @mdistantmetastasi = Mdistantmetastasi.find(params[:id])\n end",
"def set_medication\n @patient = Patient.find(params[:patient_id])\n @medication = Medication.find(params[:id])\n end",
"def update\n \n if (@medication.description.blank? or @medication.side_effects.blank?) and @medication.name.present?\n drug_sections = MedlinePlus.find_drug_by_name(@medication.name)\n # we expect drug to be an array of hashes [{title: \"Title\", body: \"Body\"}, ...]\n \n if drug_sections != nil\n drug_sections.each do |section|\n if section[:title] == \"Why is this medication prescribed?\"\n @medication.description = section[:body]\n elsif section[:title] == \"What side effects can this medication cause?\"\n @medication.side_effects = section[:body]\n end\n end\n end\n end\n\n respond_to do |format|\n if @medication.update(medication_params)\n format.html { redirect_to @medication, notice: 'Medication was successfully updated.' }\n format.json { render :show, status: :ok, location: @medication }\n else\n format.html { render :edit }\n format.json { render json: @medication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_attr\n #sanity checks \n @persona = current_persona\n @mediaset = @persona.mediasets.find(params[:id])\n \n respond_to do |format|\n @mediaset.update_attributes( params[:mediaset] )\n format.json{ respond_with_bip(@mediaset) }\n end\n end",
"def set_medication\n @medication = Medication.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @ahmed.update(ahmed_params)\n format.html { redirect_to @ahmed, notice: 'Ahmed was successfully updated.' }\n format.json { render :show, status: :ok, location: @ahmed }\n else\n format.html { render :edit }\n format.json { render json: @ahmed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medication\n @medication = Medication.find(params[:id])\n end",
"def set_medication\n @medication = Medication.find(params[:id])\n end",
"def update\n @materia = Materia.find(params[:id])\n\n respond_to do |format|\n if @materia.update_attributes(params[:materia])\n format.html { redirect_to @materia, notice: 'Materia was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @materia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_skill = Admin::Skill.find(params[:id])\n\n if @admin_skill.update(admin_skill_params)\n head :no_content\n else\n render json: @admin_skill.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @maudio.update(maudio_params)\n format.html { redirect_to @maudio, notice: 'Maudio was successfully updated.' }\n format.json { render json: @maudio, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @maudio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medicine = Medicine.find(params[:id])\n debugger\n respond_to do |format|\n if (params[:medicine])\n medicine = params[:medicine]\n else\n # debugger\n medicine = {:name => params[:name], :specificDays => params[:specificDays], \n :canceledNotificationDate => params[:canceledNotificationDate], \n :daysOffset => params[:daysOffset],\n :isSpecificDays => params[:isSpecificDays], :secondHour => params[:secondHour],\n :daysOffsetStartDate => params[:daysOffsetStartDate], \n :firstHour => params[:firstHour]}\n end\n if @medicine.update_attributes(medicine)#params[:medicine])\n result = { \"opcode\" => 102, \"response\" => 200, \"medicine\" => @medicine }\n format.html { redirect_to @medicine, notice: 'Medicine was successfully updated.' }\n format.json { render json: result, status: :created, location: result }\n # format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medicine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @musique = Musique.find(params[:id])\n\n respond_to do |format|\n if @musique.update_attributes(params[:musique])\n format.html { redirect_to @musique, notice: 'Musique was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @musique.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @metum = Metum.find(params[:id])\n\n respond_to do |format|\n if @metum.update_attributes(params[:metum])\n format.html { redirect_to @metum, notice: 'Metum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @metum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion = Promotion.find(params[:id])\n\n if @promotion.update(promotion_params)\n head :no_content\n else\n render json: @promotion.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @medication_detail.update(medication_detail_params)\n format.html { redirect_to @medication_detail, notice: 'Medication detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @medication_detail }\n else\n format.html { render :edit }\n format.json { render json: @medication_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mdistantmetastasi_params\n params.require(:mdistantmetastasi).permit(:id, :name)\n end",
"def update\n respond_to do |format|\n if @musing.update(musing_params)\n format.html { redirect_to @musing, notice: 'Musing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @musing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medic_patient\n @medic_patient = MedicPatient.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @mantenimiento.update(mantenimiento_params)\n format.html { redirect_to @mantenimiento, notice: 'Mantenimiento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mantenimiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @vdm = Vdm.find(params[:id])\n\n if @vdm.update(vdm_params)\n head :no_content\n else\n render json: @vdm.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @moon.update(moon_params)\n format.html { redirect_to @moon, notice: 'Moon was successfully updated.' }\n format.json { render :show, status: :ok, location: @moon }\n else\n format.html { render :edit }\n format.json { render json: @moon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mannerism.update(mannerism_params)\n format.html { redirect_to @mannerism, notice: 'Mannerism was successfully updated.' }\n format.json { render :show, status: :ok, location: @mannerism }\n else\n format.html { render :edit }\n format.json { render json: @mannerism.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matome.update(matome_params)\n format.html { redirect_to @matome, notice: 'Matome was successfully updated.' }\n format.json { render :show, status: :ok, location: @matome }\n else\n format.html { render :edit }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matome.update(matome_params)\n format.html { redirect_to @matome, notice: 'Matome was successfully updated.' }\n format.json { render :show, status: :ok, location: @matome }\n else\n format.html { render :edit }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medida_talla\n @fichatecnica = Fichatecnica.find(params[:fichatecnica_id])\n @medida_talla = MedidaTalla.find(params[:id]) if params[:id]\n end",
"def update\n @dilemma = Dilemma.find(params[:id])\n\n respond_to do |format|\n if @dilemma.update_attributes(params[:dilemma])\n format.html { redirect_to @dilemma, notice: \"Ok your dilemma has been updated, let's hope you have it right this time.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dilemma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:patient][:illness_ids] ||= []\n params[:patient][:medicament_ids] ||= []\n @patient = Patient.find(params[:id])\n\n respond_to do |format|\n if @patient.update_attributes(params[:patient])\n flash[:success] = \"Patient was successfully updated.\"\n format.html { redirect_to @patient }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medio_video.update(medio_video_params)\n format.html { redirect_to @medio_video, notice: 'Medio video was successfully updated.' }\n format.json { render :show, status: :ok, location: @medio_video }\n else\n format.html { render :edit }\n format.json { render json: @medio_video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @music =Music.find_by_sql(\"SELECT * FROM Musics M Where M.id = \" + params[:id]).first()\n\n respond_to do |format|\n if @music.update_attributes(params[:music])\n format.html { redirect_to \"/musics\", notice: 'Music was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @music.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_medical\n @medical = Medical.find(params[:id])\n end",
"def update\n @testmonial = Testmonial.find(params[:id])\n\n if @testmonial.update(testmonial_params)\n head :no_content\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end",
"def set_ahmed\n @ahmed = Ahmed.find(params[:id])\n end",
"def update\n @arma = Arma.find(params[:id])\n\n respond_to do |format|\n if @arma.update_attributes(params[:arma])\n format.html { redirect_to @arma, notice: 'Arma was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @arma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @skill = Skill.find(params[:id])\n\n if @skill.update(skill_params)\n head :no_content\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end"
] | [
"0.6921429",
"0.6847556",
"0.67260194",
"0.6720236",
"0.6683383",
"0.6668607",
"0.665465",
"0.6643562",
"0.66112393",
"0.66082436",
"0.65730864",
"0.65675664",
"0.65178573",
"0.6512114",
"0.64614624",
"0.6389441",
"0.6381887",
"0.6380272",
"0.6359773",
"0.6358228",
"0.6305697",
"0.6303817",
"0.62974066",
"0.62848645",
"0.62656015",
"0.6241698",
"0.623422",
"0.6227202",
"0.61966586",
"0.61914563",
"0.618757",
"0.6185607",
"0.61676675",
"0.6165447",
"0.6163538",
"0.6162067",
"0.6148392",
"0.6148392",
"0.6140385",
"0.6131431",
"0.61248064",
"0.61248064",
"0.61160916",
"0.6093217",
"0.60195553",
"0.60093",
"0.60092026",
"0.6000613",
"0.5981581",
"0.5979838",
"0.5974486",
"0.59663725",
"0.59640944",
"0.59609365",
"0.59601086",
"0.5959377",
"0.5949859",
"0.5946325",
"0.5937294",
"0.5937294",
"0.5937294",
"0.5929869",
"0.5921686",
"0.59157306",
"0.591434",
"0.59017515",
"0.5899328",
"0.58944",
"0.5893324",
"0.5891834",
"0.5890703",
"0.588877",
"0.588877",
"0.5876669",
"0.5875399",
"0.587242",
"0.58716077",
"0.5867427",
"0.58604956",
"0.5859331",
"0.5856506",
"0.58546525",
"0.5851446",
"0.5849086",
"0.58318794",
"0.5826026",
"0.58209485",
"0.58189887",
"0.581703",
"0.581703",
"0.5814794",
"0.581315",
"0.58124965",
"0.5812293",
"0.5811528",
"0.5810073",
"0.5809818",
"0.5806403",
"0.5802597",
"0.5801479"
] | 0.7033592 | 0 |
DELETE /medidas/1 DELETE /medidas/1.json | def destroy
@medida = Medida.find(params[:id])
if @medida.destroy
message = "Medida eliminada correctamente"
else
message = "Medida No eliminada, contiene dependencias"
end
respond_to do |format|
format.html { redirect_to medidas_url, :notice => message }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @unidade_medida = UnidadeMedida.find(params[:id])\n @unidade_medida.destroy\n\n respond_to do |format|\n format.html { redirect_to unidade_medidas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medida.destroy\n respond_to do |format|\n format.html { redirect_to medidas_url, notice: 'Unidad medida was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @remedio = Remedio.find(params[:id])\n @remedio.destroy\n\n respond_to do |format|\n format.html { redirect_to remedios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relacion_articulo_medida = RelacionArticuloMedida.find(params[:id])\n @relacion_articulo_medida.destroy\n\n respond_to do |format|\n format.html { redirect_to relaciones_articulos_medida_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad_medida.destroy\n respond_to do |format|\n format.html { redirect_to unidad_medidas_url, notice: 'Unidad medida was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @receita_medica = ReceitaMedica.find(params[:id])\n @receita_medica.destroy\n\n respond_to do |format|\n format.html { redirect_to receita_medicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medalha.destroy\n respond_to do |format|\n format.html { redirect_to medalhas_url, notice: 'Medalha was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medicamento = Medicamento.find(params[:id])\n @medicamento.destroy\n\n respond_to do |format|\n format.html { redirect_to medicamentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @midia.destroy\n\n respond_to do |format|\n format.html { redirect_to midias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medida = Medida.find(params[:id])\n @medida.destroy\n\n respond_to do |format|\n format.html { redirect_to(medidas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @unidadmedida = Unidadmedida.find(params[:id])\n @unidadmedida.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidadmedidas_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @medico.destroy\n respond_to do |format|\n format.html { redirect_to medicos_url, notice: \"Medico deletado com SUCESSO.\" }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @medio = Medio.find(params[:id])\n @medio.destroy\n\n respond_to do |format|\n format.html { redirect_to medios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_medidor.destroy\n respond_to do |format|\n format.html { redirect_to tipo_medidors_url, notice: 'Se ha eliminado el Tipo de Medidor.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medicina.destroy\n respond_to do |format|\n format.html { redirect_to medicinas_url, notice: 'Medicina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medida_talla.destroy\n respond_to do |format|\n format.html { redirect_to fichatecnica_medida_tallas_url(@fichatecnica), notice: 'Medida talla was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manga = Manga.find(params[:id])\n @manga.destroy\n\n respond_to do |format|\n format.html { redirect_to mangas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @medio_pago = MedioPago.find(params[:id])\n @medio_pago.destroy\n\n respond_to do |format|\n format.html { redirect_to medio_pagos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades3 = Humanidades3.find(params[:id])\n @humanidades3.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades3s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mantenimiento.destroy\n respond_to do |format|\n format.html { redirect_to mantenimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dynamique = Dynamique.find(params[:id])\n @dynamique.destroy\n\n respond_to do |format|\n format.html { redirect_to dynamiques_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medidor.destroy\n respond_to do |format|\n format.html { redirect_to medidores_url, notice: 'Medidor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n medication = Medication.find(params[:id])\n medication.delete\n render json: {medicationID: medication.id}\n end",
"def destroy\n @mensagem = Mensagem.find(params[:id])\n api_client.delete_object(@mensagem.post_id)\n @mensagem.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.js { head :ok }\n end\n end",
"def destroy\n @medzz = Medzz.find(params[:id])\n @medzz.destroy\n\n respond_to do |format|\n format.html { redirect_to medzzs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medio = Medio.find(params[:id])\n @medio.destroy\n\n respond_to do |format|\n format.html { redirect_to(medios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @medicion = Medicion.find(params[:id])\n @medicion.destroy\n\n respond_to do |format|\n format.html { redirect_to(medicions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @med.destroy\n respond_to do |format|\n format.html { redirect_to meds_url, notice: 'Med was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medicos_autorizado = current_user.medicos_autorizados.find(params[:id])\n @medicos_autorizado.destroy\n\n respond_to do |format|\n format.html { redirect_to current_user }\n format.json { head :no_content }\n end\n end",
"def destroy\n @med.destroy\n respond_to do |format|\n format.html { redirect_to meds_url, notice: 'Med was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mdistantmetastasi.destroy\n respond_to do |format|\n format.html { redirect_to mdistantmetastasis_url, notice: 'Mdistantmetastasi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @muscle_mass.destroy\r\n respond_to do |format|\r\n format.html { redirect_to muscle_masses_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @medicamento = Medicamento.find(params[:id])\n @medicamento.destroy\n\n respond_to do |format|\n format.html { redirect_to(medicamentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @medical.destroy\n respond_to do |format|\n format.html { redirect_to vigs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @requerimiento = Requerimiento.find(params[:id])\n @requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to requerimientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @humanidades2 = Humanidades2.find(params[:id])\n @humanidades2.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades2s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @farmacium.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end",
"def destroy\n @retroalimentacion = Retroalimentacion.find(params[:id])\n @retroalimentacion.destroy\n\n respond_to do |format|\n format.html { redirect_to retroalimentacions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end",
"def destroy\n @milddew_imm.destroy\n respond_to do |format|\n format.html { redirect_to milddew_imms_url, notice: 'Milddew imm was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jamaat = Jamaat.find(params[:id])\n @jamaat.destroy\n\n respond_to do |format|\n format.html { redirect_to jamaats_url }\n format.json { head :ok }\n end\n end",
"def destroy\n \t @motivobaja = MotivoBaja.find(params[:id])\n @motivobaja.destroy\n respond_with(@motivobaja)\n end",
"def destroy\n @metodo = Metodo.find(params[:id])\n @metodo.destroy\n\n respond_to do |format|\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @musica.audios.purge\n @musica.destroy\n respond_to do |format|\n format.html { redirect_to musicas_url, notice: 'Álbum apagado com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diemtrentuyen = Diemtrentuyen.find(params[:id])\n @diemtrentuyen.destroy\n\n respond_to do |format|\n format.html { redirect_to diemtrentuyens_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mata_matum.destroy\n respond_to do |format|\n format.html { redirect_to mata_mata_url, notice: 'Mata matum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @detalle = Detalle.find(params[:id])\n @detalle.destroy\n\n respond_to do |format|\n format.html { redirect_to detalles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @musique = Musique.find(params[:id])\n @musique.destroy\n\n respond_to do |format|\n format.html { redirect_to musiques_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dm_especialidade.destroy\n respond_to do |format|\n format.html { redirect_to dm_especialidades_url, notice: 'Dm especialidade was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @muscle_diary.destroy\n respond_to do |format|\n format.html { redirect_to muscle_diaries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tmedicion = Tmedicion.find(params[:id])\n @tmedicion.destroy\n\n respond_to do |format|\n format.html { redirect_to(tmedicions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @malarium.destroy\n respond_to do |format|\n format.html { redirect_to malaria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medal.destroy\n respond_to do |format|\n format.html { redirect_to medals_url, notice: 'Medal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medication = Medication.find(params[:id])\n @medication.destroy\n\n respond_to do |format|\n format.html { redirect_to medications_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidadmedidaingrediente = Unidadmedidaingrediente.find(params[:id])\n @unidadmedidaingrediente.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidadmedidaingredientes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apertura_moneda.destroy\n respond_to do |format|\n format.html { redirect_to apertura_monedas_url, notice: 'Apertura moneda was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @publicidad = Publicidad.find(params[:id])\n @publicidad.destroy\n\n respond_to do |format|\n format.html { redirect_to publicidads_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @medicine.destroy\n respond_to do |format|\n format.html { redirect_to medicines_url, notice: 'Medicine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medicine.destroy\n respond_to do |format|\n format.html { redirect_to medicines_url, notice: 'Medicine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n @moresmallarmorinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmallarmorinfos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmacy.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n @momsg = Momsg.find(params[:id])\n @momsg.destroy\n\n respond_to do |format|\n format.html { redirect_to momsgs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @mutacao = Mutacao.find(params[:id])\n @mutacao.destroy\n\n respond_to do |format|\n format.html { redirect_to mutacaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmalltrial = Moresmalltrial.find(params[:id])\n @moresmalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @materia = Materia.find(params[:id])\n @materia.destroy\n\n respond_to do |format|\n format.html { redirect_to materia_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to ministerios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n padre=@familia.padre_id\n @familia.destroy\n respond_to do |format|\n format.html { redirect_to familias_url(:id => padre) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mapeamento = Mapeamento.find(params[:id])\n @mapeamento.destroy\n\n respond_to do |format|\n format.html { redirect_to mapeamentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @makrana_marble.destroy\n respond_to do |format|\n format.html { redirect_to makrana_marbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @duda.destroy\n respond_to do |format|\n format.html { redirect_to dudas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @metum = Metum.find(params[:id])\n @metum.destroy\n\n respond_to do |format|\n format.html { redirect_to meta_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @m1.destroy\n respond_to do |format|\n format.html { redirect_to m1s_url, notice: 'M1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ramal = Ramal.find(params[:id])\n @ramal.destroy\n\n respond_to do |format|\n format.html { redirect_to ramais_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @mesasredonda\n @mesasredonda = Mesasredonda.find(params[:id])\n @mesasredonda.destroy\n\n respond_to do |format|\n format.html { redirect_to mesasredondas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n @imobiliaria.destroy\r\n\r\n respond_to do |format|\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exmedico.destroy\n respond_to do |format|\n format.html { redirect_to exmedicos_url, notice: 'Exmedico was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @detalhe.destroy\n respond_to do |format|\n format.html { redirect_to detalhes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @demot = Demot.find(params[:id])\n @demot.destroy\n\n respond_to do |format|\n format.html { redirect_to demots_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material_didatico.destroy\n respond_to do |format|\n format.html { redirect_to material_didaticos_url, notice: 'Material didatico was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @especialidad.destroy\n respond_to do |format|\n format.html { redirect_to especialidads_url, notice: 'Servicio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medic_patient.destroy\n respond_to do |format|\n format.html { redirect_to medic_patients_url, notice: 'Medic patient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @materia = Materia.find(params[:id])\n @materia.destroy\n\n respond_to do |format|\n format.html { redirect_to materie_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.75034916",
"0.739012",
"0.73766834",
"0.7351802",
"0.7329697",
"0.7324184",
"0.73103684",
"0.73030835",
"0.72956884",
"0.72857183",
"0.72289306",
"0.721111",
"0.7198863",
"0.7190818",
"0.71822226",
"0.7154424",
"0.71383643",
"0.7127287",
"0.71202946",
"0.7090932",
"0.7088511",
"0.7085874",
"0.70824754",
"0.70807606",
"0.7078098",
"0.70677155",
"0.7065089",
"0.7041122",
"0.70306534",
"0.70137894",
"0.7011144",
"0.70045346",
"0.7001553",
"0.7001542",
"0.7000957",
"0.6998147",
"0.69947165",
"0.6972517",
"0.69582576",
"0.69568354",
"0.6955518",
"0.6947957",
"0.6942806",
"0.6940116",
"0.6930628",
"0.69163007",
"0.69142044",
"0.6912149",
"0.690943",
"0.69086474",
"0.6903801",
"0.6897476",
"0.6895981",
"0.6895674",
"0.6893179",
"0.689207",
"0.6885128",
"0.6884614",
"0.68831664",
"0.688314",
"0.6878251",
"0.68767685",
"0.687613",
"0.6872007",
"0.6872007",
"0.68713844",
"0.6865472",
"0.68647003",
"0.68641657",
"0.68628716",
"0.6859547",
"0.6859547",
"0.6857122",
"0.6855834",
"0.6852706",
"0.68526804",
"0.6852376",
"0.6851125",
"0.6847861",
"0.6838627",
"0.68383765",
"0.683328",
"0.68327165",
"0.6830595",
"0.68230665",
"0.6822736",
"0.68222",
"0.6817223",
"0.68078315",
"0.6806062",
"0.6805832",
"0.6804936",
"0.6792028",
"0.67911774",
"0.6790391",
"0.6785296",
"0.6784273",
"0.6783549",
"0.6780061",
"0.67789066"
] | 0.71317786 | 17 |
Use callbacks to share common setup or constraints between actions. | def set_mood
@mood = Mood.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def call\n setup_context\n super\n end"
] | [
"0.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
"0.5312988",
"0.529798",
"0.52968603",
"0.52962637",
"0.52577317",
"0.5244704",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5233461",
"0.52322435",
"0.5227552",
"0.52224743",
"0.5217851",
"0.521241",
"0.52069896",
"0.5206555",
"0.5176617",
"0.51738507",
"0.51725876",
"0.51660734",
"0.51605034",
"0.51571786",
"0.5152762",
"0.5152164",
"0.5151477",
"0.5145819",
"0.51408994",
"0.5134412",
"0.5114031",
"0.5113695",
"0.5113695",
"0.5108603",
"0.5107358",
"0.5090405",
"0.50889385",
"0.50817686",
"0.5081617",
"0.50658226",
"0.50551206",
"0.5051746",
"0.5049091",
"0.5049091",
"0.5034681",
"0.5024972",
"0.5021291",
"0.5016024",
"0.50134826",
"0.50008893",
"0.50000244",
"0.4999155",
"0.49907947",
"0.49907947",
"0.49853387",
"0.49796683",
"0.4979596",
"0.49778128",
"0.49673793",
"0.49662578",
"0.49587822",
"0.4956063",
"0.49550167",
"0.49523485",
"0.4951614",
"0.49452996",
"0.49442068",
"0.49336892",
"0.49306205",
"0.49264124",
"0.49259305",
"0.4925823",
"0.49229056",
"0.4918999",
"0.49171805",
"0.49167436",
"0.4916559",
"0.49153692",
"0.49148256"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def mood_params
params.require(:mood).permit(:status, :time, :reason, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] | 0.0 | -1 |
Retrieve keys from file/stdin | def get_keys_from_commandline(filename=nil)
ARGV << filename unless filename.nil?
return_keys = []
ARGF.each do |line|
return_keys << line.chomp!
end
ARGV << '-' # close ARGF
return_keys.each { |key| verify_key(key) }
return_keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_keys_file(path)\n return [] unless File.exists?(path)\n File.readlines(path).map! { |l| l.chomp.strip }\n end",
"def read_key_file_for_add(file)\n if file.nil?\n if $stdin.tty?\n info \"Paste a public key, then hit <ctrl+d> twice.\"\n key = Dotgpg::Key.read($stdin)\n else\n key = Dotgpg::Key.read($stdin)\n $stdin.reopen \"/dev/tty\"\n end\n elsif File.readable?(file)\n key = Dotgpg::Key.read(File.read(file))\n end\n end",
"def load_keys(path)\n file_lines = read_keys_file(path)\n\n keys = []\n file_lines.map do |l|\n components = LoginPolicy.parse_public_key(l)\n\n if components\n #preserve algorithm, key and comments; discard options (the 0th element)\n keys << [ components[1], components[2], components[3] ]\n elsif l =~ COMMENT\n next \n else\n RightScale::Log.error(\"Malformed (or not SSH2) entry in authorized_keys file: #{l}\")\n next\n end\n end\n\n keys\n end",
"def ssh_key_triple_for(key)\n begin\n file = File.open key\n rescue Errno::ENOENT => e\n raise ::RHC::KeyFileNotExistentException.new(\"File '#{key}' does not exist.\")\n rescue Errno::EACCES => e\n raise ::RHC::KeyFileAccessDeniedException.new(\"Access denied to '#{key}'.\")\n end\n file.gets.chomp.split\n end",
"def read_key; end",
"def get_hash_from_stdin\n STDOUT.sync = true\n hash_to_send = {}\n puts \"No data supplied, what do you want to send? (Leave key blank to end)\"\n incr = 1\n\n loop do\n print \"Key ##{incr}: \"\n key = STDIN.gets.chomp\n\n if key == \"\"\n break\n end\n\n print \"Value ##{incr}: \"\n value = STDIN.gets.chomp\n\n hash_to_send[key] = value\n incr += 1\n end\n hash_to_send\n end",
"def keys\n return @keys if @keys\n keys = py \"keys.py\"\n keys = parse_keys keys\n @keys = keys\n end",
"def input \n\t@plaintext = File.read(ARGV[0]).split(//)\n\t@key = ARGV[1].to_i\n\t@file_out = ARGV[2]\nend",
"def retrieve_key_string_from_stream(stream)\n return stream.read if stream.respond_to?(:read)\n return File.read(stream) if stream.to_s !~ /^-+BEGIN .* KEY-+$/\n stream\n end",
"def read_keys(opts={})\n if !defined?(@@keys) || !@@keys || key_file_changed?\n\n if ! File.exists?(key_file_path)\n @@keys = {}\n return\n end\n\n key_file = File.new(key_file_path, 'r')\n \n @@keys = YAML::load(key_file.read)\n\n @@keys = {} unless @@keys\n\n key_file.close\n end\n end",
"def keys\n JSON.parse get('/users/ssh_keys', :accept => 'json').to_s\n end",
"def keys\n map { |line| line.key }\n end",
"def get_root_keys_from_file(file)\n @logger.debug(\"Getting Root Keys fromt %s\" % file)\n keys = []\n y = YAML.load_file(file)\n y.each{ |k,v| keys << k }\n return keys\n end",
"def generate_keys()\n bobhi = read_key(\"key_bobhi345.txt\")\n floatlift = read_key(\"key_FloatLift.txt\")\n sirbob = read_key(\"key_sirbob3.txt\")\n api = read_key(\"key_JustForTheApiLul.txt\")\n return [bobhi, floatlift, sirbob, api]\nend",
"def source\n puts '------------------------------------------------'.colorize(:light_blue)\n puts 'Input keys? [y/n]'.colorize(:light_blue)\n puts '------------------------------------------------'.colorize(:light_blue)\n $stdin.gets.chomp == 'y' ? source_keys : all_keys\n end",
"def scan_file(path)\n keys = []\n File.open(path, 'rb') do |f|\n f.read.scan(pattern) do |match|\n key = extract_key_from_match(match, path)\n keys << key if valid_key?(key)\n end\n end\n keys\n end",
"def initialize_input_hash(filename)\n input = {}\n File.open(filename, 'r') do |file|\n while line = file.gets\n input[line.to_i] = true\n end\n end\n input\nend",
"def get_keys\n @encryption_io.get_keys\n end",
"def keys_for(host, options = {})\n keys = []\n return keys unless File.readable?(source)\n\n entries = host.split(/,/)\n host_name = entries[0]\n host_ip = entries[1]\n\n File.open(source) do |file|\n file.each_line do |line|\n if line.start_with?('@')\n marker, hosts, type, key_content, comment = line.split(' ')\n else\n marker = nil\n hosts, type, key_content, comment = line.split(' ')\n end\n\n # Skip empty line or one that is commented\n next if hosts.nil? || hosts.start_with?('#')\n\n hostlist = hosts.split(',')\n\n next unless SUPPORTED_TYPE.include?(type)\n\n found = hostlist.any? { |pattern| match(host_name, pattern) } || known_host_hash?(hostlist, entries)\n next unless found\n\n found = hostlist.include?(host_ip) if options[:check_host_ip] && entries.size > 1 && hostlist.size > 1\n next unless found\n\n blob = key_content.unpack(\"m*\").first\n raw_key = Net::SSH::Buffer.new(blob).read_key\n\n keys <<\n if marker == \"@cert-authority\"\n HostKeyEntries::CertAuthority.new(raw_key, comment: comment)\n else\n HostKeyEntries::PubKey.new(raw_key, comment: comment)\n end\n end\n end\n\n keys\n end",
"def getKey\n begin\n # save previous state of stty\n old_state = `stty -g`\n # disable echoing and enable raw (not having to press enter)\n system \"stty raw -echo\"\n# key = STDIN.getc.chr\n key = STDIN.getbyte\n # gather next two characters of special keys\n if(key == \"\\e\")\n extra_thread = Thread.new{\n# key << STDIN.getc.chr\n# key << STDIN.getc.chr\n key << STDIN.getbyte\n key << STDIN.getbyte\n }\n # wait just long enough for special keys to get swallowed\n extra_thread.join(0.00010)\n # kill thread so not-so-long special keys don't wait on getc\n extra_thread.kill\n end\n# rescue => ex\n# puts \"#{ex.class}: #{ex.message}\"\n# puts ex.backtrace\n ensure\n # restore previous state of stty\n system \"stty #{old_state}\"\n end\n return key\nend",
"def get_key_list\n read(Common::KEY) || Hash.new\n end",
"def keys\n doc = JSON.parse get('/api/v1/ssh_keys')\n doc[\"ssh_keys\"]\n end",
"def underbang_reader(key); end",
"def get_key_from(field)\n return [] if Chef::Config[:solo] && !chef_solo_search_installed?\n return [] unless Chef::DataBag.list.key?('users')\n search('users', \"#{field}:*\").map do |v| # ~FC003 ignore footcritic violation\n Chef::Log.info \"ssh_server: installing ssh-keys for root access of user #{v['id']}\"\n v[field]\n end.flatten\nend",
"def keys() end",
"def take_input\n pp File.open('input.txt').read.split\n end",
"def key_files; end",
"def get_trusted_keys\n return [] unless File.file?(@trust_path)\n\n # no signature verification\n File.open(@trust_path, 'r').readlines.map(&:chomp).uniq.sort\nend",
"def gets(keys)\n get(keys, true)\n end",
"def keys\n\t\tdoc = xml get('/user/keys')\n\t\tdoc.elements.to_a('//keys/key').map do |key|\n\t\t\tkey.elements['contents'].text\n\t\tend\n\tend",
"def keys\n\t\tdoc = xml get('/user/keys')\n\t\tdoc.elements.to_a('//keys/key').map do |key|\n\t\t\tkey.elements['contents'].text\n\t\tend\n\tend",
"def scan_file(path)\n keys = []\n text = read_file(path)\n text.scan(@pattern) do |match|\n src_pos = Regexp.last_match.offset(0).first\n location = occurrence_from_position(path, text, src_pos, raw_key: strip_literal(match[0]))\n next if exclude_line?(location.line, path)\n\n key = match_to_key(match, path, location)\n next unless key\n\n key += ':' if key.end_with?('.')\n next unless valid_key?(key)\n\n keys << [key, location]\n end\n keys\n rescue Exception => e # rubocop:disable Lint/RescueException\n raise ::I18n::Tasks::CommandError.new(e, \"Error scanning #{path}: #{e.message}\")\n end",
"def keys(options={})\n get(\"/user/keys\", options, 3)\n end",
"def readlines\n return nil unless __advance!\n\n lines = []\n while line = gets()\n lines << line\n end\n\n lines\n end",
"def keys\n head.commit.tree.contents.map{|blob| deserialize(blob.name) }\n end",
"def keys\n head.commit.tree.contents.map{|blob| deserialize(blob.name) }\n end",
"def ssh_key_triple_for(key)\n begin\n IO.read(key).chomp.split\n rescue Errno::ENOENT => e\n raise ::RHC::KeyFileNotExistentException.new(\"File '#{key}' does not exist.\")\n rescue Errno::EACCES => e\n raise ::RHC::KeyFileAccessDeniedException.new(\"Access denied to '#{key}'.\")\n end\n end",
"def read(_ = nil)\n as_hash(read_lines)[base_name]\n end",
"def get_key(line)\n line.match(/-k ([^ ]+)/)[1]\n end",
"def list_keys()\n # TODO\n end",
"def read_key(key)\n if File.exist?(key.to_s) && File.file?(key.to_s)\n File.read(File.absolute_path(key))\n else\n key\n end\n end",
"def keys(pattern = \"*\")\n send_command([:keys, pattern]) do |reply|\n if reply.is_a?(String)\n reply.split(\" \")\n else\n reply\n end\n end\n end",
"def key_contents(path, options = {})\n # Check if key exists first. Otherwise we could return some\n # weird strings. Also, raise error if user is trying to get a\n # private key.\n key_content_type = key_metadata(path, options).rundeck_content_type\n if key_content_type == content_type('private')\n fail Error::Unauthorized,\n 'You are not allowed to retrieve the contents of a private key'\n end\n\n options.merge!(format: :plain,\n headers: { 'Accept' => 'application/pgp-keys' })\n key = get(\"#{STORAGE_KEYS_PATH}/#{path}\", options)\n objectify 'public_key' => key\n end",
"def read_in\n File.foreach(file_name).map(&:chomp)\n end",
"def extract_fingerprints_from_cmd(cmd)\n so = Mixlib::ShellOut.new(cmd, env: { 'LANG' => 'en_US' })\n so.run_command\n so.stdout.split(/\\n/).map do |t|\n if z = t.match(/^ +Key fingerprint = ([0-9A-F ]+)/)\n z[1].split.join\n end\n end.compact\nend",
"def load_keys(path)\n keys = Hash.new {|k,v| k[v] = []}\n\n list_keys(path).each do |key|\n new_key = SSHKey.from_file(File.join(path, key))\n owner = new_key.owner\n\n keys[owner] << new_key\n end\n\n keys\n end",
"def input\n STDIN.read.split(\"\\n\")\nend",
"def keys\n deprecate # 07/31/2012\n doc = xml get('/user/keys').to_s\n doc.elements.to_a('//keys/key').map do |key|\n key.elements['contents'].text\n end\n end",
"def _ssh_keys\n Chef::Log.info \"Getting keys for user #{ username } from https://github.com/#{ github_username }.keys.\"\n keys = Array(ssh_keys)\n if github_username\n @github_keys = begin\n Chef::HTTP.new('https://github.com').get(\"#{ github_username }.keys\")\n # Use a really big hammer, github being down shouldn't break things.\n # The downside is that if github is down, it will yank your key, possibly\n # leaving login unavailable. Not sure what to do about this right now.\n rescue\n Chef::Log.fatal \"There was an issue getting keys for user #{ username } from https://github.com/#{ github_username }.keys.\"\n end\n Chef::Log.debug \"Got from request: #{@github_keys}\"\n keys += @github_keys.split(\"\\n\")\n end\n Chef::Log.debug \"found some keys! #{keys}\"\n keys\n end",
"def read(key)\n if ::File.file?(full_key(key))\n ::File.read(full_key(key))\n elsif ::File.directory?(full_key(key))\n Dir.entries('.')[2..-1] #don't return the . and .. directories\n end\n end",
"def keys\n end",
"def groups\n @groups ||= STDIN.read.split(\"\\n\\n\").map { |e| e.split.map { |f| f.chars } }\nend",
"def read_stdin\n open_connection\n $stdin.each_line { |l| call_write(process_line(l.strip), false) }\n close_connection\n rescue SystemExit, Interrupt\n puts 'ctrl-c. Exiting.'\n wf.close\n exit 0\n end",
"def keyload(key_file_path=\"rsa_private_key.rb\")\n #require key_file_path\n require_relative key_file_path\n @n, @e= publickey\n @privatekey=privatekey\n #puts $n, $e, $privatekey\n end",
"def run_keys\n %i[verbose pty only_output_on_error in out err]\n end",
"def read_from_cmdline\n require \"shellwords\"\n\n string = unless ARGV.empty?\n ARGV.join(' ')\n else\n if STDIN.tty?\n STDERR.print(\n %|(offline mode: enter name=value pairs on standard input)\\n|\n )\n end\n array = readlines rescue nil\n if not array.nil?\n array.join(' ').gsub(/\\n/n, '')\n else\n \"\"\n end\n end.gsub(/\\\\=/n, '%3D').gsub(/\\\\&/n, '%26')\n\n words = Shellwords.shellwords(string)\n\n if words.find{|x| /=/n.match(x) }\n words.join('&')\n else\n words.join('+')\n end\n end",
"def passwords\n @passwords ||= STDIN.read.split(\"\\n\").map do |password|\n a, b, c = password.split\n {\n position_1: a.split(\"-\").first.to_i,\n position_2: a.split(\"-\").last.to_i,\n letter: b.chars.first,\n password: c\n }\n end\nend",
"def list\n @keychain.keys\n end",
"def get_api_key()\n api_key = nil\n File.open(\"api_key.txt\").each do |line|\n api_key = line\n return api_key\n end\nend",
"def keys\n list = []\n each_key{|key| list << key}\n list\n end",
"def stdin; @current[1]; end",
"def stdin; @current[1]; end",
"def gets(*args)\n Kernel.gets(*args)\n end",
"def keys(glob = \"*\", &block)\n execute(\"keys\", [glob], &block)\n end",
"def keys\n end",
"def keys\n end",
"def keys\n end",
"def find_source_keys\n @source_keys ||= begin\n if (grep_out = run_grep)\n grep_out.split(\"\\n\").map { |r|\n key = r.match(/['\"](.*?)['\"]/)[1]\n if key.start_with? '.'\n absolutize_key key, r.split(':')[0]\n else\n key\n end\n }.uniq.reject { |k| k !~ /^[\\w.\\#{}]+$/ }\n else\n []\n end\n end\n end",
"def keys(arg = nil)\n if arg.nil?\n storage.keys\n else\n with_interest(arg).map { |key, _, _| key }\n end\n end",
"def read(key)\n perform_read(:read, key)\n end",
"def answer_keys\n [key]\n end",
"def input\n option[:ifile] == '-' ? $stdin.read.force_encoding('ascii-8bit') : File.binread(option[:ifile])\n end",
"def grab_keys(hsh)\n keys = []\n hsh.each_pair do |key,value|\n keys << key\n end\n keys\nend",
"def stdin_to_entries\n Atom::Feed.parse($stdin).entries\n end",
"def key_inputs; end",
"def read_auth_key\n f = nil\n begin\n f = File.open(@auth_key_name) \n rescue Errno::ENOENT\n return nil\n else\n return f.read\n ensure\n f.close unless f.nil? \n end\n end",
"def read_entry(key, options)\n @hash[key]\n end",
"def custom_reader(key); end",
"def get_ssh_auth_keys(host)\n return on(host, 'cat ~/.ssh/authorized_keys').stdout\nend",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def key_splitter(lines)\n lines[0].split(\"\\t\")\n end",
"def readline\n @handle.gets\n end",
"def gets\n return $stdin.gets\n end",
"def raw_key\n key = read['pem']\n raise \"There is no key for some reason for user @#{@login}\" if key.nil?\n key\n end",
"def as_string(key)\n with_input_io(key) do |io|\n io.read\n end\n end",
"def keyscan_dump\n\t\trequest = Packet.create_request('stdapi_ui_get_keys')\n\t\tresponse = client.send_request(request)\n\t\treturn response.get_tlv_value(TLV_TYPE_KEYS_DUMP);\n\tend",
"def instructions\n STDIN.read.split(\"\\n\")\nend",
"def stdin; @current[0]; end",
"def extract_commands_from_input_file(args)\n\t\tcommands = []\n\t\tFile.open(args[0], \"r\").each do | line |\n\t\t\tcommands << extract_command_from_line(line)\n\t\tend\n\t\tcommands\n\tend",
"def keys\n @key\n end",
"def key_set()\n return @outputs.keys()\n end",
"def read_input\n ary = []\n File.open('./input.txt', 'r') do |file|\n file.each do |line|\n ary << line.to_s\n end\n end\n\n ary.freeze\nend"
] | [
"0.7070969",
"0.6890355",
"0.64317423",
"0.6419398",
"0.6386319",
"0.63223076",
"0.62945116",
"0.6243742",
"0.61785877",
"0.6175719",
"0.6165203",
"0.61060333",
"0.6092908",
"0.6077547",
"0.60535413",
"0.5995376",
"0.5968735",
"0.5958796",
"0.5922167",
"0.58999497",
"0.5874305",
"0.58735174",
"0.5870172",
"0.58042675",
"0.57917637",
"0.577477",
"0.57376194",
"0.57337457",
"0.57029366",
"0.5679812",
"0.5679812",
"0.5677187",
"0.5655324",
"0.56231296",
"0.56206924",
"0.56206924",
"0.5617011",
"0.56123435",
"0.5553945",
"0.5534372",
"0.5512971",
"0.55028903",
"0.5502307",
"0.5495308",
"0.5492755",
"0.5488897",
"0.5487849",
"0.5484704",
"0.5477709",
"0.5463717",
"0.5461655",
"0.54570204",
"0.5456092",
"0.5455018",
"0.5450428",
"0.5444628",
"0.5438121",
"0.5438012",
"0.5418545",
"0.54142815",
"0.54107225",
"0.54107225",
"0.5403427",
"0.5400641",
"0.539799",
"0.539799",
"0.539799",
"0.539053",
"0.536931",
"0.53688604",
"0.53684384",
"0.5364418",
"0.5352176",
"0.5352064",
"0.5349941",
"0.5345817",
"0.5331916",
"0.53187305",
"0.5318276",
"0.5317768",
"0.5317768",
"0.5317768",
"0.5317768",
"0.5317768",
"0.5317768",
"0.5317768",
"0.5317768",
"0.5317768",
"0.53161263",
"0.5307137",
"0.53056973",
"0.5291389",
"0.5288914",
"0.52833635",
"0.52815545",
"0.5279001",
"0.52710927",
"0.52528083",
"0.52463794",
"0.5238637"
] | 0.7374161 | 0 |
if user is logged in, return current_user, else return guest_user | def current_or_guest_user
if current_user
if session[:guest_user_id] && session[:guest_user_id] != current_user.id
logging_in
session[:guest_user_id] = nil
end
current_user
else
guest_user
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_or_guest_user\n if current_user\n transfer_session_to_logged_in_user if session[:guest_user_id].present?\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if user_signed_in? then current_user else guest_user end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user_log_out\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n current_user ? current_user : guest_user\n end",
"def current_or_guest_user\n current_user || guest_user\n end",
"def current_or_guest_user\n current_user || guest_user\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n #guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user!\n if current_user\n if cookies[:uuid]\n\n # Called when a guest user is converted to current user\n promote_guest_to_user(current_user)\n\n # destroy the guest user and the session\n destroy_guest_user\n end\n current_user\n else\n find_or_create_guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in(guest_user_id)\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n return current_user\n else\n return guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if cookies.signed[:guest_user_email]\n logging_in\n guest_user.delete\n cookies.delete :guest_user_email\n end\n current_user\n else\n guest_user\n end\n end",
"def get_current_user\n @current_user = current_or_guest_user\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_authentication_token] &&\n !current_user.matches_guest_authentication_token?(session[:guest_authentication_token])\n # transfer_guest_to_current_user\n guest_user(with_retry = false).try(:destroy)\n session[:guest_authentication_token] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n current_user || User.find_by_lazy_id(cookies[:uuid])\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_user\n # if a user is logged in we just use devise's implementation.\n super || guest_user\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n\t\tif current_user\n\t\t\tif session[:guest_user_id] && session[:guest_user_id] != current_user.id\n\t\t\t\tlogging_in\n\t\t\t\tguest_user(with_retry = false).try(:destroy)\n\t\t\t\tsession[:guest_user_id] = nil\n\t\t\tend\n\t\t\tcurrent_user\n\t\telse\n\t\t\tguest_user\n\t\tend\n\tend",
"def current_user\n if session[:user_id] != nil\n user = User.find(session[:user_id])\n elsif session[:guest_id] != nil\n user = User.find(session[:guest_id])\n else\n user = User.new(name: \"Guest\", authenticated: false)\n user.save\n session[:guest_id] = user.id\n end\n return user\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n #guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user(params)\n if current_user\n if cookies[:uuid]\n unless current_user.guest?\n cookies.delete :uuid\n end\n end\n current_user\n else\n guest_user(params)\n end\n end",
"def current_user\r\n super || guest_user\r\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_user\r\n super || guest_user\r\n end",
"def current_user_or_guest\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if cookies[:uuid]\n logging_in # Look at this method to see how handing over works\n guest_user.destroy # Stuff have been handed over. Guest isn't needed anymore.\n cookies.delete :uuid # The cookie is also irrelevant now\n end\n current_user\n else\n guest_user\n end\n end",
"def current_user\n super || guest_user\n end",
"def current_user\n super || guest_user\n end",
"def current_user\n super || guest_user\n end",
"def current_or_guest_user(create_guest = false)\n @current_or_guest_user ||=\n (\n logger.debug 'ApplicationController:current_or_guest_user'\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n remove_guest\n logger.debug \"ApplicationController:current_or_guest_user >>> current_user and guest_user session found -- guest_user remove and return current_user\"\n end\n current_user\n else\n logger.debug \"ApplicationController:current_or_guest_user >>> current_user not found -- switching to guest_user with create = #{create_guest}\"\n guest_user(create_guest)\n end\n )\n end",
"def current_or_guest_user\n \tif current_user\n \t\tif session[:guest_user_id]\n \t\t\tlogging_in\n \t\t\tguest_user.destroy\n \t\t\tsession[:guest_user_id] = nil\n \t\tend\n \t\tcurrent_user\n \telse\n \t\tguest_user\n \tend \t\n end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def current_user \n #will never return NIL, create a fake user\n #will return the super value (logged in user) OR the guest infos.\n super || guest_user\n end",
"def current_or_guest_user\n Rails.logger.warn(\"current_or_guest_user is DEPRECATED - just use current_user\") \n current_user\n end",
"def current_user( user = :get )\n if( user == :get )\n session[:user] ||= guest_account\n else\n session[:user] = user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_user\n \tsuper || guest_user\n \t#Super quiere decir que exactamente con los valores \n \t#del metodo original sin cambiar nada\n end",
"def user_or_guest\n user or Guest.new(guest_uid, guest_name)\n end",
"def guest_user\n @guest_user ||= User.where(guest: true).first || super\n end",
"def guest_user\n guest_id = session[:guest_user_id]\n if guest_id.nil? || User.find(guest_id).nil?\n user = create_guest_user\n session[:guest_user_id] = user.id\n return User.find(user.id)\n end\n User.find(guest_id)\n end",
"def current_user\n @current_user ||= User.find(session[:user_id])\n rescue ActiveRecord::RecordNotFound\n #login User.create_guest\n end",
"def guest_user\n unless defined? @guest_user\n if session[:guest_user_id] && (user = User.where(:id => session[:guest_user_id]).first)\n @guest_user = user\n else\n @guest_user = create_guest_user!\n session[:guest_user_id] = @guest_user.id\n end\n end\n return @guest_user\n end",
"def current_user\n # super: don't change anything, i just want the exact same behavior \n # as in the method that we are overriding\n\n # what this line means is that if the user is logged in, super is true,\n # then call super treat everything normal, and ignore right hand side\n # if super == false, call right hand side\n\n # super comes from devise class\n # meanwhile the r.h.s comes from open struct class\n super || guest_user\n end",
"def current_user\n User.find_by(uid: session[:user]) if logged_in?\n end",
"def current_user\n if devise_current_user\n if cookies[:guest_user_id]\n logging_in\n guest_user.destroy\n cookies.delete :guest_user_id\n end\n devise_current_user\n else\n guest_user\n end\n end",
"def guest_user\n User.find(session[:guest_user_id].nil? ? session[:guest_user_id] = create_guest_user.id : session[:guest_user_id])\n end",
"def guest_user\n @_guest ||= Guest.from_cookies(cookies) unless user_signed_in?\n end",
"def current_user\n if session[:user_id]\n return User.find(session[:user_id])\n end\nend",
"def current_user\n logged_in? ? User.find_by_id(session[:user_id]) : nil\n end",
"def current_user_or_admin\n if current_user \n return current_user\n elsif current_admin \n return current_admin\n end \n end",
"def current_user\n @user ||= User.find_by_id(session[:user_id])if logged_in?\n end",
"def get_user\n @current_user = current_admin || current_user\n end",
"def current_user\n User.find session[:user_id] if user_signed_in?\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n end\n end",
"def get_or_create_user\n @user||=use_url_session? ? get_or_create_url_session_user : current_user_with_guest\n end",
"def current_user\n if @user\n @user\n elsif session[:user_id]\n @user = User.find(session[:user_id])\n else\n redirect_to login_path and return\n end\n end",
"def guest_user\n User.find_by_lazy_id(cookies[:uuid].nil? ? create_guest_user.lazy_id : cookies[:uuid])\n end",
"def current_user\n # User.find would throw an error if we cannot find the user\n if session[:user_id]\n User.find_by({ id: session[:user_id] })\n else\n Dog.find_by({ id: session[:dog_id] })\n end\n end",
"def current_user\n login_from_session || login_from_basic_auth \n end",
"def current_user\n logger.debug 'ApplicationController:current_user'\n @current_user ||= super\n @current_user && @current_user.is_guest? ? nil : @current_user\n end",
"def token_or_current_or_guest_user\n token_user || current_or_guest_user\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n end\nend",
"def current_user\n User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n User.find(session[:user_id]) if session[:user_id]\n end",
"def guest\n defaultuser = (\n case ActiveRecord::Base.connection.adapter_name\n when 'MySQL'\n 'defaultUser'\n else\n 'defaultuser'\n end\n )\n User.find(:first, :conditions => \"#{self.class.primary_key}=#{self.id} AND #{defaultuser} = true\" )\n end",
"def current_user\n begin\n unless @current_user.nil?\n return @current_user\n else\n if session[:user_id]\n return @current_user = User.find(session[:user_id])\n else\n return nil\n end\n end\n rescue\n return nil\n end\nend",
"def current_user\n return unless session[:user_id]\n User.find(session[:user_id])\n end",
"def current_user\n login_from_session || login_from_basic_auth\n end",
"def current_user\n\t\tauthenticated(User)\n\tend",
"def current_user\n return @current_user if @current_user.present?\n\n session_user_id = session[:user_id]\n @current_user = if session_user_id.present?\n User.find_by(id: session_user_id) || AdminUser.find_by(id: session_user_id)\n end\n end",
"def current_user(id = session[:user_id])\n User.get_one id\n end",
"def current_user # Check the current user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n User.find_by_id(session[:user_id]) if session[:user_id] \n end",
"def current_user\n @current_user if logged_in?\n end",
"def current_user\n @current_user if logged_in?\n end",
"def current_user\n return nil unless session[:user_id]\n User.get(session[:user_id])\nend",
"def guest_user\n begin\n if !@cached_guest_user\n session[:guest_user_id] ||= create_guest_user.id\n @cached_guest_user = User.find(session[:guest_user_id])\n end\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n @cached_guest_user = nil\n guest_user\n end\n @cached_guest_user\n end",
"def current_user\n @current_user ||= find_logged_in_user\n end",
"def current_user\n \n # Normally we would look in the session to see if there is a user_id \n # to figure out if the user is loggged in.\n # For demo purposes this app randomly picks if the user is logged in\n if rand(100) > 20 \n User.last\n else\n nil\n end\n end",
"def current_user\n # User.find would throw an error if we cannot find the user\n User.find_by({ id: session[:user_id] })\n end",
"def current_user\n\tif session[:user_id].present?\n\t\tUser.find(session[:user_id])\t\n\tend\nend",
"def current_user\n User.find(session[:user])\n end",
"def current_user\n if session[:user_id] # if there is a session id, the current user is the one whose session id is the same as the user id \n @current_user ||= User.find_by(id: session[:user_id])\n end\n end",
"def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id] #find user in database based on id, if not already logged in. \n \n end",
"def current_user\n User.find session[:id] if session[:id]\n end",
"def current_user\n\tsession[:user_id] ? User.find(session[:user_id]) : nil\nend",
"def current_user\n\tsession[:user_id] ? User.find(session[:user_id]) : nil\nend",
"def current_user\n if !session[:user_id] then nil else User.find(session[:user_id]) end\n end",
"def current_user\n User.get_user(session[:user_id]) if session[:user_id]\n end",
"def find_current_user\n # adding if to prevent rails from checking user when logged out\n if is_logged_in?\n #save to a variable\n @current_user = User.find(session[:user_id]);\n else\n @current_user = nil\n end\n end",
"def current_user\n @current_user || User.find(session[:user_id]) if session[:user_id]\n \tend",
"def current_user\n @current_user ||= User.find(session[:user_id]) if user_signed_in?\n end"
] | [
"0.8972537",
"0.89303094",
"0.88523144",
"0.8651935",
"0.853423",
"0.853423",
"0.85133153",
"0.84569985",
"0.8417819",
"0.84024686",
"0.8402046",
"0.8398895",
"0.8398895",
"0.83985436",
"0.83967316",
"0.83779323",
"0.8376421",
"0.8368573",
"0.83656144",
"0.83558625",
"0.83558625",
"0.83558625",
"0.83545",
"0.8354306",
"0.83484375",
"0.83024883",
"0.8283488",
"0.82755435",
"0.82409245",
"0.8236153",
"0.8236153",
"0.82105494",
"0.8188958",
"0.817646",
"0.8107046",
"0.8107046",
"0.8107046",
"0.8089587",
"0.8087759",
"0.8000476",
"0.7981806",
"0.7978643",
"0.79599285",
"0.78380364",
"0.7826428",
"0.781091",
"0.7798456",
"0.7777851",
"0.7776419",
"0.7730281",
"0.7713538",
"0.7705536",
"0.7705426",
"0.7687456",
"0.764002",
"0.7629204",
"0.76251084",
"0.76141155",
"0.76001644",
"0.7597891",
"0.75722486",
"0.7567297",
"0.75436485",
"0.7541088",
"0.753377",
"0.7533639",
"0.7527513",
"0.7519109",
"0.750613",
"0.75047475",
"0.7502743",
"0.7502743",
"0.7501187",
"0.7500736",
"0.7489399",
"0.74870306",
"0.74703634",
"0.7468451",
"0.7468202",
"0.7459815",
"0.74593127",
"0.7459294",
"0.7459294",
"0.7457408",
"0.7452582",
"0.744892",
"0.7443056",
"0.744226",
"0.7435741",
"0.74325943",
"0.7429412",
"0.742878",
"0.7423948",
"0.74234164",
"0.74234164",
"0.7421879",
"0.7415005",
"0.7413265",
"0.7411776",
"0.7411127"
] | 0.8694018 | 3 |
find guest_user object associated with the current session, creating one as needed | def guest_user(with_retry = true)
# Cache the value the first time it's gotten.
@cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)
rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid
session[:guest_user_id] = nil
guest_user if with_retry
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guest_user\n User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user\n end",
"def guest_user\n User.find(session[:guest_user_id].nil? ? session[:guest_user_id] = create_guest_user.id : session[:guest_user_id])\n end",
"def guest_user\n if session[:guest_user_id]\n guest = Guest.where(id: session[:guest_user_id]).first\n end\n guest ||= Guest.create\n session[:guest_user_id] = guest.id\n guest\n end",
"def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user\n end",
"def guest_user\n \t# Cache the value the first time it's gotten.\n \t@cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound #if (session[:guest_user_id] invalid\n \tsession[:guest_user_id] = nil\n \tguest_user\n end",
"def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user\n end",
"def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user\n end",
"def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue Mongoid::Errors::DocumentNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user\n end",
"def guest_user\n begin\n if !@cached_guest_user\n session[:guest_user_id] ||= create_guest_user.id\n @cached_guest_user = User.find(session[:guest_user_id])\n end\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n @cached_guest_user = nil\n guest_user\n end\n @cached_guest_user\n end",
"def guest_user\n unless defined? @guest_user\n if session[:guest_user_id] && (user = User.where(:id => session[:guest_user_id]).first)\n @guest_user = user\n else\n @guest_user = create_guest_user!\n session[:guest_user_id] = @guest_user.id\n end\n end\n return @guest_user\n end",
"def guest_user\n\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n @cached_guest_user\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n\n guest_user\n end",
"def guest_user\n guest_id = session[:guest_user_id]\n if guest_id.nil? || User.find(guest_id).nil?\n user = create_guest_user\n session[:guest_user_id] = user.id\n return User.find(user.id)\n end\n User.find(guest_id)\n end",
"def guest_user\n @cached_guest ||= create_guest_user\n end",
"def create_guest_user\n logger.debug \"ApplicationController:create_guest_user >>> creating new guest_user record\"\n guest = User.new_guest_user\n session[:guest_user_id] = guest.id\n guest\n end",
"def create_guest_user\n u = User.new(:name => \"guest\", :email => \"guest_#{Time.now.to_i}#{rand(100)}@example.com\", :guest => true)\n u.save!(:validate => false)\n session[:guest_user_id] = u.id\n u\n end",
"def create_guest_user!\n # bah, this may not be entirely guaranteed to be unique\n # but it would be hard for it to collide, good enough. Actually\n # if the rails session id isn't unique, it's gonna cause problems\n # for more than just us, we should be good with just that even.\n unique_token = \"#{request.session_options[:id]}_#{(Time.now.to_f * 1000.0).to_i}_#{Process.pid}\"\n\n new_user = User.new.tap do |u|\n u.login = \"GUEST_USER_#{unique_token}\"\n u.guest = true\n u.save!\n end\n end",
"def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(cookies[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n cookies[:guest_user_id] = nil\n guest_user\n end",
"def create_guest_user\n email = \"guest_#{Time.now.to_i}#{rand(99)}@example.com\"\n u = User.create(:email => email)\n u.save!(:validate => false)\n session[:guest_user_id] = u.id\n u\n end",
"def guest_user\n User.find_by_lazy_id(cookies[:uuid].nil? ? create_guest_user.lazy_id : cookies[:uuid])\n end",
"def guest_user(allow_create = false)\n if allow_create\n @cached_guest_user ||= User.find(session[:guest_user_id] || create_guest_user.id)\n else\n @cached_guest_user ||= User.find(session[:guest_user_id])\n end\n\n rescue ActiveRecord::RecordNotFound\n # only allow retry if allow_create == true\n session[:guest_user_id] = nil\n guest_user if allow_create\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n # if session[:guest_user_id] invalid\n rescue ActiveRecord::RecordNotFound\n session[:guest_user_id] = nil\n guest_user if with_retry\n end",
"def guest_user\n guest = GuestUser.new\n guest.name = \"friend\"\n guest.first_name = \"Visitor\"\n guest.last_name = \"User\"\n guest.email = \"guest@ptorrsmith.com\"\n \n # return guest\n guest\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user if with_retry\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user if with_retry\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user if with_retry\n end",
"def guest_user\r\n guest = GuestUser.new\r\n guest.name = 'Guest User'\r\n guest.first_name = 'Guest'\r\n guest.last_name = 'User'\r\n guest.email = 'guest@test.com'\r\n guest\r\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user if with_retry\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user if with_retry\n end",
"def new_guest_user\n if object.user && object.user.guest? && object.user.trips.count == 1\n {email: object.user.email, authentication_token: object.user.authentication_token}\n else\n nil\n end\n end",
"def guest_user(params)\n if u = User.where(:lazy_id => true).where(:lazy_id => cookies[:uuid]).first\n u\n else\n create_guest_user(params)\n end\n end",
"def guest_user(with_retry = true)\n\t # Cache the value the first time it's gotten.\n\t @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n\t rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n\t \tsession[:guest_user_id] = nil\n\t \tguest_user if with_retry\n\t end",
"def guest_user(with_retry = true)\n begin\n # Cache the value the first time it's gotten.\n @cached_guest_user ||=User.find_by_guest_authentication_token(session[:guest_authentication_token]) ||User.build_guest(session)\n rescue ActiveRecord::RecordNotFound\n session[:guest_authentication_token] = nil\n guest_user if with_retry\n end\n end",
"def set_guest\n @user = GuestUsers::User.find(params[:id])\n end",
"def register_guest\n params[:guest] = params[:user] if params[:user]\n if current_guest\n @user = User.find(current_guest.id)\n @user.email = params[:guest][:email]\n @user.email_preference = params[:guest][:email_preference]\n return render :guest_registration unless @user.valid?\n\n @user.save!\n else\n # See if I can convert these next few lines to find_or_create_by, making sure to still\n # set account_status to 'G'. Pay attention to the block below looking to see if @user is valid\n @user = Guest.find_by_email(params[:guest][:email].downcase)\n @user ||= Guest.new(guest_params.merge(account_status: 'G'))\n # Doing the 'unless' condition so a user can't then make himself a guest and break his account\n @user.account_status = 'G' unless @user.account_status == 'A'\n\n unless @user.valid?\n flash[:alert] = 'You must enter a valid email and accept the terms of service before you can proceed.'\n return render :guest_registration\n end\n\n @user.save!\n session[:guest] = @user.id\n end\n redirect_to controller: :store, action: :checkout\n end",
"def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find_by!(email: (cookies.permanent.signed[:guest_user_email] ||= create_guest_user.email))\n\n # if cookies.signed[:guest_user_email] invalid\n rescue ActiveRecord::RecordNotFound\n cookies.delete :guest_user_email\n guest_user\n end",
"def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||=\n User.find_by!(email: (cookies.permanent.signed[:guest_user_email] ||= create_guest_user.email))\n\n # if cookies.signed[:guest_user_email] invalid\n rescue ActiveRecord::RecordNotFound #\n cookies.delete :guest_user_email\n guest_user\n end",
"def user_or_guest\n user or Guest.new(guest_uid, guest_name)\n end",
"def create_guest_user\n user = User.new { |user| user.role = 'guest' }\n user.email = \"guest_#{Time.now.to_i}#{rand(99)}@example.com\"\n user.save(validate: false)\n user\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id]) if session[:guest_user_id]\n\n # rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n # session[:guest_user_id] = nil\n # guest_user if with_retry\n end",
"def current_user\n if session[:user_id] != nil\n user = User.find(session[:user_id])\n elsif session[:guest_id] != nil\n user = User.find(session[:guest_id])\n else\n user = User.new(name: \"Guest\", authenticated: false)\n user.save\n session[:guest_id] = user.id\n end\n return user\n end",
"def guest_user\n @guest_user ||= User.where(guest: true).first || super\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(guest_user_id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user if with_retry\n end",
"def create_guest_user\n uuid = rand(36**64).to_s(36)\n temp_email = \"guest_#{uuid}@guest_user.com\"\n u = User.create(name: \"GUEST\", username: \"Guest #{User.guests.size}\", email: temp_email, lazy_id: uuid)\n cookies[:uuid] = { value: uuid, path: '/', expires: 5.years.from_now }\n u.save(validate: false)\n u\n end",
"def guest_user\n User.find_by_email('guest@guest.com')\n end",
"def current_or_guest_user!\n if current_user\n if cookies[:uuid]\n\n # Called when a guest user is converted to current user\n promote_guest_to_user(current_user)\n\n # destroy the guest user and the session\n destroy_guest_user\n end\n current_user\n else\n find_or_create_guest_user\n end\n end",
"def guest_user\n @_guest ||= Guest.from_cookies(cookies) unless user_signed_in?\n end",
"def guest_user\n User.find_by_lazy_id(cookies[:uuid])\n end",
"def guest_user(with_retry = true)\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(cookies.signed.permanent[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if cookies.signed[:guest_user_id] invalid\n cookies.delete :guest_user_id\n guest_user if with_retry\n end",
"def current_or_guest_user(create_guest = false)\n @current_or_guest_user ||=\n (\n logger.debug 'ApplicationController:current_or_guest_user'\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n remove_guest\n logger.debug \"ApplicationController:current_or_guest_user >>> current_user and guest_user session found -- guest_user remove and return current_user\"\n end\n current_user\n else\n logger.debug \"ApplicationController:current_or_guest_user >>> current_user not found -- switching to guest_user with create = #{create_guest}\"\n guest_user(create_guest)\n end\n )\n end",
"def maybe_login_guest\n # Assume that guest exists in DB\n # session[:usr_id] = (Usr.find_by_login(\"guest\").id)\n # Being a guest means that session[:usr_id] is nil\n # unless (session[:usr_id])\n # The idea that a guest has a usr_id causes problems with login_sugar.\n # So, a guest does not have a usr_id.\n end",
"def guest\n new(email: GUEST_USER_EMAIL).freeze\n end",
"def guest\n defaultuser = (\n case ActiveRecord::Base.connection.adapter_name\n when 'MySQL'\n 'defaultUser'\n else\n 'defaultuser'\n end\n )\n User.find(:first, :conditions => \"#{self.class.primary_key}=#{self.id} AND #{defaultuser} = true\" )\n end",
"def current_user\n @current_user ||= User.find(session[:user_id])\n rescue ActiveRecord::RecordNotFound\n #login User.create_guest\n end",
"def guest\n\t\tid = User.count + 1\n\t\t@user = User.new(username: \"Guest_#{id}\", password: \"guestpass#{id}\", password_confirmation: \"guestpass#{id}\")\n\t\tif @user.save!\n\t\t\tsign_in @user\n\t\t\tflash[:success] = \"Welcome to Lightcycles!\"\n\t\t\tredirect_to root_path\n\t\telse\n\t\t\tflash[:error] = \"Sorry, there was an error!\"\n\t\t\tredirect_to \"/login\"\n\t\tend\n\tend",
"def get_or_create_user\n @user||=use_url_session? ? get_or_create_url_session_user : current_user_with_guest\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n #guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def create_guest_user\n u = User.create(name: 'guest', email: \"guest_#{Time.current.to_i}#{rand(99)}@example.com\")\n # u.skip_confirmation!\n u.save!(validate: false)\n u\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_authentication_token] &&\n !current_user.matches_guest_authentication_token?(session[:guest_authentication_token])\n # transfer_guest_to_current_user\n guest_user(with_retry = false).try(:destroy)\n session[:guest_authentication_token] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n transfer_session_to_logged_in_user if session[:guest_user_id].present?\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in(guest_user_id)\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n puts \"test\"\n puts \"11111111\"\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n puts \"222222222222\"\n else\n guest_user\n puts \"3333333333\"\n end\n end",
"def check_for_guest\n if(params[:user_id]) then \n @user=User.find(params[:user_id])\n else\n @user=nil\n end\n @user\n end",
"def create_guest_user\n u = User.create(email: \"guest_#{Time.now.to_i}#{rand(99)}@example.com\")\n #u.skip_confirmation!\n u.save!(validate: false)\n u\n end",
"def create\n if (params[:user][:email] == \"guest@example.com\")\n prep_guest\n end\n super\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def promote_guest_to_user(user)\n # What should be done here is take all that belongs to user with lazy_id matching current_user's uuid cookie...\n # then associate them with current_user\n\n # Copy the subscription data from the guest user to the newly created user:\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save\n # end\n\n if !cookies[:uuid].nil?\n #user.subscriptions = guest_user.subscriptions.dup\n true\n else\n false\n end\n\n # When we promote a guest to a user, the guest should be destroyed (This includes deleting the cookie)\n destroy_guest_user\n\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n #guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n return current_user\n else\n return guest_user\n end\n end",
"def current_or_guest_user\n\t\tif current_user\n\t\t\tif session[:guest_user_id] && session[:guest_user_id] != current_user.id\n\t\t\t\tlogging_in\n\t\t\t\tguest_user(with_retry = false).try(:destroy)\n\t\t\t\tsession[:guest_user_id] = nil\n\t\t\tend\n\t\t\tcurrent_user\n\t\telse\n\t\t\tguest_user\n\t\tend\n\tend",
"def create_guest\n\t\tcustom_params = { \n\t\t\temail: Faker::Internet.email, \n\t\t\tpassword: \"demodemo\",\n\t\t\tguest: true\n\t\t}\t\t\n\t\t\n\t\tUser.transaction do\n\t\t\t@user = User.new(custom_params)\n\t\t\t@user.create_dashboard\n\t\tend\n\t\t\n\t\tif @user.save\n log_in!(@user)\n\t\t\t@user.create_guest_blog_with_posts!\n\t\t\t\n render json: @user\n else\n render json: @user.errors.full_messages, status: 422\n end\n\t\t\n\tend",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def guest\n @patient=User.find_by_wedgetail(params[:wedgetail],:order =>\"created_at DESC\")\n authorize_only (:patient) {@patient.wedgetail == @user.wedgetail}\n authorize :admin\n @newuser = User.new\n \n @newuser.username= WedgePassword.username_make(\"G\")\n @newuser.password= WedgePassword.random_password(6)\n @newuser.family_name=\"Guest \"+@newuser.username\n @newuser.wedgetail=@newuser.username + @patient.wedgetail\n @newuser.role=7\n if @newuser.save \n render(:layout => \"layouts/guestcard\")\n flash.now[:notice] = \"Guest User Created\"\n else\n flash.now[:notice] = \"Guest User Not Created Due to Error\"\n redirect_to(patient_path(@patient.wedgetail))\n end\n end",
"def set_guest_session_association\n @guest_session_association = GuestSessionAssociation.new(user_id:session[:user_id],jam_session_id:params[:id],player:params[:player])\n @guest_session_association.save!\n end",
"def current_user_or_guest\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guest.find(params[:id])\n end",
"def set_guest\n @guest = Guests.find(params[:id])\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user_log_out\n end\n current_user\n else\n guest_user\n end\n end"
] | [
"0.8470449",
"0.8451743",
"0.84341997",
"0.83501446",
"0.82567453",
"0.82224774",
"0.82224774",
"0.82161653",
"0.81839544",
"0.81606865",
"0.8078032",
"0.80538064",
"0.8025579",
"0.801468",
"0.79474324",
"0.79386055",
"0.7862031",
"0.7785836",
"0.77789694",
"0.77545303",
"0.77031493",
"0.76924855",
"0.76834935",
"0.76834935",
"0.7673195",
"0.76378065",
"0.7635158",
"0.76323557",
"0.7576845",
"0.7566925",
"0.7558789",
"0.75072664",
"0.7465027",
"0.7453731",
"0.7422603",
"0.73846036",
"0.73821396",
"0.737704",
"0.73733133",
"0.7351538",
"0.7349835",
"0.72851187",
"0.7270765",
"0.7253622",
"0.72286624",
"0.71625304",
"0.71080184",
"0.7096098",
"0.70818025",
"0.7032515",
"0.70301145",
"0.70195633",
"0.700763",
"0.6993784",
"0.69238263",
"0.6865728",
"0.68343365",
"0.6834114",
"0.6833101",
"0.6813519",
"0.6813519",
"0.6813519",
"0.6788592",
"0.6781602",
"0.672174",
"0.6712116",
"0.67028266",
"0.67028266",
"0.6674184",
"0.6668365",
"0.666013",
"0.6650751",
"0.664328",
"0.65894866",
"0.6581861",
"0.65463114",
"0.6534887",
"0.65345454",
"0.65097904",
"0.6486233",
"0.6486233",
"0.6486233",
"0.6486233",
"0.6486233",
"0.64779377",
"0.64779377",
"0.64761436",
"0.6475923",
"0.6460631",
"0.64460456",
"0.64460456",
"0.64460456",
"0.64460456",
"0.64310086",
"0.64279205"
] | 0.7612736 | 28 |
called (once) when the user logs in, insert any code your application needs to hand off from guest_user to current_user. | def logging_in
current_user.absorb_from(guest_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logging_in\n logger.debug \"ApplicationController:logging_in >>> \"\n current_user.transfer_data(guest_user)\n end",
"def logging_in\n\t\tguest_comments = guest_user.comments.all\n\t\tguest_comments.each do |comment|\n\t\t\tcomment.user_id = current_user.id\n\t\t\tcomment.save!\n\t\tend\n\t\tguest_notes = guest_user.notes.all\n\t\tguest_notes.each do |note|\n\t\t\tnote.user_id = current_user.id\n\t\t\tnote.save!\n\t\tend\n\t\tguest_likes = guest_user.likes.all\n\t\tguest_likes.each do |like|\n\t\t\tlike.user_id = current_user.id\n\t\t\tlike.save!\n\t\tend\n\tend",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def logging_in\n # copy the guest user's championships into the new one (merge them in...)\n guest_user.move_associations_to non_guest_current_user\n\n # remove guest user\n # (not absolutely neccesary as the creation of new ones would eventually remove it)\n guest_user.destroy\n end",
"def current_user\n # if a user is logged in we just use devise's implementation.\n super || guest_user\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n puts \"test\"\n puts \"11111111\"\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n puts \"222222222222\"\n else\n guest_user\n puts \"3333333333\"\n end\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def current_or_guest_user!\n if current_user\n if cookies[:uuid]\n\n # Called when a guest user is converted to current user\n promote_guest_to_user(current_user)\n\n # destroy the guest user and the session\n destroy_guest_user\n end\n current_user\n else\n find_or_create_guest_user\n end\n end",
"def current_user\n # super: don't change anything, i just want the exact same behavior \n # as in the method that we are overriding\n\n # what this line means is that if the user is logged in, super is true,\n # then call super treat everything normal, and ignore right hand side\n # if super == false, call right hand side\n\n # super comes from devise class\n # meanwhile the r.h.s comes from open struct class\n super || guest_user\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def logging_in\n # TODO merge friends with the same name\n guest_user.friends.update_all(user_id: current_user.id)\n guest_user.bills.update_all(user_id: current_user.id)\n guest_user.participations.update_all(person_id: current_user.id)\n end",
"def logging_in\n guest_user.books.each { |book| book.update(user_id: current_user.id) } if guest_user.books.present?\n guest_user.holsts.each { |holst| holst.update(user_id: current_user.id) } if guest_user.holsts.present?\n end",
"def logging_in\n guest_order_items = guest_user.order_items.all\n guest_order_items.each do |order_item|\n order_item.user_id = current_user.id\n order_item.save!\n end\n guest_orders = guest_user.orders.all\n guest_orders.each do |order|\n order.user_id = current_user.id\n order.save!\n end\n end",
"def logging_in\n guest_reviews = guest_user.reviews.all\n guest_reviews.each do |review|\n review.user_id = current_user.id\n review.save\n end\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save\n # end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n #guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n\n guest_likes = guest_user.likes\n current_user_likes = devise_current_user.likes\n guest_likes.each do |like|\n if current_user_likes.find_by_post_id(like.post_id).blank?\n like.user_id = devise_current_user.id\n like.save!\n else\n like.destroy\n end\n end\n\n guest_comments = guest_user.my_comments.with_state([:published, :draft])\n guest_comments.each do |comment|\n comment.user_id = devise_current_user.id\n comment.title = devise_current_user.email\n comment.save!\n end\n\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n\n current_user.room_id = guest_user.room_id\n \n end",
"def guest_user(_user)\n if RuntimeConfig.vote_signin_active?\n can :access, :sessions\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n puts \"this is a test\"\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user_log_out\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:reload).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n # reload guest_user to prevent caching problems before destruction\n guest_user(with_retry = false).reload.try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def logging_in\n guest_user.notes.all.each do |note|\n note.user_id = current_user.id\n note.from_address = current_user.email\n note.save\n end\n current_user.unique_id = guest_user.unique_id\n current_user.save\n end",
"def current_or_guest_user\n\t\tif current_user\n\t\t\tif session[:guest_user_id] && session[:guest_user_id] != current_user.id\n\t\t\t\tlogging_in\n\t\t\t\tguest_user(with_retry = false).try(:destroy)\n\t\t\t\tsession[:guest_user_id] = nil\n\t\t\tend\n\t\t\tcurrent_user\n\t\telse\n\t\t\tguest_user\n\t\tend\n\tend",
"def logged_in\r\n end",
"def current_user\n @current_user ||= User.find(session[:user_id])\n rescue ActiveRecord::RecordNotFound\n #login User.create_guest\n end",
"def current_or_guest_user\n \tif current_user\n \t\tif session[:guest_user_id]\n \t\t\tlogging_in\n \t\t\tguest_user.destroy\n \t\t\tsession[:guest_user_id] = nil\n \t\tend\n \t\tcurrent_user\n \telse\n \t\tguest_user\n \tend \t\n end",
"def repel_usr_guest\n redirect_to(\"/\") if session[:usr_id].nil?\n end",
"def login_guest()\n login(:guest)\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in(guest_user_id)\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def autologin_the_user\n #unless logged_in?\n # FrontendUserSession.create(params[:frontend_user_session])\n #end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id] && session[:guest_user_id] != current_user.id\n logging_in\n guest_user(with_retry = false).try(:destroy)\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def guest_user\n if signed_in?\n flash[:danger] = 'Please sign out before accessing this page'\n redirect_to overview_user_path(current_user)\n end\n end",
"def guest\n\t\tid = User.count + 1\n\t\t@user = User.new(username: \"Guest_#{id}\", password: \"guestpass#{id}\", password_confirmation: \"guestpass#{id}\")\n\t\tif @user.save!\n\t\t\tsign_in @user\n\t\t\tflash[:success] = \"Welcome to Lightcycles!\"\n\t\t\tredirect_to root_path\n\t\telse\n\t\t\tflash[:error] = \"Sorry, there was an error!\"\n\t\t\tredirect_to \"/login\"\n\t\tend\n\tend",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n #guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def logging_in\n orders = guest_user.orders.all\n orders.each do |order|\n order.user_id = current_user.id\n order.save!\n puts order.inspect\n end\n end",
"def setup_current_user\n @current_user = User.find(session[:user_id]) unless session[:user_id].nil?\n end",
"def current_or_guest_user\n if current_user\n transfer_session_to_logged_in_user if session[:guest_user_id].present?\n current_user\n else\n guest_user\n end\n end",
"def logging_in\n guest_order = guest_user.current_order_in_progress\n current_order = current_user.current_order_in_progress\n current_order.merge guest_order\n end",
"def current_or_guest_user\n if current_user\n if cookies.signed[:guest_user_email]\n logging_in\n guest_user.delete\n cookies.delete :guest_user_email\n end\n current_user\n else\n guest_user\n end\n end",
"def logging_in\n guest_charts = guest_user.charts\n guest_charts.each do |chart|\n chart.user_id = current_user.id\n chart.save\n end\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def create\n @user = params[:user] ? User.new(params[:user]) : User.new_guest\n if @user.save\n flash[:notice] = \"Your account was created successfully.\"\n current.user.move_to(@user) if current.user && current.user.guest?\n session[:user_id] = @user.id\n redirect_to root_path\n else\n render \"new\"\n flash[:notice] = \"There was a problem creating your account.\"\n end\n after_create :set_admin \n end",
"def get_current_user\n @current_user = current_or_guest_user\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in to vote\"\n redirect_to login_url\n end\n end",
"def guest_user\n @_guest ||= Guest.from_cookies(cookies) unless user_signed_in?\n end",
"def set_current_user! #naming convention to have the !\n @current_user = User.find_by(id: session[:user_id])\n end",
"def user_authentication\n end",
"def current_user\n \tsuper || guest_user\n \t#Super quiere decir que exactamente con los valores \n \t#del metodo original sin cambiar nada\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Primero has Log In\"\n redirect_to login_url\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def current_user_or_guest\n if current_user\n if session[:guest_user_id]\n logging_in\n guest_user.destroy\n session[:guest_user_id] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def set_current_user\n if logged_in?\n @current_user = current_user\n end\n end",
"def ensure_user_logged_in\n bounce_user unless current_user\n end",
"def user_logged_in\n if session[:just_logged_in] && !current_user.is_admin \n gon.display_login_popup = true\n \n session[:just_logged_in] = false\n end\n end",
"def logging_in\n guest = guest_user\n current_cart = current_user.cart\n\n # if guest exists and the current_user does not already have a pending cart from previous session\n # then save all items in current cart into its own cart\n\n unless guest.nil? || !current_cart.items.empty?\n guest_cart = guest.cart\n current_cart.items.destroy_all unless current_user.cart.items.empty?\n current_cart.items = guest_cart.items\n current_cart.save!\n end\n end",
"def current_or_guest_user\n if current_user\n if cookies[:uuid]\n logging_in # Look at this method to see how handing over works\n guest_user.destroy # Stuff have been handed over. Guest isn't needed anymore.\n cookies.delete :uuid # The cookie is also irrelevant now\n end\n current_user\n else\n guest_user\n end\n end",
"def transfer_guest_information\n\t if session[:guest_user_id]\n\t guest = User.find(session[:guest_user_id])\n\t guest.move_to(current_user)\n\t guest.destroy\n\t end\n\tend",
"def guest_user\n @guest_user ||= User.where(guest: true).first || super\n end",
"def check_user_before_membership\n if current_user\n ncm_membership = current_user.get_membership(@mother)\n epicenter = Epicenter.find_by_slug(params['epicenter_id'])\n\n if epicenter != @mother and not ncm_membership\n session[:new_ncm_membership] = { \n :epicenter_id => params['epicenter_id'], \n :membership_id => params['membership_id'],\n :t => Time.now\n }\n #\n redirect_to new_epicenter_subscription_path(@mother)\n end\n else\n # it's possible that we can put the logic from \"authenticate\" method below here\n redirect_to epicenters_path\n end\n end",
"def set_current_user\n \t\tif session[:user_id]\n \t\t\tCurrent.user = User.find_by(id: session[:user_id])\n \t\tend\n \tend",
"def current_user\r\n super || guest_user\r\n end",
"def setup \n @user = current_user\n end",
"def current_or_guest_user\n if current_user\n if session[:guest_authentication_token] &&\n !current_user.matches_guest_authentication_token?(session[:guest_authentication_token])\n # transfer_guest_to_current_user\n guest_user(with_retry = false).try(:destroy)\n session[:guest_authentication_token] = nil\n end\n current_user\n else\n guest_user\n end\n end",
"def guest_user\n User.find(session[:guest_user_id].nil? ? session[:guest_user_id] = create_guest_user.id : session[:guest_user_id])\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def current_user\n if session[:user_id] != nil\n user = User.find(session[:user_id])\n elsif session[:guest_id] != nil\n user = User.find(session[:guest_id])\n else\n user = User.new(name: \"Guest\", authenticated: false)\n user.save\n session[:guest_id] = user.id\n end\n return user\n end",
"def log_in\n end",
"def current_user\n if devise_current_user\n if cookies[:guest_user_id]\n logging_in\n guest_user.destroy\n cookies.delete :guest_user_id\n end\n devise_current_user\n else\n guest_user\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Admin Access Only.\"\n redirect_to login_url\n \n end\n end",
"def logging_in\n current_user.todos = (current_user.todos + guest_user.todos)\n current_user.save\n end",
"def set_logged_in_user\n @logged_in_user = logged_in_user\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in first.\"\n redirect_to root_url\n end\n end",
"def current_user\r\n super || guest_user\r\n end",
"def set_user; end",
"def custom_user_auth\n\t\t\tunless student_signed_in? || admin_signed_in?\n\t\t\t\tredirect_to root_path, notice: \"You have to sign in.\"\n\t\t\tend\n\t\tend",
"def set_user\n UserInfo.current_user = session[:user]\n end",
"def guest_user\n User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user\n end",
"def logged_in_user\n if user_signed_in? then\n \n else\n redirect_to root_path\n end \n \n end",
"def logged_in_user\n unless current_user \n redirect_to root_path\n end\n end",
"def loggedIn\n @user = current_user\nend",
"def require_login\n if current_user\n gon.current_user_email = current_user.email\n gon.current_user_created_at = current_user.created_at.to_i\n gon.current_user_username = current_user.username.capitalize\n gon.current_user_id = current_user.id\n gon.current_user_coaching_intensity = current_user.preference.coaching_intensity\n gon.current_user_last_login_at = current_user.last_login_at\n\n else\n store_location\n flash[:notice] = \"You must be logged in to access this page\"\n redirect_to login_url\n end\n end",
"def guest_user\n \t# Cache the value the first time it's gotten.\n \t@cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue ActiveRecord::RecordNotFound #if (session[:guest_user_id] invalid\n \tsession[:guest_user_id] = nil\n \tguest_user\n end",
"def logged_in_user\n\t\tunless logged_in?\n\t\t\tstore_location\n\t\t\tflash[:danger] = \"E' necessario accedere\"\n\t\t\tredirect_to login_url\n\t\tend\n\tend",
"def current_or_guest_user\n Rails.logger.warn(\"current_or_guest_user is DEPRECATED - just use current_user\") \n current_user\n end",
"def current_user \n #will never return NIL, create a fake user\n #will return the super value (logged in user) OR the guest infos.\n super || guest_user\n end",
"def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end"
] | [
"0.76545906",
"0.7417004",
"0.70993006",
"0.7069182",
"0.69960326",
"0.69612724",
"0.6960114",
"0.6960114",
"0.6960114",
"0.6960114",
"0.69566405",
"0.6956096",
"0.69517374",
"0.6908953",
"0.68947226",
"0.68411946",
"0.67875904",
"0.6775122",
"0.67685986",
"0.6762087",
"0.6729135",
"0.6722554",
"0.67194045",
"0.6719272",
"0.6719158",
"0.67141074",
"0.668829",
"0.6682566",
"0.6682566",
"0.6682566",
"0.66815835",
"0.66731864",
"0.6659512",
"0.6643724",
"0.6629793",
"0.6610988",
"0.6579737",
"0.6556043",
"0.65493786",
"0.6538316",
"0.6523335",
"0.6521549",
"0.6521549",
"0.65188295",
"0.65158516",
"0.6491173",
"0.6480155",
"0.64673984",
"0.64672416",
"0.6444034",
"0.64310867",
"0.64271235",
"0.64237237",
"0.642129",
"0.640695",
"0.6390026",
"0.63688886",
"0.63613564",
"0.6355745",
"0.63445145",
"0.6331564",
"0.6331564",
"0.6320129",
"0.63191736",
"0.6314302",
"0.63085514",
"0.63073516",
"0.63033795",
"0.6285275",
"0.6283019",
"0.6280575",
"0.6280348",
"0.62680846",
"0.62546146",
"0.6241611",
"0.62404865",
"0.6233512",
"0.6233512",
"0.6233375",
"0.62197614",
"0.62167406",
"0.6208852",
"0.6202174",
"0.6198113",
"0.6197358",
"0.6196328",
"0.6190157",
"0.6187228",
"0.6186947",
"0.61855483",
"0.6183314",
"0.61756957",
"0.6173108",
"0.6163545",
"0.61629766",
"0.6162304",
"0.61614406",
"0.6158906",
"0.6157125",
"0.61561114"
] | 0.7561395 | 1 |
Redirect to the requested page after signing in | def after_sign_in_path_for(resource)
session["user_return_to"] || root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_in_user\n unless signed_in?\n store_location #record url of intended page before redirect\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def redirect_to_login_page\n query_params = request.query_parameters\n query_params.merge!(return_to: request.path)\n\n target = cms_path(Homepage.default.login_page, query_params)\n\n redirect_to(target, alert: \"This page is protected. You either don't have neccessary access rights or you are not logged in.\")\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def sign_in_and_redirect!\n set_user_session_from_oauth\n set_user_cookie\n\n url = if params[:state] == \"popup\"\n Exvo::Helpers.auth_uri + \"/close_popup.html\"\n elsif params[:state] # if not popup then an url\n params[:state]\n else\n session[:user_return_to] || \"/\"\n end\n\n redirect_to url\n end",
"def logged_in_redirect\n if logged_in?\n flash[:err] = \"you are already logged in\"\n redirect_to root_path\n end\n end",
"def signed_in_user\n redirect_to root_url, alert: \"Action Unsuccessful, please sign in.\" unless signed_in?\n end",
"def redirect_to_appropriate_page_after_sign_in\n if params[:redirect_back_url]\n redirect_to params[:redirect_back_url]+\"?auth_token=#{@current_user.auth_token}\"\n else\n redirect_to default_redirect_url_after_sign_in\n end\n return\n end",
"def auth_user\n redirect_to new_user_session_url unless user_signed_in?\n end",
"def auth_after\n url = session[:auth_redirect] || root_path\n redirect_to url\n end",
"def redirect_signed_in_user\n redirect_to user_home_path if user_signed_in?\n end",
"def sign_in_and_redirect(resource_or_scope, *args); end",
"def log()\n if user_signed_in?\n else\n \tredirect_to \"http://localhost:3000/users/sign_in\"\n end\n end",
"def signed_in_user\n store_location #pour ensuite rediriger l'utilisateur vers la destination qu'il voulait avant\n # d'etre rediriger vers la pagne d'authentification\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def auth\n #redirect to login page unless already logged in\n redirect_to new_user_session_path, alert: \"You must login to access that page\" unless logged_in?\n end",
"def signed_in_user\n unless signed_in?\n store_location # for friendly forwarding\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def authenticate_user!\n if !signed_in?\n session[:user_return_to] = request.path if request.path\n redirect_to \"/auth/githubteammember\"\n end\n end",
"def redirect_if_signed_in\n if user_signed_in?\n redirect_to home_path\n end\n end",
"def user_signin_status\n unless user_signed_in?\n redirect_to root_url\n end\n end",
"def signed_in_user\n unless signed_in?\n # If not signed in, save current location in session object\n # to be able to redirect after successful sign in.\n session[:return_to] = request.url\n # prompt sign in page\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n redirect_to login_url, notice: \"Log in to continue\" unless signed_in?\n end",
"def signed_in_user\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def signed_in_user\n unless signed_in?\n # store friendly URL so we can redirect after signin (stored in session)\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def signin_required\n return if signed_in?\n session[:return_to] = request.path if request.path\n redirect_to \"/auth/twitter\"\n end",
"def after_sign_in_path_for(resource)\n redirect_to_home(resource)\n end",
"def authenticate_user\n redirect_to root_path unless signed_in?\n end",
"def signed_in_user\n\t store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to :signin, notice: \"Please sign in.\"\n end\n end",
"def redirect_to_user_page\n if teacher_signed_in?\n redirect_to :controller => 'search'\n elsif volunteer_signed_in?\n redirect_to :controller => 'conversations'\n end\n end",
"def signed_in\n if not myEmail\n session[:auth_redirect] = request.path\n redirect_to '/auth/google_oauth2'\n else\n log_click\n end\n end",
"def user_authenticated\n redirect_to root_url, alert: 'You must be logged in to go here' unless current_user\n end",
"def login_checkpoint\n redirect to '/' if !logged_in?\n end",
"def redirect\n\t\trender 'sessions/new'\n\tend",
"def auth_user\n redirect_to new_user_registration_url unless user_signed_in?\n end",
"def authorize\n return if session[:user_id]\n flash[:notice] = \"Please log in\"\n session[:jumpto] = request.parameters\n redirect_to(:controller => \"/login\", :action => \"index\")\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def sign_in\n if cookies[ :user_id ] != nil\n redirect_to :action => \"index\" ,:controller => \"homepage\"\n end\n render layout: false\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to( signin_url, notice: \"Please sign in.\" )\n end\n end",
"def signed_in_user\n\n\t\t# If check to see if user is signed in\n \tunless signed_in?\n\n \t\t# Store the last the requested action and store it\n \t\tstore_location\n\n \t\t# Redirect to the signin url with notice to signin\n \t\tredirect_to signin_url, notice: \"Please sign in.\"\n \tend\n \tend",
"def logged_in_user\n return if logged_in?\n store_location\n redirect_to sessions_new_path, alert: 'Please log in.'\n end",
"def signin\n sign_out\n redirect_to '/users/sign_in'\n end",
"def redirect_if_logged_in\n if logged_in?\n redirect \"/users/#{current_user.id}\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to root_path, notice: \"Please sign in.\"\n end\n end",
"def signIn_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n store_location\n redirect_to root_path, notice: \"Please sign in.\" unless signed_in?\n #we are adding an option to the redirect_to function which is a hash\n #it updates the flash[] hash\n end",
"def logged_in_user\n if user_signed_in? then\n \n else\n redirect_to root_path\n end \n \n end",
"def require_signin\n \tunless current_user\n # Stores the URL of the requested page in the session\n # before redirecting to the sign-in form.\n session[:intended_url] = request.url \n \t\tredirect_to new_session_url, alert: \"Please sign in first!\"\n \tend\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end\n end",
"def if_logged_in_redirect\n if logged_in?\n redirect_to current_user\n end\n end",
"def if_logged_in_redirect\n if logged_in?\n redirect_to current_user\n end\n end",
"def signon\n user = Account.find_by_name( params[ :acc_name ].strip )\n if !!( user && user.authenticate( params[ :password ].strip ))\n return_to = session[ :return_to ] || base_url\n reset_session\n session[ :current_user_id ] = user.id\n session[ :keep_base_open ] = user.keep_base_open\n redirect_to return_to\n else\n flash[ :alert ] = t( 'home.signon.error' )\n redirect_to home_url\n end\n end",
"def ensure_signed_in!\n return if signed_in?\n\n flash[:info] = 'You need to sign in to continue.'\n redirect_to sign_in_path return: request.path\n end",
"def signed_in_user\r\n unless signed_in?\r\n store_location\r\n redirect_to signin_url, notice: \"Please sign in.\"\r\n end\r\n end",
"def require_signin\n # If the user is not signed in:\n unless signed_in?\n # Calls the store_location method to save the url the unsigned in user was trying to navigate to:\n store_location\n # Establishes an error to display:\n flash[:error] = \"You must be signed in to reach that page.\"\n # Sends the unsigned in user to the sign in page.\n redirect_to signin_path\n end\n end",
"def custom_user_sign_in\n if current_user.nil?\n session[:return_location] = request.referrer\n redirect_to new_user_session_path\n else\n redirect_to request.referrer || root_path\n end\n end",
"def signed_in_user\n\t\tunless signed_in?\n\t\t\tstore_location\n\t\t\tredirect_to signin_url, notice: \"You have to be logged in to do this\"\n\t\tend\n\tend",
"def failure\n puts \"----------error with sign in\"\n redirect_to root_path\n end",
"def access_sign_in_page\n\t\t@browser.goto(@sign_in_url)\n\tend",
"def redirect_if_logged_in\n redirect_to root_path if logged_in?\n end",
"def redirect_to_login\n\n redirect_to('/login')\n\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n current_user # redirects to a user's show page\n end",
"def logged_in_user\n unless logged_in?\n store_url_destination\n flash[:danger] = \"please log in.\"\n redirect_to login_path\n end\n end",
"def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n return render unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n # Render...\n end\n end",
"def logged_in_user\n unless logged_in?\n redirect_to root_url\n end\n end",
"def sign_in2\n redirect_to :action => \"sign_in\" ,:controller => \"user_log\"\n end",
"def signed_in_user\n\t\t\tredirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n\t\tend",
"def logged_in_account\n return if logged_in?\n session[:forwarding_url] = request.original_url if request.get?\n flash[:error] = t('sessions.please_log_in')\n redirect_to new_account_session_url\n end",
"def authenticate_user\n# save current page for redirection after login\n redirect_to controller: :user, action: :login unless logged_in? \n current_user\n end",
"def signin\n if doctor_signed_in?\n redirect_to doctor_path(current_doctor)\n end\n end",
"def authenticate\n return redirect_to(sign_in_url) unless signed_in?\n end",
"def authenticate_user\n if !user_logged_in?\n # Store current url path for future reference\n store_location\n # Redirect to home page with error flash\n flash[:error] = \"Please Signin to access this page\"\n redirect_to root_path\n end\n end",
"def require_signin\n unless signed_in?\n store_location\n flash[:error] = \"Please sign in to continue\"\n redirect_to signin_url\n end\n end",
"def login_and_redirect(user)\n log_in user\n flash[:success] = 'Logged in with Auth0!'\n redirect_back_or user\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n\n return render layout: 'new' unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n return render layout: 'new'\n end\n end",
"def redirect_unless_signed_in\n unless signed_in?\n flash[:notice] = \"You must be logged in to access #{request.fullpath}\"\n redirect_to users_path\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n flash[:error] = \"Please sign in.\"\n redirect_to signin_url \n end\n end",
"def redirect_if_not_logged_in\n if !logged_in?\n flash[:errors] = \"You must be logged in to view the page \"\n redirect '/'\n end\n end",
"def authorize_page\n if (params[:id] == 'dashboard' or params[:id] == 'welcome') and current_user.nil?\n session[:next] = request.fullpath\n puts session[:next]\n redirect_to new_user_session_path, alert: _(\"You have to log in to continue.\")\n end\n end",
"def check_session\n if session[:user_id].nil?\n session[:return_to] = request.request_uri\n flash[:messgae] = \"Please sign-in or sign-up to access any of these pages.\"\n redirect_to :controller => 'user', :action => 'index'\n return\n end\n end",
"def auth_success_redirect(path = nil, user: nil, message: nil, **opt)\n set_flash_notice(message, **opt) if message.present?\n path ||= after_sign_in_path_for(user || resource)\n redirect_to path\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"You must be signed in to perform this action.\" \n end\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'Please log in first'\n render 'sessions/new', status: :unauthorized\n true # return true to indicate that this triggered things\n end",
"def login_first\n redirect_to account_login_path(dest: (params[:dest] || request.path))\n end",
"def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end",
"def authorize_redirect\n \tif session[:user_id]\n\t\tredirect_to :controller => 'home'\n \tend\n end",
"def signed_in_user\n\t\tunless signed_in?\n\t\t\tstore_location\n\t\t\tredirect_to signin_url \n\t\t\tflash[:success] = \"Please sign in.\"\n\t\tend\n\tend",
"def signed_in_user\n unless signed_in?\n #store_location\n flash.now[:error] = \"Please sign in to view that page.\"\n flash.keep\n redirect_to :back\n end\n end",
"def redirect_if_logged_in\n if logged_in?\n redirect \"/users/#{current_user.id}\"\n end\n #def redirect_if_logged_in_as_someone_else\n #end\n end",
"def require_signin\n unless signed_in?\n store_location\n flash[:error] = 'Please sign in.'\n redirect_to signin_url\n end\n end",
"def show\n if not signed_in?\n redirect_back_or signin_path\n end\n end",
"def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end",
"def set_sign_in_redirect\n if (hash = params[:x_return_to]).present?\n session[:user_return_to] =\n \"#{request.protocol}#{request.host_with_port}/##{hash}\"\n end\n end",
"def set_sign_in_redirect\n if (hash = params[:x_return_to]).present?\n session[:user_return_to] =\n \"#{request.protocol}#{request.host_with_port}/##{hash}\"\n end\n end"
] | [
"0.77445614",
"0.77366",
"0.7609968",
"0.7609968",
"0.75382936",
"0.74867225",
"0.7486445",
"0.74856937",
"0.7472128",
"0.7458721",
"0.74527425",
"0.74393165",
"0.7435305",
"0.743511",
"0.7415627",
"0.73916644",
"0.7382576",
"0.7370469",
"0.7355671",
"0.73350877",
"0.7327652",
"0.73183995",
"0.7316649",
"0.73155165",
"0.7309671",
"0.73058593",
"0.7293308",
"0.7291646",
"0.7291572",
"0.72636646",
"0.7253427",
"0.72345364",
"0.72288644",
"0.7227368",
"0.7226735",
"0.72231215",
"0.7222991",
"0.72214246",
"0.72214246",
"0.7213046",
"0.7207059",
"0.72028553",
"0.71981484",
"0.7192952",
"0.7187382",
"0.71632785",
"0.7160518",
"0.7156971",
"0.71494895",
"0.71491957",
"0.71421564",
"0.71376604",
"0.71376604",
"0.7133495",
"0.71301484",
"0.7111022",
"0.7108948",
"0.7108727",
"0.70959264",
"0.7090736",
"0.7088668",
"0.70874053",
"0.70873207",
"0.70765144",
"0.70765144",
"0.70765144",
"0.7062861",
"0.70580786",
"0.70574194",
"0.70568836",
"0.7054619",
"0.7046967",
"0.70417583",
"0.7041706",
"0.70379144",
"0.70299673",
"0.70294267",
"0.702681",
"0.7024051",
"0.70178485",
"0.70178485",
"0.70169383",
"0.7014468",
"0.7013947",
"0.7010352",
"0.700917",
"0.7004843",
"0.7003471",
"0.69997674",
"0.69991475",
"0.6998351",
"0.6993903",
"0.69892687",
"0.69891185",
"0.6983925",
"0.69804823",
"0.6974156",
"0.69703925",
"0.69702727",
"0.6969704",
"0.6969704"
] | 0.0 | -1 |
w konstruktorze wstrzykuejmy tutaj instancje Operations | def Calculate(x,y) do
#to mam nam zwrocic dwa stringi latexowe, tablica whatever gotowe do druku
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operations; end",
"def operations; end",
"def operation; end",
"def operation(*_)\n raise 'not implemented'\n end",
"def initialize(*arguments)\n @arguments = arguments\n @operations = []\n end",
"def create_op\n\t\t\tring = current_ring\n\t\t\top = (self.respond_to?(:op) && self.op || params[:op])\n\t\t\t#op = params[:op] unless self.respond_to? :op\n\t\t\toptions = op[:options] || {}\n\t\t\tresource,id,assoc = op['key'].split_kojac_key\n\t\t\tif model_class = KojacUtils.model_class_for_key(resource)\n\t\t\t\tif assoc # create operation on an association eg. {verb: \"CREATE\", key: \"order.items\"}\n\t\t\t\t\tif model_class.ring_can?(ring,:create_on,assoc.to_sym)\n\t\t\t\t\t\titem = KojacUtils.model_for_key(key_join(resource,id))\n\t\t\t\t\t\tma = model_class.reflect_on_association(assoc.to_sym)\n\t\t\t\t\t\ta_value = op[:value] # get data for this association, assume {}\n\t\t\t\t\t\traise \"create multiple not yet implemented for associations\" unless a_value.is_a?(Hash)\n\n\t\t\t\t\t\ta_model_class = ma.klass\n\t\t\t\t\t\tpolicy = Pundit.policy!(current_user,a_model_class)\n\t\t\t\t\t\tp_fields = policy.permitted_fields(:write)\n\t\t\t\t\t\tfields = a_value.permit( *p_fields )\n\t\t\t\t\t\tnew_sub_item = nil\n\t\t\t\t\t\tcase ma.macro\n\t\t\t\t\t\t\twhen :has_many\n\t\t\t\t\t\t\t\ta_model_class.write_op_filter(current_user,fields,a_value) if a_model_class.respond_to? :write_op_filter\n\t\t\t\t\t\t\t\tnew_sub_item = item.send(assoc.to_sym).create(fields)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\traise \"#{ma.macro} association unsupported in CREATE\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\tresult_key = op[:result_key] || new_sub_item.kojac_key\n\t\t\t\t\t\tmerge_model_into_results(new_sub_item)\n\t\t\t\t\telse\n\t\t\t\t\t\terror = {\n\t\t\t\t\t\t\tcode: 403,\n\t\t\t\t\t\t\tstatus: \"Forbidden\",\n\t\t\t\t\t\t\tmessage: \"User does not have permission for #{op[:verb]} operation on #{model_class.to_s}.#{assoc}\"\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\telse # create operation on a resource eg. {verb: \"CREATE\", key: \"order_items\"} but may have embedded association values\n\t\t\t\t\tif model_class.ring_can?(ring,:create)\n\t\t\t\t\t\tpolicy = Pundit.policy!(current_user,model_class)\n\t\t\t\t\t\tp_fields = policy.permitted_fields(:write)\n\n\t\t\t\t\t\t# see the 20171213-Permissions branch for work here\n\t\t\t\t\t\tp_fields = op[:value].reverse_merge!(policy.defaults).permit( *p_fields )\n\t\t\t\t\t\tmodel_class.write_op_filter(current_user,p_fields,op[:value]) if model_class.respond_to? :write_op_filter\n\t\t\t\t\t\titem = model_class.new(p_fields)\n\t\t\t\t\t\tpolicy = Pundit.policy!(current_user,item)\n\t\t\t\t\t\tforbidden! unless policy.create?\n\t\t\t\t\t\titem.save!\n\n\t\t\t\t\t\toptions_include = options['include'] || []\n\t\t\t\t\t\tincluded_assocs = []\n\t\t\t\t\t\tp_assocs = policy.permitted_associations(:write)\n\t\t\t\t\t\tif p_assocs\n\t\t\t\t\t\t\tp_assocs.each do |a|\n\t\t\t\t\t\t\t\tnext unless (a_value = op[:value][a]) || options_include.include?(a.to_s)\n\t\t\t\t\t\t\t\tcreate_on_association(item,a,a_value,ring)\n\t\t\t\t\t\t\t\tincluded_assocs << a.to_sym\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tforbidden! unless policy.create?\n\t\t\t\t\t\titem.save!\n\t\t\t\t\t\tresult_key = op[:result_key] || item.kojac_key\n\t\t\t\t\t\tmerge_model_into_results(item,result_key,:include => included_assocs)\n\t\t\t\t\telse\n\t\t\t\t\t\terror = {\n\t\t\t\t\t\t\tcode: 403,\n\t\t\t\t\t\t\tstatus: \"Forbidden\",\n\t\t\t\t\t\t\tmessage: \"User does not have permission for #{op[:verb]} operation on #{model_class.to_s}\"\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\terror = {\n\t\t\t\t\tcode: 501,\n\t\t\t\t\tstatus: \"Not Implemented\",\n\t\t\t\t\tmessage: \"model class not found\"\n\t\t\t\t}\n\t\t\tend\n\t\t\tresponse = {\n\t\t\t\tkey: op[:key],\n\t\t\t verb: op[:verb],\n\t\t\t}\n\t\t\tif error\n\t\t\t\tresponse[:error] = error\n\t\t\telse\n\t\t\t\tresponse[:results] = results\n\t\t\t\tresponse[:result_key] = result_key\n\t\t\tend\n\t\t\tresponse\n\t\tend",
"def ops!\n @ops\n end",
"def operation(code, size, name, time, desc = nil, &block)\n inst = Operation.new(code, size, name, time, desc, &block)\n @operation_by_code[inst.code] = inst \n @operation_by_name[inst.name.downcase.to_sym] = inst\n end",
"def start_operation(op_name)\n end",
"def op; end",
"def operation_class\n Clowne::Utils::Operation\n end",
"def initialize(ops = [OP_DOUBLE, OP_HALVE, OP_ADD_TWO])\n @ops = ops\n end",
"def operation\n @op_notifier = Notifier.new\n Operation.new(self)\n end",
"def define_instance_operation(operation, *options)\n options = options.extract_options!\n params = prepare_params(options)\n\n instance_operation_module.module_eval <<-RUBY_EVAL, __FILE__, __LINE__+1\n def #{operation.to_s.snakecase}(#{params.join(',')})\n self.class.#{operation.to_s.snakecase} #{params.join(',').chomp(' = {}')}\n end\n RUBY_EVAL\n end",
"def operations\n @operations\n end",
"def agc_2(operador)\n @pOper << operador\nend",
"def construct\n end",
"def initialize\n super\n # Default operators\n @evaluator = Evaluator.new self\n @expressor = Expressor.new self\n @evolver = Evolver.new self\n end",
"def initialize(estacion) #SpaceStation\n super(estacion)\n end",
"def initialize(name)\n @name = name\n @nota\n #declaracion v instancia\n end",
"def initialize\n\t\t@operands = []\n\tend",
"def op(*args, &block)\n Operation.new(*args, &block)\n end",
"def operation\n @component.operation\n end",
"def oper\n return @oper\n end",
"def initialize (name) #actions qui s'exécuteront dès lors de la création d'une nouvelle instance\r\n\t\t@name = name\r\n\t\t@life_points = 10 #n'est pas prit en argument dans la méthode car a une valeur fixe\r\n\tend",
"def define_class_operation(operation, *options)\n options = options.extract_options!\n params = prepare_params(options)\n\n class_operation_module.module_eval <<-RUBY_EVAL, __FILE__, __LINE__+1\n def #{operation.to_s.snakecase}(#{params.join(',')})\n req_hash = {\n #{params.select{|p| p != 'locals = {}'}\n .map{|p| \"'#{params_key(p)}' => #{p}\"}\n .join(',')}\n }\n locals ||= {}\n client.call #{operation.inspect}, :message => locals.merge(req_hash)\n end\n RUBY_EVAL\n end",
"def oper=(value)\n @oper = value\n end",
"def operations\n operation_classes.each_with_object({}) do |operation, hash|\n hash[operation.key] = operation.new\n end\n end",
"def create_operation(data)\n puts \"Importing Operation #{data[:invoice_num]}\"\n Operation.find_or_create_by(company_id: find_company_id(data[:company]),\n invoice_num: data[:invoice_num],\n invoice_date: parse_date(data[:invoice_date]),\n operation_date: parse_date(data[:operation_date]),\n amount: data[:amount] || 1.0,\n reporter: data[:reporter],\n notes: data[:notes],\n status: data[:status],\n kind: data[:kind] \n )\n end",
"def initialize\n\t\t\n\tend",
"def initialize(operation)\n @operation = operation\n @database = operation.database\n end",
"def create\n @operation = Operation.new(operation_params)\n\n respond_to do |format|\n if @operation.save\n format.html { redirect_to admin_operations_path, notice: 'Operation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @operation }\n else\n format.html { render action: 'new' }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_operations_processor\n JSONAPI::ActiveRecordOperationsProcessor.new\n end",
"def set_operation\n @operation = Operation.find(params[:id])\n end",
"def set_operation\n @operation = Operation.find(params[:id])\n end",
"def set_operation\n @operation = Operation.find(params[:id])\n end",
"def set_operation\n @operation = Operation.find(params[:id])\n end",
"def set_operation\n @operation = Operation.find(params[:id])\n end",
"def set_operation\n @operation = Operation.find(params[:id])\n end",
"def set_operation\n @operation = Operation.find(params[:id])\n end",
"def operation\n nil\n end",
"def mi_carrera\n\n\tend",
"def operation\n @operation ||= operation_class.new(current_user, params_for_action)\n end",
"def initialize(*args)\n\tsuper\n\t@action = :add\nend",
"def define_operations\n @info.operations.each do |op| \n self.class.__send__(:define_method, op.name) do |*params|\n jargs, jtypes = java_args(op.signature, params)\n @server.invoke @object_name, op.name, jargs, jtypes\n end\n end\n end",
"def initialize(nombre,peso,talla,edad,sexo,imc,estados,rcc,rcca) #constructor\n super(nombre,peso,talla,edad,sexo,imc,estados,rcc,rcca)\n end",
"def constructor; end",
"def initialize(op_data = {})\n @@log.debug {\"Node Element Initialized with: #{op_data.inspect}\"} if @@log.debug?\n \n #set the module with the operation definition and include them\n @ops_set_module = op_data[:op_sets_mod] ||DefaultOpSets\n self.class.__send__(:include, @ops_set_module) #why is this private? am I doing something wrong?\n \n #set the mapping between fields and the type of operations supported by those fields\n @field_op_set_sym = DefaultFieldOpSet.merge(op_data[:field_op_set] || {})\n @@log.info {\"Field Operations Set: #{@field_op_set_sym.inspect}\"} if @@log.info?\n @field_op_defs = get_field_op_procs(@field_op_set_sym)\n \n #set the key fields that will work as node/record identifiers or other key fields\n @key_fields = op_data[:key_fields]||DefaultKeyFields\n raise \"key_fields are required\" unless @key_fields\n\n #we are no longer differentiating between keys required for insantiation and persistence\n #this can be added in the future easily though.\n @required_instance_keys = @key_fields[:required_keys]\n @required_save_keys = @key_fields[:required_keys]\n @node_key = @key_fields[:primary_key]\n @views = default_views(@field_op_set_sym) #TODO: Allow custom views in the future\n end",
"def initialize\n \n end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApiMultiemisor\n Facturama::FacturamaApiMulti.new(facturama_user,facturama_password,is_development)\n end",
"def operation_method\n raise 'Not implemented!'\n end",
"def suivre; end",
"def initialize(numero, titular, saldo)\n @numero = numero#variavel de instacia\n @titular = titular\n @saldo = saldo\n end",
"def initialize(nombre,peso,talla,edad,sexo,imc,estados,rccm,rcca) #constructor\n @peso = peso\n @talla = talla\n\t@edad = edad\n\t@sexo = sexo\n\t@nombre = nombre\n\t@imc = imc\n\t@estados = estados\n\t@rccm = rccm\n\t@rcca = rcca\n end",
"def zuruecksetzen()\n end",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def build_operation(options = {})\n double(:operation, {\n execute: true,\n metadata: {},\n trailing_metadata: {},\n deadline: Time.now.to_i + 600,\n cancelled?: false,\n execution_time: rand(1_000..10_000)\n }.merge(options))\n end",
"def build_operation(options = {})\n double(:operation, {\n execute: true,\n metadata: {},\n trailing_metadata: {},\n deadline: Time.now.to_i + 600,\n cancelled?: false,\n execution_time: rand(1_000..10_000)\n }.merge(options))\n end",
"def operation(_name)\n raise Orocos::NotFound, \"#operation is not implemented in #{self.class}\"\n end",
"def operation\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end",
"def initialize(params={})\n super(OPERATION_INPUT, params)\n end",
"def create\n @operadore = Operadore.new(operadore_params)\n\n respond_to do |format|\n @operadore.OP_FECHAACTIVO=current_admin.last_sign_in_at\n\n if @operadore.save\n format.html { redirect_to operadores_url, notice: 'Operadore Se creó correctamente.' }\n format.json { render :index, status: :created, location: @operadore }\n else\n format.html { render :new }\n format.json { render json: @operadore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def operations\n @operations.dup\n end",
"def operations\n @operations.dup\n end",
"def create\n @operation = Operation.new(operation_params)\n\n respond_to do |format|\n if @operation.save\n format.html { redirect_to @operation, notice: 'Operation was successfully created.' }\n format.json { render :show, status: :created, location: @operation }\n else\n format.html { render :new }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @operation = Operation.new(operation_params)\n\n respond_to do |format|\n if @operation.save\n format.html { redirect_to @operation, notice: 'Operation was successfully created.' }\n format.json { render :show, status: :created, location: @operation }\n else\n format.html { render :new }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize(operator, less)\n @operator = operator \n @less = less\n end",
"def code_of_conduct; end",
"def new\n @operating = Operating.new\n\n end",
"def operation(name, opts = {}, &block)\n raise DuplicateOperationException if @operations[name]\n @operations[name] = Operation.new(self, name, opts, &block)\n end",
"def initialize\r\n\r\n end",
"def cops; end",
"def cops; end",
"def cops; end",
"def new\n @calculator = Calculator.new\n\n end",
"def initialize() end",
"def initialize(name) # aqui ionicializamos nuestro contructor ahora que instanciemos un objeto este ira primero aqui \n @nombre = name #esta es una variable de instancia \n end",
"def operation(name, &block)\n unless op = @operations.find { |op| op.name == name }\n op = Operation.new(name, &block)\n @operations << op\n else\n op.instance_eval(&block) if block_given?\n end\n op\n end",
"def initialize(operator)\n @operator = operator\n end",
"def initialize(operator)\n @operator = operator\n end",
"def initialize(nombre,edad) #--> se crean los metodos, y se inicializan para darles un valor al crear el objeto \n @nombre = nombre #-->la variable local nombre es asignada a la var. de instancia @nombre, al realizar esto cada instancia tendra un valor propio.\n @edad = edad #--> lo mismo para edad\n\nend",
"def initialize()\n\t\tend",
"def initialize(nome) #inicializando os atributos\n self.saldo = 0.0\n self.nome = nome\n end",
"def create\n @operact = Operact.new(operact_params)\n\n respond_to do |format|\n if @operact.save\n format.html { redirect_to @operact, notice: 'Operact was successfully created.' }\n format.json { render :show, status: :created, location: @operact }\n else\n format.html { render :new }\n format.json { render json: @operact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def operator; end",
"def initialize(op, lhs, rhs)\n @args = [lhs, rhs]\n @op = op\n end",
"def initialize(*args)\n super\n @action = :add\nend",
"def initialize(ops={})\n\t\t\t#\tfor the readers\n\t\t\t#\tnot necessary, but polite\n\t\t\tops.each do |k, v|\n\t\t\t\tinstance_variable_set \"@#{k}\".to_sym, v\n\t\t\tend\n\n\t\t\traise Error.new(\"you must provide an Access Token\") unless self.token\n\t\tend",
"def op()\n @model.op\n end",
"def command_factory\n end",
"def call\n\n\tend",
"def call\n\n\tend",
"def construir_ruta(a, b)\n # ...\n\n puts 'Context: Definiendo ruta con la estrategia (no estoy seguro cual es)'\n @estrategia.algoritmo(a, b)\n\n # ...\n end",
"def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end",
"def AddOperation(args)\n args.name = args.type if args.name == ''\n args.name = namespace + '/' + args.name if namespace != ''\n op = graph.AddOperation(args)\n end",
"def initialize(*)\n super\n @predicate = Function.optimize_operand(operation.predicate)\n end"
] | [
"0.7389176",
"0.7389176",
"0.7280533",
"0.6439976",
"0.6423605",
"0.637093",
"0.63459337",
"0.6324426",
"0.63140833",
"0.6234913",
"0.6197272",
"0.6165209",
"0.61507326",
"0.60896325",
"0.6044825",
"0.60376865",
"0.60286343",
"0.5997621",
"0.5967049",
"0.5941537",
"0.59336364",
"0.5906054",
"0.5838087",
"0.5829322",
"0.5828248",
"0.5827815",
"0.58139783",
"0.58111763",
"0.57931226",
"0.57790554",
"0.57777566",
"0.5765813",
"0.5752814",
"0.5746009",
"0.5746009",
"0.5746009",
"0.5746009",
"0.5746009",
"0.5746009",
"0.5746009",
"0.5737868",
"0.5725106",
"0.5723151",
"0.5713762",
"0.56878567",
"0.56852895",
"0.56770605",
"0.5671172",
"0.56535995",
"0.56432635",
"0.56373304",
"0.563627",
"0.5631595",
"0.56206053",
"0.56135666",
"0.5610679",
"0.5610679",
"0.5609774",
"0.5609774",
"0.56023306",
"0.5595176",
"0.559356",
"0.55841714",
"0.5581409",
"0.5581409",
"0.5572532",
"0.55716854",
"0.55694616",
"0.55694616",
"0.55694616",
"0.55694616",
"0.55684286",
"0.55672234",
"0.5562934",
"0.5548053",
"0.55448604",
"0.5542226",
"0.5542226",
"0.5542226",
"0.5539322",
"0.55268717",
"0.55240226",
"0.55166155",
"0.55163115",
"0.55163115",
"0.55110985",
"0.55000967",
"0.5493577",
"0.54823875",
"0.54813004",
"0.5472118",
"0.54707104",
"0.5469535",
"0.5465574",
"0.54645497",
"0.5460155",
"0.5460155",
"0.54579455",
"0.54520494",
"0.5435902",
"0.543251"
] | 0.0 | -1 |
If you need authentication logic, assign a Proc to Garage.docs.configuration.docs_authorization_method. Example: Garage.docs.configuration.docs_authorization_method do |args| if name.start_with?("admin_") args[:user].admin? else true end end | def visible_to?(user)
if method = Garage.configuration.docs.docs_authorization_method
method.call(document: self, user: user)
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorization(*args, &block); end",
"def authorize(verb); send_or_default(\"authorize_#{verb}\",true) ; end",
"def authenticate_active_admin_user\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n send(active_admin_namespace.authentication_method) if active_admin_namespace.authentication_method\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n end",
"def method_missing(meth, *args, &block)\n if meth.to_s =~ /^(\\w*)\\?$/\n if %w(auto_create_users auto_update_users enabled fake_ichain_server keep_standard_login logout_of_ichain_on_logout match_also_by_mail).include? $1\n setting($1) == \"true\"\n else\n super\n end\n else\n super\n end\n end",
"def authorization; end",
"def admin?\n if role == \"admin\"\n return true\n end\nend",
"def method_missing(*args)\n method_name = args.first.to_s\n if method_name=~/is_.*[?]/\n roles = method_name.gsub(/is_(.*)[?]/, \"\\\\1\")\n roles.split(\"_or_\").each do |role|\n return name.underscore==role\n end\n elsif method_name=~/has_.*[?]/\n controller = args.second\n action = method_name.gsub(/has_(.*)[?]/, \"\\\\1\")\n return has_permission(controller, action)\n else\n super(*args)\n end\n end",
"def is_admin?\n true if admin_rights == \"true\"\n end",
"def authorize?(person)\n person.is_admin?\n end",
"def isAdmin\n \n end",
"def authenticate_admin!\n current_user.is_admin? \n end",
"def is_admin\n test_access :admin\n end",
"def documentation_authorizer\n @documentation_authorizer ||= Documentation.config.authorizer.new(controller)\n end",
"def authorise\n tmp_permission = @object_to_route_to.permission?\n if tmp_permission == \"yes\"\n permision_name = @pdt_method.method_name\n return @env.authorise(extract_actual_program_name(@pdt_method.program_name),permision_name,@user)\n elsif tmp_permission == nil\n return true\n else\n permision_name = tmp_permission\n return @env.authorise(extract_actual_program_name(@pdt_method.program_name),permision_name,@user)\n end\n\n end",
"def host_authorization; end",
"def host_authorization; end",
"def verify_admin\n :authenticate_user!\n have_no_rights('restricted area') unless current_user.isAdmin?\nend",
"def authorize?(user)\n user && user.admin?\n end",
"def admin?; current_user.admin?; end",
"def admin?; current_user.admin?; end",
"def authorize_admin\n\t\tauthorize( ADMIN_USER_LEVEL ) \n\tend",
"def authorization_mode; end",
"def authorize_admin!\n authorize! :manage, :all\n end",
"def admin? \n role == 'admin'\n end",
"def run\n case\n when args.first =~ /authorize/i\n authorize\n else\n usage\n end\n end",
"def admin?\n role == \"admin\"\n end",
"def access_control\n \n end",
"def is_admin?\n admin\n end",
"def is_admin?\n admin\n end",
"def auth(args)\r\n auth_method = args.fetch(:type, :standard)\r\n standard_auth(args) if auth_method == :standard\r\n end",
"def authorized?\n current_user.login == \"Admin\"\n end",
"def authorize \n self.make 'authorization' \n end",
"def admin?\n role?('admin')\n end",
"def authorize_user_on(lmda)\n\t\tcurrent_user = get_user_by_token\n\t\trender_unauthorized_msg unless current_user && lmda.call(current_user)\n\tend",
"def is_admin?\n (self.role =~ /admin/) == 0 ? true : false\n end",
"def authorized?(**args)\n true\n end",
"def check_if_should_be_admin\n end",
"def authorize?(_user)\n true\n end",
"def authorize?(_user)\n true\n end",
"def only_authorize_admin!\n authorize!(is?(:admin))\n end",
"def admin?\n name == 'admin'\n end",
"def auth_enabled?\n if auth = ENV['AUTH']\n auth == 'auth'\n else\n $mongo_client ||= initialize_scanned_client!\n begin\n $mongo_client.use(:admin).command(getCmdLineOpts: 1).first[\"argv\"].include?(\"--auth\")\n rescue => e\n e.message =~ /(not authorized)|(unauthorized)|(no users authenticated)|(requires authentication)/\n end\n end\nend",
"def admin_access?\n admin?\n end",
"def admin?\n self.role.downcase == \"admin\"\n end",
"def admin?\n self.role.downcase == \"admin\"\n end",
"def superadmin #all admin roles need to include this method.\n role.name == \"admin\"\n end",
"def authorized?\n\n return false unless current_user\n\n %w{ show index }.include?(action_name) || current_user.is_admin?\n end",
"def auth_methods; end",
"def allowed?(method:, by: nil, action: '')\n case by&.role_id\n when ROLE_ID[:admin]\n true\n else\n false\n end\n end",
"def authorized?\n true\n end",
"def admin?\n permissions == 'admin'\n end",
"def admin?\n role == 'admin'\n end",
"def admin?\n role == 'admin'\n end",
"def is_admin?\n admin?\n end",
"def admin_or_curator?\n self.admin? || self.curator?\n end",
"def authorize_with_policy_method(name)\n @authorize_with_policy_method_name = name\n end",
"def is_admin\n admin?\n end",
"def w000thenticate_admin!\n check_token\n authenticate_user!\n raise AbstractController::ActionNotFound unless current_user.admin?\n end",
"def authorization_required\n case action_name.to_s\n when /index/, /show/ then list_authorized?\n when /create/ then create_authorized?\n when /update/ then update_authorized?\n when /destroy/ then delete_authorized?\n end\n false\n end",
"def admin?\n role.to_s == \"admin\"\n end",
"def administrator?\n admin?\n end",
"def authorize\n end",
"def authorize\n end",
"def admin?; false end",
"def customize_authorized?\n authorized_for?(:action => :read)\n end",
"def authorized?(data=nil)\n auth = Rack::Auth::Basic::Request.new(request.env)\n\n auth.provided? && auth.basic? && auth.credentials &&\n (conf.auth[:logic] || ->(data, u, p) {\n %w(admin password) == [u, p]\n }).(data, *auth.credentials)\n end",
"def admin?\r\n has_role?(\"admin\")\r\n end",
"def authorize(required_role)\n self.send required_role.to_sym\n end",
"def user_permission(singed_in, admin, paid, cancelled)\n\tif paid == \"no\" or cancelled == \"yes\"\n\t\tputs(\"go away\")\n\telsif signed_in == \"yes\" and admin == \"yes\"\n\t\tputs(\"You can see and change all the pages!\")\t\n\telsif signed_in == \"yes\" and admin == \"no\"\n\t\tputs(\"You can see all the pages!\")\n\telsif singed_in == \"no\" and admin == \"no\"\t\n\t\tputs(\"You can't see any of the pages, please sign in!\")\nend\nend",
"def admin?\n has_role? :admin\n end",
"def admin?\n self.role == 'Admin'\n end",
"def admin_authorize\n unless admin?\n unauthorized_access\n end\n end",
"def any_action?\n admin?\n end",
"def admin?\n self.role == 'admin'\n end",
"def admin?\n self.role == 'admin'\n end",
"def admin?\n self.role == 'admin'\n end",
"def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end",
"def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end",
"def superadmin_authenticate\n authorize current_user, :superadmin?\n end",
"def grifter_authenticate_do\n auth_methods = self.singleton_methods.select { |m| m =~ /grifter_authenticate$/ }\n auth_methods.each do |m|\n Log.debug \"Executing a grifter_authentication on method: #{m}\"\n self.send(m)\n end\n end",
"def is_admin?\n role == 'admin'\n end",
"def is_admin?\n role == 'admin'\n end",
"def is_admin?\n role == 'admin'\n end",
"def authen_method_guest!()\n @authen_method = TAC_PLUS_AUTHEN_METH_GUEST\n end",
"def admin?\n user.admin?\n end",
"def admin?\n admin\n end",
"def authorize_admin!\n redirect_to home_path unless current_user&.admin\n end",
"def is_admin?\n is_admin == 1\n end",
"def admin?\n role == 1\n end",
"def admin_section?\n params[:controller].starts_with?('admin')\n end",
"def needs_authorization?\n true\n end",
"def is_admin?\n self.role =~ /patissier/\n end",
"def authorize?(user)\n true\n #user.login == \"administrador\"\n end",
"def authen_method_enable!()\n @authen_method = TAC_PLUS_AUTHEN_METH_ENABLE\n end",
"def show\n authorize @adoc_name\n end",
"def admin?\n return self.role == \"admin\"\n end",
"def admin?\n return self.role == \"admin\"\n end",
"def authorized?\nlogged_in?\nend",
"def require_admin\n grant_access?(\"index\", \"users\")\n #position?('admin')\n end",
"def has_admin_access?\n admin? || moderator?\n end"
] | [
"0.6274595",
"0.6235718",
"0.604033",
"0.5928822",
"0.5925991",
"0.5876786",
"0.58731234",
"0.585014",
"0.58410597",
"0.5792424",
"0.5775368",
"0.5748071",
"0.5746015",
"0.5719865",
"0.5708999",
"0.5708999",
"0.5708038",
"0.56924105",
"0.5685736",
"0.5685736",
"0.5641049",
"0.56371075",
"0.5623304",
"0.5579903",
"0.55778253",
"0.5575697",
"0.5575202",
"0.5571913",
"0.5571913",
"0.55658984",
"0.55609757",
"0.55594206",
"0.5551122",
"0.5550407",
"0.55482304",
"0.5547135",
"0.55459",
"0.5545157",
"0.5545157",
"0.5539852",
"0.5537382",
"0.55369765",
"0.553387",
"0.55295277",
"0.55295277",
"0.5526349",
"0.5522051",
"0.55206406",
"0.55191284",
"0.5518996",
"0.5517019",
"0.5513184",
"0.5513184",
"0.5504642",
"0.5499168",
"0.5485231",
"0.5480339",
"0.54797876",
"0.5467483",
"0.5466635",
"0.5464392",
"0.5456143",
"0.5456143",
"0.54531676",
"0.54525864",
"0.5452027",
"0.5439196",
"0.5432278",
"0.54279584",
"0.5420268",
"0.54194355",
"0.5412414",
"0.541071",
"0.5409178",
"0.5409178",
"0.5409178",
"0.5401963",
"0.5401963",
"0.54015046",
"0.53974336",
"0.53925425",
"0.53925425",
"0.53925425",
"0.5392352",
"0.5390373",
"0.5387623",
"0.5383693",
"0.53829765",
"0.53810966",
"0.53755045",
"0.53697246",
"0.5366039",
"0.5363972",
"0.53624666",
"0.5356753",
"0.5346748",
"0.5346748",
"0.5345464",
"0.53447527",
"0.53438646"
] | 0.5662296 | 20 |
validate :origin_complete validate :destination_complete | def build_email_content
txt = I18n.t("estimate_request.fltk.email_content", :origin => self.origin_port.name, :destination => destination_port.name, :count => self.estimate_items.first.number_of_items, :description => self.estimate_items.first.description)
txt
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validation_origin_destination\n errors.add(:base,\"Origin and Destination must be different\") if locale_origin_id == locale_destination_id # Rails3 slightly different?\n end",
"def ensure_valid_origin_and_destination(player)\n reset_origin_and_destination\n ensure_valid_origin(player) until !@origin.nil? && valid_coordinate?(@origin)\n ensure_valid_destination(player) until !@destination.nil? && valid_coordinate?(@destination)\n end",
"def validate_source_destination(object)\n\t\t\treturn if object.nil?\n\t\t\treturn false if object.class.to_s != \"PetriNet::Place\" and object.class.to_s != \"PetriNet::Transition\"\n\n\t\t\treturn if @source.nil? or @source.class.to_s == object.class.to_s\n\t\t\treturn if @destination.nil? or @destination.class.to_s == object.class.to_s\n\t\t\treturn true\n\t\tend",
"def validates_libs_destinations_id\n self.type == 'destination'\n end",
"def is_valid?(_destination)\n raise NotImplementedError, \"Must be able to detect if a move is valid!\"\n end",
"def validate\n assert_present :source_target_id\n assert_present :source_target_class\n assert_present :dest_target_id\n assert_present :dest_target_class\n assert_present :source_entity_id\n end",
"def path_validator(the_board,origin_arr,destination_arr)\n\t\tif horizontal_direction(origin_arr,destination_arr)\n\t\t\tvalidity = path_validator_horizontal_vertical(the_board,origin_arr,destination_arr)\n\t\telsif diagonal_direction(origin_arr,destination_arr)\n\t\t\tvalidity = path_validator_diagonal(the_board,origin_arr,destination_arr)\n\t\tend\n\t\tvalidity\n\tend",
"def path_validator(the_board,origin_arr,destination_arr)\n\t\tif horizontal_direction(origin_arr,destination_arr)\n\t\t\tvalidity = path_validator_horizontal_vertical(the_board,origin_arr,destination_arr)\n\t\telsif diagonal_direction(origin_arr,destination_arr)\n\t\t\tvalidity = path_validator_diagonal(the_board,origin_arr,destination_arr)\n\t\tend\n\t\tvalidity\n\tend",
"def validate_from_and_to_state(from, to)\n unless successors.fetch(from, []).include?(to)\n raise InvalidTransitionError,\n \"Cannot transition from '#{from}' to '#{to}'\"\n end\n end",
"def valid?\n return false if @from.nil?\n return false if @to.nil?\n true\n end",
"def validate\n return false unless ( @graph.nodes.has_key? @source.name and @graph.nodes.has_key? @destination.name )\n true\n end",
"def validate\n if (start_date > end_date || (start_date == end_date && start_time >= end_time))\n errors.add(\"end_date\", I18n.t(\"tog_conclave.fields.errors.end_date_before_start_date\"))\n end\n loc = gg.locate self.venue_address rescue nil\n #errors.add(\"venue_address\", I18n.t(\"tog_conclave.fields.errors.venue_address_error\")) if loc.nil?\n end",
"def valid?\n if ( !@from )\n return false\n end\n if ( !@to )\n return false\n end\n if ( !@api_key )\n return false\n end\n if ( !from_does_not_equal_to )\n return false\n end\n return true\n end",
"def validate_other_church_info\n event_complete_validator = EventCompleteValidator.new(self)\n event_complete_validator.validate(baptized_catholic_validation_params)\n event_complete = church_address.validate_event_complete\n event_complete = propagate_errors_up(church_address, event_complete)\n rename_scanned_image_error_message(\n :scanned_certificate,\n I18n.t('errors.format_blank', attribute: I18n.t('activerecord.attributes.baptismal_certificate.certificate_picture'))\n )\n event_complete\n end",
"def process_validity_geocoords\n unless self.status == OrderStatusEnum::COMPLETED\n if self.lat && self.long\n if self.get_assigned_tour\n self.status = OrderStatusEnum::ASSIGNED\n else\n self.status = OrderStatusEnum::ACTIVE\n end\n else\n self.status = OrderStatusEnum::INVALID\n end\n end\n end",
"def validate\n #unless sources.length > 0\n # raise ControlError, \"Configuration must include one of the following for the source: #{source_types.join(',')}\"\n #end\n #unless destinations.length > 0\n # raise ControlError, \"Configuration must include one of the following for the destination: #{destination_types.join(',')}\"\n #end\n end",
"def create\n @destination = Destination.new(params[:destination])\n @roadmap = Roadmap.find(params[:roadmap_id])\n \n if not validate_permission(@roadmap)\n return\n end\n\n @destination.start_date = Converters::to_date(params[:destination][:start_date])\n @destination.end_date = Converters::to_date(params[:destination][:end_date])\n @destination.roadmap = @roadmap\n\t\t@destination.planned_cost = Converters::currency_to_number(params[:destination][:planned_cost])\n\n respond_to do |format|\n if @destination.save\n flash[:notice] = 'O destino foi criado com sucesso!'\n format.html { redirect_to(:controller => \"roadmaps\", \n\t\t\t\t\t\t\t\t\t\t\t:action => \"show\", \n\t\t\t\t\t\t\t\t\t\t\t:id => @destination.roadmap.id\n\t\t\t\t\t\t\t\t\t\t ) }\n format.xml { render :xml => @destination, :status => :created, :location => @destination }\n else\n # Recarrega os estados e cidades\n load_states_and_cities(@destination)\n @roadmap = @destination.roadmap\n @destinations =@roadmap.destinations\n @vehicles = Vehicle.all\n @destinations = @roadmap.destinations\n \n format.html { render :action => \"new\" }\n format.xml { render :xml => @destination.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def journey_complete?\n false\n end",
"def valid_move?(start_coords, end_coords)\n return false if end_coords.size == 0 # validate user input\n return true unless valid_move_chain(start_coords, end_coords).empty?\n false\n end",
"def validate_position(transition)\n newx, newy, newdir = transition.args\n valid = valid_coordinates?(newx, newy) && Directions.include?(newdir.to_s)\n throw :halt unless valid\n end",
"def validate_nonoverlapping\n end",
"def validate_user_complete_update\n\t\tself.complete = User::user_complete_validation(self)\n\tend",
"def validate\n\n if self[:from_coord].blank? && @possible_movers && @possible_movers.length > 1\n errors.add :notation, \"Ambiguous move #{notation}. Clarify as in Ngf3 or R2d4, for example\"\n return \n end\n\n if self[:notation] && ( self[:from_coord].blank? || self[:to_coord].blank? )\n errors.add :notation, \"The notation #{notation} doesn't specify a valid move\" and return \n end\n \n #ensure the validity of the coordinates we have whether specified or inferred\n [from_coord, to_coord].each do |coord|\n errors.add_to_base \"#{coord} is not a valid coordinate\" unless Chess.valid_position?( coord )\n end\n\n #verify allowability of the move\n \n errors.add_to_base \"No piece present at #{from_coord} on this board\" and return if !@piece_moving\n\n unless @piece_moving.allowed_moves(@board).include?( to_coord.to_sym ) \n errors.add_to_base \"#{@piece_moving.function} not allowed to move to #{to_coord}\" \n end\n\n #can not leave your king in check at end of a move\n #new_board= @board.consider_move( Move.new( :from_coord => from_coord, :to_coord => to_coord ) )\n #if new_board.in_check?( @piece_moving.side )\n # errors.add_to_base \"Can not place or leave one's own king in check - you may as well resign if you do that !\" \n #end\n\n end",
"def set_errors\n @errors = []\n \n if self.destination_id == nil || self.destination_id == \"\"\n @errors << \"Destination cannot be blank.\"\n end\n \n end",
"def valid?\n return false if @destination.nil?\n return false if @name.nil?\n return false if @query.nil?\n true\n end",
"def create\n @destination = Destination.new(destination_params)\n if @destination.valid?\n @destination.save\n redirect_to root_path\n else\n render :new, notice: 'Error in processing destination'\n end\n end",
"def is_complete?()\n return false if @name.nil? || @name.empty?\n return false if @url.nil? || @url.empty? \n return false if @zip.nil? || @zip.empty?\n return false if @lat.nil? || @lat.empty?\n return false if @long.nil? || @long.empty?\n true \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n if @provider.nil?\n return false\n end\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n allowed_values = [\"OUTBOUND\", \"INBOUND\"]\n if @direction && !allowed_values.include?(@direction)\n return false\n end\n \n \n \n \n \n \n \n \n \n \n \n end",
"def path_validator(the_board,origin_arr,destination_arr)\n\t\tpath_validator_horizontal_vertical(the_board,origin_arr,destination_arr)\n\tend",
"def update\n @destination = Destination.find(params[:id])\n @roadmap = @destination.roadmap\n\n params[:destination][:start_date] = Converters::to_date(params[:destination][:start_date])\n params[:destination][:end_date] = Converters::to_date(params[:destination][:end_date])\n\t\tparams[:destination][:planned_cost] = Converters::currency_to_number(params[:destination][:planned_cost])\n \n if not validate_permission(@roadmap)\n return\n end\n\n respond_to do |format|\n if @destination.update_attributes(params[:destination])\n flash[:notice] = 'O destino foi atualizado com sucesso!'\n format.html { redirect_to(roadmap_path(@destination.roadmap)) }\n format.xml { head :ok }\n else\n load_states_and_cities(@destination)\n @vehicles = Vehicle.all\n @destinations = @roadmap.destinations\n\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @destination.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def coordinates_valid?(@coordinates)\n #still need to set conditions for validation to be true.\n\n #for 2-unit shit\n if true\n @user_ship_1.set_coordinates(@coordinates)\n else\n #need to kick back to BoardGame with out Board knowing about BoardGame\n @Messages.error_ship_location_is_invalid\n coordinates_match\n end\n\n #for 3-unit ship\n if true\n @user_ship_2.set_coordinates(@coordinates)\n else\n #need to kick back to BoardGame with out Board knowing about BoardGame\n @Messages.error_ship_location_is_invalid\n coordinates_match\n #place_your_3_unit_ship\n end\n end",
"def complete\n sanitized = whitelist(params, :complete)\n travel = Travels::Travel.find(sanitized[:id])\n\n unless travel.taken? && travel.performer == current_user.becomes(Users::Performer)\n fail(:any, :bad_request, \"Sorry! You're not eligible to complete un-taken travels!\")\n return\n end\n\n respond_to do |format|\n if travel.complete\n format.html { redirect_to status_travel_path(travel) }\n format.json { render json: travel.as_json, status: :ok}\n else\n format.html { redirect_to status_travel_path(travel), alert: \"Failed to complete! Errors: #{travel.errors.full_messages}\" }\n format.json { render json: travel.as_json, status: :unprocessable_entity }\n end\n end\n end",
"def valid?\n#calls on the sender and receiver's #valid? methods\n sender.valid? && receiver.valid?\n end",
"def path_validator_horizontal_vertical(the_board,origin_arr,destination_arr)\n\t\tvalidity = true\n\t\t#puts \"Starting Position #{origin_arr}, final position #{destination_arr}\"\n\n\t\tif origin_arr[0] == destination_arr[0]\n\t\t\t#puts \"Horitzontal direction\"\n\t\t\tif origin_arr[1] < destination_arr[1]\n\t\t\t\ti = origin_arr[1] + 1\n\t\t\telse\n\t\t\t\ti = origin_arr[1] - 1\n\t\t\tend\n\t\t\tuntil i == (destination_arr[1])\n\t\t\t\tif the_board.board[origin_arr[0]][i] != nil\n\t\t\t\t\t#puts \"Not VALID, A piece at the position [[#{origin_arr[0]}],#{[i]}] was FOUND.\"\n\t\t\t\t\tvalidity = false\n\t\t\t\tend\n\t\t\t\tif origin_arr[1] < destination_arr[1]\n\t\t\t\t\ti += 1\n\t\t\t\telse\n\t\t\t\t\ti -= 1\n\t\t\t\tend\n\t\t\tend\n\n\t\telse\n\t\t\t#puts \"Vertical direction\"\n\t\t\tif origin_arr[0] < destination_arr[0]\n\t\t\t \ti = origin_arr[0] + 1\n\t\t\t else\n\t\t\t \ti = origin_arr[0] - 1\n\t\t\t end\n\t\t\t until i == (destination_arr[0])\n\t\t\t \tif the_board.board[i][origin_arr[1]] != nil\n\t\t\t \t\t#puts \"Not VALID, A piece at the position [#{[i]},[#{origin_arr[1]}]] was FOUND.\"\n\t\t\t\t\tvalidity = false\n\t\t\t\telse\n\t\t\t\t\tvalidity = true\n\t\t\t \tend\n\t\t\t \tif origin_arr[0] < destination_arr[0]\n\t\t\t\t\ti += 1\n\t\t\t \telse\n\t\t\t \t\ti -= 1\n\t\t\t \tend\n\t\t\tend\n\t\tend\n\t\tvalidity\n\tend",
"def validate_from\n @from = validate_address(FROM)\n end",
"def create\n @origin = Origin.new(\n :latitude => trip_params[:origin][:latitude],\n :longitude => trip_params[:origin][:longitude]\n )\n @origin.save\n @destination = Destination.new(:address => trip_params[:destination][:address].concat(\" New York City\"))\n @destination.save\n @trip = Trip.new(:origin_id => @origin.id, :destination_id => @destination.id)\n @trip.save \n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip }\n format.json { render action: 'show', status: :created, location: @trip }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate_for_another_reservation\n if start_at && end_at && BUSY_STATUSES.include?(self.status)\n errors.add(:start_at, 'Another reservation already exists for these dates.') if exists_other_reservations_in_same_period?\n end\n end",
"def lat_changed?\n if (self.address_changed?)\n if !(self.latitude_changed?)\n self.errors.add(:address, \"is not valid\")\n return false\n end\n end\n return true\nend",
"def validate\n @invalid=false\n end",
"def create\n @destination = Destination.new(destination_params)\n geo = Geocoder.coordinates(@destination.name)\n unless geo.nil?\n @destination.lat = geo.first\n @destination.lng = geo.last\n end\n\n respond_to do |format|\n if @destination.save\n format.html { redirect_to destinations_path, notice: 'Destination was successfully created.' }\n format.json { render :show, status: :created, location: @destination }\n else\n format.html { render :new }\n format.json { render json: @destination.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @destination = Destination.new(destination_params)\n @destination.save\n set_destinations\n end",
"def verify_address_owners\n if complete?\n errors.add(:bill_address, 'Billing address should not have a user') if bill_address.try(:user_id)\n errors.add(:ship_address, 'Shipping address should not have a user') if ship_address.try(:user_id)\n else\n if bill_address && bill_address.valid? && !bill_address.user_id.nil? && bill_address.user_id != user_id\n errors.add(\n :bill_address,\n \"Billing address user #{bill_address.user_id.inspect} does not match order #{user_id.inspect}\"\n )\n end\n\n if ship_address && ship_address.valid? && !ship_address.user_id.nil? && ship_address.user_id != user_id\n errors.add(\n :ship_address,\n \"Shipping address user #{ship_address.user_id.inspect} does not match order #{user_id.inspect}\"\n )\n end\n end\n end",
"def path_validator(the_board,origin_arr,destination_arr)\n\t\tpath_validator_diagonal(the_board,origin_arr,destination_arr)\n\tend",
"def destination_params\n params.require(:destination).permit(:name, :arrived_on, :left_on, :lng, :lat, :visited)\n end",
"def validate\r\n @invalid=false\r\n end",
"def validate_event_complete(_options = {})\n event_complete_validator = EventCompleteValidator.new(self, validate_others: !retreat_held_at_home_parish)\n event_complete_validator.validate([], RetreatVerification.basic_validation_params)\n # event_complete_validator = EventCompleteValidator.new(self).validate(RetreatVerification.basic_validation_params)\n # convert empty picture attributes to something the user can understand\n found = false\n found |= !errors.delete(:scanned_retreat).nil?\n return unless found\n\n errors.add(:base, \"Scanned retreat verification #{I18n.t('errors.messages.blank')}\")\n end",
"def registration_complete?\n self.address.present?\n end",
"def validate(lat1, lon1, lat2, lon2)\n [lat1, lat2].each do |lat|\n if lat > 90 || lat < -90\n msg = \"Latitude '#{lat}' is invalid - must be between -90 and 90\"\n raise Error, msg\n end\n end\n\n [lon1, lon2].each do |lon|\n if lon > 180 || lon < -180\n msg = \"Longitude '#{lon}' is invalid - must be between -180 and 180\"\n raise Error, msg\n end\n end\n end",
"def validate_move(world, new_coords)\n true if new_coords[0].between?(0, world.size-1) && new_coords[1].between?(0, world.size-1)\n end",
"def ensure_not_in_dest; end",
"def valid?\n sender.valid?\n receiver.valid?\n end",
"def lat_changed?\n if (self.location_changed?)\n if !(self.latitude_changed?)\n self.errors.add(:location, \"is not valid\")\n return false\n end\n end\n return true\nend",
"def check_if_destination_empty(destination_arr)\n\t\tif the_board.position_status(destination_arr) == false\n\t\t\tfalse\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend",
"def validate_on_update\n if final_areas\n if final_areas['cz'].values.join('').strip == '' ||\n final_areas['en'].values.join('').strip == ''\n errors.add('final_areas', I18n.t(:final_areas_must_be_filled, :scope => [:model, :study_plan]))\n end\n end\n end",
"def validate_from_input\n if outbound_request? && !account.phone_numbers.where(number: from).exists?\n errors.add(:from, I18n.t('errors.messages.parameter_not_found'))\n end\n end",
"def check_resolved_at\n self.errors.add('Resolved at', 'can\\'t be blank') if (self.resolved && self.resolved_at.blank?)\n end",
"def bus_in_district\n if bus_stop && bus_stop.district_id != district.id\n errors.add(:bus_stop, 'must be in the same district as the student')\n end\n if bus_route && bus_route.district_id != district.id\n errors.add(:bus_route, 'must be in the same district as the student')\n end\n end",
"def isLegal?(source,destination)\n if source == 1\n if @@tower_1==nil \n return false \n end\n if destination == 2 \n if @@tower_2.empty? || @@tower_1.last < @@tower_2.last\n return true\n end\n end\n if destination == 3 \n if @@tower_3.empty? || @@tower_1.last < @@tower_3.last\n return true\n end\n end\n \n elsif source == 2\n if @@tower_2.empty?\n return false\n end\n if destination == 1 \n if @@tower_1.empty? || @@tower_2.last < @@tower_1.last\n return true\n end\n end\n if destination == 3 \n if @@tower_3.empty? || @@tower_2.last < @@tower_3.last\n return true\n end\n end\n \n \n elsif source == 3\n if @@tower_3.empty?\n return false\n end\n if destination == 1 \n if @@tower_1.empty? || @@tower_3.last < @@tower_1.last\n return true\n end\n end\n if destination == 2 \n if @@tower_2.empty? || @@tower_3.last < @@tower_2.last\n return true\n end\n end\n \n else \n return false\n end\n \n end",
"def can_complete? (x: nil, y: nil, count: nil, time: nil)\n\n time ||= DateTime.now\n\n # Raise exception if the objective is time constrained and cannot be completed\n unless time_constraint == \"NONE\"\n case time_constraint\n when \"BETWEEN_TIMESTAMP_MONTHS\"\n if !(from_timestamp.month..to_timestamp.month).include?(time.month)\n raise OutsideTimeRangeException.new(\n \"Objective can only be completed between #{from_timestamp.strftime(\"%B\")}-#{to_timestamp.strftime(\"%B\")}\"\n ) \n end\n when \"BETWEEN_TIMESTAMP_HOURS\"\n if !(from_timestamp.hour..to_timestamp.hour).include?(time.hour)\n raise OutsideTimeRangeException.new(\n \"Objective can only be completed between #{from_timestamp.strftime(\"%H:00\")}-#{to_timestamp.strftime(\"%H:00\")}\"\n ) \n end\n when \"BETWEEN_TIMESTAMP_DAYS\"\n if !(from_timestamp.mday..to_timestamp.mday).include?(time.mday)\n raise OutsideTimeRangeException.new(\n \"Objective can only be completed between #{from_timestamp.mday}-#{to_timestamp.mday} each month\"\n ) \n end\n when \"BETWEEN_TIMESTAMP_WEEKDAYS\"\n if !(from_timestamp.wday..to_timestamp.wday).include?(time.wday)\n raise OutsideTimeRangeException.new(\n \"Objective can only be completed between #{from_timestamp.strftime(\"%A\")}-#{to_timestamp.strftime(\"%A\")}\"\n ) \n end\n when \"BETWEEN_TIMESTAMP_EXACT\"\n if !(from_timestamp..to_timestamp).include?(time)\n raise OutsideTimeRangeException.new(\n \"Objective can only be completed between #{from_timestamp.strftime(\"%Y-%m-%d %H:%M\")}-#{to_timestamp.strftime(\"%Y-%m-%d %H:%M\")}\"\n ) \n end\n end\n end\n\n case kind\n when \"LOCATION\"\n raise TooFarAwayException.new(\"Invalid coordinates\") if x.nil? or y.nil?\n distance = distance_to([x.to_f, y.to_f])\n raise TooFarAwayException.new(\"#{distance} is further away than minimum #{Settings.unlock_distance}\") if (distance > Settings.unlock_distance)\n true\n when \"ACTION\"\n true\n else\n false\n end\n end",
"def valid?\n return false if @to.nil?\n return false if @from.nil?\n carrier_validator = EnumAttributeValidator.new('String', [\"USPS\"])\n return false unless carrier_validator.valid?(@carrier)\n return false if @date_created.nil?\n return false if @date_modified.nil?\n return false if @id.nil?\n return false if @id !~ Regexp.new(/^ltr_[a-zA-Z0-9]+$/)\n return false if !@template_id.nil? && @template_id !~ Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n return false if !@template_version_id.nil? && @template_version_id !~ Regexp.new(/^vrsn_[a-zA-Z0-9]+$/)\n return false if !@url.nil? && @url !~ Regexp.new(/^https:\\/\\/(lob-assets|lob-assets-staging)\\.com\\/(letters|postcards|bank-accounts|checks|self-mailers|cards)\\/[a-z]{3,4}_[a-z0-9]{15,16}(\\.pdf|_thumb_[a-z]+_[0-9]+\\.png)\\?(version=[a-z0-9-]*&)?expires=[0-9]{10}&signature=[a-zA-Z0-9_-]+$/)\n return false if @object.nil?\n object_validator = EnumAttributeValidator.new('String', [\"letter\"])\n return false unless object_validator.valid?(@object)\n return false if !@description.nil? && @description.to_s.length > 255\n return false if !@tracking_events.nil? && @tracking_events.length > 0\n address_placement_validator = EnumAttributeValidator.new('String', [\"top_first_page\", \"insert_blank_page\", \"bottom_first_page_center\", \"bottom_first_page\"])\n return false unless address_placement_validator.valid?(@address_placement)\n true\n end",
"def valid?\n @sender.valid?\n @receiver.valid?\n end",
"def validate_start_and_stop_date\n if active_date\n if active_start_date.nil? or active_stop_date.nil?\n errors.add(:active_date, \"start date or end date not set\")\n end\n end\n end",
"def create\n @trip = Trip.new(user_id: params[:user_id], trip_name: params[:trip_name], distance: params[:distance], walked_at: Time.now)\n @origin = Place.new(user_id: params[:user_id], place_name: params[:origin_name], latitude: params[:origin_lat], longitude: params[:origin_long])\n @destination = Place.new(user_id: params[:user_id], place_name: params[:dest_name], latitude: params[:dest_lat], longitude: params[:dest_long])\n if @trip.save && @origin.save && @destination.save\n @origin_point = TripPoint.new(trip_id: @trip.id, place_id: @origin.id, place_type: \"Origin\")\n @destination_point = TripPoint.new(trip_id: @trip.id, place_id: @destination.id, place_type: \"Destination\")\n @origin_point.save\n @destination_point.save\n else\n render :json => {:success => false, :errors => [\"Trip creation failed.\"]}\n end\n end",
"def validate_step\n\n r = fetch_eth_ost_balance(true)\n return r unless r.success?\n\n r = super\n return r unless r.success?\n\n if is_client_step_one_complete? && is_client_step_two_complete?\n\n success\n\n elsif is_client_step_one_complete?\n error_with_go_to(\n 'e_tss_sth_1',\n 'token_setup_not_complete',\n GlobalConstant::GoTo.economy_planner_step_two\n )\n else\n error_with_go_to(\n 'e_tss_sth_2',\n 'token_setup_not_complete',\n GlobalConstant::GoTo.economy_planner_step_one\n )\n end\n\n end",
"def create\n @route = Route.new(route_params)\n respond_to do |format|\n @route.validate\n if (@route.errors.keys - [:start_station_id, :end_station_id]).size == 0\n @route.save(validate: false)\n end\n if @route.save\n format.html { redirect_to @route, notice: 'Маршрут создан.' }\n format.json { render :show, status: :created, location: @route }\n else\n format.html { render :new }\n format.json { render json: @route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate\r\n invalid_strings = [\r\n 'PO BOX', 'P.O. BOX', 'P.O BOX', 'PO. BOX', 'POBOX',\r\n 'P.OBOX', 'P.O.BOX', 'PO.BOX', 'P.BOX', 'PBOX', 'AFO',\r\n 'A.F.O.', 'APO', 'A.P.O.'\r\n ]\r\n cap_address = self.address.upcase()\r\n invalid_strings.each do |string|\r\n if cap_address.include?(string) then\r\n errors.add(:address, \"Sorry, we don't ship to P.O. boxes\")\r\n end\r\n end\r\n if self.country && self.country.name == \"United States of America\"\r\n unless zip.blank?\r\n unless zip =~ /^\\d{5}/\r\n errors.add(:zip, \"Please enter a valid zip.\")\r\n end\r\n end\r\n self.state = self.state.upcase\r\n errors.add(:state, \"Please use a US state abbreviation\") unless US_STATES.include?(self.state)\r\n end\r\n end",
"def validate_move(move) \n move_from_file = @data[\"moves\"][move]\n move_from_file ? valid = true : valid = false\n end",
"def create\n @destination = Destination.new(params[:destination])\n @destination.update_attributes(:active => \"1\", :is_deleted => \"0\")\n\n @destination.company_id = current_user.company_id\n\n respond_to do |format|\n if @destination.save\n format.html { redirect_to destinations_path, notice: \"El destino #{@destination.name} fue creado exitosamente.\" }\n format.json { render json: @destination, status: :created, location: @destination }\n else\n format.html { render action: \"new\" }\n format.json { render json: @destination.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validation(x, y)\n if(x >= plane[0].length || x < 0)\n puts \"invalid start or end point on across direction\"\n return false\n end\n if(y >= plane.length || y < 0)\n puts \"invalid start or end point on down direction\"\n return false\n end\n return true\n end",
"def validate!\n unless resource_type === 'user_moves'\n fail PayloadValidationError, 'Invalid resource type at \"data.type\", expected \"user_moves\"'\n end\n\n unless raw_given_position.is_a?(Array) && raw_given_position.length == 2\n fail PayloadValidationError, 'Invalid resource type at \"data.attributes.position\", expected Array([x, y])'\n end\n end",
"def time_valid\n if self.valid_from and self.valid_to then\n errors.add(:valid_from,\n \"must be before the valid to date. #{self.valid_from} >= #{self.valid_to}\") unless self.valid_from < self.valid_to\n else\n if self.valid_from or self.valid_to then\n errors.add(:valid_from,\n \" must be set when valid_to is set.\") unless self.valid_from\n errors.add(:valid_to,\n \" must be set when valid_from is set.\") unless self.valid_to\n end\n end\n end",
"def input_valid?(from, to)\n\tvalid_position?(from) && valid_position?(to)\nend",
"def check_completed_at\n self.errors.add('Completion Date', 'can\\'t be blank') if (self.completed && self.completed_at.blank?)\n end",
"def valid_dest?(to, board)\n diff = path_diff(to)\n\n if diff[0] == diff[1] || diff[0] == (-diff[1])\n return path_empty?(diff, board)\n end\n false\n end",
"def validate_end_time\n if self.end_time.present? && self.end_time < self.start_time\n errors.add(:end_time, \"can't be before start time\")\n end\n end",
"def validate_x_y_coords(x, y)\n validate_x_coords(x)\n validate_y_coords(y)\n end",
"def validate_two_end(begX, begY, endX, endY)\n puts \"Outbound input point(s)\" if validation(begX, begY) && validation(endX,endY) == false\n return validation(begX, begY) && validation(endX,endY)\n end",
"def validate_place(x,y,direction,placed,place_position)\n params=place_position.split(',')\n if is_integer(params[0]) && is_integer(params[1]) # Checking invalid inputs\n temp_x=params[0].to_i\n temp_y=params[1].to_i\n else\n return x,y,direction,placed # Place invalid, return\n end \n if validate(temp_x) && validate(temp_y) # Checking board boundaries\n if ['NORTH','EAST','WEST','SOUTH'].include?(params[2]) # Checking valid Directions\n x=temp_x\n y=temp_y\n direction=params[2]\n return x,y,direction,true #place is valid return updated coordinates and placed_state\n end\n end\n return x,y,direction,placed # Place invalid, return\n end",
"def complete?\n place.present? && report.present?\n end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def valid; end",
"def valid?\n sender.valid? && receiver.valid?\n end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def complete?\n end",
"def validated; end",
"def dest_params\n params.require(:destination).permit(:name, :date, :start_time, :end_time, :address, :date, :trip_id, :like_count)\n end",
"def validate_leg(from_to_distance)\n if from_to_distance.length != 3\n return %Q[Invalid Route \"#{from_to_distance}\": Route must be 3 characters long]\n end\n\n if (Integer from_to_distance[2] rescue nil) == nil\n return %Q[Invalid Route \"#{from_to_distance}\": Third character of route must be a number]\n end\n end",
"def validate_start_and_stop_time\n if active_time\n if active_start_time.nil? or active_stop_time.nil?\n errors.add(:active_time, \"start time or end time not set\")\n end\n end\n end",
"def trip_params\n params.require(:trip).permit(:origin =>[:address, :latitude, :longitude], :destination => [:address])\n end",
"def movement_rule(destination)\n true\n end",
"def checkDestination\n\n log('debug', \"Checking destination parameter '#{@destination}'.\")\n\n if File.file?(@destination)\n log('error', \"Destination '#{@destination}' is a file.\")\n puts \"Abort. Destination '#{@destination}' is a file.\"\n exit 1\n end\n\n # Create destination if switch is 'true'\n if @dest_create\n\n if @dryrun and !File.directory?(@destination)\n log('info', \"Dryrun: Folder '#{@destination}' created.\")\n elsif !File.directory?(@destination)\n FileUtils.mkdir_p(@destination)\n log('info', \"Folder '#{@destination}' created.\")\n end\n\n else\n log('debug', \"Destination not created\")\n end\n\n if File.directory?(@destination)\n log('debug', \"Destination '#{@destination}' as directory confirmed.\")\n true\n else\n log('error', \"Destination '#{@destination}' as directory not confirmed.\")\n puts \"Abort. Destination '#{@destination}' not available!\"\n exit 1\n end\n\n end",
"def validation\n self.nation ||= region.nation\n unless !@x || !@y || @x == '' || @y == ''\n self.geom = Point.from_x_y(@x.to_f, @y.to_f)\n end\n end",
"def input_valid?(from, to)\r\n\tvalid_position?(from) && valid_position?(to)\r\nend",
"def check_data_integrity(source, dest)\n\t\t\tstation_list = @graph.map {|x| x.first}\n\t\t\terrors = []\n\t\t\tif !station_list.include?(source)\n\t\t\t\terrors << source\n\t\t\tend\n\n\t\t\tif !station_list.include?(dest)\n\t\t\t\terrors << dest\n\t\t\tend\n\n\t\t\tif errors.size > 0\n\t\t\t\tputs \"The following stations were not found in the application: #{errors.join(\",\")}. Please, check your data.\"\n\t\t\t\texit\n\t\t\tend\n\t\tend",
"def valid?\n @sender.valid? && @receiver.valid?\n end",
"def validate_event_complete(_options = {})\n event_complete_validator = EventCompleteValidator.new(self, validate_others: !sponsor_attends_home_parish)\n event_complete_validator.validate(SponsorEligibility.attends_home_parish_validation_params,\n SponsorEligibility.not_attends_home_parish_params)\n\n found = false\n found |= !errors.delete(:scanned_eligibility).nil?\n return unless found\n\n errors.add(:base, :blank, message: \"Scanned sponsor eligibility form #{I18n.t('errors.messages.blank')}\")\n end"
] | [
"0.75685304",
"0.68077946",
"0.6605376",
"0.64060026",
"0.63521993",
"0.6302603",
"0.6248893",
"0.6248893",
"0.6084031",
"0.6061894",
"0.60558015",
"0.60010695",
"0.5970524",
"0.5942762",
"0.5834744",
"0.58254266",
"0.5791098",
"0.57865226",
"0.57853246",
"0.5780166",
"0.5756491",
"0.5730745",
"0.57285047",
"0.57248133",
"0.5696651",
"0.5692349",
"0.56502545",
"0.56404555",
"0.56293136",
"0.5621122",
"0.56060076",
"0.55989283",
"0.55855113",
"0.55669767",
"0.55460715",
"0.5543621",
"0.5520921",
"0.55165154",
"0.54937",
"0.54841375",
"0.54754406",
"0.54666877",
"0.54631525",
"0.54557496",
"0.54531306",
"0.5443412",
"0.5441773",
"0.54373574",
"0.5431604",
"0.5413706",
"0.5400397",
"0.5396204",
"0.53906643",
"0.5390181",
"0.5386809",
"0.5381435",
"0.537852",
"0.53760624",
"0.5373972",
"0.53652376",
"0.5357655",
"0.5351612",
"0.5345005",
"0.534492",
"0.5342991",
"0.53392744",
"0.533849",
"0.5336671",
"0.5335461",
"0.53344655",
"0.5331954",
"0.5329582",
"0.53252965",
"0.5324512",
"0.53229475",
"0.5314656",
"0.5313951",
"0.53027",
"0.53023005",
"0.5289301",
"0.5289301",
"0.5289301",
"0.5289301",
"0.52878445",
"0.528715",
"0.5285634",
"0.5285634",
"0.5285634",
"0.5282233",
"0.5271329",
"0.5270317",
"0.52700245",
"0.526955",
"0.52687913",
"0.5266849",
"0.5258849",
"0.5258347",
"0.52562547",
"0.52546954",
"0.52445924",
"0.5243683"
] | 0.0 | -1 |
POST request to change show to watched | def watched_tvshow
@watch = Watchlist.find_by(show_watched: false, user_id: params[:user_id], tv_show_id: params[:tv_show_id])
if @watch
@watch.update(show_watched: true)
render json: @watch
else
render json: {
error: "Something went wrong"
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_show\n server_id = params[:server]\n user_id = @current_user.id\n show = params[:show]\n\n if server_id.nil? || show.nil?\n render :json => {error:'please enter correct params'}\n return\n end\n\n up = UserPermission.where(user_id:user_id, server_id:server_id).first\n\n unless up.nil?\n if !up.avalible && show\n render :json => {status:false}\n return\n end\n up.show = show\n up.save\n render :json => {status:true}\n return\n end\n\n render :json => {status:false,up: up , params:params}\n end",
"def change_show\n server_id = params[:server]\n user_id = params[:user]\n show = params[:show]\n\n if server_id.nil? || user_id.nil? || show.nil?\n render :json => {error:'please enter params'}\n return\n end\n\n up = UserPermission.where(user_id:user_id, server_id:server_id).first\n\n unless up.nil?\n if !up.avalible && show\n render :json => {status:false}\n return\n end\n up.show = show\n up.save\n render :json => {status:true}\n return\n end\n\n render :json => {status:false,up: up , params:params}\n end",
"def show\n render json: @vdm_change\n end",
"def show\n @notify = Notify.find(params[:id])\n\n @notify.is_read = true ;\n @notify.save\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @notify }\n end\n end",
"def show\n @watch_list = WatchList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @watch_list }\n end\n end",
"def watching\n Birdman::Requester.get(\"movies/#{id}/watching\")\n end",
"def update\n respond_to do |format|\n if @watch.update(watch_params)\n format.html { redirect_to @watch, notice: 'Watch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @watch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @watched_post.update(watched_post_params)\n format.html { redirect_to @watched_post, notice: 'Watched post was successfully updated.' }\n format.json { render :show, status: :ok, location: @watched_post }\n else\n format.html { render :edit }\n format.json { render json: @watched_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @request.accept\n redirect_to posts_url\n end",
"def viewing_params\n params.require(:viewing).permit(:user_id, :movie_id, :watched)\n end",
"def set_watched_post\n @watched_post = WatchedPost.find(params[:id])\n end",
"def waiver\n @entry = Entry.find_by_id(params[:id])\n\n respond_to do |format|\n if @entry && @entry.toggle!(:waiver)\n format.js\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tv_show.update(tv_show_params)\n format.html { redirect_to @tv_show, notice: 'Tv show was successfully updated.' }\n format.json { render :show, status: :ok, location: @tv_show }\n else\n format.html { render :edit }\n format.json { render json: @tv_show.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tv_show.update(tv_show_params)\n format.html { redirect_to @tv_show, notice: 'Tv show was successfully updated.' }\n format.json { render :show, status: :ok, location: @tv_show }\n else\n format.html { render :edit }\n format.json { render json: @tv_show.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_watch\n @watch = Watch.find(params[:id])\n end",
"def watch\n\t\t@event = Event.find(params[:id])\n \t@attendee = User.find(session[:user_id])\n\n\t\t# get @attendee's event_commitment with this event, if any\n\t\t@event_commitment = @attendee.event_commitments.where(:event_id => @event.id).first\n\n\t\t# create a new event_commitment, or change @event_commitment's description to \"watch\"\n\t\tif @event_commitment == nil\n\t\t\t@event_commitment = EventCommitment.create(:user => @attendee, :event => @event, :description => \"watch\")\n\t\telsif @event_commitment.description != \"watch\"\n\t\t\t# use update_attributes b/c saves automatically\n\t\t\t@event_commitment.update_attributes(:description => \"watch\")\n end\n\n @event_commitments = @event.event_commitments(true) # use \"true\" to reload info from the db\n\n # respond to: calls watch.js.erb\n respond_to do |format|\n format.js\n format.html { redirect_to(@event) }\n end\n\tend",
"def watch_request(titles, unwatch = false)\n titles = titles.is_a?(Array) ? titles : [titles]\n params = {\n action: 'watch',\n titles: titles.shift(get_limited(titles.length, 50, 500)).join('|'),\n token: get_token('watch')\n }\n success_key = 'watched'\n if unwatch\n params[:unwatch] = 1\n success_key = 'unwatched'\n end\n\n post(params)['watch'].inject({}) do |result, entry|\n title = entry['title']\n if entry.key?(success_key)\n result[title] = entry.key?('missing') ? nil : true\n else\n result[title] = false\n end\n\n result\n end\n end",
"def status_change\n respond_to do |format|\n format.js do\n @activity = CurationActivity.create(identifier_id: params[:id], status: params[:status], user_id: current_user.id,\n note: params[:note])\n end\n end\n end",
"def watchlist_params\n params.require(:watchlist).permit(:user_id, :tv_show_id)\n end",
"def update_show\n\tend",
"def update_show\n\tend",
"def show\n @rate_watcher = RateWatcher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rate_watcher }\n end\n end",
"def showing_params\n params.require(:showing).permit(:name, :type_of_show, :body)\n end",
"def show\n update\n end",
"def status\n @way.status = request.raw_post\n @way.save!\n render :text => @way.status\n end",
"def show\n # If an old id or a numeric id was used to find the record, then\n # the request path will not match the watchlist_path, and we should do\n # a 301 redirect that uses the current friendly id.\n if request.path != watchlist_path(@watchlist)\n return redirect_to @watchlist, :status => :moved_permanently\n end\n\n @watchdiv = params[:watchdiv]\n if @watchdiv == 'unwatched'\n @unwatched_movies = @watchlist.movies.unwatched.paginate(:page => params[:page], :per_page => 18).order('created_at DESC')\n else\n @unwatched_movies = @watchlist.movies.unwatched.paginate(:page => 1, :per_page => 18).order('created_at DESC')\n end\n if @watchdiv == 'been_watched'\n @watched_movies = @watchlist.movies.been_watched.paginate(:page => params[:page], :per_page => 10).order('movies.date_watched DESC')\n else\n @watched_movies = @watchlist.movies.been_watched.paginate(:page => 1, :per_page => 10).order('movies.date_watched DESC')\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unwatched_movies }\n format.js\n end\n end",
"def update\n respond_to do |format|\n if @showing.update(showing_params)\n format.html { redirect_to @showing, notice: 'Showing was successfully updated.' }\n format.json { render :show, status: :ok, location: @showing }\n else\n format.html { render :edit }\n format.json { render json: @showing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @showing.update(showing_params)\n format.html { redirect_to @showing, notice: 'Showing was successfully updated.' }\n format.json { render :show, status: :ok, location: @showing }\n else\n format.html { render :edit }\n format.json { render json: @showing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @showing.update(showing_params)\n format.html { redirect_to @showing, notice: 'Showing was successfully updated.' }\n format.json { render :show, status: :ok, location: @showing }\n else\n format.html { render :edit }\n format.json { render json: @showing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @watcher.update(watcher_params)\n format.html { redirect_to @watcher, notice: 'Watcher was successfully updated.' }\n format.json { render :show, status: :ok, location: @watcher }\n else\n format.html { render :edit }\n format.json { render json: @watcher.errors, status: :unprocessable_entity }\n end\n end\n end",
"def toggle_status\n @offer.toggle_status\n\n respond_to do |format|\n format.html { redirect_to admin_offers_url,\n notice: 'Offer status was updated.' }\n format.json { render :show, status: :ok, location: @offer }\n end\n end",
"def watch\n klass = params[:commentable_type].constantize\n @commentable = klass.find(params[:commentable_id])\n\n authorize! :read, @commentable\n\n if request.post?\n User.create_action(:watch_comment, target: @commentable, user: current_user, action_option: \"watch\")\n else\n User.create_action(:watch_comment, target: @commentable, user: current_user, action_option: \"ignore\")\n end\n end",
"def show\n puts \"SHOW\"\n puts params.inspect\n puts \"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\"\n\n\n scout = Scout.find(params[:scout_id])\n @advance = scout.advancement\n con = params[:con]\n req = params[:req]\n puts con\n puts req\n @link = @advance.toggle_approve(scout, con, req)\n respond_to do |format|\n format.json\n end\n end",
"def new\n @watch_list = WatchList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @watch_list }\n end\n end",
"def show\n @second_watched_model = SecondWatchedModel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @second_watched_model }\n end\n end",
"def show\n render json: @cp_change\n end",
"def index\n @submissions = Submission.all.reverse\n @watch = params[:watch].to_i\n if @watch == 0 then \n @watch = nil\n end\n if @watch then\n my_submission = (@submissions.select do |x| x.id == @watch end)[0]\n @watch = nil if my_submission && (not self.class.helpers.now_judging?(my_submission))\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @submissions }\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n @event.update(status: \"Pending\")\n else\n @reopen = true\n format.json { render json: @event.errors, status: :unprocessable_entity }\n format.html { render :show }\n end\n end\n end",
"def status_update(_event)\n @submitted = false\n @filed = false\n end",
"def show\n @watched_movie = WatchedMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @watched_movie }\n end\n end",
"def watch\n\nend",
"def update\n respond_to do |format|\n if @tvshow.update(tvshow_params)\n format.html { redirect_to tvshows_url, notice: 'Tvshow was successfully updated.' }\n format.json { render :show, status: :ok, location: @tvshow }\n else\n format.html { render :edit }\n format.json { render json: @tvshow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @show.update(show_params)\n format.js\n format.html { redirect_to admin_shows_path, notice: \"Show was successfully updated.\" }\n format.json { render :show, status: :ok, location: @show }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @show.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_show_request(event)\n return false if event.channel.pm?\n\n request_setcmd = event.content.delete_prefix('!dm request').strip\n server = event.server.id\n check_user_or_nick(event)\n\n if event.user.defined_permission?(:manage_messages) == true ||\n event.user.defined_permission?(:administrator) == true ||\n event.user.permission?(:manage_messages, event.channel) == true\n if request_setcmd == 'show'\n @request_option = true\n $db.execute \"insert or replace into server_options(server,show_requests,timestamp) VALUES (#{server},\\\"#{@request_option}\\\",CURRENT_TIMESTAMP)\"\n elsif request_setcmd == 'hide'\n $db.execute \"delete from server_options where server = #{server}\"\n else\n event.respond(content: \"'\" + request_setcmd + \"' is not a valid option. Please use 'show' or 'hide'.\")\n return true\n end\n event.respond(content: 'Requests will now be ' + (@request_option ? 'shown' : 'hidden') + ' in responses.')\n true\n else\n event.respond(content: \"#{@user} does not have permissions for this command\")\n true\n end\nend",
"def show\n render json: @event, status: :ok\n end",
"def update\n respond_to do |format|\n if @movies_ive_watched.update(movies_ive_watched_params)\n format.html { redirect_to @movies_ive_watched, notice: 'Movies ive watched was successfully updated.' }\n format.json { render :show, status: :ok, location: @movies_ive_watched }\n else\n format.html { render :edit }\n format.json { render json: @movies_ive_watched.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @issue_watch.update(issue_watch_params)\n format.html { redirect_to @issue_watch, notice: 'Issue watch was successfully updated.' }\n format.json { render :show, status: :ok, location: @issue_watch }\n else\n format.html { render :edit }\n format.json { render json: @issue_watch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # find our musician\n @musician = Musician.find(params[:id])\n\n # set the status to true\n @musician.update_attributes(:status => true)\n @musician.save\n\n respond_to do |format|\n format.js {render inline: \"location.reload();\" }\n end\n end",
"def update\n respond_to do |format|\n if @show.update(show_params)\n\n params[:tags].each do |tag|\n\n show_tag = ShowTag.where(:name => tag[0]).last\n\n if show_tag #is this a real show_tag?\n\n show_tag_entry = ShowTagEntry.where(:show_id => @show.id, :show_tag_id => show_tag.id).last\n\n if tag[1] == \"true\" #if selected\n\n unless show_tag_entry\n\n ShowTagEntry.create(:show_tag_id => show_tag.id, :show_id => @show.id, :is_active => true)\n\n else\n\n show_tag_entry.update(:is_active => true)\n\n end\n\n\n else #if not selected\n\n if show_tag_entry\n\n show_tag_entry.update(:is_active => false)\n\n end\n\n end\n\n end\n\n end\n\n format.html { redirect_to show_home_path(@show.city, @show.url_slug), notice: 'Show was successfully updated.' }\n format.json { render :show, status: :ok, location: @show }\n else\n format.html { render :edit }\n format.json { render json: @show.errors, status: :unprocessable_entity }\n end\n end\n end",
"def changeShow\n @feedback = Feedback.find(params[:id])\n @feedback.show = !@feedback.show\n @feedback.save\n redirect_to feedbacks_path\n end",
"def showing_params\n params.require(:showing).permit(:time_slot, :seats_available, :screening_room_id, :movie_id)\n end",
"def show_change_request_form\n respond_to do |format|\n format.js {render 'log_entry/change_request/show_change_request_form'}\n end\n end",
"def update\n thing_name = params[:id]\n is_on = params[:on].to_i\n client = Broker::Wrapper.new(current_user, thing_name)\n result = client.set_state(is_on)\n\n result_hash = result.as_json\n render json: result_hash, status: 200\n end",
"def show\n render json: @verb\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tresult = Tmdb::TV.detail(show_params[:tmdbid])\n\t\t\t@show.title = result[\"name\"]\n\t\t\t@show.description = result[\"overview\"]\n\t\t\t@show.seasons = result[\"number_of_seasons\"]\n\t\t\t@show.episodes = result[\"number_of_episodes\"]\n\t\t\t@show.episoderuntime = result[\"episode_run_time\"].dig(0)\n\t\t\t@show.showrating = result[\"vote_average\"]\n\t\t\t@show.airdate = result[\"first_air_date\"]\n\t\t\t@show.save\n\t format.html { redirect_to @show, notice: 'Show was successfully updated.' }\n\t format.json { render :show, status: :ok, location: @show }\n\t\tend\n\tend",
"def show\n\n \t\t\trespond_with @play\n\n \t\tend",
"def show\n @reef_tank = ReefTank.find(params[:id])\n @watchers = Watcher.all\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reef_tank }\n end\n end",
"def show\n @event = Event.last\n\n if request.protocol.include?(\"https\")\n if running_rpi?\n broadcast_id_fn = `ls /home/pi/rails/tam4dummies/stream/create_broadcast/ | awk '{ print $NF }'`\n else\n broadcast_id_fn = `ls /Users/paulonegrao/codecore/railsdir/tam_for_dummies_app/stream/create_broadcast/ | awk '{ print $NF }'`\n end\n\n if broadcast_id_fn != \"\"\n fn_array = broadcast_id_fn.split(\"@@t4d@@\")\n stream_id = fn_array[0]\n broadcast_id = fn_array[1]\n stream_name = fn_array[2]\n stream = Stream.find stream_id\n stream.update_attributes(:broadcast_id => broadcast_id, :stream_name => stream_name)\n if running_rpi?\n `rm /home/pi/rails/tam4dummies/stream/create_broadcast/*`\n else\n `rm /Users/paulonegrao/codecore/railsdir/tam_for_dummies_app/stream/create_broadcast/*`\n end\n\n cookies[:broadcast_id] = broadcast_id\n end\n end\n\n respond_to do |format|\n format.js { render :show }\n end\n end",
"def show\n begin\n @meeting = Meeting.find(params[:id])\n #more code here\n rescue ActiveRecord::RecordNotFound\n redirect_to :action=>\"index\", :type => \"attending\"\n return\n end\n \n xml_rsp = Typhoeus::Request.get(@meeting.runningurl).body\n \n if Nokogiri.XML(xml_rsp).xpath('//response/running')[0].content == \"true\"\n @running = true\n else\n @running = false\n end\n \n \n #if \n # @meeting.status = 0\n # @meeting.save \n #end\n \n if !params[:accept].nil? && params[:accept] == '1' && @meeting.tutor_id == session[:tutor_id]\n #only tutor for the meeting can accept the meeting\n @meeting.accept = 1\n @meeting.status = 1# status has further meanings, meeting started 2, meeting completed 2\n @meeting.save\n redirect_to @meeting\n return\n elsif !params[:accept].nil? && params[:accept] == '-1' && @meeting.tutor_id == session[:tutor_id]\n @meeting.accept = -1\n @meeting.status = -1\n @meeting.save\n ta = @meeting.tutor_availability\n ta.taken = 0\n ta.save\n redirect_to @meeting\n return\n elsif !params[:started].nil? && params[:started] == '2' && (@meeting.tutor_id == session[:tutor_id] || @meeting.tutor_id == session[:tutor_id])\n @meeting.status = 2\n @meeting.save \n elsif !params[:finish].nil? && (@meeting.user_id == session[:user_id] || @meeting.tutor_id == session[:tutor_id])\n @meeting.status = 3\n @meeting.save\n elsif !params[:accept].nil? && params[:accept] == '1' && @meeting.tutor_id != session[:tutor_id]\n end\n #puts params.inspect\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meeting }\n end\n end",
"def watching=(name)\n gateway_check\n update_status(@status, name, nil, nil, nil, 3)\n end",
"def show\n update_clicks\n end",
"def show\n @watch_site = WatchSite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @watch_site }\n end\n end",
"def query\n\n # Allows us to execute javascript\n respond_to do |format|\n format.html\n format.js\n end\n\n # If a post request is made, store the show name in @query\n if request.post?\n @query = params[:show]\n end\n\n end",
"def update\n respond_to do |format|\n if @videoo.update(videoo_params)\n format.html { redirect_to @videoo, notice: 'Videoo was successfully updated.' }\n format.json { render :show, status: :ok, location: @videoo }\n else\n format.html { render :edit }\n format.json { render json: @videoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def open\n respond_to do |format|\n @scrachpad.update_attributes(:is_opened=> true);\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @serving.update(serving_params)\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { render :show, status: :ok, location: @serving }\n else\n format.html { render :edit }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def start\n \n @preview = Preview.find(params[:preview_id])\n update_preview @preview\n head :ok\n #redirect_to action: 'status'\n \n end",
"def add_findings\n @pattern = Pattern.find(params[:id])\n @pattern.update_attribute(:status, \"needs_approval\")\n respond_to do |format|\n format.html # add_finding.html.erb\n end\n end",
"def watch_params\n params.permit(:user_id, :user_name, :watcher_id, :watcher_name, :lat, :lng, :location_description, :location_picture, \n\t\t :requested_minutes, :start_time, :end_time, :status)\n end",
"def create\n @watch = Watch.new(watch_params)\n\n respond_to do |format|\n if @watch.save\n format.html { redirect_to @watch, notice: 'Watch was successfully created.' }\n format.json { render action: 'show', status: :created, location: @watch }\n else\n format.html { render action: 'new' }\n format.json { render json: @watch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @status.update(isshared: params[:isshared])\n format.json { head :no_content }\n else\n format.json {\n render json: @status.errors,\n status: :unprocessable_entity\n }\n end\n end\n end",
"def update\n @tv_show = TvShow.find(params[:id])\n\n respond_to do |format|\n if @tv_show.update_attributes(params[:tv_show])\n format.html { redirect_to @tv_show, notice: 'Tv show was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tv_show.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_watchlist\n @watchlist = Watchlist.find(params[:id])\n end",
"def watchlist\n @items=current_user.items.paginate(page: params[:page], per_page: 10)\n @bid_items=current_user.bid_items.paginate(page: params[:bid_page], per_page: 10)\n @watched_items=current_user.watched_items.paginate(page: params[:watched_page], per_page: 10)\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def update\n \twatchlist_item = WatchlistItem.new(watchlist_item_params)\n\n id = SecureRandom.uuid.to_s\n\n watchlist_item_info = {:id => id, type => \"update\",\n :watchlist_item_id => watchlist_item.watchlist_item_id,\n :item_name => watchlist_item.item_name,\n :item_description => watchlist_item.item_description,\n :item_price => watchlist_item.item_price\n\n }\n\n publish :watchlist_item, JSON.generate(watchlist_item_info)\n\n status, @error = get_success(id)\n\n if status == \"true\"\n @status = \"New watchlist item updated!\"\n else\n @status = \"Watchlist item could not be updated\"\n end \n\n render 'confirm' \n # respond_to do |format|\n # if @watchlist.update(watchlist_params)\n # format.html { redirect_to @watchlist, notice: 'Watchlist was successfully updated.' }\n # format.json { render :show, status: :ok, location: @watchlist }\n # else\n # format.html { render :edit }\n # format.json { render json: @watchlist.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update_event_visibility\n setter = EventConcealedSetter.new(event: @event)\n if params[:status] == 'public'\n setter.make_public\n elsif params[:status] == 'private'\n setter.make_private\n else\n render json: {errors: ['invalid status'], detail: 'request must include status: public or status: private'}, status: :bad_request and return\n end\n render json: setter.response, status: setter.status\n end",
"def remove_tvshow\n @watch = Watchlist.find_by(show_watched: false, user_id: params[:user_id], tv_show_id: params[:tv_show_id])\n\n if @watch\n @watch.destroy\n render json: @watch\n else\n render json: {\n error: \"Something went wrong\"\n }\n end\n end",
"def POST; end",
"def update\n respond_to do |format|\n if @watchlist.update(watchlist_params)\n format.html { redirect_to @watchlist, notice: 'Watchlist was successfully updated.' }\n format.json { render :show, status: :ok, location: @watchlist }\n else\n format.html { render :edit }\n format.json { render json: @watchlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_watcher\n @watcher = Watcher.friendly.find(params[:id])\n end",
"def change_status\n # Администратор может поменять статус заявки на любой. Клиент же только на \"отменена\"\n if current_user.owner_or_worker?(@organization) || (current_user == @appointment.user_by_phone && %w(cancel_client).include?(params[:state]))\n @appointment.status = params[:state]\n respond_to do |wants|\n if @appointment.save\n wants.html { redirect_to calendar_path(day: @appointment.start.to_i, worker_id: @appointment.worker_id), notice: 'Статус успешно изменен' }\n wants.js { render js: refresh_calendar }\n else\n wants.html { redirect_to calendar_path(day: @appointment.start.to_i, worker_id: @appointment.worker_id), notice: 'При сохранении произошла ошибка' }\n wants.js { render js: \"alert('при сохранении произошла ошибка'\" }\n end\n end\n else\n redirect_to :back, alert: 'У вас не достаточно прав'\n end\n end",
"def set_reqdevstatus\n @reqdevstatus = Reqdevstatus.find(params[:id])\n end",
"def field_update\n\n @artist = Artist.find_by_url_slug(params[:url_slug])\n\n authorize! :admin, @artist\n\n\n @artist.update_attribute('quick_start_popup_toggle',params[:field][:value])\n\n\n respond_to do |format|\n\n\n format.json {\n render :json => {\n :success => true}\n }\n\n end\n end",
"def suscribe\n @estate = Estate.find(params[:id])\n @estate.update_attribute(:status, true)\n respond_to do |format|\n format.html { redirect_to estates_url, notice: 'Propiedad publicada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def new\n @watched_movie = WatchedMovie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @watched_movie }\n end\n end",
"def show\n @submit_value = \"Show\"\n @hidden_submit = \"hidden\"\n end",
"def show\n @submit_value = \"Show\"\n @hidden_submit = \"hidden\"\n end",
"def show\n @submit_value = \"Show\"\n @hidden_submit = \"hidden\"\n end",
"def update_api\n \t@task = Task.find(params[:id])\n \tcurrent_user\n \t@favorite = Favorite.find(@task.favorite_id)\n\n respond_to do |format|\n format.js { render 'demo/update_api' }\n end\n end",
"def accept\n @pick_request = @branch.pick_requests.find(params[:id]) if @branch\n\n if @pick_request.status == \"1\"\n if @pick_request.update(accept_params) && (@pick_request.status == \"2\" || @pick_request.status == \"4\")\n json_true\n else\n @pick_request.update(status: \"1\")\n json_error(@pick_request)\n end\n elsif @pick_request.status == \"2\"\n if @pick_request.update(accept_params) && (@pick_request.status == '3' || @pick_request.status ==\"4\")\n json_true\n else\n @pick_request.update(status: \"2\")\n json_error(@pick_request)\n end\n else\n json_error(@pick_request)\n end\n end",
"def accept\n self.update_attributes(:status => ACCEPTED)\n end",
"def update\n #@event.status = \"Pending\"\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, success: 'Event was successfully rescheduled.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:is_show]==\"-1\" || params[:is_show]==\"0\"\n is_show = nil if params[:is_show]==\"-1\"\n is_show = false if params[:is_show]==\"0\"\n # is_show = false if params[:is_show]==\"0\"\n @cg_kind.update(is_show:is_show)\n respond_to do |format|\n format.html { redirect_to cg_kinds_url, notice: 'Kind was successfully destroyed.' }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n if @cg_kind.update(cg_kind_params)\n format.html { redirect_to @cg_kind, notice: 'Kind was successfully updated.' }\n format.json { render :show, status: :ok, location: @cg_kind }\n else\n format.html { render :edit }\n format.json { render json: @cg_kind.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def show\n @new_status = NewStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @new_status }\n end\n end",
"def update\n respond_to do |format|\n if @listen.update(listen_params)\n format.html { redirect_to @listen, notice: 'Listen was successfully updated.' }\n format.json { render :show, status: :ok, location: @listen }\n else\n format.html { render :edit }\n format.json { render json: @listen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reactive.update(reactive_params)\n format.html { redirect_to @reactive, notice: 'Reactive was successfully updated.' }\n format.json { render :show, status: :ok, location: @reactive }\n else\n format.html { render :edit }\n format.json { render json: @reactive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_showing\n @showing = Showing.find(params[:id])\n end",
"def set_showing\n @showing = Showing.find(params[:id])\n end",
"def set_showing\n @showing = Showing.find(params[:id])\n end",
"def show\n render json: @todo\n end"
] | [
"0.61067456",
"0.60135585",
"0.5896506",
"0.5805469",
"0.57810664",
"0.5769888",
"0.5765345",
"0.5715358",
"0.5691228",
"0.5686285",
"0.5686265",
"0.5648426",
"0.5613828",
"0.5613828",
"0.56109285",
"0.56007516",
"0.55607694",
"0.55492556",
"0.55348974",
"0.552976",
"0.552976",
"0.5523152",
"0.55030644",
"0.5477323",
"0.5473863",
"0.54732424",
"0.5468546",
"0.5468546",
"0.5468546",
"0.54383785",
"0.54373074",
"0.54343915",
"0.54246616",
"0.5419012",
"0.54140145",
"0.54120725",
"0.54080814",
"0.5401345",
"0.5374255",
"0.53718364",
"0.53605163",
"0.5352385",
"0.53507936",
"0.5350772",
"0.53424644",
"0.5341018",
"0.5333632",
"0.53284395",
"0.5327732",
"0.5323658",
"0.53201044",
"0.53071237",
"0.5293749",
"0.5289065",
"0.52882236",
"0.52875155",
"0.52872634",
"0.52857274",
"0.52846354",
"0.52767193",
"0.52763367",
"0.5269792",
"0.52636445",
"0.52498233",
"0.5246016",
"0.52427775",
"0.5237321",
"0.52366245",
"0.5233941",
"0.52313423",
"0.522716",
"0.52172625",
"0.52155197",
"0.521325",
"0.5213237",
"0.521128",
"0.52103686",
"0.5204421",
"0.5203866",
"0.5202976",
"0.52026296",
"0.5201753",
"0.52001315",
"0.51983804",
"0.5196121",
"0.519396",
"0.519396",
"0.519396",
"0.51865876",
"0.5186381",
"0.51861674",
"0.5183855",
"0.5183288",
"0.5180655",
"0.51790035",
"0.5168656",
"0.51676476",
"0.5167248",
"0.5167248",
"0.516315"
] | 0.73290175 | 0 |
DLEETE request to remove wathclist | def remove_tvshow
@watch = Watchlist.find_by(show_watched: false, user_id: params[:user_id], tv_show_id: params[:tv_show_id])
if @watch
@watch.destroy
render json: @watch
else
render json: {
error: "Something went wrong"
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove list\n list_action list, \"remove\"\n end",
"def destroy\n @wellist.destroy\n\n head :no_content\n end",
"def remove list\n remove = @watch.objects.find { |obj| obj.name == \"remove\" }\n\n obix = OBIX::Builder.new do |obix|\n obix.obj is: \"obix:WatchIn\" do |obix|\n obix.list name: \"hrefs\" do |obix|\n list.each do |item|\n obix.uri val: item\n end\n end\n end\n end\n\n remove.invoke obix.object\n end",
"def remove_from_list_resource\n manage_list_resource(:remove)\n end",
"def destroy\n @fwlist = Fwlist.find(params[:id])\n @fwlist.destroy\n\t\n respond_to do |format|\n format.html { redirect_to fwlists_url }\n format.json { head :no_content }\n end\n end",
"def remove_item(grcy_list, string)\n grcy_list.delete(string)\nend",
"def remove\n\t\t\tself.make_request!({uri: self.to_uri, method: :delete})\n\t\tend",
"def delete_item(rmstr,list)\n list.delete(rmstr)\n list\nend",
"def remove(list, item_name)\r\n\tlist.delete(item_name)\r\n\tp list\r\nend",
"def remove_item(name, list)\n list.delete(name)\n p list\n return list\nend",
"def remove_from_mailchimp(list_name)\n apikey ||= chimpLogin(monkeybrains[:username], monkeybrains[:password])\n list_id ||= find_mailing_list(apikey, list_name)\n chimpUnsubscribe(apikey, list_id[\"id\"], self[email_column])\n rescue XMLRPC::FaultException\n end",
"def destroy\n @college_wish_list = CollegeWishList.find(params[:id])\n @college_wish_list.destroy\n\n respond_to do |format|\n format.html { redirect_to college_wish_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_str_wk = ListStrWk.find(params[:id])\n @list_str_wk.destroy\n @cart_ef=find_cart_ef\n respond_to do |format|\n format.html { redirect_to(list_str_wks_url) }\n format.xml { head :ok }\n end\n end",
"def remove_to_list(list, remove_list_key)\r\n list.delete(remove_list_key)\r\n list\r\nend",
"def remove(list,item)\r\n\tlist.delete(item)\r\n\tlist\r\nend",
"def remove_item(list_item,user_list)\n user_list.delete(list_item)\n user_list\nend",
"def remove_item(list, item_name)\r\n list.delete(item_name)\r\n list\r\nend",
"def remove_item(list, key_name)\r\n\tlist.delete(key_name)\r\n\treturn list\r\nend",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end",
"def remove_item(new_list, item_name)\r\n new_list.delete(item_name)\r\nend",
"def delete_list(params={})\n @obj.delete('delete', @auth.merge(params))\n end",
"def remove_shopping_list\n user_id = current_user.id\n yummly_id = params[:yummly_id]\n\n shopping_list = ShoppingList.find_by(yummly_id: yummly_id, user_id: user_id)\n shopping_list.destroy\n\n redirect_to recipes_url, notice: \"Removed recipe from your shopping lists\"\n end",
"def remove_item(grocery_list, rem_item)\r\n grocery_list.delete(rem_item)\r\n p grocery_list\r\nend",
"def list_remover(list_input_remover, item_name_remove)\n list_input_remover.delete(item_name_remove)\nend",
"def destroy\n @wish_list = WishList.find(params[:id])\n @wish_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_wish_lists_url) }\n format.xml { head :ok }\n end\n end",
"def remove_from_hot_list\n self.update_attribute(:added_to_hot_list, nil)\n end",
"def remove_item(list, name)\n list.delete(normalize_string(name))\n return list\nend",
"def api_remove\n data_hash = make_hash\n delete_hash = { division: data_hash[:division][:value] }\n handler.remove(delete_hash, path, subscriber_id)\n end",
"def remove_item(item)\n $grocery_list.delete(item)\n # puts \"List with #{item} deleted\"\n $grocery_list\nend",
"def remove_item(list, item_name)\n list.delete(item_name)\n list\nend",
"def list_remover(list,item) #takes 2 arguments, 1 list and name of an item\n\tlist.delete(item)\t\n\t\nend",
"def remove_item (item,list)\nlist.delete(item)\nlist\nend",
"def admin_remove_member_request_list\n %w( tt_remove_member_request_list@booktrope.com )\n end",
"def remove(list, item)\r\n list.delete(item)\r\n list\r\nend",
"def remove_item(grocery_list,item_name)\r\n\t \r\n\t grocery_list.delete(item_name)\r\n\r\nend",
"def remove_item(list,item)\r\n\r\n list.delete(item)\r\n list\r\nend",
"def remove_item(item, list)\r\n list.delete(item)\r\n p list\r\n list\r\nend",
"def remove_list(older_list, item)\r\n older_list.delete(item)\r\n return older_list\r\nend",
"def deleteEntityYext_list( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/yext_list\",params)\n end",
"def remove(request) \n data = request.data \t \n\t id = data[@pk]\t \n # remove the item\n @model.destroy(id)\t \n response = DSResponse.new\n response.data = nil\n response.status = 0 \n return response \n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def remove_item(grocery_list, item_name)\r\n\tgrocery_list.delete(item_name)\r\n\treturn grocery_list\r\nend",
"def add_add_del_on_list(key, to_add, to_remove)\n if (@is_commit)\n raise RuntimeError.new('No further request supported after a commit!')\n end\n @requests << {'add_del_on_list' => {'key' => key, 'add' => to_add, 'del'=> to_remove}}\n self\n end",
"def remove_page key, token\n server = Configuration.SERVER\n addr = Configuration.CLIOWL_ADDRESS\n HttpHelper.get(server, \"#{addr}/remove/#{key}/#{token}\")\n end",
"def remove_item(list, rm_item)\n# steps:\n # use delete method with key (item) as argument\n list.delete(rm_item)\n # return list\n list\nend",
"def remove_list_entry(serial)\n return nil if @crl_list_file.nil?\n\n data = read_data(@crl_list_file)\n\n updated_list = []\n\n data.each_line do |line|\n line.chomp!\n revoke_info = line.split(',', 3)\n if revoke_info[0].to_i != serial\n updated_list.push(line)\n end\n end\n write_data(@crl_list_file, updated_list.join(\"\\n\") + \"\\n\")\n nil\n end",
"def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tlist\nend",
"def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tlist\nend",
"def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tlist\nend",
"def destroy\n @mailee_list = Mailee::List.find(params[:id])\n @mailee_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailee_lists_url) }\n format.xml { head :ok }\n end\n end",
"def delete_list\n logger.debug(params[:deleteIdList])\n\n if params[:deleteIdList].present?\n # 一括削除実行\n Kokyaku.update_all(\"\\\"delFlg\\\"=1, \\\"koshinshaId\\\"=\" + params[:koshinshaId], \"\\\"kokyakuId\\\" IN (\" + params[:deleteIdList] + \")\")\n end\n\n respond_to do |format|\n format.html { redirect_to action: \"index\", notice: 'Kokyaku was successfully bulk logical deleted.', reload: 'on' }\n format.json { head :no_content }\n end\n end",
"def remove(list, food_item)\n\tlist.delete(food_item)\n\tlist\nend",
"def remove_from_list(list, item)\n list.delete(item)\n p list\nend",
"def sub_remove _value=0\n send_cmd(\"sub_remove #{_value}\")\n end",
"def remove(grocery_list, item)\n grocery_list.delete(item)\nend",
"def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tp list\nend",
"def remove(list, item_name)\n\tlist.delete(item_name)\nend",
"def remove_item_from_list(grocery_list, item) \n grocery_list.delete(item) \n grocery_list \nend",
"def remove\n product = Product.find(params[:id])\n wishlist = Wishlist.get_current(current_user, session)\n wishlist.products.delete(product)\n render :update do |page| \n page.remove(\"dg_#{product.id}\")\n end\n end",
"def remove_from_whitelist(word)\n params = {\n :method => WebPurify::Constants.methods[:remove_from_whitelist],\n :word => word\n }\n parsed = WebPurify::Request.query(text_request_base, @query_base, params)\n return parsed[:success]=='1'\n end",
"def destroy\n @mylist = Mylist.find(params[:id])\n @mylist.destroy\n\n respond_to do |format|\n format.html { redirect_to(mylists_url) }\n format.xml { head :ok }\n end\n end",
"def remove(input_list, item)\n input_list.delete(item)\nend",
"def remove(grocery_list, food)\n\tgrocery_list.delete(food)\nend",
"def remove_item(list, item)\r\n list.delete(item)\r\n list\r\nend",
"def delete_list\n logger.debug(params[:deleteIdList])\n\n if params[:deleteIdList].present?\n # 一括削除実行\n KonyuRireki.update_all(\"\\\"delFlg\\\"=1, \\\"koshinshaId\\\"=\" + params[:koshinshaId], \"\\\"id\\\" IN (\" + params[:deleteIdList] + \")\")\n end\n\n respond_to do |format|\n format.html { redirect_to action: \"index\", notice: 'KonyuRireki was successfully bulk logical deleted.', reload: 'on' }\n format.json { head :no_content }\n end\n end",
"def remove_from_list(list_id, lead)\n list_operation(list_id_key(list_id), ListOperationType::REMOVE_FROM, lead.id)[:success_list_operation][:result][:success]\n end",
"def remove_item(grocery_list, item_name)\r\n grocery_list.delete(item_name)\r\n #puts grocery_list\r\n return grocery_list\r\nend",
"def destroy\n @watch_list = WatchList.find(params[:id])\n @watch_list.destroy\n\n respond_to do |format|\n format.html { redirect_to watch_lists_url }\n format.json { head :ok }\n end\n end",
"def remove_item(item, grocery_list)\n grocery_list.delete(item)\n # print_list(grocery_list)\n grocery_list\nend",
"def remove(entry); end",
"def remove_from_list(item,list)\n list.delete(item)\nend",
"def remove_item (item, list)\n list.delete(item)\n return list\nend",
"def remove_item(olist, item)\n olist.delete(item) \n olist\nend",
"def remove_item(list, item)\r\n list.delete(item)\r\n p list\r\nend",
"def destroy\n authorize @list\n @list.destroy\n head :no_content\n end",
"def destroy\n @cyclist = Cyclist.find(params[:id])\n @cyclist.destroy\n\n respond_to do |format|\n format.html { redirect_to cyclists_url }\n format.json { head :no_content }\n end\n end",
"def remove_item(list, item_removed)\n list.delete(item_removed)\nend",
"def destroy\n @word_list = WordList.find(params[:id])\n @word_list.destroy\n\n respond_to do |format|\n format.html { redirect_to word_lists_url }\n format.json { head :no_content }\n end\n end",
"def remove_item(list, string)\n\tlist.delete(string)\n\treturn list\nend",
"def remove_item(list, string)\n\tlist.delete(string)\n\treturn list\nend",
"def chef_to_be_removed(chef_server_list)\n servers_up = cloud_server_list\n chef_server_list.delete_if do |name,server|\n puts \"Do not delete #{name}, it's up\" if servers_up[name]\n !! servers_up[name]\n end\nend",
"def destroy\n listentries = List.find(:all,:conditions => \"list_cat_id = #{params[:id]}\")\n for listentry in listentries \n listentry.destroy\n end\n @list_cat = ListCat.find(params[:id])\n @list_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to(:controller => 'lists') }\n format.xml { head :ok }\n end\n end",
"def remove_item(list,item)\n list.delete(item)\n p list\nend",
"def destroy\n @wordlist = Wordlist.find(params[:id])\n @wordlist.destroy\n\n respond_to do |format|\n format.html { redirect_to(wordlists_url) }\n format.xml { head :ok }\n end\n end",
"def remove_item(grocery_list, item)\r\n grocery_list.delete(item) \r\n \r\nend",
"def remove_item(item, list)\n list.delete(item)\n return list\nend",
"def remove_item(list, item)\n list.delete(item)\n list\nend",
"def remove_item(list, item_name)\n list.delete(item_name)\nend",
"def reqdel(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"reqdel \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def destroy\n @ota_code_list_list = Ota::CodeList::List.find(params[:id])\n @ota_code_list_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(ota_code_list_lists_url) }\n format.xml { head :ok }\n end\n end",
"def remove!; end",
"def destroy\n @runlist = Runlist.find(params[:id])\n @runlist.destroy\n\t\t\n\t\t(rend; return) if request.xhr?\n\n respond_to do |format|\n format.html { redirect_to(runlists_url) }\n format.xml { head :ok }\n end\n end",
"def remove_item_from_list(grocery_list,item_to_delete)\n grocery_list.delete(item_to_delete)\n puts \"No need to pick up #{item_to_delete} anymore.\"\nend",
"def remove_item(item, grocery_list)\n grocery_list.delete(item)\n return grocery_list\nend",
"def remove_item(item, grocery_list)\n grocery_list.delete(item)\n return grocery_list\nend",
"def remove(list, item)\n\tlist.delete(item)\n\tlist\nend",
"def remove_item(list, item)\r\n# input: item to be removed, list\r\n# steps: \r\n # check if item exists\r\n # remove item\r\n list.delete(item)\r\n # print success message of item removed\r\n puts \"#{item.upcase} has been removed to your grocery list!\"\r\n p list\r\n# output: updated list\r\nend"
] | [
"0.6507535",
"0.63298684",
"0.6244101",
"0.6075164",
"0.60540617",
"0.5910465",
"0.5884319",
"0.5847864",
"0.5842659",
"0.5833158",
"0.58221096",
"0.5803351",
"0.5802323",
"0.57687587",
"0.5757693",
"0.57446635",
"0.5727193",
"0.5726542",
"0.572249",
"0.572249",
"0.572249",
"0.572249",
"0.57210726",
"0.57202494",
"0.5699282",
"0.56923664",
"0.566577",
"0.5659859",
"0.56545174",
"0.5653538",
"0.56527233",
"0.56362724",
"0.56169087",
"0.56167996",
"0.56144375",
"0.56085217",
"0.5607932",
"0.56068367",
"0.55970186",
"0.5592625",
"0.55864674",
"0.5581561",
"0.55776936",
"0.5571428",
"0.5571329",
"0.5566612",
"0.5565812",
"0.5559764",
"0.5555645",
"0.5551269",
"0.5528903",
"0.5528903",
"0.5528903",
"0.552655",
"0.551958",
"0.5516945",
"0.5511421",
"0.5511053",
"0.5504571",
"0.55027115",
"0.5502018",
"0.55018145",
"0.54938656",
"0.5490381",
"0.5481493",
"0.54765016",
"0.54751486",
"0.547445",
"0.5474003",
"0.5472313",
"0.54679954",
"0.54679215",
"0.54633766",
"0.5458267",
"0.54576135",
"0.54550636",
"0.544828",
"0.54456925",
"0.54454726",
"0.54451174",
"0.543463",
"0.54279524",
"0.54274154",
"0.54274154",
"0.54254097",
"0.54210216",
"0.5419974",
"0.54129714",
"0.54128337",
"0.54112244",
"0.54083836",
"0.5403064",
"0.5401713",
"0.53996354",
"0.5397048",
"0.5393659",
"0.5382563",
"0.53809625",
"0.53809625",
"0.5375961",
"0.53745896"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def call\n setup_context\n super\n end"
] | [
"0.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
"0.5312988",
"0.529798",
"0.52968603",
"0.52962637",
"0.52577317",
"0.5244704",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5236856",
"0.5233461",
"0.52322435",
"0.5227552",
"0.52224743",
"0.5217851",
"0.521241",
"0.52069896",
"0.5206555",
"0.5176617",
"0.51738507",
"0.51725876",
"0.51660734",
"0.51605034",
"0.51571786",
"0.5152762",
"0.5152164",
"0.5151477",
"0.5145819",
"0.51408994",
"0.5134412",
"0.5114031",
"0.5113695",
"0.5113695",
"0.5108603",
"0.5107358",
"0.5090405",
"0.50889385",
"0.50817686",
"0.5081617",
"0.50658226",
"0.50551206",
"0.5051746",
"0.5049091",
"0.5049091",
"0.5034681",
"0.5024972",
"0.5021291",
"0.5016024",
"0.50134826",
"0.50008893",
"0.50000244",
"0.4999155",
"0.49907947",
"0.49907947",
"0.49853387",
"0.49796683",
"0.4979596",
"0.49778128",
"0.49673793",
"0.49662578",
"0.49587822",
"0.4956063",
"0.49550167",
"0.49523485",
"0.4951614",
"0.49452996",
"0.49442068",
"0.49336892",
"0.49306205",
"0.49264124",
"0.49259305",
"0.4925823",
"0.49229056",
"0.4918999",
"0.49171805",
"0.49167436",
"0.4916559",
"0.49153692",
"0.49148256"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def watchlist_params
params.require(:watchlist).permit(:user_id, :tv_show_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] | 0.0 | -1 |
GET /leaf_spot_imm_searches GET /leaf_spot_imm_searches.json | def index
@leaf_spot_imm_searches = LeafSpotImmSearch.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_leaf_spot_imm_search\n @leaf_spot_imm_search = LeafSpotImmSearch.find(params[:id])\n end",
"def leaf_spot_imm_search_params\n params.require(:leaf_spot_imm_search).permit(:search_id, :leaf_spot_imm_id)\n end",
"def index\n @search = WordRoot.ransack(params[:q])\n @word_roots = @search.result.paginate(:page => params[:page], per_page: 20)\n end",
"def search\n @hits = []\n\n if params[:query]\n search = DesignMethod.solr_search do\n fulltext params[:query] do\n highlight\n minimum_match 0\n end\n end\n store_location\n @hits = search.hits\n @results = search.results\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def create\n @leaf_spot_imm_search = LeafSpotImmSearch.new(leaf_spot_imm_search_params)\n\n respond_to do |format|\n if @leaf_spot_imm_search.save\n format.html { redirect_to @leaf_spot_imm_search, notice: 'Leaf spot imm search was successfully created.' }\n format.json { render :show, status: :created, location: @leaf_spot_imm_search }\n else\n format.html { render :new }\n format.json { render json: @leaf_spot_imm_search.errors, status: :unprocessable_entity }\n end\n end\n end",
"def search_all_terms\n render json: Article.with_all_terms(params[:query]).map(&:title)\n end",
"def all\n\t\tquery = (params[:term] || params[:query])\n\t\t\n @search_results = PgSearch\n\t\t\t.multisearch(query)\n\t\t\t.page(params[:page])\n\t\t\n\t\trender 'multi_search'\n\tend",
"def search_any_term\n render json: Article.with_any_terms(params[:query]).map(&:title)\n end",
"def search_for_active_towns\n q = params[:query].mb_chars.capitalize.to_s\n @towns = Town.get_central_authority_towns(q).order_by(:level => :asc)\n respond_to do |format|\n format.json { render 'search'}\n end\n end",
"def index\n @query = params[:query] || {\n search: '',\n }\n @theorems = Theorem.all.where(root: true).limit(50)\n @theorems = @theorems.order('views desc')\n @theorems = @theorems.where('text ILIKE ?', \"%#{@query[:search]}%\") if @query[:search] && @query[:search].length > 0\n respond_to do |f|\n f.html { render 'index' }\n f.json { render json: @theorems }\n end\n end",
"def searches\n Boundary.get(@url)\n end",
"def search_for_towns_and_areas\n @towns = use_cache get_controller_action_key do\n Town.all.reject{|town| town.level != 13 && town.level != 1 }\n end\n\n respond_to do |format|\n q = params[:query].mb_chars.capitalize.to_s\n @towns = @towns.select{ |t| Regexp.new(\"^#{q}.*\") =~ t.title }\n format.json\n end\n\n end",
"def search_for_areas\n @towns = use_cache get_controller_action_key do\n Town.all.reject{|town| town.level != 1 }\n end\n\n respond_to do |format|\n q = params[:query].mb_chars.capitalize.to_s\n @towns = @towns.select{ |t| Regexp.new(\"^#{q}.*\") =~ t.title }\n format.json\n end\n\n end",
"def index\n search = Sunspot.new_search(Classification)\n query = params[:query].to_s.strip\n if query.present?\n @query = query.dup\n search.build do\n fulltext query\n end\n end\n unless params[:mode] == 'add'\n subject = @subject\n classification_type = @classification_type\n search.build do\n with(:subject_ids).equal_to subject.id if subject\n with(:classification_type_id).equal_to classification_type.id if classification_type\n end\n end\n\n page = params[:page] || 1\n search.query.paginate(page.to_i, Classification.default_per_page)\n @classifications = search.execute!.results\n\n session[:params] = {} unless session[:params]\n session[:params][:classification] = params\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @flagged_words = FlaggedWord.search(params[:search], params[:page], 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @flagged_words }\n end\n end",
"def search\n @selected = Herb.find_by_id(params[:search])\n if @selected\n redirect_to @selected and return\n else\n \n @search = Herb.search do\n fulltext params[:search]\n\n end\n @herbs = @search.results\n @first = @herbs.pop\n @second = @herbs.pop\n @third = @herbs.pop\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @herbs }\n end\n end",
"def place_search\n @places = []\n area = params[:area_id].blank? ? nil : Place.find(params[:area_id])\n if area.present? && area.area > 0\n search_text = Riddle::Query.escape(help.strip_links(params[:search]))\n results = Place.search(search_text, :field_weights => { :name => 10 })\n\n results.each do |place|\n @places << place if place.areas.include?(area)\n end\n end\n \n respond_to do |format|\n format.json\n end\n end",
"def search\n terms = @authority.search(url_search)\n render json: terms\n end",
"def search\n @q = params[:q]\n @results = Series.external_search(@q)\n\n respond_to do |format|\n format.html # search.html.haml\n format.json { render json: @results.to_json }\n end\n end",
"def search_people(searchterm,params={})\n @opensearch.search_people(searchterm,params) \n end",
"def get_results()\n restriction_nodes = []\n result_nodes = []\n if !(@inputs.nil? || @inputs.empty? || @inputs.first.empty?)\n input_set = @inputs.first\n restriction_nodes= input_set.nodes\n result_nodes = input_set.breadth_first_search(true){|node| node.item.text.downcase.include?(@keyword_phrase.to_s.downcase)} \n end\n \n if !@inplace\n results = @server.match_all(parse_keyword_phrase(), restriction_nodes) \n result_nodes = results.map{|item| Xplain::Node.new(item: item)}\n end\n \n result_nodes\n \n end",
"def search\n @listings = Listing.search do\n keywords params[:query]\n end.results\n\n respond_to do |format|\n format.html { render :action => \"show\" }\n format.xml { render :xml => @listings }\n end\n end",
"def index\n # @entries = Entry.all\n @search.sorts = ['term desc', 'created_at desc'] if @search.sorts.empty?\n @search_term = params[:q]\n @entries = @search\n .result(distinct: true)\n .includes(:definitions)\n .page(params[:page])\n .per(params[:per_page])\n\n\n 1\n end",
"def search\n \n search = params[:search]\n miniresume = params[:miniresume]\n location = params[:location]\n\n #thinking_sphinx conditions - \n @adviceposts = Advicepost.search(search,miniresume,location,page: 1, per_page: 25)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @adviceposts }\n end\n end",
"def index\n # @search = Shelter.search do\n # fulltext params[:search]\n # end\n # @shelters = @search.results\n @shelters = Shelter.all\nend",
"def update\n respond_to do |format|\n if @leaf_spot_imm_search.update(leaf_spot_imm_search_params)\n format.html { redirect_to @leaf_spot_imm_search, notice: 'Leaf spot imm search was successfully updated.' }\n format.json { render :show, status: :ok, location: @leaf_spot_imm_search }\n else\n format.html { render :edit }\n format.json { render json: @leaf_spot_imm_search.errors, status: :unprocessable_entity }\n end\n end\n end",
"def search\n if params[:collection_ids]\n data = {:sites => [], :clusters => []}\n params[:collection_ids].each do |id|\n result = search_by_collection id, params\n data[:sites].concat result[:sites] if result[:sites]\n data[:clusters].concat result[:clusters] if result[:clusters]\n end\n render json: data\n else\n render json: []\n end\n end",
"def index\n @leafs = Leaf.all\n end",
"def index\n # Generate sunspot search\n @records = record_default_search\n\n respond_with(@records)\n end",
"def index\n @searches = @website.searches.all\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @searches }\n end\n end",
"def index\n @buildings = Building.find_near_me(search_params)\n end",
"def search\n search_param = params[:term]\n matching_keys = UserKey.submitted.search(search_param).collect { |u| { value: \"#{u.name}\", data: u.id } }\n render json: { suggestions: matching_keys }\n end",
"def search\n # max = (params[:valueMax] || 1_000_000).to_i\n # min = (params[:valueMin] || 0).to_i\n # @offers = Offer.where(\"title ILIKE :search AND value <= :max AND value >= :min\", { search: \"%#{params[:search]}%\", max: max, min: min })\n # render json: @offers\n max = (params[:valueMax] || 1_000_000).to_i\n min = (params[:valueMin] || 0).to_i\n @offers = []\n query = (params[:search])\n query.split(' ').each do |keyword|\n @offers += Offer.where(\"title ILIKE :search AND value <= :max AND value >= :min\", { search: \"%#{keyword}%\", max: max, min: min })\n end\n render json: @offers\n end",
"def search\n @places = FoursquarePlace.places_near_coordinates(@coordinates, query: params[:search_terms])\n render json: { data: @places }\n end",
"def index\n @query = params[:q] || '*:*'\n query = Jbuilder.encode do |json|\n json.filter do\n json.missing do\n json.field \"parent_id\"\n end\n end\n json.query do\n json.query_string do\n json.query @query\n end\n end\n json.sort do\n json.node \"asc\"\n end\n end\n @themata = Thema.__elasticsearch__.search(query).page(params[:page]).records\n end",
"def index\n query = params[:query].to_s.strip\n search = Sunspot.new_search(Work)\n @count = {}\n unless query.blank?\n @query = query.dup\n query = query.gsub(' ', ' ')\n search.build do\n fulltext query\n end\n end\n\n set_role_query(current_user, search)\n\n unless params[:mode] == 'add'\n patron = @patron\n subject = @subject\n work = @work\n work_merge_list = @work_merge_list\n search.build do\n with(:patron_ids).equal_to patron.id if patron\n with(:subject_ids).equal_to subject.id if subject\n with(:original_work_ids).equal_to work.id if work\n with(:work_merge_list_ids).equal_to work_merge_list.id if work_merge_list\n end\n end\n\n role = current_user.try(:role) || Role.find('Guest')\n search.build do\n with(:required_role_id).less_than_or_equal_to role.id\n end\n\n page = params[:page] || 1\n search.query.paginate(page.to_i, Work.default_per_page)\n @works = search.execute!.results\n @count[:total] = @works.total_entries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @works }\n format.atom\n end\n end",
"def index\n page = params[:page] || 1\n page = page.to_i\n per_page = params[:per_page] || 25\n per_page = per_page.to_i\n @results = {}\n\n search = params[:searchterm]\n if search && search.empty?\n search = nil\n end\n\n if search\n page = 1\n per_page = 50\n @stats = SearchEngine.search(Stat, search)\n total = @stats.count\n @stats = Kaminari.paginate_array(@stats).page(page).per(per_page)\n \n @searchterm = search\n else\n @stats = Stat.desc(:id).page(page).per(per_page)\n total = Stat.count\n end\n \n @results[:first] = (page-1) * per_page + 1\n @results[:last ] = [total, page * per_page].min\n @results[:total] = total\n end",
"def search\n #begin\n page = params[:page].present? ? params[:page].to_i : 1\n page = 1 if page <= 0\n query = params[:query]\n @unclean_query = query.dup\n\n # return error message\n if @unclean_query.present? && (@unclean_query.length < 3 || @unclean_query.length > 30)\n if @unclean_query.length < 3\n gon.searchErrorMessage = I18n.t(\"views.shared.search_errors.too_short\")\n else\n gon.searchErrorMessage = I18n.t(\"views.shared.search_errors.too_long\")\n end\n else\n # Finding yards in which current employee has access\n employee_yard_access = current_employee.yards.pluck(:id)\n employee_country = current_employee.present? ? current_employee.operating_country : nil\n\n # .where(\"yards.id in (?)\", employee_yard_access)\n @vehicles = Vehicle.includes([:seller, :facility, :vehicle_type, {model: :make}]).search(query, page, {yard_access: employee_yard_access, \n country_id: employee_country.try(:id)}, current_role_id)\n if @vehicles.empty?\n gon.searchResultMessage = I18n.t(\"controllers.vehicle.search.no_results\")\n else\n gon.searchResultMessage = I18n.t(\"controllers.vehicle.search.results\")\n end\n gon.pagination = { current_page: @vehicles.current_page,\n default_per_page: Kaminari.config.default_per_page,\n per_page: @vehicles.size,\n total_pages: @vehicles.total_pages,\n total_count: @vehicles.total_count }\n\n gon.vehicles = @vehicles.map(&:search_results) || [] \n gon.sortOptionAscending = Vehicle::SORT_ASCENDING\n gon.sortOptionDescending = Vehicle::SORT_DESCENDING\n gon.httpSlug = \"/search\" \n end\n\n gon.queryString = @unclean_query\n gon.parameters = { page: page,\n query: @unclean_query}\n \n respond_to do |format|\n format.html\n format.json { render :json => { vehicles: gon.vehicles, \n parameters: gon.parameters, \n pagination: gon.pagination } }\n end\n \n end",
"def searches\n wrapping!(\n search(\n root_uri,\n data_raw.to_s.gsub('=>', ':')\n )\n )\n end",
"def search_ranked\n render json: Article.with_ranked_terms(params[:query]).map(&:title)\n end",
"def keyword\n\n @search_text = params[\"search_text\"] ||= \"\"\n\n add_breadcrumb \"Keyword Search: '#{@search_text}'\"\n\n if @search_text.blank? or @search_text.length < 2\n @keyword_search_results = KeywordSearchIndex.where(\"1 = 2\")\n else\n\n # here we build the query one clause at a time based on the input params. The query\n # is of the form:\n #\n # where organization_id IN (?) AND (search_text LIKE ? OR search_text_like ? OR ... )\n\n where_clause = 'organization_id IN (?) AND ('\n values = []\n # The organization is scoped to search across all objects that are owned by\n # the user's list of organizations\n orgs = @organization_list.dup\n # add org = 0 to get objects that are not indexed by org and are by\n # contract available to users of all organizations\n orgs << 0\n values << orgs\n\n search_params = []\n @search_text.split(\",\").each_with_index do |search_string|\n search_params << 'search_text LIKE ?'\n values << \"%#{search_string.strip}%\"\n end\n\n where_clause << search_params.join(' OR ')\n where_clause << ')'\n\n @keyword_search_results = KeywordSearchIndex.where(where_clause, *values)\n\n end\n\n @num_rows = @keyword_search_results.count\n cache_list(@keyword_search_results, INDEX_KEY_LIST_VAR)\n\n respond_to do |format|\n format.html\n format.json {\n render :json => {\n :total => @num_rows,\n :rows => data\n }\n }\n end\n\n end",
"def search \n\n end",
"def search\n @maps = Map.find_map_by_input(@maps, params[:name])\n render json: @maps\n end",
"def search keyword, opts = {}\n get '/v1/search/illust', {\n **SEARCH_DEFAULT_OPT,\n word: keyword,\n **opts\n }\n end",
"def search\n\n end",
"def show\n @permitted_params = params.permit(Search::RESULTS_PARAMS +\n Search::SIMPLE_SEARCH_PARAMS)\n @start = [@permitted_params[:start].to_i.abs, MAX_START].min\n @window = window_size\n q = \"%#{@permitted_params[:q]&.downcase}%\"\n @terms = @vocabulary.vocabulary_terms.\n where(\"LOWER(displayed_value) LIKE ? OR LOWER(stored_value) LIKE ?\", q, q).\n order(:displayed_value)\n @count = @terms.count\n @terms = @terms.limit(@window).offset(@start)\n @current_page = ((@start / @window.to_f).ceil + 1 if @window > 0) || 1\n\n if request.xhr?\n render partial: \"terms\"\n else\n render \"show\"\n end\n end",
"def index\n @projects = Project.all\n @found_sector = Project.search(params['sector_name'], fields: [:sector_name])\n if @found_sector.length == 0\n @found_sector = Project.all\n end\n # query = params[:query].presence || \"*\"\n # conditions = {}\n # conditions[:sector_name] = params[:sector_name] if params[:sector_name].present?\n # conditions[:country] = params[:country] if params[:country].present?\n # @found_sector = Project.search query, where: conditions\n\n @found_sector = Project.search(params[:sector_name], fields: [:sector_name]).results &\n Project.search(params[:country], fields: [:country]).results &\n Project.search(params[:region], fields: [:region]).results\n if @found_sector.length == 0\n @found_sector = Project.all\n end\n end",
"def search(term,maxResults = 10 )\n refreshToken\n url = \"/api/search?\" + \"query=#{ERB::Util.url_encode(term)}\\&results=#{maxResults.to_i}\\&offset=2\\&auth=#{@token}\\&email=#{@email}\"\n result = agent.get(url)\n JSON.parse(result.body)\n end",
"def index\n @search = Keyword.search(params[:search])\n @keywords = @search.paginate(:page => params[:page], :per_page => GlobalSettings.per_page).order('id DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end",
"def index\n session[:special_words_search] ||= {}\n if params[:search_button]\n set_conditions\n elsif params[:clear_button]\n session[:special_words_search] = {}\n end\n\n # 検索条件を処理\n cond, order_by = make_conditions\n \n @special_words = find_login_owner(:special_words)\n .where(cond)\n .order(order_by)\n .page(params[:page])\n .per(current_user.per_page)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @special_words }\n end\n end",
"def index\n if can?(:read, Part)\n @parts = Part.ransack(params[:q])\n @searched = false\n @search_results = []\n if params[:q]\n @search_results = @parts.result(:distinct => true)\n @searched = true\n end\n render_template\n else\n redirect_to root_path\n end\n end",
"def index\n authorize! :read, Recipe\n @query = params[:query]\n @search_result = Recipe.search do\n fulltext params[:query]\n if params[:course_type_ids].present?\n all_of do\n params[:course_type_ids].each do |filter|\n with(:course_type_ids, filter)\n end\n end\n end\n if params[:exclu_course_type_ids].present?\n all_of do\n params[:exclu_course_type_ids].each do |filter|\n without(:course_type_ids, filter)\n end\n end\n end\n if params[:difficulty].present?\n all_of do\n params[:difficulty].each do |filter|\n with(:difficulty, filter)\n end\n end\n end\n if params[:exclu_difficulty].present?\n all_of do\n params[:exclu_difficulty].each do |filter|\n without(:difficulty, filter)\n end\n end\n end\n if params[:cost].present?\n all_of do\n params[:cost].each do |filter|\n with(:cost, filter)\n end\n end\n end\n if params[:exclu_cost].present?\n all_of do\n params[:exclu_cost].each do |filter|\n without(:cost, filter)\n end\n end\n end\n if params[:category_ids].present?\n all_of do\n params[:category_ids].each do |filter|\n with(:category_ids, filter)\n end\n end\n end\n if params[:exclu_category_ids].present?\n all_of do\n params[:exclu_category_ids].each do |filter|\n without(:category_ids, filter)\n end\n end\n end\n if params[:main_ingredient_ids].present?\n all_of do\n params[:main_ingredient_ids].each do |filter|\n with(:main_ingredient_ids, filter)\n end\n end\n end\n if params[:exclu_main_ingredient_ids].present?\n all_of do\n params[:exclu_main_ingredient_ids].each do |filter|\n without(:main_ingredient_ids, filter)\n end\n end\n end\n if params[:source_ids].present?\n all_of do\n params[:source_ids].each do |filter|\n with(:source_ids, filter)\n end\n end\n end\n if params[:exclu_source_ids].present?\n all_of do\n params[:exclu_source_ids].each do |filter|\n without(:source_ids, filter)\n end\n end\n end\n facet :course_type_ids\n facet :category_ids\n facet :main_ingredient_ids\n facet :source_ids\n facet :difficulty, :sort => :index\n facet :cost, :sort => :index\n paginate :page => params[:page] || 1, :per_page => 10\n order_by(:score, :desc)\n order_by(:created_at, :desc)\n end\n @query_params = params.except( :page )\n \n filters = [\n :course_type_ids, \n :exclu_course_type_ids, \n :difficulty, \n :exclu_difficulty, \n :cost, \n :exclu_cost, \n :category_ids, \n :exclu_category_ids, \n :main_ingredient_ids, \n :exclu_main_ingredient_ids, \n :source_ids, \n :exclu_source_ids\n ]\n filters.each do |filter|\n if params[filter].present?\n params[filter].map!{ |x| x.to_i }\n end\n end\n \n # @search_result.facet(:main_ingredient_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n # @search_result.facet(:course_type_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n # @search_result.facet(:category_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n # @search_result.facet(:source_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n \n sort_alphabetical(@search_result.facet(:main_ingredient_ids).rows)\n sort_alphabetical(@search_result.facet(:course_type_ids).rows)\n sort_alphabetical(@search_result.facet(:category_ids).rows)\n sort_alphabetical(@search_result.facet(:source_ids).rows)\n end",
"def index\n if !params[:commit].nil? && params[:commit].downcase == \"search\"\n if !params[:q].blank?\n @results = Mountain.search(params[:q])\n else\n @results = Mountain.search({:id_eq => 0})\n end\n\n @mountains = @results.result\n\n else\n @mountains = Mountain.all\n end\n\n end",
"def text\n \tlat = params[:latitude]\n lng = params[:longitude]\n city_filter = current_user_city\n search_text = params[:search_text].to_s.downcase\n main_limit = 20\n if params[:search_type] && params[:search_type].to_i.eql?(2)\n\n stores = Store.without_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n\n outlet_stores = Store.with_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n outlets = Outlet.outlet_status.allowed_outlets(city_filter)\n .where(['lower(outlets.locality) like ?', \"%#{search_text}%\"])\n .select('outlets.id, outlets.locality, outlets.store_id')\n .reorder('outlets.locality').limit(main_limit)\n \n results = []\n results.concat stores.map { |store| text_response(2, store, store.name) }\n results.concat outlet_stores.map { |store| text_response(4, store, store.local_name ) }\n results.concat outlets.map { |outlet| text_response(5, outlet, outlet.local_name) }\n else\n # malls = Mall.allowed_malls.where(['lower(malls.name) like ?', \"%#{search_text}%\"])\n stores = Store.without_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n\n deals = Deal.without_outlets.group('deals.id').click_notify_allowed_deals(city_filter, [Deal::DealType[:rd], Deal::DealType[:ed], Deal::DealType[:pd]])\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line')\n .reorder('deals.main_line').limit(main_limit)\n outlet_stores = Store.with_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n outlets = Outlet.outlet_status.allowed_outlets(city_filter)\n .where(['lower(outlets.locality) like ?', \"%#{search_text}%\"])\n .select('outlets.id, outlets.locality, outlets.store_id')\n .reorder('outlets.locality').limit(main_limit)\n outlet_deals = Deal.with_outlets.group('deals.id').click_notify_allowed_deals(city_filter, [Deal::DealType[:rd], Deal::DealType[:ed], Deal::DealType[:pd]])\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line')\n .reorder('deals.main_line').limit(main_limit)\n lmd_deals = Deal.without_outlets.click_notify_allowed_deals(city_filter, Deal::DealType[:lmd]).in_last_minute_deal_time\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line, deals.last_end_time')\n .reorder('deals.main_line').limit(main_limit)\n lmd_outlet_deals = Deal.with_outlets.group('deals.id').click_notify_allowed_deals(city_filter, Deal::DealType[:lmd]).in_last_minute_deal_time\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line, deals.last_end_time')\n .reorder('deals.main_line').limit(main_limit)\n\n results = []\n # results.concat malls.map { |mall| text_response(1, mall, mall.name) }\n results.concat stores.map { |store| text_response(2, store, store.name) }\n results.concat deals.map { |deal| text_response(3, deal, deal.main_line) }\n results.concat outlet_stores.map { |store| text_response(4, store, store.local_name ) }\n results.concat outlets.map { |outlet| text_response(5, outlet, outlet.local_name) }\n results.concat(outlet_deals.map do |deal|\n deal.outlets.map { |outlet| text_response(6, deal, deal.main_line, { outlet_id: outlet.id }) }\n end.flatten)\n results.concat lmd_deals.map { |deal| text_response(7, deal, deal.main_line, { time_difference: deal.lmd_time_difference.strftime(\"%H:%M\"), deal_category_id: deal.try(:deal_category_ids).try(:first) }) }\n results.concat(lmd_outlet_deals.map do |deal|\n deal.outlets.map { |outlet| text_response(8, deal, deal.main_line, { outlet_id: outlet.id, time_difference: deal.lmd_time_difference.strftime(\"%H:%M\"), deal_category_id: deal.try(:deal_category_ids).try(:first) }) }\n end.flatten)\n end\n render_success(results: results.compact.sort_by {|h| h[:text] }.first(main_limit))\n end",
"def search\n\n end",
"def search_for_example\n visit('/locations?keyword=alpha%20app')\n end",
"def search\n @search_keyword = params[\"search\"]\n @project_id = params[:project_id]\n @country = params[\"country\"]\n @age_from = params[\"age_from\"]\n @age_from = @age_from.to_i if !@age_from.blank?\n @age_to = params[\"age_to\"]\n @age_to = @age_to.to_i if !@age_to.blank?\n if !@age_from.blank? && !@age_to.blank? && @age_from > @age_to\n temp = @age_from\n @age_from = @age_to\n @age_to = temp\n end\n @gender = params[\"gender\"]\n @education = params[\"education\"]\n if !@search_keyword.blank?\n @search_keyword = @search_keyword.strip\n @search_keyword = @search_keyword.split(\" \").join(\" \")\n @no_synonyms_found = false\n @search_keyword_model = Keyword.find_by_name(@search_keyword)\n if !@search_keyword_model.blank?\n @synonyms, @votes =\n @search_keyword_model.retrieve_synonyms(@country, @age_from, @age_to, @gender, @education)\n @no_synonyms_found = true if @synonyms.blank?\n @total_votes = 0\n @votes.each { |synonym_id, synonym_votes| @total_votes += synonym_votes }\n else\n redirect_to search_keywords_path(search: @search_keyword)\n end\n else\n redirect_to search_keywords_path\n end\n end",
"def search\n unless params[:search].blank?\n @search = Sunspot.search(KyuEntry) do\n fulltext params[:search]\n end\n @kyu = @search.results\n end\n end",
"def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end",
"def do_search\n @search_text = params[:q]\n\n # Doctoring for the view to find matches:\n @q = @search_text\n @q.chop! if params[:q] =~ /\\*$/\n @q = @q[1..-1] if params[:q] =~ /^\\*/\n\n # TODO: we'll want some whitelist filtering here later:\n # params[:q] = \"#{@q}*\" unless params[:q] =~ /\\*$/ or params[:q] =~ /^[-+]/ or params[:q] =~ /\\s/\n params[:q] = I18n.transliterate(params[:q]).downcase\n\n # TODO: This search suggestions block is large; extract.\n\n # First step (and, yes, this will be slow—we will optimize later), look for\n # search suggestions that match the query:\n words = params[:q].split # TODO: we might want to remove words with ^-\n # TODO: we might also want to remove stopwords e.g.: https://github.com/brenes/stopwords-filter\n suggestions = []\n # YUCK! This is the best way to do this in Searchkick at the moment, though.\n # :S\n words.each do |word|\n word_search = SearchSuggestion.search(word, fields: [{ match: :exact }])\n suggestions += word_search.results if word_search.respond_to?(:results)\n end\n\n # If we only found one thing and they only asked for one thing:\n if suggestions.size == 1 && params[:q] !~ /\\s/\n Rails.logger.warn(\"One suggestion.\")\n # TODO: move this to a helper? It can't go on the model...\n suggestion = suggestions.first\n suggestion = suggestion.synonym_of if suggestion.synonym_of\n where = case suggestion.type\n when :page\n suggestion.page\n when :object_term\n term_records_path(uri: suggestion.object_term, object: true)\n when :path\n suggestion.path\n when :wkt_string\n flash[:notice] = \"Unimplemented, sorry.\"\n \"/\"\n end\n return redirect_to(where)\n elsif suggestions.size >= 2 && params[:q] =~ /\\s/\n Rails.logger.warn(\"Multiple suggestions.\")\n groups = suggestions.group_by(&:type)\n # Easier to handle:\n groups[:page] ||= []\n groups[:object_term] ||= []\n groups[:path] ||= []\n groups[:wkt_string] ||= []\n if groups[:page].size > 1\n Rails.logger.warn(\"Multiple PAGE suggestions.\")\n # We can't use suggestions if there's more than one species. Sorry.\n flash[:notice] = t(\"search.flash.more_than_one_species\",\n species: groups[:page].map(&:match).to_sentence)\n else\n Rails.logger.warn(\"0 or 1 Page suggestions.\")\n clade = groups[:page].try(:first).try(:page_id)\n Rails.logger.warn(\"Page suggestion: #{clade}\") if clade\n if groups[:object_term].size > 2\n Rails.logger.warn(\"Over two TERM suggestions.\")\n flash[:notice] = t(\"search.flash.more_than_two_terms\",\n terms: groups[:object_term].map(&:match).to_sentence)\n elsif groups[:path].size > 0\n Rails.logger.warn(\"...had PATH suggestions.\")\n flash[:notice] = t(\"search.flash.cannot_combine_paths\",\n path: groups[:path].map(&:match).to_sentence)\n else # NOTE: this assumes we only have OBJECT term suggestions, not predicates.\n Rails.logger.warn(\"Usable suggestions...\")\n (first, second) = groups[:object_term] # Arbitrary which is first...\n Rails.logger.warn(\"First term: #{first.object_term}\")\n Rails.logger.warn(\"Second term: #{second.object_term}\") if second\n return redirect_to(term_records_path(uri: first.object_term, object: true,\n and_object: second.try(:object_term), clade: clade))\n end\n end\n end\n\n @clade = if params[:clade]\n puts \"*\" * 100\n puts \"** Filtering by clade #{params[:clade]}\"\n # It doesn't make sense to filter some things by clade:\n params[:only] = if params[:only]\n Array(params[:only]) - [:collections, :users, :predicates, :object_terms]\n else\n [:pages, :media]\n end\n puts \"Only param should now be: #{params[:only]}\"\n Page.find(params[:clade])\n else\n nil\n end\n\n default = params.has_key?(:only)? false : true\n @types = {}\n [ :pages, :collections, :articles, :images, :videos, :videos, :sounds, :links, :users, :predicates, :object_terms ].\n each do |sym|\n @types[sym] = default\n end\n\n @types[params[:only].to_sym] = true if params.has_key?(:only)\n\n # if params.has_key?(:only)\n # Array(params[:only]).each { |type| @types[type.to_sym] = true }\n # elsif params.has_key?(:except)\n # Array(params[:except]).each { |type| @types[type.to_sym] = false }\n # end\n\n # NOTE: no search is performed unless the @types hash indicates a search for\n # that class is required:\n\n @pages = if @types[:pages]\n fields = %w[preferred_vernacular_strings^20 vernacular_strings^20 preferred_scientific_names^10 scientific_name^10 synonyms^10 providers resource_pks]\n match = words.size == 1 ? :text_start : :phrase\n basic_search(Page, boost_by: [:page_richness, :specificity, :depth], match: match, fields: fields,\n where: @clade ? { ancestry_ids: @clade.id } : nil,\n includes: [:preferred_vernaculars, :medium, { native_node: { node_ancestors: :ancestor } }])\n else\n nil\n end\n\n\n @collections = if @types[:collections]\n basic_search(Collection, fields: [\"name^5\", \"description\"])\n else\n nil\n end\n\n @articles = if @types[:articles]\n basic_search(Searchkick,\n fields: [\"name^5\", \"resource_pk^10\", \"owner\", \"description^2\"],\n where: @clade ? { ancestry_ids: @clade.id } : nil,\n index_name: [Article])\n else\n nil\n end\n\n @images = if @types[:images]\n media_search(\"image\")\n else\n nil\n end\n\n @videos = if @types[:videos]\n media_search(\"video\")\n else\n nil\n end\n\n @sounds = if @types[:sounds]\n media_search(\"sound\")\n else\n nil\n end\n\n # @links = if @types[:links]\n # basic_search(Searchkick,\n # fields: [\"name^5\", \"resource_pk^10\", \"owner\", \"description^2\"],\n # where: @clade ? { ancestry_ids: @clade.id } : nil,\n # index_name: [Link])\n # else\n # nil\n # end\n\n @users = if @types[:users]\n basic_search(User, fields: [\"username^6\", \"name^4\", \"tag_line\", \"bio^2\"])\n else\n nil\n end\n\n Searchkick.multi_search([@pages, @articles, @images, @videos, @sounds, @collections, @users].compact)\n\n @pages = PageSearchDecorator.decorate_collection(@pages) if @pages\n @articles = ArticleSearchDecorator.decorate_collection(@articles) if @articles\n @images = ImageSearchDecorator.decorate_collection(@images) if @images\n @videos = VideoSearchDecorator.decorate_collection(@videos) if @videos\n @sounds = SoundSearchDecorator.decorate_collection(@sounds) if @sounds\n @collections = CollectionSearchDecorator.decorate_collection(@collections) if @collections\n @users = UserSearchDecorator.decorate_collection(@users) if @users\n\n # if @types[:predicates]\n # @predicates_count = TraitBank.count_predicate_terms(@q)\n # # NOTE we use @q here because it has no wildcard.\n # @predicates = Kaminari.paginate_array(\n # TraitBank.search_predicate_terms(@q, params[:page], params[:per_page]),\n # total_count: @predicates_count\n # ).page(params[:page]).per(params[:per_page] || 50)\n # end\n #\n # if @types[:object_terms]\n # @object_terms_count = TraitBank.count_object_terms(@q)\n # # NOTE we use @q here because it has no wildcard.\n # @object_terms = Kaminari.paginate_array(\n # TraitBank.search_object_terms(@q, params[:page], params[:per_page]),\n # total_count: @object_terms_count\n # ).page(params[:page]).per(params[:per_page] || 50)\n # end\n\n respond_to do |fmt|\n fmt.html do\n @page_title = t(:page_title_search, query: @q)\n end\n\n fmt.js { }\n\n # TODO: JSON results for other types! TODO: move; this is view logic...\n fmt.json do\n render json: JSON.pretty_generate(@pages.results.as_json(\n except: :native_node_id,\n methods: :scientific_name,\n include: {\n preferred_vernaculars: { only: [:string],\n include: { language: { only: :code } } },\n # NOTE I'm excluding a lot more for search than you would want for\n # the basic page json:\n top_media: { only: [ :id, :guid, :owner, :name ],\n methods: [:small_icon_url, :medium_icon_url],\n include: { provider: { only: [:id, :name] },\n license: { only: [:id, :name, :icon_url] } } }\n }\n ))\n end\n end\n end",
"def search\n spotyfy_client = SpotyfyClient.new(params[:search])\n spotyfy_client.perform\n items = SpotyfyService.parse_hash(spotyfy_client.body)\n render :json => items.to_json\n end",
"def serachable_leafs\n leafs.select { |leaf| leaf && leaf.searchable && leaf.visible }.compact\n end",
"def search\n\n @search = Location.near(params[:search], 15, :order => :distance)\n \n @query = params[:search]\n @locations = @search\n \n @filtros = ajustaFiltros\n @precios = precios(@locations)\n @campos = self.campos\n @places = places(@locations,@filtros)\n @facets = facetas(@locations, @filtros)\n @json = @locations.to_gmaps4rails\n end",
"def index\n @q = params['q']\n\n if params['underground']\n tube = \" AND underground = 1\"\n else\n tube = \"\"\n end\n if params['lat'] and params['lng']\n lat = params['lat'].to_f\n lng = params['lng'].to_f\n @stations = Station.unscoped.select(\"stations.*, #{distance_sql(lat,lng)} AS distance\").where(\"lat IS NOT NULL AND lng IS NOT NULL\" + tube).order(\"distance ASC\").limit(1)\n elsif @q && !@q.empty?\n @stations = Station.where(\"(upper(crs) LIKE ? OR upper(name) LIKE ?)\" + tube, @q.upcase, \"%#{@q.upcase}%\").page(params[:page])\n else\n @stations = Station.page(params[:page])\n end\n\n respond_to do |format|\n format.html\n format.xml { render xml: @stations }\n format.json { render json: @stations, callback: params['callback'] }\n end\n end",
"def search; end",
"def index\n @search = params[\"search\"]\n if @search.present?\n client = Client.new(@search)\n response = client.call\n\n new_results = StoreSearch.new(@search, response).run\n if new_results\n scope_to_use = client.find_search_key || \"random\"\n\n if scope_to_use == \"category\"\n searches = Search.with_category(@search[\"category\"])\n @searches = Search.paginate(page: params[:page], per_page: 5).where(id: searches.map(&:id))\n # TODO recover former sintax\n # @searches = Search.paginate(page: params[:page], per_page: 5)\n # .with_category(@search[\"category\"])\n elsif scope_to_use == \"text\"\n @searches = Search.paginate(page: params[:page], per_page: 5)\n .with_text(@search[\"text\"])\n elsif scope_to_use == \"random\"\n @searches = Search.paginate(page: params[:page], per_page: 5)\n .created_randomly\n else\n @searches = Search.paginate(page: params[:page], per_page: 5)\n end\n else\n @searches = Search.paginate(page: params[:page], per_page: 5)\n end\n end\n \n @searches ||= Search.paginate(page: params[:page], per_page: 5)\n @search = Search.new()\n end",
"def search\n send_request\n parse_response\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def index\n if params[:keyword]\n @spots = Spot.find(:all, :conditions => [\"name like ?\", \"%#{params[:keyword]}%\"])\n else\n @spots = Spot.find(:all)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n format.json { render :json => @spots.to_json(:only => [:name, :latitude, :longitude, :visits_count])}\n end\n end",
"def search\n query = params[:q]\n works = ActiveFedora::SolrService.query(query, fq: @fq, fl: @fl, df: @df, rows: @max_rows) \n format_solr_keys(works)\n render(json: works)\n end",
"def index\n respond_with Official.search(official_search_params)\n end",
"def index\n @hp_searches = HpSearch.all\n end",
"def index\n @searches = searches_from_history\n end",
"def search_inspections\n search_business_context( true )\n end",
"def index\n @title = t('view.hierarchies.index_title')\n @searchable = true\n @hierarchies = Hierarchy.filtered_list(params[:q]).page(params[:page])\n end",
"def\tsearch\n\t\tresult = query_google_places\n\t\trender :json => result\n\tend",
"def search\n\n # extract the terms from params\n terms = params[:search_terms]\n\n # redirect to root in case of missing terms\n redirect_to root_path && return if terms.blank?\n\n # extract the terms to an array\n # delete('-') because phones are saved without '-' (numbers only)\n terms_array = params[:search_terms].delete('-').split(' ')\n\n # extract the params using private methods\n age = age_param(terms_array)\n phone = phone_param(terms_array)\n names_array = name_param_array(terms)\n\n # find the people available for the search terms\n @peoples = People.search_by_terms(names_array, phone, age)\n\n # renders 'search.js'\n end",
"def search\n @institutions = Institution.order(:nome).where(\"nome ilike ?\", \"%#{params[:term]}%\")\n render json: @institutions.map{|institution| {:label => institution.nome, :value => institution.id}}\n end",
"def results\n # lat, lng, and term from user.js AJAX get request\n p params\n @lat = params[:lat]\n @long = params[:lng]\n term = params[:term]\n yelp_params = { term: term, limit: 5, sort: 1}\n coordinates = { latitude: @lat, longitude: @long }\n new_search = Yelp.client.search_by_coordinates(coordinates, yelp_params)\n # TODO - refactor into a separate function\n p new_search\n new_search.businesses.each do |business|\n \t result_name = business.name\n result_distance = business.distance\n \t result_address = business.location.address\n \t result_lat = business.location.coordinate.latitude\n \t result_long = business.location.coordinate.longitude\n \t # result_review = business.review_count\n \t # result_rating = business.rating\n end \n render json: new_search\n end",
"def current_spots\n\n if current_spots_params[:filter] && current_spots_params[:filter][:location]\n location = RGeo::GeoJSON.decode(current_spots_params[:filter][:location])\n end\n # assign default location (LA City Hall) if one couldn't be deciphered from the params.\n location ||= LA_LOCATION\n\n limit = current_spots_params[:limit] || 20\n\n @spots = Spot.current.near(location).limit(limit).includes(:guesses, :user, :game)\n\n respond_to do |format|\n format.json\n end\n end",
"def search\n # bail out if doing an unauthenticated API request\n failures = []\n respond_to do |format|\n format.html do\n @test_instances, failures = \n TestInstance.query(params[:query_text]) if params[:query_text]\n if @test_instances\n @test_instances = @test_instances.page(params[:page])\n end\n unless failures.empty?\n flash.now[:warning] = 'Invalid search parameters: ' + \n failures.join(', ') + '.'\n end\n @show_instructions = @test_instances.nil?\n end\n format.json do\n if authenticated?\n @test_instances, failures = \n TestInstance.query(params[:query_text]) if params[:query_text]\n if @test_instances\n render json: {\"results\" => @test_instances,\n \"failures\" => failures}.to_json\n else\n render json: {\"results\" => [], \"failures\" => failures}.to_json\n end\n else\n fail_authenticate_json\n end\n end\n end\n end",
"def search\nend",
"def search\n end",
"def search\n @core_search.joins(:name_status)\n .select('max(name.id) id')\n .select('max(name.simple_name) simple_name')\n .select('max(name.full_name) full_name')\n .select('max(name.full_name_html) full_name_html')\n .select('tree_element.excluded')\n .select('max(name_status.id) name_status_id')\n .select('max(name_status.name) name_status_name_')\n .select('instance_type.misapplied')\n .select('instance_type.pro_parte')\n .select('max(names_instance.full_name) cross_referenced_full_name')\n .select('null cross_reference_misapplication_details')\n .select('max(names_instance.id) cross_referenced_full_name_id')\n .select('max(instance.id) instance_id')\n .select('max(citer_instances_instance.id) citers_instance_id')\n .select('max(tree_version_element.name_path) name_path')\n .select('null profile')\n .select('null synonyms')\n .select('true cross_reference')\n .select('max(names_instance.full_name_html) cross_ref_full_name_html')\n .select('instance_type.doubtful')\n .select('max(reference.citation) reference_citation')\n .group(main_group_by_columns)\n .limit(@parser.limit)\n .offset(@parser.offset)\n .order(' full_name ')\n end",
"def search\n @kms = params[:kms]\n if current_user\n @pets = Pet.where.not(user_id: current_user.id, adpted: 't').within(@kms.to_i, :origin=>[19.3234472,-99.1796417])\n @hash = Gmaps4rails.build_markers(@pets) do |pet, marker|\n marker.lat pet.latitude\n marker.lng pet.longitude\n marker.infowindow '<a style=\"font-size:18px\" href=\"'+pet_path(pet)+'\">'+pet.name+'</a>'\n end\n else\n @pets = Pet.where(adpted: 'f').within(@kms.to_i, :origin=>[19.3234472,-99.1796417])\n @hash = Gmaps4rails.build_markers(@pets) do |pet, marker|\n marker.lat pet.latitude\n marker.lng pet.longitude\n marker.infowindow '<a style=\"font-size:18px\" href=\"'+pet_path(pet)+'\">'+pet.name+'</a>'\n end\n end\n @hash << { \"lat\":19.3234472, \"lng\":-99.1796417, \"infowindow\":'<div style=\"font-size:18px\">Aqui estas tu</div> ' }\n puts @hash.to_json\n end",
"def index\n \n @show_all_features = true\n if params.has_key?(:search)\n @search = params[:search]\n #problem_this_solves, :mandatory_requirements, :technical_notes,extra_notes\n @features_searched = AppFeatureRequest.joins(:app_feature_comment).where(\"problem_this_solves like ? \n or mandatory_requirements like ? or technical_notes like ? or extra_notes like ? or name like ? \n or app_feature_comments.details like ?\", \"%#{@search}%\", \"%#{@search}%\", \"%#{@search}%\", \"%#{@search}%\", \n \"%#{@search}%\", \"%#{@search}%\")\n .paginate(:page => params[:page]) #.all\n @show_all_features = false\n else\n @show_all_features = true\n show_all_features_and_errors\n end\n\n @display_level = AppCommentDisplayLevel.all\n end",
"def Search query\n \n APICall(path: \"search.json?query=#{query}\",method: 'GET')\n \n end",
"def search\n @query = params[:q]\n @editions = Book.search(@query)\n respond_to do |format|\n format.html # show.html.haml\n format.xml { render :xml => @editions }\n end\n end",
"def index\n #@words = Word.all.order('created_at DESC').paginate(:page => params[:page])\n #@definitions = @words.each {|word| word.definitions.order(:cached_votes_up => :desc)}\n\n if params[:letter]\n @words = Word.all.order('created_at DESC').where(\"word like ?\", params[:letter] +\"%\" ).paginate(:page => params[:page])\n # creates this /words?letter=i\n elsif params[:term]\n @words = Word.where('word LIKE ?', \"%#{params[:term]}%\").paginate(:page => params[:page])\n else\n @words = Word.all.order('created_at DESC').paginate(:page => params[:page])\n end\n\n respond_to do |format|\n format.html # will render index.html.erb in case of a HTML request\n format.js # will render index.js.erb in case of an AJAX request\n end\n end",
"def index\n if params[:query].present?\n @animals = Animal.search_by_species(params[:query])\n if params[:search].present?\n @animals = @animals.where(care_level: params[:search])\n end\n else\n @animals = Animal.all\n if params[:search].present?\n @animals = @animals.where(care_level: params[:search])\n end\n @previous_search = ''\n end\n end",
"def index\n @microspots = Microspot.all\n\n if params[:search]\n @microspots = Microspot.search(params[:search]).order(\"created_at DESC\")\n else\n @microspots = Microspot.all.order('created_at DESC')\n end\n end"
] | [
"0.7002329",
"0.6680524",
"0.6360336",
"0.6002374",
"0.594759",
"0.5936186",
"0.59035736",
"0.58770686",
"0.5854715",
"0.5835244",
"0.5832496",
"0.5823618",
"0.57928723",
"0.57237566",
"0.5723646",
"0.5707511",
"0.57050204",
"0.5703179",
"0.5700361",
"0.56868213",
"0.5672963",
"0.5664586",
"0.5659352",
"0.5655769",
"0.56426126",
"0.56365937",
"0.5632999",
"0.5621901",
"0.561593",
"0.56137824",
"0.5600055",
"0.5597372",
"0.5581834",
"0.55774355",
"0.55676824",
"0.5561951",
"0.55584306",
"0.5557624",
"0.5549915",
"0.5546118",
"0.5542282",
"0.5536848",
"0.55359244",
"0.5531466",
"0.5529241",
"0.5522325",
"0.5522117",
"0.5519635",
"0.5518117",
"0.5516699",
"0.55164844",
"0.55107045",
"0.55100095",
"0.5506665",
"0.5506173",
"0.55049336",
"0.55036104",
"0.5499682",
"0.548072",
"0.54782885",
"0.54770523",
"0.5475594",
"0.5466212",
"0.54641587",
"0.5461506",
"0.545904",
"0.5458806",
"0.54572934",
"0.54572934",
"0.54572934",
"0.54572934",
"0.54572934",
"0.54572934",
"0.54572934",
"0.54572934",
"0.54572934",
"0.54572934",
"0.5451657",
"0.5447739",
"0.54451555",
"0.54395986",
"0.543955",
"0.54395396",
"0.54370743",
"0.54343766",
"0.54338527",
"0.5431277",
"0.5425027",
"0.54129714",
"0.54110736",
"0.5392653",
"0.5388532",
"0.53788275",
"0.53755426",
"0.5374829",
"0.53738695",
"0.5372648",
"0.5371773",
"0.5369962",
"0.5360834"
] | 0.7771079 | 0 |
GET /leaf_spot_imm_searches/1 GET /leaf_spot_imm_searches/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @leaf_spot_imm_searches = LeafSpotImmSearch.all\n end",
"def set_leaf_spot_imm_search\n @leaf_spot_imm_search = LeafSpotImmSearch.find(params[:id])\n end",
"def leaf_spot_imm_search_params\n params.require(:leaf_spot_imm_search).permit(:search_id, :leaf_spot_imm_id)\n end",
"def index\n @search = WordRoot.ransack(params[:q])\n @word_roots = @search.result.paginate(:page => params[:page], per_page: 20)\n end",
"def create\n @leaf_spot_imm_search = LeafSpotImmSearch.new(leaf_spot_imm_search_params)\n\n respond_to do |format|\n if @leaf_spot_imm_search.save\n format.html { redirect_to @leaf_spot_imm_search, notice: 'Leaf spot imm search was successfully created.' }\n format.json { render :show, status: :created, location: @leaf_spot_imm_search }\n else\n format.html { render :new }\n format.json { render json: @leaf_spot_imm_search.errors, status: :unprocessable_entity }\n end\n end\n end",
"def search_any_term\n render json: Article.with_any_terms(params[:query]).map(&:title)\n end",
"def search\n @hits = []\n\n if params[:query]\n search = DesignMethod.solr_search do\n fulltext params[:query] do\n highlight\n minimum_match 0\n end\n end\n store_location\n @hits = search.hits\n @results = search.results\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def search_all_terms\n render json: Article.with_all_terms(params[:query]).map(&:title)\n end",
"def index\n @query = params[:query] || {\n search: '',\n }\n @theorems = Theorem.all.where(root: true).limit(50)\n @theorems = @theorems.order('views desc')\n @theorems = @theorems.where('text ILIKE ?', \"%#{@query[:search]}%\") if @query[:search] && @query[:search].length > 0\n respond_to do |f|\n f.html { render 'index' }\n f.json { render json: @theorems }\n end\n end",
"def search_for_active_towns\n q = params[:query].mb_chars.capitalize.to_s\n @towns = Town.get_central_authority_towns(q).order_by(:level => :asc)\n respond_to do |format|\n format.json { render 'search'}\n end\n end",
"def search\n terms = @authority.search(url_search)\n render json: terms\n end",
"def update\n respond_to do |format|\n if @leaf_spot_imm_search.update(leaf_spot_imm_search_params)\n format.html { redirect_to @leaf_spot_imm_search, notice: 'Leaf spot imm search was successfully updated.' }\n format.json { render :show, status: :ok, location: @leaf_spot_imm_search }\n else\n format.html { render :edit }\n format.json { render json: @leaf_spot_imm_search.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n # @entries = Entry.all\n @search.sorts = ['term desc', 'created_at desc'] if @search.sorts.empty?\n @search_term = params[:q]\n @entries = @search\n .result(distinct: true)\n .includes(:definitions)\n .page(params[:page])\n .per(params[:per_page])\n\n\n 1\n end",
"def index\n @flagged_words = FlaggedWord.search(params[:search], params[:page], 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @flagged_words }\n end\n end",
"def search\n @q = params[:q]\n @results = Series.external_search(@q)\n\n respond_to do |format|\n format.html # search.html.haml\n format.json { render json: @results.to_json }\n end\n end",
"def search_ranked\n render json: Article.with_ranked_terms(params[:query]).map(&:title)\n end",
"def index\n @searches = @website.searches.all\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @searches }\n end\n end",
"def search\n @selected = Herb.find_by_id(params[:search])\n if @selected\n redirect_to @selected and return\n else\n \n @search = Herb.search do\n fulltext params[:search]\n\n end\n @herbs = @search.results\n @first = @herbs.pop\n @second = @herbs.pop\n @third = @herbs.pop\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @herbs }\n end\n end",
"def search_for_towns_and_areas\n @towns = use_cache get_controller_action_key do\n Town.all.reject{|town| town.level != 13 && town.level != 1 }\n end\n\n respond_to do |format|\n q = params[:query].mb_chars.capitalize.to_s\n @towns = @towns.select{ |t| Regexp.new(\"^#{q}.*\") =~ t.title }\n format.json\n end\n\n end",
"def place_search\n @places = []\n area = params[:area_id].blank? ? nil : Place.find(params[:area_id])\n if area.present? && area.area > 0\n search_text = Riddle::Query.escape(help.strip_links(params[:search]))\n results = Place.search(search_text, :field_weights => { :name => 10 })\n\n results.each do |place|\n @places << place if place.areas.include?(area)\n end\n end\n \n respond_to do |format|\n format.json\n end\n end",
"def index\n search = Sunspot.new_search(Classification)\n query = params[:query].to_s.strip\n if query.present?\n @query = query.dup\n search.build do\n fulltext query\n end\n end\n unless params[:mode] == 'add'\n subject = @subject\n classification_type = @classification_type\n search.build do\n with(:subject_ids).equal_to subject.id if subject\n with(:classification_type_id).equal_to classification_type.id if classification_type\n end\n end\n\n page = params[:page] || 1\n search.query.paginate(page.to_i, Classification.default_per_page)\n @classifications = search.execute!.results\n\n session[:params] = {} unless session[:params]\n session[:params][:classification] = params\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def search_for_areas\n @towns = use_cache get_controller_action_key do\n Town.all.reject{|town| town.level != 1 }\n end\n\n respond_to do |format|\n q = params[:query].mb_chars.capitalize.to_s\n @towns = @towns.select{ |t| Regexp.new(\"^#{q}.*\") =~ t.title }\n format.json\n end\n\n end",
"def index\n if params[:keyword]\n @spots = Spot.find(:all, :conditions => [\"name like ?\", \"%#{params[:keyword]}%\"])\n else\n @spots = Spot.find(:all)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n format.json { render :json => @spots.to_json(:only => [:name, :latitude, :longitude, :visits_count])}\n end\n end",
"def index\n @search = Keyword.search(params[:search])\n @keywords = @search.paginate(:page => params[:page], :per_page => GlobalSettings.per_page).order('id DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end",
"def index\n # Generate sunspot search\n @records = record_default_search\n\n respond_with(@records)\n end",
"def search\n \n search = params[:search]\n miniresume = params[:miniresume]\n location = params[:location]\n\n #thinking_sphinx conditions - \n @adviceposts = Advicepost.search(search,miniresume,location,page: 1, per_page: 25)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @adviceposts }\n end\n end",
"def show\n @permitted_params = params.permit(Search::RESULTS_PARAMS +\n Search::SIMPLE_SEARCH_PARAMS)\n @start = [@permitted_params[:start].to_i.abs, MAX_START].min\n @window = window_size\n q = \"%#{@permitted_params[:q]&.downcase}%\"\n @terms = @vocabulary.vocabulary_terms.\n where(\"LOWER(displayed_value) LIKE ? OR LOWER(stored_value) LIKE ?\", q, q).\n order(:displayed_value)\n @count = @terms.count\n @terms = @terms.limit(@window).offset(@start)\n @current_page = ((@start / @window.to_f).ceil + 1 if @window > 0) || 1\n\n if request.xhr?\n render partial: \"terms\"\n else\n render \"show\"\n end\n end",
"def index\n @query = params[:q] || '*:*'\n query = Jbuilder.encode do |json|\n json.filter do\n json.missing do\n json.field \"parent_id\"\n end\n end\n json.query do\n json.query_string do\n json.query @query\n end\n end\n json.sort do\n json.node \"asc\"\n end\n end\n @themata = Thema.__elasticsearch__.search(query).page(params[:page]).records\n end",
"def search\n @maps = Map.find_map_by_input(@maps, params[:name])\n render json: @maps\n end",
"def search\n @listings = Listing.search do\n keywords params[:query]\n end.results\n\n respond_to do |format|\n format.html { render :action => \"show\" }\n format.xml { render :xml => @listings }\n end\n end",
"def searches\n Boundary.get(@url)\n end",
"def index\n # @search = Shelter.search do\n # fulltext params[:search]\n # end\n # @shelters = @search.results\n @shelters = Shelter.all\nend",
"def index\n if !params[:commit].nil? && params[:commit].downcase == \"search\"\n if !params[:q].blank?\n @results = Mountain.search(params[:q])\n else\n @results = Mountain.search({:id_eq => 0})\n end\n\n @mountains = @results.result\n\n else\n @mountains = Mountain.all\n end\n\n end",
"def search\n @institutions = Institution.order(:nome).where(\"nome ilike ?\", \"%#{params[:term]}%\")\n render json: @institutions.map{|institution| {:label => institution.nome, :value => institution.id}}\n end",
"def search\n query = params[:q]\n works = ActiveFedora::SolrService.query(query, fq: @fq, fl: @fl, df: @df, rows: @max_rows) \n format_solr_keys(works)\n render(json: works)\n end",
"def search\n search_param = params[:term]\n matching_keys = UserKey.submitted.search(search_param).collect { |u| { value: \"#{u.name}\", data: u.id } }\n render json: { suggestions: matching_keys }\n end",
"def results\n # lat, lng, and term from user.js AJAX get request\n p params\n @lat = params[:lat]\n @long = params[:lng]\n term = params[:term]\n yelp_params = { term: term, limit: 5, sort: 1}\n coordinates = { latitude: @lat, longitude: @long }\n new_search = Yelp.client.search_by_coordinates(coordinates, yelp_params)\n # TODO - refactor into a separate function\n p new_search\n new_search.businesses.each do |business|\n \t result_name = business.name\n result_distance = business.distance\n \t result_address = business.location.address\n \t result_lat = business.location.coordinate.latitude\n \t result_long = business.location.coordinate.longitude\n \t # result_review = business.review_count\n \t # result_rating = business.rating\n end \n render json: new_search\n end",
"def search\n spotyfy_client = SpotyfyClient.new(params[:search])\n spotyfy_client.perform\n items = SpotyfyService.parse_hash(spotyfy_client.body)\n render :json => items.to_json\n end",
"def index\n @leafs = Leaf.all\n end",
"def all\n\t\tquery = (params[:term] || params[:query])\n\t\t\n @search_results = PgSearch\n\t\t\t.multisearch(query)\n\t\t\t.page(params[:page])\n\t\t\n\t\trender 'multi_search'\n\tend",
"def search keyword, opts = {}\n get '/v1/search/illust', {\n **SEARCH_DEFAULT_OPT,\n word: keyword,\n **opts\n }\n end",
"def search\n @search_keyword = params[\"search\"]\n @project_id = params[:project_id]\n @country = params[\"country\"]\n @age_from = params[\"age_from\"]\n @age_from = @age_from.to_i if !@age_from.blank?\n @age_to = params[\"age_to\"]\n @age_to = @age_to.to_i if !@age_to.blank?\n if !@age_from.blank? && !@age_to.blank? && @age_from > @age_to\n temp = @age_from\n @age_from = @age_to\n @age_to = temp\n end\n @gender = params[\"gender\"]\n @education = params[\"education\"]\n if !@search_keyword.blank?\n @search_keyword = @search_keyword.strip\n @search_keyword = @search_keyword.split(\" \").join(\" \")\n @no_synonyms_found = false\n @search_keyword_model = Keyword.find_by_name(@search_keyword)\n if !@search_keyword_model.blank?\n @synonyms, @votes =\n @search_keyword_model.retrieve_synonyms(@country, @age_from, @age_to, @gender, @education)\n @no_synonyms_found = true if @synonyms.blank?\n @total_votes = 0\n @votes.each { |synonym_id, synonym_votes| @total_votes += synonym_votes }\n else\n redirect_to search_keywords_path(search: @search_keyword)\n end\n else\n redirect_to search_keywords_path\n end\n end",
"def show\n respond_to do |format|\n format.html do \n if @custom_search_engine.publish? || current_user == @custom_search_engine.author\n @valid_labels = @custom_search_engine.labels.map { |l| l.name }\n @labels_hash = Hash.new\n @no_labels_arr = Array.new\n @custom_search_engine.annotations.score_desc.each do |a|\n if a.labels_list.any?\n a.labels_list.each do |l|\n if @valid_labels.include?(l)\n @labels_hash[l] = Array.new if @labels_hash[l].nil?\n @labels_hash[l].push(a)\n else\n @no_labels_arr.push(a)\n end\n end\n else\n @no_labels_arr.push(a)\n end \n end\n if @custom_search_engine.status == 'publish' && current_user != @custom_search_engine.author\n @custom_search_engine.inc(:browse_count, 1)\n end\n render 'show'\n else\n flash[:error] = I18n.t('human.errors.only_publish_cse_available')\n redirect_to nodes_path \n end\n end\n #format.json { render json: @custom_search_engine }\n format.xml { @labels = @custom_search_engine.labels }\n end\n end",
"def index\n @q = params['q']\n\n if params['underground']\n tube = \" AND underground = 1\"\n else\n tube = \"\"\n end\n if params['lat'] and params['lng']\n lat = params['lat'].to_f\n lng = params['lng'].to_f\n @stations = Station.unscoped.select(\"stations.*, #{distance_sql(lat,lng)} AS distance\").where(\"lat IS NOT NULL AND lng IS NOT NULL\" + tube).order(\"distance ASC\").limit(1)\n elsif @q && !@q.empty?\n @stations = Station.where(\"(upper(crs) LIKE ? OR upper(name) LIKE ?)\" + tube, @q.upcase, \"%#{@q.upcase}%\").page(params[:page])\n else\n @stations = Station.page(params[:page])\n end\n\n respond_to do |format|\n format.html\n format.xml { render xml: @stations }\n format.json { render json: @stations, callback: params['callback'] }\n end\n end",
"def keyword\n\n @search_text = params[\"search_text\"] ||= \"\"\n\n add_breadcrumb \"Keyword Search: '#{@search_text}'\"\n\n if @search_text.blank? or @search_text.length < 2\n @keyword_search_results = KeywordSearchIndex.where(\"1 = 2\")\n else\n\n # here we build the query one clause at a time based on the input params. The query\n # is of the form:\n #\n # where organization_id IN (?) AND (search_text LIKE ? OR search_text_like ? OR ... )\n\n where_clause = 'organization_id IN (?) AND ('\n values = []\n # The organization is scoped to search across all objects that are owned by\n # the user's list of organizations\n orgs = @organization_list.dup\n # add org = 0 to get objects that are not indexed by org and are by\n # contract available to users of all organizations\n orgs << 0\n values << orgs\n\n search_params = []\n @search_text.split(\",\").each_with_index do |search_string|\n search_params << 'search_text LIKE ?'\n values << \"%#{search_string.strip}%\"\n end\n\n where_clause << search_params.join(' OR ')\n where_clause << ')'\n\n @keyword_search_results = KeywordSearchIndex.where(where_clause, *values)\n\n end\n\n @num_rows = @keyword_search_results.count\n cache_list(@keyword_search_results, INDEX_KEY_LIST_VAR)\n\n respond_to do |format|\n format.html\n format.json {\n render :json => {\n :total => @num_rows,\n :rows => data\n }\n }\n end\n\n end",
"def get_results()\n restriction_nodes = []\n result_nodes = []\n if !(@inputs.nil? || @inputs.empty? || @inputs.first.empty?)\n input_set = @inputs.first\n restriction_nodes= input_set.nodes\n result_nodes = input_set.breadth_first_search(true){|node| node.item.text.downcase.include?(@keyword_phrase.to_s.downcase)} \n end\n \n if !@inplace\n results = @server.match_all(parse_keyword_phrase(), restriction_nodes) \n result_nodes = results.map{|item| Xplain::Node.new(item: item)}\n end\n \n result_nodes\n \n end",
"def\tsearch\n\t\tresult = query_google_places\n\t\trender :json => result\n\tend",
"def index\n @leaves = Leaf.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leaves }\n end\n end",
"def search\n @places = FoursquarePlace.places_near_coordinates(@coordinates, query: params[:search_terms])\n render json: { data: @places }\n end",
"def index\n query = params[:query].to_s.strip\n search = Sunspot.new_search(Work)\n @count = {}\n unless query.blank?\n @query = query.dup\n query = query.gsub(' ', ' ')\n search.build do\n fulltext query\n end\n end\n\n set_role_query(current_user, search)\n\n unless params[:mode] == 'add'\n patron = @patron\n subject = @subject\n work = @work\n work_merge_list = @work_merge_list\n search.build do\n with(:patron_ids).equal_to patron.id if patron\n with(:subject_ids).equal_to subject.id if subject\n with(:original_work_ids).equal_to work.id if work\n with(:work_merge_list_ids).equal_to work_merge_list.id if work_merge_list\n end\n end\n\n role = current_user.try(:role) || Role.find('Guest')\n search.build do\n with(:required_role_id).less_than_or_equal_to role.id\n end\n\n page = params[:page] || 1\n search.query.paginate(page.to_i, Work.default_per_page)\n @works = search.execute!.results\n @count[:total] = @works.total_entries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @works }\n format.atom\n end\n end",
"def index\n page = params[:page] || 1\n page = page.to_i\n per_page = params[:per_page] || 25\n per_page = per_page.to_i\n @results = {}\n\n search = params[:searchterm]\n if search && search.empty?\n search = nil\n end\n\n if search\n page = 1\n per_page = 50\n @stats = SearchEngine.search(Stat, search)\n total = @stats.count\n @stats = Kaminari.paginate_array(@stats).page(page).per(per_page)\n \n @searchterm = search\n else\n @stats = Stat.desc(:id).page(page).per(per_page)\n total = Stat.count\n end\n \n @results[:first] = (page-1) * per_page + 1\n @results[:last ] = [total, page * per_page].min\n @results[:total] = total\n end",
"def Search query\n \n APICall(path: \"search.json?query=#{query}\",method: 'GET')\n \n end",
"def search\n # max = (params[:valueMax] || 1_000_000).to_i\n # min = (params[:valueMin] || 0).to_i\n # @offers = Offer.where(\"title ILIKE :search AND value <= :max AND value >= :min\", { search: \"%#{params[:search]}%\", max: max, min: min })\n # render json: @offers\n max = (params[:valueMax] || 1_000_000).to_i\n min = (params[:valueMin] || 0).to_i\n @offers = []\n query = (params[:search])\n query.split(' ').each do |keyword|\n @offers += Offer.where(\"title ILIKE :search AND value <= :max AND value >= :min\", { search: \"%#{keyword}%\", max: max, min: min })\n end\n render json: @offers\n end",
"def index\n @search = MicrornaPatient.search do\n fulltext params[:query_microrna_patient]\n end\n \n @microrna_patients = @search.results\n \n \n respond_to do |format|\n format.html\n format.json { render :json => @microrna_patients.map(&:attributes) }\n end\nend",
"def search_people(searchterm,params={})\n @opensearch.search_people(searchterm,params) \n end",
"def index\n @reloud_checks = ReloudCheck.search(params[:search])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reloud_checks }\n end\n end",
"def search\n if params[:collection_ids]\n data = {:sites => [], :clusters => []}\n params[:collection_ids].each do |id|\n result = search_by_collection id, params\n data[:sites].concat result[:sites] if result[:sites]\n data[:clusters].concat result[:clusters] if result[:clusters]\n end\n render json: data\n else\n render json: []\n end\n end",
"def index\n @microspots = Microspot.all\n\n if params[:search]\n @microspots = Microspot.search(params[:search]).order(\"created_at DESC\")\n else\n @microspots = Microspot.all.order('created_at DESC')\n end\n end",
"def index\n @projects = Project.all\n @found_sector = Project.search(params['sector_name'], fields: [:sector_name])\n if @found_sector.length == 0\n @found_sector = Project.all\n end\n # query = params[:query].presence || \"*\"\n # conditions = {}\n # conditions[:sector_name] = params[:sector_name] if params[:sector_name].present?\n # conditions[:country] = params[:country] if params[:country].present?\n # @found_sector = Project.search query, where: conditions\n\n @found_sector = Project.search(params[:sector_name], fields: [:sector_name]).results &\n Project.search(params[:country], fields: [:country]).results &\n Project.search(params[:region], fields: [:region]).results\n if @found_sector.length == 0\n @found_sector = Project.all\n end\n end",
"def search\n send_request\n parse_response\n end",
"def search(term,maxResults = 10 )\n refreshToken\n url = \"/api/search?\" + \"query=#{ERB::Util.url_encode(term)}\\&results=#{maxResults.to_i}\\&offset=2\\&auth=#{@token}\\&email=#{@email}\"\n result = agent.get(url)\n JSON.parse(result.body)\n end",
"def index\n respond_with Official.search(official_search_params)\n end",
"def text\n \tlat = params[:latitude]\n lng = params[:longitude]\n city_filter = current_user_city\n search_text = params[:search_text].to_s.downcase\n main_limit = 20\n if params[:search_type] && params[:search_type].to_i.eql?(2)\n\n stores = Store.without_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n\n outlet_stores = Store.with_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n outlets = Outlet.outlet_status.allowed_outlets(city_filter)\n .where(['lower(outlets.locality) like ?', \"%#{search_text}%\"])\n .select('outlets.id, outlets.locality, outlets.store_id')\n .reorder('outlets.locality').limit(main_limit)\n \n results = []\n results.concat stores.map { |store| text_response(2, store, store.name) }\n results.concat outlet_stores.map { |store| text_response(4, store, store.local_name ) }\n results.concat outlets.map { |outlet| text_response(5, outlet, outlet.local_name) }\n else\n # malls = Mall.allowed_malls.where(['lower(malls.name) like ?', \"%#{search_text}%\"])\n stores = Store.without_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n\n deals = Deal.without_outlets.group('deals.id').click_notify_allowed_deals(city_filter, [Deal::DealType[:rd], Deal::DealType[:ed], Deal::DealType[:pd]])\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line')\n .reorder('deals.main_line').limit(main_limit)\n outlet_stores = Store.with_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n outlets = Outlet.outlet_status.allowed_outlets(city_filter)\n .where(['lower(outlets.locality) like ?', \"%#{search_text}%\"])\n .select('outlets.id, outlets.locality, outlets.store_id')\n .reorder('outlets.locality').limit(main_limit)\n outlet_deals = Deal.with_outlets.group('deals.id').click_notify_allowed_deals(city_filter, [Deal::DealType[:rd], Deal::DealType[:ed], Deal::DealType[:pd]])\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line')\n .reorder('deals.main_line').limit(main_limit)\n lmd_deals = Deal.without_outlets.click_notify_allowed_deals(city_filter, Deal::DealType[:lmd]).in_last_minute_deal_time\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line, deals.last_end_time')\n .reorder('deals.main_line').limit(main_limit)\n lmd_outlet_deals = Deal.with_outlets.group('deals.id').click_notify_allowed_deals(city_filter, Deal::DealType[:lmd]).in_last_minute_deal_time\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line, deals.last_end_time')\n .reorder('deals.main_line').limit(main_limit)\n\n results = []\n # results.concat malls.map { |mall| text_response(1, mall, mall.name) }\n results.concat stores.map { |store| text_response(2, store, store.name) }\n results.concat deals.map { |deal| text_response(3, deal, deal.main_line) }\n results.concat outlet_stores.map { |store| text_response(4, store, store.local_name ) }\n results.concat outlets.map { |outlet| text_response(5, outlet, outlet.local_name) }\n results.concat(outlet_deals.map do |deal|\n deal.outlets.map { |outlet| text_response(6, deal, deal.main_line, { outlet_id: outlet.id }) }\n end.flatten)\n results.concat lmd_deals.map { |deal| text_response(7, deal, deal.main_line, { time_difference: deal.lmd_time_difference.strftime(\"%H:%M\"), deal_category_id: deal.try(:deal_category_ids).try(:first) }) }\n results.concat(lmd_outlet_deals.map do |deal|\n deal.outlets.map { |outlet| text_response(8, deal, deal.main_line, { outlet_id: outlet.id, time_difference: deal.lmd_time_difference.strftime(\"%H:%M\"), deal_category_id: deal.try(:deal_category_ids).try(:first) }) }\n end.flatten)\n end\n render_success(results: results.compact.sort_by {|h| h[:text] }.first(main_limit))\n end",
"def current_spots\n\n if current_spots_params[:filter] && current_spots_params[:filter][:location]\n location = RGeo::GeoJSON.decode(current_spots_params[:filter][:location])\n end\n # assign default location (LA City Hall) if one couldn't be deciphered from the params.\n location ||= LA_LOCATION\n\n limit = current_spots_params[:limit] || 20\n\n @spots = Spot.current.near(location).limit(limit).includes(:guesses, :user, :game)\n\n respond_to do |format|\n format.json\n end\n end",
"def index\n authorize! :read, Recipe\n @query = params[:query]\n @search_result = Recipe.search do\n fulltext params[:query]\n if params[:course_type_ids].present?\n all_of do\n params[:course_type_ids].each do |filter|\n with(:course_type_ids, filter)\n end\n end\n end\n if params[:exclu_course_type_ids].present?\n all_of do\n params[:exclu_course_type_ids].each do |filter|\n without(:course_type_ids, filter)\n end\n end\n end\n if params[:difficulty].present?\n all_of do\n params[:difficulty].each do |filter|\n with(:difficulty, filter)\n end\n end\n end\n if params[:exclu_difficulty].present?\n all_of do\n params[:exclu_difficulty].each do |filter|\n without(:difficulty, filter)\n end\n end\n end\n if params[:cost].present?\n all_of do\n params[:cost].each do |filter|\n with(:cost, filter)\n end\n end\n end\n if params[:exclu_cost].present?\n all_of do\n params[:exclu_cost].each do |filter|\n without(:cost, filter)\n end\n end\n end\n if params[:category_ids].present?\n all_of do\n params[:category_ids].each do |filter|\n with(:category_ids, filter)\n end\n end\n end\n if params[:exclu_category_ids].present?\n all_of do\n params[:exclu_category_ids].each do |filter|\n without(:category_ids, filter)\n end\n end\n end\n if params[:main_ingredient_ids].present?\n all_of do\n params[:main_ingredient_ids].each do |filter|\n with(:main_ingredient_ids, filter)\n end\n end\n end\n if params[:exclu_main_ingredient_ids].present?\n all_of do\n params[:exclu_main_ingredient_ids].each do |filter|\n without(:main_ingredient_ids, filter)\n end\n end\n end\n if params[:source_ids].present?\n all_of do\n params[:source_ids].each do |filter|\n with(:source_ids, filter)\n end\n end\n end\n if params[:exclu_source_ids].present?\n all_of do\n params[:exclu_source_ids].each do |filter|\n without(:source_ids, filter)\n end\n end\n end\n facet :course_type_ids\n facet :category_ids\n facet :main_ingredient_ids\n facet :source_ids\n facet :difficulty, :sort => :index\n facet :cost, :sort => :index\n paginate :page => params[:page] || 1, :per_page => 10\n order_by(:score, :desc)\n order_by(:created_at, :desc)\n end\n @query_params = params.except( :page )\n \n filters = [\n :course_type_ids, \n :exclu_course_type_ids, \n :difficulty, \n :exclu_difficulty, \n :cost, \n :exclu_cost, \n :category_ids, \n :exclu_category_ids, \n :main_ingredient_ids, \n :exclu_main_ingredient_ids, \n :source_ids, \n :exclu_source_ids\n ]\n filters.each do |filter|\n if params[filter].present?\n params[filter].map!{ |x| x.to_i }\n end\n end\n \n # @search_result.facet(:main_ingredient_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n # @search_result.facet(:course_type_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n # @search_result.facet(:category_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n # @search_result.facet(:source_ids).rows.sort!{|a,b| (a.count <=> b.count) == 0 ? (a.instance.name <=> b.instance.name) : (a.count <=> b.count)*(-1) }\n \n sort_alphabetical(@search_result.facet(:main_ingredient_ids).rows)\n sort_alphabetical(@search_result.facet(:course_type_ids).rows)\n sort_alphabetical(@search_result.facet(:category_ids).rows)\n sort_alphabetical(@search_result.facet(:source_ids).rows)\n end",
"def index\n @searches = Search.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @searches }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leaf }\n end\n end",
"def autocomplete\n unless /\\A#.+/.match(params[:query])\n @mindlogs = Mindlog.search(params[:query], where:{workflow_state:\"published\"},fields: [:title,{title: :text_start}], limit: 10).as_json(only:[:id,:title]) \n end\n render json: @mindlogs\n end",
"def suggest\n @result = Artist.search( params[:term] )\n \n respond_to do |format|\n format.html\n format.json { render :json => @result }\n end\n end",
"def index\n @tunning_diagrams = TunningDiagram.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunning_diagrams }\n format.xml { render xml: @tunning_diagrams }\n end\n end",
"def index\n #@words = Word.all.order('created_at DESC').paginate(:page => params[:page])\n #@definitions = @words.each {|word| word.definitions.order(:cached_votes_up => :desc)}\n\n if params[:letter]\n @words = Word.all.order('created_at DESC').where(\"word like ?\", params[:letter] +\"%\" ).paginate(:page => params[:page])\n # creates this /words?letter=i\n elsif params[:term]\n @words = Word.where('word LIKE ?', \"%#{params[:term]}%\").paginate(:page => params[:page])\n else\n @words = Word.all.order('created_at DESC').paginate(:page => params[:page])\n end\n\n respond_to do |format|\n format.html # will render index.html.erb in case of a HTML request\n format.js # will render index.js.erb in case of an AJAX request\n end\n end",
"def search\n @kms = params[:kms]\n if current_user\n @pets = Pet.where.not(user_id: current_user.id, adpted: 't').within(@kms.to_i, :origin=>[19.3234472,-99.1796417])\n @hash = Gmaps4rails.build_markers(@pets) do |pet, marker|\n marker.lat pet.latitude\n marker.lng pet.longitude\n marker.infowindow '<a style=\"font-size:18px\" href=\"'+pet_path(pet)+'\">'+pet.name+'</a>'\n end\n else\n @pets = Pet.where(adpted: 'f').within(@kms.to_i, :origin=>[19.3234472,-99.1796417])\n @hash = Gmaps4rails.build_markers(@pets) do |pet, marker|\n marker.lat pet.latitude\n marker.lng pet.longitude\n marker.infowindow '<a style=\"font-size:18px\" href=\"'+pet_path(pet)+'\">'+pet.name+'</a>'\n end\n end\n @hash << { \"lat\":19.3234472, \"lng\":-99.1796417, \"infowindow\":'<div style=\"font-size:18px\">Aqui estas tu</div> ' }\n puts @hash.to_json\n end",
"def search\n unless params[:search].blank?\n @search = Sunspot.search(KyuEntry) do\n fulltext params[:search]\n end\n @kyu = @search.results\n end\n end",
"def restaurant_suggestions\n match_key = Riddle.escape(params[:key]).split(' ').join('* ') + '*'\n begin\n suggestions = Restaurant.search(match_key,{:limit=>20,:match_mode => :extended,\n :ignore_errors=>true,:populate=>true,:retry_stale=>true})\n rescue Exception\n suggestions = []\n end\n response = []\n suggestions.each{|d| response << {:value=>d.id,:label=>d.name}}\n render :json=>response.to_json\n end",
"def index\n if params[:search]\n @tutorials = Tutorial.search(params[:search]).order(\"created_at DESC\")\n else\n @tutorials = Tutorial.all.order('created_at DESC')\n end\n=begin\n #for sunspot\n @search = Tutorial.search do\n fulltext params[:search]\n end\n @tutorials = @search.results\n=end\n end",
"def search\n\n @search = Location.near(params[:search], 15, :order => :distance)\n \n @query = params[:search]\n @locations = @search\n \n @filtros = ajustaFiltros\n @precios = precios(@locations)\n @campos = self.campos\n @places = places(@locations,@filtros)\n @facets = facetas(@locations, @filtros)\n @json = @locations.to_gmaps4rails\n end",
"def search \n\n end",
"def query(term, *opts)\n\n opts = {:count => 1, :ratio => 0.0}.merge(opts[0] || {})\n\n return [] if opts[:count] <= 0\n\n resp = JSON.parse(open(search_url term).read, :symbolize_names => true)\n\n resp[:list].map do |res|\n {\n :id => res[:defid],\n :word => res[:word],\n :author => res[:author],\n :permalink => res[:permalink],\n :definition => res[:definition].strip,\n :example => res[:example].strip,\n :upvotes => res[:thumbs_up],\n :downvotes => res[:thumbs_down]\n }\n end.keep_if do |d|\n d[:upvotes]/[d[:downvotes], 0.1].max.to_f >= opts[:ratio]\n end.take opts[:count]\n end",
"def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end",
"def index\n if params[:search]\n @search = CourseMatrix.search do\n fulltext params[:search]\n paginate :page => params[:page] || 1, :per_page => 10\n end\n @matrices = @search.results\n else\n @matrices = CourseMatrix.paginate(:page => params[:page], :per_page => 10)\n\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrices }\n end\nend",
"def searches\n wrapping!(\n search(\n root_uri,\n data_raw.to_s.gsub('=>', ':')\n )\n )\n end",
"def search\n\n end",
"def search\n @core_search.joins(:name_status)\n .select('max(name.id) id')\n .select('max(name.simple_name) simple_name')\n .select('max(name.full_name) full_name')\n .select('max(name.full_name_html) full_name_html')\n .select('tree_element.excluded')\n .select('max(name_status.id) name_status_id')\n .select('max(name_status.name) name_status_name_')\n .select('instance_type.misapplied')\n .select('instance_type.pro_parte')\n .select('max(names_instance.full_name) cross_referenced_full_name')\n .select('null cross_reference_misapplication_details')\n .select('max(names_instance.id) cross_referenced_full_name_id')\n .select('max(instance.id) instance_id')\n .select('max(citer_instances_instance.id) citers_instance_id')\n .select('max(tree_version_element.name_path) name_path')\n .select('null profile')\n .select('null synonyms')\n .select('true cross_reference')\n .select('max(names_instance.full_name_html) cross_ref_full_name_html')\n .select('instance_type.doubtful')\n .select('max(reference.citation) reference_citation')\n .group(main_group_by_columns)\n .limit(@parser.limit)\n .offset(@parser.offset)\n .order(' full_name ')\n end",
"def show\n @records = @habit.records.has_data.newer.page(params[:page]).per(200)\n if params[:habit].present? && params[:habit][:search_word].present?\n searcher = HabitRecordSearcher.new(@records, params[:habit][:search_word])\n @records = searcher.result\n @habit.search_word = params[:habit][:search_word]\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @habit }\n end\n end",
"def search\n search_results = NeedHelp.search(params[:column], params[:key])\n render :json => search_results.to_json(\n :include => [\n :need_help_category, :user => {:include => :street}\n ])\n end",
"def index\n @spots = Spot.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end",
"def search\n @journal_entries = JournalEntry.search(params[:query])\n @summary_array = @journal_entries.collect do |entry|\n { :text => entry.text, :id => entry.id }\n end\n\n respond_to do |format|\n format.json { render :json => @summary_array }\n end\n end",
"def index\n\n # set group1 from params\n group1_check\n\n # set search keyword\n keyword_check\n\n # terget attribute for search and keyword is;\n search_target = 'name LIKE ?'\n key = '%'+@keyword+'%'\n\n # get necessary attr only\n select = 'id, name, period, status, group1'\n\n # Debug\n #debug 'index', 'page is set: ['+@page.to_s+':'+session[:page].to_s+':'+params[:page].to_s+']'\n debug 'index', 'group1 is set: ['+@group1.to_s+':'+session[:group1].to_s+':'+params[:group1].to_s+']'\n debug 'index', 'search is set: ['+@keyword+']'\n\n #@leafs = Leaf.all\n if @group1 != '0'\n @leafs = Leaf.select(select).where(['group1 = ?', @group1]).order(:id)\n elsif @keyword.present?\n @leafs = Leaf.select(select).where([search_target, key])\n else\n @leafs = Leaf.select(select).order(:id)\n end\n\n end",
"def index\n @search = Place.ransack(params[:q])\n @search.sorts = 'created_at DESC' if @search.sorts.empty?\n @places = @search.result.where(draft: false)\n @qualifying_type = QualifyingType.all\n @hash = Gmaps4rails.build_markers(@places) do |place, marker|\n marker.lat place.latitude\n marker.lng place.longitude\n marker.json({operating_address: place.operating_address})\n marker.picture({\n \"url\" => \"http://halalfoodhunt.com/friends/wp-content/uploads/2016/10/shadows-marker.png\",\n \"width\" => 52,\n \"height\" => 52})\n marker.infowindow render_to_string(:partial => \"/layouts/infobox\", :locals => { :place => place})\n end\n respond_to do |format|\n format.html\n format.json { render json: @places }\n end\n end",
"def search\n\n end",
"def find\n render json: format_places(closest(params[:latitude], params[:longitude]).take(3))\n end",
"def search_for_example\n visit('/locations?keyword=alpha%20app')\n end",
"def index\n @search = Sunspot.search Generator do\n fulltext params[:query_generator]\n end\n @generators = @search.results\n respond_to do |format|\n format.html\n format.json {render :json => @generators.map(&:attributes) }\n end\nend",
"def index\n session[:special_words_search] ||= {}\n if params[:search_button]\n set_conditions\n elsif params[:clear_button]\n session[:special_words_search] = {}\n end\n\n # 検索条件を処理\n cond, order_by = make_conditions\n \n @special_words = find_login_owner(:special_words)\n .where(cond)\n .order(order_by)\n .page(params[:page])\n .per(current_user.per_page)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @special_words }\n end\n end",
"def search(phrase, limit=5, description=true, display=true)\n search = phrase.split.join(\"_\")\n endpoint = \"https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=#{search}&limit=#{limit}\"\n hash = get(endpoint)\n results = hash[1]\n descriptions = hash[2]\n if display\n puts \"Displaying #{results.length} results:\"\n for i in 0...results.length\n if description\n if ! descriptions[i].empty?\n puts \"\\n'#{results[i]}' : #{descriptions[i]}\"\n else\n puts \"\\n'#{results[i]}' : No Immediate Description Available. Try `wik -d #{results[i]}`\"\n end\n else\n puts \"\\n'#{results[i]}'\"\n end\n end\n end\n return hash\n end",
"def search\n #begin\n page = params[:page].present? ? params[:page].to_i : 1\n page = 1 if page <= 0\n query = params[:query]\n @unclean_query = query.dup\n\n # return error message\n if @unclean_query.present? && (@unclean_query.length < 3 || @unclean_query.length > 30)\n if @unclean_query.length < 3\n gon.searchErrorMessage = I18n.t(\"views.shared.search_errors.too_short\")\n else\n gon.searchErrorMessage = I18n.t(\"views.shared.search_errors.too_long\")\n end\n else\n # Finding yards in which current employee has access\n employee_yard_access = current_employee.yards.pluck(:id)\n employee_country = current_employee.present? ? current_employee.operating_country : nil\n\n # .where(\"yards.id in (?)\", employee_yard_access)\n @vehicles = Vehicle.includes([:seller, :facility, :vehicle_type, {model: :make}]).search(query, page, {yard_access: employee_yard_access, \n country_id: employee_country.try(:id)}, current_role_id)\n if @vehicles.empty?\n gon.searchResultMessage = I18n.t(\"controllers.vehicle.search.no_results\")\n else\n gon.searchResultMessage = I18n.t(\"controllers.vehicle.search.results\")\n end\n gon.pagination = { current_page: @vehicles.current_page,\n default_per_page: Kaminari.config.default_per_page,\n per_page: @vehicles.size,\n total_pages: @vehicles.total_pages,\n total_count: @vehicles.total_count }\n\n gon.vehicles = @vehicles.map(&:search_results) || [] \n gon.sortOptionAscending = Vehicle::SORT_ASCENDING\n gon.sortOptionDescending = Vehicle::SORT_DESCENDING\n gon.httpSlug = \"/search\" \n end\n\n gon.queryString = @unclean_query\n gon.parameters = { page: page,\n query: @unclean_query}\n \n respond_to do |format|\n format.html\n format.json { render :json => { vehicles: gon.vehicles, \n parameters: gon.parameters, \n pagination: gon.pagination } }\n end\n \n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end"
] | [
"0.75964737",
"0.7059821",
"0.6557024",
"0.6318823",
"0.62202275",
"0.6103193",
"0.607459",
"0.60558397",
"0.59986216",
"0.5993699",
"0.5937954",
"0.59330165",
"0.5929788",
"0.59000385",
"0.5876035",
"0.5869741",
"0.5867246",
"0.5847813",
"0.5796441",
"0.5792615",
"0.57847506",
"0.57567585",
"0.5734824",
"0.5730148",
"0.57221186",
"0.57119817",
"0.570564",
"0.57050097",
"0.56988114",
"0.56786966",
"0.5677275",
"0.56659144",
"0.5665652",
"0.56652844",
"0.56628984",
"0.5660972",
"0.5653867",
"0.56510544",
"0.56469727",
"0.5641702",
"0.5632099",
"0.5631218",
"0.56152135",
"0.56129086",
"0.5610847",
"0.56023705",
"0.5597039",
"0.5596376",
"0.5589017",
"0.5586916",
"0.5585633",
"0.5576731",
"0.5571267",
"0.5570791",
"0.55638945",
"0.55631316",
"0.5556483",
"0.55545485",
"0.55500597",
"0.5546162",
"0.5525772",
"0.5521613",
"0.5520751",
"0.5508741",
"0.55059046",
"0.5502503",
"0.55020386",
"0.5499877",
"0.5498067",
"0.54890454",
"0.54877853",
"0.5479291",
"0.5470224",
"0.5468489",
"0.54666704",
"0.5463771",
"0.5463046",
"0.5459588",
"0.5459305",
"0.54518336",
"0.5448212",
"0.5445684",
"0.54452974",
"0.5443787",
"0.54403377",
"0.5440325",
"0.5436006",
"0.5433376",
"0.5430257",
"0.54235405",
"0.54217464",
"0.5415576",
"0.54105836",
"0.5408255",
"0.5407189",
"0.5405653",
"0.54055136",
"0.54055136",
"0.54055136",
"0.54055136",
"0.54055136"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.