Class: Stockshark::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/stockshark/configuration.rb

Overview

Environment-driven configuration — nothing here is ever a hardcoded, machine-specific path. Every value has a sensible default so the library works out of the box locally, but production is expected to set these explicitly (particularly STOCKFISH_PATH, since "stockfish" resolving via $PATH isn't guaranteed on every deploy target). Env var names stay STOCKFISH_* (not STOCKSHARK_*) deliberately — they configure the actual Stockfish (or Stockfish-compatible) binary being launched, which is a separate thing from what this gem happens to be called.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: ENV.fetch("STOCKFISH_PATH", "stockfish"), threads: Integer(ENV.fetch("STOCKFISH_THREADS", 1)), hash_mb: Integer(ENV.fetch("STOCKFISH_HASH", 16)), max_analyze_ms: Integer(ENV.fetch("STOCKFISH_MAX_ANALYZE_MS", 30_000))) ⇒ Configuration

Returns a new instance of Configuration.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stockshark/configuration.rb', line 13

def initialize(
  path: ENV.fetch("STOCKFISH_PATH", "stockfish"),
  threads: Integer(ENV.fetch("STOCKFISH_THREADS", 1)),
  hash_mb: Integer(ENV.fetch("STOCKFISH_HASH", 16)),
  max_analyze_ms: Integer(ENV.fetch("STOCKFISH_MAX_ANALYZE_MS", 30_000))
)
  @path = path
  @threads = threads
  @hash_mb = hash_mb
  @max_analyze_ms = max_analyze_ms
end

Instance Attribute Details

#hash_mbObject

Returns the value of attribute hash_mb.



11
12
13
# File 'lib/stockshark/configuration.rb', line 11

def hash_mb
  @hash_mb
end

#max_analyze_msObject

Returns the value of attribute max_analyze_ms.



11
12
13
# File 'lib/stockshark/configuration.rb', line 11

def max_analyze_ms
  @max_analyze_ms
end

#pathObject

Returns the value of attribute path.



11
12
13
# File 'lib/stockshark/configuration.rb', line 11

def path
  @path
end

#threadsObject

Returns the value of attribute threads.



11
12
13
# File 'lib/stockshark/configuration.rb', line 11

def threads
  @threads
end