Class: Eaternet::Lives_1_0::Adapter Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/eaternet/lives_1_0/adapter.rb

Overview

This class is abstract.

Subclass and override #businesses, #inspections, and optionally #violations, #feed_info, and #legends to implement a custom Lives 1.0 data source adapter.

Instance Method Summary collapse

Instance Method Details

#businessesEnumerable<Business>

Examples:

Print the number of restaurants in SomeCity.

some_city = Eaternet::SomeCity.new
puts some_city.businesses.count

Returns:

Required:

  • Yes


13
14
15
# File 'lib/eaternet/lives_1_0/adapter.rb', line 13

def businesses
  fail 'Override Adapter#businesses to return an Enumerable of Business'
end

#feed_infoFeedInfo

Examples:

Retrieve the name & URL of SomeCity's health agency.

some_city = Eaternet::SomeCity.new
info = some_city.feed_info
puts info.municipality_name
puts info.municipality_url

Returns:

Required:

  • No


46
47
48
# File 'lib/eaternet/lives_1_0/adapter.rb', line 46

def feed_info
  fail 'Optionally override this to return a FeedInfo'
end

#inspectionsEnumerable<Inspection>

Examples:

Compute the average inspection score for SomeCity.

some_city = Eaternet::SomeCity.new
sum = some_city.inspections
        .map(&:score)
        .reduce(0, :+)
count = some_city.inspections.count

puts "Average inspection score: " + sum / count

Returns:

Required:

  • Yes


28
29
30
# File 'lib/eaternet/lives_1_0/adapter.rb', line 28

def inspections
  fail 'Override Adapter#inspections to return an Enumerable of Inspection'
end

#legendsEnumerable<Legend>

Returns:

Required:

  • No


52
53
54
# File 'lib/eaternet/lives_1_0/adapter.rb', line 52

def legends
  fail 'Optionally override this to return an Enumerable of Legend'
end

#violationsEnumerable<Violation>

Returns:

Required:

  • No


34
35
36
# File 'lib/eaternet/lives_1_0/adapter.rb', line 34

def violations
  fail 'Optionally override this to return an Enumerable of Violation'
end