sup-heliotrope/sup · scroll_mode.rb
ruby logo
def find_text query, start_line
    regex = /#{query}/i
    (start_line ... lines).each do |i|
      case(s = self[i])
      when String
        match = s =~ regex
        return [i, match] if match
      when Array
        offset = 0
        s.each do |color, string|
          match = string =~ regex
          if match
            return [i, offset + match]
          else
            offset += string.display_length
          end
        end
      end
    end
    nil
  end
Similar code snippets
1.
jmettraux/rufus-cloche · cloche.rb
Match rating: 51.39% · See similar code snippets
ruby logo
def match?(key, regexes)

      regexes.first.is_a?(Regexp) ?
        regexes.find { |regex| regex.match(key) } :
        regexes.find { |s| key[-s.length..-1] == s }
    end
2.
sportdb/sport.db · standings.rb
Match rating: 51.29% · See similar code snippets
ruby logo
def update( match_or_matches )
    puts " [debug] update match_or_matches.class.name: #{match_or_matches.class.name}"

    ## convenience - update all matches at once
    if match_or_matches.is_a?( Array ) ||
       match_or_matches.is_a?( ActiveRecord::Associations::CollectionProxy )
      matches = match_or_matches
      matches.each_with_index do |match,i| # note: index(i) starts w/ zero (0)
        update_match( match )
      end
    else
      match = match_or_matches
      update_match( match )
    end
    self  # note: return self to allow chaining
  end
3.
stackbuilders/stub_shell · command.rb
Match rating: 50.44% · See similar code snippets
ruby logo
def matches? input_string
      case match
      when String
        input_string == match
      when Regexp
        !!(match.match input_string)
      end
    end
4.
veger/ruby-bbcode · tag_sifter.rb
Match rating: 49.86% · See similar code snippets
ruby logo
def match_url_id(url, regex_matches)
      regex_matches.each do |regex|
        if url =~ regex
          id = $1
          return id
        end
      end

      return url # if we couldn't find a match, then just return the url, hopefully it's a valid ID...
    end
5.
yltsrc/warder · bundle_audit_runner.rb
Match rating: 49.74% · See similar code snippets
ruby logo
def number_of_issues(line)
      match = FAILURE_REGEXP.match(line)
      return 0 unless match
      @stats_msg = line
      match[1].match('No ') ? 0 : 1
    end
6.
orta/gh_inspector · exception_hound.rb
Match rating: 49.1% · See similar code snippets
ruby logo
def regex_replace(string, find, replace)
      if string.match find
        full = string.match(find)[0]
        simple = string.match(replace)[1]
        string.gsub full, simple
      else
        string
      end
    end
7.
rocketjob/semantic_logger · log.rb
Match rating: 49.09% · See similar code snippets
ruby logo
def extract_file_and_line(stack, short_name = false)
      match = CALLER_REGEXP.match(stack.first)
      [short_name ? File.basename(match[1]) : match[1], match[2].to_i]
    end
8.
mare-imbrium/canis · listscrollable.rb
Match rating: 49.06% · See similar code snippets
ruby logo
def _find_prev regex=@last_regex, start = @search_found_ix, first_time = false
      #TODO the firsttime part, see find_next
      #raise "No previous search" if regex.nil?
      warn "No previous search" and return if regex.nil?
      #$log.debug " _find_prev #{@search_found_ix} : #{@current_index}"
      if start != 0
        start -= 1 unless start == 0
        @last_regex = regex
        @search_start_ix = start
        regex = Regexp.new(regex, Regexp::IGNORECASE) if @search_case
        start.downto(0) do |ix| 
          row = @list[ix].to_s
          m=row.match(regex)
          if !m.nil?
            @find_offset = m.offset(0)[0]
            @find_offset1 = m.offset(0)[1]
            ix += (@_header_adjustment || 0)
            @search_found_ix = ix
            return ix 
          end
        end
      end
      fend = start-1
      start = @list.size-1
      if @search_wrap
        start.downto(fend) do |ix| 
          row = @list[ix].to_s
          m=row.match(regex)
          if !m.nil?
            @find_offset = m.offset(0)[0]
            @find_offset1 = m.offset(0)[1]
            ix += (@_header_adjustment || 0)
            @search_found_ix = ix
            return ix 
          end
        end
      end
      return nil
    end
9.
infertux/bashcov · field_stream.rb
Match rating: 48.83% · See similar code snippets
ruby logo
def chunk_matches(start_match)
      i = 0

      lambda do |e|
        if e.match?(start_match)
          i += 1
          nil
        else
          i
        end
      end
    end
10.
cantino/reckon · app.rb
Match rating: 48.75% · See similar code snippets
ruby logo
def most_specific_regexp_match( row )
      matches = regexps.map { |regexp, account|
        if match = regexp.match(row[:description])
          [account, match[0]]
        end
      }.compact
      matches.sort_by! { |account, matched_text| matched_text.length }.map(&:first)
    end