Sha256: 27cebd61fa688c990b5874900689dc15f57e0383f2a17a8ddb45e88ee57e1a8f
Contents?: true
Size: 1.35 KB
Versions: 19
Compression:
Stored size: 1.35 KB
Contents
require 'flydata-core/source_pos_base' module FlydataCore module Mysql class BinlogPos include SourcePosBase 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] ||arg[:binfile] end # Set -1 to pos if filename is predefined value if set_predefined_flags(@filename) @pos = -1 end if @filename.nil? || @pos.nil? raise "Invalid initialize argument (#{arg}, #{binlog_pos})" end @pos = @pos.to_i end def self.load(binlog_pos_str) self.new(binlog_pos_str) end attr_reader :filename, :pos # Override (Comparable) def <=>(other_pos) s = super return s if s other_pos = self.class.new(other_pos) unless other_pos.kind_of?(self.class) (@filename <=> other_pos.filename) == 0 ? (@pos <=> other_pos.pos) : (@filename <=> other_pos.filename) end # Override (Comparable) def ==(other_pos) return false if other_pos.nil? return @filename == other_pos.filename if empty? || other_pos.empty? self.<=>(other_pos) == 0 end # Override def to_s s = super return s if s "#{@filename}\t#{@pos}" end end end end
Version data entries
19 entries across 19 versions & 1 rubygems