Class: Watcher::Hostname

Inherits:
BasicWatcher show all
Defined in:
lib/informer/watcher/hostname.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interface = "eth0", &block) ⇒ Hostname

Returns a new instance of Hostname.



6
7
8
9
# File 'lib/informer/watcher/hostname.rb', line 6

def initialize(interface = "eth0", &block)
  @custom_message = block if block_given?
  @interface = interface
end

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



4
5
6
# File 'lib/informer/watcher/hostname.rb', line 4

def hostname
  @hostname
end

#ipObject (readonly)

Returns the value of attribute ip.



4
5
6
# File 'lib/informer/watcher/hostname.rb', line 4

def ip
  @ip
end

Instance Method Details

#messageObject



16
17
18
# File 'lib/informer/watcher/hostname.rb', line 16

def message
  @message ||= "#{hostname}\n#{ip}"
end

#reportObject



11
12
13
14
# File 'lib/informer/watcher/hostname.rb', line 11

def report
  return @custom_message.call(self) if @custom_message
  message
end