Class: Eaternet::Agencies::Snhd
Instance Method Summary
collapse
#convert, #csv_map, #csv_rows, #map_csv, #try_to_create, #zip_dir, #zip_file_url
Methods included from Loggable
#logger
Constructor Details
#initialize ⇒ Snhd
Returns a new instance of Snhd.
14
15
16
|
# File 'lib/eaternet/agencies/snhd.rb', line 14
def initialize
@prototype = Eaternet::Agencies::SnhdPrototype.new
end
|
Instance Method Details
#_violations ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/eaternet/agencies/snhd.rb', line 71
def _violations
violation_kinds = {}
@prototype.violation_kinds.each do |vk|
violation_kinds[vk.orig_key] = vk
end
result = []
@prototype.inspections.each do |proto_inspection|
proto_inspection.violations.each do |kind_id|
begin
result << Eaternet::Lives_1_0::Violation.new do |v|
v.business_id = proto_inspection.business_orig_key
v.date = Date.parse(proto_inspection.date)
v.code = violation_kinds[kind_id].code
v.description = violation_kinds[kind_id].description
end
rescue StandardError => e
logger.debug "Error creating violation kind #{kind_id} for inspection #{proto_inspection.orig_key}: #{e}"
end
end
end
result.compact
end
|
#adapter_name ⇒ Object
18
19
20
|
# File 'lib/eaternet/agencies/snhd.rb', line 18
def adapter_name
'SNHD'
end
|
#business(proto) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/eaternet/agencies/snhd.rb', line 34
def business(proto)
Eaternet::Lives_1_0::Business.new do |b|
b.business_id = proto.orig_key
b.name = proto.name
b.address = proto.address
b.city = proto.city
b.postal_code = proto.zipcode
b.state = 'NV'
end
end
|
#businesses ⇒ Object
22
23
24
25
26
|
# File 'lib/eaternet/agencies/snhd.rb', line 22
def businesses
@prototype.businesses
.map { |proto| try_to_create(:business, from_csv_row: proto) }
.compact
end
|
#feed_info ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/eaternet/agencies/snhd.rb', line 57
def feed_info
Eaternet::Lives_1_0::FeedInfo.new do |fi|
fi.feed_date = Date.today
fi.feed_version = '1.0'
fi.municipality_name = 'Southern Nevada'
fi.municipality_url = 'http://southernnevadahealthdistrict.org/restaurants/index.php'
fi.contact_email = '[email protected]'
end
end
|
#inspection(proto) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/eaternet/agencies/snhd.rb', line 45
def inspection(proto)
Eaternet::Lives_1_0::Inspection.new do |i|
i.business_id = proto.business_orig_key
i.score = proto.demerits.nil? ? nil : 100 - proto.demerits.to_i
i.date = Date.parse(proto.date)
end
end
|
#inspections ⇒ Object
28
29
30
31
32
|
# File 'lib/eaternet/agencies/snhd.rb', line 28
def inspections
@prototype.inspections
.map { |proto| try_to_create(:inspection, from_csv_row: proto) }
.compact
end
|
#legends ⇒ Object
67
68
69
|
# File 'lib/eaternet/agencies/snhd.rb', line 67
def legends
[]
end
|
#violations ⇒ Object
53
54
55
|
# File 'lib/eaternet/agencies/snhd.rb', line 53
def violations
@violations ||= _violations
end
|