Class: Rubicure::Core

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Rubicure::Concerns::Util, Singleton
Defined in:
lib/rubicure/core.rb

Overview

generic methods

Instance Method Summary collapse

Methods included from Rubicure::Concerns::Util

load_yaml_file, #to_date

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/rubicure/core.rb', line 16

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

  if unmarked_precure.respond_to?(name)
    unmarked_precure.send(name, *args)
  else
    super
  end
end

Instance Method Details

#all_girls(arg = Time.current) ⇒ Array<Rubicure::Girl> Also known as: all, all_members

Get all precures

Examples:

Precure.all_girls.count
Precure.all_girls.map(&:precure_name)
# returns current precure count and names

Precure.all_girls("2013-10-26").count
#=> 33

Precure.all_girls.include?(Cure.echo)
#=> true

Parameters:

  • arg (Time, Date) (defaults to: Time.current)

    Time, Date or date like String (ex. “2013-12-16”)

Returns:



146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/rubicure/core.rb', line 146

def all_girls(arg = Time.current)
  date = to_date(arg)

  unless @all_girls
    @all_girls = []
    Rubicure::Girl.names.each do |girl_name|
      @all_girls << Rubicure::Girl.find(girl_name)
    end

    @all_girls.uniq!(&:human_name)
  end

  @all_girls.select {|girl| girl.created_date && girl.created_date <= date }
end

#all_stars(arg = Time.current) ⇒ Array<Rubicure::Girl>

Get precure all stars

Examples:

precure all stars

Precure.all_stars.count
Precure.all_stars.map(&:precure_name)
# returns current precure count and names

Precure.all_stars.include?(Cure.echo)
#=> false

Precure.all_stars("2013-10-26").count
#=> 33

Precure.all_stars(:dx).count
#=> 14

Precure.all_stars(:dx2).count
#=> 17

Precure.all_stars(:dx3).count
#=> 21

Precure.all_stars(:new_stage).count
#=> 29
Precure.all_stars(:new_stage).include?(Cure.echo)
#=> true

Precure.all_stars(:new_stage2).count
#=> 32

Precure.all_stars(:new_stage3).count
#=> 37
Precure.all_stars(:new_stage3).include?(Cure.echo)
#=> true

Precure.all_stars(:spring_carnival).count
#=> 40

Precure.all_stars(:sing_together_miracle_magic).count
#=> 44
Precure.all_stars(:sing_together_miracle_magic).include?(Cure.echo)
#=> true

Precure.all_stars(:memories).count
#=> 55

Precure.all_stars(:f).count
#=> 78
Precure.all_stars(:f).include?(Cure.echo)
#=> false

Parameters:

  • arg (Time, Date, String, Symbol) (defaults to: Time.current)

    Time, Date or date like String (ex. “2013-12-16”)

Returns:



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/rubicure/core.rb', line 106

def all_stars(arg = Time.current)
  extra_girls = []

  # args is Time or Date
  date = to_date(arg)

  if date
    last_all_stars_date = Rubicure::Movie.find(:stmm).started_date
    if date > last_all_stars_date
      date = last_all_stars_date
    end
  else
    # args is movie name
    movie = Rubicure::Movie.find(arg.to_sym)
    date = movie.started_date

    if movie.has_key?(:extra_girls)
      extra_girls = movie.extra_girls.map {|girl_name| Rubicure::Girl.find(girl_name.to_sym) }
    end
  end

  all_girls(date) - [Cure.echo] + extra_girls
end

#dream_starsArray<Rubicure::Girl>

Get precure dream stars

Examples:

Precure.dream_stars.count
#=> 12

Precure.dream_stars.map(&:precure_name)
#=> ["キュアフローラ", "キュアマーメイド", "キュアトゥインクル", "キュアスカーレット", "キュアミラクル", "キュアマジカル", "キュアフェリーチェ", "キュアホイップ", "キュアカスタード", "キュアジェラート", "キュアマカロン", "キュアショコラ"]

Returns:



174
175
176
177
178
179
180
181
182
183
# File 'lib/rubicure/core.rb', line 174

def dream_stars
  return @dream_stars if @dream_stars

  girls = Precure.go_princess.girls + Precure.maho_girls.girls + Precure.a_la_mode.girls

  dream_stars_date = Rubicure::Movie.find(:dream_stars).started_date
  @dream_stars = girls.select {|girl| girl.created_date && girl.created_date <= dream_stars_date }

  @dream_stars
