class AsciiParadise::SierpinksiTriangle
Constants
- N_TIMES
#¶ ↑
N_TIMES
¶ ↑#¶ ↑
Public Class Methods
Public Instance Methods
handle_input(i)
click to toggle source
#¶ ↑
handle_input
¶ ↑
This method will handle input given to this class.
#¶ ↑
# File lib/ascii_paradise/static_ascii/sierpinksi_triangle.rb, line 42 def handle_input(i) if i if i.is_a?(Array) and !i.empty? @n_times = i.first elsif i.is_a?(Array) and i.empty? # Array is empty, thus use the default. @n_times = N_TIMES elsif i.is_a? Hash if i.has_key? :size @n_times = i.delete :size end else @n_times = i end @n_times = @n_times.to_i end end
reset()
click to toggle source
run()
click to toggle source
#¶ ↑
run¶ ↑
#¶ ↑
# File lib/ascii_paradise/static_ascii/sierpinksi_triangle.rb, line 69 def run @n_times.times { |counter| joined_substring = (0 .. counter).map {|entry| # =================================================================== # # Either add a ' .' token or a ' A' token. # =================================================================== # ~counter & entry > 0 ? ' .' : ' A' }.join print ' ' * (@n_times-1-counter), joined_substring e } end