Class: Txbr::TemplateGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/txbr/template_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#projectObject (readonly)

Returns the value of attribute project.



3
4
5
# File 'lib/txbr/template_group.rb', line 3

def project
  @project
end

#template_nameObject (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

#templatesObject (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_resourceObject



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..to_a }
    .group_by(&:metadata)
    .each do |, |
      strings = .inject(StringsManifest.new) do |manifest, |
        manifest.merge(.strings_manifest)
      end

      yield to_resource(, strings) unless strings.empty?
    end
end