Class: CoffeeOutside::PriorLocationsFile

Inherits:
Object
  • Object
show all
Defined in:
lib/coffeeoutside/locations.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename = "./prior_locations.yaml") ⇒ PriorLocationsFile

Returns a new instance of PriorLocationsFile.



129
130
131
132
133
134
135
136
# File 'lib/coffeeoutside/locations.rb', line 129

def initialize(filename = "./prior_locations.yaml")
  @filename = filename
  @locations = if File.exist? filename
                 YAML.load_file(filename) || []
               else
                 []
               end
end

Instance Method Details

#append_location(location) ⇒ Object



142
143
144
145
146
# File 'lib/coffeeoutside/locations.rb', line 142

def append_location(location)
  @locations.append location.name
  f = File.open(@filename, "w")
  f.write(YAML.dump(@locations))
end

#previous_locationsObject



138
139
140
# File 'lib/coffeeoutside/locations.rb', line 138

def previous_locations
  @locations
end