Class: Txbr::TemplateGroup
- Inherits:
-
Object
- Object
- Txbr::TemplateGroup
- Defined in:
- lib/txbr/template_group.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#template_name ⇒ Object
readonly
Returns the value of attribute template_name.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
- #each_resource ⇒ Object
-
#initialize(template_name, templates, project) ⇒ TemplateGroup
constructor
A new instance of TemplateGroup.
Constructor Details
#initialize(template_name, templates, project) ⇒ TemplateGroup
Returns a new instance of TemplateGroup.
5 6 7 8 9 |
# File 'lib/txbr/template_group.rb', line 5 def initialize(template_name, templates, project) @template_name = template_name @templates = templates @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
3 4 5 |
# File 'lib/txbr/template_group.rb', line 3 def project @project end |
#template_name ⇒ Object (readonly)
Returns the value of attribute template_name.
3 4 5 |
# File 'lib/txbr/template_group.rb', line 3 def template_name @template_name end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
3 4 5 |
# File 'lib/txbr/template_group.rb', line 3 def templates @templates end |
Instance Method Details
#each_resource ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/txbr/template_group.rb', line 11 def each_resource return to_enum(__method__) unless block_given? templates .flat_map { |tmpl| tmpl.each_content_tag.to_a } .group_by(&:metadata) .each do |, | strings = .inject(StringsManifest.new) do |manifest, content_tag| manifest.merge(content_tag.strings_manifest) end yield to_resource(, strings) unless strings.empty? end end |