Class: Tlux::Config::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/tlux/config/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Parser

Returns a new instance of Parser.



15
16
17
18
# File 'lib/tlux/config/parser.rb', line 15

def initialize(config)
  @config = config
  @session = Tlux::Session.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/tlux/config/parser.rb', line 13

def config
  @config
end

#sessionObject (readonly)

Returns the value of attribute session.



13
14
15
# File 'lib/tlux/config/parser.rb', line 13

def session
  @session
end

Class Method Details

.from_file(path) ⇒ Object



6
7
8
9
10
11
# File 'lib/tlux/config/parser.rb', line 6

def self.from_file(path)
  raise Tlux::Config::FileNotFound.new(path) unless File.exists?(path) && File.file?(path)
  File.open(path, 'r') do |config|
    self.new(config.read)
  end
end

Instance Method Details

#parse!Object



20
21
22
# File 'lib/tlux/config/parser.rb', line 20

def parse!
  session.instance_eval(config)
end