idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
19,100 | def update_factory ( id , update_factory_body , opts = { } ) data , _status_code , _headers = update_factory_with_http_info ( id , update_factory_body , opts ) return data end | Updates a Factory s settings . Returns a Factory object . |
19,101 | def update_notifications ( factory_id , cloud_notification_settings_body , opts = { } ) data , _status_code , _headers = update_notifications_with_http_info ( factory_id , cloud_notification_settings_body , opts ) return data end | Updates a Factory s notification settings . |
19,102 | def update_profile ( id , factory_id , update_profile_body , opts = { } ) data , _status_code , _headers = update_profile_with_http_info ( id , factory_id , update_profile_body , opts ) return data end | Updates a given Profile |
19,103 | def upload_video ( factory_id , video_upload_body , opts = { } ) data , _status_code , _headers = upload_video_with_http_info ( factory_id , video_upload_body , opts ) return data end | Creates an upload session . |
19,104 | def video_encodings ( id , factory_id , opts = { } ) data , _status_code , _headers = video_encodings_with_http_info ( id , factory_id , opts ) return data end | Returns a list of Encodings that belong to a Video . |
19,105 | def video_metadata ( id , factory_id , opts = { } ) data , _status_code , _headers = video_metadata_with_http_info ( id , factory_id , opts ) return data end | Returns a Video s metadata |
19,106 | def videos ( factory_id , opts = { } ) data , _status_code , _headers = videos_with_http_info ( factory_id , opts ) return data end | Returns a collection of Video objects . |
19,107 | def workflows ( factory_id , opts = { } ) data , _status_code , _headers = workflows_with_http_info ( factory_id , opts ) return data end | Returns a collection of Workflows that belong to a Factory . |
19,108 | def liquid_assigns view_context . assigns . merge ( current_store : current_store , current_comable_user : current_comable_user , current_order : current_order , current_trackers : current_trackers , form_authenticity_token : form_authenticity_token ) . stringify_keys end | To use the functionality of liquid - rails |
19,109 | def flush begin valid_existing_file? ( @file ) raise ReadOnlyThresholdsFile if @readonly hash = current_hash file = File . open ( @file , 'w+' ) raise ThresholdAtomicLockFailure , 'The @file state/hash changed before we could flush the file' unless stored_hash == hash file . write self . sort . to_s file . close rescue... | Write changes to the file |
19,110 | def loadfile valid_existing_file? ( @file ) results = Threshold :: Parser . new ( @file ) @stored_hash = results . filehash results . caps . each do | result | builder = Threshold :: Builder . new ( result ) self << builder . build end end | Append in the thresholds . conf file to current collection |
19,111 | def valid? begin self . each do | threshold | if threshold . respond_to? ( :valid? ) return false unless threshold . valid? else raise InvalidThresholdsObject , "Container object has unknown objects" end end return true rescue InvalidThresholdsObject return false end end | Check if all objects in the Threshold Instance report . valid? |
19,112 | def uniq ( & blk ) if block_given? Thresholds . new ( @thresholds . uniq ( & blk ) ) else Thresholds . new ( @thresholds . uniq { | lineitem | lineitem . to_s ( true ) } ) end end | Uniques by default to printable output Returns a new Threshold Object |
19,113 | def suppressions ( & blk ) if block_given? self . suppressions . select ( & blk ) else Thresholds . new ( @thresholds . select { | t | t . class . to_s == "Threshold::Suppression" } ) end end | Returns a new Threshold Object with just suppressions |
19,114 | def event_filters ( & blk ) if block_given? self . event_filters . select ( & blk ) else Thresholds . new ( @thresholds . select { | t | t . class . to_s == "Threshold::EventFilter" } ) end end | Returns a new Threshold Object with just event_filters |
19,115 | def rate_filters ( & blk ) if block_given? self . rate_filters . select ( & blk ) else Thresholds . new ( @thresholds . select { | t | t . class . to_s == "Threshold::RateFilter" } ) end end | Returns a new Threshold Object with just rate_filters |
19,116 | def count_issue ( condition ) raise Backlog :: API :: ArgumentError , "must specify 'projectId'" unless condition . has_key? "projectId" condition = Backlog :: Object :: FindCondition . new ( condition ) self . call ( "backlog.countIssue" , condition . to_h ) end | Hash - > Integer |
19,117 | def write ( file_name , options = { } ) if file_name . is_a? ( String ) w = NWrite . new ( self , file_name , options ) w . write @write_success = w . success add_msg ( w . msg ) if w . msg . length > 0 else raise ArgumentError , "Invalid file_name. Expected String, got #{file_name.class}." end end | Passes the NObject to the DWrite class which writes out the header and image to the specified file . |
19,118 | def read ( string , options = { } ) if string . is_a? ( String ) @string = string r = NRead . new ( string , options ) if r . success @read_success = true @header = r . hdr @extended_header = r . extended_header if r . image_narray @image = r . image_narray elsif r . image_rubyarray @image = r . image_rubyarray end els... | Returns a NIFTI object by reading and parsing the specified file . This is accomplished by initializing the NRead class which loads NIFTI information . |
19,119 | def duplicate new_sheet = QuestionSheet . new ( self . attributes ) new_sheet . label = self . label + ' - COPY' new_sheet . save ( :validate => false ) self . pages . each do | page | page . copy_to ( new_sheet ) end new_sheet end | Pages get duplicated Question elements get associated non - question elements get cloned |
19,120 | def rubylog_unify other if @bound rubylog_dereference . rubylog_unify ( other ) do yield end else other = other . rubylog_dereference if other . is_a? Rubylog :: Variable ( yield ; return ) if self . equal? other other . append_guards guards do bind_to other do yield end end else bind_to other do if guards . all? { | g... | Unifies the receiver with another value . |
19,121 | def send_invite return if self . email . blank? application = self . applicant_answer_sheet Notifier . deliver_notification ( self . email , application . email , "Reference Invite" , { 'reference_full_name' => self . name , 'applicant_full_name' => application . name , 'applicant_email' => application . email , 'appli... | send email invite |
19,122 | def generate_i return ( begin bytes = ( time_low << 96 ) + ( time_mid << 80 ) + ( time_hi_and_version << 64 ) + ( clock_seq_hi_and_reserved << 56 ) + ( clock_seq_low << 48 ) for i in 0 .. 5 bytes += ( nodes [ i ] << ( 40 - ( i * 8 ) ) ) end bytes end ) end | Generates an integer representation for this UUID . |
19,123 | def authorize_url ( opts = { } ) opts [ :redirect_uri ] ||= DEFAULT_REDIRECT_URI opts [ :scope ] ||= "basic netdisk super_msg" oauth_client . auth_code . authorize_url ( scope : opts [ :scope ] , redirect_uri : opts [ :redirect_uri ] ) end | = begin rdoc OAuth2 + authorize_url + |
19,124 | def token! ( authorization_code , opts = { } ) opts [ :redirect_uri ] ||= DEFAULT_REDIRECT_URI self . access_token = oauth_client . auth_code . get_token ( authorization_code , redirect_uri : opts [ :redirect_uri ] ) end | = begin rdoc OAuth get_token method |
19,125 | def refresh_token! ( refresh_token ) old_token = OAuth2 :: AccessToken . new ( oauth_client , '' , refresh_token : refresh_token ) self . access_token = old_token . refresh! end | = begin rdoc OAuth refresh_token method |
19,126 | def stub object , stub , visibility = nil , & proc [ Symbol , String , Hash ] . include? ( stub . class ) || raise ( ArgumentError , 'a Symbol, String or Hash expected' ) if stub . is_a? ( Hash ) return hash_stub ( object , stub , visibility , & proc ) elsif stub =~ / \. / return chained_stub ( object , stub , visibili... | stubbing given method and keeps original visibility |
19,127 | def stubs object , * stubs , & proc MiniSpec :: Mocks :: MultipleStubsProxy . new ( stubs . map { | s | stub ( object , s , & proc ) } ) end | same as stub except it defines multiple stubs at once |
19,128 | def to_request card = { number_token : self . number_token , cardholder_name : self . cardholder_name , security_code : self . security_code , brand : self . brand , expiration_month : self . expiration_month , expiration_year : self . expiration_year } return card end | Nova instancia da classe Card |
19,129 | def post_init ( * args ) logger . info "got connection from #{remote_ip}" @lt2_delimiter = "\r\n" @ircd = IRCD . new ( self , options ) if options [ :ssl ] logger . info "starting TLS for #{remote_ip}" start_tls ( :cert_chain_file => options [ :ssl_cert ] , :private_key_file => options [ :ssl_private_key ] , :verify_pe... | Public callback once a server connection is established . |
19,130 | def generate_ULA ( mac , subnet_id = 0 , locally_assigned = true ) now = Time . now . utc ntp_time = ( ( now . to_i + 2208988800 ) << 32 ) + now . nsec system_id = '::/64' . to_ip . eui_64 ( mac ) . to_i key = [ ntp_time , system_id ] . pack ( 'QQ' ) global_id = Digest :: SHA1 . digest ( key ) . unpack ( 'QQ' ) . last ... | Generate an IPv6 Unique Local Address using the supplied system MAC address . Note that the MAC address is just used as a source of randomness so where you get it from is not important and doesn t restrict this ULA to just that system . See RFC4193 |
19,131 | def show_panel @tab_name = params [ :panel_name ] @panel_name = params [ :panel_name ] == "properties" ? "prop_sheet" : params [ :panel_name ] @all_pages = @question_sheet . pages . find ( :all ) @page = @question_sheet . pages . find ( params [ :id ] ) respond_to do | format | format . js end end | load panel all AJAX - like GET |
19,132 | def wrap ( obj ) ptr = FFI :: MemoryPointer . new ( :uint64 ) ptr . write_uint64 ( obj . object_id ) ptr end | Returns a pointer to the object_id of + obj + |
19,133 | def method_visibility object , method { public : :public_methods , protected : :protected_methods , private : :private_methods } . each_pair do | v , m | if v == :public return v if object . respond_to? ( method ) else return v if object . send ( m ) . include? ( method ) end end nil end | determines method s visibility |
19,134 | def any_match? label , matchers reject , select = matchers . partition { | m | m . is_a? ( Hash ) } rejected = rejected? ( label , reject ) if select . any? return select . find { | x | ( x == :* ) || match? ( label , x ) } && ! rejected end ! rejected end | checks whether given label matches any matcher . even if label matched it will return false if label matches some rejector . |
19,135 | def rejected? label , reject if reject . any? && ( x = reject . first [ :except ] ) if x . is_a? ( Array ) return true if x . find { | m | match? ( label , m ) } else return true if match? ( label , x ) end end false end | checks whether given label matches any rejector . |
19,136 | def match? label , x x . is_a? ( Regexp ) ? label . to_s =~ x : label == x end | compare given label to given expression . if expression is a Regexp comparing using = ~ . otherwise == are used |
19,137 | def uri_with_signature separator = if request_parser . query_params? then '&' else '?' end encoded_signature = signature . extend ( UriSigner :: Helpers :: String ) . escaped "%s%s_signature=%s" % [ self . uri , separator , encoded_signature ] end | Returns the URI with the signature appended to the query string |
19,138 | def pluralize ( n , * variants ) raise ArgumentError , "Must have a Numeric as a first parameter" unless n . is_a? ( Numeric ) raise ArgumentError , "Must have 3 variants for pluralization" if variants . size < 3 variants_hash = pluralization_variants_to_hash ( * variants ) I18n . backend . send ( :pluralize , LOCALE ,... | Simple pluralization proxy |
19,139 | def set_response ( values , app ) values = Array . wrap ( values ) if ! object_name . blank? and ! attribute_name . blank? object = object_name == 'application' ? app : eval ( "app." + object_name ) unless object . present? if object_name . include? ( '.' ) objects = object_name . split ( '.' ) object = eval ( "app." +... | set answers from posted response |
19,140 | def save_response ( answer_sheet ) unless @answers . nil? for answer in @answers if answer . is_a? ( Answer ) answer . answer_sheet_id = answer_sheet . id answer . save! end end end unless @mark_for_destroy . nil? for answer in @mark_for_destroy answer . destroy end @mark_for_destroy . clear end rescue TypeError raise ... | save this question s |
19,141 | def has_response? ( answer_sheet = nil ) if answer_sheet . present? answers = responses ( answer_sheet ) else answers = Answer . where ( :question_id => self . id ) end return false if answers . length == 0 answers . each do | answer | value = answer . is_a? ( Answer ) ? answer . value : answer return true if ( value .... | has any sort of non - empty response? |
19,142 | def << ( other ) case other when String other . each_char do | char | byte = char_to_byte ( char ) @chars [ byte ] = char super ( byte ) end return self when Integer super ( other ) else raise ( TypeError , "can only append Strings and Integers" ) end end | Adds a character to the set . |
19,143 | def include_char? ( char ) unless char . empty? @chars . has_value? ( char ) || include_byte? ( char_to_byte ( char ) ) else false end end | Determines if a character is contained within the character set . |
19,144 | def each_random_char ( n , & block ) return enum_for ( :each_random_char , n ) unless block_given? each_random_byte ( n ) { | byte | yield @chars [ byte ] } end | Pass random characters to a given block . |
19,145 | def random_bytes ( length ) if ( length . kind_of? ( Array ) || length . kind_of? ( Range ) ) Array . new ( length . sort_by { rand } . first ) { random_byte } else Array . new ( length ) { random_byte } end end | Creates an Array of random bytes from the character set . |
19,146 | def random_distinct_bytes ( length ) if ( length . kind_of? ( Array ) || length . kind_of? ( Range ) ) self . entries . sort_by { rand } . slice ( 0 ... ( length . sort_by { rand } . first ) ) else self . entries . sort_by { rand } . slice ( 0 ... length ) end end | Creates an Array of random non - repeating bytes from the character set . |
19,147 | def strings_in ( data , options = { } , & block ) unless block if options [ :offsets ] found = { } block = lambda { | offset , substring | found [ offset ] = substring } else found = [ ] block = lambda { | substring | found << substring } end strings_in ( data , options , & block ) return found end min_length = options... | Finds sub - strings within given data that are made of characters within the character set . |
19,148 | def has_offers_model ( has_offers_class_name ) has_offers_class = "HasOffers::#{has_offers_class_name}" . constantize class_eval do define_method ( "has_offers_create" ) do if respond_to? :has_offer_id response = has_offers_class . create ( has_offers_params ) if response . success? if response . data . is_a? Hash self... | requires that your model has the column has_offer_id requires that you implement the method has_offers_params within your model |
19,149 | def inner_avps ( name ) code , _type , _vendor = AVPNames . get ( name ) grouped_value . select { | a | a . code == code } end | For a grouped AVP returns all AVPs it contains with this name . |
19,150 | def ip_address = ( value ) bytes = if value . ipv4? [ 1 ] . pack ( 'n' ) else [ 2 ] . pack ( 'n' ) end bytes += value . hton @content = bytes end | Sets this AVP s byte data to an Address . |
19,151 | def double * args , & proc name = args . first . is_a? ( Hash ) ? nil : args . shift object = Object . new object . define_singleton_method ( :__ms__double_instance ) { true } object . define_singleton_method ( :inspect ) { name } if name hashes , rest = args . partition { | s | s . is_a? ( Hash ) } hashes . each { | h... | creates a double object . if one or more arguments given first argument will be used as name unless it is a Hash . arguments that goes after first one are treated as stubs . |
19,152 | def convert ( remove_ns = false ) organization = @gateway . fetch_organization [ 'organization' ] builder = Nokogiri :: XML :: Builder . new ( encoding : 'UTF-8' ) builder [ :ofx ] . OFX ( 'xmlns:ofx' => 'http://ofx.net/types/2003/04' ) do | xml | add_signonmsgsrsv1_block xml xml . BANKMSGSRSV1 do xml . parent . namesp... | valid_ofx = false removes the namespaces |
19,153 | def connect log ( "connect" ) ret = Lib :: Rados . rados_connect ( handle ) raise SystemCallError . new ( "connect to cluster failed" , - ret ) if ret < 0 end | helper methods below |
19,154 | def define actual_name = Hash === name ? name . keys . first : name unless :: Rake . application . last_comment desc "Run JShint" end task name do unless js_file_list . empty? result = Jshintrb :: report ( js_file_list , @options , @globals , STDERR ) if result . size > 0 abort ( "JSHint check failed" ) if fail_on_erro... | Defines a new task using the name + name + . |
19,155 | def split_ints ( secret ) result = [ ] secret . split ( '' ) . map { | x | data = x . unpack ( "H*" ) [ 0 ] "0" * ( data . size % 2 ) + data } . join ( "" ) . scan ( / / ) { | segment | result . push ( segment + "0" * ( 64 - segment . size ) ) . hex } return result end | split_ints and merge_ints converts between string and integer array where the integer is right - padded until it fits a 256 bit integer . |
19,156 | def inherit! ( order ) self . bill_address ||= order . bill_address self . ship_address ||= order . ship_address self . payment ||= order . payment self . shipments = order . shipments if shipments . empty? stated? ( order . state ) ? save! : next_state! end | Inherit from other Order |
19,157 | def duplicate ( page , parent = nil ) new_element = self . class . new ( self . attributes ) case parent . class . to_s when ChoiceField new_element . conditional_id = parent . id when QuestionGrid , QuestionGridWithTotal new_element . question_grid_id = parent . id end new_element . save ( :validate => false ) PageEle... | copy an item and all it s children |
19,158 | def decode ( html ) html . gsub ( ENTITIES :: REGEXP ) { if $1 if ENTITIES :: MAP [ $1 ] ENTITIES :: MAP [ $1 ] else $& end elsif $2 [ $2 . to_i ( 10 ) ] . pack ( 'U' ) elsif $3 [ $3 . to_i ( 16 ) ] . pack ( 'U' ) else $& end } end | decode html entity |
19,159 | def notification ( p_recipients , p_from , template_name , template_params = { } , options = { } ) email_template = EmailTemplate . find_by_name ( template_name ) if email_template . nil? raise "Email Template #{template_name} could not be found" else @recipients = p_recipients @from = p_from @subject = Liquid :: Templ... | call Notifier . deliver_notification |
19,160 | def find_item ( name , item_type = nil ) link = find_item_link ( name ) item = VCloudSdk :: CatalogItem . new ( @session , link ) check_item_type ( item , item_type ) item end | Find catalog item from catalog by name and type . If item_type is set to nil returns catalog item as long as its name match . Raises an exception if catalog is not found . Raises ObjectNotFoundError if an item matching the name and type is not found . Otherwise returns the catalog item . |
19,161 | def set_endpoint if ambiente == :producao return GetnetApi :: Configure :: URL [ :producao ] elsif ambiente == :homologacao return GetnetApi :: Configure :: URL [ :homologacao ] else return GetnetApi :: Configure :: URL [ :sandbox ] end end | Retornar a url conforme o ambiente |
19,162 | def signature core_signature = [ self . http_method , self . encoded_base_uri ] core_signature << self . encoded_query_params if self . query_params? core_signature . join ( self . separator ) end | Create a new RequestSignature instance |
19,163 | def to_s parts = @query_hash . sort . inject ( [ ] ) do | arr , ( key , value ) | if value . kind_of? ( Array ) value . each do | nested | arr << "%s=%s" % [ key , nested ] end else arr << "%s=%s" % [ key , value ] end arr end parts . join ( '&' ) end | Creates a new QueryHashParser instance |
19,164 | def sfind ( sexp , specs ) specs . inject ( sexp ) do | node , spec | return NotFound if node . nil? if spec . is_a? ( Symbol ) && node . type == spec node elsif spec . is_a? ( Integer ) && node . children . length > spec node . children [ spec ] elsif spec . is_a? ( Array ) node . children . grep ( AST :: Node ) . fla... | Traverse into sexp by type and child position |
19,165 | def helper helper , opts = { } , & proc proc || raise ( ArgumentError , 'block is missing' ) helpers [ helper ] = [ proc , opts ] end | define custom assertion helpers . |
19,166 | def symbol_thrown? expected_symbol , expected_value , context , & block thrown_symbol , thrown_value = catch_symbol ( expected_symbol , & block ) if context [ :right_proc ] expected_symbol && raise ( ArgumentError , 'Both arguments and block given. Please use either one.' ) return MiniSpec :: ThrowInspector . thrown_as... | checks whether given block throws a symbol and if yes compare it with expected one . if a optional value given it will be compared to thrown one . |
19,167 | def catch_symbol expected_symbol , & block thrown_symbol , thrown_value = nil begin if expected_symbol thrown_value = catch :__ms__nothing_thrown do catch expected_symbol do block . call throw :__ms__nothing_thrown , :__ms__nothing_thrown end end thrown_symbol = expected_symbol unless thrown_value == :__ms__nothing_thr... | calling given block and catching thrown symbol if any . |
19,168 | def extract_thrown_symbol exception return unless exception . is_a? ( Exception ) return unless s = exception . message . scan ( / \W \w / ) . flatten [ 0 ] s . to_sym end | extract thrown symbol from given exception |
19,169 | def find_fields rowname row = row_by_name ( rowname ) fields = ( row ? row . fields : [ ] ) fields . fill ( nil , fields . size , header . size - 1 - fields . size ) end | Find a record by rowname and return the fields . Empty fields are nils . |
19,170 | def checkout ( & b ) spec = { block : b , parent : :: Fiber . current } if @pool . empty? raise "The fiber queue has been overflowed" if @queue . size > @pool_queue_size @queue . push spec return end @pool . shift . tap do | fiber | @reserved [ fiber . object_id ] = spec fiber . resume ( spec ) end self end | Initialize fiber s pool Borrow fiber from the pool and call the block inside |
19,171 | def fiber_entry ( spec ) loop do raise "wrong spec in fiber block" unless spec . is_a? ( Hash ) begin before! ( spec ) spec [ :block ] . call after! ( spec ) rescue StandardError => e if error . empty? raise Fibre :: FiberError . new ( e ) else error! ( e ) end end unless @queue . empty? spec = @queue . shift next end ... | There is entrypoint running fibers |
19,172 | def checkin ( result = nil ) @reserved . delete :: Fiber . current . object_id @pool . unshift :: Fiber . current :: Fiber . yield end | Return the fiber into the pool |
19,173 | def anonymous_function ( block ) lambda do | * args | raise ArgumentError , "missing node" if args . empty? @tree [ :Anonymous ] . new block . call ( @tree , args . last ) end end | Creates a JavaScript anonymous function from a Ruby block |
19,174 | def extend_js ( mod ) extend mod mod . public_instance_methods . each do | method_name | add_function ( sym_to_css ( method_name ) ) { | tree , cxt | send method_name . to_sym , unquote ( cxt . toCSS ( ) ) } end end | Adds all of a module s public instance methods as Less functions |
19,175 | def append ( node ) if node . is_a? ( EndTag ) return if empty_tag? ( node . name ) po = @pos while po . parent and po . name != node . name po = po . parent end if po . name == node . name @pos = po . parent end else rexml = to_rexml ( node ) if rexml . is_a? ( REXML :: Element ) and @pos == @doc and @doc . root if @d... | append node to document |
19,176 | def to_request obj , type payment = { seller_id : GetnetApi . seller_id . to_s , amount : self . amount . to_i , currency : self . currency . to_s , order : self . order . to_request , customer : self . customer . to_request ( :payment ) , } if type == :boleto payment . merge! ( { "boleto" => obj . to_request , } ) els... | Nova instancia da classe Cliente |
19,177 | def diff ( path , options = { } ) raise Svn :: Error , "cannot diff directory #{path}@#{to_s}" if dir? path other = options [ :with ] if options [ :with ] . is_a? Root other = repo . revision ( options [ :with ] ) if options [ :with ] . is_a? Numeric other ||= repo . revision ( to_i - 1 ) return other . diff ( path , :... | diffs + path + with another revision . if no revision is specified the previous revision is used . |
19,178 | def resp_with_token mtd , path , form fail unless path . start_with? ?/ timeout = 5 begin reddit_resp mtd , "https://oauth.reddit.com" + path , form , { "Authorization" => "bearer #{token}" , "User-Agent" => "bot/#{@user_agent || @name}/#{RedditBot::VERSION} by /u/nakilon" , } rescue NetHTTPUtils :: Error => e sleep ti... | def update_captcha return if |
19,179 | def languages unless @languages_cache response = call_request ( :get_languages ) languages = response . to_hash [ :get_languages_response ] [ :return ] [ :item ] [ 1 ] [ :value ] [ :item ] @languages_cache = Hash [ create_dict ( languages ) . sort_by { | k , v | k . to_i } ] end return @languages_cache end | Get a list of supported languages and cache it . |
19,180 | def to_request boleto = { our_number : self . our_number , document_number : self . document_number , expiration_date : self . expiration_date , instructions : self . instructions , provider : self . provider } return boleto end | Nova instancia da classe Boleto |
19,181 | def all_avps_by_name ( name ) code , _type , vendor = Internals :: AVPNames . get ( name ) all_avps_by_code ( code , vendor ) end | Returns all AVPs with the given name . Only covers top - level AVPs - it won t look inside Grouped AVPs . |
19,182 | def encode ( s ) return s if s . nil? return s if s . valid_encoding? if s . force_encoding ( "iso-8859-1" ) . valid_encoding? return s . encode ( 'utf-8' , 'iso-8859-1' ) end s end | Handle any string encoding |
19,183 | def retrieve_page ( rurl = nil ) durl = rurl || url return nil unless durl durl = filter_url ( durl ) if self . respond_to? ( :filter_url ) self . class . retrieve_session ||= WebPageParser :: HTTP :: Session . new encode ( self . class . retrieve_session . get ( durl ) ) end | request the page from the server and return the raw contents |
19,184 | def title return @title if @title if matches = class_const ( :TITLE_RE ) . match ( page ) @title = matches [ 1 ] . to_s . strip title_processor @title = decode_entities ( @title ) end end | The title method returns the title of the web page . |
19,185 | def content return @content if @content matches = class_const ( :CONTENT_RE ) . match ( page ) if matches @content = class_const ( :KILL_CHARS_RE ) . gsub ( matches [ 1 ] . to_s , '' ) content_processor @content . collect! { | p | decode_entities ( p . strip ) } @content . delete_if { | p | p == '' or p . nil? } end @c... | The content method returns the important body text of the web page . |
19,186 | def [] ( index ) if ( index . is_a? ( Fixnum ) && index >= self . shape [ 0 ] ) || ( index . is_a? ( Range ) && index . last >= self . shape [ 0 ] ) raise IndexError . new ( "Index over bounds" ) elsif self . shape . count == 1 if index . is_a? ( Range ) value = [ ] index . each { | i | value << self . array_image [ ge... | Creates an NImage instance . |
19,187 | def []= ( index , value ) if self . shape . count != 1 or index >= self . shape [ 0 ] raise IndexError . new ( "You can only set values for array values" ) else @array_image [ get_index_value ( index ) ] = value end end | Set the value for an element of the dataset |
19,188 | def post ( params , answer_sheet ) questions_indexed = @questions . index_by { | q | q . id } params ||= { } params . each do | question_id , response | next if questions_indexed [ question_id . to_i ] . nil? questions_indexed [ question_id . to_i ] . set_response ( posted_values ( response ) , answer_sheet ) end end | associate answers from database with a set of elements update with responses from form |
19,189 | def posted_values ( param ) if param . kind_of? ( Hash ) and param . has_key? ( 'year' ) and param . has_key? ( 'month' ) year = param [ 'year' ] month = param [ 'month' ] if month . blank? or year . blank? values = '' else values = [ Date . new ( year . to_i , month . to_i , 1 ) . strftime ( '%m/%d/%Y' ) ] end elsif p... | convert posted response to a question into Array of values |
19,190 | def mock object , method , visibility = nil , & proc if method . is_a? ( Hash ) proc && raise ( ArgumentError , 'Both Hash and block given. Please use either one.' ) method . each_pair { | m , r | mock ( object , m , visibility , & proc { r } ) } return MiniSpec :: Mocks :: HashedStub end visibility ||= MiniSpec :: Uti... | the mock is basically a stub with difference it will also add a expectation . that s it a mock will stub a method on a object and will expect that stub to be called before test finished . |
19,191 | def proxy object , method_name return if object . respond_to? ( :__ms__double_instance ) return if ( x = @__ms__stubs__originals ) && ( x = x [ object ] ) && x [ method_name ] proxies = ( @__ms__proxies [ object ] ||= [ ] ) return if proxies . include? ( method_name ) proxies << method_name if method_name == :nil? || o... | overriding given method of given object with a proxy so MiniSpec can later check whether given method was called . |
19,192 | def index @answer_sheets = AnswerSheet . find ( :all , :order => 'created_at' ) @question_sheets = QuestionSheet . find ( :all , :order => 'label' ) . map { | s | [ s . label , s . id ] } end | list existing answer sheets |
19,193 | def create_job ( project_id , data , opts = { } ) data , _status_code , _headers = create_job_with_http_info ( project_id , data , opts ) return data end | Create a new job |
19,194 | def get_job ( project_id , job_id , opts = { } ) data , _status_code , _headers = get_job_with_http_info ( project_id , job_id , opts ) return data end | Get QC job |
19,195 | def get_project ( project_id , opts = { } ) data , _status_code , _headers = get_project_with_http_info ( project_id , opts ) return data end | Get project by Id |
19,196 | def list_jobs ( project_id , opts = { } ) data , _status_code , _headers = list_jobs_with_http_info ( project_id , opts ) return data end | Get jobs form projects |
19,197 | def belongs_to ( table , options = { } ) options = options . merge ( :references => table ) options [ :on_delete ] = options . delete ( :dependent ) if options . has_key? ( :dependent ) column ( "#{table.to_s.singularize}_id" . to_sym , :integer , options ) end | Some people liked this ; personally I ve decided against using it but I ll keep it nonetheless |
19,198 | def read_all content = String . new while bytes = read and ! bytes . empty? content << bytes end content end | reads the stream contents into a String object |
19,199 | def to_string_io content = StringIO . new while bytes = read and ! bytes . empty? content . write ( bytes ) end content . rewind content end | reads the stream contents into a StringIO object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.