Sha256: 0316862fff27d41835838fe43afb5c5c7047eaa5fae02197196db58d8cd8012a

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

module Rubicure
  require "singleton"

  class Core
    include Singleton

    def method_missing(name, *args)
      unmarked_precure = Rubicure::Series::find(:unmarked)

      if Rubicure::Series::valid?(name)
        Rubicure::Series::find(name)
      elsif unmarked_precure.respond_to?(name)
        unmarked_precure.send(name, *args)
      else
        super
      end
    end

    # @return [Series] current precure
    # @raise not onair!
    def now
      current_time = Time.now
      Rubicure::Series.names.each do |name|
        series = Rubicure::Series.find(name)
        return series if series.on_air?(current_time)
      end
      raise "Not on air precure!"
    end

    alias :current :now

    # @return [Array<Rubicure::Girl>]
    def all_stars
      unless @all_stars
        @all_stars = []
        Rubicure::Girl.names.each do |girl_name|
          @all_stars << Rubicure::Girl.find(girl_name)
        end

        @all_stars.uniq!{|girl| girl.precure_name }
      end

      @all_stars
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubicure-0.0.3 lib/rubicure/core.rb
rubicure-0.0.2 lib/rubicure/core.rb
rubicure-0.0.1 lib/rubicure/core.rb