Class: Riptables::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/riptables/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
# File 'lib/riptables/base.rb', line 10

def initialize(&block)
  @tables = []
  @host_groups = {}
  dsl.instance_eval(&block) if block_given?
end

Instance Attribute Details

#host_groupsObject (readonly)

Returns the value of attribute host_groups.



8
9
10
# File 'lib/riptables/base.rb', line 8

def host_groups
  @host_groups
end

#tablesObject (readonly)

Returns the value of attribute tables.



7
8
9
# File 'lib/riptables/base.rb', line 7

def tables
  @tables
end

Class Method Details

.load_from_file(file) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/riptables/base.rb', line 20

def self.load_from_file(file)
  base = Base.new
  if File.file?(file)
    base.load_from_file(file)
    base
  else
    raise Error, "File not found at `#{file}`"
  end
end

Instance Method Details

#dslObject



16
17
18
# File 'lib/riptables/base.rb', line 16

def dsl
  @dsl ||= DSL::Base.new(self)
end

#load_from_file(file) ⇒ Object



30
31
32
# File 'lib/riptables/base.rb', line 30

def load_from_file(file)
  self.dsl.instance_eval(File.read(file), file)
end