Class: Ronin::OS
- Inherits:
-
Object
- Object
- Ronin::OS
- Includes:
- Model, Model::HasName
- Defined in:
- lib/ronin/os.rb
Overview
Represents an Operating System and pre-defines other common ones (linux, freebsd, openbsd, netbsd, osx, solaris, windows and unix).
Class Method Summary collapse
-
.predefine(name, attributes) ⇒ nil
private
Defines a new predefined OS.
Instance Method Summary collapse
-
#recent_ip_address ⇒ IPAddress
The IP Address that was most recently guessed to be using the Operating System.
-
#to_ary ⇒ Array<String>
Splits the Operating System into multiple variables.
-
#to_s ⇒ String
Converts the Operating System to a String.
Methods included from Model::HasName
Methods included from Model
Class Method Details
.predefine(name, attributes) ⇒ nil
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defines a new predefined OS.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/ronin/os.rb', line 134 def OS.predefine(name,attributes) unless attributes[:name] raise(ArgumentError,"must specify the :name attribute") end super(name,attributes) # if no version was predefined, allow the predefined helper-methods # to accept a version argument unless attributes[:version] os_name = attributes[:name] (name) do |*arguments| attributes = predefined_attributes[name] version = if arguments.first arguments.first.to_s end OS.first_or_create(attributes.merge(:version => version)) end end return nil end |
Instance Method Details
#recent_ip_address ⇒ IPAddress
The IP Address that was most recently guessed to be using the Operating System.
67 68 69 70 71 72 73 |
# File 'lib/ronin/os.rb', line 67 def recent_ip_address relation = self.os_guesses.first(:order => [:created_at.desc]) if relation return relation.ip_address end end |
#to_ary ⇒ Array<String>
Splits the Operating System into multiple variables.
114 115 116 |
# File 'lib/ronin/os.rb', line 114 def to_ary [self.name, self.version] end |
#to_s ⇒ String
Converts the Operating System to a String.
87 88 89 90 91 92 93 |
# File 'lib/ronin/os.rb', line 87 def to_s if self.version "#{self.name} #{self.version}" else super end end |