Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/modify_until.rb

Overview

>> “1.5.8”.compare_by_fields(“1.5.8”)

Instance Method Summary collapse

Instance Method Details

#compare_by_fields(other, fieldsep = ".") ⇒ Object



83
84
85
86
# File 'lib/modify_until.rb', line 83

def compare_by_fields(other, fieldsep = ".")
  cmp = proc { |s| s.split(fieldsep).map(&:to_i) }
  cmp.call(self) <=> cmp.call(other)
end

#trans_home_path!Object



88
89
90
91
92
93
# File 'lib/modify_until.rb', line 88

def trans_home_path!
    real = Config.Home
    if self.include? '~'
        self.gsub(/~/,real)
    end
end