Class: I18nContextGenerator::TranslationCommentIndex
- Inherits:
-
Object
- Object
- I18nContextGenerator::TranslationCommentIndex
- Defined in:
- lib/i18n_context_generator/translation_comment_index.rb
Overview
Associates translator-comment lines with the translation entry that follows. Diff consumers use this to treat comment-only edits as entry changes while retaining the exact changed comment line for review placement.
Instance Method Summary collapse
-
#initialize(file_path = nil, format:, content: nil) ⇒ TranslationCommentIndex
constructor
A new instance of TranslationCommentIndex.
- #key_at(line_number) ⇒ Object
- #line_for_key(key) ⇒ Object
Constructor Details
#initialize(file_path = nil, format:, content: nil) ⇒ TranslationCommentIndex
Returns a new instance of TranslationCommentIndex.
11 12 13 14 15 16 |
# File 'lib/i18n_context_generator/translation_comment_index.rb', line 11 def initialize(file_path = nil, format:, content: nil) @file_path = file_path @format = format @content = content || File.binread(file_path) @key_lines = {} end |
Instance Method Details
#key_at(line_number) ⇒ Object
18 19 20 |
# File 'lib/i18n_context_generator/translation_comment_index.rb', line 18 def key_at(line_number) entries[line_number] end |
#line_for_key(key) ⇒ Object
22 23 24 25 |
# File 'lib/i18n_context_generator/translation_comment_index.rb', line 22 def line_for_key(key) entries @key_lines[key] end |