Sha256: cb42e706e8273c957eb13c11c153702929e8f28f3816565615beba78fbd0411b
Contents?: true
Size: 1008 Bytes
Versions: 3
Compression:
Stored size: 1008 Bytes
Contents
module LinuxStat module Kernel class << self def version return @@version ||= ''.freeze if string.empty? @@version ||= string.split[2] end def compiler return @@compiler ||= ''.freeze if string.empty? @@compiler ||= case string.split[4].to_s when /gcc/i then [:gcc ] when /clang/i then [:clang] when /icc/i then [:icc] end << string[/\(.*\)/].split.drop(1).find { |x| x[/^\d.*\d/] }[/^\d.*\d/] end def build_date return @@time ||= Time.new(0) if string.empty? @@time ||= begin require 'time' Time.strptime(string.split[16..-1].join(' '), "%d %b %Y %H:%M:%S %z") rescue StandardError Time.new(0) end end def string # Cached ; as changing the value in runtime is unexpected # Hotfix update can be problem, but it's rare and might not # affect the version string during program runtime. @@string ||= File.readable?('/proc/version') ? IO.read('/proc/version').tap(&:strip!) : '' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
linux_stat-0.1.3 | lib/linux_stat/kernel.rb |
linux_stat-0.1.2 | lib/linux_stat/kernel.rb |
linux_stat-0.1.1 | lib/linux_stat/kernel.rb |