Class: ModpackLocalizer::SNBT::Formatter
- Inherits:
-
Object
- Object
- ModpackLocalizer::SNBT::Formatter
- Includes:
- IndentHelper
- Defined in:
- lib/modpack_localizer/snbt/formatter.rb
Overview
翻訳された内容をSNBT形式に整形するクラス
Instance Method Summary collapse
-
#adjust_line_length(content) ⇒ void
行数をstart_line~end_lineと一致させる.
-
#format_for_snbt(lines, indent, content) ⇒ String
SNBT形式に整形.
-
#format_overwritable_lines(content, indent) ⇒ String
保存できるように整形.
Methods included from IndentHelper
#count_indent, #create_indent, #middle_indent
Instance Method Details
#adjust_line_length(content) ⇒ void
This method returns an undefined value.
行数をstart_line~end_lineと一致させる
35 36 37 38 39 40 41 42 43 |
# File 'lib/modpack_localizer/snbt/formatter.rb', line 35 def adjust_line_length(content) required_lines = extract_required_line_counts(content) lines = content[:text].split("\n") delete_over_lines(lines, required_lines) add_missing_lines(lines, required_lines, content[:indent]) lines end |
#format_for_snbt(lines, indent, content) ⇒ String
SNBT形式に整形
25 26 27 28 29 |
# File 'lib/modpack_localizer/snbt/formatter.rb', line 25 def format_for_snbt(lines, indent, content) lines = prepare_lines_for_snbt(lines, content) formatted_lines = format_lines(lines, indent, content) "#{indent}#{content[:type]}: #{formatted_lines}" end |
#format_overwritable_lines(content, indent) ⇒ String
保存できるように整形
14 15 16 17 |
# File 'lib/modpack_localizer/snbt/formatter.rb', line 14 def format_overwritable_lines(content, indent) full_lines = adjust_line_length(content) format_for_snbt(full_lines, indent, content) end |