Class: YARD::I18n::Text
- Inherits:
-
Object
- Object
- YARD::I18n::Text
- Defined in:
- lib/yard/i18n/text.rb
Overview
Provides some convenient features for translating a text.
Instance Method Summary collapse
-
#extract_messages {|:attribute, name, value, line_no| ... } ⇒ void
Extracts translation target messages from @input.
-
#initialize(input, options = {}) ⇒ Text
constructor
Creates a text object that has translation related features for the input text.
Constructor Details
#initialize(input, options = {}) ⇒ Text
Creates a text object that has translation related features for the input text.
11 12 13 14 |
# File 'lib/yard/i18n/text.rb', line 11 def initialize(input, ={}) @input = input @options = end |
Instance Method Details
#extract_messages {|:attribute, name, value, line_no| ... } ⇒ void
This method returns an undefined value.
Extracts translation target messages from @input.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/yard/i18n/text.rb', line 34 def paragraph = "" paragraph_start_line = 0 line_no = 0 in_header = @options[:have_header] @input.each_line do |line| line_no += 1 if in_header case line when /^#!\S+\s*$/ in_header = false unless line_no == 1 when /^\s*#\s*@(\S+)\s*(.+?)\s*$/ name, value = $1, $2 yield(:attribute, name, value, line_no) else in_header = false next if line.chomp.empty? end next if in_header end case line when /^\s*$/ next if paragraph.empty? yield(:paragraph, paragraph.rstrip, paragraph_start_line) paragraph = "" else paragraph_start_line = line_no if paragraph.empty? paragraph << line end end unless paragraph.empty? yield(:paragraph, paragraph.rstrip, paragraph_start_line) end end |