Class: SfMobileFoodPermit::Restaurant

Inherits:
Object
  • Object
show all
Defined in:
lib/sf_mobile_food_permit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Restaurant

Returns a new instance of Restaurant.



9
10
11
12
13
14
15
# File 'lib/sf_mobile_food_permit.rb', line 9

def initialize(hash)
  @applicant = hash["applicant"]
  @address = hash["address"]
  @food_items = hash["fooditems"]
  @permit_number = hash["permit"]
  @expiration = hash["expirationdate"]
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



7
8
9
# File 'lib/sf_mobile_food_permit.rb', line 7

def address
  @address
end

#applicantObject (readonly)

Returns the value of attribute applicant.



7
8
9
# File 'lib/sf_mobile_food_permit.rb', line 7

def applicant
  @applicant
end

#expirationObject (readonly)

Returns the value of attribute expiration.



7
8
9
# File 'lib/sf_mobile_food_permit.rb', line 7

def expiration
  @expiration
end

#food_itemsObject (readonly)

Returns the value of attribute food_items.



7
8
9
# File 'lib/sf_mobile_food_permit.rb', line 7

def food_items
  @food_items
end

#permit_numberObject (readonly)

Returns the value of attribute permit_number.



7
8
9
# File 'lib/sf_mobile_food_permit.rb', line 7

def permit_number
  @permit_number
end

Class Method Details

.allObject



17
18
19
20
21
22
23
24
25
# File 'lib/sf_mobile_food_permit.rb', line 17

def self.all
  restaurants_array = Unirest.get("https://data.sfgov.org/resource/6a9r-agq8.json").body
  restaurants = []
  restaurants_array.each do |restaurant_hash|
    restaurants << Restaurant.new(restaurant_hash)
  end

  return restaurants
end