Class: MacroDroid
- Inherits:
-
Object
- Object
- MacroDroid
- Defined in:
- lib/ruby-macrodroid.rb
Instance Attribute Summary collapse
-
#geofence ⇒ Object
readonly
Returns the value of attribute geofence.
-
#macros ⇒ Object
readonly
Returns the value of attribute macros.
Instance Method Summary collapse
- #add(macro) ⇒ Object
- #build_h ⇒ Object
- #export_json ⇒ Object (also: #to_json)
-
#initialize(obj = nil, debug: false) ⇒ MacroDroid
constructor
A new instance of MacroDroid.
- #to_h ⇒ Object
-
#to_pc ⇒ Object
returns pseudocode.
- #to_s ⇒ Object
- #to_summary ⇒ Object
Constructor Details
#initialize(obj = nil, debug: false) ⇒ MacroDroid
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
# File 'lib/ruby-macrodroid.rb', line 684 def initialize(obj=nil, debug: false) @debug = debug if obj then raw_s, _ = RXFHelper.read(obj) s = raw_s.strip if s[0] == '{' then import_json(s) elsif s[0] == '<' import_xml(s) @h = build_h else puts 's: ' + s.inspect if @debug if s =~ /m(?:acro)?:\s/ then puts 'before RowX.new' if @debug s2 = s.gsub(/^m:/,'macro:').gsub(/^t:/,'trigger:')\ .gsub(/^a:/,'action:').gsub(/^c:/,'constraint:') xml = RowX.new(s2.gsub(/^#.*/,'')).to_xml import_rowxml(xml) elsif s =~ /^# / xml = pc_to_xml(s) import_xml(xml) else raise MacroDroidError, 'invalid input' end @h = build_h end else @h = build_h() @macros = [] end end |
Instance Attribute Details
#geofence ⇒ Object (readonly)
Returns the value of attribute geofence.
682 683 684 |
# File 'lib/ruby-macrodroid.rb', line 682 def geofence @geofence end |
#macros ⇒ Object (readonly)
Returns the value of attribute macros.
682 683 684 |
# File 'lib/ruby-macrodroid.rb', line 682 def macros @macros end |
Instance Method Details
#add(macro) ⇒ Object
737 738 739 |
# File 'lib/ruby-macrodroid.rb', line 737 def add(macro) @macros << macro end |
#build_h ⇒ Object
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
# File 'lib/ruby-macrodroid.rb', line 741 def build_h() puts 'inside Macro#build_h' if @debug { cell_tower_groups: [], cell_towers_ignore: [], drawer_configuration: { drawer_items: [], background_color: -1, header_color: 12692882, left_side: false, swipe_area_color: -7829368, swipe_area_height: 20, swipe_area_offset: 40, swipe_area_opacity: 80, swipe_area_width: 14, visible_swipe_area_width: 0 }, variables: [], user_icons: [], geofence_data: { geofence_map: {} }, macro_list: [] } end |
#export_json ⇒ Object Also known as: to_json
769 770 771 772 773 |
# File 'lib/ruby-macrodroid.rb', line 769 def export_json() to_h.to_json end |
#to_h ⇒ Object
778 779 780 781 782 |
# File 'lib/ruby-macrodroid.rb', line 778 def to_h() @h.merge(macro_list: @macros.map(&:to_h)).to_camel_case end |
#to_pc ⇒ Object
returns pseudocode
786 787 788 |
# File 'lib/ruby-macrodroid.rb', line 786 def to_pc() @macros.map(&:to_pc).join("\n\n") end |
#to_s ⇒ Object
790 791 792 |
# File 'lib/ruby-macrodroid.rb', line 790 def to_s() @macros.map(&:to_s).join("\n") end |
#to_summary ⇒ Object
794 795 796 |
# File 'lib/ruby-macrodroid.rb', line 794 def to_summary() @macros.map(&:to_summary).join("\n") end |