Class: Rubipara::Character

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

Defined Under Namespace

Classes: NotFoundError

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Character

Returns a new instance of Character.

Raises:



18
19
20
21
22
23
24
25
26
# File 'lib/rubipara/character.rb', line 18

def initialize(name)
  raise NotFoundError.new('ERROR: No such a character') unless @@config.has_key?(name)
  @en_name    = name # English first name
  @name       = @@config[name]['name'] # Japanese full name
  @cv         = @@config[name]['cv']
  @grade      = @@config[name]['grade']
  @team       = @@config[name]['team']
  @fav_phrase = @@config[name]['fav_phrase']
end

Instance Attribute Details

#cvObject (readonly)

Returns the value of attribute cv.



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

def cv
  @cv
end

#en_nameObject (readonly)

Returns the value of attribute en_name.



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

def en_name
  @en_name
end

#fav_phraseObject (readonly)

Returns the value of attribute fav_phrase.



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

def fav_phrase
  @fav_phrase
end

#gradeObject (readonly)

Returns the value of attribute grade.



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

def grade
  @grade
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#teamObject (readonly)

Returns the value of attribute team.



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

def team
  @team
end

Class Method Details

.allObject

return an array of character objects of all characters



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

def all
  @@config.keys.map {|name| Character.new name }
end