Class: Decode::Source

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, language) ⇒ Source

Returns a new instance of Source.



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

def initialize(path, language)
	@path = path
	@language = language
end

Instance Attribute Details

#languageObject (readonly)

Returns the value of attribute language.



32
33
34
# File 'lib/decode/source.rb', line 32

def language
  @language
end

#pathObject (readonly)

Returns the value of attribute path.



30
31
32
# File 'lib/decode/source.rb', line 30

def path
  @path
end

Instance Method Details

#definitions(&block) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/decode/source.rb', line 38

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

#open(&block) ⇒ Object



34
35
36
# File 'lib/decode/source.rb', line 34

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

#segments(&block) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/decode/source.rb', line 46

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