Class: Pair::Config
- Inherits:
-
Object
- Object
- Pair::Config
- Defined in:
- lib/pair/config.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#input ⇒ Object
Returns the value of attribute input.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #api_token ⇒ Object
- #growl_enabled? ⇒ Boolean
-
#initialize(host = HOST, input = STDIN, output = STDOUT) ⇒ Config
constructor
A new instance of Config.
- #method_missing(method, *args, &block) ⇒ Object
- #ssh_enabled? ⇒ Boolean
-
#ssh_on? ⇒ Boolean
FIXME: Does this belong in config?.
- #update(options = {}) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/pair/config.rb', line 21 def method_missing(method, *args, &block) method = method.to_s if method =~ /=$/ # setter self[method.gsub(/=$/,'').to_sym] = [*args].first else self[method.to_sym] || super end end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/pair/config.rb', line 13 def host @host end |
#input ⇒ Object
Returns the value of attribute input.
13 14 15 |
# File 'lib/pair/config.rb', line 13 def input @input end |
#output ⇒ Object
Returns the value of attribute output.
13 14 15 |
# File 'lib/pair/config.rb', line 13 def output @output end |
Instance Method Details
#api_token ⇒ Object
31 32 33 |
# File 'lib/pair/config.rb', line 31 def api_token self[:api_token] end |
#growl_enabled? ⇒ Boolean
39 40 41 |
# File 'lib/pair/config.rb', line 39 def growl_enabled? self[:growl_enabled] end |
#ssh_enabled? ⇒ Boolean
35 36 37 |
# File 'lib/pair/config.rb', line 35 def ssh_enabled? self[:ssh_enabled] end |
#ssh_on? ⇒ Boolean
FIXME: Does this belong in config?
44 45 46 47 48 49 50 |
# File 'lib/pair/config.rb', line 44 def ssh_on? if Pair::OS.os_x? `systemsetup -getremotelogin`.match("Remote Login: On") elsif Pair::OS.linux? `ps aux | grep sshd | grep -v grep` != "" end end |
#update(options = {}) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/pair/config.rb', line 52 def update( = {}) if .is_a? Hash .each do |key, value| self[key] = value end end end |