Class: Decode::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/decode/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, language = nil) ⇒ Source

Returns a new instance of Source.



25
26
27
28
# File 'lib/decode/source.rb', line 25

def initialize(path, language = nil)
	@path = path
	@language = language || Language.detect(path).new
end

Instance Method Details

#open(&block) ⇒ Object



38
39
40
# File 'lib/decode/source.rb', line 38

def open(&block)
	File.open(@path, &block)
end

#parse(&block) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/decode/source.rb', line 30

def parse(&block)
	return to_enum(:parse) unless block_given?
	
	self.open do |file|
		@language.parse(file, &block)
	end
end