Class: Eaternet::Lives_1_0::Inspection

Inherits:
ValidatedObject show all
Defined in:
lib/eaternet/lives_1_0/inspection.rb

Overview

Information about an inspectors’ visit to a businesses.

Constant Summary collapse

ZERO_TO_ONE_HUNDRED_AND_BLANK =
(0..100).to_a + ['']

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ValidatedObject

#check_validations!, #initialize

Constructor Details

This class inherits a constructor from Eaternet::ValidatedObject

Instance Attribute Details

#business_idString

Unique identifier of the business for which this inspection was done.

Returns:

  • (String)

Required:

  • Yes


17
18
19
# File 'lib/eaternet/lives_1_0/inspection.rb', line 17

def business_id
  @business_id
end

#dateDate

Date of the inspection.

Returns:

  • (Date)

Required:

  • Yes


43
44
45
# File 'lib/eaternet/lives_1_0/inspection.rb', line 43

def date
  @date
end

#descriptionString

Single line description containing details on the outcome of an inspection. Use of this field is only encouraged if no violations are provided.

Returns:

  • (String)

Required:

  • No


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

def description
  @description
end

#scoreInteger, String

Inspection score on a 0-100 scale. 100 is the highest score. This column must always be present in inspections.csv. However, it can be safely left blank for inspection rows that don’t have an associated score. (For example, some municipalities don’t associate a follow-up inspection with a score.)

Returns:

  • (Integer)

    if it's a scored inspection

  • (String)

    if it's an un-scored inspection, then the return value will be an empty string.

Required:

  • No


30
31
32
# File 'lib/eaternet/lives_1_0/inspection.rb', line 30

def score
  @score
end

#typeString

String representing the type of inspection. Must be (initial, routine, followup, complaint).

Returns:

  • (String)

Required:

  • No


59
60
61
# File 'lib/eaternet/lives_1_0/inspection.rb', line 59

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



69
70
71
# File 'lib/eaternet/lives_1_0/inspection.rb', line 69

def ==(other)
  business_id == other.business_id && date == other.date
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/eaternet/lives_1_0/inspection.rb', line 73

def eql?(other)
  self == other
end

#hashObject



77
78
79
# File 'lib/eaternet/lives_1_0/inspection.rb', line 77

def hash
  "#{business_id} #{date}".hash
end

#to_sString

Returns:

  • (String)


65
66
67
# File 'lib/eaternet/lives_1_0/inspection.rb', line 65

def to_s
  "Inspection #{business_id}/#{date}/#{score}"
end