module Thelister::ClassMethods
Constants
- DATA_PATH
- DOT_EXTENSION
Public Instance Methods
all()
click to toggle source
# File lib/listof/thelister.rb, line 32 def all() contents_hash = {} Dir.glob("#{DATA_PATH}/*#{DOT_EXTENSION}").each_with_index do |path, index| contents_hash[index] = File.basename(path, DOT_EXTENSION) end contents_hash end
file_for_query()
click to toggle source
# File lib/listof/thelister.rb, line 28 def file_for_query "#{DATA_PATH}/#{@query}#{DOT_EXTENSION}" end
find(query)
click to toggle source
# File lib/listof/thelister.rb, line 8 def find(query) @query = query contents_hash = {} if File.file?(file_for_query) f = File.open(file_for_query) _lineno = 1 f.each_line.with_index do |line| line = line.strip if !line.start_with?("#") and line.length >= 1 contents_hash[_lineno] = line _lineno += 1 elsif line.start_with?("#") l = line.sub("#", "").split() contents_hash[l[0]] = l[1] end end end contents_hash end