M
M
mortify2016-04-27 10:07:42
ruby
mortify, 2016-04-27 10:07:42

Where did the zeros come from?

there is this code:

require 'nokogiri'
require 'open-uri'

url = "http://ruby-doc.org/core-2.3.1/"

data = Nokogiri::HTML(open(url))
class_url = []
doc = data.css('#class-index .entries p a').each do |d|
  class_url <<  "#{url}#{d.attribute("href")}"
end

class_url.each do |u|
  data = Nokogiri::HTML(open(u))
  #puts data.at_css("h1.class, h1.module").text
  methods = data.css("#method-list-section ul li a")
  puts methods.each {|n| puts "    #{n.text}"}
end

do zeros appear in the output as separators between pages, and zeros without indents? those. not from the methods loop. Where did they come from and what gives them away?
spoiler
::[]
    ::new
    ::try_convert
    #&
    #*
    #+
    #-
    #
    #
    #==
    #[]
    #[]=
    #any?
    #assoc
    #at
    #bsearch
    #bsearch_index
    #clear
    #collect
    #collect!
    #combination
    #compact
    #compact!
    #concat
    #count
    #cycle
    #delete
    #delete_at
    #delete_if
    #dig
    #drop
    #drop_while
    #each
    #each_index
    #empty?
    #eql?
    #fetch
    #fill
    #find_index
    #first
    #flatten
    #flatten!
    #frozen?
    #hash
    #include?
    #index
    #initialize_copy
    #insert
    #inspect
    #join
    #keep_if
    #last
    #length
    #map
    #map!
    #pack
    #permutation
    #pop
    #product
    #push
    #rassoc
    #reject
    #reject!
    #repeated_combination
    #repeated_permutation
    #replace
    #reverse
    #reverse!
    #reverse_each
    #rindex
    #rotate
    #rotate!
    #sample
    #select
    #select!
    #shift
    #shuffle
    #shuffle!
    #size
    #slice
    #slice!
    #sort
    #sort!
    #sort_by!
    #take
    #take_while
    #to_a
    #to_ary
    #to_h
    #to_s
    #transpose
    #uniq
    #uniq!
    #unshift
    #values_at
    #zip
    #|
0
    #%
    #&
    #*
    #**
    #+
    #-
    #[email protected]
    #/
    #
    #
    #
    #
    #==
    #===
    #>
    #>=
    #>>
    #[]
    #^
    #abs
    #bit_length
    #coerce
    #div
    #divmod
    #eql?
    #even?
    #fdiv
    #hash
    #inspect
    #magnitude
    #modulo
    #odd?
    #remainder
    #size
    #to_f
    #to_s
    #|
    #~
0
    ::new
    #!
    #!=
    #==
    #__id__
    #__send__
    #equal?
    #instance_eval
    #instance_exec
    #method_missing
    #singleton_method_added
    #singleton_method_removed
    #singleton_method_undefined
0
    #!~
    #
    #===
    #=~
    #class
    #clone
    #define_singleton_method
    #display
    #dup
    #enum_for
    #eql?
    #extend
    #freeze
    #frozen?
    #hash
    #inspect
    #instance_of?
    #instance_variable_defined?
    #instance_variable_get
    #instance_variable_set
    #instance_variables
    #is_a?
    #itself
    #kind_of?
    #method
    #methods
    #nil?
    #object_id
    #private_methods
    #protected_methods
    #public_method
    #public_methods
    #public_send
    #remove_instance_variable
    #respond_to?
    #respond_to_missing?
    #send
    #singleton_class
    #singleton_method
    #singleton_methods
    #taint
    #tainted?
    #tap
    #to_enum
    #to_s
    #trust
    #untaint
    #untrust
    #untrusted?
0
    ::constants
    ::nesting
    ::new
    #
    #
    #
    #==
    #===
    #>
    #>=
    #alias_method
    #ancestors
    #append_features
    #attr
    #attr_accessor
    #attr_reader
    #attr_writer
    #autoload
    #autoload?
    #class_eval
    #class_exec
    #class_variable_defined?
    #class_variable_get
    #class_variable_set
    #class_variables
    #const_defined?
    #const_get
    #const_missing
    #const_set
    #constants
    #define_method
    #deprecate_constant
    #extend_object
    #extended
    #freeze
    #include
    #include?
    #included
    #included_modules
    #inspect
    #instance_method
    #instance_methods
    #method_added
    #method_defined?
    #method_removed
    #method_undefined
    #module_eval
    #module_exec
    #module_function
    #name
    #prepend
    #prepend_features
    #prepended
    #private
    #private_class_method
    #private_constant
    #private_instance_methods
    #private_method_defined?
    #protected
    #protected_instance_methods
    #protected_method_defined?
    #public
    #public_class_method
    #public_constant
    #public_instance_method
    #public_instance_methods
    #public_method_defined?
    #refine
    #remove_class_variable
    #remove_const
    #remove_method
    #singleton_class?
    #to_s
    #undef_method
    #using
0
    ::new
    #allocate
    #inherited
    #new
    #superclass
0
    ::polar
    ::rect
    ::rectangular
    #*
    #**
    #+
    #-
    #[email protected]
    #/
    #==
    #abs
    #abs2
    #angle
    #arg
    #conj
    #conjugate
    #denominator
    #fdiv
    #imag
    #imaginary
    #inspect
    #magnitude
    #numerator
    #phase
    #polar
    #quo
    #rationalize
    #real
    #real?
    #rect
    #rectangular
    #to_c
    #to_f
    #to_i
    #to_r
    #to_s
    #~
0


PS if you check like this, then there are no zeros on the page024591b0027340479564dedc3ba61a0d.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question