Class: RollForInitiative::Klass

Inherits:
Object
  • Object
show all
Defined in:
lib/roll_for_initiative/klass.rb

Constant Summary collapse

@@all =

this is the container holding the objects

[]
@@klass_name_list =

this should be just the array of klass names as strings

[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Klass

Returns a new instance of Klass.



11
12
13
14
# File 'lib/roll_for_initiative/klass.rb', line 11

def initialize(name)
    @name = name
    @@all << self
end

Instance Attribute Details

#klass_urlObject

Returns the value of attribute klass_url.



2
3
4
# File 'lib/roll_for_initiative/klass.rb', line 2

def klass_url
  @klass_url
end

#more_infoObject

Returns the value of attribute more_info.



2
3
4
# File 'lib/roll_for_initiative/klass.rb', line 2

def more_info
  @more_info
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/roll_for_initiative/klass.rb', line 2

def name
  @name
end

#shortObject

Returns the value of attribute short.



2
3
4
# File 'lib/roll_for_initiative/klass.rb', line 2

def short
  @short
end

Class Method Details

.allObject



31
32
33
# File 'lib/roll_for_initiative/klass.rb', line 31

def self.all
    @@all
end

.get_klass_namesObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/roll_for_initiative/klass.rb', line 18

def self.get_klass_names
    
    klass_list = RollForInitiative::Scraper.doc.search(".listing-card__content")
    klass_list.each do |klass_info|
        new_klass = RollForInitiative::Klass.new(klass_info.search(".listing-card__title").text.strip)
        @@klass_name_list << klass_info.search(".listing-card__title").text.strip.downcase
        new_klass.short = klass_info.search(".listing-card__description p").first.text.strip
        new_klass.klass_url = klass_info.search("a").first["href"] #>/classes/'theclass'
    end


end

.klass_name_listObject



35
36
37
# File 'lib/roll_for_initiative/klass.rb', line 35

def self.klass_name_list
    @@klass_name_list
end