class MartialArts::Styles

Attributes

country[RW]
description[R]
fighting_focus[RW]
name[R]
website[R]

Public Class Methods

all() click to toggle source
# File lib/martial_arts/styles.rb, line 30
def self.all
  @@all
end
duplicates?(style) click to toggle source
# File lib/martial_arts/styles.rb, line 51
def self.duplicates?(style)
  self.all.detect {|style_instance| style_instance.name == style}
end
missing_info() click to toggle source
# File lib/martial_arts/styles.rb, line 55
def self.missing_info
  #use missing_info array to make corrections to retrieve it via the scraper's correct errors method
  @@missing_info
end
new(style, country, fighting_focus, website, description) click to toggle source
# File lib/martial_arts/styles.rb, line 9
def initialize(style, country, fighting_focus, website, description)
  @name = style
  @country = MartialArts::Countries.new(country)
  @fighting_focus = MartialArts::FightingFocus.new(fighting_focus)
  @website = website
  @description = description

  @country.add_style(self)              #every style belongs to a country or fighting_focus
  @fighting_focus.add_style(self)

  self.class.missing_info << self  if country == "N/A" or fighting_focus == "N/A" or description == "N/A"
end
search_by_country(country) click to toggle source
# File lib/martial_arts/styles.rb, line 43
def self.search_by_country(country) #need to setup so that cli is getting from country_instance.styles
  self.styles_list.find_all {|style_instance| style_instance.country_name.strip.include? "#{country}" }
end
search_by_focus(focus) click to toggle source
# File lib/martial_arts/styles.rb, line 47
def self.search_by_focus(focus) #need to setup so that cli is getting from fighting_focus_instance.styles
  self.styles_list.find_all {|style_instance| style_instance.fighting_focus_name.strip.include? "#{focus}" }
end
styles_list() click to toggle source
# File lib/martial_arts/styles.rb, line 39
def self.styles_list
  self.all.sort {|a,b| a.name <=> b.name }
end

Public Instance Methods

country_name() click to toggle source
# File lib/martial_arts/styles.rb, line 22
def country_name
  self.country.name
end
fighting_focus_name() click to toggle source
# File lib/martial_arts/styles.rb, line 26
def fighting_focus_name
  self.fighting_focus.name
end