Class: MySolaredge::CredentialGetter
- Inherits:
-
Object
- Object
- MySolaredge::CredentialGetter
- Defined in:
- lib/my_solaredge/credential_getter.rb
Overview
Gets credentials from a source, either YAML or a string
Defined Under Namespace
Classes: InvalidSourceError, SiteIdNotAnIntegerError
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #api_key ⇒ Object
-
#initialize(data_source) ⇒ CredentialGetter
constructor
A new instance of CredentialGetter.
- #site_id ⇒ Object
Constructor Details
#initialize(data_source) ⇒ CredentialGetter
Returns a new instance of CredentialGetter.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/my_solaredge/credential_getter.rb', line 11 def initialize(data_source) case data_source.class.to_s when 'Hash' load_hash(data_source) when 'String' load_file(data_source) else raise InvalidSourceError end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/my_solaredge/credential_getter.rb', line 9 def data @data end |
Instance Method Details
#api_key ⇒ Object
26 27 28 |
# File 'lib/my_solaredge/credential_getter.rb', line 26 def api_key data["api_key"] end |
#site_id ⇒ Object
22 23 24 |
# File 'lib/my_solaredge/credential_getter.rb', line 22 def site_id data["site_id"] end |