Module: EricTools
- Defined in:
- lib/eric_tools.rb,
lib/eric_tools/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.generate_random_string(length, type = 1) ⇒ Object
type=1表示只包含数字,type=2表示只包含字母,type=3表示都包含.
- .uuid ⇒ Object
Class Method Details
.generate_random_string(length, type = 1) ⇒ Object
type=1表示只包含数字,type=2表示只包含字母,type=3表示都包含
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eric_tools.rb', line 12 def self.generate_random_string length, type=1 case type when 1 rand(10 ** length).to_s(10) when 2 rand(26 ** length).to_s(26) when 3 rand(36 ** length).to_s(36) end end |
.uuid ⇒ Object
7 8 9 |
# File 'lib/eric_tools.rb', line 7 def self.uuid UUIDTools::UUID..to_s end |