Sha256: eaf7cdc62a59b1755ab8a6d014c2447e2b55fd055a1a5854cfbcdb48fde03fe6

Contents?: true

Size: 535 Bytes

Versions: 15

Compression:

Stored size: 535 Bytes

Contents

require 'socket'
require 'i18n'

# Utilities.
class Utils
  class << self
    # Gets local host name.
    # @return [String] Host name.
    # @note Caches host name on first access.
    def host_name
      unless @host_name
        begin
          @host_name = Socket.gethostbyname(Socket.gethostname).first
        rescue
          @host_name = Socket.gethostname
        end
      end

      @host_name
    end

    # I18n.t shortcut.
    # @return [String] Translated string.
    def t(*args)
      I18n.t(*args)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
runit-man-2.4.14 lib/runit-man/utils.rb
runit-man-2.4.12 lib/runit-man/utils.rb
runit-man-2.4.11 lib/runit-man/utils.rb
runit-man-2.4.10 lib/runit-man/utils.rb
runit-man-2.4.9 lib/runit-man/utils.rb
runit-man-2.4.8 lib/runit-man/utils.rb
runit-man-2.4.7 lib/runit-man/utils.rb
runit-man-2.4.6 lib/runit-man/utils.rb
runit-man-2.4.5 lib/runit-man/utils.rb
runit-man-2.4.4 lib/runit-man/utils.rb
runit-man-2.4.3 lib/runit-man/utils.rb
runit-man-2.4.2 lib/runit-man/utils.rb
runit-man-2.4.1 lib/runit-man/utils.rb
runit-man-2.4.1a1 lib/runit-man/utils.rb
runit-man-2.4.0 lib/runit-man/utils.rb