Skip to content

Instantly share code, notes, and snippets.

@mizukmb
Last active July 17, 2016 11:39
Show Gist options
  • Save mizukmb/8523f0623febdd81a8c478703a8ee8e2 to your computer and use it in GitHub Desktop.
Save mizukmb/8523f0623febdd81a8c478703a8ee8e2 to your computer and use it in GitHub Desktop.
class Nozaki
attr_reader :status
def initialize(status="嫌い")
@status = status
end
def 反対の
s = 好き? ^ true ? "好き" : "嫌い"
Nozaki.new(s)
end
def 反対は
print self.反対の.to_s
end
def inspect
print "<Class: #{self.class} #{self.object_id}|#{self.status}>"
end
def to_s
好き? == true ? "好き" : "嫌い"
end
private
def 好き?
self.status == "好き" ? true : false
end
end
@mizukmb
Copy link
Author

mizukmb commented Jul 17, 2016

Usage

[1] pry(main)> require "./nozaki"
=> true
[2] pry(main)> 嫌いの = Nozaki.new
<Class: Nozaki 70305173626980|嫌い>=> #<Nozaki:0x3ff132e66064>
[3] pry(main)> 嫌いの.反対は
好き=> nil
[4] pry(main)> 嫌いの.反対の.反対は
嫌い=> nil
[5] pry(main)> 嫌いの.反対の.反対の.反対の.反対の.反対の.反対の.反対は
好き=> nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment