Module: CharacterToDescription
- Defined in:
- lib/character_to_description.rb,
lib/character_to_description/version.rb
Constant Summary collapse
- DESCRIPTION_FOR_UNKNOWN =
'説明がありません'- DICTIONARY_PATH =
File. '../../descriptions.dic', __FILE__
- VERSION =
"0.2.0"
Class Attribute Summary collapse
-
.dictionary ⇒ Object
readonly
Returns the value of attribute dictionary.
-
.user_dictionary ⇒ Object
Returns the value of attribute user_dictionary.
Instance Method Summary collapse
- #to_description ⇒ Object (also: #to_d)
Class Attribute Details
.dictionary ⇒ Object (readonly)
Returns the value of attribute dictionary.
21 22 23 |
# File 'lib/character_to_description.rb', line 21 def dictionary @dictionary end |
.user_dictionary ⇒ Object
Returns the value of attribute user_dictionary.
22 23 24 |
# File 'lib/character_to_description.rb', line 22 def user_dictionary @user_dictionary end |
Instance Method Details
#to_description ⇒ Object Also known as: to_d
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/character_to_description.rb', line 25 def to_description character = self[0] description = CharacterToDescription.user_dictionary[character] return description unless description.nil? case character when /[a-z]/ "Lower case #{character}" when /[A-Z]/ "Upper case: #{character}" when /\p{Hiragana}/ "ひらがなの「#{character}」" when /\p{Katakana}/ "カタカナの「#{character}」" when /[一-龠]/ CharacterToDescription.dictionary[character] else CharacterToDescription::DESCRIPTION_FOR_UNKNOWN end end |