Class: TextUtils::TitleMapper
- Inherits:
-
Object
- Object
- TextUtils::TitleMapper
- Includes:
- LogUtils::Logging
- Defined in:
- lib/textutils/title_mapper.rb
Overview
todo/check: rename to NameMapper ? why? why not??
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) ⇒ TitleMapper
constructor
A new instance of TitleMapper.
-
#map_titles!(line) ⇒ Object
rename to just map! - why?? why not???.
Constructor Details
#initialize(records, tag) ⇒ TitleMapper
Returns a new instance of TitleMapper.
25 26 27 28 29 30 |
# File 'lib/textutils/title_mapper.rb', line 25 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?
23 24 25 |
# File 'lib/textutils/title_mapper.rb', line 23 def known_titles @known_titles end |
Instance Method Details
#find_key!(line) ⇒ Object
42 43 44 |
# File 'lib/textutils/title_mapper.rb', line 42 def find_key!( line ) find_key_for!( @tag, line ) end |
#find_keys!(line) ⇒ Object
NB: keys (plural!) - will return array
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/textutils/title_mapper.rb', line 46 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???
33 34 35 36 37 38 39 |
# File 'lib/textutils/title_mapper.rb', line 33 def map_titles!( line ) ## rename to just map! - why?? why not??? @known_titles.each do |rec| key = rec[0] values = rec[1] map_title_for!( @tag, line, key, values ) end end |