Class: JSON2Ruby::Attribute
- Inherits:
-
Object
- Object
- JSON2Ruby::Attribute
- Defined in:
- lib/json2ruby/attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#original_name ⇒ Object
Returns the value of attribute original_name.
-
#ruby_type ⇒ Object
Returns the value of attribute ruby_type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attr_hash ⇒ Object
-
#initialize(name, ruby_type = nil) ⇒ Attribute
constructor
A new instance of Attribute.
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
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/json2ruby/attribute.rb', line 5 def name @name end |
#original_name ⇒ Object
Returns the value of attribute original_name.
5 6 7 |
# File 'lib/json2ruby/attribute.rb', line 5 def original_name @original_name end |
#ruby_type ⇒ Object
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_name ⇒ Object
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_hash ⇒ Object
16 17 18 |
# File 'lib/json2ruby/attribute.rb', line 16 def attr_hash Digest::MD5.hexdigest("#{@name}:#{@ruby_type}") end |