idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
5,800 | def get_typeof_error name pspec = get_pspec name raise Vips :: Error unless pspec pspec [ :value ] [ :value_type ] end | return a gtype raise an error on not found |
5,801 | def set value gtype = self [ :gtype ] fundamental = :: GObject :: g_type_fundamental gtype case gtype when GBOOL_TYPE :: GObject :: g_value_set_boolean self , ( value ? 1 : 0 ) when GINT_TYPE :: GObject :: g_value_set_int self , value when GUINT64_TYPE :: GObject :: g_value_set_uint64 self , value when GDOUBLE_TYPE :: ... | Set the value of a GValue . The value is converted to the type of the GValue if possible . |
5,802 | def get gtype = self [ :gtype ] fundamental = :: GObject :: g_type_fundamental gtype result = nil case gtype when GBOOL_TYPE result = :: GObject :: g_value_get_boolean ( self ) != 0 ? true : false when GINT_TYPE result = :: GObject :: g_value_get_int self when GUINT64_TYPE result = :: GObject :: g_value_get_uint64 self... | Get the value of a GValue . The value is converted to a Ruby type in the obvious way . |
5,803 | def call if rows . empty? report . done! return report end report . in_progress! persist_rows! report . done! report rescue ImportAborted report . aborted! report end | Persist the rows model and return a Report |
5,804 | def sanitize_cells ( rows ) rows . map do | cells | cells . map do | cell | cell ? cell . strip : "" end end end | Remove trailing white spaces and ensure we always return a string |
5,805 | def model @model ||= begin model = find_or_build_model set_attributes ( model ) after_build_blocks . each { | block | instance_exec ( model , & block ) } model end end | The model to be persisted |
5,806 | def set_attribute ( model , column , csv_value ) column_definition = column . definition if column_definition . to && column_definition . to . is_a? ( Proc ) to_proc = column_definition . to case to_proc . arity when 1 model . public_send ( "#{column_definition.name}=" , to_proc . call ( csv_value ) ) when 2 to_proc . ... | Set the attribute using the column_definition and the csv_value |
5,807 | def errors Hash [ model . errors . map do | attribute , errors | if column_name = header . column_name_for_model_attribute ( attribute ) [ column_name , errors ] else [ attribute , errors ] end end ] end | Error from the model mapped back to the CSV header if we can |
5,808 | def match? ( column_name , search_query = ( as || name ) ) return false if column_name . nil? downcased_column_name = column_name . downcase underscored_column_name = downcased_column_name . gsub ( / \s / , '_' ) case search_query when Symbol underscored_column_name == search_query . to_s when String downcased_column_n... | Return true if column definition matches the column name passed in . |
5,809 | def generate ( template_options , color_option ) templates . each do | src , dst | source = @source_path . join ( src ) destination = @target_path . join ( dst ) . to_s next unless :: File . exist? ( source ) within_root_path do TTY :: File . copy_file ( source , destination , { context : template_options } . merge ( c... | Process templates by injecting vars and moving to location |
5,810 | def load_from ( gemspec_path , pattern ) Gem . refresh spec = Gem :: Specification . load ( gemspec_path ) dependencies = spec . runtime_dependencies . concat ( spec . development_dependencies ) dependencies . each do | gem | gem_name = gem . name [ pattern ] next if gem_name . to_s . empty? register ( gem_name , Plugi... | Loads gemspec from a file and registers gems matching pattern . |
5,811 | def names plugins . reduce ( { } ) do | hash , plugin | hash [ plugin . name ] = plugin hash end end | Return a list of all plugin names as strings |
5,812 | def relative_path_from ( root_path , path ) project_path = Pathname . new ( path ) return project_path if project_path . relative? project_path . relative_path_from ( root_path ) end | Extract a relative path for the app |
5,813 | def authenticate ( options = nil ) if user_and_pass? ( options ) req = https_request ( self . host ) user = self . username || options [ :username ] pass = self . password || options [ :password ] path = encode_path_with_params ( '/services/oauth2/token' , :grant_type => 'password' , :client_id => self . client_id , :c... | Returns a new client object . _options_ can be one of the following |
5,814 | def list_sobjects result = http_get ( "/services/data/v#{self.version}/sobjects" ) if result . is_a? ( Net :: HTTPOK ) JSON . parse ( result . body ) [ "sobjects" ] . collect { | sobject | sobject [ "name" ] } elsif result . is_a? ( Net :: HTTPBadRequest ) raise SalesForceError . new ( result ) end end | Returns an Array of Strings listing the class names for every type of _Sobject_ in the database . Raises SalesForceError if an error occurs . |
5,815 | def trending_topics result = http_get ( "/services/data/v#{self.version}/chatter/topics/trending" ) result = JSON . parse ( result . body ) result [ "topics" ] . collect { | topic | topic [ "name" ] } end | Returns an array of trending topic names . |
5,816 | def record_from_hash ( data ) attributes = data . delete ( 'attributes' ) new_record = find_or_materialize ( attributes [ "type" ] ) . new data . each do | name , value | field = new_record . description [ 'fields' ] . find do | field | key_from_label ( field [ "label" ] ) == name || field [ "name" ] == name || field [... | Converts a Hash of object data into a concrete SObject |
5,817 | def check_symbol_to_proc return unless method_call . block_argument_names . count == 1 return if method_call . block_body . nil? return unless method_call . block_body . sexp_type == :call return if method_call . arguments . count > 0 body_method_call = MethodCall . new ( method_call . block_body ) return unless body_m... | Need to refactor fukken complicated conditions . |
5,818 | def scheduled? ( job_or_job_id ) job , _ = fetch ( job_or_job_id ) ! ! ( job && job . unscheduled_at . nil? && job . next_time != nil ) end | Returns true if this job is currently scheduled . |
5,819 | def merge_base ( * args ) opts = args . last . is_a? ( Hash ) ? args . pop : { } arg_opts = opts . map { | k , v | "--#{k}" if v } . compact + args command ( 'merge-base' , arg_opts ) end | git merge - base ... . Returns common ancestor for all passed commits |
5,820 | def start! self . map = nil map_storage . clear! map_storage . dump ( map . metadata . to_h ) strategies . reverse . each ( & :after_start ) self . started = true end | Registers strategies and prepares metadata for execution map |
5,821 | def refresh_for_case ( example ) map << strategies . run ( ExampleGroupMap . new ( example ) , example ) { example . run } check_dump_threshold end | Runs example and collects execution map for it |
5,822 | def finalize! return unless started strategies . each ( & :before_finalize ) return unless map . size . positive? example_groups = ( configuration . compact_map? ? MapCompactor . compact_map! ( map ) : map ) . example_groups map_storage . dump ( example_groups ) end | Finalizes strategies and saves map |
5,823 | def add_resource ( type , rsrc , name = nil ) if name . nil? rsrc_name = self . resources ( type ) . key ( rsrc ) return rsrc_name if rsrc_name end name ||= new_id ( type ) target = self . is_a? ( Resources ) ? self : ( self . Resources ||= Resources . new ) rsrc_dict = ( target [ type ] and target [ type ] . solve ) |... | Adds a resource of the specified _type_ in the current object . If _name_ is not specified a new name will be automatically generated . |
5,824 | def each_resource ( type ) target = self . is_a? ( Resources ) ? self : ( self . Resources ||= Resources . new ) rsrc = ( target [ type ] and target [ type ] . solve ) return enum_for ( __method__ , type ) { rsrc . is_a? ( Dictionary ) ? rsrc . length : 0 } unless block_given? return unless rsrc . is_a? ( Dictionary ) ... | Iterates over the resources by _type_ . |
5,825 | def resources ( type = nil ) if type . nil? self . extgstates . merge self . colorspaces . merge self . patterns . merge self . shadings . merge self . xobjects . merge self . fonts . merge self . properties else self . each_resource ( type ) . to_h end end | Returns a Hash of all resources in the object or only the specified _type_ . |
5,826 | def each_page ( browsed_nodes : [ ] , & block ) return enum_for ( __method__ ) { self . Count . to_i } unless block_given? if browsed_nodes . any? { | node | node . equal? ( self ) } raise InvalidPageTreeError , "Cyclic tree graph detected" end unless self . Kids . is_a? ( Array ) raise InvalidPageTreeError , "Kids mus... | Iterate through each page of that node . |
5,827 | def get_page ( n ) raise IndexError , "Page numbers are referenced starting from 1" if n < 1 raise IndexError , "Page not found" if n > self . Count . to_i self . each_page . lazy . drop ( n - 1 ) . first or raise IndexError , "Page not found" end | Get the n - th Page object in this node starting from 1 . |
5,828 | def each_content_stream contents = self . Contents return enum_for ( __method__ ) do case contents when Array then contents . length when Stream then 1 else 0 end end unless block_given? case contents when Stream then yield ( contents ) when Array then contents . each { | stm | yield ( stm . solve ) } end end | Iterates over all the ContentStreams of the Page . |
5,829 | def add_annotation ( * annotations ) self . Annots ||= [ ] annotations . each do | annot | annot . solve [ :P ] = self if self . indirect? self . Annots << annot end end | Add an Annotation to the Page . |
5,830 | def each_annotation annots = self . Annots return enum_for ( __method__ ) { annots . is_a? ( Array ) ? annots . length : 0 } unless block_given? return unless annots . is_a? ( Array ) annots . each do | annot | yield ( annot . solve ) end end | Iterate through each Annotation of the Page . |
5,831 | def add_flash_application ( swfspec , params = { } ) options = { windowed : false , transparent : false , navigation_pane : false , toolbar : false , pass_context_click : false , activation : Annotation :: RichMedia :: Activation :: PAGE_OPEN , deactivation : Annotation :: RichMedia :: Deactivation :: PAGE_CLOSE , flas... | Embed a SWF Flash application in the page . |
5,832 | def metadata metadata_stm = self . Catalog . Metadata if metadata_stm . is_a? ( Stream ) doc = REXML :: Document . new ( metadata_stm . data ) info = { } doc . elements . each ( '*/*/rdf:Description' ) do | description | description . attributes . each_attribute do | attr | case attr . prefix when 'pdf' , 'xap' info [ ... | Returns a Hash of the information found in the metadata stream |
5,833 | def create_metadata ( info = { } ) skeleton = <<-XMP \xef \xbb \xbf XMP xml = if self . Catalog . Metadata . is_a? ( Stream ) self . Catalog . Metadata . data else skeleton end doc = REXML :: Document . new ( xml ) desc = doc . elements [ '*/*/rdf:Description' ] info . each do | name , value | elt = REXML :: Element . ... | Modifies or creates a metadata stream . |
5,834 | def trailer if @revisions . last . trailer . dictionary? trl = @revisions . last . trailer else trl = @revisions . last . xrefstm end raise InvalidPDFError , "No trailer found" if trl . nil? trl end | Returns the current trailer . This might be either a Trailer or XRefStream . |
5,835 | def add_certificate ( certfile , attributes , viewable : false , editable : false ) if certfile . is_a? ( OpenSSL :: X509 :: Certificate ) x509 = certfile else x509 = OpenSSL :: X509 :: Certificate . new ( certfile ) end address_book = get_address_book cert = Certificate . new cert . Cert = x509 . to_der cert . ID = ad... | Add a certificate into the address book |
5,836 | def each_filter filters = self . Filter return enum_for ( __method__ ) do case filters when NilClass then 0 when Array then filters . length else 1 end end unless block_given? return if filters . nil? if filters . is_a? ( Array ) filters . each do | filter | yield ( filter ) end else yield ( filters ) end self end | Iterates over each Filter in the Stream . |
5,837 | def set_predictor ( predictor , colors : 1 , bitspercomponent : 8 , columns : 1 ) filters = self . filters layer = filters . index ( :FlateDecode ) or filters . index ( :LZWDecode ) if layer . nil? raise InvalidStreamObjectError , 'Predictor functions can only be used with Flate or LZW filters' end params = Filter :: L... | Set predictor type for the current Stream . Applies only for LZW and FlateDecode filters . |
5,838 | def decode! self . decrypt! if self . is_a? ( Encryption :: EncryptedStream ) return if decoded? filters = self . filters dparams = decode_params @data = @encoded_data . dup @data . freeze filters . each_with_index do | filter , layer | params = dparams [ layer ] . is_a? ( Dictionary ) ? dparams [ layer ] : { } if filt... | Uncompress the stream data . |
5,839 | def encode! return if encoded? filters = self . filters dparams = decode_params @encoded_data = @data . dup ( filters . length - 1 ) . downto ( 0 ) do | layer | params = dparams [ layer ] . is_a? ( Dictionary ) ? dparams [ layer ] : { } filter = filters [ layer ] if filter == :Crypt raise Filter :: Error , "Crypt filte... | Compress the stream data . |
5,840 | def import_object_from_document ( object ) obj_doc = object . document if obj_doc . equal? ( @document ) @document . delete_object ( object . reference ) if object . indirect? else object = object . export end object end | Preprocess the object in case it already belongs to a document . If the document is the same as the current object stream remove the duplicate object from our document . If the object comes from another document use the export method to create a version without references . |
5,841 | def to_utf8 detect_encoding utf16 = self . encoding . to_utf16be ( self . value ) utf16 . slice! ( 0 , Encoding :: UTF16BE :: BOM . size ) utf16 . encode ( "utf-8" , "utf-16be" ) end | Convert String object to an UTF8 encoded Ruby string . |
5,842 | def draw_polygon ( coords = [ ] , attr = { } ) load! stroke_color = attr . fetch ( :stroke_color , DEFAULT_STROKE_COLOR ) fill_color = attr . fetch ( :fill_color , DEFAULT_FILL_COLOR ) line_cap = attr . fetch ( :line_cap , DEFAULT_LINECAP ) line_join = attr . fetch ( :line_join , DEFAULT_LINEJOIN ) line_width = attr . ... | Draw a polygon from a array of coordinates . |
5,843 | def version_required max = [ "1.0" , 0 ] self . each_key do | field | attributes = self . class . fields [ field . value ] if attributes . nil? STDERR . puts "Warning: object #{self.class} has undocumented field #{field.value}" next end version = attributes [ :Version ] || '1.0' level = attributes [ :ExtensionLevel ] |... | Returns the version and level required by the current Object . |
5,844 | def set_indirect ( bool ) unless bool == true or bool == false raise TypeError , "The argument must be boolean" end if bool == false @no = @generation = 0 @document = nil @file_offset = nil end @indirect = bool self end | Creates a new PDF Object . |
5,845 | def copy saved_doc = @document saved_parent = @parent @document = @parent = nil copyobj = Marshal . load ( Marshal . dump ( self ) ) @document = saved_doc @parent = saved_parent copyobj . set_document ( saved_doc ) if copyobj . indirect? copyobj . parent = parent copyobj end | Deep copy of an object . |
5,846 | def cast_to ( type , parser = nil ) assert_cast_type ( type ) cast = type . new ( self . copy , parser ) cast . file_offset = @file_offset transfer_attributes ( cast ) end | Casts an object to a new type . |
5,847 | def reference raise InvalidObjectError , "Cannot reference a direct object" unless self . indirect? ref = Reference . new ( @no , @generation ) ref . parent = self ref end | Returns an indirect reference to this object . |
5,848 | def xrefs raise InvalidObjectError , "Cannot find xrefs to a direct object" unless self . indirect? raise InvalidObjectError , "Not attached to any document" if self . document . nil? @document . each_object ( compressed : true ) . flat_map { | object | case object when Stream object . dictionary . xref_cache [ self . ... | Returns an array of references pointing to the current object . |
5,849 | def export exported_obj = self . logicalize exported_obj . no = exported_obj . generation = 0 exported_obj . set_document ( nil ) if exported_obj . indirect? exported_obj . parent = nil exported_obj . xref_cache . clear exported_obj end | Creates an exportable version of current object . The exportable version is a copy of _self_ with solved references no owning PDF and no parent . References to Catalog or PageTreeNode objects have been destroyed . |
5,850 | def type name = ( self . class . name or self . class . superclass . name or self . native_type . name ) name . split ( "::" ) . last . to_sym end | Returns the symbol type of this Object . |
5,851 | def transfer_attributes ( target ) target . no , target . generation = @no , @generation target . parent = @parent if self . indirect? target . set_indirect ( true ) target . set_document ( @document ) end target end | Copy the attributes of the current object to another object . Copied attributes do not include the file offset . |
5,852 | def resolve_all_references ( obj , browsed : [ ] , cache : { } ) return obj if browsed . include? ( obj ) browsed . push ( obj ) if obj . is_a? ( ObjectStream ) obj . each do | subobj | resolve_all_references ( subobj , browsed : browsed , cache : cache ) end end if obj . is_a? ( Stream ) resolve_all_references ( obj .... | Replace all references of an object by their actual object value . |
5,853 | def try_object_promotion ( obj ) return obj unless Origami :: OPTIONS [ :enable_type_propagation ] and @deferred_casts . key? ( obj . reference ) types = @deferred_casts [ obj . reference ] types = [ types ] unless types . is_a? ( :: Array ) cast_type = types . find { | type | type < obj . class } if cast_type obj = ob... | Attempt to promote an object using the deferred casts . |
5,854 | def signed? begin self . Catalog . AcroForm . is_a? ( Dictionary ) and self . Catalog . AcroForm . SigFlags . is_a? ( Integer ) and ( self . Catalog . AcroForm . SigFlags & InteractiveForm :: SigFlags :: SIGNATURES_EXIST != 0 ) rescue InvalidReferenceError false end end | Returns whether the document contains a digital signature . |
5,855 | def extract_signed_data ( digsig ) start_sig = digsig [ :Contents ] . file_offset stream = StringScanner . new ( self . original_data ) stream . pos = digsig [ :Contents ] . file_offset Object . typeof ( stream ) . parse ( stream ) end_sig = stream . pos stream . terminate r1 , r2 = digsig . ranges if r1 . begin != 0 o... | Verifies the ByteRange field of a digital signature and returned the signed data . |
5,856 | def update_values ( & b ) return enum_for ( __method__ ) unless block_given? return self . class . new self . transform_values ( & b ) if self . respond_to? ( :transform_values ) return self . class . new self . map ( & b ) if self . respond_to? ( :map ) raise NotImplementedError , "This object does not implement this ... | Returns a new compound object with updated values based on the provided block . |
5,857 | def update_values! ( & b ) return enum_for ( __method__ ) unless block_given? return self . transform_values! ( & b ) if self . respond_to? ( :transform_values! ) return self . map! ( & b ) if self . respond_to? ( :map! ) raise NotImplementedError , "This object does not implement this method" end | Modifies the compound object s values based on the provided block . |
5,858 | def linearized? begin first_obj = @revisions . first . objects . min_by { | obj | obj . file_offset } rescue return false end @revisions . size > 1 and first_obj . is_a? ( Dictionary ) and first_obj . has_key? :Linearized end | Returns whether the current document is linearized . |
5,859 | def delinearize! raise LinearizationError , 'Not a linearized document' unless self . linearized? prev_trailer = @revisions . first . trailer linear_dict = @revisions . first . objects . min_by { | obj | obj . file_offset } delete_hint_streams ( linear_dict ) last_trailer = ( @revisions . last . trailer ||= Trailer . n... | Tries to delinearize the document if it has been linearized . This operation is xrefs destructive should be fixed in the future to merge tables . |
5,860 | def delete_hint_streams ( linearization_dict ) hints = linearization_dict [ :H ] return unless hints . is_a? ( Array ) hints . each_slice ( 2 ) do | offset , _length | next unless offset . is_a? ( Integer ) stream = get_object_by_offset ( offset ) delete_object ( stream . reference ) if stream . is_a? ( Stream ) end en... | Strip the document from Hint streams given a linearization dictionary . |
5,861 | def follow doc = self . document if doc . nil? raise InvalidReferenceError , "Not attached to any document" end target = doc . get_object ( self ) if target . nil? and not Origami :: OPTIONS [ :ignore_bad_references ] raise InvalidReferenceError , "Cannot resolve reference : #{self}" end target or Null . new end | Returns the object pointed to by the reference . The reference must be part of a document . Raises an InvalidReferenceError if the object cannot be found . |
5,862 | def create_form ( * fields ) acroform = self . Catalog . AcroForm ||= InteractiveForm . new . set_indirect ( true ) self . add_fields ( * fields ) acroform end | Creates a new AcroForm with specified fields . |
5,863 | def each_field return enum_for ( __method__ ) do if self . form? and self . Catalog . AcroForm . Fields . is_a? ( Array ) self . Catalog . AcroForm . Fields . length else 0 end end unless block_given? if self . form? and self . Catalog . AcroForm . Fields . is_a? ( Array ) self . Catalog . AcroForm . Fields . each do |... | Iterates over each Acroform Field . |
5,864 | def create_security_handler ( version , revision , params ) doc_id = ( trailer_key ( :ID ) || generate_id ) . first handler = Encryption :: Standard :: Dictionary . new handler . Filter = :Standard handler . V = version handler . R = revision handler . Length = params [ :key_size ] handler . P = - 1 if revision >= 4 ha... | Installs the standard security dictionary marking the document as being encrypted . Returns the handler and the encryption key used for protecting contents . |
5,865 | def << ( object ) owner = object . document if owner and not owner . equal? ( self ) import object else add_to_revision ( object , @revisions . last ) end end | Adds a new object to the PDF file . If this object has no version number then a new one will be automatically computed and assignated to him . |
5,866 | def add_to_revision ( object , revision ) object . set_indirect ( true ) object . set_document ( self ) object . no , object . generation = allocate_new_object_number if object . no == 0 revision . body [ object . reference ] = object object . reference end | Adds a new object to a specific revision . If this object has no version number then a new one will be automatically computed and assignated to him . |
5,867 | def add_new_revision root = @revisions . last . trailer [ :Root ] unless @revisions . empty? @revisions << Revision . new ( self ) @revisions . last . trailer = Trailer . new @revisions . last . trailer . Root = root self end | Ends the current Revision and starts a new one . |
5,868 | def delete_object ( no , generation = 0 ) case no when Reference target = no when :: Integer target = Reference . new ( no , generation ) else raise TypeError , "Invalid parameter type : #{no.class}" end @revisions . each do | rev | rev . body . delete ( target ) end end | Remove an object . |
5,869 | def cast_object ( reference , type ) @revisions . each do | rev | if rev . body . include? ( reference ) object = rev . body [ reference ] return object if object . is_a? ( type ) if type < rev . body [ reference ] . class rev . body [ reference ] = object . cast_to ( type , @parser ) return rev . body [ reference ] en... | Casts a PDF object into another object type . The target type must be a subtype of the original type . |
5,870 | def search_object ( object , pattern , streams : true , object_streams : true ) result = [ ] case object when Stream result . concat object . dictionary . strings_cache . select { | str | str . match ( pattern ) } result . concat object . dictionary . names_cache . select { | name | name . value . match ( pattern ) } b... | Searches through an object possibly going into object streams . Returns an array of matching strings names and streams . |
5,871 | def load_object_at_offset ( revision , offset ) return nil if loaded? or @parser . nil? pos = @parser . pos begin object = @parser . parse_object ( offset ) return nil if object . nil? if self . is_a? ( Encryption :: EncryptedDocument ) make_encrypted_object ( object ) end add_to_revision ( object , revision ) ensure @... | Load an object from its given file offset . The document must have an associated Parser . |
5,872 | def make_encrypted_object ( object ) case object when String object . extend ( Encryption :: EncryptedString ) when Stream object . extend ( Encryption :: EncryptedStream ) when ObjectCache object . strings_cache . each do | string | string . extend ( Encryption :: EncryptedString ) end end end | Method called on encrypted objects loaded into the document . |
5,873 | def load_all_objects return if loaded? or @parser . nil? @revisions . each do | revision | if revision . xreftable? xrefs = revision . xreftable elsif revision . xrefstm? xrefs = revision . xrefstm else next end xrefs . each_with_number do | xref , no | self . get_object ( no ) unless xref . free? end end loaded! end | Force the loading of all objects in the document . |
5,874 | def physicalize ( options = { } ) @revisions . each do | revision | revision . objects . each do | obj | build_object ( obj , revision , options ) end end self end | Converts a logical PDF view into a physical view ready for writing . |
5,875 | def init catalog = ( self . Catalog = ( trailer_key ( :Root ) || Catalog . new ) ) @revisions . last . trailer . Root = catalog . reference loaded! self end | Instanciates basic structures required for a valid PDF file . |
5,876 | def build_xrefs ( objects ) lastno = 0 brange = 0 xrefs = [ XRef . new ( 0 , XRef :: FIRSTFREE , XRef :: FREE ) ] xrefsection = XRef :: Section . new objects . sort_by { | object | object . reference } . each do | object | if ( object . no - lastno ) . abs > 1 xrefsection << XRef :: Subsection . new ( brange , xrefs ) ... | Build a xref section from a set of objects . |
5,877 | def transform_values ( & b ) self . class . new self . map { | k , v | [ k . to_sym , b . call ( v ) ] } . to_h end | Returns a new Dictionary object with values modified by given block . |
5,878 | def transform_values! ( & b ) self . each_pair do | k , v | self [ k ] = b . call ( unlink_object ( v ) ) end end | Modifies the values of the Dictionary leaving keys unchanged . |
5,879 | def remove_xrefs @revisions . reverse_each do | rev | if rev . xrefstm? delete_object ( rev . xrefstm . reference ) end if rev . trailer . XRefStm . is_a? ( Integer ) xrefstm = get_object_by_offset ( rev . trailer . XRefStm ) delete_object ( xrefstm . reference ) if xrefstm . is_a? ( XRefStream ) end rev . xrefstm = re... | Tries to strip any xrefs information off the document . |
5,880 | def each_with_number return enum_for ( __method__ ) unless block_given? load! if @xrefs . nil? ranges = object_ranges xrefs = @xrefs . to_enum ranges . each do | range | range . each do | no | begin yield ( xrefs . next , no ) rescue StopIteration raise InvalidXRefStreamObjectError , "Range is bigger than number of ent... | Iterates over each XRef present in the stream passing the XRef and its object number . |
5,881 | def find ( no ) load! if @xrefs . nil? ranges = object_ranges index = 0 ranges . each do | range | return @xrefs [ index + no - range . begin ] if range . cover? ( no ) index += range . size end nil end | Returns an XRef matching this object number . |
5,882 | def field_widths widths = self . W unless widths . is_a? ( Array ) and widths . length == 3 and widths . all? { | w | w . is_a? ( Integer ) and w >= 0 } raise InvalidXRefStreamObjectError , "Invalid W field: #{widths}" end widths end | Check and return the internal field widths . |
5,883 | def guess_name ( sections ) if sections . size > 1 sections [ - 1 ] = 'rails_db' variable = sections . join ( "_" ) result = eval ( variable ) end rescue NameError sections . delete_at ( - 2 ) guess_name ( sections ) end | in case engine was added in namespace |
5,884 | def setup require 'key_master' require 'keyring_liberator' require 'pod/command/keys/set' require 'cocoapods/user_interface' require 'dotenv' ui = Pod :: UserInterface options = @user_options || { } current_dir = Pathname . pwd Dotenv . load project = options . fetch ( 'project' ) { CocoaPodsKeys :: NameWhisperer . get... | Returns true if all keys specified by the user are satisfied by either an existing keyring or environment variables . |
5,885 | def find_with_const_defined ( class_name ) @namespaces . find do | namespace | if namespace . const_defined? ( class_name ) break namespace . const_get ( class_name ) end end end | Looks up the given class name in the configured namespaces in order returning the first one that has the class name constant defined . |
5,886 | def swagger_object ( target_class , request , options ) object = { info : info_object ( options [ :info ] . merge ( version : options [ :doc_version ] ) ) , swagger : '2.0' , produces : content_types_for ( target_class ) , authorizations : options [ :authorizations ] , securityDefinitions : options [ :security_definiti... | swagger spec2 . 0 related parts |
5,887 | def info_object ( infos ) result = { title : infos [ :title ] || 'API title' , description : infos [ :description ] , termsOfService : infos [ :terms_of_service_url ] , contact : contact_object ( infos ) , license : license_object ( infos ) , version : infos [ :version ] } GrapeSwagger :: DocMethods :: Extensions . add... | building info object |
5,888 | def license_object ( infos ) { name : infos . delete ( :license ) , url : infos . delete ( :license_url ) } . delete_if { | _ , value | value . blank? } end | sub - objects of info object license |
5,889 | def path_and_definition_objects ( namespace_routes , options ) @paths = { } @definitions = { } namespace_routes . each_key do | key | routes = namespace_routes [ key ] path_item ( routes , options ) end add_definitions_from options [ :models ] [ @paths , @definitions ] end | building path and definitions objects |
5,890 | def node ( name , type = Node , & block ) parent = @nodes_stack . empty? ? Node :: ROOT : @nodes_stack . last level = [ 0 , @nodes_stack . size - 1 ] . max prefix = ':pipe' * level if parent . class == LeafNode prefix = ':space' * level end node = type . new ( name , parent . full_path , prefix , @nodes_stack . size ) ... | Create a Tree |
5,891 | def apply_filters ( options ) return unless options . key? ( :only ) || options . key? ( :except ) attributes_only_filters , associations_only_filters = resolve_filters ( options , :only ) attributes_except_filters , associations_except_filters = resolve_filters ( options , :except ) self . attributes = apply_attribute... | Applies attributes and association filters |
5,892 | def default_value_for ( attribute , options = { } , & block ) value = options allows_nil = true if options . is_a? ( Hash ) opts = options . stringify_keys value = opts . fetch ( 'value' , options ) allows_nil = opts . fetch ( 'allows_nil' , true ) end if ! method_defined? ( :set_default_values ) include ( InstanceMeth... | Declares a default value for the given attribute . |
5,893 | def compile ( options ) begin app_id = options . fetch ( :app_id ) asset_url_prefix = options . fetch ( :assets_dir ) name = options . fetch ( :app_name ) rescue KeyError => e raise ArgumentError , e . message end locale = options . fetch ( :locale , 'en' ) source = manifest . iframe_only? ? nil : app_js app_class_name... | this is not really compile_js it compiles the whole app including scss for v1 apps |
5,894 | def default_field_lengths field_lengths = @headers ? @headers . inject ( { } ) { | h , ( k , v ) | h [ k ] = String . size ( v ) ; h } : @fields . inject ( { } ) { | h , e | h [ e ] = 1 ; h } @rows . each do | row | @fields . each do | field | len = String . size ( row [ field ] ) field_lengths [ field ] = len if len >... | find max length for each field ; start with the headers |
5,895 | def array_to_indices_hash ( array ) array . inject ( { } ) { | hash , e | hash [ hash . size ] = e ; hash } end | Converts an array to a hash mapping a numerical index to its array value . |
5,896 | def format_output ( output , options = { } , & block ) output_class = determine_output_class ( output ) options = parse_console_options ( options ) if options . delete ( :console ) options = Util . recursive_hash_merge ( klass_config ( output_class ) , options ) _format_output ( output , options , & block ) end | This method looks for an output object s view in Formatter . config and then Formatter . dynamic_config . If a view is found a stringified view is returned based on the object . If no view is found nil is returned . The options this class takes are a view hash as described in Formatter . config . These options will be ... |
5,897 | def dynamic_options ( obj ) view_methods . each do | meth | if obj . class . ancestors . map { | e | e . to_s } . include? ( method_to_class ( meth ) ) begin return send ( meth , obj ) rescue raise "View failed to generate for '#{method_to_class(meth)}' " + "while in '#{meth}' with error:\n#{$!.message}" end end end ni... | Returns a hash of options based on dynamic views defined for the object s ancestry . If no config is found returns nil . |
5,898 | def activated_by? ( string_to_page , inspect_mode = false ) inspect_mode ? ( String . size ( string_to_page ) > @height * @width ) : ( string_to_page . count ( "\n" ) > @height ) end | Determines if string should be paged based on configured width and height . |
5,899 | def recursive_hash_merge ( hash1 , hash2 ) hash1 . merge ( hash2 ) { | k , o , n | ( o . is_a? ( Hash ) ) ? recursive_hash_merge ( o , n ) : n } end | Recursively merge hash1 with hash2 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.