Class: JSON2Ruby::Attribute

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, ruby_type = nil) ⇒ Attribute

Returns a new instance of Attribute.



11
12
13
14
# File 'lib/json2ruby/attribute.rb', line 11

def initialize(name, ruby_type = nil)
  @name = name
  @ruby_type = ruby_type || "_unknown"
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/json2ruby/attribute.rb', line 5

def name
  @name
end

#original_nameObject

Returns the value of attribute original_name.



5
6
7
# File 'lib/json2ruby/attribute.rb', line 5

def original_name
  @original_name
end

#ruby_typeObject

Returns the value of attribute ruby_type.



5
6
7
# File 'lib/json2ruby/attribute.rb', line 5

def ruby_type
  @ruby_type
end

Class Method Details

.short_nameObject



7
8
9
# File 'lib/json2ruby/attribute.rb', line 7

def self.short_name
  "Attribute"
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
# File 'lib/json2ruby/attribute.rb', line 20

def ==(other)
  return false if other.class != self.class
  attr_hash == other.attr_hash
end

#attr_hashObject



16
17
18
# File 'lib/json2ruby/attribute.rb', line 16

def attr_hash
  Digest::MD5.hexdigest("#{@name}:#{@ruby_type}")
end