Class: TrueClass
- Inherits:
-
Object
- Object
- TrueClass
- Defined in:
- lib/santas_little_helper.rb
Overview
When something is True / False and I can to_s it, why can’t I to_i it? There is actually a good theoretical reason, but in real world it really helps if you can output true or false as an int when you are sending soap request to a client, whose api requires it as 1 or 0, or humanize to “yes” & “no” form. For an alternative solution check out www.ruby-forum.com/topic/206789#new
Instance Method Summary collapse
-
#to_h ⇒ Object
Humanize.
-
#to_i ⇒ Object
Rails conventions for boolean / tinyint.
-
#to_teenager ⇒ Object
Really I need to spell it out to you?.
Instance Method Details
#to_h ⇒ Object
Humanize. to_s returns “true”
63 64 65 |
# File 'lib/santas_little_helper.rb', line 63 def to_h "yes" end |
#to_i ⇒ Object
Rails conventions for boolean / tinyint
58 59 60 |
# File 'lib/santas_little_helper.rb', line 58 def to_i 1 end |
#to_teenager ⇒ Object
Really I need to spell it out to you?
68 69 70 |
# File 'lib/santas_little_helper.rb', line 68 def to_teenager "Yeah, yeah. Here you go. Did you get what you came for? Now disappear." end |