Class: Ken::Property
Instance Method Summary collapse
- #expected_type ⇒ Object
- #id ⇒ Object
-
#initialize(data, type) ⇒ Property
constructor
initializes a resource by json result.
- #inspect ⇒ Object
- #master_property ⇒ Object
- #name ⇒ Object
-
#object_type? ⇒ Boolean
returns true if the property is an object type.
- #reverse_property ⇒ Object
- #to_s ⇒ Object
-
#type ⇒ Object
returns the type of which the property is a part of every property always has exactly one type.
-
#unique? ⇒ Boolean
returns true if the property is unique.
-
#value_type? ⇒ Boolean
returns true if the property is a value type.
Constructor Details
#initialize(data, type) ⇒ Property
initializes a resource by json result
5 6 7 8 9 10 |
# File 'lib/ken/property.rb', line 5 def initialize(data, type) raise "error" unless data.kind_of?(Hash) @data = data @type = type self end |
Instance Method Details
#expected_type ⇒ Object
79 80 81 |
# File 'lib/ken/property.rb', line 79 def expected_type @data["expected_type"] end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/ken/property.rb', line 28 def inspect result = "#<Property id=\"#{id}\" expected_type=\"#{expected_type || "nil"}\" unique=\"#{unique?}\" object_type=\"#{object_type?}\">" end |
#master_property ⇒ Object
46 47 48 |
# File 'lib/ken/property.rb', line 46 def master_property @data["master_property"] end |
#object_type? ⇒ Boolean
returns true if the property is an object type
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ken/property.rb', line 58 def object_type? !%w{ /type/id /type/int /type/float /type/boolean /type/text /type/rawstring /type/uri /type/datetime /type/key }.include?(expected_type) end |
#reverse_property ⇒ Object
41 42 43 |
# File 'lib/ken/property.rb', line 41 def reverse_property @data["reverse_property"] end |
#type ⇒ Object
returns the type of which the property is a part of every property always has exactly one type. that’s why /type/property/schema is a unique property
36 37 38 |
# File 'lib/ken/property.rb', line 36 def type @type end |
#unique? ⇒ Boolean
returns true if the property is unique
52 53 54 |
# File 'lib/ken/property.rb', line 52 def unique? return @data["unique"]==true end |
#value_type? ⇒ Boolean
returns true if the property is a value type
74 75 76 |
# File 'lib/ken/property.rb', line 74 def value_type? !object_type? end |