Module: Reading::Parsing::Rows::CustomConfig
- Defined in:
- lib/reading/parsing/rows/custom_config.rb
Overview
A row that declares custom config.
Class Method Summary collapse
-
.column_classes ⇒ Array
No columns; parsed as if the row were blank.
-
.match?(row_string) ⇒ Boolean
Starts with a comment character and opening curly brace, and ends with a closing curly brace.
-
.merge_custom_config!(row_string) ⇒ Object
Adds this row’s custom config to the singleton config.
Class Method Details
.column_classes ⇒ Array
No columns; parsed as if the row were blank.
10 11 12 |
# File 'lib/reading/parsing/rows/custom_config.rb', line 10 def self.column_classes [] end |
.match?(row_string) ⇒ Boolean
Starts with a comment character and opening curly brace, and ends with a closing curly brace.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/reading/parsing/rows/custom_config.rb', line 18 def self.match?(row_string) row_string.match?( %r{\A \s* #{Regexp.escape(Config.hash.fetch(:comment_character))} \s* \{.+\} \s* \z}x ) end |
.merge_custom_config!(row_string) ⇒ Object
Adds this row’s custom config to the singleton config.
33 34 35 36 37 38 |
# File 'lib/reading/parsing/rows/custom_config.rb', line 33 def self.merge_custom_config!(row_string) stripped_row = row_string.strip.delete_prefix(Config.hash.fetch(:comment_character)) custom_config = eval(stripped_row) Config.hash.merge!(custom_config) end |