Class: Thiru
- Inherits:
-
Object
- Object
- Thiru
- Defined in:
- lib/thiru.rb
Class Method Summary collapse
- .fib_number(arg) ⇒ Object
- .horizontal_line(arg, char) ⇒ Object
- .i_am(arg) ⇒ Object
- .left_triangle(arg, char) ⇒ Object
- .right_triangle(arg, char) ⇒ Object
- .triangle(arg, char) ⇒ Object
- .vertical_line(arg, char) ⇒ Object
Class Method Details
.fib_number(arg) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/thiru.rb', line 42 def self.fib_number(arg) a, b, c = 0, 1, [] for i in (1..arg) c.push(a + b) a, b = b, c.last end puts "#{c}" end |
.horizontal_line(arg, char) ⇒ Object
11 12 13 |
# File 'lib/thiru.rb', line 11 def self.horizontal_line(arg, char) arg.times{ print "#{char}" } end |
.i_am(arg) ⇒ Object
3 4 5 |
# File 'lib/thiru.rb', line 3 def self.i_am(arg) "Hello #{arg}!" end |
.left_triangle(arg, char) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/thiru.rb', line 22 def self.left_triangle(arg, char) space = arg (0..arg).each do |i| space.times{ print " " } i.times{ print "#{char}" } puts "\n" space = space - 1 end end |
.right_triangle(arg, char) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/thiru.rb', line 15 def self.right_triangle(arg, char) (0..arg).each do |i| i.times{ print "#{char}" } puts "\n" end end |
.triangle(arg, char) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/thiru.rb', line 32 def self.triangle(arg, char) space = arg (0..arg).each do |i| space.times{ print " " } i.times{ print "#{char} " } puts "\n" space = space - 1 end end |
.vertical_line(arg, char) ⇒ Object
7 8 9 |
# File 'lib/thiru.rb', line 7 def self.vertical_line(arg, char) arg.times{ puts "#{char}" } end |