Module: Commenter::CommentType
- Defined in:
- lib/commenter/comment_type.rb
Overview
Single home for the comment type vocabulary: short codes (ge/te/ed) and their expanded names (general/technical/editorial). Unrecognized values pass through unchanged; display_name capitalizes recognized types.
Constant Summary collapse
- FULL_NAMES =
{ "ge" => "general", "te" => "technical", "ed" => "editorial" }.freeze
- CODES =
FULL_NAMES.invert.freeze
- DISPLAY_NAMES =
FULL_NAMES.each_with_object({}) do |(code, full), display| display[code] = full.capitalize display[full] = full.capitalize end.freeze
Class Method Summary collapse
Class Method Details
.code(type) ⇒ Object
23 24 25 |
# File 'lib/commenter/comment_type.rb', line 23 def code(type) CODES.fetch(type.to_s.strip.downcase) { type&.to_s&.strip } end |
.display_name(type) ⇒ Object
31 32 33 |
# File 'lib/commenter/comment_type.rb', line 31 def display_name(type) DISPLAY_NAMES.fetch(type.to_s.strip.downcase) { type || "Unknown" } end |
.full_name(type) ⇒ Object
27 28 29 |
# File 'lib/commenter/comment_type.rb', line 27 def full_name(type) FULL_NAMES.fetch(type.to_s.strip.downcase) { type&.to_s&.strip } end |