Module: YaLoremJa::WordResources

Defined in:
lib/ya_lorem_ja/word_resource.rb

Overview

manage word resources

Class Method Summary collapse

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

Parameters:

  • name (Symbol)

    name of word resource

  • char_count_range (Range)

    range of character count in a word

  • word_count_range (Range)

    range of word count in sentence

  • sentence_count_range (Range)

    renage of sentence count in paragraph

Returns:



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

Parameters:

  • name (Symbol)

    name of word resource

  • namespace (Class)

    class of 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

.resourceObject

retrun repository of word resource



16
17
18
# File 'lib/ya_lorem_ja/word_resource.rb', line 16

def resource
  @resource ||= { }
end