Skip to content

Commit

Permalink
Lolcat ,Third book of nyan'
Browse files Browse the repository at this point in the history
* No more cursor eating (patch by Yu-Jie Lin)
* Rainbow frequency now customizable.
* Much awesomer defaults.
* Now silently swallows EPIPE (like 'cat' does).
  • Loading branch information
m-o-e committed Aug 11, 2011
1 parent 4ebe695 commit 1125f07
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/lolcat/cat.rb
Expand Up @@ -49,6 +49,7 @@ def self.halp!(text, opts={})

def self.cat!
p = Trollop::Parser.new do
version "lolcat #{Lolcat::VERSION} (c)2011 moe@busyloop.net"
banner <<HEADER
Usage: lolcat [OPTION]... [FILE]...
Expand All @@ -58,7 +59,8 @@ def self.cat!
HEADER
banner ''
opt :spread, "Rainbow spread", :short => 'p', :default => 8.0
opt :spread, "Rainbow spread", :short => 'p', :default => 3.0
opt :freq, "Rainbow frequency", :short => 'F', :default => 0.1
opt :seed, "Rainbow seed, 0 = random", :short => 'S', :default => 0
opt :animate, "Enable psychedelics", :short => 'a', :default => false
opt :duration, "Animation duration", :short => 'd', :default => 12
Expand All @@ -76,7 +78,6 @@ def self.cat!
Report lolcat bugs to <http://www.github.org/busyloop/lolcat/issues>
lolcat home page: <http://www.github.org/busyloop/lolcat/>
Report lolcat translation bugs to <http://speaklolcat.com/>
For complete documentation, read the source!
FOOTER
end
Expand All @@ -98,7 +99,6 @@ def self.cat!
p.die :duration, "must be > 0" if opts[:duration] < 0.1
p.die :speed, "must be > 0.1" if opts[:duration] < 0.1

opts = { :freq => 0.3 }.merge(opts)
opts[:os] = opts[:seed]
opts[:os] = rand(256) if opts[:os] == 0

Expand All @@ -125,6 +125,8 @@ def self.cat!
rescue Errno::EISDIR
puts "lolcat: #{file}: Is a directory"
exit 1
rescue Errno::EPIPE
exit 1
end
end
rescue Interrupt
Expand Down
2 changes: 1 addition & 1 deletion lib/lolcat/lol.rb
Expand Up @@ -60,7 +60,7 @@ def self.println_ani(str, opts={})
return if str.empty?
(1..opts[:duration]).each do |i|
print "\e[#{str.length}D"
opts[:os] += opts[:spread]/Math::PI
opts[:os] += opts[:spread]
println_plain(str, opts)
sleep 1.0/opts[:speed]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lolcat/version.rb
@@ -1,3 +1,3 @@
module Lolcat
VERSION = "42.0.43"
VERSION = "42.0.84"
end

0 comments on commit 1125f07

Please sign in to comment.