-
-
Save 3limin4t0r/9030c9102f8ae4b0744bffb7819fbd38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hostel | |
attr_accessor :anv, :bnv | |
ITEM_NAMES = %w[av bv] # or ['av', 'bv'] | |
def initialize | |
@items = ITEM_NAMES.to_h { |name| [name, []] } | |
end | |
ITEM_NAMES.each do |name| | |
class_eval <<~RUBY, __FILE__, __LINE__ + 1 | |
def #{name} | |
@items[#{name.inspect}] | |
end | |
def #{name}=(value) | |
@items[#{name.inspect}] = value | |
end | |
RUBY | |
end | |
def allot_houses(num, cs, fp) | |
key = "#{cs}#{fp}" | |
if @items.key?(key) | |
@items[key].push(num) | |
else | |
puts 'Nope' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment