Class: CallDetail

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, call_type) ⇒ CallDetail

Returns a new instance of CallDetail.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tbr/call_detail.rb', line 9

def initialize(record,call_type)
	fields = record.split(',')
	if fields[0] == 'DC' && fields[8] == 'D' then  # Call Detail record
		@call_type = call_type.desc(fields[9])
		@duration = Time.at(fields[10].to_i).gmtime.strftime('%R:%S')
		@destination = fields[12]
		@area = fields[16]
		@start_date = Time.parse(fields[18]).strftime('%d/%m/%Y')
		@start_time = fields[20]
		@cost = fields[33].to_f
	else
		raise ArgumentError, "Invalid record type - " + fields[0], caller
	end
end

Instance Attribute Details

#areaObject (readonly)

OBS record type DC - page 41



7
8
9
# File 'lib/tbr/call_detail.rb', line 7

def area
  @area
end

#call_typeObject (readonly)

OBS record type DC - page 41



7
8
9
# File 'lib/tbr/call_detail.rb', line 7

def call_type
  @call_type
end

#costObject (readonly)

OBS record type DC - page 41



7
8
9
# File 'lib/tbr/call_detail.rb', line 7

def cost
  @cost
end

#destinationObject (readonly)

OBS record type DC - page 41



7
8
9
# File 'lib/tbr/call_detail.rb', line 7

def destination
  @destination
end

#durationObject (readonly)

OBS record type DC - page 41



7
8
9
# File 'lib/tbr/call_detail.rb', line 7

def duration
  @duration
end

#start_dateObject (readonly)

OBS record type DC - page 41



7
8
9
# File 'lib/tbr/call_detail.rb', line 7

def start_date
  @start_date
end

#start_timeObject (readonly)

OBS record type DC - page 41



7
8
9
# File 'lib/tbr/call_detail.rb', line 7

def start_time
  @start_time
end