Sha256: bf68516b31b9716aa80f8e45ea886efe86fe555032a71e52412aa909343995bb
Contents?: true
Size: 1.41 KB
Versions: 17
Compression:
Stored size: 1.41 KB
Contents
module FlydataCore module Mysql class BinlogPos def initialize(binlog_str_or_filename_or_hash, binlog_pos = nil) arg = binlog_str_or_filename_or_hash if binlog_pos @pos = binlog_pos @filename = arg elsif arg.kind_of?(String) @filename, @pos = arg.split("\t") elsif arg.kind_of?(Hash) @pos = arg[:pos] @filename = arg[:filename] @filename ||= arg[:binfile] end if @filename.nil? || @pos.nil? raise "Invalid initialize argument (#{arg}, #{binlog_pos})" end @pos = @pos.to_i end attr_reader :filename, :pos def <=>(other_pos) if other_pos.nil? raise ArgumentError.new("comparison of BinlosPos with nil failed") end other_pos = BinlogPos.new(other_pos) unless other_pos.kind_of?(BinlogPos) if @filename < other_pos.filename -1 elsif @filename == other_pos.filename if @pos < other_pos.pos -1 elsif @pos == other_pos.pos 0 else 1 end else 1 end end def <(other_pos) self.<=>(other_pos) < 0 end def <=(other_pos) self.<=>(other_pos) <= 0 end def ==(other_pos) return false if other_pos.nil? self.<=>(other_pos) == 0 end def !=(other_pos) !self.==(other_pos) end def >(other_pos) self.<=>(other_pos) > 0 end def >=(other_pos) self.<=>(other_pos) >= 0 end def to_s "#{@filename}\t#{@pos}" end end end end
Version data entries
17 entries across 17 versions & 1 rubygems