class Rubicure::Series
Precure
TV series (ex. Smile Precure
, Dokidoki Orecure) this is record of “config/series.yml”
Public Class Methods
config()
click to toggle source
@return [Hash] content of config/series.yml
# File lib/rubicure/series.rb, line 105 def config unless @config config_file = "#{File.dirname(__FILE__)}/../../config/series.yml" @config = YAML.load_file(config_file).deep_symbolize_keys end @config end
find(series_name)
click to toggle source
@param series_name [Symbol] @return [Rubicure::Series] @raise arg is not precure
# File lib/rubicure/series.rb, line 128 def find(series_name) raise UnknownSeriesError, "unknown series: #{series_name}" unless valid?(series_name) @cache ||= {} unless @cache[series_name] series_config = config[series_name] || {} series_config.compact! @cache[series_name] = Rubicure::Series[series_config] end @cache[series_name] end
names()
click to toggle source
@return [Array<Symbol>]
# File lib/rubicure/series.rb, line 91 def names config.keys end
reload_config!()
click to toggle source
@return [Hash] content of config/precure.yml
# File lib/rubicure/series.rb, line 114 def reload_config! @cache = {} @config = nil config end
uniq_names()
click to toggle source
@return [Array<Symbol>]
# File lib/rubicure/series.rb, line 96 def uniq_names uniq_names = [] config.each do |name, series| uniq_names << name unless uniq_names.any? {|uniq_name| config[uniq_name][:title] == series[:title] } end uniq_names end
valid?(series_name)
click to toggle source
@param [Symbol] series_name
# File lib/rubicure/series.rb, line 121 def valid?(series_name) names.include?(series_name) end
Public Instance Methods
===(other)
click to toggle source
@param [Rubicure::Series,Rubicure::Girl] other
@return [Boolean] other is same Rubicure::Series
or Rubicure::Series
include Rubicure::Girl
# File lib/rubicure/series.rb, line 17 def ===(other) case other when self.class self == other when Rubicure::Girl girls.include? other else false end end
each(&block)
click to toggle source
# File lib/rubicure/series.rb, line 63 def each(&block) girls.each(&block) end
Also aliased as: each_without_girls
girls()
click to toggle source
@return [Array<Rubicure::Girl>]
# File lib/rubicure/series.rb, line 48 def girls unless @girls @girls = [] if has_key?(:girls) fetch(:girls).each do |girl_name| @girls << Rubicure::Girl.find(girl_name.to_sym) end end end @girls end
heisei?()
click to toggle source
Whether Heisei precure
# File lib/rubicure/series.rb, line 77 def heisei? started_date.heisei? || ended_date.heisei? end
on_air?(arg)
click to toggle source
Whether series is on air
@param [Time,Date,String] arg Time, Date or date like String (ex. “2013-12-16”)
@return [Boolean]
# File lib/rubicure/series.rb, line 33 def on_air?(arg) date = to_date(arg) return false unless respond_to?(:started_date) if respond_to?(:ended_date) # ended title (started_date..ended_date).cover?(date) else # on air title started_date <= date end end
reiwa?()
click to toggle source
Whether Reiwa precure
# File lib/rubicure/series.rb, line 82 def reiwa? # TODO: Remove after StarTwinkle Precure is finished return true unless has_key?(:ended_date) started_date.reiwa? || ended_date.reiwa? end
to_json(*_args)
click to toggle source
@return [String] json string
# File lib/rubicure/series.rb, line 68 def to_json(*_args) original_hash = {} each_without_girls do |k, v| original_hash[k] = v end original_hash.to_json end