Class: ScrapeGot::Houses
- Inherits:
-
Object
- Object
- ScrapeGot::Houses
- Defined in:
- lib/scrape_got/houses.rb
Instance Attribute Summary collapse
-
#coat ⇒ Object
Returns the value of attribute coat.
-
#name ⇒ Object
Returns the value of attribute name.
-
#region ⇒ Object
Returns the value of attribute region.
-
#words ⇒ Object
Returns the value of attribute words.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Houses
constructor
A new instance of Houses.
Constructor Details
#initialize(attributes = {}) ⇒ Houses
Returns a new instance of Houses.
17 18 19 20 21 22 |
# File 'lib/scrape_got/houses.rb', line 17 def initialize(attributes = {}) @name = attributes["name"] @coat = attributes["coatOfArms"] @region = attributes["region"] @words = attributes["words"] end |
Instance Attribute Details
#coat ⇒ Object
Returns the value of attribute coat.
4 5 6 |
# File 'lib/scrape_got/houses.rb', line 4 def coat @coat end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/scrape_got/houses.rb', line 4 def name @name end |
#region ⇒ Object
Returns the value of attribute region.
4 5 6 |
# File 'lib/scrape_got/houses.rb', line 4 def region @region end |
#words ⇒ Object
Returns the value of attribute words.
4 5 6 |
# File 'lib/scrape_got/houses.rb', line 4 def words @words end |
Class Method Details
.all_houses ⇒ Object
7 8 9 |
# File 'lib/scrape_got/houses.rb', line 7 def self.all_houses @@all_houses ||= self.load_houses end |
.load_houses ⇒ Object
11 12 13 14 15 |
# File 'lib/scrape_got/houses.rb', line 11 def self.load_houses API.get_houses.collect do |houses_hash| Houses.new(houses_hash) end end |
.print_houses ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/scrape_got/houses.rb', line 24 def self.print_houses Houses.all_houses.each.with_index(1) do |house, index| puts "#{index} #{house.name}: #{house.words}" puts "Coat of Arms: #{house.coat}" puts "Region: #{house.region}" puts "-----------------------------------".colorize(:light_yellow) end end |