frosty_meadow 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/frosty_meadow.rb +32 -30
  2. metadata +1 -1
data/lib/frosty_meadow.rb CHANGED
@@ -3,7 +3,7 @@ require 'json'
3
3
  module FrostyMeadow
4
4
  module Version
5
5
  MAJOR = 1
6
- MINOR = 1
6
+ MINOR = 2
7
7
  PATCH = 0
8
8
 
9
9
  FULL = [MAJOR, MINOR, PATCH].join('.')
@@ -15,45 +15,47 @@ module FrostyMeadow
15
15
  end
16
16
  end
17
17
 
18
- def self.generate params = {}
19
- words = get_words params
18
+ class << self
19
+ def generate params = {}
20
+ words = get_words params
20
21
 
21
- adjectives = words['adjectives']
22
- nouns = words['nouns']
22
+ adjectives = words['adjectives']
23
+ nouns = words['nouns']
23
24
 
24
- result = "#{adjectives[rand(adjectives.length)]} #{nouns[rand(nouns.length)]}"
25
-
26
- return (params[:separator] && self.seperate(result, params[:separator])) || result
27
- end
25
+ result = "#{adjectives[rand(adjectives.length)]} #{nouns[rand(nouns.length)]}"
26
+
27
+ return (params[:separator] && self.seperate(result, params[:separator])) || result
28
+ end
28
29
 
29
- def self.seperate result, separator
30
- result.gsub(/ +/, separator)
31
- end
30
+ def seperate result, separator
31
+ result.gsub(/ +/, separator)
32
+ end
32
33
 
33
- def self.get_words params = {}
34
- file_path = File.join(File.dirname(__FILE__), 'data/words.json')
35
- file = File.new file_path, "r"
34
+ def get_words params = {}
35
+ file_path = File.join(File.dirname(__FILE__), 'data/words.json')
36
+ file = File.new file_path, "r"
36
37
 
37
- file_contents = ""
38
- while line = file.gets
39
- file_contents << line
40
- end
38
+ file_contents = ""
39
+ while line = file.gets
40
+ file_contents << line
41
+ end
41
42
 
42
- words = JSON.parse(file_contents)
43
+ words = JSON.parse(file_contents)
43
44
 
44
- words['adjectives'] = params[:adjectives] unless params[:adjectives].nil?
45
- words['nouns'] = params[:nouns] unless params[:nouns].nil?
45
+ words['adjectives'] = params[:adjectives] unless params[:adjectives].nil?
46
+ words['nouns'] = params[:nouns] unless params[:nouns].nil?
46
47
 
47
- return words
48
- end
48
+ return words
49
+ end
49
50
 
50
- def self.generate_hex_name
51
- generated_string = self.generate(:separator => '-')
51
+ def generate_hex_name
52
+ generated_string = self.generate(:separator => '-')
52
53
 
53
- return "#{generated_string}-#{self.hex_string}"
54
- end
54
+ return "#{generated_string}-#{self.hex_string}"
55
+ end
55
56
 
56
- def self.hex_string length=5
57
- ((0..length).map{rand(256).chr}*"").unpack("H*")[0][0,length]
57
+ def hex_string length=5
58
+ ((0..length).map{rand(256).chr}*"").unpack("H*")[0][0,length]
59
+ end
58
60
  end
59
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frosty_meadow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: