Sha256: b6619a54de4fc3e4cf777c27f02421134acf8804337a3856572738197a5a685f

Contents?: true

Size: 857 Bytes

Versions: 19

Compression:

Stored size: 857 Bytes

Contents

module TreasureData
  module Helpers
    module_function

    def format_with_delimiter(number, delimiter = ',')
      number.to_s.gsub(/(\d)(?=(?:\d{3})+(?!\d))/, "\\1#{delimiter}")
    end

    def home_directory
      on_windows? ? ENV['USERPROFILE'].gsub("\\","/") : ENV['HOME']
    end

    def on_windows?
      RUBY_PLATFORM =~ /mswin32|mingw32/
    end

    def on_mac?
      RUBY_PLATFORM =~ /-darwin\d/
    end

    def on_64bit_os?
      if on_windows?
        if ENV.fetch('PROCESSOR_ARCHITECTURE', '').downcase.include? 'amd64'
          return true
        end
        return ENV.has_key?('PROCESSOR_ARCHITEW6432')
      else
        require 'open3'
        out, status = Open3.capture2('uname', '-m')
        raise 'Failed to detect OS bitness' unless status.success?
        return out.downcase.include? 'x86_64'
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
td-0.16.10 lib/td/helpers.rb
td-0.16.9 lib/td/helpers.rb
td-0.16.8 lib/td/helpers.rb
td-0.16.7 lib/td/helpers.rb
td-0.16.6 lib/td/helpers.rb
td-0.16.5 lib/td/helpers.rb
td-0.16.4 lib/td/helpers.rb
td-0.16.3 lib/td/helpers.rb
td-0.16.1 lib/td/helpers.rb
td-0.16.0 lib/td/helpers.rb
td-0.15.9 lib/td/helpers.rb
td-0.15.8 lib/td/helpers.rb
td-0.15.7 lib/td/helpers.rb
td-0.15.6 lib/td/helpers.rb
td-0.15.5 lib/td/helpers.rb
td-0.15.4 lib/td/helpers.rb
td-0.15.3 lib/td/helpers.rb
td-0.15.2 lib/td/helpers.rb
td-0.15.0 lib/td/helpers.rb