Module: Thermal::Db::Loader

Extended by:
Loader
Included in:
Loader
Defined in:
lib/thermal/db/loader.rb

Constant Summary collapse

MUTEX =
Mutex.new

Instance Method Summary collapse

Instance Method Details

#charset(charset) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/thermal/db/loader.rb', line 26

def charset(charset)
  charset = charset&.to_i
  cached(:charsets, charset) do
    charmap = data.charset(charset)&.[]('charmap')
    ::Thermal::Db::Charset.new(charset, charmap) if charmap
  end
end

#cjk_encoding(cjk) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/thermal/db/loader.rb', line 34

def cjk_encoding(cjk)
  cjk = cjk&.to_s
  cached(:cjk_encodings, cjk) do
    ruby = data.encoding(cjk)&.[]('ruby')
    ::Thermal::Db::CjkEncoding.new(cjk, ruby) if ruby
  end
end

#device(device) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/thermal/db/loader.rb', line 10

def device(device)
  device = device&.to_s
  cached(:devices, device) do
    cfg = data.device(device)
    ::Thermal::Db::Device.new(device, cfg) if cfg
  end
end

#encoding(encoding) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/thermal/db/loader.rb', line 18

def encoding(encoding)
  encoding = encoding&.to_s
  cached(:encodings, encoding) do
    charmap = data.encoding(encoding)&.[]('charmap')
    ::Thermal::Db::Encoding.new(encoding, charmap) if charmap
  end
end

#reloadObject



42
43
44
45
46
# File 'lib/thermal/db/loader.rb', line 42

def reload
  MUTEX.synchronize do
    @cache = nil
  end
end