Module: RailsAiContext::DetailLevel
- Defined in:
- lib/rails_ai_context/detail_level.rb
Overview
The detail parameter shared by most tools. Values arrive over the wire as
strings, so this stays string-compatible rather than wrapping them; what it
adds is one definition of the allowed values and an ordering, so callers can
ask "is this at least standard?" instead of comparing literals.
Constant Summary collapse
- SUMMARY =
"summary"- STANDARD =
"standard"- FULL =
"full"- ALL =
[ SUMMARY, STANDARD, FULL ].freeze
- DEFAULT =
STANDARD- ORDER =
{ SUMMARY => 0, STANDARD => 1, FULL => 2 }.freeze
- SCHEMA_ENUM =
The enum tools publish in their input schema, so the advertised values and the normalizer cannot drift apart. Spelling the values in a tool instead fails the enum-ownership spec.
ALL
Class Method Summary collapse
- .at_least?(detail, minimum) ⇒ Boolean
- .full?(detail) ⇒ Boolean
-
.normalize(detail) ⇒ Object
Unknown values read as the default rather than falling through to whichever branch happens to be last.
- .summary?(detail) ⇒ Boolean
- .valid?(detail) ⇒ Boolean
Class Method Details
.at_least?(detail, minimum) ⇒ Boolean
33 34 35 |
# File 'lib/rails_ai_context/detail_level.rb', line 33 def self.at_least?(detail, minimum) ORDER.fetch(normalize(detail)) >= ORDER.fetch(minimum) end |
.full?(detail) ⇒ Boolean
37 38 39 |
# File 'lib/rails_ai_context/detail_level.rb', line 37 def self.full?(detail) normalize(detail) == FULL end |
.normalize(detail) ⇒ Object
Unknown values read as the default rather than falling through to whichever branch happens to be last.
29 30 31 |
# File 'lib/rails_ai_context/detail_level.rb', line 29 def self.normalize(detail) valid?(detail) ? detail.to_s : DEFAULT end |
.summary?(detail) ⇒ Boolean
41 42 43 |
# File 'lib/rails_ai_context/detail_level.rb', line 41 def self.summary?(detail) normalize(detail) == SUMMARY end |
.valid?(detail) ⇒ Boolean
23 24 25 |
# File 'lib/rails_ai_context/detail_level.rb', line 23 def self.valid?(detail) ALL.include?(detail.to_s) end |