Class: MacroObject
- Inherits:
-
Object
- Object
- MacroObject
- Defined in:
- lib/ruby-macrodroid.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(h = {}) ⇒ MacroObject
constructor
A new instance of MacroObject.
- #to_h ⇒ Object
- #to_s ⇒ Object (also: #to_summary)
Constructor Details
#initialize(h = {}) ⇒ MacroObject
Returns a new instance of MacroObject.
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'lib/ruby-macrodroid.rb', line 1072 def initialize(h={}) $env ||= {} @h = {constraint_list: [], is_or_condition: false, is_disabled: false}.merge(h) @list = [] # fetch the class name and convert from camelCase to snake_eyes @type = self.class.to_s.sub(/Trigger|Action$/,'')\ .gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\ .gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\ .downcase.to_sym end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
1070 1071 1072 |
# File 'lib/ruby-macrodroid.rb', line 1070 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1069 1070 1071 |
# File 'lib/ruby-macrodroid.rb', line 1069 def type @type end |
Instance Method Details
#to_h ⇒ Object
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 |
# File 'lib/ruby-macrodroid.rb', line 1087 def to_h() h = @h h2 = h.inject({}) do |r,x| puts 'x: ' + x.inspect if @debug key, value = x puts 'key: ' + key.inspect if @debug new_key = key.to_s.gsub(/\w_\w/){|x| x[0] + x[-1].upcase} new_key = new_key.prepend 'm_' unless @list.include? new_key new_key = 'm_SIGUID' if new_key == 'm_siguid' r.merge(new_key => value) end h2.merge('m_classType' => self.class.to_s) end |
#to_s ⇒ Object Also known as: to_summary
1105 1106 1107 |
# File 'lib/ruby-macrodroid.rb', line 1105 def to_s() "#<%s %s>" % [self.class, @h.inspect] end |