Module: YaLoremJa::WordResources
- Defined in:
- lib/ya_lorem_ja/word_resource.rb
Overview
manage word resources
Class Method Summary collapse
- .default_resource_name=(resource_name) ⇒ Object
-
.load(name, char_count_range, word_count_range, sentence_count_range) ⇒ WordResource
create a instance of word resource.
-
.register(name, namespace) ⇒ Object
register word resource.
-
.resource ⇒ Object
retrun repository of word resource.
Class Method Details
.default_resource_name=(resource_name) ⇒ Object
10 11 12 |
# File 'lib/ya_lorem_ja/word_resource.rb', line 10 def default_resource_name=(resource_name) @default_resource_name = resource_name end |
.load(name, char_count_range, word_count_range, sentence_count_range) ⇒ WordResource
create a instance of word resource
38 39 40 41 42 43 44 |
# File 'lib/ya_lorem_ja/word_resource.rb', line 38 def load(name, char_count_range, word_count_range, sentence_count_range) kls = resource[name.to_sym] unless kls return nil end return kls.new(char_count_range, word_count_range, sentence_count_range) end |
.register(name, namespace) ⇒ Object
register word resource
24 25 26 27 28 29 |
# File 'lib/ya_lorem_ja/word_resource.rb', line 24 def register(name, namespace) if resource.key?(name) return end resource[name.to_sym] = namespace end |
.resource ⇒ Object
retrun repository of word resource
16 17 18 |
# File 'lib/ya_lorem_ja/word_resource.rb', line 16 def resource @resource ||= { } end |