Class: TextUtils::TitleMapper2
- Inherits:
-
Object
- Object
- TextUtils::TitleMapper2
- Includes:
- LogUtils::Logging
- Defined in:
- lib/textutils/title_mapper2.rb
Overview
todo/check: rename to NameMapper ? why? why not??
Defined Under Namespace
Classes: MappingStruct
Instance Attribute Summary collapse
-
#known_titles ⇒ Object
readonly
rename to mapping or mappings or just titles - why? why not?.
Instance Method Summary collapse
- #find_key!(line) ⇒ Object
-
#find_keys!(line) ⇒ Object
NB: keys (plural!) - will return array.
-
#initialize(records, tag) ⇒ TitleMapper2
constructor
A new instance of TitleMapper2.
-
#map_titles!(line) ⇒ Object
rename to just map! - why?? why not???.
Constructor Details
#initialize(records, tag) ⇒ TitleMapper2
Returns a new instance of TitleMapper2.
24 25 26 27 28 29 |
# File 'lib/textutils/title_mapper2.rb', line 24 def initialize( records, tag ) @known_titles = build_title_table_for( records ) ## build mapping lookup table ## todo: rename tag to attrib or attrib_name - why ?? why not ??? @tag = tag # e.g. tag name use for @@brewery@@ @@team@@ etc. end |
Instance Attribute Details
#known_titles ⇒ Object (readonly)
rename to mapping or mappings or just titles - why? why not?
15 16 17 |
# File 'lib/textutils/title_mapper2.rb', line 15 def known_titles @known_titles end |
Instance Method Details
#find_key!(line) ⇒ Object
38 39 40 |
# File 'lib/textutils/title_mapper2.rb', line 38 def find_key!( line ) find_key_for!( @tag, line ) end |
#find_keys!(line) ⇒ Object
NB: keys (plural!) - will return array
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/textutils/title_mapper2.rb', line 42 def find_keys!( line ) # NB: keys (plural!) - will return array counter = 1 keys = [] key = find_key_for!( "#{@tag}#{counter}", line ) while key.present? keys << key counter += 1 key = find_key_for!( "#{@tag}#{counter}", line ) end keys end |
#map_titles!(line) ⇒ Object
rename to just map! - why?? why not???
32 33 34 35 36 |
# File 'lib/textutils/title_mapper2.rb', line 32 def map_titles!( line ) ## rename to just map! - why?? why not??? begin found = map_title_for!( @tag, line, @known_titles ) end while found end |