Class: Jaspion::Kilza::Property
- Inherits:
-
Object
- Object
- Jaspion::Kilza::Property
- Defined in:
- lib/jaspion/kilza/property.rb
Overview
Represents a single Class property
Instance Attribute Summary collapse
-
#array ⇒ Object
(also: #array?)
Indicates if the property represents an array of objects.
-
#key ⇒ Object
(also: #key?)
Indicates if the property should be used for comparing purposes Used to compare if one object is equal to another one.
-
#name ⇒ Object
Normalized property name Starts with _ or alphanumeric character and doesn’t contain any special character.
-
#original_name ⇒ Object
Original JSON property name.
-
#original_type ⇒ Object
Ruby string type Can be object, fixnum, float, falseclass, trueclass and nilclass.
-
#type ⇒ Object
Property type name.
Instance Method Summary collapse
- #==(pr) ⇒ Object
- #boolean? ⇒ Boolean
- #fixnum? ⇒ Boolean
- #float? ⇒ Boolean
-
#initialize(name, type, array, key) ⇒ Property
constructor
A new instance of Property.
- #null? ⇒ Boolean
- #object? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, type, array, key) ⇒ Property
Returns a new instance of Property.
29 30 31 32 33 34 35 36 |
# File 'lib/jaspion/kilza/property.rb', line 29 def initialize(name, type, array, key) @name = Kilza.normalize(name) @original_name = name @type = type @array = array @key = key @original_type = type end |
Instance Attribute Details
#array ⇒ Object Also known as: array?
Indicates if the property represents an array of objects
21 22 23 |
# File 'lib/jaspion/kilza/property.rb', line 21 def array @array end |
#key ⇒ Object Also known as: key?
Indicates if the property should be used for comparing purposes Used to compare if one object is equal to another one
26 27 28 |
# File 'lib/jaspion/kilza/property.rb', line 26 def key @key end |
#name ⇒ Object
Normalized property name Starts with _ or alphanumeric character and doesn’t contain any special character
8 9 10 |
# File 'lib/jaspion/kilza/property.rb', line 8 def name @name end |
#original_name ⇒ Object
Original JSON property name
11 12 13 |
# File 'lib/jaspion/kilza/property.rb', line 11 def original_name @original_name end |
#original_type ⇒ Object
Ruby string type Can be object, fixnum, float, falseclass, trueclass and nilclass
15 16 17 |
# File 'lib/jaspion/kilza/property.rb', line 15 def original_type @original_type end |
#type ⇒ Object
Property type name
18 19 20 |
# File 'lib/jaspion/kilza/property.rb', line 18 def type @type end |
Instance Method Details
#==(pr) ⇒ Object
58 59 60 |
# File 'lib/jaspion/kilza/property.rb', line 58 def ==(pr) @name == pr.name end |
#boolean? ⇒ Boolean
46 47 48 |
# File 'lib/jaspion/kilza/property.rb', line 46 def boolean? @original_type == 'trueclass' || @original_type == 'falseclass' end |
#fixnum? ⇒ Boolean
42 43 44 |
# File 'lib/jaspion/kilza/property.rb', line 42 def fixnum? @original_type == 'fixnum' end |
#float? ⇒ Boolean
50 51 52 |
# File 'lib/jaspion/kilza/property.rb', line 50 def float? @original_type == 'float' end |
#null? ⇒ Boolean
54 55 56 |
# File 'lib/jaspion/kilza/property.rb', line 54 def null? @original_type == 'nilclass' end |
#object? ⇒ Boolean
38 39 40 |
# File 'lib/jaspion/kilza/property.rb', line 38 def object? @original_type == 'hash' end |
#to_s ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/jaspion/kilza/property.rb', line 62 def to_s { name: @name, original_name: @original_name, type: @type, array?: @array }.to_s end |