Class: StaticStruct::Structure

Inherits:
Object
  • Object
show all
Includes:
Enumerable
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.



9
10
11
12
# File 'lib/static_struct/structure.rb', line 9

def initialize(hash)
  @static_methods = SortedSet.new
  define_structure(self, hash)
end

Instance Attribute Details

#static_methodsObject (readonly)

Returns the value of attribute static_methods.



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

def static_methods
  @static_methods
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/static_struct/structure.rb', line 22

def ==(other)
  current_state == other.current_state
end

#eachObject



26
27
28
29
30
# File 'lib/static_struct/structure.rb', line 26

def each
  static_methods.each do |m|
    yield m, public_send(m)
  end
end

#to_sObject



14
15
16
17
18
19
20
# File 'lib/static_struct/structure.rb', line 14

def to_s
  joined_line = [self.class, current_state].map(&:to_s).select do |str|
    str.size > 0
  end.join(' ')

  "#<#{joined_line}>"
end