Class: StaticStruct::Structure
- Inherits:
-
Object
- Object
- StaticStruct::Structure
- Defined in:
- lib/static_struct/structure.rb
Instance Attribute Summary collapse
-
#static_methods ⇒ Object
readonly
Returns the value of attribute static_methods.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each ⇒ Object
-
#initialize(hash) ⇒ Structure
constructor
A new instance of Structure.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ Structure
Returns a new instance of Structure.
7 8 9 10 |
# File 'lib/static_struct/structure.rb', line 7 def initialize(hash) @static_methods = SortedSet.new define_structure(hash) end |
Instance Attribute Details
#static_methods ⇒ Object (readonly)
Returns the value of attribute static_methods.
5 6 7 |
# File 'lib/static_struct/structure.rb', line 5 def static_methods @static_methods end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 |
# File 'lib/static_struct/structure.rb', line 24 def ==(other) current_state == other.current_state end |
#each ⇒ Object
28 29 30 31 32 |
# File 'lib/static_struct/structure.rb', line 28 def each static_methods.each do |m| yield m, public_send(m) end end |
#inspect ⇒ Object
20 21 22 |
# File 'lib/static_struct/structure.rb', line 20 def inspect to_s end |
#to_s ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/static_struct/structure.rb', line 12 def to_s joined_line = [self.class, current_state].map(&:to_s).select do |str| str.size > 0 end.join(' ') "#<#{joined_line}>" end |