Sha256: cd48d3da980df7022417dc4f90101fef157e611824647e5bbf92e290b9c9597d

Contents?: true

Size: 573 Bytes

Versions: 1

Compression:

Stored size: 573 Bytes

Contents

require "demisyn/version"

module Demisyn
  class << self
    def lonely_operator?
      major, minor, _ = RUBY_VERSION.split('.')
      major.to_i.>=(2) && minor.to_i.>=(3)
    end
  end

  refine String do
    def ~()
      eval squeeze.gsub(/ /, ".")
    end 

    case Demisyn.send :lonely_operator?
    when true
      def -@
        eval squeeze.gsub(/ /, "&.")
      end
    end
  end

  refine Array do
    def ~()
      eval join(".") 
    end

    case Demisyn.send :lonely_operator?
    when true
      def -@
        eval join("&.")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
demisyn-0.2.1 lib/demisyn.rb