Class: Rubicure::Movie
- Inherits:
-
Hash
- Object
- Hash
- Rubicure::Movie
- Extended by:
- Concerns::Util
- Includes:
- Hashie::Extensions::MethodAccess
- Defined in:
- lib/rubicure/movie.rb
Overview
Precure All Stars Movie
this is record of “config/movies.yml”
Class Method Summary collapse
-
.config ⇒ Hash
Content of config/movies.yml.
- .find(movie_name) ⇒ Rubicure::Movie
- .names ⇒ Array<Symbol>
-
.reload_config! ⇒ Hash
Content of config/movies.yml.
- .uniq_names ⇒ Array<Symbol>
- .valid?(series_name) ⇒ Boolean
Methods included from Concerns::Util
Class Method Details
.config ⇒ Hash
Returns content of config/movies.yml.
26 27 28 29 30 31 32 |
# File 'lib/rubicure/movie.rb', line 26 def config unless @config config_file = "#{File.dirname(__FILE__)}/../../config/movies.yml" @config = load_yaml_file(config_file).deep_symbolize_keys end @config end |
.find(movie_name) ⇒ Rubicure::Movie
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rubicure/movie.rb', line 49 def find(movie_name) raise UnknownMovieError, "unknown movie: #{movie_name}" unless valid?(movie_name) @cache ||= {} unless @cache[movie_name] movie_config = config[movie_name] || {} movie_config.compact! @cache[movie_name] = Rubicure::Movie[movie_config] end @cache[movie_name] end |
.names ⇒ Array<Symbol>
12 13 14 |
# File 'lib/rubicure/movie.rb', line 12 def names config.keys end |
.reload_config! ⇒ Hash
Returns content of config/movies.yml.
35 36 37 38 39 |
# File 'lib/rubicure/movie.rb', line 35 def reload_config! @cache = {} @config = nil config end |
.uniq_names ⇒ Array<Symbol>
17 18 19 20 21 22 23 |
# File 'lib/rubicure/movie.rb', line 17 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) ⇒ Boolean
42 43 44 |
# File 'lib/rubicure/movie.rb', line 42 def valid?(series_name) names.include?(series_name) end |