class T7s::Idol

Attributes

id[R]
idol_id[R]
key[R]
name[R]

Public Class Methods

all() click to toggle source
# File lib/t7s/idol.rb, line 30
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() click to toggle source
# File lib/t7s/idol.rb, line 15
def config
  unless @@config
    @@config = Dir.glob("#{File.dirname(__FILE__)}/../../config/idols/*.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/t7s/idol.rb, line 35
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/t7s/idol.rb, line 40
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/t7s/idol.rb, line 26
def names
  config.keys
end
new(**args) click to toggle source
# File lib/t7s/idol.rb, line 7
def initialize(**args)
  @idol_id          = args[:idol_id]
  @key              = args[:key]
  @name             = Name.new(args[:name])
end
valid?(idol_name) click to toggle source
# File lib/t7s/idol.rb, line 44
def valid?(idol_name)
  names.include?(idol_name)
end