Class: Faker::Computer

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/computer.rb

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.os(platform: self.platform) ⇒ String

Produces the name of a computer os.

Examples:

Faker::Computer.os #=> "RHEL 6.10"

Parameters:

  • platform (String) (defaults to: self.platform)

    optionally specify the platform ‘linux`, `macos`, or `windows`.

Returns:

  • (String)

Available since:

  • 2.12.0



42
43
44
45
# File 'lib/faker/default/computer.rb', line 42

def os(platform: self.platform)
  platform = self.platform unless fetch_all('computer.platform').include?(platform)
  fetch("computer.os.#{platform.downcase}")
end

.platformString

Produces the name of a computer platform.

Examples:

Faker::Computer.platform #=> "Linux"

Returns:

  • (String)

Available since:

  • 2.12.0



15
16
17
# File 'lib/faker/default/computer.rb', line 15

def platform
  fetch('computer.platform')
end

.stackString

Produces a string with computer platform and os

Examples:

Faker::Computer.stack #=> "Linux, RHEL 6.10"

Returns:

  • (String)

Available since:

  • 2.12.0



56
57
58
59
60
# File 'lib/faker/default/computer.rb', line 56

def stack
  platform = self.platform
  os = fetch("computer.os.#{platform.downcase}")
  "#{platform}, #{os}"
end

.typeString

Produces the name of a computer type.

Examples:

Faker::Computer.type #=> "server"

Returns:

  • (String)

Available since:

  • 2.12.0



28
29
30
# File 'lib/faker/default/computer.rb', line 28

def type
  fetch('computer.type')
end