Class: UU::OS::GVC::Component
- Inherits:
-
Object
- Object
- UU::OS::GVC::Component
- Defined in:
- uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb
Overview
Common component object.
Direct Known Subclasses
DataTable::DataTable, Form::FormButton, Form::InfoBar, Form::Input, Form::Label, Button, Icon, Image, Link, Table, Text, TouchIcon, Tree, UxmlFragment, Widget
Instance Attribute Summary (collapse)
-
- (Object) attributes
readonly
deprecated
Deprecated.
Direct access to attribute values through the attributes attribute is deprecated and is not going to be supported in the future versions. Use individual attribute accessors instead.
-
- (Object) code
readonly
Component code.
-
- (Object) component_type
readonly
Component type.
-
- (Object) form
readonly
ID of form to which component belongs.
-
- (Object) height
readonly
deprecated
Deprecated.
component may not respect this dimension
-
- (Object) id
readonly
Unique component ID.
-
- (Object) name
readonly
Component name.
-
- (Object) width
readonly
deprecated
Deprecated.
component may not respect this dimension
Instance Method Summary (collapse)
-
- (Object) add_message(message)
Adds message for component.
-
- (FalseClass, TrueClass) focus
Sets focus to this component.
-
- (Component) initialize(container, data = nil)
constructor
Creates new instance of component.
-
- (Array<UU::OS::GVC::Message>) messages
Returns list of all component messages.
Constructor Details
- (Component) initialize(container, data = nil)
Creates new instance of component.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 44 def initialize(container, data = nil) # Moved 'require' here because there was a cyclic dependency between # component.rb and container.rb. require 'uu/os/gvc/container' if (container.nil?) raise ArgumentError.new('Parent container must be defined to create new component.') end if data.nil? @attributes = {} return end if data.kind_of?String data = JSON.parse(data, :symbolize_names => true) end if data.kind_of?Hash @attributes = data elsif data.kind_of?Component if data.attributes @attributes = data.attributes else @attributes = {} end else raise ArgumentError.new("Component data must be JSON String or Hash, but was #{data.class}.") end @container = container end |
Instance Attribute Details
- (Object) attributes (readonly)
Direct access to attribute values through the attributes attribute is deprecated and is not going to be supported in the future versions. Use individual attribute accessors instead.
Raw component attributes.
13 14 15 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 13 def attributes @attributes end |
- (Object) code (readonly)
Component code.
22 23 24 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 22 def code @code end |
- (Object) component_type (readonly)
Component type.
25 26 27 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 25 def component_type @component_type end |
- (Object) form (readonly)
ID of form to which component belongs.
38 39 40 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 38 def form @form end |
- (Object) height (readonly)
component may not respect this dimension
Component height.
35 36 37 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 35 def height @height end |
- (Object) id (readonly)
Unique component ID.
16 17 18 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 16 def id @id end |
- (Object) name (readonly)
Component name.
19 20 21 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 19 def name @name end |
- (Object) width (readonly)
component may not respect this dimension
Component width.
30 31 32 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 30 def width @width end |
Instance Method Details
- (Object) add_message(message)
Adds message for component.
115 116 117 118 119 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 115 def () msg = UU::OS::GVC::Message.new() msg. << id @container.(msg) end |
- (FalseClass, TrueClass) focus
Sets focus to this component. Actual behavior of focus depends on type of focused component and also on type of container in which is component placed. Only one component can be focused, setting focus on one component disables focus of previously focused component within container.
128 129 130 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 128 def focus() return @container.focus(id) end |
- (Array<UU::OS::GVC::Message>) messages
Returns list of all component messages.
104 105 106 107 108 109 110 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/component.rb', line 104 def result = [] @container..each do || result << if ..include?id end result end |