class Kilza::Property

Represents a single Class property

Attributes

array[RW]

Indicates if the property represents an array of objects

array?[RW]

Indicates if the property represents an array of objects

key[RW]

Indicates if the property should be used for comparing purposes Used to compare if one object is equal to another one

key?[RW]

Indicates if the property should be used for comparing purposes Used to compare if one object is equal to another one

name[RW]

Normalized property name Starts with _ or alphanumeric character and doesn't contain any special character

original_name[RW]

Original JSON property name

original_type[RW]

Ruby string type Can be object, fixnum, float, falseclass, trueclass and nilclass

type[RW]

Property type name

Public Class Methods

new(name, type, array, key) click to toggle source
# File lib/kilza/property.rb, line 28
def initialize(name, type, array, key)
  @name = Kilza.normalize(name)
  @original_name = name
  @type = type
  @array = array
  @key = key
  @original_type = type
end

Public Instance Methods

==(pr) click to toggle source
# File lib/kilza/property.rb, line 57
def ==(pr)
  @name == pr.name
end
boolean?() click to toggle source
# File lib/kilza/property.rb, line 45
def boolean?
  @original_type == 'trueclass' || @original_type == 'falseclass'
end
fixnum?() click to toggle source
# File lib/kilza/property.rb, line 41
def fixnum?
  @original_type == 'fixnum'
end
float?() click to toggle source
# File lib/kilza/property.rb, line 49
def float?
  @original_type == 'float'
end
null?() click to toggle source
# File lib/kilza/property.rb, line 53
def null?
  @original_type == 'nilclass'
end
object?() click to toggle source
# File lib/kilza/property.rb, line 37
def object?
  @original_type == 'hash'
end
to_s() click to toggle source
# File lib/kilza/property.rb, line 61
def to_s
  {
    name: @name,
    original_name: @original_name,
    type: @type,
    array?: @array
  }.to_s
end