Class: RailsAiBridge::Serializers::ContextSummary::DatabaseSize::BucketLabel

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/serializers/context_summary.rb

Overview

Value object for mapping an approximate row count to a safe label.

Instance Method Summary collapse

Constructor Details

#initialize(row_count) ⇒ BucketLabel

Returns a new instance of BucketLabel.



420
421
422
# File 'lib/rails_ai_bridge/serializers/context_summary.rb', line 420

def initialize(row_count)
  @value = row_count
end

Instance Method Details

#labelString?

Returns safe size bucket label.

Returns:

  • (String, nil)

    safe size bucket label



425
426
427
428
429
430
# File 'lib/rails_ai_bridge/serializers/context_summary.rb', line 425

def label
  return @value if SAFE_LABELS.include?(@value)
  return nil unless rows

  BUCKETS.find { |range, _bucket| range.cover?(rows) }&.last || 'hot'
end