Class: UU::OS::GVC::Component
- Inherits:
-
Object
- Object
- UU::OS::GVC::Component
- Defined in:
- uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb
Overview
Common component object.
Direct Known Subclasses
DataTable::DataTable, Form::FormButton, Form::InfoBar, Form::Input, Form::Label, Image, Table
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
Component height.
-
- (Object) id
readonly
Unique component ID.
-
- (Object) name
readonly
Component name.
-
- (Object) width
readonly
Component width.
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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 41 def initialize(container, data = nil) if (container.nil?) || (!container.kind_of?Container) 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.
14 15 16 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 14 def attributes @attributes end |
- (Object) code (readonly)
Component code.
23 24 25 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 23 def code @code end |
- (Object) component_type (readonly)
Component type.
26 27 28 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 26 def component_type @component_type end |
- (Object) form (readonly)
ID of form to which component belongs.
35 36 37 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 35 def form @form end |
- (Object) height (readonly)
Component height.
32 33 34 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 32 def height @height end |
- (Object) id (readonly)
Unique component ID.
17 18 19 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 17 def id @id end |
- (Object) name (readonly)
Component name.
20 21 22 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 20 def name @name end |
- (Object) width (readonly)
Component width.
29 30 31 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 29 def width @width end |
Instance Method Details
- (Object) add_message(message)
Adds message for component.
108 109 110 111 112 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 108 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.
121 122 123 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 121 def focus() return @container.focus(id) end |
- (Array<UU::OS::GVC::Message>) messages
Returns list of all component messages.
97 98 99 100 101 102 103 |
# File 'uu_os_gvc-0.9.6/lib/uu/os/gvc/component.rb', line 97 def result = [] @container..each do || result << if ..include?id end result end |