Class: Lutra::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/lutra/scanner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Scanner

Returns a new instance of Scanner.



6
7
8
9
10
# File 'lib/lutra/scanner.rb', line 6

def initialize(options = {})
  @tags = options[:tags] || TAGS.dup
  @comments = options[:comments] || COMM.dup
  @notes = []
end

Instance Attribute Details

#commentsObject

Returns the value of attribute comments.



3
4
5
# File 'lib/lutra/scanner.rb', line 3

def comments
  @comments
end

#notesObject (readonly)

Returns the value of attribute notes.



4
5
6
# File 'lib/lutra/scanner.rb', line 4

def notes
  @notes
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/lutra/scanner.rb', line 3

def tags
  @tags
end

Instance Method Details

#scan(source) ⇒ Object



12
13
14
15
# File 'lib/lutra/scanner.rb', line 12

def scan(source)
  check_tags and check_comments
  extract(source.split("\n")) and self
end

#scan_file(path) ⇒ Object



17
18
19
20
# File 'lib/lutra/scanner.rb', line 17

def scan_file(path)
  check_tags and check_comments
  extract(File.open(path), path) and self
end