1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
# frozen_string_literal: true
module Faker
class Computer < Base
class << self
##
# Produces the name of a computer platform.
#
# @return [String]
#
# @example
# Faker::Computer.platform #=> "Linux"
#
# @faker.version 2.12.0
def platform
fetch('computer.platform')
end
##
# Produces the name of a computer type.
#
# @return [String]
#
# @example
# Faker::Computer.type #=> "server"
#
# @faker.version 2.12.0
def type
fetch('computer.type')
end
##
# Produces the name of a computer os.
#
# @param platform [String] optionally specify the platform `linux`, `macos`, or `windows`.
# @return [String]
#
# @example
# Faker::Computer.os #=> "RHEL 6.10"
#
# @faker.version 2.12.0
def os(platform: self.platform)
platform = self.platform unless fetch_all('computer.platform').include?(platform)
fetch("computer.os.#{platform.downcase}")
end
##
# Produces a string with computer platform and os
#
# @return [String]
#
# @example
# Faker::Computer.stack #=> "Linux, RHEL 6.10"
#
# @faker.version 2.12.0
def stack
platform = self.platform
os = fetch("computer.os.#{platform.downcase}")
"#{platform}, #{os}"
end
end
end
end
|