Class: Txgh::TxResource
- Inherits:
-
Object
- Object
- Txgh::TxResource
- Defined in:
- lib/txgh/tx_resource.rb
Instance Attribute Summary collapse
-
#project_slug ⇒ Object
readonly
Returns the value of attribute project_slug.
-
#resource_slug ⇒ Object
(also: #original_resource_slug)
readonly
Returns the value of attribute resource_slug.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
-
#source_lang ⇒ Object
readonly
Returns the value of attribute source_lang.
-
#translation_file ⇒ Object
readonly
Returns the value of attribute translation_file.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #branch ⇒ Object
- #has_branch? ⇒ Boolean
-
#initialize(project_slug, resource_slug, type, source_lang, source_file, lang_map, translation_file) ⇒ TxResource
constructor
A new instance of TxResource.
- #lang_map(tx_lang) ⇒ Object
- #slugs ⇒ Object
- #to_api_h ⇒ Object
- #to_h ⇒ Object
- #translation_path(language) ⇒ Object
Constructor Details
#initialize(project_slug, resource_slug, type, source_lang, source_file, lang_map, translation_file) ⇒ TxResource
Returns a new instance of TxResource.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/txgh/tx_resource.rb', line 8 def initialize(project_slug, resource_slug, type, source_lang, source_file, lang_map, translation_file) @project_slug = project_slug @resource_slug = resource_slug @type = type @source_lang = source_lang @source_file = source_file @lang_map = lang_map @translation_file = translation_file end |
Instance Attribute Details
#project_slug ⇒ Object (readonly)
Returns the value of attribute project_slug.
3 4 5 |
# File 'lib/txgh/tx_resource.rb', line 3 def project_slug @project_slug end |
#resource_slug ⇒ Object (readonly) Also known as: original_resource_slug
Returns the value of attribute resource_slug.
3 4 5 |
# File 'lib/txgh/tx_resource.rb', line 3 def resource_slug @resource_slug end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
4 5 6 |
# File 'lib/txgh/tx_resource.rb', line 4 def source_file @source_file end |
#source_lang ⇒ Object (readonly)
Returns the value of attribute source_lang.
3 4 5 |
# File 'lib/txgh/tx_resource.rb', line 3 def source_lang @source_lang end |
#translation_file ⇒ Object (readonly)
Returns the value of attribute translation_file.
4 5 6 |
# File 'lib/txgh/tx_resource.rb', line 4 def translation_file @translation_file end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/txgh/tx_resource.rb', line 3 def type @type end |
Instance Method Details
#branch ⇒ Object
51 52 53 |
# File 'lib/txgh/tx_resource.rb', line 51 def branch nil end |
#has_branch? ⇒ Boolean
55 56 57 |
# File 'lib/txgh/tx_resource.rb', line 55 def has_branch? false end |
#lang_map(tx_lang) ⇒ Object
19 20 21 |
# File 'lib/txgh/tx_resource.rb', line 19 def lang_map(tx_lang) @lang_map.fetch(tx_lang, tx_lang) end |
#slugs ⇒ Object
27 28 29 |
# File 'lib/txgh/tx_resource.rb', line 27 def slugs [project_slug, resource_slug] end |
#to_api_h ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/txgh/tx_resource.rb', line 42 def to_api_h { 'slug' => resource_slug, 'i18n_type' => type, 'source_language_code' => source_lang, 'name' => translation_file } end |
#to_h ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/txgh/tx_resource.rb', line 31 def to_h { project_slug: project_slug, resource_slug: resource_slug, type: type, source_lang: source_lang, source_file: source_file, translation_file: translation_file } end |
#translation_path(language) ⇒ Object
23 24 25 |
# File 'lib/txgh/tx_resource.rb', line 23 def translation_path(language) translation_file.gsub('<lang>', lang_map(language)) end |