idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
7,500
def save_manual_journal ( manual_journal ) request_xml = manual_journal . to_xml response_xml = nil create_or_save = nil if manual_journal . manual_journal_id . nil? response_xml = http_put ( @client , "#{@xero_url}/ManualJournals" , request_xml , { } ) create_or_save = :create else response_xml = http_post ( @client ,...
Create or update a manual journal record based on if it has an manual_journal_id .
7,501
def build_contact ( params = { } ) self . contact = gateway ? gateway . build_contact ( params ) : Contact . new ( params ) end
Helper method to create the associated contact object .
7,502
def renew_access_token ( access_token = nil , access_secret = nil , session_handle = nil ) access_token ||= @atoken access_secret ||= @asecret session_handle ||= @session_handle old_token = :: OAuth :: RequestToken . new ( consumer , access_token , access_secret ) access_token = old_token . get_access_token ( { :oauth_...
Renewing access tokens only works for Partner applications
7,503
def update_attributes_from_token ( access_token ) @expires_at = Time . now + access_token . params [ :oauth_expires_in ] . to_i @authorization_expires_at = Time . now + access_token . params [ :oauth_authorization_expires_in ] . to_i @session_handle = access_token . params [ :oauth_session_handle ] @atoken , @asecret =...
Update instance variables with those from the AccessToken .
7,504
def valid? @errors = [ ] if ! bank_transaction_id . nil? && bank_transaction_id !~ GUID_REGEX @errors << [ 'bank_transaction_id' , 'must be blank or a valid Xero GUID' ] end if type && ! TYPES [ type ] @errors << [ 'type' , "must be one of #{TYPES.keys.join('/')}" ] end if status && ! STATUSES [ status ] @errors << [ '...
Validate the BankTransaction record according to what will be valid by the gateway .
7,505
def valid? @errors = [ ] if ! manual_journal_id . nil? && manual_journal_id !~ GUID_REGEX @errors << [ 'manual_journal_id' , 'must be blank or a valid Xero GUID' ] end if narration . blank? @errors << [ 'narration' , "can't be blank" ] end unless date @errors << [ 'date' , "can't be blank" ] end unless journal_lines . ...
Validate the ManualJournal record according to what will be valid by the gateway .
7,506
def to_xml_for_invoice_messages ( b = Builder :: XmlMarkup . new ) b . TrackingCategory { b . TrackingCategoryID self . tracking_category_id unless tracking_category_id . nil? b . Name self . name b . Option self . options . is_a? ( Array ) ? self . options . first : self . options . to_s } end
When a tracking category is serialized as part of an invoice it may only have a single option and the Options tag is omitted
7,507
def to_js ( element_id ) js = "" js << "\n<script type='text/javascript'>" js << load_js ( element_id ) js << draw_js ( element_id ) js << "\n</script>" js end
Generates JavaScript and renders the Google Chart in the final HTML output .
7,508
def draw_js ( element_id ) js = "" js << "\n function #{chart_function_name(element_id)}() {" js << "\n #{@data_table.to_js}" js << "\n var chart = new google.#{chart_class}.#{chart_name}(document.getElementById('#{element_id}'));" @listeners . each do | listener | js << "\n google.visualization.events.addLis...
Generates JavaScript function for rendering the chart .
7,509
def new_columns ( columns ) columns . each do | column | new_column ( column [ :type ] , column [ :label ] , column [ :id ] , column [ :role ] , column [ :pattern ] ) end end
Adds multiple columns to the data_table .
7,510
def set_column ( column_index , column_values ) if @rows . size < column_values . size 1 . upto ( column_values . size - @rows . size ) { @rows << Array . new } end column_values . each_with_index do | column_value , row_index | set_cell ( row_index , column_index , column_value ) end end
Sets a column in data_table specified by column_index with an array of column_values . column_index starts from 0 .
7,511
def add_row ( row_values = [ ] ) @rows << Array . new row_index = @rows . size - 1 row_values . each_with_index do | row_value , column_index | set_cell ( row_index , column_index , row_value ) end end
Adds a new row to the data_table . Call method without any parameters to add an empty row otherwise call method with a row object .
7,512
def add_rows ( array_or_num ) if array_or_num . is_a? ( Array ) array_or_num . each do | row | add_row ( row ) end else array_or_num . times do add_row end end end
Adds multiple rows to the data_table . You can call this method with data to populate a set of new rows or create new empty rows .
7,513
def get_cell ( row_index , column_index ) if within_range? ( row_index , column_index ) @rows [ row_index ] [ column_index ] . v else raise RangeError , "row_index and column_index MUST be < @rows.size and @cols.size" , caller end end
Gets a cell value from the visualization at row_index column_index . row_index and column_index start from 0 .
7,514
def to_js js = "var data_table = new google.visualization.DataTable();" @cols . each do | column | js << "data_table.addColumn(" js << display ( column ) js << ");" end @rows . each do | row | js << "data_table.addRow(" js << "[#{row.map(&:to_js).join(", ")}]" unless row . empty? js << ");" end if @formatters @formatte...
Returns the JavaScript equivalent for this data_table instance .
7,515
def run_action ( msg ) ui . info ( "#{msg}... " , :nonewline ) begin result = yield ui . puts ui . color ( "complete!" , :green , :bold ) result rescue => e ui . puts ui . color ( "error!" , :red , :bold ) ui . error "Reason - #{e}" raise end end
Create a new callback instance
7,516
def save_expanded_stack ( stack_id , stack_attributes ) current_stacks = MultiJson . load ( cached_stacks ) cache . locked_action ( :stacks_lock ) do logger . info "Saving expanded stack attributes in cache (#{stack_id})" current_stacks [ stack_id ] = stack_attributes . merge ( "Cached" => Time . now . to_i ) cache [ :...
Store stack attribute changes
7,517
def remove_stack ( stack_id ) current_stacks = MultiJson . load ( cached_stacks ) logger . info "Attempting to remove stack from internal cache (#{stack_id})" cache . locked_action ( :stacks_lock ) do val = current_stacks . delete ( stack_id ) logger . info "Successfully removed stack from internal cache (#{stack_id})"...
Remove stack from the cache
7,518
def expand_stack ( stack ) logger . info "Stack expansion requested (#{stack.id})" if ( ( stack . in_progress? && Time . now . to_i - stack . attributes [ "Cached" ] . to_i > stack_expansion_interval ) || ! stack . attributes [ "Cached" ] ) begin expanded = false cache . locked_action ( :stack_expansion_lock ) do expan...
Expand all lazy loaded attributes within stack
7,519
def fetch_stacks ( stack_id = nil ) cache . locked_action ( :stacks_lock ) do logger . info "Lock aquired for stack update. Requesting stacks from upstream. (#{Thread.current})" if stack_id single_stack = connection . stacks . get ( stack_id ) stacks = single_stack ? { single_stack . id => single_stack } : { } else sta...
Request stack information and store in cache
7,520
def update_stack_list! if updater . nil? || ! updater . alive? self . updater = Thread . new { loop do begin fetch_stacks sleep ( stack_list_interval ) rescue => e logger . error "Failure encountered on stack fetch: #{e.class} - #{e}" end end } true else false end end
Start async stack list update . Creates thread that loops every self . stack_list_interval seconds and refreshes stack list in cache
7,521
def load_api_provider_extensions! if config . get ( :credentials , :provider ) base_ext = Bogo :: Utility . camel ( config . get ( :credentials , :provider ) ) . to_sym targ_ext = self . class . name . split ( "::" ) . last if ApiProvider . constants . include? ( base_ext ) base_module = ApiProvider . const_get ( base_...
Load API provider specific overrides to customize behavior
7,522
def discover_config ( opts ) cwd = Dir . pwd . split ( File :: SEPARATOR ) detected_path = "" until cwd . empty? || File . exists? ( detected_path . to_s ) detected_path = Dir . glob ( ( cwd + [ "#{CONFIG_BASE_NAME}{#{VALID_CONFIG_EXTENSIONS.join(",")}}" ] ) . join ( File :: SEPARATOR ) ) . first cwd . pop end if opts ...
Start with current working directory and traverse to root looking for a . sfn configuration file
7,523
def init ( name , kind , args = { } ) get_storage ( self . class . type , kind , name , args ) true end
Create new instance
7,524
def get_storage ( store_type , data_type , name , args = { } ) full_name = "#{key}_#{name}" result = nil case store_type . to_sym when :redis result = get_redis_storage ( data_type , full_name . to_s , args ) when :local @_local_cache ||= { } unless @_local_cache [ full_name . to_s ] @_local_cache [ full_name . to_s ] ...
Fetch item from storage
7,525
def get_redis_storage ( data_type , full_name , args = { } ) self . class . redis_ping! case data_type . to_sym when :array Redis :: List . new ( full_name , { :marshal => true } . merge ( args ) ) when :hash Redis :: HashKey . new ( full_name ) when :value Redis :: Value . new ( full_name , { :marshal => true } . merg...
Fetch item from redis storage
7,526
def get_local_storage ( data_type , full_name , args = { } ) @storage ||= { } @storage [ full_name ] ||= case data_type . to_sym when :array [ ] when :hash { } when :value LocalValue . new when :lock LocalLock . new ( full_name , { :expiration => 60 , :timeout => 0.1 } . merge ( args ) ) when :stamped Stamped . new ( f...
Fetch item from local storage
7,527
def time_check_allow? ( key , stamp ) Time . now . to_i - stamp . to_i > apply_limit ( key ) end
Check if cache time has expired
7,528
def apply_limit ( kind , seconds = nil ) @apply_limit ||= { } if seconds @apply_limit [ kind . to_sym ] = seconds . to_i end @apply_limit [ kind . to_sym ] . to_i end
Apply time limit for data type
7,529
def locked_action ( lock_name , raise_on_locked = false ) begin self [ lock_name ] . lock do yield end rescue => e if e . class . to_s . end_with? ( "Timeout" ) raise if raise_on_locked else raise end end end
Perform action within lock
7,530
def index_of_match_after_additions return unless expected_additions > 0 ( 1 .. expected_additions ) . each do | i | next_difference = item_difference ( old_array [ old_index ] , new_array [ new_index + i ] , old_index ) return new_index + i if next_difference . empty? end nil end
look ahead in the new array to see if the current item appears later thereby having new items added
7,531
def index_of_match_after_deletions return unless expected_additions < 0 ( 1 .. ( expected_additions . abs ) ) . each do | i | next_difference = item_difference ( old_array [ old_index + i ] , new_array [ new_index ] , old_index ) return old_index + i if next_difference . empty? end nil end
look ahead in the old array to see if the current item appears later thereby having items removed
7,532
def cast ( value ) if value . is_a? ( MySQLBinUUID :: Type :: Data ) add_dashes ( value . to_s ) elsif value . is_a? ( String ) && value . encoding == Encoding :: ASCII_8BIT && strip_dashes ( value ) . length != 32 undashed_uuid = value . unpack1 ( 'H*' ) add_dashes ( undashed_uuid . to_s ) else super end end
Invoked when a value that is returned from the database needs to be displayed into something readable again .
7,533
def serialize ( value ) return if value . nil? undashed_uuid = strip_dashes ( value ) unless valid_undashed_uuid? ( undashed_uuid ) raise MySQLBinUUID :: InvalidUUID , "#{value} is not a valid UUID" end Data . new ( undashed_uuid ) end
Invoked when the provided value needs to be serialized before storing it to the database .
7,534
def add_dashes ( uuid ) return uuid if uuid =~ / \- / [ uuid [ 0 .. 7 ] , uuid [ 8 .. 11 ] , uuid [ 12 .. 15 ] , uuid [ 16 .. 19 ] , uuid [ 20 .. - 1 ] ] . join ( "-" ) end
A UUID consists of 5 groups of characters . 8 chars - 4 chars - 4 chars - 4 chars - 12 characters
7,535
def sign_in user Oath . config . sign_in_service . new ( user , warden ) . perform . tap do | status | if status && block_given? yield end end end
Sign in a user
7,536
def sign_up user_params Oath . config . sign_up_service . new ( user_params ) . perform . tap do | status | if status && block_given? yield end end end
Sign up a user
7,537
def authenticate_session session_params , field_map = nil token_field = Oath . config . user_token_field params_hash = Oath . transform_params ( session_params ) . symbolize_keys password = params_hash . fetch ( token_field ) user = Oath . lookup ( params_hash . except ( token_field ) , field_map ) authenticate ( user ...
Authenticates a session .
7,538
def authenticate user , password Oath . config . authentication_service . new ( user , password ) . perform end
Authenticates a user given a password
7,539
def reset_password user , password Oath . config . password_reset_service . new ( user , password ) . perform end
Resets a user s password
7,540
def to_h sanitized_params . each_with_object ( { } ) do | ( key , value ) , hash | hash [ key ] = transform ( key , value ) end end
Initialize parameter transformer
7,541
def get ( url , instrumentation : { } , ** _options ) uri = URI . parse url response = ActiveSupport :: Notifications . instrument ( 'client_request_matrix_data.google_distance_matrix' , instrumentation ) do Net :: HTTP . get_response uri end handle response , url rescue Timeout :: Error => error raise ServerError , er...
Make a GET request to given URL
7,542
def encode return @encoded if @encoded deltas = @delta . deltas_rounded @array_of_lat_lng_pairs chars_array = deltas . map { | v | @value_encoder . encode v } @encoded = chars_array . join end
Initialize a new encoder
7,543
def unsorted_query records = scope if search_term escaped = Regexp . escape ( search_term ) regexp = Regexp . new ( escaped , Regexp :: IGNORECASE ) if search_columns . size == 1 records = records . where ( search_columns . first => regexp ) else cols = search_columns . collect { | col | { col => regexp } } records = r...
Returns the filtered query expression
7,544
def editable_field_html ( klass , field_name , value , f , include_nil_selectors = false ) field = klass . fields [ field_name . to_s ] return unless field && field . type placeholder = field . default_val placeholder = nil if placeholder . is_a? ( Proc ) case field . type . name when 'Symbol' , 'String' , 'Integer' op...
Returns the editable field as html for use in editing dynamic fields from a Job class .
7,545
def map ( job ) index = 0 h = { } @columns . each do | column | h [ index . to_s ] = send ( column [ :value ] , job ) index += 1 end h [ 'DT_RowClass' ] = "card callout callout-#{job_state(job)}" h end
Map the values for each column
7,546
def parse ( file ) return nil unless File . exist? ( file ) document = parse_xml ( file ) node = document . xpath ( '*' ) . first node . attributes . each do | key , value | case key when 'count' @count = value . value . to_i when 'uniqueCount' @unique_count = value . value . to_i end end node . xpath ( '*' ) . each do...
Parse Shared string table file
7,547
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'shape' element = OldDocxGroupElement . new ( :shape ) element . object = OldDocxShape . new ( parent : self ) . parse ( node_child ) @elements << element when 'wrap' @properties . wrap = node_child . attribute ( 'type' ) . val...
Parse OldDocxGroup object
7,548
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'barChart' @bar_chart = CommonChartData . new ( parent : self ) . parse ( node_child ) when 'lineChart' @line_chart = CommonChartData . new ( parent : self ) . parse ( node_child ) when 'areaChart' @area_chart = CommonChartData...
Parse View3D object
7,549
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'dLblPos' @position = value_to_symbol ( node_child . attribute ( 'val' ) ) when 'showLegendKey' @show_legend_key = true if node_child . attribute ( 'val' ) . value == '1' when 'showVal' @show_values = true if node_child . attri...
Parse DisplayLabelsProperties object
7,550
def parse ( node ) @preset = node . attribute ( 'prst' ) . value . to_sym node . xpath ( '*' ) . each do | node_child | case node_child . name when 'fgClr' @foreground_color = Color . new ( parent : self ) . parse_color_model ( node_child ) when 'bgClr' @background_color = Color . new ( parent : self ) . parse_color_mo...
Parse DocxPatternFill object
7,551
def parse ( node ) node . attributes . each do | key , value | case key when 'id' @file_reference = FileReference . new ( parent : self ) . parse ( node ) when 'type' @stretching_type = case value . value when 'frame' :stretch else value . value . to_sym end when 'title' @title = value . value . to_s end end self end
Parse OldDocxShapeFill object
7,552
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'bottom' @bottom = BordersProperties . new ( parent : self ) . parse ( node_child ) when 'left' @left = BordersProperties . new ( parent : self ) . parse ( node_child ) when 'top' @top = BordersProperties . new ( parent : self ...
Parse Paragraph Borders data
7,553
def parse ( node ) node . xpath ( 'mc:Choice/*' , 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006' ) . each do | node_child | case node_child . name when 'timing' @timing = Timing . new ( parent : self ) . parse ( node_child ) when 'transition' @transition = Transition . new ( parent : self )...
Parse PresentationAlternateContent object
7,554
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'solidFill' @type = :solid @color = Color . new ( parent : self ) . parse_color_model ( node_child ) when 'gradFill' @type = :gradient @color = GradientColor . new ( parent : self ) . parse ( node_child ) when 'noFill' @color =...
Parse DocxColorScheme object
7,555
def parse ( node ) @color1 = Color . new ( parent : self ) . parse_hex_string ( node . attribute ( 'color' ) . value ) node . xpath ( 'v:background' ) . each do | second_color | @size = second_color . attribute ( 'targetscreensize' ) . value . sub ( ',' , 'x' ) unless second_color . attribute ( 'targetscreensize' ) . n...
Parse DocumentBackground object
7,556
def parse ( node ) list = [ ] node . xpath ( '*' ) . each do | node_child | case node_child . name when 'AlternateContent' list << AlternateContent . new ( parent : self ) . parse ( node_child ) end end list end
Parse OleObjects object
7,557
def parse ( node ) node . attributes . each do | key , value | case key when 'type' @type = value . value . to_sym when 'styleId' @style_id = value . value when 'default' @default = attribute_enabled? ( value . value ) end end node . xpath ( '*' ) . each do | subnode | case subnode . name when 'name' @name = subnode . ...
Parse single document style
7,558
def parse_drawing drawing_node = parse_xml ( OOXMLDocumentObject . current_xml ) drawing_node . xpath ( 'xdr:wsDr/*' ) . each do | drawing_node_child | @drawings << XlsxDrawing . new ( parent : self ) . parse ( drawing_node_child ) end end
Parse list of drawings in file
7,559
def parse_comments return unless relationships comments_target = relationships . target_by_type ( 'comment' ) return if comments_target . empty? comments_file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/#{comments_target.first.gsub('..', '')}" @comments = ExcelComments . new ( parent ...
Do work for parsing shared comments file
7,560
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 't' @text = node_child . text when 'r' @run = ParagraphRun . new ( parent : self ) . parse ( node_child ) end end self end
Parse StringIndex data
7,561
def parse ( node ) node . attributes . each do | key , value | case key when 'id' @id = value . value . to_i when 'name' @name = value . value end end self end
Parse BookmarkStart object
7,562
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'cTn' @common_time_node = CommonTiming . new ( parent : self ) . parse ( node_child ) when 'tgtEl' @target = TargetElement . new ( parent : self ) . parse ( node_child ) when 'attrNameLst' node_child . xpath ( 'p:attrName' ) . ...
Parse Behavior object
7,563
def parse ( node ) node . attributes . each do | key , value | case key when 'abstractNumId' @id = value . value . to_f end end node . xpath ( '*' ) . each do | numbering_child_node | case numbering_child_node . name when 'multiLevelType' @multilevel_type = MultilevelType . new ( parent : self ) . parse ( numbering_chi...
Parse Abstract Numbering data
7,564
def parse ( node ) node . attributes . each do | key , value | case key when 'customHeight' @custom_height = option_enabled? ( node , 'customHeight' ) when 'ht' @height = OoxmlSize . new ( value . value . to_f , :point ) when 'hidden' @hidden = option_enabled? ( node , 'hidden' ) when 'r' @index = value . value . to_i ...
Parse XlsxRow object
7,565
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'accPr' node_child . xpath ( '*' ) . each do | node_child_child | case node_child_child . name when 'chr' @symbol = node_child_child . attribute ( 'val' ) . value end end end end @element = DocxFormula . new ( parent : self ) ....
Parse Accent object
7,566
def looks_like? ( color_to_check = nil , delta = 8 ) color_to_check = color_to_check . converted_color if color_to_check . is_a? ( SchemeColor ) color_to_check = color_to_check . pattern_fill . foreground_folor if color_to_check . is_a? ( Fill ) color_to_check = color_to_check . color . converted_color if color_to_chec...
To compare color which look alike
7,567
def parse ( node ) @list = node . xpath ( 'c:f' ) [ 0 ] . text . split ( '!' ) . first coordinates = Coordinates . parser_coordinates_range ( node . xpath ( 'c:f' ) [ 0 ] . text ) return self unless coordinates node . xpath ( 'c:numCache/c:pt' ) . each_with_index do | point_node , index | point = ChartPoint . new ( coo...
Parse ChartCellsRange object
7,568
def parse ( node ) node . attributes . each do | key , value | case key when 'horizontal' @horizontal = value . value . to_sym @wrap_text = true if @horizontal == :justify when 'vertical' @vertical = value . value . to_sym when 'wrapText' @wrap_text = value . value . to_s == '1' when 'textRotation' @text_rotation = val...
Parse XlsxAlignment object
7,569
def parse ( node ) node . attributes . each do | key , value | case key when 'styleId' @id = value . value . to_s when 'styleName' @name = value . value . to_s when 'val' @value = value . value . to_s end end node . xpath ( '*' ) . each do | style_node_child | case style_node_child . name when 'wholeTbl' @whole_table =...
Parse TableStyle object
7,570
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'rPr' @properties = RunProperties . new ( parent : self ) . parse ( node_child ) when 't' @t = Text . new ( parent : self ) . parse ( node_child ) @text = t . text when 'tab' @tab = Tab . new ( parent : self ) . parse ( node_ch...
Parse ParagraphRun object
7,571
def all_formula_values ( precision = 14 ) formulas = [ ] worksheets . each do | c_sheet | next unless c_sheet c_sheet . rows . each do | c_row | next unless c_row c_row . cells . each do | c_cell | next unless c_cell next unless c_cell . formula next if c_cell . formula . empty? text = c_cell . raw_text if StringHelper...
Get all values of formulas .
7,572
def parse_shared_strings shared_strings_target = relationships . target_by_type ( 'sharedString' ) return if shared_strings_target . empty? shared_string_file = "#{OOXMLDocumentObject.path_to_folder}/xl/#{shared_strings_target.first}" @shared_strings_table = SharedStringTable . new ( parent : self ) . parse ( shared_st...
Do work for parsing shared strings file
7,573
def parse ( node ) node . attributes . each do | key , value | case key when 'leftFromText' @left = OoxmlSize . new ( value . value . to_f ) when 'rightFromText' @right = OoxmlSize . new ( value . value . to_f ) when 'topFromText' @top = OoxmlSize . new ( value . value . to_f ) when 'bottomFromText' @bottom = OoxmlSize...
Parse TablePosition object
7,574
def parse ( node , type ) @type = type node . attribute ( 'style' ) . value . to_s . split ( ';' ) . each do | property | if property . include? ( 'margin-top' ) @properties . margins . top = property . split ( ':' ) . last elsif property . include? ( 'margin-left' ) @properties . margins . left = property . split ( ':...
Parse Shape object
7,575
def parse ( node ) @id = node . attribute ( 'id' ) . value @type = node . attribute ( 'type' ) . value node . xpath ( '*' ) . each do | text_field_node_child | case text_field_node_child . name when 't' @text = text_field_node_child . text end end self end
Parse TextField object
7,576
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'blipFill' @type = :picture @value = DocxBlip . new ( parent : self ) . parse ( node_child ) node_child . xpath ( '*' ) . each do | fill_type_node_child | case fill_type_node_child . name when 'tile' @stretching_type = :tile wh...
Parse DocxColor object
7,577
def parse ( node , default_paragraph , default_character ) node . xpath ( '*' ) . each do | pg_size_subnode | case pg_size_subnode . name when 'pgSz' @size = PageSize . new . parse ( pg_size_subnode ) when 'pgBorders' page_borders = Borders . new page_borders . display = pg_size_subnode . attribute ( 'display' ) . valu...
Parse PageProperties data
7,578
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'tx' node_child . xpath ( 'c:rich/*' ) . each do | rich_node_child | case rich_node_child . name when 'p' root_object . default_font_style = FontStyle . new ( true ) @elements << Paragraph . new ( parent : self ) . parse ( rich...
Parse ChartAxisTitle object
7,579
def parse ( node ) node . xpath ( '*' ) . each do | child_node | case child_node . name when 'from' @from = XlsxDrawingPositionParameters . new ( parent : self ) . parse ( child_node ) when 'to' @to = XlsxDrawingPositionParameters . new ( parent : self ) . parse ( child_node ) when 'sp' @shape = DocxShape . new ( paren...
Parse XlsxDrawing object
7,580
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'lnL' , 'left' @left = TableCellLine . new ( parent : self ) . parse ( node_child ) when 'lnR' , 'right' @right = TableCellLine . new ( parent : self ) . parse ( node_child ) when 'lnT' , 'top' @top = TableCellLine . new ( pare...
Parse Borders object
7,581
def transform_of_object ( object ) case object when :image elements . find { | e | e . is_a? Picture } . properties . transform when :chart elements . find { | e | e . is_a? GraphicFrame } . transform when :table elements . find { | e | e . is_a? GraphicFrame } . transform when :shape elements . find { | e | ! e . shap...
Get transform property of object by object type
7,582
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'blip' @blip = Blip . new ( parent : self ) . parse ( node_child ) when 'stretch' @stretch = Stretch . new ( parent : self ) . parse ( node_child ) end end self end
Parse BlipFill object
7,583
def parse ( node ) node . attributes . each do | key , value | case key when 'fillcolor' @fill_color = Color . new ( parent : self ) . parse_hex_string ( value . value . delete ( '#' ) ) when 'opacity' @opacity = value . value . to_f when 'strokecolor' @stroke_color = Color . new ( parent : self ) . parse_hex_string ( ...
Parse OldDocxShapeProperties object
7,584
def parse OOXMLDocumentObject . add_to_xmls_stack ( @xml_path ) @name = File . basename ( @xml_path , '.*' ) node = parse_xml ( OOXMLDocumentObject . current_xml ) node . xpath ( '//p:sld/*' ) . each do | node_child | case node_child . name when 'cSld' @common_slide_data = CommonSlideData . new ( parent : self ) . pars...
Parse Slide object
7,585
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'blipFill' @path_to_image = DocxBlip . new ( parent : self ) . parse ( node_child ) when 'spPr' @properties = DocxShapeProperties . new ( parent : self ) . parse ( node_child ) when 'nvPicPr' @non_visual_properties = NonVisualS...
Parse DocxPicture object
7,586
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'gsLst' node_child . xpath ( '*' ) . each do | gradient_stop_node | @gradient_stops << GradientStop . new ( parent : self ) . parse ( gradient_stop_node ) end when 'path' @path = node_child . attribute ( 'path' ) . value . to_s...
Parse GradientColor object
7,587
def parse ( node ) node . attributes . each do | key , value | case key when 'algn' , 'val' @value = value_to_symbol ( value ) when 'leader' @leader = value_to_symbol ( value ) when 'pos' @position = OoxmlSize . new ( value . value . to_f , position_unit ( node ) ) end end self end
Parse ParagraphTab object
7,588
def parse ( node ) node . attributes . each do | key , value | case key when 'name' @name = value . value . to_s when 'showColumnStripes' @show_column_stripes = attribute_enabled? ( value ) when 'showFirstColumn' @show_first_column = attribute_enabled? ( value ) when 'showLastColumn' @show_last_column = attribute_enabl...
Parse TableStyleInfo data
7,589
def parse ( node ) node . attributes . each do | key , value | case key when 'instr' @instruction = value . value . to_s end end node . xpath ( '*' ) . each do | node_child | case node_child . name when 'r' @runs << ParagraphRun . new ( parent : self ) . parse ( node_child ) end end self end
Parse FieldSimple object
7,590
def parse ( node ) node . attributes . each do | key , value | case key when 'prst' @preset = value . value . to_sym end end node . xpath ( '*' ) . each do | color_node | case color_node . name when 'fgClr' @foreground_color = Color . new ( parent : self ) . parse_color ( color_node . xpath ( '*' ) . first ) when 'bgCl...
Parse PresentationPattern object
7,591
def parse settings_path = OOXMLDocumentObject . path_to_folder + 'word/settings.xml' return nil unless File . exist? ( settings_path ) doc = parse_xml ( settings_path ) doc . xpath ( 'w:settings/*' ) . each do | node_child | case node_child . name when 'defaultTabStop' @default_tab_stop = OoxmlSize . new . parse ( node...
Parse Settings object
7,592
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'round' , 'bevel' @type = node_child . name . to_sym when 'miter' @type = :miter @limit = node_child . attribute ( 'lim' ) . value . to_f end end self end
Parse LineJoin object
7,593
def parse ( node ) node . xpath ( '*' ) . each do | column_node | case column_node . name when 'ext' @extension_array << Extension . new ( parent : self ) . parse ( column_node ) end end self end
Parse ExtensionList data
7,594
def parse ( node ) node . attributes . each do | key , value | case key when 's' @style_index = value . value . to_i when 't' @type = value . value . to_s end end node . xpath ( '*' ) . each do | node_child | case node_child . name when 'f' @formula = Formula . new ( parent : self ) . parse ( node_child ) when 'v' @val...
Parse XlsxCell object
7,595
def get_shared_string ( value ) return '' if value == '' string = root_object . shared_strings_table . string_indexes [ value . to_i ] @character = string . run @raw_text = string . text end
Get shared string by it s number
7,596
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'sp' @elements << DocxShape . new ( parent : self ) . parse ( node_child ) . dup when 'pic' @elements << DocxPicture . new ( parent : self ) . parse ( node_child ) when 'graphicFrame' @elements << GraphicFrame . new ( parent : ...
Parse ShapeTree object
7,597
def parse ( file ) node = parse_xml ( file ) node . xpath ( 'p:notes/*' ) . each do | node_child | case node_child . name when 'cSld' @common_slide_data = CommonSlideData . new ( parent : self ) . parse ( node_child ) end end self end
Parse PresentationNotes object
7,598
def parse ( node ) node . xpath ( '*' ) . each do | node_child | case node_child . name when 'sldTgt' @type = :slide when 'sndTgt' @type = :sound @name = node_child . attribute ( 'name' ) . value @built_in = node_child . attribute ( 'builtIn' ) . value ? StringHelper . to_bool ( node_child . attribute ( 'builtIn' ) . v...
Parse TargetElement object
7,599
def parse ( node , number = 0 , default_table_properties = TableProperties . new ) table_properties = default_table_properties . dup table_properties . jc = :left node . xpath ( '*' ) . each do | node_child | case node_child . name when 'tblGrid' @grid = TableGrid . new ( parent : self ) . parse ( node_child ) when 'tr...
Parse Table object