mercredi 18 octobre 2017

uninitialized method first_name using fixy gem

I am using this gem to help me in making fixed file formatters. I am following the documentation but getting an error

require('fixy')
class Record < Fixy::Record
  include Fixy::Formatter::Alphanumeric
  # Define record length
  set_record_length 20

  # Fields Declaration:
  # -----------------------------------------------------------
  #       name          size      Range             Format
  # ------------------------------------------------------------

  field :first_name,     10,     '1-10' ,      :alphanumeric
  field :last_name ,     10,     '11-20',      :alphanumeric

  # Any required data for the record can be
  # provided through the initializer

  def initialize(first_name, last_name)
    @first_name = first_name
    @last_name  = last_name
  end

  # 2) Using a method definition.
  #    This is most interesting when complex logic is involved.
  def last_name
    @last_name
  end
end

shinken =  Reky.new('Sarah', 'Smith')
p shinken.generate

The last method: shinken.generate gives the error: generate': undefined methodfirst_name' for # (NoMethodError)

What may be causing this?

Aucun commentaire:

Enregistrer un commentaire