Class: MartialArts::Styles
- Inherits:
-
Object
- Object
- MartialArts::Styles
- Defined in:
- lib/martial_arts/styles.rb
Constant Summary collapse
- @@all =
[]
- @@popular =
[]
- @@missing_info =
[]
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#fighting_focus ⇒ Object
Returns the value of attribute fighting_focus.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Class Method Summary collapse
- .all ⇒ Object
- .duplicates?(style) ⇒ Boolean
- .missing_info ⇒ Object
- .popular ⇒ Object
-
.search_by_country(country) ⇒ Object
need to setup so that cli is getting from country_instance.styles.
-
.search_by_focus(focus) ⇒ Object
need to setup so that cli is getting from fighting_focus_instance.styles.
- .styles_list ⇒ Object
Instance Method Summary collapse
- #country_name ⇒ Object
- #fighting_focus_name ⇒ Object
-
#initialize(style, country, fighting_focus, website, description) ⇒ Styles
constructor
A new instance of Styles.
Constructor Details
#initialize(style, country, fighting_focus, website, description) ⇒ Styles
Returns a new instance of Styles.
9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/martial_arts/styles.rb', line 3 def country @country end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/martial_arts/styles.rb', line 4 def description @description end |
#fighting_focus ⇒ Object
Returns the value of attribute fighting_focus.
3 4 5 |
# File 'lib/martial_arts/styles.rb', line 3 def fighting_focus @fighting_focus end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/martial_arts/styles.rb', line 4 def name @name end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
4 5 6 |
# File 'lib/martial_arts/styles.rb', line 4 def website @website end |
Class Method Details
.all ⇒ Object
30 31 32 |
# File 'lib/martial_arts/styles.rb', line 30 def self.all @@all end |
.duplicates?(style) ⇒ Boolean
51 52 53 |
# File 'lib/martial_arts/styles.rb', line 51 def self.duplicates?(style) self.all.detect {|style_instance| style_instance.name == style} end |
.missing_info ⇒ Object
55 56 57 58 |
# 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 |
.popular ⇒ Object
34 35 36 37 |
# File 'lib/martial_arts/styles.rb', line 34 def self.popular #top 10 list taken from simpatong website; up-to-date, but list is not dynamic @@popular end |
.search_by_country(country) ⇒ Object
need to setup so that cli is getting from country_instance.styles
43 44 45 |
# 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) ⇒ Object
need to setup so that cli is getting from fighting_focus_instance.styles
47 48 49 |
# 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 ⇒ Object
39 40 41 |
# File 'lib/martial_arts/styles.rb', line 39 def self.styles_list self.all.sort {|a,b| a.name <=> b.name } end |
Instance Method Details
#country_name ⇒ Object
22 23 24 |
# File 'lib/martial_arts/styles.rb', line 22 def country_name self.country.name end |
#fighting_focus_name ⇒ Object
26 27 28 |
# File 'lib/martial_arts/styles.rb', line 26 def fighting_focus_name self.fighting_focus.name end |