Sha256: a01068a8753585adf9a2c2c192f3fc00b52490891715b8c57f76e6606e2b126f
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
module BibleReferenceParser # This module encapsulates shared behavior for classes that keep track of parsing errors. # For example, a BookReference may encounter a parsing error due to a book that doesn't # exist. A ChapterReference may have a parsing error because the chapter number isn't valid # for the book it is referencing. module TracksErrors def initialize(*args, &block) super # A collection of error messages. @errors = [] end # Add an error message. def add_error(message) @errors << message end # Erase all error messages. def clear_errors @errors = [] end # Get the list of error messages. This will include any errors in child references # if include_child_errors is true (by default it's true). def errors(include_child_errors = true) if(include_child_errors && respond_to?("children") && children) return @errors + children.errors(true) end @errors end # Whether any errors occured when parsing. def has_errors? !errors.empty? end # Convienence method for the reverse of "has_errors?" def no_errors? errors.empty? end end end
Version data entries
4 entries across 4 versions & 1 rubygems