Class: QML::Component
- Inherits:
-
Object
- Object
- QML::Component
- Defined in:
- lib/qml/component.rb
Overview
The Component class is used to instantiate objects like Window / ApplicationWindow objects from QML files.
You usually do not need to use this class because Application#load, #load_path, #load_data do same for the application top-level objects such as main windows.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#create ⇒ QML::JSObject
Instantiates a object from the QML file.
-
#initialize(data: nil, path: nil) ⇒ Object
constructor
Creates an component.
- #load_data(data) ⇒ Object
- #load_path(path) ⇒ Object
Constructor Details
#initialize(data: nil, path: nil) ⇒ Object
Creates an component. Either data or path must be specified.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/qml/component.rb', line 19 def initialize(data: nil, path: nil) fail TypeError, "neither data nor path privided" unless data || path initialize_impl case when data load_data(data) when path load_path(path) end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/qml/component.rb', line 13 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/qml/component.rb', line 13 def path @path end |
Instance Method Details
#create ⇒ QML::JSObject
Instantiates a object from the QML file.
51 52 53 54 55 |
# File 'lib/qml/component.rb', line 51 def create check_error_string do create_impl end end |
#load_data(data) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/qml/component.rb', line 41 def load_data(data) check_error_string do @data = data load_data_impl(data, "<<STRING>>") end self end |
#load_path(path) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/qml/component.rb', line 32 def load_path(path) path = path.to_s check_error_string do @path = Pathname.new(path) load_path_impl(path) end self end |