Class: ServiceSummary
- Inherits:
-
Object
- Object
- ServiceSummary
- Defined in:
- lib/tbr/service_summary.rb
Constant Summary collapse
- DS_CODE =
OBS record type DS - page 30
0- DS_SERVICE =
6- DS_TYPE =
8- DS_CALL_TYPE =
10- DS_SERVICE_TYPE =
11- DS_UNITS =
12- DS_CALL_COUNT =
13- DS_START_DATE =
15- DS_COST =
33
Instance Attribute Summary collapse
-
#call_count ⇒ Object
readonly
Returns the value of attribute call_count.
-
#call_type ⇒ Object
readonly
Returns the value of attribute call_type.
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#service_number ⇒ Object
readonly
Returns the value of attribute service_number.
-
#service_type ⇒ Object
readonly
Returns the value of attribute service_type.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
Instance Method Summary collapse
-
#initialize(record, call_type) ⇒ ServiceSummary
constructor
A new instance of ServiceSummary.
- #to_a ⇒ Object
Constructor Details
#initialize(record, call_type) ⇒ ServiceSummary
Returns a new instance of ServiceSummary.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tbr/service_summary.rb', line 20 def initialize(record,call_type) fields = record.split(',') if fields[DS_CODE] == 'DS' && fields[DS_TYPE] == 'D' then # Service Summary and Detail record @service_number = fields[DS_SERVICE] @call_type = call_type.desc(fields[DS_CALL_TYPE]) @service_type = fields[DS_SERVICE_TYPE] @units = fields[DS_UNITS] @call_count = fields[DS_CALL_COUNT].to_i @start_date = Time.parse(fields[DS_START_DATE]).strftime('%d/%m/%Y') fields[16] == '' ? @end_date = '' : @end_date = Time.parse(fields[16]).strftime('%d/%m/%Y') @cost = fields[DS_COST].to_f else raise ArgumentError, "Invalid record type - " + fields[DS_CODE], caller end end |
Instance Attribute Details
#call_count ⇒ Object (readonly)
Returns the value of attribute call_count.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def call_count @call_count end |
#call_type ⇒ Object (readonly)
Returns the value of attribute call_type.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def call_type @call_type end |
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def cost @cost end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def end_date @end_date end |
#service_number ⇒ Object (readonly)
Returns the value of attribute service_number.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def service_number @service_number end |
#service_type ⇒ Object (readonly)
Returns the value of attribute service_type.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def service_type @service_type end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def start_date @start_date end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
17 18 19 |
# File 'lib/tbr/service_summary.rb', line 17 def units @units end |
Instance Method Details
#to_a ⇒ Object
36 37 38 39 40 |
# File 'lib/tbr/service_summary.rb', line 36 def to_a call_count = @call_count == 0 ? call_count = "" : call_count = sprintf("%d",@call_count) cost = sprintf("%0.2f",@cost) [@call_type, @service_type, call_count, @units, cost] end |