Class: StaticStruct::Structure

Inherits:
Object
  • Object
show all
Defined in:
lib/static_struct/structure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Structure

Returns a new instance of Structure.



5
6
7
8
# File 'lib/static_struct/structure.rb', line 5

def initialize(hash)
  @static_methods = []
  define_structure(self, hash)
end

Instance Attribute Details

#static_methodsObject (readonly)

Returns the value of attribute static_methods.



3
4
5
# File 'lib/static_struct/structure.rb', line 3

def static_methods
  @static_methods
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'lib/static_struct/structure.rb', line 17

def ==(other)
  inspect == other.inspect
end

#inspectObject



10
11
12
13
14
15
# File 'lib/static_struct/structure.rb', line 10

def inspect
  methods = static_methods.sort.each_with_object({}) do |method, result|
    result[method] = public_send(method)
  end
  "#<#{self.class} #{methods}>"
end