Class: JsonRander::JSpecialValue
- Inherits:
-
Object
- Object
- JsonRander::JSpecialValue
- Defined in:
- lib/json_rander/json_special_builder.rb
Overview
special value: true/false/nil
Instance Method Summary collapse
-
#initialize ⇒ JSpecialValue
constructor
A new instance of JSpecialValue.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ JSpecialValue
Returns a new instance of JSpecialValue.
4 5 6 |
# File 'lib/json_rander/json_special_builder.rb', line 4 def initialize value = [true, false, nil].sample end |
Instance Method Details
#to_s ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/json_rander/json_special_builder.rb', line 8 def to_s case @value when true return 'true' when false return 'false' when nil return 'null' end end |