Class: Fluent::Plugin::RedmineOutput::TemplateExpander
- Inherits:
-
Object
- Object
- Fluent::Plugin::RedmineOutput::TemplateExpander
- Defined in:
- lib/fluent/plugin/out_redmine.rb
Constant Summary collapse
- EMPTY =
''
Instance Attribute Summary collapse
-
#placeholders ⇒ Object
readonly
Returns the value of attribute placeholders.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #bind(values) ⇒ Object
-
#initialize(template) ⇒ TemplateExpander
constructor
A new instance of TemplateExpander.
Constructor Details
#initialize(template) ⇒ TemplateExpander
Returns a new instance of TemplateExpander.
147 148 149 150 151 152 153 |
# File 'lib/fluent/plugin/out_redmine.rb', line 147 def initialize(template) @template = template @placeholders = [] @template.gsub(/%{([^}]+)}/) do @placeholders << $1 unless @placeholders.include?($1) end end |
Instance Attribute Details
#placeholders ⇒ Object (readonly)
Returns the value of attribute placeholders.
143 144 145 |
# File 'lib/fluent/plugin/out_redmine.rb', line 143 def placeholders @placeholders end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
143 144 145 |
# File 'lib/fluent/plugin/out_redmine.rb', line 143 def template @template end |
Instance Method Details
#bind(values) ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/fluent/plugin/out_redmine.rb', line 155 def bind(values) @placeholders.each do |key| key_ = :"#{key}" values[key_] = EMPTY unless values.key?(key_) end @template % values end |