Class: Bcli::Config
- Inherits:
-
Object
- Object
- Bcli::Config
- Defined in:
- lib/bcli/config.rb
Instance Attribute Summary collapse
-
#creds ⇒ Object
readonly
Returns the value of attribute creds.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
- #creds_present? ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #read_from_file ⇒ Object
- #token_expired? ⇒ Boolean
Constructor Details
Instance Attribute Details
#creds ⇒ Object (readonly)
Returns the value of attribute creds.
2 3 4 |
# File 'lib/bcli/config.rb', line 2 def creds @creds end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
2 3 4 |
# File 'lib/bcli/config.rb', line 2 def file_path @file_path end |
Instance Method Details
#creds_present? ⇒ Boolean
21 22 23 |
# File 'lib/bcli/config.rb', line 21 def creds_present? creds[:email] && creds[:password] end |
#read_from_file ⇒ Object
12 13 14 15 |
# File 'lib/bcli/config.rb', line 12 def read_from_file return {} unless File.exist?(file_path) YAML.load_file(file_path) end |
#token_expired? ⇒ Boolean
17 18 19 |
# File 'lib/bcli/config.rb', line 17 def token_expired? creds[:issued_at] && (Time.now.to_i - creds[:issued_at]) > (3600 * 24) end |