Class: PDD::Source
- Inherits:
-
Object
- Object
- PDD::Source
- Defined in:
- lib/pdd/source.rb
Overview
Source.
Instance Method Summary collapse
-
#initialize(file, path) ⇒ Source
constructor
Ctor.
-
#puzzles ⇒ Object
Fetch all puzzles.
Constructor Details
#initialize(file, path) ⇒ Source
Ctor.
file-
Absolute file name with source code
path-
Path to show (without full file name)
32 33 34 35 |
# File 'lib/pdd/source.rb', line 32 def initialize(file, path) @file = file @path = path end |
Instance Method Details
#puzzles ⇒ Object
Fetch all puzzles.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pdd/source.rb', line 38 def puzzles re = /(.*(?:^|\s))@todo\s+#([\w\-\.:\/]+)\s+(.+)/ puzzles = [] lines = File.readlines(@file) lines.each_with_index do |line, idx| re.match(line) do |match| puzzles << puzzle(lines.drop(idx + 1), match, idx) end end puzzles end |