Shopify/liquid · standardfilters.rb
ruby logo
def nil_safe_casecmp(a, b)
      if !a.nil? && !b.nil?
        a.to_s.casecmp(b.to_s)
      else
        a.nil? ? 1 : -1
      end
    end
Similar code snippets
1.
mloughran/signature · signature.rb
Match rating: 52.08% · See similar code snippets
ruby logo
def identical?(a, b)
        return true if a.nil? && b.nil?
        return false if a.nil? || b.nil?
        return false unless a.bytesize == b.bytesize
        a.bytes.zip(b.bytes).reduce(0) { |memo, (a, b)| memo += a ^ b } == 0
      end
2.
tmm1/ripper-tags · parser.rb
Match rating: 50.79% · See similar code snippets
ruby logo
def on_const_path_ref(a, b)
    return if a.nil? || b.nil?
    a.flatten!(1)
    [[a && a[0], b[0]].join('::'), b[1]]
  end
3.
tmm1/stackprof · report.rb
Match rating: 50.68% · See similar code snippets
ruby logo
def add_lines(a, b)
      return b if a.nil?
      return a+b if a.is_a? Integer
      return [ a[0], a[1]+b ] if b.is_a? Integer
      [ a[0]+b[0], a[1]+b[1] ]
    end
4.
oggy/cast · node_list.rb
Match rating: 49.47% · See similar code snippets
ruby logo
def link2_(a, b)
      if a.nil?
        @first = b
      else
        a.instance_variable_set(:@next, b) unless a.nil?
      end
      if b.nil?
        @last = a
      else
        b.instance_variable_set(:@prev, a) unless b.nil?
      end
    end
5.
chastell/art-decomp · kiss.rb
Match rating: 49.03% · See similar code snippets
ruby logo
def find_matching # rubocop:disable AbcSize
      @lines.pairs.each do |a, b|
        next unless a[/\s.*$/] == b[/\s.*$/]
        a.size.times do |i|
          return a, b, i if a[0...i] == b[0...i] and a[i+1..-1] == b[i+1..-1]
        end
      end
      nil
    end
6.
sup-heliotrope/sup · thread.rb
Match rating: 48.27% · See similar code snippets
ruby logo
def latest_message
    inject(nil) do |a, b|
      b = b.first
      if a.nil?
        b
      elsif b.nil?
        a
      else
        b.date > a.date ? b : a
      end
    end
  end
7.
sportngin/active_zuora · base.rb
Match rating: 46.92% · See similar code snippets
ruby logo
def fields_order(a, b)
      if send(a.name) == nil
        send(b.name) == nil ? 0 : -1
      elsif a.name.to_sym == :id
        send(b.name) == nil ? 1 : -1
      else
        (b.name.to_sym == :id || send(b.name) == nil) ? 1 : 0
      end
    end
8.
yuki24/did_you_mean · levenshtein.rb
Match rating: 46.1% · See similar code snippets
ruby logo
def min3(a, b, c)
      if a < b && a < c
        a
      elsif b < c
        b
      else
        c
      end
    end
9.
pazdera/tco · palette.rb
Match rating: 45.85% · See similar code snippets
ruby logo
def CieLab2Hue(a, b)
      bias = 0
      return 0 if (a >= 0 && b == 0)
      return 180 if (a <  0 && b == 0)
      return 90 if (a == 0 && b > 0)
      return 270 if (a == 0 && b < 0)

      bias = case
      when a > 0 && b > 0 then 0
      when a < 0 then 180
      when a > 0 && b < 0 then 360
      end

      rad_to_deg(Math.atan(b / a)) + bias
    end
10.
icyleaf/app_info · try.rb
Match rating: 45.68% · See similar code snippets
ruby logo
def try!(*a, &b)
      if a.empty? && block_given?
        if b.arity.zero?
          instance_eval(&b)
        else
          yield self
        end
      else
        public_send(*a, &b)
      end
    end