class Object
Constants
- DEFAULT_NEWLINES
!/usr/bin/env -S ruby -W0
vim: ft=ruby:syntax=ruby
- KEYWORDS_REGEX
Public Instance Methods
comment?(line)
click to toggle source
true if line is a comment
# File lib/ruval.rb, line 40 def comment?(line) line.strip[0] == '#' end
help()
click to toggle source
# File lib/ruval.rb, line 20 def help puts <<~e Usage: #{prog} <file> [option] Print the value of statements in a file Options: -h, --help print this message -n N line spacing between evaluations (non-negative value, default 1) e exit end
prog()
click to toggle source
# File lib/ruval.rb, line 16 def prog File.basename $0 end
update_scope(line, line_stack, scope)
click to toggle source
# File lib/ruval.rb, line 72 def update_scope(line, line_stack, scope) keywords = line.scan(KEYWORDS_REGEX) return if keywords.empty? && scope.empty? line_stack << line keywords.each do |kw| unless %w"end } ] )".include?(kw) scope.push kw else scope.pop end end end