Module: ProjectFileReader
- Included in:
- InvoiceProject
- Defined in:
- lib/ascii_invoicer/projectFileReader.rb
Instance Method Summary collapse
-
#read(key, data = @data) ⇒ Object
little read function returns data if read already or does a lookup.
Instance Method Details
#read(key, data = @data) ⇒ Object
little read function returns data if read already or does a lookup
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ascii_invoicer/projectFileReader.rb', line 17 def read(key, data = @data) return nil unless key.class == Symbol # data has already been read @logger.info Paint["KNOWN KEY: #{key}",:cyan] if data[key] if @settings.DEBUG return data[key] if data[key] @logger.info Paint["reading :#{key}", :green, :bold] if @settings.DEBUG raw = @raw_data[key.to_s] default = @defaults[key.to_s] # if key is in raw_data walk it trough applying filters if raw @logger.info " FOUND RAW #{key}" if @settings.DEBUG @logger.info " walking #{key}" if @settings.DEBUG return data[key] = walk(raw, [key]) #fail "#{self.class} DOES NOT KNOW WHAT TO DO WITH #{raw.class}" end # or the default from the settings unless default.nil? @logger.info " FOUND DEFAULT #{key}" if @settings.DEBUG return data[key] = walk(default, [key]) end # otherwise fail return data[key] = fail_at(key) end |