Class: Haml::I18n::Extractor::TextReplacer
- Inherits:
-
Object
- Object
- Haml::I18n::Extractor::TextReplacer
- Defined in:
- lib/haml-i18n-extractor/text_replacer.rb
Constant Summary collapse
- T_REGEX =
/t\('\..*'\)/
- LIMIT_KEY_NAME =
limit the number of chars
30
- NOT_ALLOWED_IN_KEYNAME =
do not pollute the key space it will make it invalid yaml
%w( ~ ` ! @ # $ % ^ & * - ( ) , ? { } )
Instance Attribute Summary collapse
-
#full_line ⇒ Object
readonly
Returns the value of attribute full_line.
-
#line_type ⇒ Object
readonly
Returns the value of attribute line_type.
-
#text_to_replace ⇒ Object
readonly
Returns the value of attribute text_to_replace.
Instance Method Summary collapse
-
#initialize(full_line, text_to_replace, line_type) ⇒ TextReplacer
constructor
A new instance of TextReplacer.
-
#modified_line ⇒ Object
the new full line, including a ‘t()` replacement instead of the `text_to_replace` portion.
- #replace_hash ⇒ Object
Constructor Details
#initialize(full_line, text_to_replace, line_type) ⇒ TextReplacer
Returns a new instance of TextReplacer.
14 15 16 17 18 19 20 21 22 |
# File 'lib/haml-i18n-extractor/text_replacer.rb', line 14 def initialize(full_line, text_to_replace,line_type) @full_line = full_line @text_to_replace = text_to_replace if LINE_TYPES_ALL.include?(line_type) @line_type = line_type else raise Extractor::NotDefinedLineType, "line type #{line_type} for #{full_line} does not make sense!" end end |
Instance Attribute Details
#full_line ⇒ Object (readonly)
Returns the value of attribute full_line.
6 7 8 |
# File 'lib/haml-i18n-extractor/text_replacer.rb', line 6 def full_line @full_line end |
#line_type ⇒ Object (readonly)
Returns the value of attribute line_type.
6 7 8 |
# File 'lib/haml-i18n-extractor/text_replacer.rb', line 6 def line_type @line_type end |
#text_to_replace ⇒ Object (readonly)
Returns the value of attribute text_to_replace.
6 7 8 |
# File 'lib/haml-i18n-extractor/text_replacer.rb', line 6 def text_to_replace @text_to_replace end |
Instance Method Details
#modified_line ⇒ Object
the new full line, including a ‘t()` replacement instead of the `text_to_replace` portion.
29 30 31 32 33 34 35 |
# File 'lib/haml-i18n-extractor/text_replacer.rb', line 29 def modified_line full_line = @full_line.dup return @full_line if has_been_translated?(full_line) remove_surrounding_quotes(full_line) apply_ruby_evaling(full_line) full_line end |
#replace_hash ⇒ Object
24 25 26 |
# File 'lib/haml-i18n-extractor/text_replacer.rb', line 24 def replace_hash @replace_hash ||= { :modified_line => modified_line, :keyname => keyname, :replaced_text => @text_to_replace } end |