Class: Rubipara::Episode

Inherits:
Object
  • Object
show all
Defined in:
lib/rubipara/episode.rb

Defined Under Namespace

Classes: NotFoundError

Constant Summary collapse

@@config =
YAML.load_file("#{File.dirname(__FILE__)}/../../config/episode.yml")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(episode_num) ⇒ Episode

Returns a new instance of Episode.

Raises:



18
19
20
21
22
# File 'lib/rubipara/episode.rb', line 18

def initialize(episode_num)
  @episode_num = episode_num.to_i
  raise NotFoundError.new('ERROR: No such an episode') unless @@config.has_key?(@episode_num)
  @title = @@config[@episode_num]['title']
end

Instance Attribute Details

#episode_numObject (readonly)

Returns the value of attribute episode_num.



5
6
7
# File 'lib/rubipara/episode.rb', line 5

def episode_num
  @episode_num
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/rubipara/episode.rb', line 5

def title
  @title
end

Class Method Details

.allObject

return an array of episode objects of all episodes



12
13
14
# File 'lib/rubipara/episode.rb', line 12

def all
  @@config.keys.map {|episode_num| Episode.new episode_num }
end