Skip to content

Instantly share code, notes, and snippets.

@trappist
Created August 31, 2013 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trappist/6400200 to your computer and use it in GitHub Desktop.
Save trappist/6400200 to your computer and use it in GitHub Desktop.
class Sizes::CupSize < Size
US = %w[A B C D DD/E DDD/F DDDD/G DDDDD/H]
EU = %w[A B C D E F G H]
UK = %w[A B C D DD E F FF]
[:us, :uk, :eu].each do |region|
class_eval %Q"
def #{region}
by_region(:#{region})
end
"
end
private
def by_region(r)
"Sizes::CupSize::#{r.to_s.upcase}".constantize[read_attribute(r).to_i-1]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment