class HardwareInformation

#
#
#
#

require 'hardware_information/class/menu.rb'

#
#
#

require 'hardware_information/class/obtain.rb'

#
#

require 'hardware_information/class/reset.rb'

#
#

require 'hardware_information/class/run.rb'

#
#

HardwareInformation::GUI::Gtk::PurchasedHardwareModule

#

require 'hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb' include ::HardwareInformation::GUI::Gtk::PurchasedHardwareModule

#
#

HardwareInformation::GUI::Gtk::ShowInputDevicesModule

#

require 'hardware-information/gui/shared_code/foobar/foobar_module.rb' include ::HardwareInformation::GUI::Gtk::ShowInputDevicesModule

#
#

HardwareInformation::PurchasedHardware

This module has been primarily written to support the old content shown in the old .cgi file. By having this available as a module we can, in principle, adapt this easily into sinatra or rails as well, so we gain more flexibility by using a module here.

#

require 'hardware_information/misc/purchased_hardware/purchased_hardware.rb' include HardwareInformation::PurchasedHardware

#
#

require 'hardware_information/monitor/monitor.rb' HardwareInformation.return_the_monitor_resolution

#
#

require 'hardware_information/project/project.rb'

#
#

require 'hardware_information/version/version.rb'

#
#

require 'hardware_information/www/embeddable_interface.rb' include HardwareInformation::EmbeddableInterface

#

Constants

CPUINFO
CPUINFO_LOCATION
#

CPUINFO_LOCATION

This constants stores where cpuinfo is kept. Will work only on Linux, I think.

#
DATASET_FROM_PROC_MEMINFO
ERROR_LINE
#

ERROR_LINE

#
FILE_COLOURS_FOR_THE_HARDWARE_PROJECT
#

FILE_COLOURS_FOR_THE_HARDWARE_PROJECT

#
LAST_UPDATE
#

LAST_UPDATE

#
LEFT_PADDING
#

LEFT_PADDING

How many characters to pad on the left side. Used for the header_content() method.

#
LSCPU
LSPCI
MAIN_DEFAULT_RJUST
#

MAIN_DEFAULT_RJUST

#
N
#

N

#
PROC_MEMINFO
#

PROC_MEMINFO

#
PROJECT_BASE_DIRECTORY
#

PROJECT_BASE_DIRECTORY

#
PROJECT_YAML_DIRECTORY
#

PROJECT_YAML_DIRECTORY

Refer to the internal yaml-directory as well.

#
RAM_AVAILABLE
#

RAM_AVAILABLE

#
RAM_AVAILABLE_FREE
#

RAM_AVAILABLE_FREE

#
SPLITTED_CPUINFO
VERSION
#

VERSION

#

Public Class Methods

embeddable_interface() click to toggle source
#

HardwareInformation.embeddable_interface

#
# File lib/hardware_information/www/embeddable_interface.rb, line 46
def self.embeddable_interface
  object = Object.new
  object.extend(::HardwareInformation::EmbeddableInterface)
  return object
end
is_on_windows?() click to toggle source
#

HardwareInformation.is_on_windows?

#
# File lib/hardware_information/class/constants.rb, line 65
def self.is_on_windows?
  if RUBY_PLATFORM.include?('win') or # if on windows.
     RUBY_PLATFORM.include?('mingw')
    return true
  end
  return false
end
kb_to_mb(i) click to toggle source
#

HardwareInformation.kb_to_mb(i)

#
# File lib/hardware_information/class/constants.rb, line 56
def self.kb_to_mb(i)
  (
    i.gsub(/ kB/,'').to_i / 1024
  ).to_s+ ' MB'
end
new( run_already = true ) click to toggle source
#

initialize

#
# File lib/hardware_information/class/initialize.rb, line 10
def initialize(
    run_already = true
  )
  reset
  case run_already
  when :do_not_run_yet
    run_already = false
  end
  set_run_already(
    run_already
  )
  run if run_already
end
project_base_directory?() click to toggle source
#

HardwareInformation.project_base_directory?

#
# File lib/hardware_information/project/project.rb, line 25
def self.project_base_directory?
  PROJECT_BASE_DIRECTORY
end
return_the_monitor_resolution() click to toggle source
#

HardwareInformation.return_the_monitor_resolution

This method essentially captures the resolution from a String such as:

dimensions:    1920x1080 pixels (508x285 millimeters)

It will then return a String, as result, such as “1920x1080”.

#
# File lib/hardware_information/monitor/monitor.rb, line 20
def self.return_the_monitor_resolution
  result = `xdpyinfo`.split("\n").select {|entry| entry.include? 'dimensions' }
  if result.is_a? Array
    result = result.first
  end
  result.strip!
  if result.include? 'x'
    result = result.scan(/(\d{2,4}x\d{2,4})/).flatten.first.strip
  end
  return result
end
run() click to toggle source
#

HardwareInformation.run

#
# File lib/hardware_information/class/run.rb, line 44
def self.run
  self.new
end
start_sinatra_interface() click to toggle source
#

HardwareInformation.start_sinatra_interface

#
# File lib/hardware_information/www/my_hardware_for_sinatra.rb, line 56
def self.start_sinatra_interface
  puts 'Trying to start the sinatra-interface of HardwareInformation next.'
  HardwareInformation::SinatraMyHardware.start_sinatra_interface
end

Public Instance Methods

_(i, optional_colour = nil) click to toggle source
#

_ (_ tag)

This method, as a shortcut, makes use of the method called add(), but it will also append a newline to the given input and support colours (if given as argument).

#
# File lib/hardware_information/class/misc.rb, line 74
def _(i, optional_colour = nil)
  if optional_colour and use_colours? # Add colours only if needed.
    if optional_colour.is_a? Symbol
      i = ::Colours.send(optional_colour, i)
    else
      i = optional_colour+i+rev
    end
  end
  add i+N # We try it with mandatory newline for now.
end
add(i) click to toggle source
#

add (add tag)

#
# File lib/hardware_information/class/misc.rb, line 271
def add(i)
  @string << i
end
add_audio_information() click to toggle source
#

add_audio_information (audio tag)

#
# File lib/hardware_information/class/misc.rb, line 255
def add_audio_information
  audio_device = `aplay -l`.scan(/card.+$/).first
  make_line(pad?+'Audio Device', N+(pad? * 2)+audio_device.to_s)
end
add_title() click to toggle source
#

add_title

#
# File lib/hardware_information/class/misc.rb, line 88
def add_title
  optional_colour = nil
  if use_colours?
    if Object.const_defined? :Colours # User has the colours gem installed.
      optional_colour = :mediumslateblue
    else
      optional_colour = green?
    end
  end
  _ N+'Hardware Information'+N, optional_colour
end
append_newline() click to toggle source
#

append_newline

#
# File lib/hardware_information/class/misc.rb, line 24
def append_newline
  add N
end
append_output_generated_via_lsblk() click to toggle source
#

append_output_generated_via_lsblk

Typical output generated via lsblk may be like this:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  2.7T  0 disk 
├─sda1   8:1    0    1M  0 part 
└─sda2   8:2    0  2.7T  0 part /
sr0     11:0    1 1024M  0 rom
#
# File lib/hardware_information/class/misc.rb, line 166
def append_output_generated_via_lsblk
  _ = ''.dup
  # ======================================================================== #
  # Next we will display/obtain more information, via df.
  # ======================================================================== #
  extended_information = `df -T`.split(N)
  result = `lsblk`.strip.split(N).map {|line| "    #{line}" }
  result.each {|entry|
    # ===================================================================== #
    # Modify the input.
    # ===================================================================== #
    if entry.include? ' /'
      # =================================================================== #
      # These entries will be colourized. Note that the first part may
      # look like this: "└─sda2"
      #
      #   "    └─sda2   8:2    0  2.7T  0 part /"
      #
      # =================================================================== #
      splitted = entry.split(' ')
      # =================================================================== #
      # The root_entry may look like this:
      #
      #   /dev/sda2      ext4     2883218608 529813416 2206875608  20% /
      #
      # =================================================================== #
      selection = extended_information.select {|line|
        last = line.split(' ').last
        last == '/' or last.include?('USB')
      }
      if selection
        selection = selection.select {|inner_line|
          inner_line.end_with? splitted[-1]
        }
        if selection.is_a?(Array) and selection.first
          selection = selection.first.split(' ')
        end
      end
      splitted[-1] = colourize_highlighted_content(splitted[-1].ljust(12)) # ← The last part.
      splitted[0] = colourize_highlighted_content("    #{splitted[0]}")    # ← The first part.
      splitted[1] = colourize_via_regular_colour(splitted[1].strip.ljust(4).rjust(6))
      splitted[2] = colourize_via_regular_colour(" #{splitted[2].strip.rjust(2)}")
      splitted[3] = colourize_filesize_of_the_harddisc(splitted[3].strip.rjust(5).ljust(6)) # ← The size of the harddisc.
      splitted[4] = colourize_via_regular_colour(splitted[4].strip.ljust(2).rjust(3))
      splitted[5] = colourize_via_regular_colour(splitted[5].strip)
      file_system_type   = selection[1]
      n_percent_occupied = selection[5]
      # =================================================================== #
      # /dev/sda2   ext4    2883218608 529753916 2206935108  20% /"]
      # =================================================================== #
      splitted = splitted.join(' ')
      unless entry.include? '/boot/' # ← Don't show information for /boot/ entries.
        splitted << colourize_file_system_type(" (#{file_system_type})")
        splitted << colourize_n_percent_occupied(" (#{n_percent_occupied} used)")
      end
      entry = splitted
    else # Else we only do a slightly simpler colourization-part.
      splitted = entry.split(' ')
      splitted[0] = colourize_via_regular_colour("    #{splitted[0].ljust(6)}")      # ← The first part.
      splitted[1] = colourize_via_regular_colour(splitted[1].strip.ljust(4).rjust(6))
      splitted[2] = colourize_via_regular_colour(" #{splitted[2].strip.rjust(2)}")
      splitted[3] = colourize_filesize_of_the_harddisc(splitted[3].strip.rjust(5).ljust(6)) # ← The size of the harddisc.
      splitted[4] = colourize_via_regular_colour(splitted[4].strip.ljust(2).rjust(3))
      splitted[5] = colourize_via_regular_colour(splitted[5].strip)
      if splitted[6] and (splitted[6] == '[SWAP]')
        splitted[6] = royalblue(splitted[6])
      end
      entry = splitted.join(' ')
      entry = colourize_via_regular_colour(entry)
    end
    _ << "#{entry}\n" # Now we can append this.
  }
  # ======================================================================= #
  # Add two newlines too, for slightly more readable output.
  # ======================================================================= #
  _ << "#{N}#{N}"
  add _
end
bold_teal?() click to toggle source
#

bold_teal?

#
# File lib/hardware_information/class/colours.rb, line 22
def bold_teal?
  Colours::BOLD_TEAL
end
colourize_file_system_type(i) click to toggle source
#

colourize_file_system_type

#
# File lib/hardware_information/class/misc.rb, line 113
def colourize_file_system_type(i)
  Colours.send(
    @hash_use_these_colours[:file_system_type],
    i
  )
end
colourize_filesize_of_the_harddisc(i) click to toggle source
#

colourize_filesize_of_the_harddisc

#
# File lib/hardware_information/class/misc.rb, line 103
def colourize_filesize_of_the_harddisc(i)
  Colours.send(
    @hash_use_these_colours[:filesize_of_the_harddisc],
    i
  )
end
colourize_highlighted_content(i) click to toggle source
#

colourize_highlighted_content

#
# File lib/hardware_information/class/misc.rb, line 133
def colourize_highlighted_content(i)
  Colours.send(
    @hash_use_these_colours[:highlighted_content],
    i
  )
end
colourize_n_percent_occupied(i) click to toggle source
#

colourize_n_percent_occupied

#
# File lib/hardware_information/class/misc.rb, line 123
def colourize_n_percent_occupied(i)
  Colours.send(
    @hash_use_these_colours[:n_percent_occupied],
    i
  )
end
colourize_via_regular_colour(i) click to toggle source
#

colourize_via_regular_colour

Do note that this is presently hardcoded to the “thistle” colour. Unsure whether to allow the user more customization here, so for the time being this remains hardcoded.

#
# File lib/hardware_information/class/misc.rb, line 147
def colourize_via_regular_colour(i)
  Colours.send(
    :thistle,
    i
  )
end
default_ljust(i) click to toggle source
#

default_ljust

#
# File lib/hardware_information/class/misc.rb, line 248
def default_ljust(i)
  i.to_s.ljust(15)
end
default_rjust(i) click to toggle source
#

default_ljust

#
# File lib/hardware_information/class/misc.rb, line 59
def default_rjust(i)
  if i.is_a? Array # We do not handle Arrays.
    i
  else
    i.to_s.rjust(MAIN_DEFAULT_RJUST)
  end
end
disable_colours() click to toggle source
#

disable_colours

#
# File lib/hardware_information/class/colours.rb, line 43
def disable_colours
  @use_colours = false
end
enable_colours() click to toggle source
#

enable_colours

#
# File lib/hardware_information/class/colours.rb, line 36
def enable_colours
  @use_colours = true
end
find_out_the_amount_of_processors() click to toggle source
#

find_out_the_amount_of_processors

#
# File lib/hardware_information/class/misc.rb, line 263
def find_out_the_amount_of_processors
  data = CPUINFO.scan(/cpu cores\t: (\d+)\n/).flatten.map(&:to_i).sum.to_i
  make_line('  Processors', data) { :slateblue }
end
green?() click to toggle source
#

green?

#
# File lib/hardware_information/class/colours.rb, line 15
def green?
  Colours::GREEN
end
make_line( title, content ) { || ... } click to toggle source
#

make_line

The first argument to this method should be the title that will be displayed.

The second argument should show the content towards that argument.

#
# File lib/hardware_information/class/make_line.rb, line 15
def make_line(
    title, content
  )
  title = title.dup if title.frozen?
  use_this_colour_for_change = bold_teal?
  use_this_colour_to_revert  = @default_colour # First a copy.
  title << ': ' if @use_colon_as_delimiter
  title   = default_ljust(title)
  content = default_rjust(content)
  # ======================================================================= #
  # === Handle blocks next
  #
  # The passed block can modify the variable called content. This
  # will happen after the various padding-operations above.
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    when nil
      # Pas through.
    else # Else, use colours.
      if use_colours?
        content = Colours.send(yielded, content)
      end
    end
  end
  string = ''.dup
  string << use_this_colour_for_change if use_colours?
  string << title
  string << use_this_colour_to_revert if use_colours?
  string = string.ljust(40)
  if content.is_a? Array
    _ string
    content.each {|line| _ "    #{line}" }
  else
    string << content
    _ string
  end
end
menu( i = nil ) click to toggle source
#

menu (menu tag)

Commandline-arguments, e. g. ARGV, will be passed into this menu interface.

#
obtain_architecture() click to toggle source
#

obtain_architecture

#
# File lib/hardware_information/class/obtain.rb, line 244
def obtain_architecture
  result = LSCPU.grep(/Architecture:/).first.split(':').last.strip
  make_line('  Architecture', result) { :violet }
end
obtain_byte_order() click to toggle source
#

obtain_byte_order

#
# File lib/hardware_information/class/obtain.rb, line 194
def obtain_byte_order
  result = LSCPU.grep(/Byte Order:/).first.split(':').last.strip
  make_line '  Byte Order', result
end
obtain_cache_size() click to toggle source
#

obtain_cache_size

#
# File lib/hardware_information/class/obtain.rb, line 174
def obtain_cache_size
  make_line '  Cache Size',
    SPLITTED_CPUINFO.select {|line|
      line.include? 'cache size'
    }.first.split(':')[1].strip
end
obtain_chip_mhz() click to toggle source
#

obtain_chip_mhz

#
# File lib/hardware_information/class/obtain.rb, line 164
def obtain_chip_mhz
  make_line '  Chip MHzx',
    SPLITTED_CPUINFO.select {|line|
      line.include? 'cpu MHz'
    }.first.split(':')[1].strip
end
obtain_cpu_family() click to toggle source
#

obtain_cpu_family

#
# File lib/hardware_information/class/obtain.rb, line 202
def obtain_cpu_family
  result = LSCPU.grep(/CPU family:/).first.split(':').last.strip
  make_line '  CPU family', result
end
obtain_cpu_model() click to toggle source
#

obtain_cpu_model

#
# File lib/hardware_information/class/obtain.rb, line 184
def obtain_cpu_model
  result = SPLITTED_CPUINFO.select {|line|
    line.include? 'model name'
  }.first.split(':')[1].strip
  make_line '  Model', result
end
obtain_cpu_op_modes() click to toggle source
#

obtain_cpu_op_modes

#
# File lib/hardware_information/class/obtain.rb, line 226
def obtain_cpu_op_modes
  result = LSCPU.grep(/CPU op-mode/).first.split(':').last.strip
  make_line('  CPU op-mode(s)', result)
end
obtain_firmware_information() click to toggle source
#

obtain_firmware_information

Note that this functionality depends on the binary called “lshw”.

#
# File lib/hardware_information/class/obtain.rb, line 64
def obtain_firmware_information
  result = `lshw 2>&1`
  if result
    # ===================================================================== #
    # See: https://rubular.com/r/Uf4XqmbZW3atCy
    # ===================================================================== #
    regex = 
      /description: Motherboard\s+product: (.+)\s+vendor: (.+)\s+[.:0-9a-zA-Z\n ]+\*-firmware[.:0-9a-zA-Z\n ]+version: (\d{0,4}[0-9.]+)\s+date: (\d{1,2}.+)/
    result =~ regex
    motherboard = $1.to_s.dup
    motherboard_vendor = $2.to_s.dup
    bios_version = $3.to_s.dup
    bios_release = $4.to_s.dup
    # ===================================================================== #
    # Show some more information next, in particular the BIOS.
    # ===================================================================== #
    make_line('  Motherboard vendor', motherboard_vendor)
    make_line('  Motherboard', motherboard)
    make_line('  BIOS version', bios_version)
    make_line('  BIOS released on', bios_release)
  end
end
obtain_information_about_the_GPU() click to toggle source
#

obtain_information_about_the_GPU

#
# File lib/hardware_information/class/obtain.rb, line 23
def obtain_information_about_the_GPU
  make_line(
    '  GPU',
    return_information_about_the_GPU
  ) { :mediumpurple }
end
obtain_information_about_the_monitor() click to toggle source
#

obtain_information_about_the_monitor

#
# File lib/hardware_information/class/obtain.rb, line 13
def obtain_information_about_the_monitor
  make_line(
    '  Monitor resolution',
    ::HardwareInformation.return_the_monitor_resolution
  ) { :mediumspringgreen }
end
obtain_linux_kernel_version() click to toggle source
#

obtain_linux_kernel_version

This method should return a String, such as '4.14.4'.

#
# File lib/hardware_information/class/obtain.rb, line 236
def obtain_linux_kernel_version
  result = `uname -r`.strip
  make_line('  Linux kernel version', result)
end
obtain_model() click to toggle source
#

obtain_model

#
# File lib/hardware_information/class/obtain.rb, line 210
def obtain_model
  result = LSCPU.grep(/Model:/).first.split(':').last.strip
  make_line '  Model', result
end
obtain_n_cores() click to toggle source
#

obtain_n_cores

Return how many cores that machine has.

#
# File lib/hardware_information/class/obtain.rb, line 100
def obtain_n_cores
  make_line(
    '  n CPU cores',
    `nproc --all`.strip
  ) { :lightgreen }
end
obtain_pci_information() click to toggle source
#

obtain_pci_information

#
# File lib/hardware_information/class/obtain.rb, line 145
def obtain_pci_information
  array_fetch_these_types = %w(
    SMBus Audio IDE VGA
    Memory Controller
  )
  results = []
  if LSPCI
    LSPCI.split(N).each {|line|
      array_fetch_these_types.each { |inner_line|
        results << line if line.include? inner_line
      }
    }
    make_line '  PCI Devices', results
  end
end
obtain_ram() click to toggle source
#

obtain_ram (ram tag)

#
# File lib/hardware_information/class/obtain.rb, line 110
def obtain_ram
  make_line('  RAM (max)', RAM_AVAILABLE) { :orangered }
end
obtain_ram_free() click to toggle source
#

obtain_ram_free

#
# File lib/hardware_information/class/obtain.rb, line 117
def obtain_ram_free
  make_line('  RAM (free)', RAM_AVAILABLE_FREE) { :orangered }
end
obtain_swap_size() click to toggle source
#

obtain_swap_size (swap tag)

#
# File lib/hardware_information/class/obtain.rb, line 124
def obtain_swap_size
  _ = DATASET_FROM_PROC_MEMINFO.grep(/SwapTotal:/).first.
      split('  ').last.strip.upcase
  make_line('  SwapTotal', _) { :springgreen }
end
obtain_system_bogomips() click to toggle source
#

obtain_system_bogomips

BogoMIPS measure CPU speed.

#
# File lib/hardware_information/class/obtain.rb, line 135
def obtain_system_bogomips
  make_line '  BogoMIPS',
    SPLITTED_CPUINFO.select {|line|
      line.include? 'bogomips'
    }.first.split(':')[1].strip
end
obtain_vendor_id() click to toggle source
#

obtain_vendor_id

#
# File lib/hardware_information/class/obtain.rb, line 90
def obtain_vendor_id
  result = LSCPU.grep(/Vendor ID:/).first.split(':').last.strip
  make_line('  Vendor ID', result) { :mediumseagreen }
end
obtain_virtualization() click to toggle source
#

obtain_virtualization

#
# File lib/hardware_information/class/obtain.rb, line 218
def obtain_virtualization
  result = LSCPU.grep(/Virtualization:/).first.split(':').last.strip
  make_line('  Virtualization', result) { :mediumseagreen }
end
pad?() click to toggle source
#

pad?

#
# File lib/hardware_information/class/misc.rb, line 17
def pad?
  @default_padding
end
report()
Alias for: run
report_result() click to toggle source
#

report_result

#
# File lib/hardware_information/class/misc.rb, line 31
def report_result
  e string?
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/hardware_information/class/reset.rb, line 12
def reset
  # ======================================================================= #
  # === @string
  # ======================================================================= #
  @string = ''.dup
  # ======================================================================= #
  # === @default_colour
  # ======================================================================= #
  @default_colour = green?
  # ======================================================================= #
  # === @default_padding
  #
  # This variable denotes the leading padding. That padding will be
  # prepended to the output.
  # ======================================================================= #
  @default_padding = ' '.dup # 1 space.
  # ======================================================================= #
  # === @use_colours
  # ======================================================================= #
  @use_colours = true # If true we use ANSI colours.
  # ======================================================================= #
  # === @use_colon_as_delimiter
  # ======================================================================= #
  @use_colon_as_delimiter = true # If true we use colon as delimiter.
  # ======================================================================= #
  # === @hash_use_these_colours
  #
  # Next we will load the internal .yml file, if it exists.
  # ======================================================================= #
  @hash_use_these_colours = {}
  if File.exist? FILE_COLOURS_FOR_THE_HARDWARE_PROJECT
    require 'yaml'
    @hash_use_these_colours.update(
      YAML.load_file(FILE_COLOURS_FOR_THE_HARDWARE_PROJECT)
    )
  else # else use a hardcoded approach.
    @hash_use_these_colours[:filesize_of_the_harddisc] = :orchid
    @hash_use_these_colours[:file_system_type] = :steelblue
  end
  set_commandline_mode # Default.
