Debian Codegraph @

demo/kitchen-sink/docs/ruby.rb

raw
1 #!/usr/bin/ruby
2
3 # Program to find the factorial of a number
4 def fact(n)
5 if n == 0
6 1
7 else
8 n * fact(n-1)
9 end
10 end
11
12 puts fact(ARGV[0].to_i)
13
14 class Range
15 def to_json(*a)
16 {
17 'json_class' => self.class.name, # = 'Range'
18 'data' => [ first, last, exclude_end? ]
19 }.to_json(*a)
20 end
21 end
22
23 {:id => ?", :key => "value"}
24
25
26 herDocs = [<<'FOO', <<BAR, <<-BAZ, <<-`EXEC`] #comment
27 FOO #{literal}
28 FOO
29 BAR #{fact(10)}
30 BAR
31 BAZ indented
32 BAZ
33 echo hi
34 EXEC
35 puts herDocs