Class: JsonRander::JSpecialValue

Inherits:
Object
  • Object
show all
Defined in:
lib/json_rander/json_special_builder.rb

Overview

special value: true/false/nil

Instance Method Summary collapse

Constructor Details

#initializeJSpecialValue

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_sObject



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