Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created May 7, 2009 07:17
Show Gist options
  • Select an option

  • Save ukstudio/107967 to your computer and use it in GitHub Desktop.

Select an option

Save ukstudio/107967 to your computer and use it in GitHub Desktop.
# coding: utf-8
# 定数をモジュールにすることでグルーピングする試み
class Foo
module Statuses
INVALID = 0
VALID = 1
end
include Statuses
def initialize(status_code)
@status_code = status_code
end
def status
case @status_code
when INVALID
'だめです'
when VALID
'大丈夫です'
end
end
end
puts Foo.new(Foo::Statuses::INVALID).status
puts Foo.new(Foo::Statuses::VALID).status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment