Class: StreamdeckProf::Profile
- Inherits:
-
Object
- Object
- StreamdeckProf::Profile
- Defined in:
- lib/streamdeck_prof/profile.rb
Instance Attribute Summary collapse
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#profile_dir ⇒ Object
readonly
Returns the value of attribute profile_dir.
Instance Method Summary collapse
- #actions ⇒ Object
- #actions=(actions) ⇒ Object
- #app_identifier ⇒ Object
- #app_identifier=(app_identifier) ⇒ Object
-
#initialize(profile_dir) ⇒ Profile
constructor
A new instance of Profile.
- #name ⇒ Object
- #name=(name) ⇒ Object
- #save ⇒ Object
- #uuid ⇒ Object
Constructor Details
#initialize(profile_dir) ⇒ Profile
Returns a new instance of Profile.
12 13 14 15 |
# File 'lib/streamdeck_prof/profile.rb', line 12 def initialize(profile_dir) @profile_dir = profile_dir @manifest = JSON.parse(File.read(manifest_path)) end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
10 11 12 |
# File 'lib/streamdeck_prof/profile.rb', line 10 def manifest @manifest end |
#profile_dir ⇒ Object (readonly)
Returns the value of attribute profile_dir.
10 11 12 |
# File 'lib/streamdeck_prof/profile.rb', line 10 def profile_dir @profile_dir end |
Instance Method Details
#actions ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/streamdeck_prof/profile.rb', line 37 def actions @actions ||= StreamdeckProf::ActionList.new.tap do |actions| actions_hash = actions.to_h manifest["Actions"].each do |key, value| actions_hash[key] = make_action(key, value) end end end |
#actions=(actions) ⇒ Object
46 47 48 |
# File 'lib/streamdeck_prof/profile.rb', line 46 def actions=(actions) @actions = actions || StreamdeckProf::ActionList.new end |
#app_identifier ⇒ Object
29 30 31 |
# File 'lib/streamdeck_prof/profile.rb', line 29 def app_identifier manifest["AppIdentifier"] end |
#app_identifier=(app_identifier) ⇒ Object
33 34 35 |
# File 'lib/streamdeck_prof/profile.rb', line 33 def app_identifier=(app_identifier) manifest["AppIdentifier"] = app_identifier end |
#name ⇒ Object
21 22 23 |
# File 'lib/streamdeck_prof/profile.rb', line 21 def name manifest["Name"] end |
#name=(name) ⇒ Object
25 26 27 |
# File 'lib/streamdeck_prof/profile.rb', line 25 def name=(name) manifest["Name"] = name end |
#save ⇒ Object
50 51 52 53 54 |
# File 'lib/streamdeck_prof/profile.rb', line 50 def save sync_manifest @actions&.to_h&.each { |position_key, action| action.save(action_storage_path(position_key)) } File.write(manifest_path, JSON.dump(manifest)) end |
#uuid ⇒ Object
17 18 19 |
# File 'lib/streamdeck_prof/profile.rb', line 17 def uuid File.basename(profile_dir, ".sdProfile") end |