class Rubimas::Idol

Attributes

age[R]
birthday[R]
blood_type[R]
bust[R]
color[R]
cv[R]
favorites[R]
handedness[R]
height[R]
hip[R]
hobbies[R]
id[R]
idol_id[R]
idol_image[R]
idol_type[R]
key[R]
name[R]
talents[R]
waist[R]
weight[R]

Public Class Methods

all() click to toggle source
# 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
Also aliased as: all_idols
all_idols()
Alias for: all
config(force: false) click to toggle source
# 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) click to toggle source
# File lib/rubimas/idol.rb, line 59
def find(idol_id)
  all_idols.find { |idol| idol.id == idol_id }
end
Also aliased as: find_by_id
find_by_id(idol_id)
Alias for: find
find_by_name(idol_name) click to toggle source
# 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() click to toggle source
# File lib/rubimas/idol.rb, line 50
def names
  config.keys
end
new(**args) click to toggle source
# 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
theaterdays!() click to toggle source
# File lib/rubimas/idol.rb, line 44
def theaterdays!
  @@theaterdays = true
  config(force: true)
  true
end
valid?(idol_name) click to toggle source
# File lib/rubimas/idol.rb, line 68
def valid?(idol_name)
  names.include?(idol_name)
end