Sha256: 7996cf65720a4ea91c5c060ffc03f29bc414730e208fc26e00102c6cd918943e

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

module RintCore
  module Driver
    # Utilities for performing OS level tasks
    module OperatingSystem

    # Return name of OS as a symbol.
    # @return [Symbol] name of OS as symbol.
    def get_os
      return :linux if /linux/ =~ RUBY_PLATFORM
      return :mac if /darwin/ =~ RUBY_PLATFORM
      return :windows if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
      return :unknown
    end

private
      def control_ttyhup(port, disable_hup)
        if get_os == :linux
          if disable_hup
            `stty -F #{port} -hup`
          else
            `stty -F #{port} hup`
          end
        end
      end

      def enable_hup(port)
        control_ttyhup(port, true)
      end

      def disable_hup(port)
        control_ttyhup(port, false)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rintcore-0.0.5 lib/rint_core/driver/operating_system.rb
rintcore-0.0.4 lib/rint_core/driver/operating_system.rb