Module: Codeball::Border
- Defined in:
- lib/codeball/border.rb
Overview
Domain knowledge about the visual delimiter between sections in a codeball.
Borders are repeated punctuation patterns that separate entries in serialized codeball text. The pattern is fixed, not configurable.
During serialization, SEPARATOR is used as-is. During parsing, recognition is heuristic to tolerate mangling by browsers, editors, and clipboard transfer.
Constant Summary collapse
- PATTERN =
"---\t"- WIDTH =
10- SEPARATOR =
(PATTERN * WIDTH).freeze
- SUFFIX =
/[-#=~*_|+][-#=~*_|+\s]{8,}\s*\z/- MIN_LENGTH =
6- MIN_PUNCTUATION_LENGTH =
9
Class Method Summary collapse
Class Method Details
.recognize?(line) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/codeball/border.rb', line 21 def recognize?(line) return false if line.empty? return false if line.start_with?("BEGIN ", "END ") stripped = line.gsub(/\s+/, "") return false if stripped.empty? return false if stripped.length < MIN_LENGTH single_char?(stripped) || punctuation_run?(stripped) end |