Sha256: a94617e7a0b5ebd669bc42091964aea1fcdb7748ac3dd2376d8bd39ae184c695

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 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
    case Demisyn.send :lonely_operator?
    when true
      def ~()
        eval gsub(/ /, "&.")
      end
    when false
      def ~()
        eval gsub(/ /, ".") rescue nil
      end
    end 
  end

  refine Array do
    case Demisyn.send :lonely_operator?
    when true
      def ~()
        eval join("&.")
      end
    when false
      def ~()
        eval join(".") rescue nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
demisyn-0.1.0 lib/demisyn.rb