Created
May 25, 2022 13:26
-
-
Save vovs03/df3964b6bd9bf84e16579f7794d414c3 to your computer and use it in GitHub Desktop.
log_line_parser.rb for Exercism/string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogLineParser | |
@@lvl = '' | |
@@msg = '' | |
def initialize(line) | |
@line = line | |
#@msg = msg | |
#@lvl = lvl | |
end | |
def message | |
#raise 'Please implement the LogLineParser#message method' | |
#%q{...} | |
#'Disk almost full' || 'Stack overflow' #|| | |
#"#{[LEVEL]} : #{MESSAGE}" | |
#line.new('[ERROR]: Invalid operation') | |
#__LINE__ | |
#@line.split(":")[1].slice(0).gsub(" ", "") #+ @line.split(":")[1] | |
# .strip - delete all backspaces | |
@@msg = @line.split(":")[1].strip | |
end | |
def log_level | |
#raise 'Please implement the LogLineParser#log_level method' | |
# Ruby I.Simdyanov p.70-72 Strings | |
@@lvl = @line.split(":")[0].downcase[1..-2] #.(/^[a-z]/) | |
end | |
def reformat | |
#raise 'Please implement the LogLineParser#reformat method' | |
#message() + | |
ref = @line.split(":")[1].strip | |
ref_e = @line.split(":")[0].downcase[1..-2] | |
"#{ref} (#{ref_e})" | |
#"#{@@msg} (#{@@lvl})" | |
#@line = "#{@lvl}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment