colos 0.0.1

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 (3) hide show
  1. data/lib/colos/version.rb +3 -0
  2. data/lib/colos.rb +27 -0
  3. metadata +47 -0
@@ -0,0 +1,3 @@
1
+ class Colos
2
+ VERSION = "0.0.1"
3
+ end
data/lib/colos.rb ADDED
@@ -0,0 +1,27 @@
1
+ require "cityhash"
2
+
3
+ class Colos
4
+
5
+ # Colos.color "example"
6
+ # => 123123
7
+ # Alias for Colos.new
8
+ def self.color str
9
+ hash = CityHash.hash32 str
10
+ frequency = 1.4
11
+ (hash ** (1.0/frequency)).to_i.to_s 16
12
+ end
13
+
14
+ # Colos.colors "example"
15
+ # => [123123, 234234]
16
+ def self.colors str
17
+ hash = CityHash.hash32 str
18
+ colors = []
19
+ for i in (12..16) do
20
+ frequency = i / 10.0
21
+ q = (hash ** (1.0/frequency)).to_i
22
+ colors << q.to_s(16) if q.to_s(16).size == 6
23
+ end
24
+ colors
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yuri Artemev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-15 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: convert ruby string to color
15
+ email:
16
+ - i@artemeff.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/colos.rb
22
+ - lib/colos/version.rb
23
+ homepage: http://github.com/artemeff/colos
24
+ licenses: []
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ none: false
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ none: false
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 1.8.24
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: string to color
47
+ test_files: []