Class: AustinsTopYogaStudios::Studio

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/Austins_Top_Yoga_Studios/studio.rb', line 3

def name
  @name
end

#paragraphObject

Returns the value of attribute paragraph.



3
4
5
# File 'lib/Austins_Top_Yoga_Studios/studio.rb', line 3

def paragraph
  @paragraph
end

Class Method Details

.allObject



20
21
22
# File 'lib/Austins_Top_Yoga_Studios/studio.rb', line 20

def self.all
  self.scrape_and_create_from_page
end

.scrape_and_create_from_pageObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/Austins_Top_Yoga_Studios/studio.rb', line 6

def self.scrape_and_create_from_page
  yogas = []
  doc = Nokogiri::HTML(open("https://fitt.co/austin/incredible-studios-practice-yoga-austin/"))
  s = doc.css("li.list-loop__item")
  s.each do |studios|
    studio = self.new
    studio.name = studios.css("h2.h2.list-loop__title").text
    studio.paragraph = studios.css("div.list-loop__description.t-content").text.strip
    yogas << studio
  end
  yogas
end