module ObjectX
This file contains the following classes:
## Object class MacroObject
Public Instance Methods
action_to_object(ap, e, item, macro)
click to toggle source
# File lib/ruby-macrodroid/base.rb, line 13 def action_to_object(ap, e, item, macro) debug = true puts 'inside action_to_object: item.xml: ' + item.xml if debug if item.element('description') then item.xpath('description').map do |description| inner_lines = description.text.to_s.strip.lines puts 'inner_lines: ' + inner_lines.inspect if debug action = if e.text.to_s.strip.empty? then inner_lines.shift.strip else e.text.strip end puts 'action: ' + action.inspect if debug r = ap.find_action action puts 'r: ' + r.inspect if debug nested = description.element('item/*') puts 'nested: ' + nested.inspect if debug if r[1].any? and not nested then macro.add r[0].new(r[1]) else puts 'description: ' + description.xml.inspect if debug #o = r[0].new([description, self]) if r index = macro.actions.length macro.add Action.new o = object_create(r[0],[description, macro, r[1]]) if r macro.actions[index] = o puts 'after o' if debug o end end else action = e.text.strip puts 'action: ' + action.inspect if $debug r = ap.find_action action a = e.xpath('item/*') h = if a.any? then a.map {|node| [node.name.to_sym, node.text.to_s]}.to_h else {} end puts 'h: ' + h.inspect if $debug #r = ap.find_action action #r[0].new(h.merge(macro: self)) if r o = object_create(r[0], h.merge(macro: macro)) if r macro.add o o end end
object_create(klass, *args)
click to toggle source
# File lib/ruby-macrodroid/base.rb, line 84 def object_create(klass, *args) begin klass.new(*args) rescue raise MacroError, klass.to_s + ': ' + ($!).to_s end end
varify(label, value='')
click to toggle source
# File lib/ruby-macrodroid/base.rb, line 93 def varify(label, value='') type = VAR_TYPES[value.class.to_s.to_sym] h = { boolean_value: false, decimal_value: 0.0, int_value: 0, name: label, string_value: '', type: type[0] } h[type[1]] = value h end