Class: Zui::Host
- Inherits:
-
Object
- Object
- Zui::Host
- Defined in:
- lib/zui/host.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #configure! ⇒ Object
- #environment(base = ENV.to_h) ⇒ Object
- #executable ⇒ Object
-
#initialize(platform: Platform.current, environment: ENV, client: nil) ⇒ Host
constructor
A new instance of Host.
Constructor Details
#initialize(platform: Platform.current, environment: ENV, client: nil) ⇒ Host
Returns a new instance of Host.
7 8 9 10 11 |
# File 'lib/zui/host.rb', line 7 def initialize(platform: Platform.current, environment: ENV, client: nil) @platform = platform.assert_supported! @environment = environment @client = client || Client.new(platform:, environment:) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/zui/host.rb', line 5 def client @client end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
5 6 7 |
# File 'lib/zui/host.rb', line 5 def platform @platform end |
Instance Method Details
#available? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/zui/host.rb', line 21 def available? override = @environment["ZUI_HOST"] return File.executable?(File.(override)) if override && !override.empty? client.configured? end |
#configure! ⇒ Object
28 |
# File 'lib/zui/host.rb', line 28 def configure! = client.configure! |
#environment(base = ENV.to_h) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/zui/host.rb', line 30 def environment(base = ENV.to_h) override = @environment["ZUI_HOST"] return base.to_h.dup if override && !override.empty? client.environment(base) end |
#executable ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/zui/host.rb', line 13 def executable override = @environment["ZUI_HOST"] return checked_executable(override) if override && !override.empty? return client.executable if client.configured? raise ArgumentError, "Zui is not configured for #{platform.id}; run `zui doctor --fix`" end |