Class: Shodan::Page
- Inherits:
-
Array
- Object
- Array
- Shodan::Page
- Defined in:
- lib/shodan/page.rb
Instance Method Summary collapse
-
#dates ⇒ Array<Date>
The dates that the hosts were added.
-
#each_date {|date| ... } ⇒ self
Iterates over the dates that each host was added.
-
#each_hostname {|hostname| ... } ⇒ self
Iterates over the host names of every host in the page.
-
#each_http_headers {|headers| ... } ⇒ self
Itereates over the HTTP headers of each host in the page.
-
#each_ip {|ip| ... } ⇒ self
Iterates over the IP addresses of every host in the page.
-
#each_response {|response| ... } ⇒ self
Iterates over the responses of each host in the page.
-
#hostnames ⇒ Array<String>
The names of the hosts in the page.
-
#hosts_with_ip(ip) {|host| ... } ⇒ Array<Host>
Selects the hosts with the matching IP address.
-
#hosts_with_name(name) {|host| ... } ⇒ Array<Host>
Selects the hosts with the matching host name.
-
#http_headers ⇒ Array<Hash>
The HTTP headers from the hosts in the page.
-
#initialize(hosts = []) {|page| ... } ⇒ Page
constructor
Creates a new Page object.
-
#ips ⇒ Array<String>
The IP addresses of the hosts in the page.
-
#map {|host| ... } ⇒ Array
Maps the hosts within the page.
-
#responses(&block) ⇒ Array<String>
The responses of the hosts in the page.
-
#responses_with(pattern) {|host| ... } ⇒ Array<Host>
Selects the hosts with the matching response.
-
#select {|host| ... } ⇒ Page
(also: #hosts_with)
Selects the hosts within the page.
Constructor Details
#initialize(hosts = []) {|page| ... } ⇒ Page
Creates a new Page object.
38 39 40 41 42 |
# File 'lib/shodan/page.rb', line 38 def initialize(hosts=[],&block) super(hosts) block.call(self) if block end |
Instance Method Details
#dates ⇒ Array<Date>
The dates that the hosts were added.
223 224 225 |
# File 'lib/shodan/page.rb', line 223 def dates Enumerator.new(self,:each_date).to_a end |
#each_date {|date| ... } ⇒ self
Iterates over the dates that each host was added.
211 212 213 214 215 |
# File 'lib/shodan/page.rb', line 211 def each_date(&block) each do |host| block.call(host.date) if block end end |
#each_hostname {|hostname| ... } ⇒ self
Iterates over the host names of every host in the page.
158 159 160 161 162 |
# File 'lib/shodan/page.rb', line 158 def each_hostname(&block) each do |host| block.call(host.hostname) if (block && host.hostname) end end |
#each_http_headers {|headers| ... } ⇒ self
Itereates over the HTTP headers of each host in the page.
291 292 293 294 295 |
# File 'lib/shodan/page.rb', line 291 def each_http_headers(&block) each do |host| block.call(host.http_headers) if block end end |
#each_ip {|ip| ... } ⇒ self
Iterates over the IP addresses of every host in the page.
106 107 108 109 110 |
# File 'lib/shodan/page.rb', line 106 def each_ip(&block) each do |host| block.call(host.ip) if block end end |
#each_response {|response| ... } ⇒ self
Iterates over the responses of each host in the page.
238 239 240 241 242 |
# File 'lib/shodan/page.rb', line 238 def each_response(&block) each do |host| block.call(host.response) if block end end |
#hostnames ⇒ Array<String>
The names of the hosts in the page.
195 196 197 |
# File 'lib/shodan/page.rb', line 195 def hostnames Enumerator.new(self,:each_hostname).to_a end |
#hosts_with_ip(ip) {|host| ... } ⇒ Array<Host>
Selects the hosts with the matching IP address.
127 128 129 130 131 132 133 134 135 |
# File 'lib/shodan/page.rb', line 127 def hosts_with_ip(ip,&block) hosts_with do |host| if host.ip.match(ip) block.call(host) if block true end end end |
#hosts_with_name(name) {|host| ... } ⇒ Array<Host>
Selects the hosts with the matching host name.
179 180 181 182 183 184 185 186 187 |
# File 'lib/shodan/page.rb', line 179 def hosts_with_name(name,&block) hosts_with do |host| if (host.hostname && host.hostname.match(name)) block.call(host) if block true end end end |
#http_headers ⇒ Array<Hash>
The HTTP headers from the hosts in the page.
303 304 305 |
# File 'lib/shodan/page.rb', line 303 def http_headers Enumerator.new(self,:each_http_headers).to_a end |
#ips ⇒ Array<String>
The IP addresses of the hosts in the page.
143 144 145 |
# File 'lib/shodan/page.rb', line 143 def ips Enumerator.new(self,:each_ip).to_a end |
#map {|host| ... } ⇒ Array
Maps the hosts within the page.
64 65 66 67 68 69 70 71 |
# File 'lib/shodan/page.rb', line 64 def map(&block) return self unless block mapped = [] each { |element| mapped << block.call(element) } return mapped end |
#responses(&block) ⇒ Array<String>
The responses of the hosts in the page.
275 276 277 |
# File 'lib/shodan/page.rb', line 275 def responses(&block) Enumerator.new(self,:each_response).to_a end |
#responses_with(pattern) {|host| ... } ⇒ Array<Host>
Selects the hosts with the matching response.
259 260 261 262 263 264 265 266 267 |
# File 'lib/shodan/page.rb', line 259 def responses_with(pattern,&block) hosts_with do |host| if host.response.match(pattern) block.call(host) if block true end end end |
#select {|host| ... } ⇒ Page Also known as: hosts_with
Selects the hosts within the page.
88 89 90 |
# File 'lib/shodan/page.rb', line 88 def select(&block) self.class.new(super(&block)) end |