Class: DHCP

Inherits:
ShellCommands show all
Defined in:
app/models/dhcp.rb,
app/models/router.rb

Constant Summary

Constants included from ShellCommands::Examples

ShellCommands::Examples::COMMAND_STRING, ShellCommands::Examples::Cd_command_array, ShellCommands::Examples::Cd_command_hash, ShellCommands::Examples::EXAMPLE, ShellCommands::Examples::Example_output, ShellCommands::Examples::Guaranteed_existing_basename, ShellCommands::Examples::Guaranteed_existing_directory, ShellCommands::Examples::Hello_world, ShellCommands::Examples::Redirect_command, ShellCommands::Examples::Redirect_command_string, ShellCommands::Examples::Relative_command

Instance Attribute Summary

Attributes inherited from ShellCommands

#command_string, #errors, #output, #process_status

Instance Method Summary collapse

Methods inherited from ShellCommands

#close, #execute, #fork, #inspect, #parse_argument_array, #puts, #server, #start, #success?, #trace, #wait

Methods included from ShellCommands::ClassMethods

#assemble_array_command, #assemble_command_string, #assemble_hash_command

Methods included from ShellCommands::Assertions

#assert_post_conditions, #assert_pre_conditions

Constructor Details

#initializeDHCP

Returns a new instance of DHCP.


4
5
6
# File 'app/models/dhcp.rb', line 4

def initialize
	super('/sbin/dhclient -v eth0')
end

Instance Method Details

#offerObject

parse


15
16
17
# File 'app/models/dhcp.rb', line 15

def offer
	parse(/Bound to ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, @errors)
end

#parse(regexp, acquisition = @output) ⇒ Object

initialize


7
8
9
10
11
12
13
14
# File 'app/models/dhcp.rb', line 7

def parse(regexp, acquisition=@output)
	matchData=regexp.match(acquisition)
	if matchData.nil? then
		nil
	else
		matchData[0]
	end #if
end

#routerObject

offer


18
19
20
# File 'app/models/dhcp.rb', line 18

def router
	parse(/DHCPACK from ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, @errors)
end