Class: Sandy::Area

Inherits:
Object
  • Object
show all
Defined in:
lib/sandy/area.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customers_affected, location, options = {}) ⇒ Area

Returns a new instance of Area.



12
13
14
15
16
17
18
19
20
21
# File 'lib/sandy/area.rb', line 12

def initialize(customers_affected, location, options = {})
  @name = location
  @customers_affected = customers_affected
  @parent = options[:parent]
  @total_customers = options[:total_customers]
  @latitude = options[:latitude]
  @longitude = options[:longitude]
  @estimated_recovery_time = options[:estimated_recovery_time]
  @children = options[:children] || []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



3
4
5
# File 'lib/sandy/area.rb', line 3

def children
  @children
end

#customers_affectedObject (readonly)

Returns the value of attribute customers_affected.



3
4
5
# File 'lib/sandy/area.rb', line 3

def customers_affected
  @customers_affected
end

#estimated_recovery_timeObject (readonly)

Returns the value of attribute estimated_recovery_time.



3
4
5
# File 'lib/sandy/area.rb', line 3

def estimated_recovery_time
  @estimated_recovery_time
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



3
4
5
# File 'lib/sandy/area.rb', line 3

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



3
4
5
# File 'lib/sandy/area.rb', line 3

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/sandy/area.rb', line 3

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/sandy/area.rb', line 3

def parent
  @parent
end

#total_customersObject (readonly)

Returns the value of attribute total_customers.



3
4
5
# File 'lib/sandy/area.rb', line 3

def total_customers
  @total_customers
end

Instance Method Details

#to_json(*a) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/sandy/area.rb', line 27

def to_json(*a)
  {"name" => @name, 
   "customers_affected" => @customers_affected,
   "parent" => @parent.to_s,
   "total_customers" => @total_customers,
   "latitude" => @latitude,
   "longitude" => @longitude, 
   "estimated_recovery_time" => @longitude,
   "children" => @children }.to_json
end

#to_sObject



23
24
25
# File 'lib/sandy/area.rb', line 23

def to_s
  @name
end