Skip to content

Instantly share code, notes, and snippets.

@daniellockard
Forked from anonymous/gist:5011016
Last active December 14, 2015 02:08
Show Gist options
  • Save daniellockard/5011108 to your computer and use it in GitHub Desktop.
Save daniellockard/5011108 to your computer and use it in GitHub Desktop.
require './lib/harddisk'
module ReImagEngine
class DiskImager
attr_reader :harddisks
attr_accessor :server_address,
:server_shared_type,
:server_share_name
# config shit here or even extract a config class
def initialize
# Initialize Configuration
# Initialize System Harddisks
# expect { expression }.to raise_error(ArgumentError)
`parted -lm`.split("\n").grep(/sd[a-z]/).map { |d| d.split(":").first }.each do |hdd|
harddisks.push HardDisk.new(hdd)
end
end
def harddisks
@harddisks || Array.new
end
private
def load_configuration
config = YAML.load_file('./config.yaml')
config["server"].each{|attr|
create_attr(attr)
}
end
def create_method(name,&block)
self.class.send(:define_method, name, &block)
end
def create_attr(name)
create_method("#{name}=".to_sym) { |val|
instance_variable_set("@"+name, val)
}
create_method( name.to_sym ) {
instance_variable_get("@" + name)
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment