Class: Enlighten::System
- Inherits:
-
Object
show all
- Defined in:
- lib/enlighten.rb
Constant Summary
collapse
- END_POINTS =
[:energy_lifetime,:envoys,:inventory,:monthly_production,:rgm_stats,:stats,:summary]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ System
Returns a new instance of System.
45
46
47
48
49
50
51
|
# File 'lib/enlighten.rb', line 45
def initialize(params={})
@id = params[:id].to_i
@params=self.class.default_params.merge(params)
@systems = fetch(nil).systems
@attributes = @systems.map{|system| system if system['system_id'] == @id }[0] rescue {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
41
42
43
|
# File 'lib/enlighten.rb', line 41
def method_missing(method,*args)
@attributes[method.to_s] || super
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
18
19
20
|
# File 'lib/enlighten.rb', line 18
def params
@params
end
|
#systems ⇒ Object
Returns the value of attribute systems.
18
19
20
|
# File 'lib/enlighten.rb', line 18
def systems
@systems
end
|
Class Method Details
.config(args = {}) ⇒ Object
Also known as:
default_options=
31
32
33
34
|
# File 'lib/enlighten.rb', line 31
def config(args={})
@default_params = @default_params.merge(args).freeze unless args.empty?
@default_params
end
|
.default_params ⇒ Object
57
58
59
|
# File 'lib/enlighten.rb', line 57
def self.default_params
@default_params
end
|
.find(id) ⇒ Object
53
54
55
|
# File 'lib/enlighten.rb', line 53
def self.find(id)
new(:id=>id)
end
|
.url ⇒ Object
61
62
63
|
# File 'lib/enlighten.rb', line 61
def self.url
"https://#{@default_params[:host]}#{@default_params[:path]}"
end
|