Class: HappyHour::Bar

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

Constant Summary collapse

@@bars =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBar

Returns a new instance of Bar.



7
8
9
10
# File 'lib/happy_hour/bars.rb', line 7

def initialize
  @@bars << self

end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/happy_hour/bars.rb', line 3

def description
  @description
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/happy_hour/bars.rb', line 3

def name
  @name
end

Class Method Details

.allObject



12
13
14
# File 'lib/happy_hour/bars.rb', line 12

def self.all
  @@bars
end

.scrape_barsObject



16
17
18
19
20
21
22
23
24
# File 'lib/happy_hour/bars.rb', line 16

def self.scrape_bars
 doc = Nokogiri::HTML(open('https://www.amny.com/eat-and-drink/brooklyn-s-best-bar-deals-happy-hours-free-snacks-games-and-more-1.11756526'))
 doc.css('.mediaCell').each do |bar|
  new_bar = HappyHour::Bar.new
   new_bar.name = bar.css('h2').text
   new_bar.description = bar.css('p').text
     #binding.pry
 end
end