lib/uniprot_parser/protein.rb
def method_missing (m, *args)
      if m =~ /dr_\S+/
        return Array.new

      elsif(tmp = (m.to_s.match(/append_(..)/)))

        instance_variable_set("@#{tmp[1]}_block".to_sym, args[0])

        #create accessor
        self.class.send(:define_method,"#{tmp[1]}_block") do ||
          instance_variable_get("@#{tmp[1]}_block").strip
        end

        #create append_** method
        self.class.send(:define_method,"append_#{tmp[1]}") do |l|
          instance_variable_set("@#{tmp[1]}_block", '') unless instance_variable_defined? "@#{tmp[1]}_block"
          instance_variable_get("@#{tmp[1]}_block").insert -1, l
        end

      else
        super.method_missing(m, *args)
      end
    end
# Override Object.method_missing in a way to create
# needed append_  and related accessor method to
# manage diffrent type line
Override Object.method_missing in a way to create
needed append_  and related accessor method to
manage diffrent type line
Override Object . method_missing in a way to create needed append_ and related accessor method to manage diffrent type line
def method_missing (m, *args)
      if m =~ /dr_\S+/
        return Array.new
      elsif(tmp = (m.to_s.match(/append_(..)/)))
        instance_variable_set("@#{tmp[1]}_block".to_sym, args[0])
        self.class.send(:define_method,"#{tmp[1]}_block") do ||
          instance_variable_get("@#{tmp[1]}_block").strip
        end
        self.class.send(:define_method,"append_#{tmp[1]}") do |l|
          instance_variable_set("@#{tmp[1]}_block", '') unless instance_variable_defined? "@#{tmp[1]}_block"
          instance_variable_get("@#{tmp[1]}_block").insert -1, l
        end
      else
        super.method_missing(m, *args)
      end
    end
def method_missing ( m , * args ) if m =~ / dr_ \S + / return Array . new elsif ( tmp = ( m . to_s . match ( / append_(..) / ) ) ) instance_variable_set ( "@#{tmp[1]}_block" . to_sym , args [ 0 ] ) self . class . send ( :define_method , "#{tmp[1]}_block" ) do | | instance_variable_get ( "@#{tmp[1]}_block" ) . strip end self . class . send ( :define_method , "append_#{tmp[1]}" ) do | l | instance_variable_set ( "@#{tmp[1]}_block" , '' ) unless instance_variable_defined? "@#{tmp[1]}_block" instance_variable_get ( "@#{tmp[1]}_block" ) . insert - 1 , l end else super . method_missing ( m , * args ) end end
Override Object.method_missing in a way to create
needed append_  and related accessor method to
manage diffrent type line
Override Object . method_missing in a way to create needed append_ and related accessor method to manage diffrent type line
#create accessor #create append_** method
m
args