Class: CSKitStrongs::Splitters::ConcordanceSplitter
- Inherits:
-
Object
- Object
- CSKitStrongs::Splitters::ConcordanceSplitter
- Includes:
- Utilities, Enumerable
- Defined in:
- lib/cskit-strongs/splitters/concordance_splitter.rb
Constant Summary collapse
- PARSER_CONST =
CSKit::Parsers::BibleParser
Instance Attribute Summary collapse
-
#input_file ⇒ Object
readonly
Returns the value of attribute input_file.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(input_file) ⇒ ConcordanceSplitter
constructor
A new instance of ConcordanceSplitter.
Methods included from Utilities
Constructor Details
#initialize(input_file) ⇒ ConcordanceSplitter
Returns a new instance of ConcordanceSplitter.
15 16 17 |
# File 'lib/cskit-strongs/splitters/concordance_splitter.rb', line 15 def initialize(input_file) @input_file = input_file end |
Instance Attribute Details
#input_file ⇒ Object (readonly)
Returns the value of attribute input_file.
11 12 13 |
# File 'lib/cskit-strongs/splitters/concordance_splitter.rb', line 11 def input_file @input_file end |
Instance Method Details
#each ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cskit-strongs/splitters/concordance_splitter.rb', line 19 def each File.open(input_file) do |f| until f.eof? # split strongs line into [number, text, citation], split citation into [book, "chapter:verse"] parts = f.readline.match(/([hg]\d{4})(.*)(\-[\w\d]{2,3}.*)/).captures.map(&:strip) citation_parts = parts.last.match(/\-([\w\d]{2,3})(.*)/).captures # replace strong's book name with something we understand citation_text = "#{book_map[citation_parts.first]}#{citation_parts.last}" number = strip_zeroes(parts[0]) text = parts[1] citation = parser.parse(citation_text).to_object yield language, number, text, citation end end end |