Class: MySolaredge::CredentialGetter

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dataObject (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_keyObject



26
27
28
# File 'lib/my_solaredge/credential_getter.rb', line 26

def api_key
  data["api_key"]
end

#site_idObject



22
23
24
# File 'lib/my_solaredge/credential_getter.rb', line 22

def site_id
  data["site_id"]
end