Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update read me to be copy/pastable runnable #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakebruemmer
Copy link

I was looking through this repo and decided to run the code listed in the README after installing the gem. I got an error:

2.5.0 :001 > require 'metro_2'
 => true 
2.5.0 :002 > metro_2_content = Metro2::Metro2File.new
metro_2_content.header.cycle_number = 15
metro_2_content.header.equifax_program_identifier = 'EFAXID'
metro_2_content.header.transunion_program_identifier = 'TRANSUNION'
# ... other header segment attributes

base_segment = Metro2::Records::BaseSegment.new
base_segment.time_stamp = Time.new(2014, 9, 15, 17, 7, 45)
base_segment.identification_number = 'REPORTERXYZ'
base_segment.cycle_number = 1
base_segment.consumer_account_number = 'ABC123'
base_segment.portfolio_type = 'I'
# ... other base segment attributes
metro_2_content.base_segments << base_segment
# add more base segments as needed

metro_2_content.to_s # contents to write to file => #<Metro2::Metro2File:0x00007fd7df8adce8 @base_segments=[], @header=#<Metro2::Records::HeaderSegment:0x00007fd7df8adc98>> 
2.5.0 :003 >  => 15 
2.5.0 :004 >  => "EFAXID" 
2.5.0 :005 >  => "TRANSUNION" 
2.5.0 :006 >  => nil 
2.5.0 :007 > 2.5.0 :008 >  => #<Metro2::Records::BaseSegment:0x00007fd7df84b6d8 @appendages=[]> 
2.5.0 :009 >  => 2014-09-15 17:07:45 -0500 
2.5.0 :010 >  => "REPORTERXYZ" 
2.5.0 :011 >  => 1 
2.5.0 :012 >  => "ABC123" 
2.5.0 :013 >  => "I" 
2.5.0 :014 >  => nil 
2.5.0 :015 >  => [#<Metro2::Records::BaseSegment:0x00007fd7df84b6d8 @appendages=[], @time_stamp=2014-09-15 17:07:45 -0500, @identification_number="REPORTERXYZ", @cycle_number=1, @consumer_account_number="ABC123", @portfolio_type="I">] 
2.5.0 :016 >  => nil 
2.5.0 :017 > 2.5.0 :018 > exit
Traceback (most recent call last):
        6: from /Users/jake/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
        5: from (irb):18
        4: from /Users/jake/.rvm/gems/ruby-2.5.0/gems/metro_2-1.2.4/lib/metro_2/metro2_file.rb:20:in `to_s'
        3: from /Users/jake/.rvm/gems/ruby-2.5.0/gems/metro_2-1.2.4/lib/metro_2/metro2_file.rb:34:in `trailer_from_base_segments'
        2: from /Users/jake/.rvm/gems/ruby-2.5.0/gems/metro_2-1.2.4/lib/metro_2/metro2_file.rb:34:in `each'
        1: from /Users/jake/.rvm/gems/ruby-2.5.0/gems/metro_2-1.2.4/lib/metro_2/metro2_file.rb:35:in `block in trailer_from_base_segments'
NoMethodError (undefined method `upcase' for nil:NilClass)

which is from base_segment.account_status being nil since it's not set in the code. This PR adds a line to the README with an account_status for a current loan. The result:

2.5.0 :001 > require 'metro_2'
 => true 
2.5.0 :002 > metro_2_content = Metro2::Metro2File.new
metro_2_content.header.cycle_number = 15
metro_2_content.header.equifax_program_identifier = 'EFAXID'
metro_2_content.header.transunion_program_identifier = 'TRANSUNION'
# ... other header segment attributes

base_segment = Metro2::Records::BaseSegment.new
base_segment.time_stamp = Time.new(2014, 9, 15, 17, 7, 45)
base_segment.identification_number = 'REPORTERXYZ'
base_segment.cycle_number = 1
base_segment.consumer_account_number = 'ABC123'
base_segment.portfolio_type = 'I'
base_segment.account_status = '11'
# ... other base segment attributes
metro_2_content.base_segments << base_segment
# add more base segments as needed

metro_2_content.to_s # contents to write to file => #<Metro2::Metro2File:0x00007fa9991aaf50 @base_segments=[], @header=#<Metro2::Records::HeaderSegment:0x00007fa9991aaf00>> 
2.5.0 :003 >  => 15 
2.5.0 :004 >  => "EFAXID" 
2.5.0 :005 >  => "TRANSUNION" 
2.5.0 :006 >  => nil 
2.5.0 :007 > 2.5.0 :008 >  => #<Metro2::Records::BaseSegment:0x00007fa999162980 @appendages=[]> 
2.5.0 :009 >  => 2014-09-15 17:07:45 -0500 
2.5.0 :010 >  => "REPORTERXYZ" 
2.5.0 :011 >  => 1 
2.5.0 :012 >  => "ABC123" 
2.5.0 :013 >  => "I" 
2.5.0 :014 >  => "11" 
2.5.0 :015 >  => nil 
2.5.0 :016 >  => [#<Metro2::Records::BaseSegment:0x00007fa999162980 @appendages=[], @time_stamp=2014-09-15 17:07:45 -0500, @identification_number="REPORTERXYZ", @cycle_number=1, @consumer_account_number="ABC123", @portfolio_type="I", @account_status="11">] 
2.5.0 :017 >  => nil 
2.5.0 :018 > 2.5.0 :019 > 
 => "0426HEADER15          EFAXID         TRANSUNION00000000000000000000000000000000                                                                                                                                        0000000000Upstart Engineer metro 2 gem            01204                                                                                                                                                            \n04261091520141707450REPORTERXYZ         1 ABC123                        I  00000000000000000000000000    00000000000000000011                             00000000000000000000000000000000000000000000000000000000000                                                                                    000000000000000000000000000                                                                                                      \n0426TRAILER000000001         000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000                   \n"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant