Class: MartialArts::Countries

Inherits:
Object
  • Object
show all
Defined in:
lib/martial_arts/countries.rb

Constant Summary collapse

@@unfiltered =
[]
@@filtered =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Countries

Returns a new instance of Countries.



7
8
9
10
# File 'lib/martial_arts/countries.rb', line 7

def initialize(name)
  @name = name
  @styles = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/martial_arts/countries.rb', line 3

def name
  @name
end

Class Method Details

.country_listObject

def styles

@styles             styles method not needed, but fulfills country has many styles relationship

end



21
22
23
# File 'lib/martial_arts/countries.rb', line 21

def self.country_list
  self.filtered.uniq.sort {|a,b| a <=> b }
end

.filteredObject



25
26
27
28
# File 'lib/martial_arts/countries.rb', line 25

def self.filtered
  #styles from the list of martial arts wikipedia page, easer to acces but not as much info
  @@filtered
end

.unfilteredObject



30
31
32
33
# File 'lib/martial_arts/countries.rb', line 30

def self.unfiltered
  #countries from the style's wikipedia page, has more info but harder to access if not specific
  @@unfiltered
end

Instance Method Details

#add_style(style) ⇒ Object



12
13
14
15
# File 'lib/martial_arts/countries.rb', line 12

def add_style(style)
  @styles << style
  style.country = self
end