class Rules
Public Class Methods
new(application)
click to toggle source
# File lib/ruby-zen/rules.rb, line 6 def initialize(application) @app = application end
Public Instance Methods
show(options = { 'more' => false, 'step' => true })
click to toggle source
# File lib/ruby-zen/rules.rb, line 10 def show(options = { 'more' => false, 'step' => true }) if options['more'] step = options['step'] show_more(step: step) else show_only_names end end
Private Instance Methods
show_more(step:)
click to toggle source
# File lib/ruby-zen/rules.rb, line 29 def show_more(step:) show_title @app.rules.each_with_index do |rule, index| principle = rule[:rule] puts "[#{(index + 1)}] #{principle}" desc = rule[:desc] if desc.is_a? String puts "#{desc}\n".white else desc.each_with_index do |line, index| text = "#{index}. #{line}".white text = "#{line}\n".white if index.zero? puts text end end puts if step print '[Press ENTER to continue]' STDIN.gets puts end end end
show_only_names()
click to toggle source
# File lib/ruby-zen/rules.rb, line 54 def show_only_names show_title @app.rules.each_with_index do |rule, index| principle = rule[:rule] puts "[#{(index + 1)}] #{principle}" end end
show_title()
click to toggle source
# File lib/ruby-zen/rules.rb, line 21 def show_title dirbase = File.dirname(__FILE__) filepath = File.join(dirbase, 'files', 'title.txt') content = File.read(filepath) puts content puts end