Sha256: 2c447de546f0052c812a4b4459a63eef3e82b8f9679fd47981a18cdfccee19ac

Contents?: true

Size: 530 Bytes

Versions: 2

Compression:

Stored size: 530 Bytes

Contents

class Person
  include Polaroid.new(:name, :age, :favorite_drinks)

  attr_reader :name, :age, :favorites

  def initialize(name, age, favorites)
    @name       = name
    @age        = age
    @favorites  = favorites
  end

  def favorite_drinks
    favorites.select { |fav| drink?(fav) }
  end

  def favorite_foods
    favorites.select { |fav| food?(fav) }
  end

  def drink?(str)
    %w[coffee beer wine tea water juice].include?(str)
  end

  def food?(str)
    %w[omelete burrito ramen pie yogurt].include?(str)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polaroid-1.0.0 test/sample_implementations/person.rb
polaroid-0.0.5 test/sample_implementations/person.rb