Class: Ray::Cache
Instance Attribute Summary (collapse)
-
- (Object) query
readonly
Returns the value of attribute query.
-
- (Object) results
Returns the value of attribute results.
-
- (Object) uri
readonly
Returns the value of attribute uri.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) cache
-
- (Cache) initialize(query)
constructor
A new instance of Cache.
- - (Boolean) match?(name, description)
- - (Object) search
Methods included from Search
#merge, #multiple_choice, #output
Constructor Details
- (Cache) initialize(query)
A new instance of Cache
15 16 17 18 19 |
# File 'lib/ray/search/cache.rb', line 15 def initialize query @query = query @results = search @uri = Ray::CACHE end |
Instance Attribute Details
- (Object) query (readonly)
Returns the value of attribute query
12 13 14 |
# File 'lib/ray/search/cache.rb', line 12 def query @query end |
- (Object) results
Returns the value of attribute results
13 14 15 |
# File 'lib/ray/search/cache.rb', line 13 def results @results end |
- (Object) uri (readonly)
Returns the value of attribute uri
12 13 14 |
# File 'lib/ray/search/cache.rb', line 12 def uri @uri end |
Class Method Details
+ (Object) clear
51 52 53 |
# File 'lib/ray/search/cache.rb', line 51 def self.clear FileUtils.rm Ray::CACHE end |
Instance Method Details
- (Object) cache
55 56 57 |
# File 'lib/ray/search/cache.rb', line 55 def cache return self end |
- (Boolean) match?(name, description)
42 43 44 45 46 47 48 49 |
# File 'lib/ray/search/cache.rb', line 42 def match? name, description if "#{name} #{description}".include?(@query) return true elsif name.include?(@query.to_extension_name) return true end return false end |
- (Object) search
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ray/search/cache.rb', line 21 def search return {} unless File.exist? Ray::CACHE cache = YAML.load_file Ray::CACHE results = {} cache.each do |extension| name = extension.first info = extension.last if match? name, info[:description] results[name] = { :author => info[:author], :description => info[:description], :homepage => info[:homepage], :name => name, :uri => info[:uri], :version => info[:version] } end end return results end |