class Pantry

This class is responsible for parsing the user ingredients, delivered in a .txt file, and putting it into an array that Reverser can work with.

Attributes

filepath[RW]

This is the user-provided filepath name that parse will use to generate an array.

list[R]

This is where the pantry ingredients array will be stored.

Public Class Methods

new(filepath) click to toggle source

This method creates a new Pantry object that takes the filepath of a text file, and is described by an array of the contents.

# File lib/tee_reverser/pantry.rb, line 14
def initialize(filepath)
        @filepath = filepath
        @list = []
end

Public Instance Methods

parse() click to toggle source

This method opens the filepath given and produces a one-dimensional array called list.

# File lib/tee_reverser/pantry.rb, line 21
def parse
        CSV.foreach(self.filepath) {|row| @list << row}
        @list.flatten!
end