Class: Pinch::Unit
- Inherits:
-
Object
- Object
- Pinch::Unit
- Defined in:
- lib/pinch/models/unit.rb
Instance Attribute Summary collapse
-
#floor_number ⇒ String
readonly
TODO: Write general description for this method.
-
#french_floor_number ⇒ String
readonly
TODO: Write general description for this method.
-
#id ⇒ Integer
readonly
TODO: Write general description for this method.
-
#kind ⇒ String
readonly
TODO: Write general description for this method.
-
#reference ⇒ String
readonly
TODO: Write general description for this method.
-
#tenant_name ⇒ String
readonly
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
Instance Method Summary collapse
-
#initialize(id = nil, reference = nil, tenant_name = nil, floor_number = nil, kind = nil, french_floor_number = nil) ⇒ Unit
constructor
A new instance of Unit.
-
#key_map ⇒ Object
Defines the key map for json serialization.
- #method_missing(method_name) ⇒ Object
-
#to_json ⇒ Object
Creates JSON of the curent object.
Constructor Details
#initialize(id = nil, reference = nil, tenant_name = nil, floor_number = nil, kind = nil, french_floor_number = nil) ⇒ Unit
Returns a new instance of Unit.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pinch/models/unit.rb', line 30 def initialize(id = nil, reference = nil, tenant_name = nil, floor_number = nil, kind = nil, french_floor_number = nil) @id = id @reference = reference @tenant_name = tenant_name @floor_number = floor_number @kind = kind @french_floor_number = french_floor_number end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
45 46 47 |
# File 'lib/pinch/models/unit.rb', line 45 def method_missing(method_name) puts "There is no method called '#{method_name}'." end |
Instance Attribute Details
#floor_number ⇒ String (readonly)
TODO: Write general description for this method
20 21 22 |
# File 'lib/pinch/models/unit.rb', line 20 def floor_number @floor_number end |
#french_floor_number ⇒ String (readonly)
TODO: Write general description for this method
28 29 30 |
# File 'lib/pinch/models/unit.rb', line 28 def french_floor_number @french_floor_number end |
#id ⇒ Integer (readonly)
TODO: Write general description for this method
8 9 10 |
# File 'lib/pinch/models/unit.rb', line 8 def id @id end |
#kind ⇒ String (readonly)
TODO: Write general description for this method
24 25 26 |
# File 'lib/pinch/models/unit.rb', line 24 def kind @kind end |
#reference ⇒ String (readonly)
TODO: Write general description for this method
12 13 14 |
# File 'lib/pinch/models/unit.rb', line 12 def reference @reference end |
#tenant_name ⇒ String (readonly)
TODO: Write general description for this method
16 17 18 |
# File 'lib/pinch/models/unit.rb', line 16 def tenant_name @tenant_name end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/pinch/models/unit.rb', line 56 def self.from_hash(hash) if hash == nil nil else # Extract variables from the hash id = hash["id"] reference = hash["reference"] tenant_name = hash["tenant_name"] floor_number = hash["floor_number"] kind = hash["kind"] french_floor_number = hash["french_floor_number"] # Create object from extracted values Unit.new(id, reference, tenant_name, floor_number, kind, french_floor_number) end end |
Instance Method Details
#key_map ⇒ Object
Defines the key map for json serialization
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/pinch/models/unit.rb', line 78 def key_map hash = {} hash['id'] = id hash['reference'] = reference hash['tenant_name'] = tenant_name hash['floor_number'] = floor_number hash['kind'] = kind hash['french_floor_number'] = french_floor_number hash end |
#to_json ⇒ Object
Creates JSON of the curent object
50 51 52 53 |
# File 'lib/pinch/models/unit.rb', line 50 def to_json hash = key_map hash.to_json end |