Class: Relyze::FileModel::Structure

Inherits:
Value
  • Object
show all
Defined in:
C:/Program Files/Relyze/lib/relyze/core/file_model.rb

Overview

A Structure value holds a number of child values. The child items may have different types and may not be linear in offset.

Instance Method Summary collapse

Methods inherited from Value

#color, #color=, #comment, #comment=, #name, #name=, #offset, #size, #to_s, #type, #value

Instance Method Details

#[](name) ⇒ Relyze::FileModel::Value?

Get an item in this structure with a specific name

Parameters:

  • name (String)

    The name of the item to return.

Returns:



209
210
211
212
213
214
# File 'C:/Program Files/Relyze/lib/relyze/core/file_model.rb', line 209

def []( name )
    self.items do | item |
        return item if item.name == name
    end
    return nil
end

#child_structures {|item| ... } ⇒ Array<Relyze::FileModel::Structure>?

Get every item in the structure which itself is a structure.

Yields:

  • (item)

    yields the item to the block.

Yield Parameters:

Returns:



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'C:/Program Files/Relyze/lib/relyze/core/file_model.rb', line 179

def child_structures
    arr = nil
    self.items do | item |  
        if( item.class == Relyze::FileModel::Structure )
            if( block_given? )
                yield item
            else
                arr = ::Array.new if not arr
                arr << item
            end
        elsif( item.class == Relyze::FileModel::Array )
            item.items do | arr_item |
                if( arr_item.class == Relyze::FileModel::Structure )
                    if( block_given? )
                        yield arr_item
                    else
                        arr = ::Array.new if not arr
                        arr << arr_item
                    end
                end
            end
        end
    end
    return arr
end

#items {|item| ... } ⇒ Array<Relyze::FileModel::Value, nil] An array of {Relyze::FileModel::Value} objects or nil.

Get every item in the structure.

Yields:

  • (item)

    yields the item to the block.

Yield Parameters:

Returns:



170
171
172
# File 'C:/Program Files/Relyze/lib/relyze/core/file_model.rb', line 170

def items
    return []
end