Class: GlobalCollect::LogParsing::CollectionReport::ReportFile
- Inherits:
-
Object
- Object
- GlobalCollect::LogParsing::CollectionReport::ReportFile
- Defined in:
- lib/global_collect/log_parsing/collection_report/report_file.rb
Constant Summary collapse
- FILENAME_FORMAT =
RG - Ch8 => Technical aspects => File name 4 chars numeric account id, 4 chars numeric master account id, 1 char numeric year, 3 char numeric day-of-year, extension /mtd+/ if production, and no test equivalent.
/^(\d{4})(\d{4})(\d{1})(\d{3})\.mt\d+$/
- YEAR_BASE_ADJUSTED =
( Date.today.year * 10 ) / 10
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#master_account_id ⇒ Object
readonly
Returns the value of attribute master_account_id.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ ReportFile
constructor
A new instance of ReportFile.
- #parse ⇒ Object
Constructor Details
#initialize(path) ⇒ ReportFile
Returns a new instance of ReportFile.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 11 def initialize(path) @path = path if File.basename(path) =~ FILENAME_FORMAT @account_id = $1 @master_account_id = $2 @date = Date.ordinal(YEAR_BASE_ADJUSTED + $3.to_i, $4.to_i) @environment = :production else raise ArgumentError.new("Unparseable path '#{path}'!") end end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
3 4 5 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 3 def account_id @account_id end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 3 def data @data end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 3 def date @date end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
3 4 5 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 3 def environment @environment end |
#master_account_id ⇒ Object (readonly)
Returns the value of attribute master_account_id.
3 4 5 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 3 def master_account_id @master_account_id end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 3 def path @path end |
Instance Method Details
#parse ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/global_collect/log_parsing/collection_report/report_file.rb', line 23 def parse begin file = File.open(@path, "r") @data = GlobalCollect::LogParsing::CollectionReport::Parser.parse(file) ensure file.close end end |