Class: Urbit::Settings
- Inherits:
-
Set
- Object
- Set
- Urbit::Settings
- Defined in:
- lib/urbit/settings.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](desk:) ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #list ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
23 24 25 |
# File 'lib/urbit/settings.rb', line 23 def initialize @hash = {} end |
Class Method Details
.load(ship:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/urbit/settings.rb', line 8 def load(ship:) ship.subscribe(app: 'settings-store', path: '/all') scry = ship.scry(app: "settings-store", path: "/all", mark: "json") # scry = self.scry(app: "settings-store", path: "/desk/#{desk}", mark: "json") s = Settings.new if scry[:body] body = JSON.parse scry[:body] body["all"].each do |k, v| # At this level the keys are the desks and the values are the buckets s << Setting.new(ship: ship, desk: k, buckets: v) end end s end |
Instance Method Details
#[](desk:) ⇒ Object
27 28 29 |
# File 'lib/urbit/settings.rb', line 27 def [](desk:) self.select {|s| desk == s.desk}.first end |
#list ⇒ Object
31 32 33 34 |
# File 'lib/urbit/settings.rb', line 31 def list self.each {|s| puts s.to_string} nil end |