Class: ScheduleFormatter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unformatted_hash, date, group) ⇒ ScheduleFormatter

Returns a new instance of ScheduleFormatter.



4
5
6
7
8
9
10
11
# File 'lib/schedule_formatter.rb', line 4

def initialize unformatted_hash, date, group
  @unformatted_hash = unformatted_hash
  @date = find_date(date)
  @formatted_result
  @group = group
  @current_status = set_timer
  @color = set_color
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



2
3
4
# File 'lib/schedule_formatter.rb', line 2

def color
  @color
end

#formatted_resultObject (readonly)

Returns the value of attribute formatted_result.



2
3
4
# File 'lib/schedule_formatter.rb', line 2

def formatted_result
  @formatted_result
end

Instance Method Details

#formatObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/schedule_formatter.rb', line 13

def format
  @formatted_result = "\n    Load Shedding Schedule for \#{@date} : \#{@date.strftime('%A')}\n    Group Number : \#{@group}\n    Morning : \#{format_time @unformatted_hash.first}\n    Evening : \#{format_time @unformatted_hash.last}\n    Currently: \#{@current_status.status} : \#{@current_status.alt_status} in \#{@current_status.time_to_change}\n    EOS\nend\n"