Class: Keyremac::Root
- Inherits:
-
Object
- Object
- Keyremac::Root
- Includes:
- Container
- Defined in:
- lib/keyremac/base.rb,
lib/keyremac/dump.rb
container collapse
-
#root_item ⇒ Object
readonly
Returns the value of attribute root_item.
Attributes included from Container
container collapse
- #app(only, **options, &block) ⇒ Item
-
#initialize ⇒ Root
constructor
A new instance of Root.
-
#item(app: nil, inputsource: nil, &block) ⇒ Item
yield [] children.
Instance Method Summary collapse
Methods included from Container
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Keyremac::Container
Instance Attribute Details
#root_item ⇒ Object (readonly)
Returns the value of attribute root_item.
100 101 102 |
# File 'lib/keyremac/base.rb', line 100 def root_item @root_item end |
Instance Method Details
#app(only, **options, &block) ⇒ Item
127 128 129 130 |
# File 'lib/keyremac/base.rb', line 127 def app(only, **, &block) [:app] = only item(**, &block) end |
#dump(xml = nil) ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/keyremac/dump.rb', line 90 def dump(xml = nil) xml ||= Builder::XmlMarkup.new(indent: 2) xml.instruct! xml.root do @root_item.dump xml @children.each { |child| child.dump(xml) } end end |
#item(app: nil, inputsource: nil, &block) ⇒ Item
yield [] children
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/keyremac/base.rb', line 113 def item(app: nil, inputsource: nil, &block) Item.new.tap { |item| item.only_ app if app item.inputsource_only_ inputsource if inputsource @children << item Keyremac::Focus.set_focus item do item.instance_eval(&block) end } end |