class I27r::Line
Attributes
text[R]
Public Class Methods
new(text, options = {})
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 12 def initialize(text, options = {}) @generated = !!options[:generated] || text.end_with?(' #g') @yaml = YAML.load text.to_s + ' ' @text = text end
Public Instance Methods
generated?()
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 30 def generated? @generated end
indent()
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 26 def indent yaml? ? @text.scan(/^ */).first : '' end
key()
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 18 def key yaml? ? @yaml.keys.first : nil end
to_s()
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 45 def to_s "#{@text}#{' #g' if generated? && yaml? && !value.nil? && !@text.end_with?(' #g')}" end
value()
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 22 def value yaml? ? @yaml.values.first : nil end
value=(val)
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 38 def value=(val) if @yaml[self.key] != val @yaml[self.key] = val generate_text self.indent end end
yaml?()
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 34 def yaml? @yaml.is_a?(Hash) && @yaml.keys.first.is_a?(String) end
Private Instance Methods
generate_text(indent)
click to toggle source
# File lib/generators/i18n_translation/lib/yaml.rb, line 50 def generate_text(indent) @text = indent + @yaml.to_yaml.sub(/--- ?\n/, '').chomp.rstrip end