Class: Gimei
- Inherits:
-
Object
- Object
- Gimei
- Extended by:
- Forwardable
- Defined in:
- lib/gimei.rb,
lib/gimei/config.rb,
lib/gimei/version.rb,
lib/gimei/unique_generator.rb
Defined Under Namespace
Classes: Address, Config, Name, RetryLimitExceeded, UniqueGenerator
Constant Summary collapse
- GENDERS =
: [:male, :female]
[:male, :female].freeze
- VERSION =
"1.5.0"
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .address ⇒ Object
- .addresses ⇒ Object
- .config ⇒ Object
- .name(gender = nil) ⇒ Object
- .names ⇒ Object
- .unique(max_retries = 10_000) ⇒ Object
Instance Method Summary collapse
-
#initialize(gender = nil) ⇒ Gimei
constructor
A new instance of Gimei.
Constructor Details
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
22 23 24 |
# File 'lib/gimei.rb', line 22 def address @address end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/gimei.rb', line 22 def name @name end |
Class Method Details
.addresses ⇒ Object
38 39 40 |
# File 'lib/gimei.rb', line 38 def addresses @addresses ||= YAML.load_file(File.(File.join('..', 'data', 'addresses.yml'), __FILE__)) end |
.name(gender = nil) ⇒ Object
30 31 32 |
# File 'lib/gimei.rb', line 30 def name(gender = nil) Name.new(gender) end |
.names ⇒ Object
34 35 36 |
# File 'lib/gimei.rb', line 34 def names @names ||= YAML.load_file(File.(File.join('..', 'data', 'names.yml'), __FILE__)) end |
.unique(max_retries = 10_000) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/gimei.rb', line 54 def unique(max_retries = 10_000) return @unique if defined? @unique @unique = UniqueGenerator.new(self, max_retries) %i[name last first hiragana katakana romaji address prefecture city town].each do |method_name| @unique.define_unique_method(method_name) end @unique.define_unique_method(:family, :last) @unique.define_unique_method(:given, :first) %i[male female kanji].each do |method_name| @unique.define_unique_method(method_name, :name) end @unique end |