Class: Rubimas::Idol
- Inherits:
-
Object
- Object
- Rubimas::Idol
- Defined in:
- lib/rubimas/idol.rb,
lib/rubimas/idol/name.rb
Defined Under Namespace
Classes: Name, UnknownIdolError
Constant Summary collapse
- @@config =
nil
- @@all_idols =
nil
- @@theaterdays =
false
Instance Attribute Summary collapse
-
#age ⇒ Object
readonly
Returns the value of attribute age.
-
#birthday ⇒ Object
readonly
Returns the value of attribute birthday.
-
#blood_type ⇒ Object
readonly
Returns the value of attribute blood_type.
-
#bust ⇒ Object
readonly
Returns the value of attribute bust.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#cv ⇒ Object
readonly
Returns the value of attribute cv.
-
#favorites ⇒ Object
readonly
Returns the value of attribute favorites.
-
#handedness ⇒ Object
readonly
Returns the value of attribute handedness.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#hip ⇒ Object
readonly
Returns the value of attribute hip.
-
#hobbies ⇒ Object
readonly
Returns the value of attribute hobbies.
-
#idol_id ⇒ Object
(also: #id)
readonly
Returns the value of attribute idol_id.
-
#idol_image ⇒ Object
readonly
Returns the value of attribute idol_image.
-
#idol_type ⇒ Object
readonly
Returns the value of attribute idol_type.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#talents ⇒ Object
readonly
Returns the value of attribute talents.
-
#waist ⇒ Object
readonly
Returns the value of attribute waist.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Class Method Summary collapse
- .all ⇒ Object (also: all_idols)
- .config(force: false) ⇒ Object
- .find(idol_id) ⇒ Object (also: find_by_id)
- .find_by_name(idol_name) ⇒ Object
- .names ⇒ Object
- .theaterdays! ⇒ Object
- .valid?(idol_name) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(**args) ⇒ Idol
constructor
A new instance of Idol.
Constructor Details
#initialize(**args) ⇒ Idol
Returns a new instance of Idol.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubimas/idol.rb', line 9 def initialize(**args) @idol_id = args[:idol_id] @key = args[:key] @idol_type = args[:idol_type] @idol_image = args[:idol_image] @name = Name.new(args[:name]) @age = args[:age] @height = args[:height] @weight = args[:weight] @bust = args[:bust] @waist = args[:waist] @hip = args[:hip] @birthday = args[:birthday] @blood_type = args[:blood_type] @handedness = args[:handedness] @hobbies = args[:hobbies] @talents = args[:talents] @favorites = args[:favorites] @color = args[:color] @cv = args[:cv] end |
Instance Attribute Details
#age ⇒ Object (readonly)
Returns the value of attribute age.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def age @age end |
#birthday ⇒ Object (readonly)
Returns the value of attribute birthday.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def birthday @birthday end |
#blood_type ⇒ Object (readonly)
Returns the value of attribute blood_type.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def blood_type @blood_type end |
#bust ⇒ Object (readonly)
Returns the value of attribute bust.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def bust @bust end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def color @color end |
#cv ⇒ Object (readonly)
Returns the value of attribute cv.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def cv @cv end |
#favorites ⇒ Object (readonly)
Returns the value of attribute favorites.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def favorites @favorites end |
#handedness ⇒ Object (readonly)
Returns the value of attribute handedness.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def handedness @handedness end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def height @height end |
#hip ⇒ Object (readonly)
Returns the value of attribute hip.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def hip @hip end |
#hobbies ⇒ Object (readonly)
Returns the value of attribute hobbies.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def hobbies @hobbies end |
#idol_id ⇒ Object (readonly) Also known as: id
Returns the value of attribute idol_id.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def idol_id @idol_id end |
#idol_image ⇒ Object (readonly)
Returns the value of attribute idol_image.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def idol_image @idol_image end |
#idol_type ⇒ Object (readonly)
Returns the value of attribute idol_type.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def idol_type @idol_type end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def name @name end |
#talents ⇒ Object (readonly)
Returns the value of attribute talents.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def talents @talents end |
#waist ⇒ Object (readonly)
Returns the value of attribute waist.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def waist @waist end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
3 4 5 |
# File 'lib/rubimas/idol.rb', line 3 def weight @weight end |
Class Method Details
.all ⇒ Object Also known as: all_idols
54 55 56 |
# File 'lib/rubimas/idol.rb', line 54 def all @@all_idols ||= config.map { |key, prof| prof[:key] = key; new(prof) }.sort_by { |idol| idol.id } end |
.config(force: false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubimas/idol.rb', line 33 def config(force: false) unless @@config && !force regexp = @@theaterdays ? '*' : '{[0-4][0-9],50}*' @@config = Dir.glob("#{File.dirname(__FILE__)}/../../config/idols/#{regexp}.yml").each_with_object({}) do |file, idols| idols.merge!(YAML.load_file(file)) end.deep_symbolize_keys @@all_idols = nil end @@config end |
.find(idol_id) ⇒ Object Also known as: find_by_id
59 60 61 |
# File 'lib/rubimas/idol.rb', line 59 def find(idol_id) all_idols.find { |idol| idol.id == idol_id } end |
.find_by_name(idol_name) ⇒ Object
64 65 66 |
# File 'lib/rubimas/idol.rb', line 64 def find_by_name(idol_name) all_idols.find { |idol| [idol.key, idol.name].include?(idol_name) } || (raise UnknownIdolError, "unknown idol: #{idol_name}") end |
.names ⇒ Object
50 51 52 |
# File 'lib/rubimas/idol.rb', line 50 def names config.keys end |
.theaterdays! ⇒ Object
44 45 46 47 48 |
# File 'lib/rubimas/idol.rb', line 44 def theaterdays! @@theaterdays = true config(force: true) true end |
.valid?(idol_name) ⇒ Boolean
68 69 70 |
# File 'lib/rubimas/idol.rb', line 68 def valid?(idol_name) names.include?(idol_name) end |