Class: MostHauntedCli::America
- Inherits:
-
Object
- Object
- MostHauntedCli::America
- Defined in:
- lib/most_haunted/america.rb
Constant Summary collapse
- INDEXES =
[ (46..48), (41..44), (36..39), (32..34), (28..30), (25..26), (21..23), (17..19), (13..15), (8..11), ]
- @@all =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .all ⇒ Object
- .america_descriptions(input) ⇒ Object
- .create(array) ⇒ Object
- .find_description_by_input(input) ⇒ Object
- .found(input) ⇒ Object
- .indexes ⇒ Object
- .list_location_names ⇒ Object
Instance Method Summary collapse
-
#initialize(id, name, location, description) ⇒ America
constructor
A new instance of America.
Constructor Details
#initialize(id, name, location, description) ⇒ America
Returns a new instance of America.
19 20 21 22 23 24 25 |
# File 'lib/most_haunted/america.rb', line 19 def initialize(id, name, location, description) @id = id @name = name @location = location @description = description @@all << self end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/most_haunted/america.rb', line 2 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/most_haunted/america.rb', line 2 def id @id end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/most_haunted/america.rb', line 2 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/most_haunted/america.rb', line 2 def name @name end |
Class Method Details
.all ⇒ Object
39 40 41 |
# File 'lib/most_haunted/america.rb', line 39 def self.all @@all end |
.america_descriptions(input) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/most_haunted/america.rb', line 59 def self.america_descriptions(input) input.each do |i| description = MostHauntedCli::Scraper.scrape_america_descriptions.children[i].text puts description.scan(/.{1,73}/).join("\n") puts "" end end |
.create(array) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/most_haunted/america.rb', line 27 def self.create(array) array.each do |unparsed_info| parsed_info = unparsed_info.split(",", 2) name = parsed_info[0] location = parsed_info[1] id = unparsed_info.split(".")[0].to_i description = indexes[id-1] self.new(id, name, location, description) end end |
.find_description_by_input(input) ⇒ Object
55 56 57 |
# File 'lib/most_haunted/america.rb', line 55 def self.find_description_by_input(input) self.all[input.to_i - 1].description end |
.found(input) ⇒ Object
47 48 49 |
# File 'lib/most_haunted/america.rb', line 47 def self.found(input) self.all.find{|america| america.id == input.to_i} end |
.indexes ⇒ Object
43 44 45 |
# File 'lib/most_haunted/america.rb', line 43 def self.indexes INDEXES.each{|range| (range).to_a } end |
.list_location_names ⇒ Object
51 52 53 |
# File 'lib/most_haunted/america.rb', line 51 def self.list_location_names self.all.each{|l| puts "#{l.name}"} end |