⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 curia.rb

📁 harvest是一个下载html网页得机器人
💻 RB
📖 第 1 页 / 共 2 页
字号:
  # This method is useful when another process uses the connected database directory.  #  def sync()    mod_sync(@index)  end  ##  # bool = curia.optimize(bnum)  # Method: Optimize the database.  # `bnum' specifies the number of the elements of the bucket array.  If it is omitted or not  # more than 0, the default value is specified.  # The return value is always `true'.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  # In an alternating succession of deleting and storing with overwrite or concatenate,  # dispensable regions accumulate.  This method is useful to do away with them.  #  def optimize(bnum = -1)    mod_optimize(@index, bnum)  end  ##  # num = curia.fsiz()  # Method: Get the total size of the database files.  # The return value is the total size of the database files.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  #  def fsiz()    mod_fsiz(@index)  end  ##  # num = curia.bnum()  # Method: Get the total number of the elements of each bucket array.  # The return value is the total number of the elements of each bucket array  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  #  def bnum()    mod_bnum(@index)  end  ##  # num = curia.rnum()  # Method: Get the number of the records stored in the database.  # The return value is the number of the records stored in the database.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  #  def rnum()    mod_rnum(@index)  end  ##  # num = curia.length()  # Method: An alias of `rnum'.  #  alias length rnum  ##  # num = curia.size()  # Method: An alias of `rnum'.  #  alias size rnum  ##  # bool = curia.writable()  # Method: Check whether the database handle is a writer or not.  # The return value is true if the handle is a writer, false if not.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  #  def writable()    mod_writable(@index)  end  ##  # bool = curia.fatalerror()  # Method: Check whether the database has a fatal error or not.  # The return value is true if the database has a fatal error, false if not.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  #  def fatalerror()    mod_fatalerror(@index)  end  ##  # curia.each() do |key, val| ... end  # Iterator Method: Iterate a process with a pair of a key and a value of each record.  #  def each()    MyMutex.synchronize() do      iterinit()      while(true)        begin          key = iternext()          val = get(key)        rescue ENOITEM          break        end        yield(key, val)      end      iterinit()    end    self  end  ##  # curia.each_pair() do |key, val| ... end  # Iterator Method: An alias of `each'.  #  alias each_pair each  ##  # curia.each_key() do |key| ... end  # Iterator Method: Iterate a process with a key of each record.  #  def each_key()    MyMutex.synchronize() do      iterinit()      while(true)        begin          key = iternext()        rescue ENOITEM          break        end        yield(key)      end      iterinit()    end    self  end  ##  # curia.each_value() do |val| ... end  # Iterator Method: Iterate a process with a value of each record.  #  def each_value()    MyMutex.synchronize() do      iterinit()      while(true)        begin          val = get(iternext())        rescue ENOITEM          break        end        yield(val)      end      iterinit()    end    self  end  ##  # ary = curia.keys()  # Method: Get an array of all keys.  # The return value is an array of all keys.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  #  def keys()    ary = Array::new(rnum())    MyMutex.synchronize() do      iterinit()      0.upto(ary.length - 1) do |i|        ary[i] = iternext()      end      iterinit()    end    ary  end  ##  # ary = curia.values()  # Method: Get an array of all values.  # The return value is an array of all values.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures.  #  def values()    ary = Array::new(rnum())    MyMutex.synchronize() do      iterinit()      0.upto(ary.length - 1) do |i|        ary[i] = get(iternext())      end      iterinit()    end    ary  end  ##  # str = curia.index(val)  # Method: Retrieve a record with a value.  # `val' specifies a value.  Although it must be an instance of String, binary data is okey.  # The return value is the key of the record with the specified value.  # An exception of `Curia::EANY' or its sub classes is thrown if an error occures or no record  # corresponds.  # If two or more records correspond, the first found record is selected.  #  def index(val)    key = nil    MyMutex.synchronize() do      iterinit()      while(true)        key = iternext()        (get(key) == val) && break      end      iterinit()    end    key  end  ##  # num = curia.to_int()  # Method: An alias of `rnum'.  #  alias to_int rnum  ##  # num = curia.to_i()  # Method: An alias of `to_int'.  #  alias to_i to_int  ##  # str = curia.to_str()  # Method: Get string standing for the instance.  #  def to_str    if(@index != -1)      sprintf("#<Curia:%#x:name=%s:state=open:bnum=%d:rnum=%d>",              object_id(), @name, bnum(), rnum())    else      sprintf("#<Curia:%#x:name=%s:state=closed>", object_id(), @name)    end  end  ##  # str = curia.to_s()  # Method: An alias of `to_str'.  #  alias to_s to_str  ##  # ary = curia.to_ary()  # Method: Get an array of alternation of each pair of key and value.  #  def to_ary    ary = Array::new(rnum())    i = 0    each() do |key, val|      ary[i] = [key, val]      i += 1    end    ary  end  ##  # ary = curia.to_a()  # Method: An alias of `to_ary'.  #  alias to_a to_ary  ##  # hash = curia.to_hash()  # Method: Get a hash storing all records.  #  def to_hash    hash = Hash::new()    each() do |key, val|      hash[key] = val    end    hash  end  ##  # hash = curia.to_h()  # Method: An alias of `to_hash'.  #  alias to_h to_hash  ##  # str = curia.inspect()  # Method: An alias of `to_str'.  #  alias inspect to_strend#----------------------------------------------------------------# Alias definition of class methods#----------------------------------------------------------------class << Curia  alias open newend# END OF FILE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -