Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Changed formatting only |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
2e3ea62bd5001cb0bd88fd8d5bf75f90 |
| User & Date: | i5ivem@gmail.com 2010-03-16 15:27:23 |
| Original User & Date: | i5ivem@gmail.com 2010-03-16 15:27:24 |
Context
|
2010-03-16
| ||
| 15:27 |
First release candidate of App
* API Key and Shared secret in external file | |
| 15:27 | Changed formatting only check-in: 2e3ea62bd5 user: i5ivem@gmail.com tags: trunk | |
| 15:27 | Progress bar and sleep interval added check-in: c532927408 user: i5ivem@gmail.com tags: trunk | |
Changes
Changes to cloud.rb.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# Taken from http://snippets.dzone.com/posts/show/6027
# Tweaked to return values suitable for Shoes (lines 38-40, etc)
class TagCloud
def initialize(words)
@wordcount = count_words(words)
end
def count_words(words)
wordcount = {}
words.split(/\s/).each do |word|
word.downcase!
if word.strip.size > 0
unless wordcount.key?(word.strip)
wordcount[word.strip] = 0
else
wordcount[word.strip] = wordcount[word.strip] + 1
end
end
end
wordcount
end
def font_ratio(wordcount={})
min, max = 1000000, -1000000
wordcount.each_key do |word|
max = wordcount[word] if wordcount[word] > max
min = wordcount[word] if wordcount[word] < min
end
18.0 / (max - min)
end
def build
cloud = String.new
ratio = font_ratio(@wordcount)
color = ["steelblue", "deeppink"]
@wordcount.each_key do |word|
font_size = (10 + (@wordcount[word] * ratio)).round #must round for shoes since pixels
cloud << %Q{para "#{word}", :size => #{font_size}, :stroke => #{color[0]}; }
color.reverse! #alternate between colours
end
cloud
end
end
| > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# Taken from http://snippets.dzone.com/posts/show/6027
# Tweaked to return values suitable for Shoes (lines 38-40, etc)
class TagCloud
def initialize(words)
@wordcount = count_words(words)
end
def count_words(words)
wordcount = {}
words.split(/\s/).each do |word|
word.downcase!
if word.strip.size > 0
unless wordcount.key?(word.strip)
wordcount[word.strip] = 0
else
wordcount[word.strip] = wordcount[word.strip] + 1
end
end
end
wordcount
end
def font_ratio(wordcount={})
min, max = 1000000, -1000000
wordcount.each_key do |word|
max = wordcount[word] if wordcount[word] > max
min = wordcount[word] if wordcount[word] < min
end
18.0 / (max - min)
end
def build
cloud = String.new
ratio = font_ratio(@wordcount)
color = ["steelblue", "deeppink"]
@wordcount.each_key do |word|
font_size = (10 + (@wordcount[word] * ratio)).round #must round for shoes since pixels
cloud << %Q{para "#{word}", :size => #{font_size}, :stroke => #{color[0]}; }
color.reverse! #alternate between colours
end
cloud
#debug cloud
end
end
|