Class: JSON2Ruby::Primitive

Inherits:
Object
  • Object
show all
Defined in:
lib/json2ruby/primitive.rb

Overview

Represents a JSON Primitive. You should not instantiate this class - use the static instances:

  • JSON2Ruby::RUBYSTRING for JSON Strings

  • JSON2Ruby::RUBYINTEGER for JSON Integers

  • JSON2Ruby::RUBYFLOAT for JSON Floats

  • JSON2Ruby::RUBYBOOLEAN for JSON Booleans

  • JSON2Ruby::RUBYNUMERIC for JSON Numerics (Integers or floats)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attr_hash) ⇒ Primitive

Create a new Primitive with the specified name and attr_hash



22
23
24
25
# File 'lib/json2ruby/primitive.rb', line 22

def initialize(name, attr_hash)
  @name = name
  @attr_hash = attr_hash
end

Instance Attribute Details

#attr_hashObject

The static attr_hash of the Primitive.



14
15
16
# File 'lib/json2ruby/primitive.rb', line 14

def attr_hash
  @attr_hash
end

#nameObject

The String name of the Primitive.



10
11
12
# File 'lib/json2ruby/primitive.rb', line 10

def name
  @name
end

#original_nameObject

String Exists for compatibility.



12
13
14
# File 'lib/json2ruby/primitive.rb', line 12

def original_name
  @original_name
end

Class Method Details

.short_nameObject

The short name is ‘Primitive’



17
18
19
# File 'lib/json2ruby/primitive.rb', line 17

def self.short_name
  "Primitive"
end

Instance Method Details

#commentObject

Return the name of the Primitive



28
29
30
# File 'lib/json2ruby/primitive.rb', line 28

def comment
  @name
end