Class: TRMNLP::UserDataAssembler

Inherits:
Object
  • Object
show all
Defined in:
lib/trmnlp/user_data_assembler.rb

Constant Summary collapse

DEFAULT_DEVICE_WIDTH =
800
DEFAULT_DEVICE_HEIGHT =
480

Instance Method Summary collapse

Constructor Details

#initialize(config:, paths:, transform_pipeline:) ⇒ UserDataAssembler

Returns a new instance of UserDataAssembler.



12
13
14
15
16
# File 'lib/trmnlp/user_data_assembler.rb', line 12

def initialize(config:, paths:, transform_pipeline:)
  @config = config
  @paths = paths
  @transform_pipeline = transform_pipeline
end

Instance Method Details

#call(device: {}) ⇒ Object

Assembles the merged data hash. The trmnl namespace is built first, layered with static_data / cached polled data / user_data_overrides, then piped through the transform. The whole trmnl namespace is re-applied after the transform so it survives even when the transform doesn’t pass it through.



23
24
25
26
27
28
29
# File 'lib/trmnlp/user_data_assembler.rb', line 23

def call(device: {})
  namespace = base_trmnl_data(device:)
  merged = assemble(namespace)
  result = transform_pipeline.call(merged)
  result['trmnl'] = namespace['trmnl']
  result
end

#device_from_params(params) ⇒ Object



31
32
33
# File 'lib/trmnlp/user_data_assembler.rb', line 31

def device_from_params(params)
  { 'width' => params[:width]&.to_i, 'height' => params[:height]&.to_i }.compact
end