The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
More self-references: Ruby speaking languages in ASCII demos

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
More self-references: Ruby speaking languages in ASCII demos Posted: Jan 3, 2006 5:57 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: More self-references: Ruby speaking languages in ASCII demos
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

I decided to imitate chris2's xmas animations and posted a rather large one to ruby-talk (to be fair, I actually used some filler to display the whole AA). If you run it, you'll notice it's also quine-like... The code looks like this: akemashite.png which stands for "happy new year" in Japanese. For the sake of symmetry, I also made the following happy.png The carrier, with base64-encoded text arranged to form some ASCII art, is based on Christian's original one, with a twist to:

  • remove all the prefix code
  • feed the encoded ehhmm code (i.e. the sources as found in the message, minus the trailing decoder) to the lambda resulting from evaluating that code

It basically works like

"LENGTH base 64 text
 here, whose spaces will be removed before unpacking;
 Essentially, something like:
 lambda do |myself|
   ... do something with my own sources ...
 end".
instance_eval do |x|
   y = x.gsub(/ \\n/, "")
   eval(y[5,y[0,5].to_i].unpack("m*")[0]).call(x)
end

Few people ever use that, but instance_eval passes self to the block; it is thanks to this that I can move all the code to the bottom, leaving a mere quotation mark as the prefix, so it barely disturbs the ASCII art.


Read more...

Read: More self-references: Ruby speaking languages in ASCII demos

Topic: Ruby 1.8.4 released! Previous Topic   Next Topic Topic: puts

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use