class Jaspion::Kilza::Property
Represents a single Class
property
Attributes
Indicates if the property represents an array of objects
Indicates if the property represents an array of objects
Indicates if the property should be used for comparing purposes Used to compare if one object is equal to another one
Indicates if the property should be used for comparing purposes Used to compare if one object is equal to another one
Normalized property name Starts with _ or alphanumeric character and doesn't contain any special character
Original JSON property name
Ruby string type Can be object, fixnum, float, falseclass, trueclass and nilclass
Property
type name
Public Class Methods
Removes everything except numbers and letters.
@param str [String] string to be cleaned
@return [String] cleaned string
# File lib/jaspion/kilza/property.rb, line 82 def self.clean(str) return if str.nil? str.gsub(/[^a-zA-Z0-9]/, '') end
# File lib/jaspion/kilza/property.rb, line 29 def initialize(name, type, array, key = '') @name = Jaspion::Kilza::Property.normalize(name) @original_name = name @type = type @array = array @key = key @original_type = type end
Cleans the string and make it lowercase.
@param str [String] string to be cleaned
@return [String] cleaned string
# File lib/jaspion/kilza/property.rb, line 92 def self.normalize(str) return if str.nil? str = str.gsub(/[^a-zA-Z0-9]/, '_') str = '_' if str.length == 0 str = '_' + str if str[0].number? str.downcase end
Public Instance Methods
# File lib/jaspion/kilza/property.rb, line 58 def ==(pr) @name == pr.name end
# File lib/jaspion/kilza/property.rb, line 46 def boolean? @original_type == 'trueclass' || @original_type == 'falseclass' end
# File lib/jaspion/kilza/property.rb, line 42 def fixnum? @original_type == 'fixnum' end
# File lib/jaspion/kilza/property.rb, line 50 def float? @original_type == 'float' end
# File lib/jaspion/kilza/property.rb, line 54 def null? @original_type == 'nilclass' end
# File lib/jaspion/kilza/property.rb, line 38 def object? @original_type == 'hash' end
# File lib/jaspion/kilza/property.rb, line 68 def to_s { name: @name, original_name: @original_name, type: @type, array?: @array }.to_s end