idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
18,900 | def check_db ( repair = false ) unless ( item_counter = dynamo_get_item ( 'item_counter' ) ) && item_counter == @item_counter PEROBS . log . error "@item_counter variable (#{@item_counter}) and " + "item_counter table entry (#{item_counter}) don't match" end item_counter = 0 each_item { item_counter += 1 } unless item_... | Basic consistency check . |
18,901 | def method_missing ( method_sym , * args , & block ) unless ( obj = _referenced_object ) :: PEROBS . log . fatal "Internal consistency error. No object with ID " + "#{@id} found in the store." end if obj . respond_to? ( :is_poxreference? ) :: PEROBS . log . fatal "POXReference that references a POXReference found." end... | Proxy all calls to unknown methods to the referenced object . |
18,902 | def _transfer ( store ) @store = store ObjectSpace . undefine_finalizer ( self ) @store . _register_in_memory ( self , @_id ) ObjectSpace . define_finalizer ( self , ObjectBase . _finalize ( @store , @_id , object_id ) ) @myself = POXReference . new ( @store , @_id ) end | Library internal method to transfer the Object to a new store . |
18,903 | def _restore ( level ) data = nil if @_stash_map ( level - 1 ) . downto ( 0 ) do | lvl | break if ( data = @_stash_map [ lvl ] ) end end if data _deserialize ( data ) elsif @store . db . include? ( @_id ) db_obj = store . db . get_object ( @_id ) _deserialize ( db_obj [ 'data' ] ) end end | Restore the object state from the storage back - end . |
18,904 | def domain_check ( * domains ) domains . flatten! response = send_request ( domain_check_xml ( * domains ) ) get_result ( :xml => response , :callback => :domain_check_process ) end | Check the availability of domains |
18,905 | def domain_info ( args ) args = { :name => args } if args . is_a? ( String ) response = send_request ( domain_info_xml ( args ) ) get_result ( :xml => response , :callback => :domain_info_process ) end | Returns the informations about a domain |
18,906 | def set_custom_data ( name , value ) unless @custom_data_labels . include? ( name ) PEROBS . log . fatal "Unknown custom data field #{name}" end @custom_data_values [ @custom_data_labels . index ( name ) ] = value write_header if @f end | Set the registered custom data field to the given value . |
18,907 | def free_address if @first_space == 0 begin offset = @f . size @f . seek ( offset ) write_n_bytes ( [ 1 ] + :: Array . new ( @entry_bytes , 0 ) ) write_header return offset_to_address ( offset ) rescue IOError => e PEROBS . log . fatal "Cannot create reserved space at #{@first_space} " + "in EquiBlobsFile #{@file_name}... | Return the address of a free blob storage space . Addresses start at 0 and increase linearly . |
18,908 | def store_blob ( address , bytes ) unless address >= 0 PEROBS . log . fatal "Blob storage address must be larger than 0, " + "not #{address}" end if bytes . length != @entry_bytes PEROBS . log . fatal "All stack entries must be #{@entry_bytes} " + "long. This entry is #{bytes.length} bytes long." end marker = 1 begin o... | Store the given byte blob at the specified address . If the blob space is already in use the content will be overwritten . |
18,909 | def retrieve_blob ( address ) unless address > 0 PEROBS . log . fatal "Blob retrieval address must be larger than 0, " + "not #{address}" end begin if ( offset = address_to_offset ( address ) ) >= @f . size PEROBS . log . fatal "Cannot retrieve blob at address #{address} " + "of EquiBlobsFile #{@file_name}. Address is ... | Retrieve a blob from the given address . |
18,910 | def delete_blob ( address ) unless address >= 0 PEROBS . log . fatal "Blob address must be larger than 0, " + "not #{address}" end offset = address_to_offset ( address ) begin @f . seek ( offset ) if ( marker = read_char ) != 1 && marker != 2 PEROBS . log . fatal "Cannot delete blob stored at address #{address} " + "of... | Delete the blob at the given address . |
18,911 | def check sync return false unless check_spaces return false unless check_entries expected_size = address_to_offset ( @total_entries + @total_spaces + 1 ) actual_size = @f . size if actual_size != expected_size PEROBS . log . error "Size mismatch in EquiBlobsFile #{@file_name}. " + "Expected #{expected_size} bytes but ... | Check the file for logical errors . |
18,912 | def open ( io ) begin @@logger = Logger . new ( io , * @@options ) rescue IOError => e @@logger = Logger . new ( $stderr ) $stderr . puts "Cannot open log file: #{e.message}" end @@logger . level = @@level @@logger . formatter = @@formatter end | Redirect all log messages to the given IO . |
18,913 | def rename ( rename_map ) @by_id . each . with_index do | klass , id | next unless klass if ( new_name = rename_map [ klass ] ) @by_id [ id ] = new_name @by_class . delete ( klass ) @by_class [ new_name ] = id end end end | Rename a set of classes to new names . |
18,914 | def keep ( classes ) @by_id . each . with_index do | klass , id | unless classes . include? ( klass ) @by_id [ id ] = nil @by_class . delete ( klass ) end end end | Delete all classes unless they are contained in _classes_ . |
18,915 | def read_file @file_path = '~/.local/share/wmctile' @file_name = 'memory.yml' @file_full = File . expand_path ( [ @file_path , @file_name ] . join ( '/' ) ) if File . exist? @file_full file_contents = File . read ( @file_full ) @memory = YAML . load ( file_contents ) else create_file write_file end end | Memory init function . Creates a default yaml file if it s non - existent . |
18,916 | def call ( request ) m = request . method . downcase . to_sym unless respond_to? ( m ) allowed = METHODS . select { | m | respond_to? ( m ) } . map ( & :upcase ) . join ( ', ' ) return [ 405 , { 'Content-Type' => 'text/plain' , 'Allow' => allowed } , "Method not allowed: '#{request.env['REQUEST_METHOD']}'" ] end begin ... | Call the request . |
18,917 | def duplicate! Page . new ( attributes . except ( 'id' , 'updated_at' , 'created_at' ) ) . tap do | page | page . title = page . title + ' (Copy)' page . slug = page . slug + '-copy' page . draft = true regions . each do | region | page . regions . build ( region . attributes . except ( 'id' , 'updated_at' , 'created_a... | Returns a duplicated post object or throws an exception |
18,918 | def consume_directive super if @in_body_statements @newline = false start = @index line = @line statement = DirectiveStatement . new ( nil , @file , line ) @statements << statement attach_comment ( statement ) multiline = false advance_loop do chr = char case chr when '\\' ; multiline = true ; advance when / \s / ; con... | Consumes a directive and generates a DirectiveStatement |
18,919 | def reply ( options ) say ( body : options [ :body ] , from : options [ :to ] . to , to : options [ :to ] . from , type : options [ :to ] . type , ) end | Replies to given message |
18,920 | def say ( options ) post Elements :: Message . new ( body : options [ :body ] , from : options [ :from ] , to : options [ :to ] , type : options [ :type ] , ) end | Send a message |
18,921 | def []= ( index , value ) index = validate_index_range ( index ) @store . transaction do if index < @entry_counter @root . set ( index , value ) elsif index == @entry_counter @root . insert ( index , value ) self . entry_counter += 1 else @entry_counter . upto ( index - 1 ) do | i | @root . insert ( i , nil ) end @root... | Store the value at the given index . If the index already exists the old value will be overwritten . |
18,922 | def insert ( index , value ) index = validate_index_range ( index ) if index < @entry_counter @store . transaction do @root . insert ( index , value ) self . entry_counter += 1 end else self [ index ] = value end end | Insert the value at the given index . If the index already exists the old value will be overwritten . |
18,923 | def delete_if old_root = @root clear old_root . each do | k , v | if ! yield ( k , v ) insert ( k , v ) end end end | Delete all entries for which the passed block yields true . The implementation is optimized for large bulk deletes . It rebuilds a new BTree for the elements to keep . If only few elements are deleted the overhead of rebuilding the BTree is rather high . |
18,924 | def each ( & block ) node = @first_leaf while node break unless node . each ( & block ) node = node . next_sibling end end | Iterate over all entries in the tree . Entries are always sorted by the key . |
18,925 | def reverse_each ( & block ) node = @last_leaf while node break unless node . reverse_each ( & block ) node = node . prev_sibling end end | Iterate over all entries in the tree in reverse order . Entries are always sorted by the key . |
18,926 | def to_a ary = [ ] node = @first_leaf while node do ary += node . values node = node . next_sibling end ary end | Convert the BigArray into a Ruby Array . This is primarily intended for debugging as real - world BigArray objects are likely too big to fit into memory . |
18,927 | def save bytes = [ @blob_address , @size , @parent ? @parent . node_address : 0 , @smaller ? @smaller . node_address : 0 , @equal ? @equal . node_address : 0 , @larger ? @larger . node_address : 0 ] . pack ( NODE_BYTES_FORMAT ) @tree . nodes . store_blob ( @node_address , bytes ) end | Save the node into the blob file . |
18,928 | def add_space ( address , size ) node = self loop do if node . size == 0 node . set_size_and_address ( size , address ) break elsif size < node . size if node . smaller node = node . smaller else node . set_link ( '@smaller' , SpaceTreeNode :: create ( @tree , address , size , node ) ) break end elsif size > node . siz... | Add a new node for the given address and size to the tree . |
18,929 | def has_space? ( address , size ) node = self loop do if node . blob_address == address return size == node . size elsif size < node . size && node . smaller node = node . smaller elsif size > node . size && node . larger node = node . larger elsif size == node . size && node . equal node = node . equal else return fal... | Check if this node or any sub - node has an entry for the given address and size . |
18,930 | def relink_parent ( node ) if @parent if @parent . smaller == self @parent . set_link ( '@smaller' , node ) elsif @parent . equal == self @parent . set_link ( '@equal' , node ) elsif @parent . larger == self @parent . set_link ( '@larger' , node ) else PEROBS . log . fatal "Cannot relink unknown child node with address... | Replace the link in the parent node of the current node that points to the current node with the given node . |
18,931 | def to_a ary = [ ] each do | node , mode , stack | if mode == :on_enter ary << [ node . blob_address , node . size ] end end ary end | Compare this node to another node . |
18,932 | def check ( flat_file , count ) node_counter = 0 max_depth = 0 @tree . progressmeter . start ( 'Checking space list entries' , count ) do | pm | each do | node , mode , stack | max_depth = stack . size if stack . size > max_depth case mode when :smaller if node . smaller return false unless node . check_node_link ( 'sm... | Check this node and all sub nodes for possible structural or logical errors . |
18,933 | def check_node_link ( link , stack ) if ( node = instance_variable_get ( '@' + link ) ) unless node . nil? || node . is_a? ( SpaceTreeNodeLink ) PEROBS . log . error "Node link #{link} of node #{to_s} " + "is of class #{node.class}" return false end if node == self PEROBS . log . error "#{link} address of node " + "#{n... | Check the integrity of the given sub - node link and the parent link pointing back to this node . |
18,934 | def to_tree_s str = '' each do | node , mode , stack | if mode == :on_enter begin branch_mark = node . parent . nil? ? '' : node . parent . smaller == node ? '<' : node . parent . equal == node ? '=' : node . parent . larger == node ? '>' : '@' str += "#{node.text_tree_prefix}#{branch_mark}-" + "#{node.smaller || node.... | Convert the node and all child nodes into a tree like text form . |
18,935 | def text_tree_prefix if ( node = @parent ) str = '+' else str = 'o' end while node last_child = false if node . parent if node . parent . smaller == node last_child = node . parent . equal . nil? && node . parent . larger . nil? elsif node . parent . equal == node last_child = node . parent . larger . nil? elsif node .... | The indentation and arch routing for the text tree . |
18,936 | def flush ( now ) if now || @entries . length > WATERMARK @entries . each do | e | if e . modified e . obj . save e . modified = false end end @entries = @entries [ 0 .. WATERMARK - 1 ] if @entries . length > WATERMARK end end | Save all modified entries and delete all but the most recently added . |
18,937 | def contact_check ( * contacts ) contacts . flatten! response = send_request ( contact_check_xml ( * contacts ) ) get_result ( :xml => response , :callback => :contact_check_process ) end | Check the availability of contacts |
18,938 | def contact_info ( args ) args = { :id => args } if args . is_a? ( String ) response = send_request ( contact_info_xml ( args ) ) get_result ( :xml => response , :callback => :contact_info_process ) end | Returns the informations about a contact |
18,939 | def find_window ( current_workspace_only = false ) @matching_windows = Wmctile . window_list . grep ( @regexp_string ) filter_out_workspaces if current_workspace_only if @matching_windows . count > 1 filter_more_matching_windows elsif @matching_windows . count == 1 @matching_line = @matching_windows [ 0 ] else fail Err... | Window init function . Tries to find an id . |
18,940 | def begin_pos node_begin_pos = @node . loc . expression . begin_pos while @node . loc . expression . source_buffer . source [ node_begin_pos -= 1 ] == ' ' end node_begin_pos - Engine :: ERUBY_STMT_SPLITTER . length + 1 end | Begin position of code to replace . |
18,941 | def end_pos node_begin_pos = @node . loc . expression . begin_pos node_begin_pos += @node . loc . expression . source . index "do" while @node . loc . expression . source_buffer . source [ node_begin_pos += 1 ] != '@' end node_begin_pos end | End position of code to replace . |
18,942 | def rewritten_code @node . loc . expression . source_buffer . source [ begin_pos ... end_pos ] . sub ( Engine :: ERUBY_STMT_SPLITTER , "@output_buffer.append= " ) . sub ( Engine :: ERUBY_STMT_SPLITTER , Engine :: ERUBY_EXPR_SPLITTER ) end | The rewritten erb expr code . |
18,943 | def verify_page ( context ) return if context . url_match_attribute . nil? return if context . has_correct_url? raise Tapestry :: Errors :: PageURLFromFactoryNotVerified end | This method is used to provide a means for checking if a page has been navigated to correctly as part of a context . This is useful because the context signature should remain highly readable and checks for whether a given page has been reached would make the context definition look sloppy . |
18,944 | def cache_read ( obj ) if obj . respond_to? ( :is_poxreference? ) PEROBS . log . fatal "POXReference objects should never be cached" end @reads [ index ( obj ) ] = obj end | Create a new Cache object . |
18,945 | def begin_transaction if @transaction_stack . empty? flush else @transaction_stack . last . each do | id | @transaction_objects [ id ] . _stash ( @transaction_stack . length - 1 ) end end @transaction_stack . push ( :: Array . new ) end | Tell the cache to start a new transaction . If no other transaction is active the write cache is flushed before the transaction is started . |
18,946 | def end_transaction case @transaction_stack . length when 0 PEROBS . log . fatal 'No ongoing transaction to end' when 1 @transaction_stack . pop . each { | id | @transaction_objects [ id ] . _sync } @transaction_objects = :: Hash . new else transactions = @transaction_stack . pop @transaction_stack . push ( @transactio... | Tell the cache to end the currently active transaction . All write operations of the current transaction will be synced to the storage back - end . |
18,947 | def abort_transaction if @transaction_stack . empty? PEROBS . log . fatal 'No ongoing transaction to abort' end @transaction_stack . pop . each do | id | @transaction_objects [ id ] . _restore ( @transaction_stack . length ) end end | Tell the cache to abort the currently active transaction . All modified objects will be restored from the storage back - end to their state before the transaction started . |
18,948 | def update_obj mean , sd = rating . to_glicko_rating @obj . rating = mean @obj . rating_deviation = sd @obj . volatility = volatility end | Update seed object with this player s values |
18,949 | def add_node ( node ) raise Abuelo :: Exceptions :: NodeAlreadyExistsError if has_node? ( node ) @nodes [ node . name ] = node node . graph = self self end | Adds a node to the graph . |
18,950 | def add_edge ( edge , opts = { } ) raise Abuelo :: Exceptions :: EdgeAlreadyExistsError if has_edge? ( edge ) @edges [ edge . node_1 ] ||= { } @edges [ edge . node_1 ] [ edge . node_2 ] = edge if undirected? && ! opts [ :symmetric ] add_edge ( edge . symmetric , symmetric : true ) end self end | Adds an edge to the graph . Auto - adds the symmetric counterpart if graph is undirected . |
18,951 | def process file_pattern = File . join ( Configuration . instance . get ( :path ) , @file_pattern ) Dir . glob ( file_pattern ) . each do | file_path | unless Configuration . instance . get ( :skip_files ) . include? file_path begin conflict_actions = [ ] source = self . class . file_source ( file_path ) ast = self . c... | Initialize an instance . |
18,952 | def get_conflict_actions i = @actions . length - 1 j = i - 1 conflict_actions = [ ] return if i < 0 begin_pos = @actions [ i ] . begin_pos while j > - 1 if begin_pos <= @actions [ j ] . end_pos conflict_actions << @actions . delete_at ( j ) else i = j begin_pos = @actions [ i ] . begin_pos end j -= 1 end conflict_actio... | It changes source code from bottom to top and it can change source code twice at the same time So if there is an overlap between two actions it removes the conflict actions and operate them in the next loop . |
18,953 | def remove_code_or_whole_line ( source , line ) newline_at_end_of_line = source [ - 1 ] == "\n" source_arr = source . split ( "\n" ) if source_arr [ line - 1 ] && source_arr [ line - 1 ] . strip . empty? source_arr . delete_at ( line - 1 ) if source_arr [ line - 2 ] && source_arr [ line - 2 ] . strip . empty? && source... | It checks if code is removed and that line is empty . |
18,954 | def encrypt ( data , nonce , additional_data = '' ) valid? ( data , nonce , additional_data ) crypt ( data , nonce ) + mac ( data , nonce , additional_data ) end | Creates a new CCM object . |
18,955 | def binary_encode_if_any_high_ascii ( string ) string = ensure_utf8 ( string ) string . force_encoding ( 'BINARY' ) if string . bytes . detect { | byte | byte > 127 } string end | Returns a BINARY - encoded version of string if is cannot be represented as 7bit ASCII . |
18,956 | def binary_encode_any_high_ascii_in_hash ( hash ) Hash [ hash . map { | key , value | [ key , binary_encode_any_high_ascii ( value ) ] } ] end | Ensures all values of the given hash are BINARY - encoded if necessary . |
18,957 | def has_key? ( key ) if :hash == self . type self . children . any? { | pair_node | pair_node . key . to_value == key } else raise Synvert :: Core :: MethodNotSupported . new "has_key? is not handled for #{self.debug_info}" end end | Test if hash node contains specified key . |
18,958 | def hash_value ( key ) if :hash == self . type value_node = self . children . find { | pair_node | pair_node . key . to_value == key } value_node ? value_node . value : nil else raise Synvert :: Core :: MethodNotSupported . new "has_key? is not handled for #{self.debug_info}" end end | Get hash value node according to specified key . |
18,959 | def to_value case self . type when :int , :str , :sym self . children . last when :true true when :false false when :array self . children . map ( & :to_value ) when :irange ( self . children . first . to_value .. self . children . last . to_value ) when :begin self . children . first . to_value else raise Synvert :: C... | Return the exact value . |
18,960 | def recursive_children self . children . each do | child | if Parser :: AST :: Node === child yield child child . recursive_children { | c | yield c } end end end | Recursively iterate all child nodes of current node . |
18,961 | def match? ( rules ) flat_hash ( rules ) . keys . all? do | multi_keys | if multi_keys . last == :any actual_values = actual_value ( self , multi_keys [ 0 ... - 1 ] ) expected = expected_value ( rules , multi_keys ) actual_values . any? { | actual | match_value? ( actual , expected ) } elsif multi_keys . last == :not a... | Match current node with rules . |
18,962 | def match_value? ( actual , expected ) case expected when Symbol if Parser :: AST :: Node === actual actual . to_source == ":#{expected}" else actual . to_sym == expected end when String if Parser :: AST :: Node === actual actual . to_source == expected || ( actual . to_source [ 0 ] == ':' && actual . to_source [ 1 .. ... | Compare actual value with expected value . |
18,963 | def flat_hash ( h , k = [ ] ) new_hash = { } h . each_pair do | key , val | if val . is_a? ( Hash ) new_hash . merge! ( flat_hash ( val , k + [ key ] ) ) else new_hash [ k + [ key ] ] = val end end new_hash end | Convert a hash to flat one . |
18,964 | def actual_value ( node , multi_keys ) multi_keys . inject ( node ) { | n , key | if n key == :source ? n . send ( key ) : n . send ( key ) end } end | Get actual value from the node . |
18,965 | def expected_value ( rules , multi_keys ) multi_keys . inject ( rules ) { | o , key | o [ key ] } end | Get expected value from rules . |
18,966 | def set ( index , value ) node = self while node do if node . is_leaf? if index >= node . values . size node . fatal "Set index (#{index}) larger than values array " + "(#{node.values.size})." end node . values [ index ] = value return else cidx = node . search_child_index ( index ) index -= node . offsets [ cidx ] nod... | Set the given value at the given index . |
18,967 | def insert ( index , value ) node = self cidx = nil while node do if node . size >= @tree . node_size index += node . parent . offsets [ cidx ] if node . parent node = node . split_node end if node . is_leaf? node . values . insert ( index , value ) node . parent . adjust_offsets ( node , 1 ) if node . parent return el... | Insert the given value at the given index . All following values will be pushed to a higher index . |
18,968 | def value_index ( idx ) node = self while node . parent idx += node . parent . offsets [ node . index_in_parent_node ] node = node . parent end idx end | Compute the array index of the value with the given index in the current node . |
18,969 | def move_first_element_of_successor_to_child ( child_index ) child = @children [ child_index ] succ = @children [ child_index + 1 ] if child . is_leaf? @offsets [ child_index + 1 ] += 1 child . values << succ . values . shift else succ . offsets . shift delta = succ . offsets . first succ . offsets . map! { | o | o -= ... | Move first element of successor to end of child node |
18,970 | def move_last_element_of_predecessor_to_child ( child_index ) pred = @children [ child_index - 1 ] child = @children [ child_index ] if child . is_leaf? @offsets [ child_index ] -= 1 child . values . unshift ( pred . values . pop ) else delta = @offsets [ child_index ] - pred . offsets . last @offsets [ child_index ] =... | Move last element of predecessor node to child |
18,971 | def []= ( key , value ) hashed_key = hash_key ( key ) @store . transaction do entry = @store . new ( Entry , key , value ) if ( existing_entry = @btree . get ( hashed_key ) ) if existing_entry . is_a? ( Collisions ) index_to_insert = 0 overwrite = false existing_entry . each do | ae | if ae . key == key overwrite = tru... | Insert a value that is associated with the given key . If a value for this key already exists the value will be overwritten with the newly provided value . |
18,972 | def [] ( key ) hashed_key = hash_key ( key ) unless ( entry = @btree . get ( hashed_key ) ) return nil end if entry . is_a? ( PEROBS :: Array ) entry . each do | ae | return ae . value if ae . key == key end else return entry . value if entry . key == key end nil end | Retrieve the value for the given key . If no value for the key is found nil is returned . |
18,973 | def has_key? ( key ) hashed_key = hash_key ( key ) unless ( entry = @btree . get ( hashed_key ) ) return false end if entry . is_a? ( PEROBS :: Array ) entry . each do | ae | return true if ae . key == key end else return true if entry . key == key end false end | Check if the is a value stored for the given key . |
18,974 | def delete ( key ) hashed_key = hash_key ( key ) unless ( entry = @btree . get ( hashed_key ) ) return nil end if entry . is_a? ( PEROBS :: Array ) entry . each_with_index do | ae , i | if ae . key == key self . entry_counter -= 1 return entry . delete_at ( i ) . value end end else return entry . value if entry . key =... | Delete and return the entry for the given key . Return nil if no matching entry exists . |
18,975 | def check return false unless @btree . check i = 0 each do | k , v | i += 1 end unless @entry_counter == i PEROBS . log . error "BigHash contains #{i} values but entry counter " + "is #{@entry_counter}" return false end true end | Check if the data structure contains any errors . |
18,976 | def method_missing ( key , * args , & block ) if key . to_s =~ / \A \z / self [ $1 ] = args . first return args . first end if key . to_s =~ / \A \? \z / return ! ! self [ $1 ] end return self [ key ] if has_key? ( key ) nil end | Sets or gets field in the hash . |
18,977 | def open @nodes . open @cache . clear node = @nodes . total_entries == 0 ? SpaceTreeNode :: create ( self ) : SpaceTreeNode :: load ( self , @nodes . first_entry ) @root_address = node . node_address end | Manage the free spaces tree in the specified directory |
18,978 | def add_space ( address , size ) if size <= 0 PEROBS . log . fatal "Size (#{size}) must be larger than 0." end root . add_space ( address , size ) end | Add a new space with a given address and size . |
18,979 | def get_space ( size ) if size <= 0 PEROBS . log . fatal "Size (#{size}) must be larger than 0." end if ( address_size = root . find_matching_space ( size ) ) return address_size elsif ( address_size = root . find_equal_or_larger_space ( size ) ) return address_size else return nil end end | Get a space that has at least the requested size . |
18,980 | def each root . each do | node , mode , stack | if mode == :on_enter yield ( node . blob_address , node . size ) end end end | Iterate over all entries and yield address and size . |
18,981 | def legalEntityInfos ( leI ) ret = { } ret [ :legalStatus ] = leI . xpath ( 'frnic:legalStatus' , EPPClient :: SCHEMAS_URL ) . attr ( 's' ) . value unless ( r = leI . xpath ( 'frnic:idStatus' , EPPClient :: SCHEMAS_URL ) ) . empty? ret [ :idStatus ] = { :value => r . text } ret [ :idStatus ] [ :when ] = r . attr ( 'whe... | parse legalEntityInfos content . |
18,982 | def insert ( id ) index = @page_records . bsearch_index { | pr | pr . max_id >= id } page = @page_records [ index ] while page . is_full? new_page = page . split @page_records . insert ( index + 1 , new_page ) if id >= new_page . min_id index += 1 page = new_page end end page . insert ( id ) end | Create a new IDList object . The data that can t be kept in memory will be stored in the specified directory under the given name . |
18,983 | def check last_max = - 1 unless ( min_id = @page_records . first . min_id ) == 0 raise RuntimeError , "min_id of first record (#{min_id}) " + "must be 0." end @page_records . each do | pr | unless pr . min_id == last_max + 1 raise RuntimeError , "max_id of previous record (#{last_max}) " + "must be exactly 1 smaller th... | Perform some consistency checks on the internal data structures . Raises a RuntimeError in case a problem is found . |
18,984 | def paths_to_pdfs paths = [ ] Zip :: ZipFile . open ( path ) do | zipfile | zipfile . select { | file | zipfile . get_entry ( file ) . file? } . each do | file | paths << file . name if file . name . end_with? ".pdf" end end paths end | Locate all PDF files within the ZIP |
18,985 | def t_has_one ( name , options = { } ) extend ( Associations :: HasOne :: ClassMethods ) association = _t_create_association ( :t_has_one , name , options ) initialize_has_one_association ( association ) define_method ( association . name ) do | * params | get_associate ( association , params ) do has_one_associate ( a... | Specifies a one - to - one association with another class . This method should only be used if the other class contains the foreign key . If the current class contains the foreign key then you should use + t_belongs_to + instead . |
18,986 | def t_belongs_to ( name , options = { } ) extend ( Associations :: BelongsTo :: ClassMethods ) association = _t_create_association ( :t_belongs_to , name , options ) initialize_belongs_to_association ( association ) define_method ( association . name ) do | * params | get_associate ( association , params ) do belongs_t... | Specifies a one - to - one association with another class . This method should only be used if this class contains the foreign key . If the other class contains the foreign key then you should use + t_has_one + instead . |
18,987 | def t_has_many ( name , options = { } ) extend ( Associations :: HasMany :: ClassMethods ) association = _t_create_association ( :t_has_many , name , options ) initialize_has_many_association ( association ) define_method ( association . name ) do | * params | get_associate ( association , params ) do has_many_associat... | Specifies a one - to - many association . |
18,988 | def aliases list = [ ] return list unless namespace . is_a? ( HeaderObject ) namespace . aliases . each do | o , aname | list << o if aname == name && o . scope == scope end list end | Returns all alias names of the object |
18,989 | def game ( game_seeds , ranks ) game_seeds . each_with_index do | iseed , i | game_seeds . each_with_index do | jseed , j | next if i == j @raters [ iseed ] . add ( player ( jseed ) . rating , Util . ranks_to_score ( ranks [ i ] , ranks [ j ] ) ) end end end | Register a game with this rating period |
18,990 | def + ( other ) if other . is_a? ( Value ) lcm_div = @div . lcm ( other . div ) Value . new ( ( @val * ( lcm_div / @div ) ) + ( other . val * ( lcm_div / other . div ) ) , lcm_div ) elsif other . is_a? ( Numeric ) to_f + other else raise "Unexpected argument" end end | Construct a Value object . |
18,991 | def * ( other ) if other . is_a? ( Value ) other = other . to_f end if other . is_a? ( Numeric ) to_f * other else raise "Unexpected argument (#{other.inspect})" end end | Multiply a Value object . |
18,992 | def add ( schema_table ) if schema_table . kind_of? Schema :: Fact collection = @facts elsif schema_table . kind_of? Schema :: Dimension collection = @dimensions end add_to_collection collection , schema_table end | Adds a prebuilt schema table to the schema |
18,993 | def define_fact ( name , & block ) add Schema :: Builders :: FactBuilder . new ( self ) . build ( name , & block ) end | Defines a fact table named + name + in this schema . |
18,994 | def define_dimension ( name , & block ) add Schema :: Builders :: DimensionBuilder . new ( self ) . build ( name , & block ) end | Defines a dimension table named + name + in this schema . |
18,995 | def define_shrunken_dimension ( name , base_name , & block ) add Schema :: Builders :: ShrunkenDimensionBuilder . new ( self , base_name ) . build ( name , & block ) end | Defines a shrunken dimension table named + name + in this schema . |
18,996 | def use_data_with ( key , value ) element = send ( key . to_s . tr ( ' ' , '_' ) ) set_and_select ( key , element , value ) check_and_uncheck ( key , element , value ) end | This is the method that is delegated to in order to make sure that elements are interacted with appropriately . This will in turn delegate to set_and_select and check_and_uncheck which determines what actions are viable based on the type of element that is being dealt with . These aspects are what tie this particular i... |
18,997 | def requires_version ( cmd , version_ ) v = check_version ( version_ ) raise NoMethodError , sprintf ( "%s is not supported in Bugzilla %s" , cmd , v [ 1 ] ) unless v [ 0 ] end | def check_version = begin rdoc |
18,998 | def load ( page_idx , record ) values = [ ] unless ( entries = record . page_entries ) == 0 begin @f . seek ( page_idx * @page_size * 8 ) values = @f . read ( entries * 8 ) . unpack ( "Q#{entries}" ) rescue IOError => e PEROBS . log . fatal "Cannot read cache file #{@file_name}: #{e.message}" end end p = IDListPage . n... | Create a new IDListPageFile object that uses the given file in the given directory as cache file . |
18,999 | def new_page ( record , values = [ ] ) idx = @page_counter @page_counter += 1 mark_page_as_modified ( IDListPage . new ( self , record , idx , values ) ) idx end | Create a new IDListPage and register it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.