Class: MostHauntedCli::States
- Inherits:
-
Object
- Object
- MostHauntedCli::States
- Defined in:
- lib/most_haunted/states.rb
Constant Summary collapse
- @@haunted =
[]
- @@states =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .add_urls ⇒ Object
- .create_columns(slice) ⇒ Object
- .create_state(array) ⇒ Object
- .haunted ⇒ Object
-
.open_state_info(input) ⇒ Object
Individual State Information.
- .state_columns ⇒ Object
- .states ⇒ Object
- .states_list ⇒ Object
Instance Method Summary collapse
-
#initialize(name) ⇒ States
constructor
A new instance of States.
Constructor Details
#initialize(name) ⇒ States
Returns a new instance of States.
7 8 9 10 |
# File 'lib/most_haunted/states.rb', line 7 def initialize(name) @name = name @@haunted << self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/most_haunted/states.rb', line 2 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/most_haunted/states.rb', line 2 def url @url end |
Class Method Details
.add_urls ⇒ Object
54 55 56 57 58 59 |
# File 'lib/most_haunted/states.rb', line 54 def self.add_urls u = MostHauntedCli::Scraper.scrape_state_url self.haunted.each.with_index do |h, i| h.url = u[i] end end |
.create_columns(slice) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/most_haunted/states.rb', line 32 def self.create_columns(slice) l = slice[0].length if l >= 24 puts "#{slice[0]}"+" "+"#{slice[1]}" else puts "#{slice[0]}"+" " * (30 - l)+"#{slice[1]}" end end |
.create_state(array) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/most_haunted/states.rb', line 12 def self.create_state(array) array.each do |s| name = s self.new(name) end add_urls end |
.haunted ⇒ Object
20 21 22 |
# File 'lib/most_haunted/states.rb', line 20 def self.haunted @@haunted end |
.open_state_info(input) ⇒ Object
Individual State Information
49 50 51 52 |
# File 'lib/most_haunted/states.rb', line 49 def self.open_state_info(input) info = MostHauntedCli::Scraper.scrape_state_locations(input) info.each{|i| puts i.gsub(' –', '.')} end |
.state_columns ⇒ Object
41 42 43 44 45 |
# File 'lib/most_haunted/states.rb', line 41 def self.state_columns states_list.each.each_slice(2) do |slice| create_columns(slice) end end |
.states ⇒ Object
24 25 26 |
# File 'lib/most_haunted/states.rb', line 24 def self.states @@states end |
.states_list ⇒ Object
28 29 30 |
# File 'lib/most_haunted/states.rb', line 28 def self.states_list self.haunted.collect.with_index(1){|s, i| "#{i}. #{s.name}"} end |