end

#each_with_series {|series| ... } ⇒ Array<Symbol> Also known as: each

iterate with :unmarked, :max_heart, …

Yields:

  • series

Yield Parameters:

Returns:

  • (Array<Symbol>)

    ex. :unmarked, :max_heart, …



260
261
262
263
264
265
# File 'lib/rubicure/core.rb', line 260

def each_with_series
  Rubicure::Series.uniq_names.each do |series_name|
    series = Rubicure::Series.find(series_name)
    yield series
  end
end

#miracle_leapArray<Rubicure::Girl>

Get precure miracle leap

Examples:

Precure.miracle_leap.count
#=> 13

Precure.miracle_leap.map(&:precure_name)
#=> ["キュアエール", "キュアアンジュ", "キュアエトワール", "キュアマシェリ", "キュアアムール", "キュアスター", "キュアミルキー", "キュアソレイユ", "キュアセレーネ", "キュアグレース", "キュアフォンテーヌ", "キュアスパークル"]

Returns:



240
241
242
243
244
245
246
247
248
249
250
# File 'lib/rubicure/core.rb', line 240

def miracle_leap
  return @miracle_leap if @miracle_leap

  girls = Precure.hugtto.girls + Precure.star_twinkle.girls + Precure.healingood.girls

  miracle_leap_date = Rubicure::Movie.find(:miracle_leap).started_date
  @miracle_leap = girls.select {|girl| girl.created_date && girl.created_date <= miracle_leap_date }
  @miracle_leap.reject! {|girl| girl == Cure.earth }

  @miracle_leap
end

#miracle_universeArray<Rubicure::Girl>

Get precure miracle universe

Examples:

Precure.miracle_universe.count
#=> 15

Precure.miracle_universe.map(&:precure_name)
#=> ["キュアホイップ", "キュアカスタード", "キュアジェラート", "キュアマカロン", "キュアショコラ", "キュアパルフェ", "キュアエール", "キュアアンジュ", "キュアエトワール", "キュアマシェリ", "キュアアムール", "キュアスター", "キュアミルキー", "キュアソレイユ", "キュアセレーネ"]

Returns:



219
220
221
222
223
224
225
226
227
228
# File 'lib/rubicure/core.rb', line 219

def miracle_universe
  return @miracle_universe if @miracle_universe

  girls = Precure.a_la_mode.girls + Precure.hugtto.girls + Precure.star_twinkle.girls

  miracle_universe_date = Rubicure::Movie.find(:miracle_universe).started_date
  @miracle_universe = girls.select {|girl| girl.created_date && girl.created_date <= miracle_universe_date }

  @miracle_universe
end

#nowRubicure::Series Also known as: current

get current precure series

Examples:

Precure.now
#=> {:series_name=>"go_princess", :title=>"Go!プリンセスプリキュア", :started_date=>Sun, 01 Feb 2015, :girls=>["cure_flora", "cure_mermaid", "cure_twinkle", "cure_scarlet"]}

Returns:

Raises:



41
42
43
44
45
46
47
# File 'lib/rubicure/core.rb', line 41

def now
  current_time = Time.now
  each_with_series do |series|
    return series if series.on_air?(current_time)
  end
  raise NotOnAirError, "Not on air precure!"
end

#respond_to_missing?(name, _include_private) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/rubicure/core.rb', line 26

def respond_to_missing?(name, _include_private)
  unmarked_precure = Rubicure::Series.find(:unmarked)
  unmarked_precure.respond_to?(name)
end

#super_starsArray<Rubicure::Girl> Also known as: superstars

Get precure super stars

Examples:

Precure.super_stars.count
#=> 12

Precure.super_stars.map(&:precure_name)
#=> ["キュアミラクル", "キュアマジカル", "キュアフェリーチェ", "キュアホイップ", "キュアカスタード", "キュアジェラート", "キュアマカロン", "キュアショコラ", "キュアパルフェ", "キュアエール", "キュアアンジュ", "キュアエトワール"]

Returns:



195
196
197
198
199
200
201
202
203
204
# File 'lib/rubicure/core.rb', line 195

def super_stars
  return @super_stars if @super_stars

  girls = Precure.maho_girls.girls + Precure.a_la_mode.girls + Precure.hugtto.girls

  super_stars_date = Rubicure::Movie.find(:super_stars).started_date
  @super_stars = girls.select {|girl| girl.created_date && girl.created_date <= super_stars_date }

  @super_stars
end