end
return_information_about_the_GPU() click to toggle source
#

return_information_about_the_GPU

This method will return information about the GPU in use on the given computer system.

This may be similar to a String such as:

GPU: AMD ATI Radeon R7 Graphics
#
# File lib/hardware_information/class/obtain.rb, line 41
def return_information_about_the_GPU
  result = `lspci #{ERROR_LINE}`.strip
  if result and result.include?('VGA compatible controller')
    result = result.split(N).select {|line|
      line.include? 'VGA compatible controller'
    }.first
    # ===================================================================== #
    # Work on:
    #
    #   VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics]"
    #
    # ===================================================================== #
    result = result.split('. [').last.
             delete('[]').tr('/',' ')
  end
  return result
end
rev() click to toggle source
#

rev

#
# File lib/hardware_information/class/colours.rb, line 74
def rev
  if use_colours?
    Colours.rev
  else
    ''
  end
end
royalblue(i) click to toggle source
#

royalblue

#
# File lib/hardware_information/class/colours.rb, line 58
def royalblue(i)
  return Colours.royalblue(i) if use_colours?
  i
end
run() click to toggle source
#

run

#
# File lib/hardware_information/class/run.rb, line 12
def run
  add_title
  obtain_architecture                  # === Architecture
  obtain_cpu_model                     # === The CPU model, such as "AMD"
  obtain_cpu_op_modes                  # === CPU op-modes
  obtain_n_cores                       # === n CPU cores
  find_out_the_amount_of_processors    # === Amount of processors
  obtain_vendor_id                     # === Vendor ID
  obtain_virtualization                # === Virtualization
  obtain_linux_kernel_version          # === The Linux kernel version
  obtain_ram                           # === Amount of RAM
  obtain_ram_free
  obtain_swap_size                     # === SwapTotal
  obtain_chip_mhz                      # === Chip MHzx
  obtain_cache_size
  obtain_system_bogomips               # === BogoMIPS
  obtain_byte_order
  obtain_cpu_family
  obtain_model                         # === Model
  obtain_information_about_the_GPU     # === Show the GPU in use
  obtain_firmware_information          # === Firmware Information
  obtain_pci_information
  add_audio_information                # === Show the audio device
  obtain_information_about_the_monitor # === Gather information about the monitor
  append_newline
  append_output_generated_via_lsblk
  report_result if @run_already # Last but not least, report the result.
end
Also aliased as: report
set_commandline_mode() click to toggle source
#

set_commandline_mode

#
# File lib/hardware_information/class/misc.rb, line 45
def set_commandline_mode
  @mode = :commandline
end
set_run_already(i) click to toggle source
#

set_run_already

#
# File lib/hardware_information/class/misc.rb, line 10
def set_run_already(i)
  @run_already = i
end
set_web_mode() click to toggle source
#

set_web_mode

#
# File lib/hardware_information/class/misc.rb, line 52
def set_web_mode
  @mode = :web
end
start_the_sinatra_interface() click to toggle source
#

start_the_sinatra_interface

To invoke this method, do:

hardi --sinatra
#
# File lib/hardware_information/class/menu.rb, line 17
def start_the_sinatra_interface
  require 'hardware_information/www/my_hardware_for_sinatra.rb'
  HardwareInformation::SinatraMyHardware.start_sinatra_interface
end
steelblue(i) click to toggle source
#

steelblue

#
# File lib/hardware_information/class/colours.rb, line 66
def steelblue(i)
  return Colours.steelblue(i) if use_colours?
  i
end
string()
Alias for: string?
string?() click to toggle source
#

string?

#
# File lib/hardware_information/class/misc.rb, line 38
def string?
  @string
end
Also aliased as: string
thistle(i) click to toggle source
#

thistle

#
# File lib/hardware_information/class/colours.rb, line 50
def thistle(i)
  return Colours.thistle(i) if use_colours?
  i
end
use_colours?() click to toggle source
#

use_colours?

#
# File lib/hardware_information/class/colours.rb, line 29
def use_colours?
  @use_colours
end