Class: Unit

Inherits:
Object
  • Object
show all
Defined in:
lib/json/unit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = nil, uid = nil) ⇒ Unit

Returns a new instance of Unit.



6
7
8
9
# File 'lib/json/unit.rb', line 6

def initialize(type = nil, uid = nil)
  @type = type
  @uid = uid
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/json/unit.rb', line 4

def type
  @type
end

#uidObject

Returns the value of attribute uid.



4
5
6
# File 'lib/json/unit.rb', line 4

def uid
  @uid
end

Instance Method Details

#==(o) ⇒ Object



11
12
13
14
15
16
# File 'lib/json/unit.rb', line 11

def ==(o)
  return true if self.object_id == o.object_id
  return false if o.nil? || self.class != o.class

  @type == o.type && @uid == o.uid
end

#hash_codeObject



18
19
20
21
22
# File 'lib/json/unit.rb', line 18

def hash_code
  {
    type: @type, uid: @uid
  }
end

#to_sObject



24
25
26
27
28
29
# File 'lib/json/unit.rb', line 24

def to_s
  "Unit{" +
    "type='" + @type + "'" +
    ", uid=" + @uid +
    "}"
end