class Claymore::GPUHashRate
Extracts asset, gpu index and gpu hash rate Sets hash rate to -1 when gpu is off
Example input: 05:45:16:028 2100 ETH: GPU0 29.586 Mh/s, GPU1 off
Example output: [
{ 'asset' => 'ETH', 'gpu' => 0, 'hash_rate' => 29.586, 'type' => 'GPU_HASH_RATE' }, { 'asset' => 'ETH', 'gpu' => 1, 'hash_rate' => -1.0, 'type' => 'GPU_HASH_RATE' }
]
Constants
- LINE_REGEXP
- RATES_REGEXP
Attributes
line[R]
Public Class Methods
call(line)
click to toggle source
# File lib/claymore/gpu_hash_rate.rb, line 21 def self.call(line) new(line).call end
new(line)
click to toggle source
# File lib/claymore/gpu_hash_rate.rb, line 27 def initialize(line) @line = line end
Public Instance Methods
call()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/claymore/gpu_hash_rate.rb, line 32 def call (match = LINE_REGEXP.match(line)) || return raw_rates.each_with_object([]) do |(raw_index, raw_rate), acc| hash_rate = raw_rate == 'off' ? -1.0 : raw_rate.to_f.round(3) index = raw_index.to_i acc << { 'type' => 'GPU_HASH_RATE', 'asset' => match[:asset], 'gpu' => index, 'hash_rate' => hash_rate } end end
Private Instance Methods
raw_rates()
click to toggle source
rubocop:enable Metrics/MethodLength
# File lib/claymore/gpu_hash_rate.rb, line 51 def raw_rates line.scan(RATES_REGEXP) end