Class: Sheetah::TemplateConfig
- Inherits:
-
Object
- Object
- Sheetah::TemplateConfig
- Defined in:
- lib/sheetah/template_config.rb
Instance Attribute Summary collapse
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#header(key, index) ⇒ Array(String, #match?)
Given an attribute key and a possibily-nil column index, return the header and header pattern for that column.
-
#initialize(types: Types::Container.new) ⇒ TemplateConfig
constructor
A new instance of TemplateConfig.
Constructor Details
#initialize(types: Types::Container.new) ⇒ TemplateConfig
Returns a new instance of TemplateConfig.
7 8 9 |
# File 'lib/sheetah/template_config.rb', line 7 def initialize(types: Types::Container.new) @types = types end |
Instance Attribute Details
#types ⇒ Object (readonly)
Returns the value of attribute types.
11 12 13 |
# File 'lib/sheetah/template_config.rb', line 11 def types @types end |
Instance Method Details
#header(key, index) ⇒ Array(String, #match?)
Given an attribute key and a possibily-nil column index, return the header and header pattern for that column.
The return value should be an array with two items:
-
The first item is the header, as a String.
-
The second item is the header pattern, and should respond to ‘#match?` with a boolean
value. Instances of Regexp will obviously do, but the requirement is really about the `#match?` method.
26 27 28 29 30 31 32 33 |
# File 'lib/sheetah/template_config.rb', line 26 def header(key, index) header = key.to_s.capitalize header = "#{header} #{index + 1}" if index pattern = /^#{Regexp.escape(header)}$/i [header, pattern] end |