Class: ET::Config
- Inherits:
-
Object
- Object
- ET::Config
- Defined in:
- lib/et/config.rb
Instance Attribute Summary collapse
-
#current_dir ⇒ Object
readonly
Returns the value of attribute current_dir.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #exists? ⇒ Boolean
- #host ⇒ Object
-
#initialize(current_dir) ⇒ Config
constructor
A new instance of Config.
- #path ⇒ Object
- #save!(options) ⇒ Object
- #token ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(current_dir) ⇒ Config
Returns a new instance of Config.
8 9 10 |
# File 'lib/et/config.rb', line 8 def initialize(current_dir) @current_dir = current_dir end |
Instance Attribute Details
#current_dir ⇒ Object (readonly)
Returns the value of attribute current_dir.
6 7 8 |
# File 'lib/et/config.rb', line 6 def current_dir @current_dir end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/et/config.rb', line 36 def [](key) [key] end |
#exists? ⇒ Boolean
32 33 34 |
# File 'lib/et/config.rb', line 32 def exists? !path.nil? end |
#host ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/et/config.rb', line 16 def host if ["host"].start_with?("http") ["host"] else "http://" + ["host"] end end |
#path ⇒ Object
12 13 14 |
# File 'lib/et/config.rb', line 12 def path @path ||= find_config_file(current_dir) end |
#save!(options) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/et/config.rb', line 40 def save!() if exists? File.write(path, .to_yaml) else File.write(File.join(current_dir, ".et"), .to_yaml) end end |
#token ⇒ Object
28 29 30 |
# File 'lib/et/config.rb', line 28 def token ["token"] end |
#username ⇒ Object
24 25 26 |
# File 'lib/et/config.rb', line 24 def username ["username"] end |