class Astronomy::Information
Constants
- DATA_FILE
Attributes
data[R]
Public Class Methods
new()
click to toggle source
# File lib/astronomy.rb, line 10 def initialize @data = YAML.load_file(DATA_FILE) end
Public Instance Methods
categories()
click to toggle source
# File lib/astronomy.rb, line 14 def categories @data.keys end
search(topic)
click to toggle source
# File lib/astronomy.rb, line 22 def search(topic) query = topic.downcase results = [] @data.each do |category, array_of_topics| array_of_topics.each do |topic| results << topic and next if topic['name'].downcase.include?(query) results << topic if topic['description'].downcase.include?(query) end end results end
topics(category)
click to toggle source
# File lib/astronomy.rb, line 18 def topics(category) @data[category] end