Class: UIC::MetaData::AssetBase
- Inherits:
-
Object
- Object
- UIC::MetaData::AssetBase
- Defined in:
- lib/ruic/assets.rb
Overview
The base class for all assets. All other classes are dynamically created when a MetaData.xml
file is loaded.
Class Attribute Summary collapse
-
.name ⇒ String
readonly
The scene graph name of the asset.
Instance Attribute Summary collapse
-
#el ⇒ Nokogiri::XML::Element
The internal XML element in the scene graph of the presentation.
-
#presentation ⇒ Presentation
The presentation that this asset is part of.
Class Method Summary collapse
-
.properties ⇒ Hash
A hash mapping attribute names to Property instances.
Instance Method Summary collapse
-
#[](attribute_name, slide_name_or_index = nil) ⇒ Object, ValuesPerSlide
Get the value(s) of an attribute.
-
#[]=(attribute_name, slide_name_or_index = nil, new_value) ⇒ Object
Set the value of an attribute, either across all slides, or on a particular slide.
-
#at(sub_path) ⇒ MetaData::AssetBase
(also: #/)
Find an asset by relative scripting path.
-
#children ⇒ Array<AssetBase>
Array of child assets in the scene graph.
-
#component ⇒ AssetBase
The component or scene that owns this asset.
-
#component? ⇒ Boolean
true
if this asset is a component or Scene. -
#find(criteria = {}, &block) ⇒ Array<AssetBase>
Find descendant assets matching criteria.
-
#has_slide?(slide_name_or_index) ⇒ Boolean
true
if this asset is present on the specified slide. -
#initialize(presentation, element) ⇒ AssetBase
constructor
Create a new asset.
-
#master? ⇒ Boolean
true
if this asset is on the master slide. -
#name ⇒ String
The name of this asset in the scene graph.
-
#name=(new_name) ⇒ String
Change the name of the asset in the scene graph.
-
#on_slide(slide_name_or_index) ⇒ SlideValues
A proxy that yields attribute values for a specific slide.
-
#parent ⇒ AssetBase
The parent of this asset in the scene graph.
-
#path ⇒ String
The script path to this asset.
-
#path_to(other_asset) ⇒ String
The script path to another asset, relative to this one.
-
#properties ⇒ Hash
A hash mapping attribute names to Property instances.
-
#slide? ⇒ Boolean
true
if this asset is a Slide. -
#slides ⇒ SlideCollection
An array-like collection of all slides that the asset is available on.
-
#to_xml ⇒ String
The XML representation of the scene graph element.
-
#type ⇒ String
The type of this asset.
Constructor Details
#initialize(presentation, element) ⇒ AssetBase
Create a new asset. This is called for you automatically; you likely should not be using it.
59 60 61 62 |
# File 'lib/ruic/assets.rb', line 59 def initialize( presentation, element ) @presentation = presentation @el = element end |
Class Attribute Details
.name ⇒ String (readonly)
Returns The scene graph name of the asset.
11 12 13 |
# File 'lib/ruic/assets.rb', line 11 def name @name end |
Instance Attribute Details
#el ⇒ Nokogiri::XML::Element
Returns the internal XML element in the scene graph of the presentation.
54 55 56 |
# File 'lib/ruic/assets.rb', line 54 def el @el end |
#presentation ⇒ Presentation
Returns the presentation that this asset is part of.
51 52 53 |
# File 'lib/ruic/assets.rb', line 51 def presentation @presentation end |
Class Method Details
.properties ⇒ Hash
Returns a hash mapping attribute names to Property instances.
14 15 16 |
# File 'lib/ruic/assets.rb', line 14 def properties (ancestors[1].respond_to?(:properties) ? ancestors[1].properties : {}).merge(@properties) end |
Instance Method Details
#[](attribute_name, slide_name_or_index = nil) ⇒ Object, ValuesPerSlide
Get the value(s) of an attribute.
If slide_name_or_index
is omitted, creates a ValuesPerSlide proxy for the specified attribute.
206 207 208 209 210 211 212 213 214 |
# File 'lib/ruic/assets.rb', line 206 def [](attribute_name, =nil) if property = properties[attribute_name.to_s] if property.get( self, ) if () else UIC::ValuesPerSlide.new(@presentation,self,property) end end end |
#[]=(attribute_name, slide_name_or_index = nil, new_value) ⇒ Object
Set the value of an attribute, either across all slides, or on a particular slide.
235 236 237 238 239 |
# File 'lib/ruic/assets.rb', line 235 def []=( attribute_name, =nil, new_value ) if property = properties[attribute_name.to_s] then property.set(self,new_value,) end end |
#at(sub_path) ⇒ MetaData::AssetBase Also known as: /
Find an asset by relative scripting path.
45 46 47 |
# File 'lib/ruic/assets.rb', line 45 def at(sub_path) presentation.at(sub_path,@el) end |
#children ⇒ Array<AssetBase>
Returns array of child assets in the scene graph. Children are in scene graph order.
77 78 79 |
# File 'lib/ruic/assets.rb', line 77 def children presentation.child_assets(self) end |
#component ⇒ AssetBase
Returns the component or scene that owns this asset. If this asset is a component, does not return itself.
104 105 106 |
# File 'lib/ruic/assets.rb', line 104 def component presentation.owning_component(self) end |
#component? ⇒ Boolean
Returns true
if this asset is a component or Scene.
109 110 111 |
# File 'lib/ruic/assets.rb', line 109 def component? @el.name=='Component' || @el.name=='Scene' end |
#find(criteria = {}, &block) ⇒ Array<AssetBase>
Find descendant assets matching criteria.
This method is the same as (but more convenient than) Presentation#find using the :_under
criteria.
See that method for documentation of the criteria
.
96 97 98 99 |
# File 'lib/ruic/assets.rb', line 96 def find(criteria={},&block) criteria[:_under] ||= self presentation.find(criteria,&block) end |
#has_slide?(slide_name_or_index) ⇒ Boolean
Returns true
if this asset is present on the specified slide.
127 128 129 |
# File 'lib/ruic/assets.rb', line 127 def () presentation.(self,) end |
#master? ⇒ Boolean
Returns true
if this asset is on the master slide.
115 116 117 |
# File 'lib/ruic/assets.rb', line 115 def master? presentation.master?(self) end |
#name ⇒ String
Returns the name of this asset in the scene graph.
177 178 179 |
# File 'lib/ruic/assets.rb', line 177 def name properties['name'].get( self, presentation.(self) ) end |
#name=(new_name) ⇒ String
Change the name of the asset in the scene graph.
184 185 186 187 |
# File 'lib/ruic/assets.rb', line 184 def name=( new_name ) @path = nil # invalidate the memoization properties['name'].set( self, new_name, presentation.(self) ) end |
#on_slide(slide_name_or_index) ⇒ SlideValues
Returns a proxy that yields attribute values for a specific slide.
155 156 157 158 159 |
# File 'lib/ruic/assets.rb', line 155 def () if () UIC::SlideValues.new( self, ) end end |
#parent ⇒ AssetBase
Returns the parent of this asset in the scene graph.
71 72 73 |
# File 'lib/ruic/assets.rb', line 71 def parent presentation.parent_asset(self) end |
#path ⇒ String
Returns the script path to this asset.
164 165 166 |
# File 'lib/ruic/assets.rb', line 164 def path @path ||= @presentation.path_to(self) end |
#path_to(other_asset) ⇒ String
Returns the script path to another asset, relative to this one.
172 173 174 |
# File 'lib/ruic/assets.rb', line 172 def path_to(other_asset) @presentation.path_to(other_asset,self) end |
#properties ⇒ Hash
Returns a hash mapping attribute names to Property instances.
25 26 27 |
# File 'lib/ruic/assets.rb', line 25 def properties self.class.properties end |
#slide? ⇒ Boolean
Returns true
if this asset is a Slide.
120 121 122 |
# File 'lib/ruic/assets.rb', line 120 def false end |
#slides ⇒ SlideCollection
Returns an array-like collection of all slides that the asset is available on.
133 134 135 |
# File 'lib/ruic/assets.rb', line 133 def presentation.(self) end |
#to_xml ⇒ String
Returns the XML representation of the scene graph element.
242 243 244 |
# File 'lib/ruic/assets.rb', line 242 def to_xml @el.to_xml end |
#type ⇒ String
Returns the type of this asset. For example: "Model"
, "Material"
, "ReferencedMaterial"
, "PathAnchorPoint"
, etc.
65 66 67 |
# File 'lib/ruic/assets.rb', line 65 def type self.class.name end |