Class: Attribute

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, value = nil, set_at = nil) ⇒ Attribute

Returns a new instance of Attribute.



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

def initialize(name = nil, value = nil, set_at = nil)
  @name = name
  @value = value
  @set_at = set_at
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#set_atObject

Returns the value of attribute set_at.



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

def set_at
  @set_at
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#==(o) ⇒ Object



12
13
14
15
16
17
# File 'lib/json/attribute.rb', line 12

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

  @name == o.name && @value == o.value && @set_at == o.set_at
end

#hash_codeObject



19
20
21
# File 'lib/json/attribute.rb', line 19

def hash_code
  { name: @name, value: @value, set_at: @set_at }
end

#to_sObject



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

def to_s
  "Attribute{" +
    "name='#{@name}'" +
    ", value=#{@value}" +
    ", setAt=#{@set_at}" +
    "}"
end