Class: RNGSyllable
- Inherits:
-
Object
- Object
- RNGSyllable
- Defined in:
- lib/random_name_generator/rng_syllable.rb
Overview
SYLLABLE CLASSIFICATION: Name is usually composed from 3 different class of syllables, which include prefix, middle part and suffix. To declare syllable as a prefix in the file, insert “-” as a first character of the line. To declare syllable as a suffix in the file, insert “+” as a first character of the line. everything else is read as a middle part.
NUMBER OF SYLLABLES: Names may have any positive number of syllables. In case of 2 syllables, name will be composed from prefix and suffix. In case of 1 syllable, name will be chosen from amongst the prefixes. In case of 3 and more syllables, name will begin with prefix, is filled with middle parts and ended with suffix.
ASSIGNING RULES: I included a way to set 4 kind of rules for every syllable. To add rules to the syllables, write them right after the syllable and SEPARATE WITH WHITESPACE. (example: “aad +v -c”). The order of rules is not important.
RULES: 1) v means that next syllable must definitely start with a vocal. 2) c means that next syllable must definitely start with a consonant. 3) -v means that this syllable can only be added to another syllable, that ends with a vocal. 4) -c means that this syllable can only be added to another syllable, that ends with a consonant.
Constant Summary collapse
- VOWELS =
%w(i y ɨ ʉ ɯ u ɪ ʏ ʊ ɯ ʊ e ø ɘ ɵ ɤ o ø ə ɵ ɤ o ɛ œ ɜ ɞ ʌ ɔ æ ɐ ɞ a ɶ ä ɒ ɑ).freeze
- CONSONANTS =
%w(b ɓ ʙ β c d ɗ ɖ ð f g h j k l ł m ɱ n ɳ p q r s t v w x y z).freeze
Instance Attribute Summary collapse
-
#next_syllable_requirement ⇒ Object
readonly
Returns the value of attribute next_syllable_requirement.
-
#previous_syllable_requirement ⇒ Object
readonly
Returns the value of attribute previous_syllable_requirement.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#syllable ⇒ Object
readonly
Returns the value of attribute syllable.
Instance Method Summary collapse
- #compatible?(next_syllable) ⇒ Boolean
- #consonant_first? ⇒ Boolean
- #consonant_last? ⇒ Boolean
- #incompatible?(next_syllable) ⇒ Boolean
-
#initialize(args) ⇒ RNGSyllable
constructor
A new instance of RNGSyllable.
- #next_syllable_must_start_with_consonant? ⇒ Boolean
- #next_syllable_must_start_with_vowel? ⇒ Boolean
- #next_syllable_universal? ⇒ Boolean
- #prefix? ⇒ Boolean
- #previous_syllable_must_end_with_consonant? ⇒ Boolean
- #previous_syllable_must_end_with_vowel? ⇒ Boolean
- #previous_syllable_universal? ⇒ Boolean
- #suffix? ⇒ Boolean
- #to_s ⇒ Object
- #to_str ⇒ Object
- #vowel_first? ⇒ Boolean
- #vowel_last? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ RNGSyllable
Returns a new instance of RNGSyllable.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/random_name_generator/rng_syllable.rb', line 28 def initialize(args) @raw = args @is_prefix = false @is_suffix = false @next_syllable_requirement = :letter @previous_syllable_requirement = :letter if args.is_a?(RNGSyllable) then parse_args(args.raw) else parse_args(args) end end |
Instance Attribute Details
#next_syllable_requirement ⇒ Object (readonly)
Returns the value of attribute next_syllable_requirement.
23 24 25 |
# File 'lib/random_name_generator/rng_syllable.rb', line 23 def next_syllable_requirement @next_syllable_requirement end |
#previous_syllable_requirement ⇒ Object (readonly)
Returns the value of attribute previous_syllable_requirement.
23 24 25 |
# File 'lib/random_name_generator/rng_syllable.rb', line 23 def previous_syllable_requirement @previous_syllable_requirement end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
23 24 25 |
# File 'lib/random_name_generator/rng_syllable.rb', line 23 def raw @raw end |
#syllable ⇒ Object (readonly)
Returns the value of attribute syllable.
23 24 25 |
# File 'lib/random_name_generator/rng_syllable.rb', line 23 def syllable @syllable end |
Instance Method Details
#compatible?(next_syllable) ⇒ Boolean
46 47 48 |
# File 'lib/random_name_generator/rng_syllable.rb', line 46 def compatible?(next_syllable) !incompatible?(next_syllable) end |
#consonant_first? ⇒ Boolean
58 59 60 |
# File 'lib/random_name_generator/rng_syllable.rb', line 58 def consonant_first? CONSONANTS.include?(syllable[0]) end |
#consonant_last? ⇒ Boolean
66 67 68 |
# File 'lib/random_name_generator/rng_syllable.rb', line 66 def consonant_last? CONSONANTS.include?(syllable[-1]) end |
#incompatible?(next_syllable) ⇒ Boolean
42 43 44 |
# File 'lib/random_name_generator/rng_syllable.rb', line 42 def incompatible?(next_syllable) (next_incompatible?(next_syllable) || previous_incompatible?(next_syllable)) end |
#next_syllable_must_start_with_consonant? ⇒ Boolean
82 83 84 |
# File 'lib/random_name_generator/rng_syllable.rb', line 82 def next_syllable_must_start_with_consonant? @next_syllable_requirement == :consonant end |
#next_syllable_must_start_with_vowel? ⇒ Boolean
78 79 80 |
# File 'lib/random_name_generator/rng_syllable.rb', line 78 def next_syllable_must_start_with_vowel? @next_syllable_requirement == :vowel end |
#next_syllable_universal? ⇒ Boolean
74 75 76 |
# File 'lib/random_name_generator/rng_syllable.rb', line 74 def next_syllable_universal? @next_syllable_requirement == :letter end |
#prefix? ⇒ Boolean
50 51 52 |
# File 'lib/random_name_generator/rng_syllable.rb', line 50 def prefix? @is_prefix end |
#previous_syllable_must_end_with_consonant? ⇒ Boolean
94 95 96 |
# File 'lib/random_name_generator/rng_syllable.rb', line 94 def previous_syllable_must_end_with_consonant? @previous_syllable_requirement == :consonant end |
#previous_syllable_must_end_with_vowel? ⇒ Boolean
90 91 92 |
# File 'lib/random_name_generator/rng_syllable.rb', line 90 def previous_syllable_must_end_with_vowel? @previous_syllable_requirement == :vowel end |
#previous_syllable_universal? ⇒ Boolean
86 87 88 |
# File 'lib/random_name_generator/rng_syllable.rb', line 86 def previous_syllable_universal? @previous_syllable_requirement == :letter end |
#suffix? ⇒ Boolean
54 55 56 |
# File 'lib/random_name_generator/rng_syllable.rb', line 54 def suffix? @is_suffix end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/random_name_generator/rng_syllable.rb', line 98 def to_s @syllable end |
#to_str ⇒ Object
102 103 104 |
# File 'lib/random_name_generator/rng_syllable.rb', line 102 def to_str @syllable end |
#vowel_first? ⇒ Boolean
62 63 64 |
# File 'lib/random_name_generator/rng_syllable.rb', line 62 def vowel_first? VOWELS.include?(syllable[0]) end |
#vowel_last? ⇒ Boolean
70 71 72 |
# File 'lib/random_name_generator/rng_syllable.rb', line 70 def vowel_last? VOWELS.include?(syllable[-1]) end |