Guest User

Untitled

a guest
May 25th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class Parsething
  2. attr_reader :people
  3. def initialize(doc)
  4. @doc = doc
  5. end
  6.  
  7. def parse
  8. @people = @doc[/ABSENT:\n+(.*)-{10}/m, 1].split(/\n+/)
  9. end
  10. end
  11.  
  12. if $0 == __FILE__
  13. require "test/unit"
  14.  
  15. class ParsethingTest < Test::Unit::TestCase
  16. def test_it
  17. @doc = "foo\n\nbar\n\nbaz\nABSENT:\n\nSomeone\nOther person\n\n\n\nSomeone else\n----------\n\nFoo"
  18. @parsething = Parsething.new(@doc)
  19. @parsething.parse
  20.  
  21. assert_equal ["Someone", "Other person", "Someone else"], @parsething.people
  22. end
  23. end
  24. end
Add Comment
Please, Sign In to add comment