Class: RailsAiBridge::DatabaseSize::BucketLabel

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/database_size.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.



72
73
74
# File 'lib/rails_ai_bridge/database_size.rb', line 72

def initialize(row_count)
  @value = row_count
end

Instance Method Details

#labelString?

Returns safe size bucket label.

Returns:

  • (String, nil)

    safe size bucket label



77
78
79
80
81
82
# File 'lib/rails_ai_bridge/database_size.rb', line 77

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

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