Class: I18nYamlEditor::Translation

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_yaml_editor/translation.rb

Overview

A Translation holds information about its name, file and text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Translation

Returns a new instance of Translation.



8
9
10
# File 'lib/i18n_yaml_editor/translation.rb', line 8

def initialize(attributes = {})
  @name, @file, @text = attributes.values_at(:name, :file, :text)
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



6
7
8
# File 'lib/i18n_yaml_editor/translation.rb', line 6

def file
  @file
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/i18n_yaml_editor/translation.rb', line 6

def name
  @name
end

#textObject

Returns the value of attribute text.



6
7
8
# File 'lib/i18n_yaml_editor/translation.rb', line 6

def text
  @text
end

Instance Method Details

#keyObject

This translation’s key



13
14
15
# File 'lib/i18n_yaml_editor/translation.rb', line 13

def key
  @key ||= name.split('.')[1..-1].join('.')
end

#localeObject

This translation’s locale



18
19
20
# File 'lib/i18n_yaml_editor/translation.rb', line 18

def locale
  @locale ||= name.split('.').first
end