Class: Object (Ruby 2.3.2)
Description: Class : Object - Ruby 2.3.2

- Home
- Core 2.3.2
- Std-lib 2.3.2
- Downloads

Support for the Ruby 2.3 series has ended. See here for reference.

### Home Classes Methods

### In Files

- socket/mkconstants.rb

### Parent

BasicObject

### Methods

- #c_str
- #def_intern
- #def_name_to_int
- #each_const
- #each_name
- #each_names_with_len
- #reverse_each_name
- #reverse_each_name_with_prefix_optional

### Class/Module Index

Quicksearch

- Addrinfo
- BasicSocket
- IPSocket
- Object
- SOCKSSocket
- Socket
- Socket::AncillaryData
- Socket::Ifaddr
- Socket::Option
- Socket::UDPSource
- SocketError
- TCPServer
- TCPSocket
- UDPSocket
- UNIXServer
- UNIXSocket

No matching classes.

# Object

### Constants

COMMENTS
C_ESC
C_ESC_PAT
DEFS
INTERN_DEFS
NAME_TO_INT_DEFS

### Public Instance Methods

c_str(str) click to toggle source

                   # File socket/mkconstants.rb, line 31
    def c_str(str)
      '"' + str.gsub(C_ESC_PAT) {|s| C_ESC[s]} + '"'
    end

def_intern(func_name, pat, prefix_optional=nil) click to toggle source

                   # File socket/mkconstants.rb, line 233
    def def_intern(func_name, pat, prefix_optional=nil)
      prefix_pat = nil
      if prefix_optional
        if Regexp === prefix_optional
          prefix_pat = prefix_optional
        else
          prefix_pat = /\A#{Regexp.escape prefix_optional}/
        end
      end
      hash_var = "#{func_name}_hash"
      vardef = "static st_table *#{hash_var};"
      gen_hash = gen_int_to_name_hash(hash_var, pat, prefix_pat)
      decl = gen_int_to_name_decl(func_name, hash_var)
      func = gen_int_to_name_func(func_name, hash_var)
      INTERN_DEFS << [vardef, gen_hash, decl, func]
    end

def_name_to_int(funcname, pat, prefix_optional, guard=nil) click to toggle source

                   # File socket/mkconstants.rb, line 190
    def def_name_to_int(funcname, pat, prefix_optional, guard=nil)
      decl = gen_name_to_int_decl(funcname, pat, prefix_optional, guard)
      func = gen_name_to_int_func(funcname, pat, prefix_optional, guard)
      NAME_TO_INT_DEFS << [decl, func]
    end

each_const() click to toggle source

                   # File socket/mkconstants.rb, line 57
    def each_const
      DEFS.each {|name, default_value|
        guard = nil
        if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name
          # IPv6 is not supported although AF_INET6 is defined on mingw
          guard = "defined(INET6)"
        end
        yield guard, name, default_value
      }
    end

each_name(pat) click to toggle source

                   # File socket/mkconstants.rb, line 68
    def each_name(pat)
      DEFS.each {|name, default_value|
        next if pat !~ name
        yield name
      }
    end

each_names_with_len(pat, prefix_optional=nil) click to toggle source

                   # File socket/mkconstants.rb, line 117
    def each_names_with_len(pat, prefix_optional=nil)
      h = {}
      DEFS.each {|name, default_value|
        next if pat !~ name
        (h[name.length] ||= []) << [name, name]
      }
      if prefix_optional
        if Regexp === prefix_optional
          prefix_pat = prefix_optional
        else
          prefix_pat = /\A#{Regexp.escape prefix_optional}/
        end
        DEFS.each {|const, default_value|
          next if pat !~ const
          next if prefix_pat !~ const
          name = $'
          (h[name.length] ||= []) << [name, const]
        }
      end
      hh = {}
      h.each {|len, pairs|
        pairs.each {|name, const|
          raise "name crash: #{name}" if hh[name]
          hh[name] = true
        }
      }
      h.keys.sort.each {|len|
        yield h[len], len
      }
    end

reverse_each_name(pat) click to toggle source

                   # File socket/mkconstants.rb, line 110
    def reverse_each_name(pat)
      DEFS.reverse_each {|name, default_value|
        next if pat !~ name
        yield name
      }
    end

reverse_each_name_with_prefix_optional(pat, prefix_pat) click to toggle source

                   # File socket/mkconstants.rb, line 196
    def reverse_each_name_with_prefix_optional(pat, prefix_pat)
      reverse_each_name(pat) {|n|
        yield n, n
      }
      if prefix_pat
        reverse_each_name(pat) {|n|
          next if prefix_pat !~ n
          yield n, $'
        }
      end
    end