Class: Senec::Cloud::TechnicalData

Inherits:
Object
  • Object
show all
Defined in:
lib/senec/cloud/technical_data.rb

Defined Under Namespace

Classes: Finder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection: nil, system_id: nil, data: nil) ⇒ TechnicalData

Returns a new instance of TechnicalData.

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
# File 'lib/senec/cloud/technical_data.rb', line 37

def initialize(connection: nil, system_id: nil, data: nil)
  raise ArgumentError unless connection.nil? ^ data.nil?

  @connection = connection
  @system_id = system_id

  # Useful for testing only
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



54
55
56
# File 'lib/senec/cloud/technical_data.rb', line 54

def data
  @data
end

#system_idObject (readonly)

Returns the value of attribute system_id.



54
55
56
# File 'lib/senec/cloud/technical_data.rb', line 54

def system_id
  @system_id
end

Class Method Details

.[](connection) ⇒ Object



33
34
35
# File 'lib/senec/cloud/technical_data.rb', line 33

def self.[](connection)
  Finder.new(connection)
end

Instance Method Details

#load_dataObject



47
48
49
50
51
52
# File 'lib/senec/cloud/technical_data.rb', line 47

def load_data
  raise 'Data already present!' if @data

  @system_id ||= connection.default_system_id
  @data = fetch_data
end